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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2de956c3f1649c9bfbee7b31f966400071895afbdf1815a488c8fa99d2f32d61
4
+ data.tar.gz: 4184f2dd95b283d588ef1465d5ee18aa9b3ae393e90805badc196168218a8f09
5
+ SHA512:
6
+ metadata.gz: 5a71ff165dc07cddaccb615b8f55264d8091fa125336da21d1fba902e16d630f48cdb3f30f35873bb923d7c6b10fb673733b4c8f1d5a44e500eb6d92fb7cdd3e
7
+ data.tar.gz: 3f48e1883d801d77badc577c785efb09a1b43e13b05b0fd94b8956de44d3ed9bb0d5448ff74fba1845372b390209d9d8aa0a44163377e0dacf784494724cc55d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .DS_Store
10
+ .idea/*
11
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ supersaas-api-client (0.9.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.11.3)
10
+ rake (10.5.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.16)
17
+ minitest (~> 5.0)
18
+ rake (~> 10.0)
19
+ supersaas-api-client!
20
+
21
+ BUNDLED WITH
22
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 SuperSaaS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,252 @@
1
+ # SuperSaaS Ruby API Client
2
+
3
+ Online bookings/appointments/calendars in Ruby using the SuperSaaS scheduling platform - https://supersaas.com
4
+
5
+ The SuperSaaS API provides services that can be used to add online booking and scheduling functionality to an existing website or CRM software.
6
+
7
+ ## Prerequisites
8
+
9
+ 1. [Register for a (free) SuperSaaS account](https://www.supersaas.com/accounts/new), and
10
+ 2. get your account name and password.
11
+
12
+ ##### Dependencies
13
+
14
+ Ruby 1.9 or greater.
15
+
16
+ No external libraries. Only the native `json` and `net/http` standard libs are used.
17
+
18
+ ## Installation
19
+
20
+ 1: Gemfile
21
+
22
+ The SuperSaaS Ruby API Client is available from RubyGems and can be included in your project GemFile. Note, the supersaas-api-client may update major versions with breaking changes, so it's recommended to use a major version when expressing the gem dependency. e.g.
23
+
24
+ gem 'supersaas-api-client', '~> 1'
25
+
26
+ 2: System Gem
27
+
28
+ You can install the SuperSaaS Ruby API Client globally by using the gem command. Open a terminal and enter the following command:
29
+
30
+ $ gem install supersaas-api-client
31
+
32
+ ## Configuration
33
+
34
+ The `Client` can be used either (1) through the singleton helper method `instance`, e.g.
35
+
36
+ Supersaas::Client.instance #=> <Supersaas::Client>
37
+
38
+ Or else by (2) simply creating a new client instance manually, e.g.
39
+
40
+ Supersaas::Client.new #=> <Supersaas::Client>
41
+
42
+ Initialize the SuperSaaS `Client` with authorization credentials:
43
+
44
+ Supersaas::Client.configure do |config|
45
+ config.account_name = 'accnt'
46
+ config.password = 'pwd'
47
+ end
48
+
49
+ > Note, ensure that `configure` is called before `instance` or `new`, otherwise the client will be initialized with configuration defaults.
50
+
51
+ If the client isn't configured explicitly, it will use default `ENV` variables for the account name and password.
52
+
53
+ ENV['SSS_API_ACCOUNT_NAME'] = 'your-env-supersaas-account-name'
54
+ ENV['SSS_API_PASSWORD'] = 'your-env-supersaas-account-name'
55
+ Supersaas::Client.instance.account_name #=> 'your-env-supersaas-account-name'
56
+ Supersaas::Client.instance.password #=> 'your-env-supersaas-account-name'
57
+
58
+ All configuration options can be individually set on the client.
59
+
60
+ Supersaas::Client.instance.password = 'pwd'
61
+ Supersaas::Client.instance.verbose = true
62
+ ...
63
+
64
+ ## API Methods
65
+
66
+ Details of the data structures, parameters, and values can be found on the developer documentation site:
67
+
68
+ https://www.supersaas.com/info/dev
69
+
70
+ #### List Schedules
71
+
72
+ Get all account schedules:
73
+
74
+ Supersaas::Client.instance.schedules.list #=> [<Supersaas::Schedule>, ...]
75
+
76
+ #### List Resource
77
+
78
+ Get all services/resources by `schedule_id`:
79
+
80
+ Supersaas::Client.instance.schedules.resources(12345) #=> [<Supersaas::Resource>, ...]
81
+
82
+ _Note: does not work for capacity type schedules._
83
+
84
+ #### Create User
85
+
86
+ Create a user with user attributes params:
87
+
88
+ Supersaas::Client.instance.users.create({full_name: 'Example Name', email: 'example@example.com'}) #=> nil
89
+
90
+ #### Update User
91
+
92
+ Update a user by `user_id` with user attributes params:
93
+
94
+ Supersaas::Client.instance.users.update(12345, {full_name: 'New Name'}) #=> nil
95
+
96
+ #### Delete User
97
+
98
+ Delete a single user by `user_id`:
99
+
100
+ Supersaas::Client.instance.users.delete(12345) #=> nil
101
+
102
+ #### Get User
103
+
104
+ Get a single user by `user_id`:
105
+
106
+ Supersaas::Client.instance.users.get(12345) #=> <Supersaas::User>
107
+
108
+ #### List Users
109
+
110
+ Get all users with optional `form` and `limit`/`offset` pagination params:
111
+
112
+ Supersaas::Client.instance.users.list(false, 25, 0) #=> [<Supersaas::User>, ...]
113
+
114
+ #### Create Appointment/Booking
115
+
116
+ Create an appointment by `schedule_id` and `user_id` with appointment attributes and `form` and `webhook` params:
117
+
118
+ Supersaas::Client.instance.appointments.create(12345, 67890, {full_name: 'Example Name', email: 'example@example.com', slot_id: 12345}, true, true) #=> nil
119
+
120
+ #### Update Appointment/Booking
121
+
122
+ Update an appointment by `schedule_id` and `appointment_id` with appointment attributes params:
123
+
124
+ Supersaas::Client.instance.appointments.update(12345, 67890, {full_name: 'New Name'}) #=> nil
125
+
126
+ #### Delete Appointment/Booking
127
+
128
+ Delete a single appointment by `appointment_id`:
129
+
130
+ Supersaas::Client.instance.appointments.delete(12345) #=> nil
131
+
132
+ #### Get Appointment/Booking
133
+
134
+ Get a single appointment by `schedule_id` and `appointment_id`:
135
+
136
+ Supersaas::Client.instance.appointments.get(12345, 67890) #=> <Supersaas::Appointment>
137
+
138
+ #### List Appointments/Bookings
139
+
140
+ List appointments by `schedule_id`, with `form` and `start_time` and `limit` view params:
141
+
142
+ Supersaas::Client.instance.appointments.list(12345, 67890, true, true) #=> [<Supersaas::Appointment>, ...]
143
+
144
+ #### Get Agenda
145
+
146
+ Get agenda (upcoming) appointments by `schedule_id` and `user_id`, with `from_time` view param:
147
+
148
+ Supersaas::Client.instance.appointments.agenda(12345, 67890, '2018-1-31 00:00:00') #=> [<Supersaas::Appointment>, ...]
149
+
150
+ #### Get Agenda Slots
151
+
152
+ Get agenda (upcoming) slots by `schedule_id` and `user_id`, with `from_time` view param:
153
+
154
+ Supersaas::Client.instance.appointments.agenda_slots(12345, 67890, '2018-1-31 00:00:00') #=> [<Supersaas::Slot>, ...]
155
+
156
+ _Note: works only for capacity type schedules._
157
+
158
+ #### Get Available Appointments/Bookings
159
+
160
+ Get available appointments by `schedule_id`, with `from` time and `length_minutes` and `resource` params:
161
+
162
+ Supersaas::Client.instance.appointments.available(12345, '2018-1-31 00:00:00', 15, 'My Class') #=> [<Supersaas::Appointment>, ...]
163
+
164
+ #### Get Recent Changes
165
+
166
+ Get recently changed appointments by `schedule_id`, with `from_time` view param:
167
+
168
+ Supersaas::Client.instance.appointments.changes(12345, '2018-1-31 00:00:00', true) #=> [<Supersaas::Appointment>, ...]
169
+
170
+ #### Get Recent Changes Slots
171
+
172
+ Get recently changed slots by `schedule_id`, with `from_time` view param:
173
+
174
+ Supersaas::Client.instance.appointments.changes_slots(12345, '2018-1-31 00:00:00', true) #=> [<Supersaas::Slot>, ...]
175
+
176
+ #### List Template Forms
177
+
178
+ Get all forms by template `superform_id`, with `from_time` param:
179
+
180
+ Supersaas::Client.instance.forms.list(12345, '2018-1-31 00:00:00') #=> [<Supersaas::Form>, ...]
181
+
182
+ #### Get Form
183
+
184
+ Get a single form by `form_id`:
185
+
186
+ Supersaas::Client.instance.forms.get(12345) #=> <Supersaas::Form>
187
+
188
+ ## Examples
189
+
190
+ The ./examples folder contains several executable Ruby scripts demonstrating how to use the API Client for common requests.
191
+
192
+ The examples will require your account name, password, 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
+
194
+ $ gem install supersaas-api-client
195
+ $ SSS_API_UID=myuserid SSS_API_SCHEDULE=myscheduleid SSS_API_ACCOUNT_NAME=myaccountname SSS_API_PASSWORD=mypassword ./examples/appointments.rb
196
+ $ SSS_API_FORM=myuserid SSS_API_ACCOUNT_NAME=myaccountname SSS_API_PASSWORD=mypassword ./examples/forms.rb
197
+ $ SSS_API_ACCOUNT_NAME=myaccountname SSS_API_PASSWORD=mypassword ./examples/users.rb
198
+
199
+ ## Testing
200
+
201
+ The HTTP requests can be stubbed by configuring the client with the `dry_run` option, e.g.
202
+
203
+ Supersaas::Client.instance.dry_run = true
204
+
205
+ Note, stubbed requests always return an empty Hash.
206
+
207
+ The `Client` also provides a `last_request` attribute containing the `Net::HTTP` object from the last performed request, e.g.
208
+
209
+ Supersaas::Client.instance.last_request #=> <Net::HTTP::Get>
210
+
211
+ The headers, body, path, etc. of the last request can be inspected for assertion in tests, or for troubleshooting failed API requests.
212
+
213
+ For additional troubleshooting, the client can be configured with the `verbose` option, which will `puts` any JSON contents in the request and response, e.g.
214
+
215
+ Supersaas::Client.instance.verbose = true
216
+
217
+ ## Error Handling
218
+
219
+ The API Client raises a custom exception for HTTP errors and invalid input. Rescue from `Supersaas::Exception` when making API requests. e.g.
220
+
221
+ begin
222
+ Supersaas::Client.instance.users.get
223
+ rescue Supersaas::Exception => e
224
+ # Handle error
225
+ end
226
+
227
+ Validation errors are assigned to the response model. e.g.
228
+
229
+ appointment = Supersaas::Client.instance.appointments.create(12345, {bad_field_name: ''})
230
+ appointment.errors #=> [{"status":"400","title":"Bad request: unknown attribute 'bad_field_name' for Booking."}]
231
+
232
+ ## Additional Information
233
+
234
+ + [SuperSaaS Registration](https://www.supersaas.com/accounts/new)
235
+ + [Product Documentation](https://www.supersaas.com/info/support)
236
+ + [Developer Documentation](https://www.supersaas.com/info/dev)
237
+ + [Python API Client](https://github.com/SuperSaaS/supersaas-python-api-client)
238
+ + [PHP API Client](https://github.com/SuperSaaS/supersaas-php-api-client)
239
+ + [NodeJS API Client](https://github.com/SuperSaaS/supersaas-nodejs-api-client)
240
+ + [C# API Client](https://github.com/SuperSaaS/supersaas-csharp-api-client)
241
+ + [Objective-C API Client](https://github.com/SuperSaaS/supersaas-objc-api-client)
242
+ + [Go API Client](https://github.com/SuperSaaS/supersaas-go-api-client)
243
+
244
+ Contact: [support@supersaas.com](mailto:support@supersaas.com)
245
+
246
+ ## Releases
247
+
248
+ The package follows [semantic versioning](https://semver.org/), i.e. MAJOR.MINOR.PATCH
249
+
250
+ ## License
251
+
252
+ The SuperSaaS Ruby API Client is available under the MIT license. See the LICENSE file for more info.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "supersaas-api-client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "date"
4
+ require "pp"
5
+ require "supersaas-api-client"
6
+
7
+ puts "\n\r# SuperSaaS Appointments Example\n\r"
8
+
9
+ unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.password
10
+ puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
11
+ puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_PASSWORD=<mypassword> ./examples/appointments.rb\n\r"
12
+ return
13
+ end
14
+
15
+ puts "## Account: #{Supersaas::Client.instance.account_name}"
16
+ puts "## Password: #{'*' * Supersaas::Client.instance.password.size}\n\r"
17
+
18
+ Supersaas::Client.instance.verbose = true
19
+
20
+ if ENV['SSS_API_SCHEDULE']
21
+ schedule_id = ENV['SSS_API_SCHEDULE']
22
+ show_slot = ENV['SSS_API_SLOT'] ? true : false
23
+ else
24
+ puts "ERROR! Missing schedule id. Rerun the script with your schedule id, e.g.\n\r"
25
+ puts " SSS_API_SCHEDULE=<scheduleid> ./examples/appointments.rb\n\r"
26
+ return
27
+ end
28
+
29
+ description = nil
30
+ new_appointment_id = nil
31
+ user = ENV['SSS_API_USER']
32
+ if user
33
+ description = '1234567890.'
34
+ params = {full_name: 'Example', description: description, name: 'example@example.com', email: 'example@example.com', mobile: '555-5555', phone: '555-5555', 'address': 'addr'}
35
+ if show_slot
36
+ params[:slot_id] = ENV['SSS_API_SLOT']
37
+ else
38
+ days = 1 + rand(30)
39
+ params[:start] = Time.now + (days * 24 * 60 * 60)
40
+ params[:finish] = params[:start] + (60 * 60)
41
+ end
42
+ puts "\n\rcreating new appointment..."
43
+ puts "\n\r#### Supersaas::Client.instance.appointments.create(#{schedule_id}, #{user}, {...})\n\r"
44
+ Supersaas::Client.instance.appointments.create(schedule_id, user, params)
45
+ else
46
+ puts "\n\rskipping create/update/delete (NO DESTRUCTIVE ACTIONS FOR SCHEDULE DATA)...\n\r"
47
+ end
48
+
49
+ puts "\n\rlisting appointments..."
50
+ puts "\n\r#### Supersaas::Client.instance.appointments.list(#{schedule_id}, nil, nil, 25)\n\r"
51
+
52
+ appointments = Supersaas::Client.instance.appointments.list(schedule_id, nil, nil, 25)
53
+ appointments.each do |appointment|
54
+ puts "#{description} == #{appointment.description}"
55
+ if description == appointment.description
56
+ puts "\n\rupdating appointment..."
57
+ puts "\n\r#### Supersaas::Client.instance.appointments.update(#{schedule_id}, #{new_appointment_id}, {...})\n\r"
58
+ Supersaas::Client.instance.appointments.update(schedule_id, new_appointment_id, {country: 'FR', address: 'Rue 1'})
59
+
60
+ puts "\n\rdeleting appointment..."
61
+ puts "\n\r#### Supersaas::Client.instance.appointments.delete(#{new_appointment_id})\n\r"
62
+ Supersaas::Client.instance.appointments.delete(new_appointment_id)
63
+ break
64
+ end
65
+ end
66
+
67
+ if appointments.size > 0
68
+ appointment_id = appointments.sample.id
69
+ puts "\n\rgetting appointment..."
70
+ puts "\n\r#### Supersaas::Client.instance.appointments.get(#{appointment_id})\n\r"
71
+ Supersaas::Client.instance.appointments.get(schedule_id, appointment_id)
72
+ end
73
+
74
+ puts "\n\rlisting changes..."
75
+ from = DateTime.now - 120
76
+ puts "\n\r#### Supersaas::Client.instance.appointments.changes(#{schedule_id}, '#{from.strftime("%Y-%m-%d %H:%M:%S")}', #{show_slot || 'false'})\n\r"
77
+
78
+ Supersaas::Client.instance.appointments.changes(schedule_id, from, show_slot)
79
+
80
+ puts "\n\rlisting available..."
81
+ from = DateTime.now
82
+ puts "\n\r#### Supersaas::Client.instance.appointments.available(#{schedule_id}, '#{from.strftime("%Y-%m-%d %H:%M:%S")}')\n\r"
83
+
84
+ Supersaas::Client.instance.appointments.available(schedule_id, from)
data/examples/forms.rb ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pp"
4
+ require "supersaas-api-client"
5
+
6
+ puts "\n\r# SuperSaaS Forms Example\n\r"
7
+
8
+ unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.password
9
+ puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
10
+ puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_PASSWORD=<mypassword> ./examples/appointments.rb\n\r"
11
+ return
12
+ end
13
+
14
+ puts "## Account: #{Supersaas::Client.instance.account_name}"
15
+ puts "## Password: #{'*' * Supersaas::Client.instance.password.size}\n\r"
16
+
17
+ Supersaas::Client.instance.verbose = true
18
+
19
+ if ENV['SSS_API_FORM']
20
+ form_id = ENV['SSS_API_FORM']
21
+ else
22
+ puts "ERROR! Missing form id. Rerun the script with your form id, e.g.\n\r"
23
+ puts " SSS_API_FORM=<formid> ./examples/forms.rb\n\r"
24
+ return
25
+ end
26
+
27
+ puts "\n\rlisting forms..."
28
+ puts "\n\r#### Supersaas::Client.instance.forms.list(#{form_id})\n\r"
29
+
30
+ forms = Supersaas::Client.instance.forms.list(form_id)
31
+
32
+ if forms.size > 0
33
+ form_id = forms.sample.id
34
+ puts "\n\rgetting form..."
35
+ puts "\n\r#### Supersaas::Client.instance.forms.get(#{form_id})\n\r"
36
+ form = Supersaas::Client.instance.forms.get(form_id)
37
+ end
38
+
39
+ puts
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "supersaas-api-client"
4
+
5
+ puts "\n\r# SuperSaaS Schedules Example\n\r"
6
+
7
+ unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.password
8
+ puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
9
+ puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_PASSWORD=<mypassword> ./examples/users.rb\n\r"
10
+ return
11
+ end
12
+
13
+ puts "## Account: #{Supersaas::Client.instance.account_name}"
14
+ puts "## Password: #{'*' * Supersaas::Client.instance.password.size}\n\r"
15
+
16
+ Supersaas::Client.instance.verbose = true
17
+
18
+ puts "\n\rlisting schedules..."
19
+ puts "\n\r#### Supersaas::Client.instance.schedules.list\n\r"
20
+ schedules = Supersaas::Client.instance.schedules.list
21
+
22
+ puts "\n\rlisting schedule resources..."
23
+ [10, schedules.size].min.times do |i|
24
+ puts "\n\r#### Supersaas::Client.instance.schedules.resources(#{schedules[i].id})\n\r"
25
+ Supersaas::Client.instance.schedules.resources(schedules[i].id)
26
+ end
27
+ puts
data/examples/users.rb ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "supersaas-api-client"
4
+
5
+ puts "\n\r# SuperSaaS Users Example\n\r"
6
+
7
+ unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.password
8
+ puts "ERROR! Missing account credentials. Rerun the script with your credentials, e.g.\n\r"
9
+ puts " SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_PASSWORD=<mypassword> ./examples/users.rb\n\r"
10
+ return
11
+ end
12
+
13
+ puts "## Account: #{Supersaas::Client.instance.account_name}"
14
+ puts "## Password: #{'*' * Supersaas::Client.instance.password.size}\n\r"
15
+
16
+ Supersaas::Client.instance.verbose = true
17
+
18
+ puts "creating new user..."
19
+ puts "\n\r#### Supersaas::Client.instance.users.create({...})\n\r"
20
+ params = {full_name: 'Example', name: 'example@example.com', email: 'example@example.com', password: 'example'}
21
+ Supersaas::Client.instance.users.create(params)
22
+ new_user_id = nil
23
+
24
+ puts "\n\rlisting users..."
25
+ puts "\n\r#### Supersaas::Client.instance.users.list(nil, 50)\n\r"
26
+
27
+ users = Supersaas::Client.instance.users.list(nil, 50)
28
+ users.each do |user|
29
+ new_user_id = user.id if user.name == params[:email] || user.email == params[:email]
30
+ end
31
+
32
+ if new_user_id
33
+ puts "\n\rgetting user..."
34
+ puts "\n\r#### Supersaas::Client.instance.users.get(#{new_user_id})\n\r"
35
+ user = Supersaas::Client.instance.users.get(new_user_id)
36
+
37
+ puts "\n\rupdating user..."
38
+ puts "\n\r#### Supersaas::Client.instance.users.update(#{new_user_id})\n\r"
39
+ Supersaas::Client.instance.users.update(new_user_id, {country: 'FR', address: 'Rue 1'})
40
+
41
+ puts "\n\rdeleting user..."
42
+ puts "\n\r#### Supersaas::Client.instance.users.delete(#{user.id})\n\r"
43
+ Supersaas::Client.instance.users.delete(user.id)
44
+ else
45
+ puts "\n\r... did not find user in list"
46
+ end
47
+
48
+ puts "\n\rcreating user with errors..."
49
+ puts "\n\r#### Supersaas::Client.instance.users.create\n\r"
50
+ Supersaas::Client.instance.users.create({name: 'error'})
51
+ puts