supersaas-api-client 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +9 -8
- data/examples/appointments.rb +17 -20
- data/examples/forms.rb +10 -10
- data/examples/groups.rb +5 -5
- data/examples/promotions.rb +6 -6
- data/examples/schedules.rb +9 -9
- data/examples/users.rb +13 -13
- data/lib/supersaas-api-client/api/appointments.rb +5 -5
- data/lib/supersaas-api-client/api/promotions.rb +3 -4
- data/lib/supersaas-api-client/client.rb +4 -4
- data/lib/supersaas-api-client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eb43732d50c7dcefda2438017a37bd2fc26c47ec74f4406a1ef18dca412ca9a
|
4
|
+
data.tar.gz: d82438701b3abcb5a79132685554278194bc0477861147779d40595b81374472
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 853d8c92cddfc0ee7f59b238f56d21ca9e706bcb2c4126fe5b3bdb0f03369d1fb1f05b42d1451aad84f7b2954a7e4330ffadbf467236746e1a7d43f1de04b571
|
7
|
+
data.tar.gz: 8000f1ba94f1f79c3d1cc8709ceaf220218d9aaca003a5c59ccd1adbbf512b3e8983dd5510da3a22c99740b069052b3de9addd63723174da362f5161a547775c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -172,15 +172,14 @@ Get recently changed appointments by `schedule_id`, with `from` time, `to` time,
|
|
172
172
|
|
173
173
|
Supersaas::Client.instance.appointments.changes(12345, '2018-01-31 00:00:00', '2019-01-31 00:00:00', true) #=> [<Supersaas::Appointment>, ...]
|
174
174
|
|
175
|
+
#### Get range of appointments
|
175
176
|
|
176
|
-
|
177
|
-
|
178
|
-
Get list of appointments by `schedule_id`, with `today`,`from` time, `to` time and `slot` view params (see [docs](https://www.supersaas.com/info/dev/appointment_api#range)),
|
177
|
+
Get range of appointments by `schedule_id`, with `today`, `from` time, `to` time and `slot` view params (see [docs](https://www.supersaas.com/info/dev/appointment_api#range)),
|
179
178
|
`range(schedule_id, today = false, from_time = nil, to = nil, slot = false, user = nil, resource_id = nil, service_id = nil, limit = nil, offset = nil)`:
|
180
179
|
|
181
180
|
Supersaas::Client.instance.appointments.range(12345, false, '2018-01-31 00:00:00', '2019-01-31 00:00:00', true) #=> [<Supersaas::Appointment>, ...]/[<Supersaas::Slot>, ...]
|
182
181
|
|
183
|
-
#### List Forms
|
182
|
+
#### List Template Forms
|
184
183
|
|
185
184
|
Get all forms by template `superform_id`, with `from_time`, and `user` params ([see](https://www.supersaas.com/info/dev/form_api)):
|
186
185
|
|
@@ -200,8 +199,8 @@ Get a list of Form templates (SuperForms):
|
|
200
199
|
|
201
200
|
#### List Promotions
|
202
201
|
|
203
|
-
Get a list of promotional coupon codes with
|
204
|
-
`list(
|
202
|
+
Get a list of promotional coupon codes with pagination parameters `limit` and `offset` (see [docs](https://www.supersaas.com/info/dev/promotion_api)),
|
203
|
+
`list(from_time = nil, user = nil)`:
|
205
204
|
|
206
205
|
Supersaas::Client.instance.promotions.list #=> [<Supersaas::Promotion>, ...]
|
207
206
|
|
@@ -213,9 +212,11 @@ Retrieve information about a single coupon code use with `promotion_code`:
|
|
213
212
|
|
214
213
|
#### Duplicate promotion code
|
215
214
|
|
216
|
-
Duplicate a template promotion by giving (new) `
|
215
|
+
Duplicate a template promotion by giving (new) `promotion_code` and `template_code` in that order,
|
216
|
+
duplicate_promotion_code(promotion_code, template_code):
|
217
|
+
|
217
218
|
|
218
|
-
Supersaas::Client.instance.promotions.duplicate_promotion_code(12345) #=> nil
|
219
|
+
Supersaas::Client.instance.promotions.duplicate_promotion_code(12345, 94832838) #=> nil
|
219
220
|
|
220
221
|
#### List Groups in an account
|
221
222
|
|
data/examples/appointments.rb
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
require 'date'
|
5
5
|
require 'supersaas-api-client'
|
6
6
|
|
7
|
-
puts
|
7
|
+
puts '# SuperSaaS Appointments Example'
|
8
8
|
|
9
9
|
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
10
|
-
puts
|
11
|
-
puts
|
10
|
+
puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
|
11
|
+
puts 'SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<api_key> ./examples/appointments.rb'
|
12
12
|
return
|
13
13
|
end
|
14
14
|
|
@@ -21,8 +21,8 @@ if ENV['SSS_API_SCHEDULE']
|
|
21
21
|
schedule_id = ENV['SSS_API_SCHEDULE']
|
22
22
|
show_slot = ENV['SSS_API_SLOT'] ? true : false
|
23
23
|
else
|
24
|
-
puts
|
25
|
-
puts
|
24
|
+
puts 'ERROR! Missing schedule id. Rerun the script with your schedule id, e.g.'
|
25
|
+
puts ' SSS_API_SCHEDULE=<scheduleid> ./examples/appointments.rb'
|
26
26
|
return
|
27
27
|
end
|
28
28
|
|
@@ -30,14 +30,13 @@ end
|
|
30
30
|
user_id = ENV.fetch('SSS_API_USER', nil)
|
31
31
|
|
32
32
|
unless user_id
|
33
|
-
puts
|
33
|
+
puts 'User is created and then deleted at the end'
|
34
34
|
params = { full_name: 'Example', name: 'example@example.com', email: 'example@example.com', api_key: 'example' }
|
35
35
|
user = Supersaas::Client.instance.users.create(params)
|
36
|
-
user_id = user.match(/
|
36
|
+
user_id = user.match(%r{users/(\d+)\.json})[1]
|
37
37
|
puts "#New user created #{user_id}"
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
40
|
description = nil
|
42
41
|
if user_id
|
43
42
|
description = '1234567890.'
|
@@ -50,26 +49,26 @@ if user_id
|
|
50
49
|
params[:start] = Time.now + (days * 24 * 60 * 60)
|
51
50
|
params[:finish] = params[:start] + (60 * 60)
|
52
51
|
end
|
53
|
-
puts
|
52
|
+
puts 'creating new appointment...'
|
54
53
|
puts "#### Supersaas::Client.instance.appointments.create(#{schedule_id}, #{user_id}, {...})"
|
55
54
|
Supersaas::Client.instance.appointments.create(schedule_id, user_id, params)
|
56
55
|
else
|
57
|
-
puts
|
56
|
+
puts 'skipping create/update/delete (NO DESTRUCTIVE ACTIONS FOR SCHEDULE DATA)...'
|
58
57
|
end
|
59
58
|
|
60
|
-
puts
|
59
|
+
puts 'listing appointments...'
|
61
60
|
puts "#### Supersaas::Client.instance.appointments.list(#{schedule_id}, nil, nil, 25)"
|
62
61
|
|
63
62
|
appointments = Supersaas::Client.instance.appointments.list(schedule_id, nil, nil, 25)
|
64
63
|
|
65
64
|
if appointments.size.positive?
|
66
65
|
appointment_id = appointments.sample.id
|
67
|
-
puts
|
66
|
+
puts 'getting appointment...'
|
68
67
|
puts "#### Supersaas::Client.instance.appointments.get(#{appointment_id})"
|
69
68
|
Supersaas::Client.instance.appointments.get(schedule_id, appointment_id)
|
70
69
|
end
|
71
70
|
|
72
|
-
puts
|
71
|
+
puts 'listing changes...'
|
73
72
|
from = DateTime.now - 120
|
74
73
|
to = DateTime.now + 360_000
|
75
74
|
puts "#### Supersaas::Client.instance.appointments.changes(#{schedule_id},
|
@@ -77,14 +76,14 @@ puts "#### Supersaas::Client.instance.appointments.changes(#{schedule_id},
|
|
77
76
|
|
78
77
|
Supersaas::Client.instance.appointments.changes(schedule_id, from, show_slot)
|
79
78
|
|
80
|
-
puts
|
79
|
+
puts 'listing available...'
|
81
80
|
from = DateTime.now
|
82
81
|
puts "#### Supersaas::Client.instance.appointments.available(#{schedule_id},
|
83
82
|
'#{from.strftime('%Y-%m-%d %H:%M:%S')}')"
|
84
83
|
|
85
84
|
Supersaas::Client.instance.appointments.available(schedule_id, from)
|
86
85
|
|
87
|
-
puts
|
86
|
+
puts 'Appointments for a single user...'
|
88
87
|
user = Supersaas::Client.instance.users.list(nil, 1).first
|
89
88
|
from = DateTime.now
|
90
89
|
puts "#### Supersaas::Client.instance.appointments.agenda(#{schedule_id}, user.id,
|
@@ -96,17 +95,15 @@ appointments.each do |appointment|
|
|
96
95
|
puts "#{description} == #{appointment.description}"
|
97
96
|
next unless description == appointment.description
|
98
97
|
|
99
|
-
puts
|
98
|
+
puts 'updating appointment...'
|
100
99
|
puts "#### Supersaas::Client.instance.appointments.update(#{schedule_id}, #{appointment.id}, {...})"
|
101
100
|
Supersaas::Client.instance.appointments.update(schedule_id, appointment.id, { country: 'FR', address: 'Rue 1' })
|
102
101
|
|
103
|
-
puts
|
102
|
+
puts 'deleting appointment...'
|
104
103
|
puts "#### Supersaas::Client.instance.appointments.delete(#{schedule_id}. #{appointment.id})"
|
105
104
|
Supersaas::Client.instance.appointments.delete(schedule_id, appointment.id)
|
106
105
|
break
|
107
106
|
end
|
108
107
|
|
109
108
|
# Puts delete user
|
110
|
-
unless ENV.fetch('SSS_API_USER', nil)
|
111
|
-
Supersaas::Client.instance.users.delete(user_id)
|
112
|
-
end
|
109
|
+
Supersaas::Client.instance.users.delete(user_id) unless ENV.fetch('SSS_API_USER', nil)
|
data/examples/forms.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'supersaas-api-client'
|
5
5
|
|
6
|
-
puts
|
6
|
+
puts '# SuperSaaS Forms Example'
|
7
7
|
|
8
8
|
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
9
|
-
puts
|
10
|
-
puts
|
9
|
+
puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
|
10
|
+
puts ' SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/appointments.rb'
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
@@ -16,22 +16,22 @@ puts "## API Key: #{'*' * Supersaas::Client.instance.api_key.size}"
|
|
16
16
|
|
17
17
|
Supersaas::Client.instance.verbose = true
|
18
18
|
|
19
|
-
puts
|
20
|
-
puts
|
19
|
+
puts 'You will need to create a form, and also attach the form to a booking, see documentation on how to do that'
|
20
|
+
puts 'The below example will take a form in random, and if it is not attached to something then 404 error will be raised'
|
21
21
|
|
22
|
-
puts
|
23
|
-
puts
|
22
|
+
puts 'listing forms...'
|
23
|
+
puts '#### Supersaas::Client.instance.forms.forms'
|
24
24
|
|
25
25
|
template_forms = Supersaas::Client.instance.forms.forms
|
26
26
|
|
27
27
|
if template_forms.size.positive?
|
28
28
|
template_form_id = template_forms.sample.id
|
29
29
|
|
30
|
-
puts
|
31
|
-
puts
|
30
|
+
puts 'listing forms from account'
|
31
|
+
puts '#### Supersaas::Client.instance.forms.list'
|
32
32
|
form_id = Supersaas::Client.instance.forms.list(template_form_id).sample.id
|
33
33
|
end
|
34
34
|
|
35
|
-
puts
|
35
|
+
puts 'getting form...'
|
36
36
|
puts "#### Supersaas::Client.instance.forms.get(#{form_id})"
|
37
37
|
Supersaas::Client.instance.forms.get(form_id)
|
data/examples/groups.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'supersaas-api-client'
|
4
4
|
|
5
|
-
puts
|
5
|
+
puts '# SuperSaaS Groups Example'
|
6
6
|
|
7
7
|
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
8
|
-
puts
|
9
|
-
puts
|
8
|
+
puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
|
9
|
+
puts 'SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/users.rb'
|
10
10
|
return
|
11
11
|
end
|
12
12
|
|
@@ -15,6 +15,6 @@ puts "## API KEY: #{'*' * Supersaas::Client.instance.api_key.size}"
|
|
15
15
|
|
16
16
|
Supersaas::Client.instance.verbose = true
|
17
17
|
|
18
|
-
puts
|
19
|
-
puts
|
18
|
+
puts 'listing groups...'
|
19
|
+
puts '#### Supersaas::Client.instance.groups.list'
|
20
20
|
Supersaas::Client.instance.groups.list
|
data/examples/promotions.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'supersaas-api-client'
|
4
4
|
|
5
|
-
puts
|
5
|
+
puts '# SuperSaaS Promotions Example'
|
6
6
|
|
7
7
|
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
8
|
-
puts
|
9
|
-
puts
|
8
|
+
puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
|
9
|
+
puts 'SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/users.rb'
|
10
10
|
return
|
11
11
|
end
|
12
12
|
|
@@ -15,12 +15,12 @@ puts "## API KEY: #{'*' * Supersaas::Client.instance.api_key.size}"
|
|
15
15
|
|
16
16
|
Supersaas::Client.instance.verbose = true
|
17
17
|
|
18
|
-
puts
|
19
|
-
puts
|
18
|
+
puts 'listing promotions...'
|
19
|
+
puts '#### Supersaas::Client.instance.promotions.list'
|
20
20
|
promotions = Supersaas::Client.instance.promotions.list
|
21
21
|
|
22
22
|
[10, promotions.size].min&.times do |i|
|
23
|
-
puts
|
23
|
+
puts 'A promotion'
|
24
24
|
puts "#### Supersaas::Client.instance.promotion(#{promotions[i].id})"
|
25
25
|
Supersaas::Client.instance.promotions.promotion(promotions[i].code)
|
26
26
|
end
|
data/examples/schedules.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'supersaas-api-client'
|
5
5
|
|
6
|
-
puts
|
6
|
+
puts '# SuperSaaS Schedules Example'
|
7
7
|
|
8
8
|
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
9
|
-
puts
|
10
|
-
puts
|
9
|
+
puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
|
10
|
+
puts 'SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/users.rb'
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
@@ -16,22 +16,22 @@ puts "## API KEY: #{'*' * Supersaas::Client.instance.api_key.size}"
|
|
16
16
|
|
17
17
|
Supersaas::Client.instance.verbose = true
|
18
18
|
|
19
|
-
puts
|
20
|
-
puts
|
19
|
+
puts 'listing schedules...'
|
20
|
+
puts '#### Supersaas::Client.instance.schedules.list'
|
21
21
|
schedules = Supersaas::Client.instance.schedules.list
|
22
22
|
|
23
|
-
puts
|
23
|
+
puts 'listing schedule resources...'
|
24
24
|
[10, schedules.size].min&.times do |i|
|
25
25
|
puts "#### Supersaas::Client.instance.schedules.resources(#{schedules[i].id})"
|
26
26
|
# Capacity schedules bomb
|
27
27
|
begin
|
28
|
-
|
29
|
-
rescue
|
28
|
+
Supersaas::Client.instance.schedules.resources(schedules[i].id)
|
29
|
+
rescue StandardError
|
30
30
|
next
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
puts
|
34
|
+
puts 'puts listing fields...'
|
35
35
|
[10, schedules.size].min&.times do |i|
|
36
36
|
puts "#### Supersaas::Client.instance.schedules.field_list(#{schedules[i].id})"
|
37
37
|
Supersaas::Client.instance.schedules.field_list(schedules[i].id)
|
data/examples/users.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'supersaas-api-client'
|
5
5
|
|
6
|
-
puts
|
6
|
+
puts '# SuperSaaS Users Example'
|
7
7
|
|
8
8
|
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
9
|
-
puts
|
10
|
-
puts
|
9
|
+
puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
|
10
|
+
puts 'SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/users.rb'
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
@@ -17,13 +17,13 @@ puts "## API Key: #{'*' * Supersaas::Client.instance.api_key.size}"
|
|
17
17
|
Supersaas::Client.instance.verbose = true
|
18
18
|
|
19
19
|
puts 'creating new user...'
|
20
|
-
puts
|
20
|
+
puts '#### Supersaas::Client.instance.users.create({...})'
|
21
21
|
params = { full_name: 'Example', name: 'example@example.com', email: 'example@example.com', api_key: 'example' }
|
22
22
|
Supersaas::Client.instance.users.create(params)
|
23
23
|
new_user_id = nil
|
24
24
|
|
25
|
-
puts
|
26
|
-
puts
|
25
|
+
puts 'listing users...'
|
26
|
+
puts '#### Supersaas::Client.instance.users.list(nil, 50)'
|
27
27
|
|
28
28
|
users = Supersaas::Client.instance.users.list(nil, 50)
|
29
29
|
users.each do |user|
|
@@ -31,29 +31,29 @@ users.each do |user|
|
|
31
31
|
end
|
32
32
|
|
33
33
|
if new_user_id
|
34
|
-
puts
|
34
|
+
puts 'getting user...'
|
35
35
|
puts "#### Supersaas::Client.instance.users.get(#{new_user_id})"
|
36
36
|
user = Supersaas::Client.instance.users.get(new_user_id)
|
37
37
|
|
38
|
-
puts
|
38
|
+
puts 'updating user...'
|
39
39
|
puts "#### Supersaas::Client.instance.users.update(#{new_user_id})"
|
40
40
|
Supersaas::Client.instance.users.update(new_user_id, { country: 'FR', address: 'Rue 1' })
|
41
41
|
|
42
|
-
puts
|
42
|
+
puts 'deleting user...'
|
43
43
|
puts "#### Supersaas::Client.instance.users.delete(#{user.id})"
|
44
44
|
Supersaas::Client.instance.users.delete(user.id)
|
45
45
|
else
|
46
|
-
puts
|
46
|
+
puts '... did not find user in list'
|
47
47
|
end
|
48
48
|
|
49
|
-
puts
|
50
|
-
puts
|
49
|
+
puts 'creating user with errors...'
|
50
|
+
puts '#### Supersaas::Client.instance.users.create'
|
51
51
|
begin
|
52
52
|
Supersaas::Client.instance.users.create({ name: 'error' })
|
53
53
|
rescue Supersaas::Exception => e
|
54
54
|
puts "This raises an error #{e.message}"
|
55
55
|
end
|
56
56
|
|
57
|
-
puts
|
57
|
+
puts '#### Supersaas::Client.instance.users.field_list'
|
58
58
|
Supersaas::Client.instance.users.field_list
|
59
59
|
puts
|
@@ -31,9 +31,9 @@ module Supersaas
|
|
31
31
|
length: length_minutes && validate_number(length_minutes),
|
32
32
|
from: validate_datetime(from_time),
|
33
33
|
resource: resource,
|
34
|
-
full: full ? true : nil
|
35
|
-
maxresults: limit && validate_number(limit)
|
34
|
+
full: full ? true : nil
|
36
35
|
}
|
36
|
+
params.merge!(maxresults: validate_number(limit)) if limit
|
37
37
|
res = client.get(path, params)
|
38
38
|
map_slots_or_bookings(res)
|
39
39
|
end
|
@@ -43,9 +43,9 @@ module Supersaas
|
|
43
43
|
params = {
|
44
44
|
schedule_id: validate_id(schedule_id),
|
45
45
|
form: form ? true : nil,
|
46
|
-
start: start_time ? validate_datetime(start_time) : nil
|
47
|
-
limit: limit && validate_number(limit)
|
46
|
+
start: start_time ? validate_datetime(start_time) : nil
|
48
47
|
}
|
48
|
+
params.merge!(maxresults: validate_number(limit)) if limit
|
49
49
|
res = client.get(path, params)
|
50
50
|
map_slots_or_bookings(res)
|
51
51
|
end
|
@@ -134,8 +134,8 @@ module Supersaas
|
|
134
134
|
limit = nil, offset = nil)
|
135
135
|
path = "/range/#{validate_id(schedule_id)}"
|
136
136
|
params = {}
|
137
|
-
params.merge!(today: true) if today
|
138
137
|
params = build_param(params, from_time, to, slot, user, limit, offset, resource_id, service_id)
|
138
|
+
params.merge!(today: true) if today
|
139
139
|
res = client.get(path, params)
|
140
140
|
map_slots_or_bookings(res)
|
141
141
|
end
|
@@ -5,10 +5,9 @@ module Supersaas
|
|
5
5
|
# REF: https://www.supersaas.com/info/dev/promotion_api
|
6
6
|
def list(limit = nil, offset = nil)
|
7
7
|
path = '/promotions'
|
8
|
-
params = {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
8
|
+
params = {}
|
9
|
+
params.merge!(limit: validate_number(limit)) if limit
|
10
|
+
params.merge!(offset: validate_number(offset)) if offset
|
12
11
|
res = client.get(path, params)
|
13
12
|
res.map { |attributes| Supersaas::Promotion.new(attributes) }
|
14
13
|
end
|
@@ -86,9 +86,9 @@ module Supersaas
|
|
86
86
|
# Represents the timestamp of the oldest request within the time window
|
87
87
|
oldest_request = @queue.push(Time.now).shift
|
88
88
|
# This ensures that the client does not make requests faster than the defined rate limit
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
return unless oldest_request && (d = Time.now - oldest_request) < WINDOW_SIZE
|
90
|
+
|
91
|
+
sleep WINDOW_SIZE - d
|
92
92
|
end
|
93
93
|
|
94
94
|
def request(http_method, path, params = {}, query = {})
|
@@ -146,7 +146,7 @@ module Supersaas
|
|
146
146
|
begin
|
147
147
|
res = http.request(req)
|
148
148
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
149
|
-
|
149
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
150
150
|
raise Supersaas::Exception, "HTTP Request Error (#{uri}#{path}): #{e.message}"
|
151
151
|
end
|
152
152
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supersaas-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaarle Kulvik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|