-
Notifications
You must be signed in to change notification settings - Fork 1
/
product.py
46 lines (40 loc) · 1.14 KB
/
product.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Product:
"""
:param asin: amazon SKU id number
:type asin: str
:param timestamp: calendar time for which product price is found
:type timestamp: str
:param price: price of item in US $
:type price: str
"""
def __init__(self, asin: str, timestamp: str, price: str):
self.asin = asin
self.timestamp = timestamp
self.price = price
def getItem(self) -> dict:
"""Get data in table
:returns: dict[dict]
"""
return {
'ASIN': {'S': self.asin},
'timeStamp': {'N': self.timestamp},
'Price': {'N': self.price}
}
@staticmethod
def getKeyAttributeDefs() -> list:
"""
:return: list[dict]
"""
return [
{'AttributeName': 'ASIN', 'AttributeType': 'S'},
{'AttributeName': 'timeStamp', 'AttributeType': 'N'}
]
@staticmethod
def getKeySchema() -> list:
"""
:return: list[dict]
"""
return [
{'AttributeName': 'ASIN', 'KeyType': 'HASH'},
{'AttributeName': 'timeStamp', 'KeyType': 'RANGE'}
]