-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_instrument.py
More file actions
50 lines (42 loc) · 2.07 KB
/
example_instrument.py
File metadata and controls
50 lines (42 loc) · 2.07 KB
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
47
48
49
50
if __name__ == "__main__":
from src.wom_connector.instrument import Instrument
from src.wom_connector.voucher import Voucher
import datetime
privk = open("keys/instrument1.pem", "rb")
coords = [(46.9, 12.0),
(46.8, 12.1),
(46.7, 12.2),
(46.6, 12.3),
(46.5, 12.4),
(46.4, 12.5),
(46.3, 12.6),
(46.2, 12.7),
(46.1, 12.8),
(46.0, 12.9)]
# Vouchers can be specified as a list of Voucher instances
'''
vouchers = []
for c in coords:
vouchers.append(Voucher.create(aim='H', latitude=c[0], longitude=c[1], timestamp=datetime.datetime.utcnow()))
'''
# Or as a list of simple dictionaries
'''
vouchers = [
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1},
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1},
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1},
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1},
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1},
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1},
{'aim': 'H', 'latitude': 46.9, 'longitude': 12.0, 'timestamp': '2020-01-28T17:08:24.073280', 'count': 1}
]
'''
# Or without location, which will be set by the WOM Pocket on redeem
vouchers = [
Voucher.createWithoutLocation(aim='X', timestamp=datetime.datetime.utcnow())
]
connector = Instrument(domain='dev.wom.social',
instrument_id='5e74203f5f21bb265a2d26bd', # instrument ID
instrument_privk=privk.read())
otc, password = connector.request_vouchers(vouchers=vouchers)
print("Otc: {otc} Password:{password}".format(otc=otc, password=password))