youcanbookme 0.0.2.alpha → 0.0.3.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +3 -3
- data/lib/youcanbookme/client.rb +107 -22
- data/lib/youcanbookme/error.rb +1 -1
- data/lib/youcanbookme/http_command.rb +1 -1
- data/lib/youcanbookme/{common_module.rb → loggable.rb} +2 -2
- data/lib/youcanbookme/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a0923f47ca98e10933774dd975b854f5d14e259e0cb6113e3626bf3cf09603c
|
4
|
+
data.tar.gz: 1bf5f156b9b1e11bbc145245cc8065f964f064c2e9209c3f8c1e12d298bb7fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b7df64ac8aafaf5f98f65a56fcae4f146071ea0f5fc7932a7495041ef01d01ec7d5b16865bde48ccfd30c785f3b2a51cdaddc6e8ee9fe9af464fdfd528ada53
|
7
|
+
data.tar.gz: b73049cf3e0090a44b3137b0a467c39b3d563698e49d41bc06e81e35024d469c862a9e55f5ef38bd65fac826a7156818e7a2aa2ca39977ab5e40b81cc52b5235
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,11 +37,11 @@ Or install it yourself as:
|
|
37
37
|
- [ ] PATCH `/v1/{accountId}/profiles/{profileId}/appointmenttypes/items/{appointmentTypeId}`
|
38
38
|
- [ ] DELETE `/v1/{accountId}/profiles/{profileId}/appointmenttypes/items/{appointmentTypeId}`
|
39
39
|
- Bookings:
|
40
|
-
- [
|
40
|
+
- [x] GET `/v1/{accountId}/bookings`
|
41
41
|
- [ ] GET `/v1/{accountId}/firedactions`
|
42
|
-
- [
|
42
|
+
- [x] GET `/v1/{accountId}/profiles/{profileId}/bookings`
|
43
43
|
- [ ] POST `/v1/{accountId}/profiles/{profileId}/bookings`
|
44
|
-
- [
|
44
|
+
- [x] GET `/v1/{accountId}/profiles/{profileId}/bookings/{bookingId}`
|
45
45
|
- [ ] PATCH `/v1/{accountId}/profiles/{profileId}/bookings/{bookingId}`
|
46
46
|
- [ ] DELETE `/v1/{accountId}/profiles/{profileId}/bookings/{bookingId}`
|
47
47
|
- [ ] GET `/v1/{accountId}/profiles/{profileId}/firedactions`
|
data/lib/youcanbookme/client.rb
CHANGED
@@ -26,22 +26,89 @@ module YouCanBookMe
|
|
26
26
|
# @param [Array<String>] fields the fields which are included in the response.
|
27
27
|
# @return [Account]
|
28
28
|
# @since 0.0.1
|
29
|
-
def account(fields
|
30
|
-
params =
|
29
|
+
def account(fields: nil)
|
30
|
+
params = build_fields_params fields
|
31
31
|
res = @connection.get account_path, params
|
32
32
|
Account.new res.body, self
|
33
33
|
end
|
34
34
|
|
35
|
+
#
|
36
|
+
# Returns a single Booking by associated ids.
|
37
|
+
#
|
38
|
+
# @param [String] profile_id the profile's unique id.
|
39
|
+
# @param [String] booking_id the booking's unique id.
|
40
|
+
# @param [Array<String>] fields the fields which are included in the response.
|
41
|
+
# @param [Hash] options the optional request parameters.
|
42
|
+
# @option options [String] :bsec
|
43
|
+
# @option options [String] :displayTimeZone
|
44
|
+
# @option options [String] :osec
|
45
|
+
# @return [Booking]
|
46
|
+
# @since 0.0.3
|
47
|
+
def booking(profile_id, booking_id, fields: nil, options: nil)
|
48
|
+
check_not_empty profile_id, 'profile_id'
|
49
|
+
check_not_empty booking_id, 'booking_id'
|
50
|
+
path = booking_path profile_id, booking_id
|
51
|
+
opts_keys = %i[bsec displayTimeZone osec]
|
52
|
+
params = build_option_params options, opts_keys, fields: fields
|
53
|
+
res = @connection.get path, params
|
54
|
+
Booking.new res.body, self
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Get List of Bookings.
|
59
|
+
#
|
60
|
+
# @param [Array<String>] fields the fields which are included in the response.
|
61
|
+
# @param [Hash] options the optional request parameters.
|
62
|
+
# @option options [String] :boundaryId
|
63
|
+
# @option options [String] :boundaryStartsAt
|
64
|
+
# @option options [String] :direction
|
65
|
+
# @option options [String] :displayTimeZone
|
66
|
+
# @option options [String] :jumpToDate
|
67
|
+
# @option options [String] :profileIds
|
68
|
+
# @option options [String] :search
|
69
|
+
# @return [Array<Booking>]
|
70
|
+
# @since 0.0.3
|
71
|
+
def bookings(fields: nil, options: nil)
|
72
|
+
opts_keys = %i[boundaryId boundaryStartsAt direction displayTimeZone jumpToDate profileIds search]
|
73
|
+
params = build_option_params options, opts_keys, fields: fields
|
74
|
+
res = @connection.get booking_path, params
|
75
|
+
map_as_collection res, Booking
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Get List of Bookings associated by profile_id.
|
80
|
+
#
|
81
|
+
# @param [String] profile_id the profile's unique id.
|
82
|
+
# @param [Array<String>] fields the fields which are included in the response.
|
83
|
+
# @param [Hash] options the optional request parameters.
|
84
|
+
# @option options [String] :boundaryId
|
85
|
+
# @option options [String] :boundaryStartsAt
|
86
|
+
# @option options [String] :direction
|
87
|
+
# @option options [String] :displayTimeZone
|
88
|
+
# @option options [String] :jumpToDate
|
89
|
+
# @option options [String] :profileIds
|
90
|
+
# @option options [String] :search
|
91
|
+
# @return [Array<Booking>]
|
92
|
+
# @since 0.0.3
|
93
|
+
def profile_bookings(profile_id, fields: nil, options: nil)
|
94
|
+
check_not_empty profile_id, 'profile_id'
|
95
|
+
path = booking_path profile_id
|
96
|
+
opts_keys = %i[boundaryId boundaryStartsAt direction displayTimeZone jumpToDate profileIds search]
|
97
|
+
params = build_option_params options, opts_keys, fields: fields
|
98
|
+
res = @connection.get path, params
|
99
|
+
map_as_collection res, Booking
|
100
|
+
end
|
101
|
+
|
35
102
|
#
|
36
103
|
# Returns a single Profile by its id.
|
37
104
|
#
|
38
|
-
# @param [String] profile_id
|
105
|
+
# @param [String] profile_id the profile's unique id.
|
39
106
|
# @param [Array<String>] fields the fields which are included in the response.
|
40
107
|
# @return [Profile]
|
41
108
|
# @since 0.0.2
|
42
|
-
def profile(profile_id, fields
|
109
|
+
def profile(profile_id, fields: nil)
|
43
110
|
check_not_empty profile_id, 'profile_id'
|
44
|
-
params =
|
111
|
+
params = build_fields_params fields
|
45
112
|
res = @connection.get profile_path(profile_id), params
|
46
113
|
Profile.new res.body, self
|
47
114
|
end
|
@@ -52,15 +119,10 @@ module YouCanBookMe
|
|
52
119
|
# @param [Array<String>] fields the fields which are included in the response.
|
53
120
|
# @return [Array<Profile>]
|
54
121
|
# @since 0.0.2
|
55
|
-
def profiles(fields
|
56
|
-
params =
|
122
|
+
def profiles(fields: nil)
|
123
|
+
params = build_fields_params fields
|
57
124
|
res = @connection.get profile_path, params
|
58
|
-
|
59
|
-
unless items.is_a? Array
|
60
|
-
raise YouCanBookMe::Error, 'the response data is not Array.'
|
61
|
-
end
|
62
|
-
|
63
|
-
items.map { |item| Profile.new item, self }
|
125
|
+
map_as_collection res, Profile
|
64
126
|
end
|
65
127
|
|
66
128
|
#
|
@@ -99,15 +161,6 @@ module YouCanBookMe
|
|
99
161
|
false
|
100
162
|
end
|
101
163
|
|
102
|
-
def set_fields_into_params(fields, params = nil)
|
103
|
-
params ||= {}
|
104
|
-
return params unless fields
|
105
|
-
return params unless fields.is_a? Array
|
106
|
-
return params if fields.empty?
|
107
|
-
|
108
|
-
params.merge(fields: fields.join(','))
|
109
|
-
end
|
110
|
-
|
111
164
|
def account_path
|
112
165
|
"/#{API_VERSION}/#{@account_id}"
|
113
166
|
end
|
@@ -118,5 +171,37 @@ module YouCanBookMe
|
|
118
171
|
|
119
172
|
"#{path}/#{profile_id}"
|
120
173
|
end
|
174
|
+
|
175
|
+
def booking_path(profile_id = nil, booking_id = nil)
|
176
|
+
return "#{account_path}/bookings" unless profile_id
|
177
|
+
|
178
|
+
path = "#{profile_path(profile_id)}/bookings"
|
179
|
+
return path unless booking_id
|
180
|
+
|
181
|
+
"#{path}/#{booking_id}"
|
182
|
+
end
|
183
|
+
|
184
|
+
def build_option_params(options, filters, fields: nil)
|
185
|
+
options ||= {}
|
186
|
+
build_fields_params fields, options.slice(*filters)
|
187
|
+
end
|
188
|
+
|
189
|
+
def build_fields_params(fields, params = nil)
|
190
|
+
params ||= {}
|
191
|
+
return params unless fields
|
192
|
+
return params unless fields.is_a? Array
|
193
|
+
return params if fields.empty?
|
194
|
+
|
195
|
+
params.merge(fields: fields.join(','))
|
196
|
+
end
|
197
|
+
|
198
|
+
def map_as_collection(response, klass)
|
199
|
+
items = response.body
|
200
|
+
unless items.is_a? Array
|
201
|
+
raise YouCanBookMe::Error, 'the response data is not Array.'
|
202
|
+
end
|
203
|
+
|
204
|
+
items.map { |item| klass.new item, self }
|
205
|
+
end
|
121
206
|
end
|
122
207
|
end
|
data/lib/youcanbookme/error.rb
CHANGED
data/lib/youcanbookme/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youcanbookme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenji Koshikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -157,10 +157,10 @@ files:
|
|
157
157
|
- bin/setup
|
158
158
|
- lib/youcanbookme.rb
|
159
159
|
- lib/youcanbookme/client.rb
|
160
|
-
- lib/youcanbookme/common_module.rb
|
161
160
|
- lib/youcanbookme/configuration.rb
|
162
161
|
- lib/youcanbookme/error.rb
|
163
162
|
- lib/youcanbookme/http_command.rb
|
163
|
+
- lib/youcanbookme/loggable.rb
|
164
164
|
- lib/youcanbookme/models/account.rb
|
165
165
|
- lib/youcanbookme/models/action.rb
|
166
166
|
- lib/youcanbookme/models/answer.rb
|
@@ -221,7 +221,7 @@ metadata:
|
|
221
221
|
homepage_uri: https://github.com/koshilife/youcanbookme-api-ruby-client
|
222
222
|
source_code_uri: https://github.com/koshilife/youcanbookme-api-ruby-client
|
223
223
|
changelog_uri: https://github.com/koshilife/youcanbookme-api-ruby-client/blob/master/CHANGELOG.md
|
224
|
-
documentation_uri: https://www.rubydoc.info/gems/youcanbookme/0.0.
|
224
|
+
documentation_uri: https://www.rubydoc.info/gems/youcanbookme/0.0.3.alpha
|
225
225
|
post_install_message:
|
226
226
|
rdoc_options: []
|
227
227
|
require_paths:
|