supersaas-api-client 0.9.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 +7 -0
- data/.gitignore +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +21 -0
- data/README.md +252 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/appointments.rb +84 -0
- data/examples/forms.rb +39 -0
- data/examples/schedules.rb +27 -0
- data/examples/users.rb +51 -0
- data/lib/supersaas-api-client/api/appointments.rb +152 -0
- data/lib/supersaas-api-client/api/base_api.rb +55 -0
- data/lib/supersaas-api-client/api/forms.rb +21 -0
- data/lib/supersaas-api-client/api/schedules.rb +16 -0
- data/lib/supersaas-api-client/api/users.rb +82 -0
- data/lib/supersaas-api-client/client.rb +159 -0
- data/lib/supersaas-api-client/exception.rb +8 -0
- data/lib/supersaas-api-client/models/appointment.rb +22 -0
- data/lib/supersaas-api-client/models/base_model.rb +19 -0
- data/lib/supersaas-api-client/models/form.rb +5 -0
- data/lib/supersaas-api-client/models/resource.rb +5 -0
- data/lib/supersaas-api-client/models/schedule.rb +5 -0
- data/lib/supersaas-api-client/models/slot.rb +14 -0
- data/lib/supersaas-api-client/models/user.rb +16 -0
- data/lib/supersaas-api-client/version.rb +4 -0
- data/lib/supersaas-api-client.rb +1 -0
- data/lib/supersaas.rb +15 -0
- data/supersaas-api-client.gemspec +27 -0
- data/test/appointments_test.rb +99 -0
- data/test/client_test.rb +46 -0
- data/test/forms_test.rb +22 -0
- data/test/schedules_test.rb +19 -0
- data/test/test_helper.rb +23 -0
- data/test/users_test.rb +68 -0
- metadata +131 -0
@@ -0,0 +1,99 @@
|
|
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.password = 'pwd'
|
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_changes_slots
|
69
|
+
from = Time.now
|
70
|
+
refute_nil @client.appointments.changes_slots(@schedule_id, from)
|
71
|
+
assert_last_request_path "/api/changes/#{@schedule_id}.json?#{URI.encode_www_form(from: from.strftime("%Y-%m-%d %H:%M:%S"))}&slot=true"
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_delete
|
75
|
+
refute_nil @client.appointments.delete(@appointment_id)
|
76
|
+
assert_last_request_path "/api/bookings/#{@appointment_id}.json"
|
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
ADDED
@@ -0,0 +1,46 @@
|
|
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.password = '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.password = 'password'
|
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 'password', Supersaas::Client.configuration.password
|
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
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
@@ -0,0 +1,19 @@
|
|
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
ADDED
@@ -0,0 +1,23 @@
|
|
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.password = 'pwd'
|
19
|
+
@client.dry_run = true
|
20
|
+
end
|
21
|
+
@client
|
22
|
+
end
|
23
|
+
end
|
data/test/users_test.rb
ADDED
@@ -0,0 +1,68 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: supersaas-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Travis Dunn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Online appointment scheduler for any type of business. Flexible and affordable
|
56
|
+
booking software that can be integrated into any site. Free basic version.
|
57
|
+
email:
|
58
|
+
- travis@supersaas.com
|
59
|
+
executables:
|
60
|
+
- console
|
61
|
+
- setup
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- examples/appointments.rb
|
74
|
+
- examples/forms.rb
|
75
|
+
- examples/schedules.rb
|
76
|
+
- examples/users.rb
|
77
|
+
- lib/supersaas-api-client.rb
|
78
|
+
- lib/supersaas-api-client/api/appointments.rb
|
79
|
+
- lib/supersaas-api-client/api/base_api.rb
|
80
|
+
- lib/supersaas-api-client/api/forms.rb
|
81
|
+
- lib/supersaas-api-client/api/schedules.rb
|
82
|
+
- lib/supersaas-api-client/api/users.rb
|
83
|
+
- lib/supersaas-api-client/client.rb
|
84
|
+
- lib/supersaas-api-client/exception.rb
|
85
|
+
- lib/supersaas-api-client/models/appointment.rb
|
86
|
+
- lib/supersaas-api-client/models/base_model.rb
|
87
|
+
- lib/supersaas-api-client/models/form.rb
|
88
|
+
- lib/supersaas-api-client/models/resource.rb
|
89
|
+
- lib/supersaas-api-client/models/schedule.rb
|
90
|
+
- lib/supersaas-api-client/models/slot.rb
|
91
|
+
- lib/supersaas-api-client/models/user.rb
|
92
|
+
- lib/supersaas-api-client/version.rb
|
93
|
+
- lib/supersaas.rb
|
94
|
+
- 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
|
+
homepage: https://www.supersaas.com
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.7.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Online bookings/appointments/calendars using the SuperSaaS scheduling platform.
|
125
|
+
test_files:
|
126
|
+
- test/appointments_test.rb
|
127
|
+
- test/client_test.rb
|
128
|
+
- test/forms_test.rb
|
129
|
+
- test/schedules_test.rb
|
130
|
+
- test/test_helper.rb
|
131
|
+
- test/users_test.rb
|