RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
NewsExplore.py
Go to the documentation of this file.
1 from RappCloud.Objects import (
2  File,
3  Payload)
4 
5 from Cloud import (
6  CloudMsg,
7  CloudRequest,
8  CloudResponse)
9 
10 
11 class NewsExplore(CloudMsg):
12  """ NewsExplore Cloud Message object """
13 
14  class Request(CloudRequest):
15  """ News Explore Cloud Request object.
16 
17  NewsExplore.Request
18  """
19  def __init__(self, **kwargs):
20  """!
21  Constructor
22 
23  @param **kwargs - Keyword arguments. Apply values to the request attributes.
24  - @ref news_engine
25  - @ref keywords
26  - @ref exclude_titles
27  - @ref region
28  - @ref topic
29  - @ref num_news
30  """
31 
32  ## The news search engine to use.
33  self.news_engine = ''
34  ## Desired keywords.
35  self.keywords = []
36  ## Reject list of previously read articles, in order to avoid duplicates.
37  self.exclude_titles = []
38  ## Language/Region.
39  self.region = ''
40  ## Main topics, i.e. sports, politics, etc.
41  self.topic = ''
42  ## Number of news stories.
43  self.num_news = 0
44 
45  super(NewsExplore.Request, self).__init__(**kwargs)
46 
47 
48  def make_payload(self):
49  """ Create and return the Payload of the Request. """
50  return Payload(
51  news_engine=self.news_engine,
52  keywords=self.keywords,
53  exclude_titles=self.exclude_titles,
54  region=self.region,
55  topic=self.topic,
56  num_news=self.num_news)
57 
58 
59  def make_files(self):
60  """ Create and return Array of File objects of the Request. """
61  return []
62 
63 
64  class Response(CloudResponse):
65  """ News Explore Cloud Response object.
66 
67  NewsExplore.Response
68  """
69  def __init__(self, **kwargs):
70  """!
71  Constructor
72 
73  @param **kwargs - Keyword arguments. Apply values to the request attributes.
74  - @ref error
75  """
76 
77  ## Error message
78  self.error = ''
79  ## Array of story objects, where story is of structure:
80  # { title: '', content: '', puplisher: '', publishedDate: '', url: '' }
81  self.news_stories = []
82  super(NewsExplore.Response, self).__init__(**kwargs)
83 
84 
85  def __init__(self, **kwargs):
86  """!
87  Constructor
88 
89  @param **kwargs - Keyword argumen.ts. Apply values to the request attributes.
90  - @ref Request.news_engine
91  - @ref Request.keywords
92  - @ref Request.exclude_titles
93  - @ref Request.region
94  - @ref Request.topic
95  - @ref Request.num_news
96  """
97 
98  # Create and hold the Request object for this CloudMsg
100  # Create and hold the Response object for this CloudMsg
102  super(NewsExplore, self).__init__(svcname='news_explore', **kwargs)
103 
104 
news_stories
Array of story objects, where story is of structure: { title: '', content: '', puplisher: ''...
Definition: NewsExplore.py:81
news_engine
The news search engine to use.
Definition: NewsExplore.py:33
exclude_titles
Reject list of previously read articles, in order to avoid duplicates.
Definition: NewsExplore.py:37