File tree Expand file tree Collapse file tree
src/main/java/me/proxer/sample Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ apply plugin : ' java'
2+ apply plugin : ' application'
3+
4+ mainClassName = " me.proxer.sample.News"
5+
6+ run {
7+ standardInput = System . in
8+ }
9+
10+ dependencies {
11+ implementation project(' :library' )
12+ }
Original file line number Diff line number Diff line change 1+ package me .proxer .sample ;
2+
3+ import me .proxer .library .api .ProxerApi ;
4+ import me .proxer .library .api .ProxerException ;
5+
6+ import java .util .Scanner ;
7+ import java .util .stream .Collectors ;
8+
9+ /**
10+ * @author Ruben Gees
11+ */
12+ public class News {
13+
14+ public static void main (String [] args ) {
15+ ProxerApi api = new ProxerApi .Builder (readApiKey ()).build ();
16+
17+ try {
18+ final String news = api .notifications ().news ()
19+ .build ()
20+ .execute ()
21+ .stream ()
22+ .map (newsArticle -> newsArticle .getSubject () + " written by " + newsArticle .getAuthor ())
23+ .collect (Collectors .joining ("\n " ));
24+
25+ System .out .println ();
26+ System .out .println ("These are the latest news:\n " + news );
27+ } catch (ProxerException exception ) {
28+ System .out .println ("Something went wrong: " + exception .getMessage ());
29+ }
30+ }
31+
32+ private static String readApiKey () {
33+ System .out .print ("Please pass your api key: " );
34+
35+ try (final Scanner scanner = new Scanner (System .in )) {
36+ return scanner .next ();
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1- include ' :library'
1+ include ' :library' , ' :sample '
You can’t perform that action at this time.
0 commit comments