Class: GitFit::Sync::IGPSPORT
- Inherits:
-
Base
- Object
- Base
- GitFit::Sync::IGPSPORT
show all
- Defined in:
- lib/git_fit/sync/igpsport.rb
Constant Summary
collapse
- BASE_URL =
"https://prod.zh.igpsport.com/service"
- LOGIN_URL =
"#{BASE_URL}/auth/account/login"
- QUERY_URL =
"#{BASE_URL}/web-gateway/web-analyze/activity/queryMyActivity"
- DOWNLOAD_URL =
"#{BASE_URL}/web-gateway/web-analyze/activity/getDownloadUrl"
- EXERCISE_MAP =
{
0 => "ride", 1 => "run", 2 => "hike", 3 => "walk",
4 => "swim", 5 => "ski", 6 => "workout"
}.freeze
- RAW_EXT =
"fit"
Instance Attribute Summary
Attributes inherited from Base
#progress_reported
Instance Method Summary
collapse
Methods inherited from Base
adapters, #build_progress_info, #call, config_key, register_adapter, register_config, register_test_adapter, test_adapters
Constructor Details
Returns a new instance of IGPSPORT.
22
23
24
25
26
|
# File 'lib/git_fit/sync/igpsport.rb', line 22
def initialize(...)
super
@phone = @config["phone"]
@password = @config["password"]
end
|
Instance Method Details
#authenticate ⇒ Object
33
34
35
|
# File 'lib/git_fit/sync/igpsport.rb', line 33
def authenticate
login
end
|
#before_call ⇒ Object
28
29
30
31
|
# File 'lib/git_fit/sync/igpsport.rb', line 28
def before_call
return false if @phone.nil? || @password.nil?
super
end
|
#pending_ids ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/git_fit/sync/igpsport.rb', line 37
def pending_ids
existing = existing_run_ids
ids = []
page = 1
loop do
acts = fetch_page(page)
break if acts.nil? || acts.empty?
acts.each do |act|
ride_id = act["rideId"].to_s
next if existing.include?(ride_id) && raw_file_exists?(ride_id)
type = map_sport(act["exerciseType"])
next if skip_type?(type)
ids << { id: ride_id, type: type, summary: act }
end
page += 1
end
ids
end
|
#process_one(pending) ⇒ Object
56
57
58
|
# File 'lib/git_fit/sync/igpsport.rb', line 56
def process_one(pending)
sync_activity(pending[:summary], pending[:id])
end
|