dimo-python-sdk 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dimo/__init__.py +3 -0
- dimo/auth.py +85 -0
- dimo/constants.py +10 -0
- dimo/device_data.py +118 -0
- dimo/device_definitions.py +39 -0
- dimo/devices.py +252 -0
- dimo/dimo.py +79 -0
- dimo/environments.py +30 -0
- dimo/events.py +13 -0
- dimo/identity.py +222 -0
- dimo/request.py +33 -0
- dimo/telemetry.py +131 -0
- dimo/test.py +92 -0
- dimo/token_exchange.py +22 -0
- dimo/trips.py +18 -0
- dimo/user.py +53 -0
- dimo/valuations.py +32 -0
- dimo/vehicle_signal_decoding.py +99 -0
- dimo_python_sdk-0.0.1.dist-info/LICENSE +201 -0
- dimo_python_sdk-0.0.1.dist-info/METADATA +385 -0
- dimo_python_sdk-0.0.1.dist-info/RECORD +23 -0
- dimo_python_sdk-0.0.1.dist-info/WHEEL +5 -0
- dimo_python_sdk-0.0.1.dist-info/top_level.txt +1 -0
dimo/identity.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
class Identity:
|
|
2
|
+
def __init__(self, dimo_instance):
|
|
3
|
+
self.dimo = dimo_instance
|
|
4
|
+
|
|
5
|
+
# Primary query method
|
|
6
|
+
async def query(self, query):
|
|
7
|
+
return await self.dimo.query('Identity', query)
|
|
8
|
+
|
|
9
|
+
# Sample query - count DIMO vehicles
|
|
10
|
+
async def count_dimo_vehicles(self):
|
|
11
|
+
query = """
|
|
12
|
+
{
|
|
13
|
+
vehicles (first:10) {
|
|
14
|
+
totalCount,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
"""
|
|
18
|
+
return await self.dimo.query('Identity', query)
|
|
19
|
+
|
|
20
|
+
# Sample query - list vehicle definitions per address
|
|
21
|
+
async def list_vehicle_definitions_per_address(self, address, limit):
|
|
22
|
+
query = """
|
|
23
|
+
query ListVehicleDefinitionsPerAddress($owner: Address!, $first: Int!) {
|
|
24
|
+
vehicles(filterBy: {owner: $owner}, first: $first) {
|
|
25
|
+
nodes {
|
|
26
|
+
aftermarketDevice {
|
|
27
|
+
tokenId
|
|
28
|
+
address
|
|
29
|
+
}
|
|
30
|
+
syntheticDevice {
|
|
31
|
+
address
|
|
32
|
+
tokenId
|
|
33
|
+
}
|
|
34
|
+
definition {
|
|
35
|
+
make
|
|
36
|
+
model
|
|
37
|
+
year
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
"""
|
|
43
|
+
variables = {
|
|
44
|
+
"owner": address,
|
|
45
|
+
"first": limit
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
49
|
+
|
|
50
|
+
# Sample query - MMY per owner
|
|
51
|
+
async def mmy_by_owner(self, address, limit):
|
|
52
|
+
query = """
|
|
53
|
+
query MMYByOwner($owner: Address!, $first: Int!) {
|
|
54
|
+
vehicles(filterBy: {owner: $owner}, first: $first) {
|
|
55
|
+
nodes {
|
|
56
|
+
definition {
|
|
57
|
+
make
|
|
58
|
+
model
|
|
59
|
+
year
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
"""
|
|
65
|
+
variables = {
|
|
66
|
+
"owner": address,
|
|
67
|
+
"first": limit
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
71
|
+
|
|
72
|
+
# Sample query - tokenIDs & privileges by owner
|
|
73
|
+
async def list_token_ids_privileges_by_owner(self, address, vehicle_limit, privileges_limit):
|
|
74
|
+
query = """
|
|
75
|
+
query TokenIDsPrivilegesByOwner($owner: Address!, $firstVehicles: Int!, $firstPrivileges: Int!) {
|
|
76
|
+
vehicles(filterBy: {owner: $owner}, first: $firstVehicles) {
|
|
77
|
+
nodes {
|
|
78
|
+
tokenId
|
|
79
|
+
privileges(first: $firstPrivileges) {
|
|
80
|
+
nodes {
|
|
81
|
+
setAt
|
|
82
|
+
expiresAt
|
|
83
|
+
id
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
"""
|
|
90
|
+
variables = {
|
|
91
|
+
"owner": address,
|
|
92
|
+
"firstVehicles": vehicle_limit,
|
|
93
|
+
"firstPrivileges": privileges_limit
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
97
|
+
|
|
98
|
+
# Sample query - list of tokenIDs granted to a dev from an owner
|
|
99
|
+
async def list_token_ids_granted_to_dev_by_owner(self, dev_address, owner_address, limit):
|
|
100
|
+
query = """
|
|
101
|
+
query ListTokenIdsGrantedToDevByOwner($privileged: Address!, $owner: Address!, $first: Int!) {
|
|
102
|
+
vehicles(filterBy: {privileged: $privileged, owner: $owner}, first: $first) {
|
|
103
|
+
nodes {
|
|
104
|
+
tokenId
|
|
105
|
+
definition {
|
|
106
|
+
make
|
|
107
|
+
}
|
|
108
|
+
aftermarketDevice {
|
|
109
|
+
manufacturer {
|
|
110
|
+
name
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
"""
|
|
117
|
+
variables = {
|
|
118
|
+
"owner": owner_address,
|
|
119
|
+
"privileged": dev_address,
|
|
120
|
+
"first": limit
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
124
|
+
|
|
125
|
+
# Sample query - DCNs by Owner
|
|
126
|
+
async def dcn_by_owner(self, address, limit):
|
|
127
|
+
query = """
|
|
128
|
+
query DCNByOwner($owner: Address!, $first: Int!) {
|
|
129
|
+
vehicles(filterBy: {owner: $owner}, first: $first) {
|
|
130
|
+
nodes {
|
|
131
|
+
dcn {
|
|
132
|
+
node
|
|
133
|
+
name
|
|
134
|
+
vehicle {
|
|
135
|
+
tokenId
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
"""
|
|
142
|
+
variables = {
|
|
143
|
+
"owner": address,
|
|
144
|
+
"first": limit
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
148
|
+
|
|
149
|
+
# Sample query - MMY by TokenID
|
|
150
|
+
async def mmy_by_token_id(self, token_id):
|
|
151
|
+
query = """
|
|
152
|
+
query MMYByTokenID($tokenId: Int!) {
|
|
153
|
+
vehicle (tokenId: $tokenId) {
|
|
154
|
+
aftermarketDevice {
|
|
155
|
+
tokenId
|
|
156
|
+
address
|
|
157
|
+
}
|
|
158
|
+
syntheticDevice {
|
|
159
|
+
tokenId
|
|
160
|
+
address
|
|
161
|
+
}
|
|
162
|
+
definition {
|
|
163
|
+
make
|
|
164
|
+
model
|
|
165
|
+
year
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
"""
|
|
170
|
+
variables = {
|
|
171
|
+
"tokenId": token_id
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
175
|
+
|
|
176
|
+
# Sample query - Rewards by owner
|
|
177
|
+
async def rewards_by_owner(self, address):
|
|
178
|
+
query = """
|
|
179
|
+
query RewardsByOwner($owner: Address!) {
|
|
180
|
+
rewards (user: $owner) {
|
|
181
|
+
totalTokens
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
"""
|
|
185
|
+
variables = {
|
|
186
|
+
"owner": address
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
|
190
|
+
|
|
191
|
+
# Sample query - get rewards history by owner
|
|
192
|
+
async def rewards_history_by_owner(self, address, limit):
|
|
193
|
+
query = """
|
|
194
|
+
query GetVehicleDataByOwner($owner: Address!, $first: Int!) {
|
|
195
|
+
vehicles (filterBy: {owner: $owner}, first: $first) {
|
|
196
|
+
nodes {
|
|
197
|
+
earnings {
|
|
198
|
+
history (first: $first) {
|
|
199
|
+
edges {
|
|
200
|
+
node {
|
|
201
|
+
week
|
|
202
|
+
aftermarketDeviceTokens
|
|
203
|
+
syntheticDeviceTokens
|
|
204
|
+
sentAt
|
|
205
|
+
beneficiary
|
|
206
|
+
connectionStreak
|
|
207
|
+
streakTokens
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
totalTokens
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
"""
|
|
217
|
+
variables = {
|
|
218
|
+
"owner": address,
|
|
219
|
+
"first": limit
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return await self.dimo.query('Identity', query, variables=variables)
|
dimo/request.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import requests
|
|
3
|
+
|
|
4
|
+
class Request:
|
|
5
|
+
|
|
6
|
+
session = requests.Session()
|
|
7
|
+
|
|
8
|
+
def __init__(self, http_method, url):
|
|
9
|
+
self.http_method = http_method
|
|
10
|
+
self.url = url
|
|
11
|
+
|
|
12
|
+
def __call__(self, headers=None, data=None, params=None, **kwargs):
|
|
13
|
+
headers = headers or {}
|
|
14
|
+
headers.update(kwargs.pop('headers', {}))
|
|
15
|
+
|
|
16
|
+
if data and isinstance(data, dict) and headers.get('Content-Type') == 'application/json':
|
|
17
|
+
data = json.dumps(data)
|
|
18
|
+
|
|
19
|
+
response = self.session.request (
|
|
20
|
+
method=self.http_method,
|
|
21
|
+
url=self.url,
|
|
22
|
+
headers=headers,
|
|
23
|
+
params=params,
|
|
24
|
+
data=data,
|
|
25
|
+
**kwargs
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# TODO: Better error responses
|
|
29
|
+
response.raise_for_status()
|
|
30
|
+
|
|
31
|
+
if response.content:
|
|
32
|
+
return response.json()
|
|
33
|
+
return None
|
dimo/telemetry.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
class Telemetry:
|
|
2
|
+
def __init__(self, dimo_instance):
|
|
3
|
+
self.dimo = dimo_instance
|
|
4
|
+
|
|
5
|
+
# Primary query method
|
|
6
|
+
async def query(self, query, token):
|
|
7
|
+
return await self.dimo.query('Telemetry', query, token=token)
|
|
8
|
+
|
|
9
|
+
# Sample query - get signals latest
|
|
10
|
+
async def get_signals_latest(self, token, token_id):
|
|
11
|
+
query = """
|
|
12
|
+
query GetSignalsLatest($tokenId: Int!) {
|
|
13
|
+
signalsLatest(tokenId: $tokenId){
|
|
14
|
+
powertrainTransmissionTravelledDistance{
|
|
15
|
+
timestamp
|
|
16
|
+
value
|
|
17
|
+
}
|
|
18
|
+
exteriorAirTemperature{
|
|
19
|
+
timestamp
|
|
20
|
+
value
|
|
21
|
+
}
|
|
22
|
+
speed {
|
|
23
|
+
timestamp
|
|
24
|
+
value
|
|
25
|
+
}
|
|
26
|
+
powertrainType{
|
|
27
|
+
timestamp
|
|
28
|
+
value
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
"""
|
|
33
|
+
variables = {
|
|
34
|
+
"tokenId": token_id
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return await self.dimo.query('Telemetry', query, token=token, variables=variables)
|
|
38
|
+
|
|
39
|
+
# Sample query - daily signals from autopi
|
|
40
|
+
async def get_daily_signals_autopi(self, token, token_id, start_date, end_date):
|
|
41
|
+
query = """
|
|
42
|
+
query GetDailySignalsAutopi($tokenId: Int!, $startDate: Time!, $endDate: Time!) {
|
|
43
|
+
signals(
|
|
44
|
+
tokenId: $tokenId,
|
|
45
|
+
interval: "24h",
|
|
46
|
+
from: $startDate,
|
|
47
|
+
to: $endDate,
|
|
48
|
+
filter: {
|
|
49
|
+
source: "autopi"
|
|
50
|
+
})
|
|
51
|
+
{
|
|
52
|
+
speed(agg: MED)
|
|
53
|
+
powertrainType(agg: RAND)
|
|
54
|
+
powertrainRange(agg: MIN)
|
|
55
|
+
exteriorAirTemperature(agg: MAX)
|
|
56
|
+
chassisAxleRow1WheelLeftTirePressure(agg: MIN)
|
|
57
|
+
timestamp
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
"""
|
|
61
|
+
variables = {
|
|
62
|
+
"tokenId": token_id,
|
|
63
|
+
"startDate": start_date,
|
|
64
|
+
"endDate": end_date
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return await self.dimo.query('Telemetry', query, token=token, variables=variables)
|
|
68
|
+
|
|
69
|
+
# Sample query - daily average speed of a specific vehicle
|
|
70
|
+
async def get_daily_average_speed(self, token, token_id, start_date, end_date):
|
|
71
|
+
query = """
|
|
72
|
+
query GetDailyAverageSpeed($tokenId: Int!, $startDate: Time!, $endDate: Time!) {
|
|
73
|
+
signals (
|
|
74
|
+
tokenId: $tokenId,
|
|
75
|
+
from: $startDate,
|
|
76
|
+
to: $endDate,
|
|
77
|
+
interval: "24h"
|
|
78
|
+
)
|
|
79
|
+
{
|
|
80
|
+
timestamp
|
|
81
|
+
avgSpeed: speed(agg: AVG)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
"""
|
|
85
|
+
variables = {
|
|
86
|
+
"tokenId": token_id,
|
|
87
|
+
"startDate": start_date,
|
|
88
|
+
"endDate": end_date
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return await self.dimo.query('Telemetry', query, token=token, variables=variables)
|
|
92
|
+
|
|
93
|
+
# Sample query - daily max speed of a specific vehicle
|
|
94
|
+
async def get_daily_max_speed(self, token, token_id, start_date, end_date):
|
|
95
|
+
query = """
|
|
96
|
+
query GetMaxSpeed($tokenId: Int!, $startDate: Time!, $endDate: Time!) {
|
|
97
|
+
signals(
|
|
98
|
+
tokenId: $tokenId,
|
|
99
|
+
from: $startDate,
|
|
100
|
+
to: $endDate,
|
|
101
|
+
interval: "24h"
|
|
102
|
+
)
|
|
103
|
+
{
|
|
104
|
+
timestamp
|
|
105
|
+
maxSpeed: speed(agg: MAX)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
"""
|
|
109
|
+
variables = {
|
|
110
|
+
"tokenId": token_id,
|
|
111
|
+
"startDate": start_date,
|
|
112
|
+
"endDate": end_date
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return await self.dimo.query('Telemetry', query, token=token, variables=variables)
|
|
116
|
+
|
|
117
|
+
# TODO: Update with Attestation API
|
|
118
|
+
# Sample query - get the VIN of a specific vehicle
|
|
119
|
+
# async def get_vin(self, token, token_id):
|
|
120
|
+
# query = """
|
|
121
|
+
# query GetVIN($tokenId: Int!) {
|
|
122
|
+
# vinVCLatest (tokenId: $tokenId) {
|
|
123
|
+
# vin
|
|
124
|
+
# }
|
|
125
|
+
# }"""
|
|
126
|
+
# variables = {
|
|
127
|
+
# "tokenId": token_id
|
|
128
|
+
# }
|
|
129
|
+
|
|
130
|
+
# return await self.dimo.query('Telemetry', query, token=token, variables=variables)
|
|
131
|
+
|
dimo/test.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from dimo import DIMO
|
|
2
|
+
from dotenv import load_dotenv # REMOVE!!
|
|
3
|
+
import os # REMOVE !!
|
|
4
|
+
import asyncio
|
|
5
|
+
load_dotenv()
|
|
6
|
+
|
|
7
|
+
dimo = DIMO("Production")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# PUBLIC ENDPOINTS
|
|
11
|
+
# async def test_public_endpoints():
|
|
12
|
+
|
|
13
|
+
# device_makes = await dimo.device_definitions.list_device_makes()
|
|
14
|
+
# print("DEVICE MAKES: ", device_makes)
|
|
15
|
+
|
|
16
|
+
# by_id = await dimo.device_definitions.get_by_id(id='26G4j1YDKZhFeCsn12MAlyU3Y2H')
|
|
17
|
+
# print(by_id)
|
|
18
|
+
|
|
19
|
+
# barretts_car_by_mmy = await dimo.device_definitions.get_by_mmy(
|
|
20
|
+
# make="Hyundai",
|
|
21
|
+
# model="Tucson",
|
|
22
|
+
# year=2022
|
|
23
|
+
# )
|
|
24
|
+
# print("HYUNDAI TUCSON: ", barretts_car_by_mmy)
|
|
25
|
+
|
|
26
|
+
# count = await dimo.identity.count_dimo_vehicles()
|
|
27
|
+
# print(count)
|
|
28
|
+
|
|
29
|
+
# listvd = await dimo.identity.list_vehicle_definitions_per_address(address="0x48f6EdC54Ae0706b5e6cFC33C342B49bf2dDb939",limit=2)
|
|
30
|
+
# print(listvd)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# if __name__ == "__main__":
|
|
34
|
+
# asyncio.run(test_public_endpoints())
|
|
35
|
+
|
|
36
|
+
# # GET ACCESS TOKEN
|
|
37
|
+
async def auth_routes():
|
|
38
|
+
authHeader = await dimo.auth.get_token(
|
|
39
|
+
client_id='0xeAa35540a94e3ebdf80448Ae7c9dE5F42CaB3481',
|
|
40
|
+
domain='http://localhost:8082',
|
|
41
|
+
private_key=os.getenv("private_key")
|
|
42
|
+
)
|
|
43
|
+
access_token = authHeader["access_token"]
|
|
44
|
+
|
|
45
|
+
# GET PRIVILEGE TOKEN
|
|
46
|
+
privileged_token_req = await dimo.token_exchange.exchange(access_token, privileges=[1,3,4], token_id=17)
|
|
47
|
+
privileged_token = privileged_token_req['token']
|
|
48
|
+
print("USE THIS ONE: ", privileged_token)
|
|
49
|
+
|
|
50
|
+
# "0x48f6EdC54Ae0706b5e6cFC33C342B49bf2dDb939"
|
|
51
|
+
|
|
52
|
+
# TELEMETRY TESTS
|
|
53
|
+
# try:
|
|
54
|
+
# anything = await dimo.telemetry.get_daily_signals_autopi(token=privileged_token, token_id=21957, start_date="2024-07-20T18:32:12Z",
|
|
55
|
+
# end_date="2024-07-31T18:32:12Z")
|
|
56
|
+
# print(anything)
|
|
57
|
+
# except Exception as e:
|
|
58
|
+
# print(f"An error occurred: {e}")
|
|
59
|
+
|
|
60
|
+
# BEARER AUTHENTICATION w/ ACCESS_TOKEN - SAMPLE ENDPOINTS
|
|
61
|
+
# my_events = await dimo.events.get_events(access_token)
|
|
62
|
+
# print("My events: ", my_events)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# TEST IDENTITY
|
|
66
|
+
# my_dev_vehicles_query = """
|
|
67
|
+
# query {
|
|
68
|
+
# vehicles(filterBy: { privileged: "0xeAa35540a94e3ebdf80448Ae7c9dE5F42CaB3481" }, first: 100) {
|
|
69
|
+
# nodes {
|
|
70
|
+
# tokenId
|
|
71
|
+
# definition {
|
|
72
|
+
# make
|
|
73
|
+
# model
|
|
74
|
+
# year
|
|
75
|
+
# }
|
|
76
|
+
# },
|
|
77
|
+
# totalCount
|
|
78
|
+
# }
|
|
79
|
+
# }"""
|
|
80
|
+
# dev_vehicles = await dimo.identity.query(query=my_dev_vehicles_query, token=privileged_token)
|
|
81
|
+
# print(dev_vehicles)
|
|
82
|
+
|
|
83
|
+
# TEST TELEMETRY
|
|
84
|
+
# latest_signals = await dimo.telemetry.get_signals_latest(token=privileged_token, token_id=17)
|
|
85
|
+
# print(latest_signals)
|
|
86
|
+
|
|
87
|
+
# BEARER AUTHENTICATION w/ PRIVILEGE_TOKEN - SAMPLE ENDPOINTS
|
|
88
|
+
# bk_vehicle_history = await dimo.device_data.get_v1_vehicle_history(privileged_token, token_id=17)
|
|
89
|
+
# print("My vehicle history: ", bk_vehicle_history)
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
asyncio.run(auth_routes())
|
dimo/token_exchange.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from dimo.constants import dimo_constants
|
|
2
|
+
|
|
3
|
+
class TokenExchange:
|
|
4
|
+
|
|
5
|
+
def __init__(self, request_method, get_auth_headers):
|
|
6
|
+
self._request = request_method
|
|
7
|
+
self._get_auth_headers = get_auth_headers
|
|
8
|
+
|
|
9
|
+
async def exchange(self, access_token, privileges, token_id, env="Production"):
|
|
10
|
+
body = {
|
|
11
|
+
'nftContractAddress': dimo_constants[env]['NFT_address'],
|
|
12
|
+
'privileges': privileges,
|
|
13
|
+
'tokenId': token_id
|
|
14
|
+
}
|
|
15
|
+
response = self._request(
|
|
16
|
+
'POST',
|
|
17
|
+
'TokenExchange',
|
|
18
|
+
'/v1/tokens/exchange',
|
|
19
|
+
headers=self._get_auth_headers(access_token),
|
|
20
|
+
data=body
|
|
21
|
+
)
|
|
22
|
+
return response
|
dimo/trips.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class Trips:
|
|
2
|
+
|
|
3
|
+
def __init__(self, request_method, get_auth_headers):
|
|
4
|
+
self._request = request_method
|
|
5
|
+
self._get_auth_headers = get_auth_headers
|
|
6
|
+
|
|
7
|
+
async def trips(self, privilege_token, token_id, page=None):
|
|
8
|
+
params = {}
|
|
9
|
+
if page is not None:
|
|
10
|
+
params['page'] = [page]
|
|
11
|
+
url = f'/v1/vehicle/{token_id}/trips'
|
|
12
|
+
return self._request(
|
|
13
|
+
'GET',
|
|
14
|
+
'Trips',
|
|
15
|
+
url,
|
|
16
|
+
params=params,
|
|
17
|
+
headers=self._get_auth_headers(privilege_token)
|
|
18
|
+
)
|
dimo/user.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class User:
|
|
2
|
+
|
|
3
|
+
def __init__(self, request_method, get_auth_headers):
|
|
4
|
+
self._request = request_method
|
|
5
|
+
self._get_auth_headers = get_auth_headers
|
|
6
|
+
|
|
7
|
+
async def user(self, access_token):
|
|
8
|
+
return self._request(
|
|
9
|
+
'GET',
|
|
10
|
+
'User',
|
|
11
|
+
'/v1/user',
|
|
12
|
+
headers=self._get_auth_headers(access_token)
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
async def update_user(self, access_token, update_user_request):
|
|
16
|
+
body = {
|
|
17
|
+
'updateUserRequest': update_user_request
|
|
18
|
+
}
|
|
19
|
+
return self._request(
|
|
20
|
+
'PUT',
|
|
21
|
+
'User',
|
|
22
|
+
'/v1/user',
|
|
23
|
+
data=body,
|
|
24
|
+
headers=self._get_auth_headers(access_token)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
async def delete_user(self, access_token):
|
|
28
|
+
return self._request(
|
|
29
|
+
'DELETE',
|
|
30
|
+
'User',
|
|
31
|
+
'/v1/user',
|
|
32
|
+
headers=self._get_auth_headers(access_token)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
async def send_confirmation_email(self, access_token):
|
|
36
|
+
return self._request(
|
|
37
|
+
'POST',
|
|
38
|
+
'User',
|
|
39
|
+
'/v1/user/send-confirmation-email',
|
|
40
|
+
headers=self._get_auth_headers(access_token)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
async def confirm_email(self, access_token, confirm_email_request):
|
|
44
|
+
body = {
|
|
45
|
+
'confirmEmailRequest': confirm_email_request
|
|
46
|
+
}
|
|
47
|
+
return self._request(
|
|
48
|
+
'POST',
|
|
49
|
+
'User',
|
|
50
|
+
'/v1/user/confirm-email',
|
|
51
|
+
data=body,
|
|
52
|
+
headers=self._get_auth_headers(access_token)
|
|
53
|
+
)
|
dimo/valuations.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class Valuations:
|
|
2
|
+
|
|
3
|
+
def __init__(self, request_method, get_auth_headers):
|
|
4
|
+
self._request = request_method
|
|
5
|
+
self._get_auth_headers = get_auth_headers
|
|
6
|
+
|
|
7
|
+
async def get_valuations(self, access_token, user_device_id):
|
|
8
|
+
url = f'/v1/user/devices/{user_device_id}/valuations'
|
|
9
|
+
return self._request(
|
|
10
|
+
'GET',
|
|
11
|
+
'Valuations',
|
|
12
|
+
url,
|
|
13
|
+
headers=self._get_auth_headers(access_token)
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
async def get_instant_offer(self, access_token, user_device_id):
|
|
17
|
+
url = f'/v1/user/devices/{user_device_id}/instant-offer'
|
|
18
|
+
return self._request(
|
|
19
|
+
'GET',
|
|
20
|
+
'Valuations',
|
|
21
|
+
url,
|
|
22
|
+
headers=self._get_auth_headers(access_token)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
async def get_offers(self, access_token, user_device_id):
|
|
26
|
+
url = f'/v1/user/devices/{user_device_id}/offers'
|
|
27
|
+
return self._request(
|
|
28
|
+
'GET',
|
|
29
|
+
'Valuations',
|
|
30
|
+
url,
|
|
31
|
+
headers=self._get_auth_headers(access_token)
|
|
32
|
+
)
|