Class: GitFit::Sync::IGPSPORT

Inherits:
Base
  • Object
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

#auth_method, #progress_reported

Instance Method Summary collapse

Methods inherited from Base

adapters, #build_progress_info, #call, camelcase_to_snakecase, config_key, register_adapter, register_config, register_test_adapter, test_adapters

Constructor Details

#initializeIGPSPORT

Returns a new instance of IGPSPORT.



24
25
26
27
28
# File 'lib/git_fit/sync/igpsport.rb', line 24

def initialize(...)
  super
  @phone = @config['phone']
  @password = @config['password']
end

Instance Method Details

#authenticateObject



35
36
37
38
39
# File 'lib/git_fit/sync/igpsport.rb', line 35

def authenticate
  result = 
  @auth_method = 'login' if result
  result
end

#before_callObject



30
31
32
33
# File 'lib/git_fit/sync/igpsport.rb', line 30

def before_call
  return false if @phone.nil? || @password.nil?
  super
end

#pending_idsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/git_fit/sync/igpsport.rb', line 41

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



60
61
62
# File 'lib/git_fit/sync/igpsport.rb', line 60

def process_one(pending)
  sync_activity(pending[:summary], pending[:id])
end