fitgem_oauth2 1.3.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fitgem_oauth2.gemspec +22 -22
- data/lib/fitgem_oauth2.rb +6 -6
- data/lib/fitgem_oauth2/activity.rb +209 -209
- data/lib/fitgem_oauth2/body_measurements.rb +163 -163
- data/lib/fitgem_oauth2/client.rb +126 -125
- data/lib/fitgem_oauth2/devices.rb +45 -45
- data/lib/fitgem_oauth2/errors.rb +30 -27
- data/lib/fitgem_oauth2/food.rb +27 -27
- data/lib/fitgem_oauth2/food/collection.rb +51 -51
- data/lib/fitgem_oauth2/food/metadata.rb +63 -63
- data/lib/fitgem_oauth2/food/series.rb +55 -55
- data/lib/fitgem_oauth2/friends.rb +44 -44
- data/lib/fitgem_oauth2/heartrate.rb +85 -85
- data/lib/fitgem_oauth2/sleep.rb +86 -86
- data/lib/fitgem_oauth2/subscriptions.rb +32 -32
- data/lib/fitgem_oauth2/users.rb +7 -7
- data/lib/fitgem_oauth2/utils.rb +48 -48
- data/lib/fitgem_oauth2/version.rb +3 -3
- metadata +3 -4
@@ -1,44 +1,44 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
class Client
|
3
|
-
# retrieves list of friends for the current user
|
4
|
-
def friends
|
5
|
-
get_call("user/#{user_id}/friends.json")
|
6
|
-
end
|
7
|
-
|
8
|
-
# retrieves leaderboard for the user
|
9
|
-
def friends_leaderboard
|
10
|
-
get_call("user/#{user_id}/friends/leaderboard.json")
|
11
|
-
end
|
12
|
-
|
13
|
-
# ==================================
|
14
|
-
# Friend Invitations
|
15
|
-
# ==================================
|
16
|
-
|
17
|
-
# send an invitation to a friend
|
18
|
-
# @param params POST parameters for sending friend invite.
|
19
|
-
def invite_friend(params)
|
20
|
-
post_call("user/#{user_id}/friends/invitations.json", params)
|
21
|
-
end
|
22
|
-
|
23
|
-
# retrieve list of friend invitations
|
24
|
-
def friend_invitations
|
25
|
-
get_call("user/#{user_id}/friends/invitations.json")
|
26
|
-
end
|
27
|
-
|
28
|
-
# respond to a friend invite
|
29
|
-
# @param from_user_id the ID of the friend
|
30
|
-
# @param params POST parameters for responding to the invite.
|
31
|
-
def respond_to_invitation(from_user_id, params)
|
32
|
-
post_call("user/#{user_id}/friends/invitations/#{from_user_id}.json", params)
|
33
|
-
end
|
34
|
-
|
35
|
-
# ==================================
|
36
|
-
# Badges
|
37
|
-
# ==================================
|
38
|
-
|
39
|
-
# retrieve badges for the user
|
40
|
-
def badges
|
41
|
-
get_call("user/#{user_id}/badges.json")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
class Client
|
3
|
+
# retrieves list of friends for the current user
|
4
|
+
def friends
|
5
|
+
get_call("user/#{user_id}/friends.json")
|
6
|
+
end
|
7
|
+
|
8
|
+
# retrieves leaderboard for the user
|
9
|
+
def friends_leaderboard
|
10
|
+
get_call("user/#{user_id}/friends/leaderboard.json")
|
11
|
+
end
|
12
|
+
|
13
|
+
# ==================================
|
14
|
+
# Friend Invitations
|
15
|
+
# ==================================
|
16
|
+
|
17
|
+
# send an invitation to a friend
|
18
|
+
# @param params POST parameters for sending friend invite.
|
19
|
+
def invite_friend(params)
|
20
|
+
post_call("user/#{user_id}/friends/invitations.json", params)
|
21
|
+
end
|
22
|
+
|
23
|
+
# retrieve list of friend invitations
|
24
|
+
def friend_invitations
|
25
|
+
get_call("user/#{user_id}/friends/invitations.json")
|
26
|
+
end
|
27
|
+
|
28
|
+
# respond to a friend invite
|
29
|
+
# @param from_user_id the ID of the friend
|
30
|
+
# @param params POST parameters for responding to the invite.
|
31
|
+
def respond_to_invitation(from_user_id, params)
|
32
|
+
post_call("user/#{user_id}/friends/invitations/#{from_user_id}.json", params)
|
33
|
+
end
|
34
|
+
|
35
|
+
# ==================================
|
36
|
+
# Badges
|
37
|
+
# ==================================
|
38
|
+
|
39
|
+
# retrieve badges for the user
|
40
|
+
def badges
|
41
|
+
get_call("user/#{user_id}/badges.json")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
class Client
|
3
|
-
|
4
|
-
HR_PERIODS = %w[1d 7d 30d 1w 1m].freeze
|
5
|
-
HR_DETAIL_LEVELS = %w[1sec 1min].freeze
|
6
|
-
|
7
|
-
def hr_series_for_date_range(start_date, end_date)
|
8
|
-
validate_start_date(start_date)
|
9
|
-
validate_end_date(end_date)
|
10
|
-
|
11
|
-
url = ['user', user_id, 'activities/heart/date', format_date(start_date), format_date(end_date)].join('/')
|
12
|
-
get_call(url + '.json')
|
13
|
-
end
|
14
|
-
|
15
|
-
def hr_series_for_period(start_date, period)
|
16
|
-
validate_start_date(start_date)
|
17
|
-
validate_hr_period(period)
|
18
|
-
|
19
|
-
url = ['user', user_id, 'activities/heart/date', format_date(start_date), period].join('/')
|
20
|
-
get_call(url + '.json')
|
21
|
-
end
|
22
|
-
|
23
|
-
# retrieve heartrate time series
|
24
|
-
def heartrate_time_series(start_date: nil, end_date: nil, period: nil)
|
25
|
-
warn '[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.'
|
26
|
-
|
27
|
-
regular_time_series_guard(
|
28
|
-
start_date: start_date,
|
29
|
-
end_date: end_date,
|
30
|
-
period: period
|
31
|
-
)
|
32
|
-
|
33
|
-
second = period || format_date(end_date)
|
34
|
-
|
35
|
-
url = ['user', user_id, 'activities/heart/date', format_date(start_date), second].join('/')
|
36
|
-
|
37
|
-
get_call(url + '.json')
|
38
|
-
end
|
39
|
-
|
40
|
-
# retrieve intraday series for heartrate
|
41
|
-
def intraday_heartrate_time_series(start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil)
|
42
|
-
intraday_series_guard(
|
43
|
-
start_date: start_date,
|
44
|
-
end_date: end_date,
|
45
|
-
detail_level: detail_level,
|
46
|
-
start_time: start_time,
|
47
|
-
end_time: end_time
|
48
|
-
)
|
49
|
-
|
50
|
-
end_date = format_date(end_date) || '1d'
|
51
|
-
|
52
|
-
url = ['user', user_id, 'activities/heart/date', format_date(start_date), end_date, detail_level].join('/')
|
53
|
-
|
54
|
-
if start_time && end_time
|
55
|
-
url = [url, 'time', format_time(start_time), format_time(end_time)].join('/')
|
56
|
-
end
|
57
|
-
|
58
|
-
get_call(url + '.json')
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def validate_hr_period(period)
|
64
|
-
raise FitgemOauth2::InvalidArgumentError, "Invalid period: #{period}. Valid periods are #{HR_PERIODS}." unless period && HR_PERIODS.include?(period)
|
65
|
-
end
|
66
|
-
|
67
|
-
def regular_time_series_guard(start_date:, end_date:, period:)
|
68
|
-
validate_start_date(start_date)
|
69
|
-
|
70
|
-
raise FitgemOauth2::InvalidArgumentError, 'Both end_date and period specified. Specify only one.' if end_date && period
|
71
|
-
|
72
|
-
raise FitgemOauth2::InvalidArgumentError, 'Neither end_date nor period specified. Specify at least one.' if !end_date && !period
|
73
|
-
|
74
|
-
validate_hr_period(period) if period
|
75
|
-
end
|
76
|
-
|
77
|
-
def intraday_series_guard(start_date:, end_date:, detail_level:, start_time:, end_time:)
|
78
|
-
raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.' unless start_date
|
79
|
-
|
80
|
-
raise FitgemOauth2::InvalidArgumentError, "Please specify the defail level. Detail level should be one of #{HR_DETAIL_LEVELS}." unless detail_level && HR_DETAIL_LEVELS.include?(detail_level)
|
81
|
-
|
82
|
-
raise FitgemOauth2::InvalidArgumentError, 'Either specify both the start_time and end_time or specify neither.' if (start_time && !end_time) || (end_time && !start_time)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
class Client
|
3
|
+
|
4
|
+
HR_PERIODS = %w[1d 7d 30d 1w 1m].freeze
|
5
|
+
HR_DETAIL_LEVELS = %w[1sec 1min].freeze
|
6
|
+
|
7
|
+
def hr_series_for_date_range(start_date, end_date)
|
8
|
+
validate_start_date(start_date)
|
9
|
+
validate_end_date(end_date)
|
10
|
+
|
11
|
+
url = ['user', user_id, 'activities/heart/date', format_date(start_date), format_date(end_date)].join('/')
|
12
|
+
get_call(url + '.json')
|
13
|
+
end
|
14
|
+
|
15
|
+
def hr_series_for_period(start_date, period)
|
16
|
+
validate_start_date(start_date)
|
17
|
+
validate_hr_period(period)
|
18
|
+
|
19
|
+
url = ['user', user_id, 'activities/heart/date', format_date(start_date), period].join('/')
|
20
|
+
get_call(url + '.json')
|
21
|
+
end
|
22
|
+
|
23
|
+
# retrieve heartrate time series
|
24
|
+
def heartrate_time_series(start_date: nil, end_date: nil, period: nil)
|
25
|
+
warn '[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.'
|
26
|
+
|
27
|
+
regular_time_series_guard(
|
28
|
+
start_date: start_date,
|
29
|
+
end_date: end_date,
|
30
|
+
period: period
|
31
|
+
)
|
32
|
+
|
33
|
+
second = period || format_date(end_date)
|
34
|
+
|
35
|
+
url = ['user', user_id, 'activities/heart/date', format_date(start_date), second].join('/')
|
36
|
+
|
37
|
+
get_call(url + '.json')
|
38
|
+
end
|
39
|
+
|
40
|
+
# retrieve intraday series for heartrate
|
41
|
+
def intraday_heartrate_time_series(start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil)
|
42
|
+
intraday_series_guard(
|
43
|
+
start_date: start_date,
|
44
|
+
end_date: end_date,
|
45
|
+
detail_level: detail_level,
|
46
|
+
start_time: start_time,
|
47
|
+
end_time: end_time
|
48
|
+
)
|
49
|
+
|
50
|
+
end_date = format_date(end_date) || '1d'
|
51
|
+
|
52
|
+
url = ['user', user_id, 'activities/heart/date', format_date(start_date), end_date, detail_level].join('/')
|
53
|
+
|
54
|
+
if start_time && end_time
|
55
|
+
url = [url, 'time', format_time(start_time), format_time(end_time)].join('/')
|
56
|
+
end
|
57
|
+
|
58
|
+
get_call(url + '.json')
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def validate_hr_period(period)
|
64
|
+
raise FitgemOauth2::InvalidArgumentError, "Invalid period: #{period}. Valid periods are #{HR_PERIODS}." unless period && HR_PERIODS.include?(period)
|
65
|
+
end
|
66
|
+
|
67
|
+
def regular_time_series_guard(start_date:, end_date:, period:)
|
68
|
+
validate_start_date(start_date)
|
69
|
+
|
70
|
+
raise FitgemOauth2::InvalidArgumentError, 'Both end_date and period specified. Specify only one.' if end_date && period
|
71
|
+
|
72
|
+
raise FitgemOauth2::InvalidArgumentError, 'Neither end_date nor period specified. Specify at least one.' if !end_date && !period
|
73
|
+
|
74
|
+
validate_hr_period(period) if period
|
75
|
+
end
|
76
|
+
|
77
|
+
def intraday_series_guard(start_date:, end_date:, detail_level:, start_time:, end_time:)
|
78
|
+
raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.' unless start_date
|
79
|
+
|
80
|
+
raise FitgemOauth2::InvalidArgumentError, "Please specify the defail level. Detail level should be one of #{HR_DETAIL_LEVELS}." unless detail_level && HR_DETAIL_LEVELS.include?(detail_level)
|
81
|
+
|
82
|
+
raise FitgemOauth2::InvalidArgumentError, 'Either specify both the start_time and end_time or specify neither.' if (start_time && !end_time) || (end_time && !start_time)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/fitgem_oauth2/sleep.rb
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
|
3
|
-
class Client
|
4
|
-
|
5
|
-
SLEEP_RESOURCES = %w[
|
6
|
-
startTime timeInBed minutesAsleep awakeningsCount minutesAwake
|
7
|
-
minutesToFallAsleep minutesAfterWakeup efficiency
|
8
|
-
].freeze
|
9
|
-
|
10
|
-
SLEEP_PERIODS = %w[1d 7d 30d 1w 1m 3m 6m 1y max].freeze
|
11
|
-
|
12
|
-
# retrieve sleep logs for a date
|
13
|
-
# @param date date for which sleep logs needs to be accessed
|
14
|
-
def sleep_logs(date)
|
15
|
-
get_call_1_2("user/#{user_id}/sleep/date/#{format_date(date)}.json")
|
16
|
-
end
|
17
|
-
|
18
|
-
def sleep_logs_by_date_range(start_date, end_date)
|
19
|
-
get_call_1_2("user/#{user_id}/sleep/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
20
|
-
end
|
21
|
-
|
22
|
-
def sleep_logs_list(date, sort, limit)
|
23
|
-
date_param = format_date(date)
|
24
|
-
if sort == 'asc'
|
25
|
-
date_param = "afterDate=#{date_param}"
|
26
|
-
elsif sort == 'desc'
|
27
|
-
date_param = "beforeDate=#{date_param}"
|
28
|
-
else
|
29
|
-
raise FitgemOauth2::InvalidArgumentError, "sort can either be asc or desc"
|
30
|
-
end
|
31
|
-
get_call_1_2("user/#{user_id}/sleep/list.json?#{date_param}&offset=0&sort=#{sort}&limit=#{limit}")
|
32
|
-
end
|
33
|
-
|
34
|
-
# retrieve sleep goal for the user
|
35
|
-
def sleep_goal
|
36
|
-
get_call("user/#{user_id}/sleep/goal.json")
|
37
|
-
end
|
38
|
-
|
39
|
-
# update sleep goal
|
40
|
-
# @param params POST parameters for updating sleep goal
|
41
|
-
def update_sleep_goal(params)
|
42
|
-
post_call("user/#{user_id}/sleep/goal.json", params)
|
43
|
-
end
|
44
|
-
|
45
|
-
# retrieve time series data for sleep
|
46
|
-
# @param resource sleep resource to be requested
|
47
|
-
# @param start_date starting date for sleep time series
|
48
|
-
# @param end_date ending date for sleep time series
|
49
|
-
# @param period period for sleep time series
|
50
|
-
def sleep_time_series(resource: nil, start_date: nil, end_date: nil, period: nil)
|
51
|
-
unless start_date
|
52
|
-
raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.'
|
53
|
-
end
|
54
|
-
|
55
|
-
unless resource && SLEEP_RESOURCES.include?(resource)
|
56
|
-
raise FitgemOauth2::InvalidArgumentError, "Invalid resource: #{resource}. Valid resources are #{SLEEP_RESOURCES}."
|
57
|
-
end
|
58
|
-
|
59
|
-
if period && end_date
|
60
|
-
raise FitgemOauth2::InvalidArgumentError, 'Both end_date and period specified. Specify only one.'
|
61
|
-
end
|
62
|
-
|
63
|
-
if period && !SLEEP_PERIODS.include?(period)
|
64
|
-
raise FitgemOauth2::InvalidArgumentError, "Invalid period: #{period}. Valid periods are #{SLEEP_PERIODS}."
|
65
|
-
end
|
66
|
-
|
67
|
-
second = period || format_date(end_date)
|
68
|
-
|
69
|
-
url = ['user', user_id, 'sleep', resource, 'date', format_date(start_date), second].join('/')
|
70
|
-
|
71
|
-
get_call(url + '.json')
|
72
|
-
end
|
73
|
-
|
74
|
-
# log sleep
|
75
|
-
# @param params POST params for creating sleep log
|
76
|
-
def log_sleep(params)
|
77
|
-
post_call_1_2("user/#{user_id}/sleep.json", params)
|
78
|
-
end
|
79
|
-
|
80
|
-
# deleted sleep log
|
81
|
-
# @param log_id ID of the sleep log that needs to be removed.
|
82
|
-
def delete_logged_sleep(log_id)
|
83
|
-
delete_call("user/#{user_id}/sleep/#{log_id}.json")
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
|
3
|
+
class Client
|
4
|
+
|
5
|
+
SLEEP_RESOURCES = %w[
|
6
|
+
startTime timeInBed minutesAsleep awakeningsCount minutesAwake
|
7
|
+
minutesToFallAsleep minutesAfterWakeup efficiency
|
8
|
+
].freeze
|
9
|
+
|
10
|
+
SLEEP_PERIODS = %w[1d 7d 30d 1w 1m 3m 6m 1y max].freeze
|
11
|
+
|
12
|
+
# retrieve sleep logs for a date
|
13
|
+
# @param date date for which sleep logs needs to be accessed
|
14
|
+
def sleep_logs(date)
|
15
|
+
get_call_1_2("user/#{user_id}/sleep/date/#{format_date(date)}.json")
|
16
|
+
end
|
17
|
+
|
18
|
+
def sleep_logs_by_date_range(start_date, end_date)
|
19
|
+
get_call_1_2("user/#{user_id}/sleep/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
20
|
+
end
|
21
|
+
|
22
|
+
def sleep_logs_list(date, sort, limit)
|
23
|
+
date_param = format_date(date)
|
24
|
+
if sort == 'asc'
|
25
|
+
date_param = "afterDate=#{date_param}"
|
26
|
+
elsif sort == 'desc'
|
27
|
+
date_param = "beforeDate=#{date_param}"
|
28
|
+
else
|
29
|
+
raise FitgemOauth2::InvalidArgumentError, "sort can either be asc or desc"
|
30
|
+
end
|
31
|
+
get_call_1_2("user/#{user_id}/sleep/list.json?#{date_param}&offset=0&sort=#{sort}&limit=#{limit}")
|
32
|
+
end
|
33
|
+
|
34
|
+
# retrieve sleep goal for the user
|
35
|
+
def sleep_goal
|
36
|
+
get_call("user/#{user_id}/sleep/goal.json")
|
37
|
+
end
|
38
|
+
|
39
|
+
# update sleep goal
|
40
|
+
# @param params POST parameters for updating sleep goal
|
41
|
+
def update_sleep_goal(params)
|
42
|
+
post_call("user/#{user_id}/sleep/goal.json", params)
|
43
|
+
end
|
44
|
+
|
45
|
+
# retrieve time series data for sleep
|
46
|
+
# @param resource sleep resource to be requested
|
47
|
+
# @param start_date starting date for sleep time series
|
48
|
+
# @param end_date ending date for sleep time series
|
49
|
+
# @param period period for sleep time series
|
50
|
+
def sleep_time_series(resource: nil, start_date: nil, end_date: nil, period: nil)
|
51
|
+
unless start_date
|
52
|
+
raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.'
|
53
|
+
end
|
54
|
+
|
55
|
+
unless resource && SLEEP_RESOURCES.include?(resource)
|
56
|
+
raise FitgemOauth2::InvalidArgumentError, "Invalid resource: #{resource}. Valid resources are #{SLEEP_RESOURCES}."
|
57
|
+
end
|
58
|
+
|
59
|
+
if period && end_date
|
60
|
+
raise FitgemOauth2::InvalidArgumentError, 'Both end_date and period specified. Specify only one.'
|
61
|
+
end
|
62
|
+
|
63
|
+
if period && !SLEEP_PERIODS.include?(period)
|
64
|
+
raise FitgemOauth2::InvalidArgumentError, "Invalid period: #{period}. Valid periods are #{SLEEP_PERIODS}."
|
65
|
+
end
|
66
|
+
|
67
|
+
second = period || format_date(end_date)
|
68
|
+
|
69
|
+
url = ['user', user_id, 'sleep', resource, 'date', format_date(start_date), second].join('/')
|
70
|
+
|
71
|
+
get_call(url + '.json')
|
72
|
+
end
|
73
|
+
|
74
|
+
# log sleep
|
75
|
+
# @param params POST params for creating sleep log
|
76
|
+
def log_sleep(params)
|
77
|
+
post_call_1_2("user/#{user_id}/sleep.json", params)
|
78
|
+
end
|
79
|
+
|
80
|
+
# deleted sleep log
|
81
|
+
# @param log_id ID of the sleep log that needs to be removed.
|
82
|
+
def delete_logged_sleep(log_id)
|
83
|
+
delete_call("user/#{user_id}/sleep/#{log_id}.json")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
class Client
|
3
|
-
|
4
|
-
SUBSCRIBABLE_TYPES = %i[sleep body activities foods all].freeze
|
5
|
-
|
6
|
-
def subscriptions(opts)
|
7
|
-
get_call(subscription_url(opts))
|
8
|
-
end
|
9
|
-
|
10
|
-
def create_subscription(opts)
|
11
|
-
post_call(subscription_url(opts))
|
12
|
-
end
|
13
|
-
|
14
|
-
def remove_subscription(opts)
|
15
|
-
delete_call(subscription_url(opts))
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
def subscription_url(opts)
|
21
|
-
type = opts[:type] || :all
|
22
|
-
subscription_id = opts[:subscription_id]
|
23
|
-
|
24
|
-
url = ['user', user_id]
|
25
|
-
url << type unless type == :all
|
26
|
-
url << 'apiSubscriptions'
|
27
|
-
url << subscription_id if subscription_id
|
28
|
-
|
29
|
-
url.join('/') + '.json'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
class Client
|
3
|
+
|
4
|
+
SUBSCRIBABLE_TYPES = %i[sleep body activities foods all].freeze
|
5
|
+
|
6
|
+
def subscriptions(opts)
|
7
|
+
get_call(subscription_url(opts))
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_subscription(opts)
|
11
|
+
post_call(subscription_url(opts))
|
12
|
+
end
|
13
|
+
|
14
|
+
def remove_subscription(opts)
|
15
|
+
delete_call(subscription_url(opts))
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def subscription_url(opts)
|
21
|
+
type = opts[:type] || :all
|
22
|
+
subscription_id = opts[:subscription_id]
|
23
|
+
|
24
|
+
url = ['user', user_id]
|
25
|
+
url << type unless type == :all
|
26
|
+
url << 'apiSubscriptions'
|
27
|
+
url << subscription_id if subscription_id
|
28
|
+
|
29
|
+
url.join('/') + '.json'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|