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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e89c0d488fea08984222ce3b14ba875165dbe57a1858792ef4d8bd4b93dbf79
4
- data.tar.gz: 78962ca5fcb66d98132c69d6d364a65d93460162a3673495a0be30cf044ae45a
3
+ metadata.gz: a22eecf79a26af28084edbb24d29302fcf7e299202bc2b06ccef19e5ac532c1f
4
+ data.tar.gz: 13b2f46e757cc82e5a72444b953813e5aacd0eb4afe06397ca50250be409e48c
5
5
  SHA512:
6
- metadata.gz: b945592bf72551661dac1a9094e65fbfae468a45678bc3cec0992057d2f4530ab3ec8470a5fc339317537bddfddbadda17cf26160c7935e06d7dee6bfa764a04
7
- data.tar.gz: b52649d8eb975de6ce19e248a4590bf487e31c0319e2448baeff22397764f31aff927b556fe3098578105c002e180612dc9a7ddf40f97ef665ffd510538147e4
6
+ metadata.gz: d04a57f8f23289e158d3dd3530dc7db72ea812c17c5cb62654e9d62a81ae44194eb3c9ce379368f1667e6366b2e19811f577d86e2ba713214e22928b714b73d4
7
+ data.tar.gz: f43802882d8fe67e3821a3d548a9016b64f61ea1ec3bdfc1411c799453187a4ac65c099fa929696a6feef7150e3990028e4cda053234680b4e5592b33ff292ca
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.5.alpha
4
+
5
+ - support APIs below.
6
+ - GET `/v1/{accountId}/remoteaccounts`
7
+ - GET `/v1/{accountId}/remoteaccounts/{remoteAccountId}`
8
+
3
9
  ## 0.0.4.alpha
4
10
 
5
11
  redefine models in order to follow changed APIs below.
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
- - [ ] GET `/v1/{accountId}/remoteaccounts`
71
+ - [x] GET `/v1/{accountId}/remoteaccounts`
72
72
  - [ ] POST `/v1/{accountId}/remoteaccounts`
73
- - [ ] GET `/v1/{accountId}/remoteaccounts/{remoteAccountId}`
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:
@@ -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
- c_klass.fields(field_with_prefix)
51
+ child_klass.fields(field_with_prefix)
50
52
  else
51
- c_klass.deep_fields(field_with_prefix, max_depth: max_depth)
52
- end
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
- private
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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YouCanBookMe
4
- VERSION = '0.0.4.alpha'
4
+ VERSION = '0.0.5.alpha'
5
5
  end
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.alpha
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-05 00:00:00.000000000 Z
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.4.alpha
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: