-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmartrow.py
More file actions
132 lines (117 loc) · 2.96 KB
/
smartrow.py
File metadata and controls
132 lines (117 loc) · 2.96 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import requests
from typing import TypedDict, List, Optional
from datetime import datetime
class SplitTime(TypedDict):
distance: int
absolute_time: float
relative_time: float
delta_time: float
class Stroke(TypedDict):
stroke: int
distance: int
power_act: int
split_act: int
rate: float
class Game(TypedDict):
id: int
calories: float
distance: int
elapsed_seconds: int
extra_millies: int
time: int
p_ave: float
stroke_count: int
option: str
option_distance: int
option_time: int
created: str
account: int
mod: str
device_mac: str
accessory_mac: str
ave_bpm: int
watt_per_beat: Optional[float]
ave_power: Optional[float]
watt_kg: float
strava_id: str
curve: str
confirmed: bool
public_id: str
user_age: int
user_max_hr: Optional[int]
calc_ave_split: int
calc_min_split: int
calc_avg_stroke_work: int
calc_avg_stroke_length: int
calc_avg_stroke_time: Optional[int]
calc_avg_stroke_rate: float
calc_max_stroke_rate: float
calc_max_power: int
protocol_version: int
calc_max_force: int
calc_ave_hr: int
calc_max_hr: int
split_times: List[SplitTime]
heart_rates: List
strokes: List[Stroke]
race_details: Optional[str]
class PublicGame(TypedDict):
id: int
calories: float
distance: int
elapsed_seconds: int
extra_millies: int
time: int
p_ave: float
stroke_count: int
option: str
option_distance: int
option_time: int
created: datetime
account: int
mod: datetime
device_mac: str
accessory_mac: str
ave_bpm: int
watt_per_beat: Optional[float]
ave_power: Optional[float]
watt_kg: float
strava_id: str
curve: str
confirmed: bool
race: Optional[None] # Assuming 'race' can be None based on your data
public_id: str
user_age: int
user_weight: int
user_max_hr: Optional[int]
protocol_version: int
calc_ave_split: int
calc_avg_stroke_work: int
calc_avg_stroke_rate: float
def Profile(TypedDict):
id: str
avatar: str
name: str
country: int
country_name: str
gender: str
age_class: str
weight_class: str
color: str
class SmartRow:
base_url = "https://smartrow.fit/api"
def __init__(self, username, password):
self.username = username
self.password = password
def get_game(self, id) -> Game:
url = f"{self.base_url}/game/{id}"
response = requests.get(url, auth=(self.username, self.password))
return response.json()
def get_games(self) -> List[PublicGame]:
url = f"{self.base_url}/public-game"
response = requests.get(url, auth=(self.username, self.password))
return response.json()
def get_profile(self) -> List[Profile]:
url = f"{self.base_url}/profile"
response = requests.get(url, auth=(self.username, self.password))
return response.json()