Class: GitFit::Sync::XOSS
- Inherits:
-
Base
- Object
- Base
- GitFit::Sync::XOSS
show all
- Defined in:
- lib/git_fit/sync/xoss.rb
Constant Summary
collapse
- FIT_FILE_PATH =
'/api/v3/activity/%<id>s/fit_file/'
- BASE_URL =
'https://backend.xoss.co'
- LOGIN_PATH =
'/api/v1/jwt-token/'
- REFRESH_PATH =
'/api/v1/jwt-token/refresh/'
- ACTIVITIES_PATH =
'/api/v3/activity/'
- ACCESS_TOKEN_TTL =
86400
- SPORT_MAP =
{
1 => 'run',
2 => 'ride',
3 => 'other',
4 => 'workout',
5 => 'swim',
11 => 'walk',
}.freeze
Instance Attribute Summary
Attributes inherited from Base
#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
#initialize ⇒ XOSS
Returns a new instance of XOSS.
31
32
33
34
35
36
|
# File 'lib/git_fit/sync/xoss.rb', line 31
def initialize(...)
super
@email = @config['email']
@password = @config['password']
@token_path = @config['token_path'] || File.join('data', 'auth', 'xoss_tokens.json')
end
|
Instance Method Details
#authenticate ⇒ Object
43
44
45
46
47
48
|
# File 'lib/git_fit/sync/xoss.rb', line 43
def authenticate
return true if load_tokens && access_token_valid?
return true if refresh_access_token
return true if login
false
end
|
#before_call ⇒ Object
38
39
40
41
|
# File 'lib/git_fit/sync/xoss.rb', line 38
def before_call
return false if @email.nil? || @password.nil?
super
end
|
#pending_ids ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/git_fit/sync/xoss.rb', line 50
def pending_ids
existing = existing_run_ids
ids = []
offset = 1
limit = 50
loop do
acts = fetch_page(offset, limit)
break if acts.nil? || acts.empty?
acts.each do |act|
act_id = act['id'].to_s
next if existing.include?(act_id) && raw_file_exists?(act_id)
type = map_sport(act['sport'])
next if skip_type?(type)
ids << { id: act_id, type: type, summary: act }
end
offset += limit
end
ids
end
|
#process_one(pending) ⇒ Object
70
71
72
|
# File 'lib/git_fit/sync/xoss.rb', line 70
def process_one(pending)
process_activity(pending[:summary])
end
|