RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
Geolocation.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 Geolocation(CloudMsg):
12  """ Geolocation Cloud Message object """
13 
14  class Request(CloudRequest):
15  """ Geolocation Cloud Request object.
16 
17  Geolocation.Request
18  """
19  def __init__(self, **kwargs):
20  """!
21  Constructor
22 
23  @param **kwargs - Keyword arguments. Apply values to the request attributes.
24  - @ref ipaddr
25  - @ref engine
26  """
27 
28  ## The machine's ipv4 address.
29  self.ipaddr = ''
30  ## Engine to use. Defaults to 'ip-api' (Currently the only supported).
31  self.engine = ''
32  super(Geolocation.Request, self).__init__(**kwargs)
33 
34 
35  def make_payload(self):
36  """ Create and return the Payload of the Request. """
37  return Payload(
38  ipaddr=self.ipaddr,
39  engine=self.engine)
40 
41 
42  def make_files(self):
43  """ Create and return Array of File objects of the Request. """
44  return []
45 
46 
47  class Response(CloudResponse):
48  """ Geolocation Cloud Response object.
49 
50  Geolocation.Response
51  """
52  def __init__(self, **kwargs):
53  """!
54  Constructor
55 
56  @param **kwargs - Keyword arguments. Apply values to the request attributes.
57  - @ref error
58  - @ref city
59  - @ref country
60  - @ref country_code
61  - @ref latitude
62  - @ref longtitude
63  - @ref timezone
64  - @ref zip
65  """
66 
67  ## Error message
68  self.error = ''
69  ## City location
70  self.city = ''
71  ## Country location
72  self.country = ''
73  ## Location's country code
74  self.country_code = ''
75  ## The latitude
76  self.latitude = 0.0
77  ## The longtitude
78  self.longtitude = 0.0
79  ## Location region
80  self.region = ''
81  ## Location timezone
82  self.timezone = ''
83  ## Location zip-postal code
84  self.zip = ''
85  super(Geolocation.Response, self).__init__(**kwargs)
86 
87 
88  def __init__(self, **kwargs):
89  """!
90  Constructor
91 
92  @param **kwargs - Keyword argumen.ts. Apply values to the request attributes.
93  - @ref Request.ipaddr
94  - @ref Request.engine
95  """
96 
97  # Create and hold the Request object for this CloudMsg
99  # Create and hold the Response object for this CloudMsg
101  super(Geolocation, self).__init__(svcname='geolocation', **kwargs)
102 
103