Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. """
  2. A collection of model class for the mobile ui service.
  3. """
  4.  
  5.  
  6. class Discount(object):
  7. """
  8. Describes the a particular discount attached to an offer.
  9.  
  10. One offer might have a discount for outside gas purchases and inside convenience store
  11. purchases. Each discount is attached to an offer and maybe accepted seperately.
  12.  
  13. Members:
  14. id: The id of this discount. An increasing numberic value.
  15.  
  16. """
  17.  
  18. id = 0
  19. type = ''
  20. percentOff = '15'
  21. text = 'Offer text'
  22.  
  23.  
  24. class CashAmount(object):
  25. """
  26. A cash amount in a given currency code.
  27.  
  28. Members:
  29. amount: a floating point amount of money.
  30. currencyCode: The currency code this money amount is in.
  31. """
  32. amount = 1.0
  33. currencyCode = ''
  34.  
  35.  
  36. class OfferEarnings(object):
  37. """
  38. The amount of money the user recieved for a given discount on a given offer.
  39.  
  40. Members:
  41. discountId: The discount tied to this OfferEarnings
  42. transactionId: The UUID of the transaction that caused the user to earn this money.
  43. amountEarned: The amount of money earned for this discount.
  44. """
  45. discountId = 1
  46. transactionUuid = ''
  47. amountEarned = CashAmount()
  48.  
  49.  
  50. class OfferState(object):
  51. """
  52. The current state of this offer and points in time the state changed.
  53.  
  54. Possible states are: CREATED ACCEPTED EXPIRED PAYED
  55.  
  56. Members:
  57. createdAt: The ISO 8601 time string when this offer was created.
  58. acceptedAt: The ISO 8601 time string when this offer was accepted or null.
  59. expiredAt: The ISO 8601 time string when this offer expired or null.
  60. earnings: If the offer was accepted and reconciled, the amount of money
  61. the user received for each discount on the offer.
  62.  
  63. """
  64. status = 'CREATED'
  65. createdAt = ''
  66. acceptedAt = ''
  67. expiredAt = ''
  68. earnings = []
  69.  
  70.  
  71. class Offer(object):
  72. """
  73. An Offer object describes the details of what the user will
  74. receive should they accept.
  75.  
  76. Additionally the offer object contains the current state of this offer and times the
  77. offer state changed over time.
  78.  
  79. Members:
  80. uuid: The unique identifier for this offer.
  81. userUuid: The user this offer was created for.
  82. siteUuid: The site this offer was created for.
  83. text: Text to be displayed for this offer.
  84. state: The current state of this offer.
  85. discounts: A list of discounts for this offer.
  86. """
  87. uuid = ''
  88. userUuid = ''
  89. siteUuid = ''
  90. text = 'global offer text'
  91. state = OfferState()
  92. discounts = []
  93.  
  94.  
  95. class SiteOffers(object):
  96. """
  97. An order list of offers for a given site.
  98.  
  99. The first offer in the list should be shown to the user.
  100.  
  101. The application may use the next offer to show the user after the first is accepted
  102. without making an additional network call for more offers.
  103.  
  104. If no offers remain for the site another call to GetUser should be made to refresh offers
  105. for all sites
  106.  
  107. In the future we will support retrieving offers by site.
  108.  
  109. Members:
  110. siteUuid: The UUID of the site.
  111. offers: A list of Offer objects.
  112. """
  113. siteUuid = ''
  114. offers = []
  115.  
  116.  
  117. class User(object):
  118. """
  119. The root object for all user data. Contains:
  120. 1. User profile information.
  121. 2. A list of offers to show the user.
  122. 3. A history of past offers shown to the user. Each offer maybe in
  123. one of several states.
  124. 4. The user's current balance available for cash out.
  125.  
  126. Members:
  127. userId: A valid UUID that identifies the user.
  128. firstName: A non empty string of the users first name.
  129. lastName: A non empty string of the usrs' last name.
  130. email: A valid email address for the user.
  131. offers: A list of SiteOffers that represent the current
  132. offers to be shown by site.
  133. offerState: A list of past offers and the state of each offer.
  134. balance: The amount of money available to the user for
  135. cash out with an attachec currency code.
  136. """
  137.  
  138. userId = None
  139. firstName = None
  140. lastName = None
  141. email = None
  142.  
  143. offers = []
  144. offerState = []
  145. balance = CashAmount()
  146.  
  147. def __init__(self):
  148. pass
  149.  
  150.  
  151. """
  152. return {
  153. "userId": get_user.user_id,
  154. "firstName": "John",
  155. "lastName": "Smit",
  156. "email": "mail@host.com",
  157. "offers": [{
  158. "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
  159. "offers": [{
  160. "uuid": "ebe682fc-c64b-11e5-9c4f-72a3db62578c",
  161. "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
  162. "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
  163. "text": "lorem ipsum",
  164. "state": {
  165. "status": "CREATED",
  166. "createdAt": 1454023610000
  167. },
  168. "discounts": [{
  169. "id": 1,
  170. "type": "gas_inside",
  171. "percentOff": "20",
  172. "text": "lorem ipsum"
  173. }
  174. ]
  175. }
  176. ]
  177. }, {
  178. "siteUuid": "93afa13c-c64a-11e5-9c4f-72a3db62578c",
  179. "offers": [{
  180. "uuid": "b681037e-c64d-11e5-9c4f-72a3db62578c",
  181. "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
  182. "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
  183. "text": "lorem ipsum",
  184. "state": {
  185. "status": "CREATED",
  186. "createdAt": 1454023610000
  187. },
  188. "discounts": [{
  189. "id": 1,
  190. "type": "gas_inside",
  191. "percentOff": "15",
  192. "text": "lorem ipsum"
  193. }, {
  194. "id": 2,
  195. "type": "gas_outside",
  196. "discountPerGallon": .05,
  197. "currencyCode": "USD",
  198. "text": "lorem ipsum"
  199. }]
  200. }]
  201. }],
  202. "offerState": [{
  203. "uuid": "ebe682fc-c64b-11e5-9c4f-72a3db62578c",
  204. "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
  205. "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
  206. "text": "lorem ipsum",
  207. "state": {
  208. "status": "ACCEPTED",
  209. "createdAt": 1454023610000,
  210. "acceptedAt": 1454024610000,
  211. "expiredAt": 1454027610000
  212. },
  213. "discounts": [{
  214. "id": 1,
  215. "type": "gas_inside",
  216. "percentOff": "20",
  217. "text": "lorem ipsum"
  218. }]
  219. }, {
  220. "uuid": "b681037e-c64d-11e5-9c4f-72a3db62578c",
  221. "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
  222. "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
  223. "text": "lorem ipsum",
  224. "state": {
  225. "status": "RESOLVED",
  226. "createdAt": 1454023610000,
  227. "acceptedAt": 1454014610000,
  228. "expiredAt": 1454017610000,
  229. "earnings": [{
  230. "discountId": 1,
  231. "transactionUuid": "d803cec8-c64d-11e5-9c4f-72a3db62578c",
  232. "amountEarned": 2.37,
  233. "currencyCode": "USD"
  234. }, {
  235. "discountId": 2,
  236. "transactionUuid": "eb43a27e-c64d-11e5-9c4f-72a3db62578c",
  237. "amountEarned": 5.22,
  238. "currencyCode": "USD"
  239. }]
  240. },
  241. "discounts": [{
  242. "id": 1,
  243. "type": "gas_inside",
  244. "percentOff": "15",
  245. "text": "lorem ipsum"
  246. }, {
  247. "id": 2,
  248. "type": "gas_outside",
  249. "discountPerGallon": .05,
  250. "currencyCode": "USD",
  251. "text": "lorem ipsum"
  252. }]
  253. }, {
  254. "uuid": "ebe682fc-c64b-11e5-9c4f-72a3db62578c",
  255. "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
  256. "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
  257. "text": "lorem ipsum",
  258. "state": {
  259. "status": "EXPIRED",
  260. "createdAt": 1454004510000,
  261. "acceptedAt": 1454004610000,
  262. "expiredAt": 1454007610000,
  263. },
  264. "discounts": [{
  265. "id": 1,
  266. "type": "gas_inside",
  267. "percentOff": "20",
  268. "text": "lorem ipsum"
  269. }]
  270. }],
  271. "balance": 51.0
  272. }
  273. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement