supersaas-api-client 1.1.0 → 2.0.0
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/.github/workflows/actions.yaml +21 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +296 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +34 -7
- data/README.md +109 -58
- data/Rakefile +8 -6
- data/bin/console +4 -3
- data/examples/appointments.rb +70 -42
- data/examples/forms.rb +20 -22
- data/examples/groups.rb +20 -0
- data/examples/promotions.rb +32 -0
- data/examples/schedules.rb +23 -11
- data/examples/users.rb +31 -23
- data/lib/supersaas-api-client/api/appointments.rb +37 -25
- data/lib/supersaas-api-client/api/base_api.rb +69 -23
- data/lib/supersaas-api-client/api/forms.rb +16 -9
- data/lib/supersaas-api-client/api/groups.rb +12 -0
- data/lib/supersaas-api-client/api/promotions.rb +29 -0
- data/lib/supersaas-api-client/api/schedules.rb +14 -4
- data/lib/supersaas-api-client/api/users.rb +28 -15
- data/lib/supersaas-api-client/client.rb +106 -36
- data/lib/supersaas-api-client/exception.rb +3 -1
- data/lib/supersaas-api-client/models/appointment.rb +9 -12
- data/lib/supersaas-api-client/models/base_model.rb +4 -1
- data/lib/supersaas-api-client/models/field_list.rb +12 -0
- data/lib/supersaas-api-client/models/form.rb +5 -2
- data/lib/supersaas-api-client/models/group.rb +7 -0
- data/lib/supersaas-api-client/models/promotion.rb +7 -0
- data/lib/supersaas-api-client/models/resource.rb +3 -1
- data/lib/supersaas-api-client/models/schedule.rb +3 -1
- data/lib/supersaas-api-client/models/slot.rb +4 -6
- data/lib/supersaas-api-client/models/super_form.rb +7 -0
- data/lib/supersaas-api-client/models/user.rb +5 -8
- data/lib/supersaas-api-client/version.rb +4 -2
- data/lib/supersaas-api-client.rb +3 -1
- data/lib/supersaas.rb +23 -15
- data/supersaas-api-client.gemspec +19 -18
- metadata +52 -38
- data/test/appointments_test.rb +0 -99
- data/test/client_test.rb +0 -46
- data/test/forms_test.rb +0 -22
- data/test/schedules_test.rb +0 -19
- data/test/test_helper.rb +0 -23
- data/test/users_test.rb +0 -68
metadata
CHANGED
@@ -1,68 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supersaas-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Kaarle Kulvik
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rubocop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description: Online appointment
|
56
|
-
booking software that can be integrated into any site. Free basic version.
|
68
|
+
version: '0'
|
69
|
+
description: Online appointment scheduling for any type of business. Flexible and
|
70
|
+
affordable booking software that can be integrated into any site. Free basic version.
|
57
71
|
email:
|
58
|
-
-
|
72
|
+
- kaarle@supersaas.com
|
59
73
|
executables:
|
60
74
|
- console
|
61
75
|
- setup
|
62
76
|
extensions: []
|
63
77
|
extra_rdoc_files: []
|
64
78
|
files:
|
79
|
+
- ".github/workflows/actions.yaml"
|
65
80
|
- ".gitignore"
|
81
|
+
- ".rubocop.yml"
|
82
|
+
- ".rubocop_todo.yml"
|
66
83
|
- Gemfile
|
67
84
|
- Gemfile.lock
|
68
85
|
- LICENSE
|
@@ -72,37 +89,40 @@ files:
|
|
72
89
|
- bin/setup
|
73
90
|
- examples/appointments.rb
|
74
91
|
- examples/forms.rb
|
92
|
+
- examples/groups.rb
|
93
|
+
- examples/promotions.rb
|
75
94
|
- examples/schedules.rb
|
76
95
|
- examples/users.rb
|
77
96
|
- lib/supersaas-api-client.rb
|
78
97
|
- lib/supersaas-api-client/api/appointments.rb
|
79
98
|
- lib/supersaas-api-client/api/base_api.rb
|
80
99
|
- lib/supersaas-api-client/api/forms.rb
|
100
|
+
- lib/supersaas-api-client/api/groups.rb
|
101
|
+
- lib/supersaas-api-client/api/promotions.rb
|
81
102
|
- lib/supersaas-api-client/api/schedules.rb
|
82
103
|
- lib/supersaas-api-client/api/users.rb
|
83
104
|
- lib/supersaas-api-client/client.rb
|
84
105
|
- lib/supersaas-api-client/exception.rb
|
85
106
|
- lib/supersaas-api-client/models/appointment.rb
|
86
107
|
- lib/supersaas-api-client/models/base_model.rb
|
108
|
+
- lib/supersaas-api-client/models/field_list.rb
|
87
109
|
- lib/supersaas-api-client/models/form.rb
|
110
|
+
- lib/supersaas-api-client/models/group.rb
|
111
|
+
- lib/supersaas-api-client/models/promotion.rb
|
88
112
|
- lib/supersaas-api-client/models/resource.rb
|
89
113
|
- lib/supersaas-api-client/models/schedule.rb
|
90
114
|
- lib/supersaas-api-client/models/slot.rb
|
115
|
+
- lib/supersaas-api-client/models/super_form.rb
|
91
116
|
- lib/supersaas-api-client/models/user.rb
|
92
117
|
- lib/supersaas-api-client/version.rb
|
93
118
|
- lib/supersaas.rb
|
94
119
|
- supersaas-api-client.gemspec
|
95
|
-
- test/appointments_test.rb
|
96
|
-
- test/client_test.rb
|
97
|
-
- test/forms_test.rb
|
98
|
-
- test/schedules_test.rb
|
99
|
-
- test/test_helper.rb
|
100
|
-
- test/users_test.rb
|
101
120
|
homepage: https://www.supersaas.com
|
102
121
|
licenses:
|
103
122
|
- MIT
|
104
|
-
metadata:
|
105
|
-
|
123
|
+
metadata:
|
124
|
+
rubygems_mfa_required: 'true'
|
125
|
+
post_install_message:
|
106
126
|
rdoc_options: []
|
107
127
|
require_paths:
|
108
128
|
- lib
|
@@ -117,14 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
137
|
- !ruby/object:Gem::Version
|
118
138
|
version: '0'
|
119
139
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
121
|
-
signing_key:
|
140
|
+
rubygems_version: 3.4.22
|
141
|
+
signing_key:
|
122
142
|
specification_version: 4
|
123
|
-
summary:
|
124
|
-
test_files:
|
125
|
-
- test/forms_test.rb
|
126
|
-
- test/client_test.rb
|
127
|
-
- test/test_helper.rb
|
128
|
-
- test/users_test.rb
|
129
|
-
- test/schedules_test.rb
|
130
|
-
- test/appointments_test.rb
|
143
|
+
summary: Manage appointments and users on the SuperSaaS scheduling platform
|
144
|
+
test_files: []
|
data/test/appointments_test.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Supersaas
|
4
|
-
class AppointmentsTest < SupersaasTest
|
5
|
-
def setup
|
6
|
-
@client = Supersaas::Client.instance
|
7
|
-
@client.account_name = 'accnt'
|
8
|
-
@client.api_key = 'xxxxxxxxxxxxxxxxxxxxxx'
|
9
|
-
@client.dry_run = true
|
10
|
-
@schedule_id = 12345
|
11
|
-
@appointment_id = 67890
|
12
|
-
@user_id = 9876
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_get
|
16
|
-
refute_nil @client.appointments.get(@schedule_id, @appointment_id)
|
17
|
-
assert_last_request_path "/api/bookings/#{@appointment_id}.json?schedule_id=#{@schedule_id}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_list
|
21
|
-
start_time = Time.now
|
22
|
-
limit = 10
|
23
|
-
form = true
|
24
|
-
refute_nil @client.appointments.list(@schedule_id, form, start_time, limit)
|
25
|
-
assert_last_request_path "/api/bookings.json?schedule_id=#{@schedule_id}&form=true&#{URI.encode_www_form(start: start_time.strftime("%Y-%m-%d %H:%M:%S"))}&limit=#{limit}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_create
|
29
|
-
refute_nil @client.appointments.create(@schedule_id, @user_id, appointment_attributes, true, true)
|
30
|
-
assert_last_request_path "/api/bookings.json"
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_update
|
34
|
-
refute_nil @client.appointments.update(@schedule_id, @appointment_id, appointment_attributes)
|
35
|
-
assert_last_request_path "/api/bookings/#{@appointment_id}.json"
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_agenda
|
39
|
-
refute_nil @client.appointments.agenda(@schedule_id, @user_id).inspect
|
40
|
-
assert_last_request_path "/api/agenda/#{@schedule_id}.json?user=#{@user_id}"
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_agenda_slots
|
44
|
-
refute_nil @client.appointments.agenda_slots(@schedule_id, @user_id).inspect
|
45
|
-
assert_last_request_path "/api/agenda/#{@schedule_id}.json?user=#{@user_id}&slot=true"
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_available
|
49
|
-
from_time = Time.now
|
50
|
-
refute_nil @client.appointments.available(@schedule_id, from_time)
|
51
|
-
assert_last_request_path "/api/free/#{@schedule_id}.json?#{URI.encode_www_form(from: from_time.strftime("%Y-%m-%d %H:%M:%S"))}"
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_available_full
|
55
|
-
length_minutes = 15
|
56
|
-
resource = 'MyResource'
|
57
|
-
limit = 10
|
58
|
-
refute_nil @client.appointments.available(@schedule_id, "2017-01-31 14:30:00", length_minutes, resource, true, limit)
|
59
|
-
assert_last_request_path "/api/free/#{@schedule_id}.json?length=#{length_minutes}&#{URI.encode_www_form(from: "2017-01-31 14:30:00")}&resource=#{resource}&full=true&maxresults=#{limit}"
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_changes
|
63
|
-
from = "2017-01-31 14:30:00"
|
64
|
-
refute_nil @client.appointments.changes(@schedule_id, from)
|
65
|
-
assert_last_request_path "/api/changes/#{@schedule_id}.json?#{URI.encode_www_form(from: from)}"
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_range
|
69
|
-
from = "2017-01-31 14:30:00"
|
70
|
-
refute_nil @client.appointments.range(@schedule_id, false, from)
|
71
|
-
assert_last_request_path "/api/range/#{@schedule_id}.json?#{URI.encode_www_form(from: from)}"
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_delete
|
75
|
-
refute_nil @client.appointments.delete(@schedule_id, @appointment_id)
|
76
|
-
assert_last_request_path "/api/bookings/#{@appointment_id}.json?schedule_id=#{@schedule_id}"
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def appointment_attributes
|
82
|
-
{
|
83
|
-
description: 'Testing.',
|
84
|
-
name: 'Test',
|
85
|
-
email: 'test@example.com',
|
86
|
-
full_name: 'Tester Test',
|
87
|
-
address: '123 St, City',
|
88
|
-
mobile: '555-5555',
|
89
|
-
phone: '555-5555',
|
90
|
-
country: 'FR',
|
91
|
-
field_1: 'f 1',
|
92
|
-
field_2: 'f 2',
|
93
|
-
field_1_r: 'f 1 r',
|
94
|
-
field_2_r: 'f 2 r',
|
95
|
-
super_field: 'sf'
|
96
|
-
}
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/test/client_test.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Supersaas
|
4
|
-
class ClientTest < SupersaasTest
|
5
|
-
def setup
|
6
|
-
config = Supersaas::Client::Configuration.new
|
7
|
-
@client = Supersaas::Client.new(config)
|
8
|
-
@client.dry_run = true
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_api
|
12
|
-
refute_nil @client.appointments
|
13
|
-
refute_nil @client.forms
|
14
|
-
refute_nil @client.schedules
|
15
|
-
refute_nil @client.users
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_request_methods
|
19
|
-
@client.account_name = 'Test'
|
20
|
-
@client.api_key = 'testing123'
|
21
|
-
[:get,:put,:post,:delete].each do |method|
|
22
|
-
refute_nil @client.send(method, '/test')
|
23
|
-
assert_equal method.to_s.upcase, @client.last_request.method
|
24
|
-
assert_equal '/api/test.json', @client.last_request.path
|
25
|
-
end
|
26
|
-
assert_equal 'Basic VGVzdDp0ZXN0aW5nMTIz', @client.last_request['Authorization']
|
27
|
-
assert_equal 'application/json', @client.last_request['Accept']
|
28
|
-
assert_equal 'application/json', @client.last_request['Content-Type']
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_instance_configuration
|
32
|
-
Supersaas::Client.configure do |config|
|
33
|
-
config.account_name = 'account'
|
34
|
-
config.api_key = 'api_key'
|
35
|
-
config.host = 'http://test'
|
36
|
-
config.dry_run = true
|
37
|
-
config.verbose = true
|
38
|
-
end
|
39
|
-
assert_equal 'account', Supersaas::Client.configuration.account_name
|
40
|
-
assert_equal 'api_key', Supersaas::Client.configuration.api_key
|
41
|
-
assert_equal 'http://test', Supersaas::Client.configuration.host
|
42
|
-
assert_equal true, Supersaas::Client.configuration.dry_run
|
43
|
-
assert_equal true, Supersaas::Client.configuration.verbose
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/test/forms_test.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Supersaas
|
4
|
-
class FormsTest < SupersaasTest
|
5
|
-
def setup
|
6
|
-
@client = client_instance
|
7
|
-
@super_form_id = 12345
|
8
|
-
@form_id = 67890
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_list
|
12
|
-
from = Time.now
|
13
|
-
refute_nil @client.forms.list(@super_form_id, from)
|
14
|
-
assert_last_request_path "/api/forms.json?form_id=#{@super_form_id}&#{URI.encode_www_form(from: from.strftime("%Y-%m-%d %H:%M:%S"))}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_get
|
18
|
-
refute_nil @client.forms.get(@form_id)
|
19
|
-
assert_last_request_path "/api/forms.json?id=#{@form_id}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/test/schedules_test.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Supersaas
|
4
|
-
class SchedulesTest < SupersaasTest
|
5
|
-
def setup
|
6
|
-
@client = client_instance
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_list
|
10
|
-
refute_nil @client.schedules.list
|
11
|
-
assert_last_request_path "/api/schedules.json"
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_resources
|
15
|
-
refute_nil @client.schedules.resources(12345)
|
16
|
-
assert_last_request_path "/api/resources.json?schedule_id=12345"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
$:.push File.expand_path('../../lib', __FILE__)
|
2
|
-
|
3
|
-
require "supersaas-api-client"
|
4
|
-
|
5
|
-
require "minitest/autorun"
|
6
|
-
|
7
|
-
class SupersaasTest < Minitest::Test
|
8
|
-
def assert_last_request_path(path)
|
9
|
-
assert_equal path, @client.last_request.path
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def client_instance
|
15
|
-
if !defined? @client
|
16
|
-
@client = Supersaas::Client.instance
|
17
|
-
@client.account_name = 'accnt'
|
18
|
-
@client.api_key = 'xxxxxxxxxxxxxxxxxxxxxx'
|
19
|
-
@client.dry_run = true
|
20
|
-
end
|
21
|
-
@client
|
22
|
-
end
|
23
|
-
end
|
data/test/users_test.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Supersaas
|
4
|
-
class UsersTest < SupersaasTest
|
5
|
-
def setup
|
6
|
-
@client = client_instance
|
7
|
-
@user_id = 12345
|
8
|
-
@user_fk = '6789fk'
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_get
|
12
|
-
refute_nil @client.users.get(@user_id)
|
13
|
-
assert_last_request_path "/api/users/#{@user_id}.json"
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_get_fk
|
17
|
-
refute_nil @client.users.get(@user_fk)
|
18
|
-
assert_last_request_path "/api/users/#{@user_fk}.json"
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_list
|
22
|
-
limit = 10
|
23
|
-
offset = 0
|
24
|
-
refute_nil @client.users.list(true, limit, offset)
|
25
|
-
assert_last_request_path "/api/users.json?form=true&limit=#{limit}&offset=#{offset}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_create
|
29
|
-
refute_nil @client.users.create(user_attributes)
|
30
|
-
assert_last_request_path "/api/users.json"
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_create_fk
|
34
|
-
refute_nil @client.users.create(user_attributes, @user_fk, true)
|
35
|
-
assert_last_request_path "/api/users/#{@user_fk}.json?webhook=true"
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_update
|
39
|
-
refute_nil @client.users.update(@user_id, user_attributes, true)
|
40
|
-
assert_last_request_path "/api/users/#{@user_id}.json?webhook=true"
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_delete
|
44
|
-
refute_nil @client.users.delete(@user_id)
|
45
|
-
assert_last_request_path "/api/users/#{@user_id}.json"
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def user_attributes
|
51
|
-
{
|
52
|
-
name: 'Test',
|
53
|
-
email: 'test@example.com',
|
54
|
-
password: 'pass123',
|
55
|
-
full_name: 'Tester Test',
|
56
|
-
address: '123 St, City',
|
57
|
-
mobile: '555-5555',
|
58
|
-
phone: '555-5555',
|
59
|
-
country: 'FR',
|
60
|
-
field_1: 'f 1',
|
61
|
-
field_2: 'f 2',
|
62
|
-
super_field: 'sf',
|
63
|
-
credit: 10,
|
64
|
-
role: 3
|
65
|
-
}
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|