youcanbookme 0.0.4.alpha → 0.0.5.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 +6 -0
- data/README.md +2 -2
- data/lib/youcanbookme/client.rb +36 -1
- data/lib/youcanbookme/models/model_utils.rb +8 -6
- data/lib/youcanbookme/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a22eecf79a26af28084edbb24d29302fcf7e299202bc2b06ccef19e5ac532c1f
|
4
|
+
data.tar.gz: 13b2f46e757cc82e5a72444b953813e5aacd0eb4afe06397ca50250be409e48c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d04a57f8f23289e158d3dd3530dc7db72ea812c17c5cb62654e9d62a81ae44194eb3c9ce379368f1667e6366b2e19811f577d86e2ba713214e22928b714b73d4
|
7
|
+
data.tar.gz: f43802882d8fe67e3821a3d548a9016b64f61ea1ec3bdfc1411c799453187a4ac65c099fa929696a6feef7150e3990028e4cda053234680b4e5592b33ff292ca
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -68,9 +68,9 @@ Or install it yourself as:
|
|
68
68
|
- Query
|
69
69
|
- [ ] POST `/v1/{accountId}/queries`
|
70
70
|
- Remote Account
|
71
|
-
- [
|
71
|
+
- [x] GET `/v1/{accountId}/remoteaccounts`
|
72
72
|
- [ ] POST `/v1/{accountId}/remoteaccounts`
|
73
|
-
- [
|
73
|
+
- [x] GET `/v1/{accountId}/remoteaccounts/{remoteAccountId}`
|
74
74
|
- [ ] PATCH `/v1/{accountId}/remoteaccounts/{remoteAccountId}`
|
75
75
|
- [ ] DELETE `/v1/{accountId}/remoteaccounts/{remoteAccountId}`
|
76
76
|
- Team Members:
|
data/lib/youcanbookme/client.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module YouCanBookMe
|
4
4
|
# YouCanBookMe APIs client.
|
5
|
-
class Client
|
5
|
+
class Client # rubocop:disable Metrics/ClassLength
|
6
6
|
API_HOST = 'https://api.youcanbook.me'
|
7
7
|
API_VERSION = 'v1'
|
8
8
|
|
@@ -148,6 +148,34 @@ module YouCanBookMe
|
|
148
148
|
res.body[:free]
|
149
149
|
end
|
150
150
|
|
151
|
+
#
|
152
|
+
# Returns a single RemoteAccount by its id.
|
153
|
+
#
|
154
|
+
# @param [String] remote_account_id the remote account's unique id.
|
155
|
+
# @param [Array<String>] fields the fields which are included in the response.
|
156
|
+
# @return [YouCanBookMe::RemoteAccount]
|
157
|
+
# @raise [YouCanBookMe::Error] if the subdomain arg is empty.
|
158
|
+
# @since 0.0.5
|
159
|
+
def remote_account(remote_account_id, fields: nil)
|
160
|
+
check_not_empty remote_account_id, 'remote_account_id'
|
161
|
+
params = build_fields_params fields
|
162
|
+
path = remote_account_path(remote_account_id)
|
163
|
+
res = @connection.get path, params
|
164
|
+
RemoteAccount.new res.body, self
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# Get List of Remote Account.
|
169
|
+
#
|
170
|
+
# @param [Array<String>] fields the fields which are included in the response.
|
171
|
+
# @return [Array<YouCanBookMe::RemoteAccount>]
|
172
|
+
# @since 0.0.5
|
173
|
+
def remote_accounts(fields: nil)
|
174
|
+
params = build_fields_params fields
|
175
|
+
res = @connection.get remote_account_path, params
|
176
|
+
map_as_collection res, RemoteAccount
|
177
|
+
end
|
178
|
+
|
151
179
|
private
|
152
180
|
|
153
181
|
def check_not_empty(value, name)
|
@@ -181,6 +209,13 @@ module YouCanBookMe
|
|
181
209
|
"#{path}/#{booking_id}"
|
182
210
|
end
|
183
211
|
|
212
|
+
def remote_account_path(remote_account_id = nil)
|
213
|
+
path = "#{account_path}/remoteaccounts"
|
214
|
+
return path unless remote_account_id
|
215
|
+
|
216
|
+
"#{path}/#{remote_account_id}"
|
217
|
+
end
|
218
|
+
|
184
219
|
def build_option_params(options, filters, fields: nil)
|
185
220
|
options ||= {}
|
186
221
|
build_fields_params fields, options.slice(*filters)
|
@@ -33,9 +33,10 @@ module YouCanBookMe
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# @param [String] prefix
|
36
|
+
# @param [Array<Symbol>] association_filters
|
36
37
|
# @param [Integer] max_depth
|
37
38
|
# @return [Array<String>]
|
38
|
-
def deep_fields(prefix = nil, max_depth: 3)
|
39
|
+
def deep_fields(prefix = nil, association_filters: nil, max_depth: 3) # rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity
|
39
40
|
ret_fields = []
|
40
41
|
fields(prefix).each do |field_with_prefix|
|
41
42
|
ret_fields << field_with_prefix
|
@@ -43,13 +44,14 @@ module YouCanBookMe
|
|
43
44
|
field = field_with_prefix.split('.')[-1].to_sym
|
44
45
|
next unless defined? self::ASSOCIATION
|
45
46
|
next unless self::ASSOCIATION.key? field
|
47
|
+
next if association_filters&.is_a?(Array) && !association_filters.include?(field)
|
46
48
|
|
47
49
|
child_klass = self::ASSOCIATION[field]
|
48
50
|
child_fields = if (self == child_klass) || depth >= max_depth
|
49
|
-
|
51
|
+
child_klass.fields(field_with_prefix)
|
50
52
|
else
|
51
|
-
|
52
|
-
|
53
|
+
child_klass.deep_fields(field_with_prefix, max_depth: max_depth)
|
54
|
+
end
|
53
55
|
child_fields.each { |c_field| ret_fields << c_field }
|
54
56
|
end
|
55
57
|
ret_fields
|
@@ -60,9 +62,9 @@ module YouCanBookMe
|
|
60
62
|
base.extend ClassMethods
|
61
63
|
end
|
62
64
|
|
63
|
-
|
65
|
+
private
|
64
66
|
|
65
|
-
def set_attributes(attrs)
|
67
|
+
def set_attributes(attrs) # rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Naming/AccessorMethodName
|
66
68
|
return if attrs.nil?
|
67
69
|
return unless attrs.is_a? Hash
|
68
70
|
return if attrs.empty?
|
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.5.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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -212,7 +212,7 @@ metadata:
|
|
212
212
|
homepage_uri: https://github.com/koshilife/youcanbookme-api-ruby-client
|
213
213
|
source_code_uri: https://github.com/koshilife/youcanbookme-api-ruby-client
|
214
214
|
changelog_uri: https://github.com/koshilife/youcanbookme-api-ruby-client/blob/master/CHANGELOG.md
|
215
|
-
documentation_uri: https://www.rubydoc.info/gems/youcanbookme/0.0.
|
215
|
+
documentation_uri: https://www.rubydoc.info/gems/youcanbookme/0.0.5.alpha
|
216
216
|
post_install_message:
|
217
217
|
rdoc_options: []
|
218
218
|
require_paths:
|