Class: GitFit::Sync::Strava
- Inherits:
-
Base
- Object
- Base
- GitFit::Sync::Strava
show all
- Defined in:
- lib/git_fit/sync/strava.rb
Constant Summary
collapse
- BASE_URL =
"https://www.strava.com/api/v3"
Instance Attribute Summary
Attributes inherited from Base
#progress_reported
Instance Method Summary
collapse
Methods inherited from Base
adapters, #before_call, #build_progress_info, #call, config_key, #initialize, register_adapter, register_config, register_test_adapter, test_adapters
Instance Method Details
#authenticate ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/git_fit/sync/strava.rb', line 14
def authenticate
return false unless @config["client_id"].to_s != "" &&
@config["client_secret"].to_s != "" &&
@config["refresh_token"].to_s != ""
@access_token = refresh_access_token
@access_token ? true : false
end
|
#pending_ids ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/git_fit/sync/strava.rb', line 22
def pending_ids
existing = existing_run_ids
ids = []
page = 1
loop do
activities = fetch_activities(@access_token, page)
break if activities.empty?
activities.each do |act|
act_id = act["id"].to_s
next if existing.include?(act_id) && raw_file_exists?(act_id)
type = map_sport_type(act["type"], act["sport_type"])
next if skip_type?(type)
ids << { id: act_id, type: type, summary: act }
end
page += 1
end
ids
end
|
#process_one(pending) ⇒ Object
41
42
43
44
|
# File 'lib/git_fit/sync/strava.rb', line 41
def process_one(pending)
result = sync_activity(pending[:summary], pending[:id], @access_token)
result
end
|