supersaas-api-client 0.10.0 → 1.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/README.md +10 -10
- data/examples/appointments.rb +3 -3
- data/examples/forms.rb +3 -3
- data/examples/schedules.rb +3 -3
- data/examples/users.rb +4 -4
- data/lib/supersaas-api-client/client.rb +6 -6
- data/lib/supersaas-api-client/version.rb +2 -2
- data/test/appointments_test.rb +1 -1
- data/test/client_test.rb +3 -3
- data/test/test_helper.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cd91008c369ed81daba9f3b18bf00e4d05ec9dd0e9251a1b3784b2a2c733c2e
|
4
|
+
data.tar.gz: 2f6140acf5eafe80cd6a393c9e1213c23702589fd9e83a1b0e715aca9ae16398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3fd7377e8aca4df5bd47ea3dc26211fd4eecc2c2406cfb55c4d914804b589c899ad5f0d2d8764f70de36f1a9d3646a9839219d9ae688bfa40dff905652dd793
|
7
|
+
data.tar.gz: 0ae95b465f2b6c48c07e9125be5a740483b268e23e9262805d3b63fd8971c6f4fd546128cc276fdae1e94549b2b15840f44018abb17c35e7257da3e3a29e75cb
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ The SuperSaaS API provides services that can be used to add online booking and s
|
|
7
7
|
## Prerequisites
|
8
8
|
|
9
9
|
1. [Register for a (free) SuperSaaS account](https://www.supersaas.com/accounts/new), and
|
10
|
-
2. get your account name and
|
10
|
+
2. get your account name and API key on the [Account Info](https://www.supersaas.com/accounts/edit) page.
|
11
11
|
|
12
12
|
##### Dependencies
|
13
13
|
|
@@ -43,21 +43,21 @@ Initialize the SuperSaaS `Client` with authorization credentials:
|
|
43
43
|
|
44
44
|
Supersaas::Client.configure do |config|
|
45
45
|
config.account_name = 'accnt'
|
46
|
-
config.
|
46
|
+
config.api_key = 'xxxxxxxxxxxxxxxxxxxxxx'
|
47
47
|
end
|
48
48
|
|
49
49
|
> Note, ensure that `configure` is called before `instance` or `new`, otherwise the client will be initialized with configuration defaults.
|
50
50
|
|
51
|
-
If the client isn't configured explicitly, it will use default `ENV` variables for the account name and
|
51
|
+
If the client isn't configured explicitly, it will use default `ENV` variables for the account name and api key.
|
52
52
|
|
53
53
|
ENV['SSS_API_ACCOUNT_NAME'] = 'your-env-supersaas-account-name'
|
54
|
-
ENV['
|
54
|
+
ENV['SSS_API_KEY'] = 'your-env-supersaas-account-name'
|
55
55
|
Supersaas::Client.instance.account_name #=> 'your-env-supersaas-account-name'
|
56
|
-
Supersaas::Client.instance.
|
56
|
+
Supersaas::Client.instance.api_key #=> 'your-env-supersaas-account-name'
|
57
57
|
|
58
58
|
All configuration options can be individually set on the client.
|
59
59
|
|
60
|
-
Supersaas::Client.instance.
|
60
|
+
Supersaas::Client.instance.api_key = 'xxxxxxxxxxxxxxxxxxxxxx'
|
61
61
|
Supersaas::Client.instance.verbose = true
|
62
62
|
...
|
63
63
|
|
@@ -189,12 +189,12 @@ Get a single form by `form_id`:
|
|
189
189
|
|
190
190
|
The ./examples folder contains several executable Ruby scripts demonstrating how to use the API Client for common requests.
|
191
191
|
|
192
|
-
The examples will require your account name,
|
192
|
+
The examples will require your account name, api key, and some of the examples a schedule id and/or user id and/or form id. These can be set as environment variables. e.g.
|
193
193
|
|
194
194
|
$ gem install supersaas-api-client
|
195
|
-
$ SSS_API_UID=myuserid SSS_API_SCHEDULE=myscheduleid SSS_API_ACCOUNT_NAME=myaccountname
|
196
|
-
$ SSS_API_FORM=myuserid SSS_API_ACCOUNT_NAME=myaccountname
|
197
|
-
$ SSS_API_ACCOUNT_NAME=myaccountname
|
195
|
+
$ SSS_API_UID=myuserid SSS_API_SCHEDULE=myscheduleid SSS_API_ACCOUNT_NAME=myaccountname SSS_API_KEY=xxxxxxxxxxxxxxxxxxxxxx ./examples/appointments.rb
|
196
|
+
$ SSS_API_FORM=myuserid SSS_API_ACCOUNT_NAME=myaccountname SSS_API_KEY=xxxxxxxxxxxxxxxxxxxxxx ./examples/forms.rb
|
197
|
+
$ SSS_API_ACCOUNT_NAME=myaccountname SSS_API_KEY=xxxxxxxxxxxxxxxxxxxxxx ./examples/users.rb
|
198
198
|
|
199
199
|
## Testing
|
200
200
|
|
data/examples/appointments.rb
CHANGED
@@ -6,14 +6,14 @@ require "supersaas-api-client"
|
|
6
6
|
|
7
7
|
puts "\n\r# SuperSaaS Appointments Example\n\r"
|
8
8
|
|
9
|
-
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.
|
9
|
+
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
10
10
|
puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
|
11
|
-
puts " SSS_API_ACCOUNT_NAME=<myaccountname>
|
11
|
+
puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<api_key> ./examples/appointments.rb\n\r"
|
12
12
|
return
|
13
13
|
end
|
14
14
|
|
15
15
|
puts "## Account: #{Supersaas::Client.instance.account_name}"
|
16
|
-
puts "##
|
16
|
+
puts "## API Key: #{'*' * Supersaas::Client.instance.api_key.size}\n\r"
|
17
17
|
|
18
18
|
Supersaas::Client.instance.verbose = true
|
19
19
|
|
data/examples/forms.rb
CHANGED
@@ -5,14 +5,14 @@ require "supersaas-api-client"
|
|
5
5
|
|
6
6
|
puts "\n\r# SuperSaaS Forms Example\n\r"
|
7
7
|
|
8
|
-
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.
|
8
|
+
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
9
9
|
puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
|
10
|
-
puts " SSS_API_ACCOUNT_NAME=<myaccountname>
|
10
|
+
puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/appointments.rb\n\r"
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
14
14
|
puts "## Account: #{Supersaas::Client.instance.account_name}"
|
15
|
-
puts "##
|
15
|
+
puts "## API Key: #{'*' * Supersaas::Client.instance.api_key.size}\n\r"
|
16
16
|
|
17
17
|
Supersaas::Client.instance.verbose = true
|
18
18
|
|
data/examples/schedules.rb
CHANGED
@@ -4,14 +4,14 @@ require "supersaas-api-client"
|
|
4
4
|
|
5
5
|
puts "\n\r# SuperSaaS Schedules Example\n\r"
|
6
6
|
|
7
|
-
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.
|
7
|
+
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
8
8
|
puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
|
9
|
-
puts " SSS_API_ACCOUNT_NAME=<myaccountname>
|
9
|
+
puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/users.rb\n\r"
|
10
10
|
return
|
11
11
|
end
|
12
12
|
|
13
13
|
puts "## Account: #{Supersaas::Client.instance.account_name}"
|
14
|
-
puts "##
|
14
|
+
puts "## API KEY: #{'*' * Supersaas::Client.instance.api_key.size}\n\r"
|
15
15
|
|
16
16
|
Supersaas::Client.instance.verbose = true
|
17
17
|
|
data/examples/users.rb
CHANGED
@@ -4,20 +4,20 @@ require "supersaas-api-client"
|
|
4
4
|
|
5
5
|
puts "\n\r# SuperSaaS Users Example\n\r"
|
6
6
|
|
7
|
-
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.
|
7
|
+
unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
|
8
8
|
puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
|
9
|
-
puts " SSS_API_ACCOUNT_NAME=<myaccountname>
|
9
|
+
puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/users.rb\n\r"
|
10
10
|
return
|
11
11
|
end
|
12
12
|
|
13
13
|
puts "## Account: #{Supersaas::Client.instance.account_name}"
|
14
|
-
puts "##
|
14
|
+
puts "## API Key: #{'*' * Supersaas::Client.instance.api_key.size}\n\r"
|
15
15
|
|
16
16
|
Supersaas::Client.instance.verbose = true
|
17
17
|
|
18
18
|
puts "creating new user..."
|
19
19
|
puts "\n\r#### Supersaas::Client.instance.users.create({...})\n\r"
|
20
|
-
params = {full_name: 'Example', name: 'example@example.com', email: 'example@example.com',
|
20
|
+
params = {full_name: 'Example', name: 'example@example.com', email: 'example@example.com', api_key: 'example'}
|
21
21
|
Supersaas::Client.instance.users.create(params)
|
22
22
|
new_user_id = nil
|
23
23
|
|
@@ -21,13 +21,13 @@ module Supersaas
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
attr_accessor :account_name, :
|
24
|
+
attr_accessor :account_name, :api_key, :host, :dry_run, :verbose
|
25
25
|
attr_reader :last_request
|
26
26
|
|
27
27
|
def initialize(configuration=nil)
|
28
28
|
configuration = configuration || Configuration.new
|
29
29
|
@account_name = configuration.account_name
|
30
|
-
@
|
30
|
+
@api_key = configuration.api_key
|
31
31
|
@host = configuration.host
|
32
32
|
@dry_run = configuration.dry_run
|
33
33
|
@verbose = configuration.verbose
|
@@ -58,7 +58,7 @@ module Supersaas
|
|
58
58
|
|
59
59
|
def request(http_method, path, params={}, query={})
|
60
60
|
raise Supersaas::Exception.new("Account name not configured. Call `Supersaas::Client.configure`.") unless account_name && account_name.size
|
61
|
-
raise Supersaas::Exception.new("Account
|
61
|
+
raise Supersaas::Exception.new("Account api key not configured. Call `Supersaas::Client.configure`.") unless api_key && api_key.size
|
62
62
|
|
63
63
|
uri = URI.parse(host)
|
64
64
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -86,7 +86,7 @@ module Supersaas
|
|
86
86
|
raise Supersaas::Exception.new("Invalid HTTP Method: #{http_method}. Only `:get`, `:post`, `:put`, `:delete` supported.")
|
87
87
|
end
|
88
88
|
|
89
|
-
req.basic_auth account_name,
|
89
|
+
req.basic_auth account_name, api_key
|
90
90
|
|
91
91
|
req['Accept'] = 'application/json'
|
92
92
|
req['Content-Type'] = 'application/json'
|
@@ -145,11 +145,11 @@ module Supersaas
|
|
145
145
|
class Configuration
|
146
146
|
DEFAULT_HOST = 'https://www.supersaas.com'
|
147
147
|
|
148
|
-
attr_accessor :account_name, :host, :
|
148
|
+
attr_accessor :account_name, :host, :api_key, :dry_run, :verbose
|
149
149
|
|
150
150
|
def initialize
|
151
151
|
@account_name = ENV['SSS_API_ACCOUNT_NAME']
|
152
|
-
@
|
152
|
+
@api_key = ENV['SSS_API_KEY']
|
153
153
|
@host = DEFAULT_HOST
|
154
154
|
@dry_run = false
|
155
155
|
@verbose = false
|
data/test/appointments_test.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -17,7 +17,7 @@ module Supersaas
|
|
17
17
|
|
18
18
|
def test_request_methods
|
19
19
|
@client.account_name = 'Test'
|
20
|
-
@client.
|
20
|
+
@client.api_key = 'testing123'
|
21
21
|
[:get,:put,:post,:delete].each do |method|
|
22
22
|
refute_nil @client.send(method, '/test')
|
23
23
|
assert_equal method.to_s.upcase, @client.last_request.method
|
@@ -31,13 +31,13 @@ module Supersaas
|
|
31
31
|
def test_instance_configuration
|
32
32
|
Supersaas::Client.configure do |config|
|
33
33
|
config.account_name = 'account'
|
34
|
-
config.
|
34
|
+
config.api_key = 'api_key'
|
35
35
|
config.host = 'http://test'
|
36
36
|
config.dry_run = true
|
37
37
|
config.verbose = true
|
38
38
|
end
|
39
39
|
assert_equal 'account', Supersaas::Client.configuration.account_name
|
40
|
-
assert_equal '
|
40
|
+
assert_equal 'api_key', Supersaas::Client.configuration.api_key
|
41
41
|
assert_equal 'http://test', Supersaas::Client.configuration.host
|
42
42
|
assert_equal true, Supersaas::Client.configuration.dry_run
|
43
43
|
assert_equal true, Supersaas::Client.configuration.verbose
|
data/test/test_helper.rb
CHANGED
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
|
121
|
-
rubygems_version: 2.7.6
|
120
|
+
rubygems_version: 3.0.1
|
122
121
|
signing_key:
|
123
122
|
specification_version: 4
|
124
123
|
summary: Online bookings/appointments/calendars using the SuperSaaS scheduling platform.
|