Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- A collection of model class for the mobile ui service.
- """
- class Discount(object):
- """
- Describes the a particular discount attached to an offer.
- One offer might have a discount for outside gas purchases and inside convenience store
- purchases. Each discount is attached to an offer and maybe accepted seperately.
- Members:
- id: The id of this discount. An increasing numberic value.
- """
- id = 0
- type = ''
- percentOff = '15'
- text = 'Offer text'
- class CashAmount(object):
- """
- A cash amount in a given currency code.
- Members:
- amount: a floating point amount of money.
- currencyCode: The currency code this money amount is in.
- """
- amount = 1.0
- currencyCode = ''
- class OfferEarnings(object):
- """
- The amount of money the user recieved for a given discount on a given offer.
- Members:
- discountId: The discount tied to this OfferEarnings
- transactionId: The UUID of the transaction that caused the user to earn this money.
- amountEarned: The amount of money earned for this discount.
- """
- discountId = 1
- transactionUuid = ''
- amountEarned = CashAmount()
- class OfferState(object):
- """
- The current state of this offer and points in time the state changed.
- Possible states are: CREATED ACCEPTED EXPIRED PAYED
- Members:
- createdAt: The ISO 8601 time string when this offer was created.
- acceptedAt: The ISO 8601 time string when this offer was accepted or null.
- expiredAt: The ISO 8601 time string when this offer expired or null.
- earnings: If the offer was accepted and reconciled, the amount of money
- the user received for each discount on the offer.
- """
- status = 'CREATED'
- createdAt = ''
- acceptedAt = ''
- expiredAt = ''
- earnings = []
- class Offer(object):
- """
- An Offer object describes the details of what the user will
- receive should they accept.
- Additionally the offer object contains the current state of this offer and times the
- offer state changed over time.
- Members:
- uuid: The unique identifier for this offer.
- userUuid: The user this offer was created for.
- siteUuid: The site this offer was created for.
- text: Text to be displayed for this offer.
- state: The current state of this offer.
- discounts: A list of discounts for this offer.
- """
- uuid = ''
- userUuid = ''
- siteUuid = ''
- text = 'global offer text'
- state = OfferState()
- discounts = []
- class SiteOffers(object):
- """
- An order list of offers for a given site.
- The first offer in the list should be shown to the user.
- The application may use the next offer to show the user after the first is accepted
- without making an additional network call for more offers.
- If no offers remain for the site another call to GetUser should be made to refresh offers
- for all sites
- In the future we will support retrieving offers by site.
- Members:
- siteUuid: The UUID of the site.
- offers: A list of Offer objects.
- """
- siteUuid = ''
- offers = []
- class User(object):
- """
- The root object for all user data. Contains:
- 1. User profile information.
- 2. A list of offers to show the user.
- 3. A history of past offers shown to the user. Each offer maybe in
- one of several states.
- 4. The user's current balance available for cash out.
- Members:
- userId: A valid UUID that identifies the user.
- firstName: A non empty string of the users first name.
- lastName: A non empty string of the usrs' last name.
- email: A valid email address for the user.
- offers: A list of SiteOffers that represent the current
- offers to be shown by site.
- offerState: A list of past offers and the state of each offer.
- balance: The amount of money available to the user for
- cash out with an attachec currency code.
- """
- userId = None
- firstName = None
- lastName = None
- email = None
- offers = []
- offerState = []
- balance = CashAmount()
- def __init__(self):
- pass
- """
- return {
- "userId": get_user.user_id,
- "firstName": "John",
- "lastName": "Smit",
- "email": "mail@host.com",
- "offers": [{
- "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
- "offers": [{
- "uuid": "ebe682fc-c64b-11e5-9c4f-72a3db62578c",
- "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
- "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
- "text": "lorem ipsum",
- "state": {
- "status": "CREATED",
- "createdAt": 1454023610000
- },
- "discounts": [{
- "id": 1,
- "type": "gas_inside",
- "percentOff": "20",
- "text": "lorem ipsum"
- }
- ]
- }
- ]
- }, {
- "siteUuid": "93afa13c-c64a-11e5-9c4f-72a3db62578c",
- "offers": [{
- "uuid": "b681037e-c64d-11e5-9c4f-72a3db62578c",
- "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
- "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
- "text": "lorem ipsum",
- "state": {
- "status": "CREATED",
- "createdAt": 1454023610000
- },
- "discounts": [{
- "id": 1,
- "type": "gas_inside",
- "percentOff": "15",
- "text": "lorem ipsum"
- }, {
- "id": 2,
- "type": "gas_outside",
- "discountPerGallon": .05,
- "currencyCode": "USD",
- "text": "lorem ipsum"
- }]
- }]
- }],
- "offerState": [{
- "uuid": "ebe682fc-c64b-11e5-9c4f-72a3db62578c",
- "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
- "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
- "text": "lorem ipsum",
- "state": {
- "status": "ACCEPTED",
- "createdAt": 1454023610000,
- "acceptedAt": 1454024610000,
- "expiredAt": 1454027610000
- },
- "discounts": [{
- "id": 1,
- "type": "gas_inside",
- "percentOff": "20",
- "text": "lorem ipsum"
- }]
- }, {
- "uuid": "b681037e-c64d-11e5-9c4f-72a3db62578c",
- "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
- "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
- "text": "lorem ipsum",
- "state": {
- "status": "RESOLVED",
- "createdAt": 1454023610000,
- "acceptedAt": 1454014610000,
- "expiredAt": 1454017610000,
- "earnings": [{
- "discountId": 1,
- "transactionUuid": "d803cec8-c64d-11e5-9c4f-72a3db62578c",
- "amountEarned": 2.37,
- "currencyCode": "USD"
- }, {
- "discountId": 2,
- "transactionUuid": "eb43a27e-c64d-11e5-9c4f-72a3db62578c",
- "amountEarned": 5.22,
- "currencyCode": "USD"
- }]
- },
- "discounts": [{
- "id": 1,
- "type": "gas_inside",
- "percentOff": "15",
- "text": "lorem ipsum"
- }, {
- "id": 2,
- "type": "gas_outside",
- "discountPerGallon": .05,
- "currencyCode": "USD",
- "text": "lorem ipsum"
- }]
- }, {
- "uuid": "ebe682fc-c64b-11e5-9c4f-72a3db62578c",
- "userUuid": "73983533-afe8-43ea-b89e-17ecfb3b0d14",
- "siteUuid": "a63ec873-a601-4c62-859a-529a3f9d4b4d",
- "text": "lorem ipsum",
- "state": {
- "status": "EXPIRED",
- "createdAt": 1454004510000,
- "acceptedAt": 1454004610000,
- "expiredAt": 1454007610000,
- },
- "discounts": [{
- "id": 1,
- "type": "gas_inside",
- "percentOff": "20",
- "text": "lorem ipsum"
- }]
- }],
- "balance": 51.0
- }
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement