Class: GitFit::Sync::Strava
Constant Summary collapse
- BASE_URL =
'https://www.strava.com/api/v3'
Instance Attribute Summary
Attributes inherited from Base
#auth_method, #progress_reported
Instance Method Summary collapse
Methods inherited from Base
adapters, #before_call, #build_progress_info, #call, camelcase_to_snakecase, config_key, #initialize, register_adapter, register_config, register_test_adapter, test_adapters
Constructor Details
This class inherits a constructor from GitFit::Sync::Base
Instance Method Details
#authenticate ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/git_fit/sync/strava.rb', line 16 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 @auth_method = 'token' @access_token ? true : false end |
#pending_ids ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/git_fit/sync/strava.rb', line 25 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
44 45 46 47 |
# File 'lib/git_fit/sync/strava.rb', line 44 def process_one(pending) result = sync_activity(pending[:summary], pending[:id], @access_token) result end |