cybrid_api_organization_ruby 0.118.121 → 0.118.125

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +18 -6
  4. data/cybrid_api_organization_ruby.gemspec +2 -2
  5. data/docs/PostSubscriptionDeliveryOrganizationModel.md +20 -0
  6. data/docs/SubscriptionDeliveriesOrganizationApi.md +236 -0
  7. data/docs/SubscriptionDeliveryListOrganizationModel.md +24 -0
  8. data/docs/SubscriptionDeliveryOrganizationModel.md +38 -0
  9. data/docs/SubscriptionEventListOrganizationModel.md +24 -0
  10. data/docs/SubscriptionEventOrganizationModel.md +30 -0
  11. data/docs/SubscriptionEventsOrganizationApi.md +159 -0
  12. data/docs/SubscriptionOrganizationModel.md +6 -0
  13. data/docs/SubscriptionsOrganizationApi.md +11 -5
  14. data/lib/cybrid_api_organization_ruby/api/organizations_organization_api.rb +2 -2
  15. data/lib/cybrid_api_organization_ruby/api/subscription_deliveries_organization_api.rb +237 -0
  16. data/lib/cybrid_api_organization_ruby/api/subscription_events_organization_api.rb +163 -0
  17. data/lib/cybrid_api_organization_ruby/api/subscriptions_organization_api.rb +8 -2
  18. data/lib/cybrid_api_organization_ruby/api_client.rb +2 -2
  19. data/lib/cybrid_api_organization_ruby/api_error.rb +2 -2
  20. data/lib/cybrid_api_organization_ruby/configuration.rb +2 -2
  21. data/lib/cybrid_api_organization_ruby/models/error_response_organization_model.rb +2 -2
  22. data/lib/cybrid_api_organization_ruby/models/organization_organization_model.rb +2 -2
  23. data/lib/cybrid_api_organization_ruby/models/patch_organization_organization_model.rb +2 -2
  24. data/lib/cybrid_api_organization_ruby/models/post_subscription_delivery_organization_model.rb +240 -0
  25. data/lib/cybrid_api_organization_ruby/models/post_subscription_organization_model.rb +2 -2
  26. data/lib/cybrid_api_organization_ruby/models/subscription_delivery_list_organization_model.rb +328 -0
  27. data/lib/cybrid_api_organization_ruby/models/subscription_delivery_organization_model.rb +383 -0
  28. data/lib/cybrid_api_organization_ruby/models/subscription_environment_organization_model.rb +2 -2
  29. data/lib/cybrid_api_organization_ruby/models/subscription_event_list_organization_model.rb +328 -0
  30. data/lib/cybrid_api_organization_ruby/models/subscription_event_organization_model.rb +305 -0
  31. data/lib/cybrid_api_organization_ruby/models/subscription_list_organization_model.rb +2 -2
  32. data/lib/cybrid_api_organization_ruby/models/subscription_organization_model.rb +63 -8
  33. data/lib/cybrid_api_organization_ruby/models/subscription_state_organization_model.rb +2 -2
  34. data/lib/cybrid_api_organization_ruby/models/subscription_type_organization_model.rb +2 -2
  35. data/lib/cybrid_api_organization_ruby/version.rb +3 -3
  36. data/lib/cybrid_api_organization_ruby.rb +9 -2
  37. data/spec/api/organizations_organization_api_spec.rb +2 -2
  38. data/spec/api/subscription_deliveries_organization_api_spec.rb +75 -0
  39. data/spec/api/subscription_events_organization_api_spec.rb +61 -0
  40. data/spec/api/subscriptions_organization_api_spec.rb +4 -2
  41. data/spec/api_client_spec.rb +2 -2
  42. data/spec/configuration_spec.rb +2 -2
  43. data/spec/models/error_response_organization_model_spec.rb +2 -2
  44. data/spec/models/organization_organization_model_spec.rb +2 -2
  45. data/spec/models/patch_organization_organization_model_spec.rb +2 -2
  46. data/spec/models/post_subscription_delivery_organization_model_spec.rb +40 -0
  47. data/spec/models/post_subscription_organization_model_spec.rb +2 -2
  48. data/spec/models/subscription_delivery_list_organization_model_spec.rb +52 -0
  49. data/spec/models/subscription_delivery_organization_model_spec.rb +98 -0
  50. data/spec/models/subscription_environment_organization_model_spec.rb +2 -2
  51. data/spec/models/subscription_event_list_organization_model_spec.rb +52 -0
  52. data/spec/models/subscription_event_organization_model_spec.rb +70 -0
  53. data/spec/models/subscription_list_organization_model_spec.rb +2 -2
  54. data/spec/models/subscription_organization_model_spec.rb +20 -2
  55. data/spec/models/subscription_state_organization_model_spec.rb +2 -2
  56. data/spec/models/subscription_type_organization_model_spec.rb +2 -2
  57. data/spec/spec_helper.rb +2 -2
  58. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-11.1.3/gem_make.out +5 -5
  59. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  60. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.2/gem_make.out +5 -5
  61. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  62. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.1.1/gem_make.out +5 -5
  63. metadata +30 -2
@@ -0,0 +1,328 @@
1
+ =begin
2
+ #Cybrid Organization API
3
+
4
+ ## Cybrid API documentation Welcome to Cybrid, an all-in-one crypto platform that enables you to easily **build** and **launch** white-label crypto products or services. In these documents, you'll find details on how our REST API operates and generally how our platform functions. If you're looking for our UI SDK Widgets for Web or Mobile (iOS/Android), generated API clients, or demo applications, head over to our [Github repo](https://github.com/Cybrid-app). 💡 We recommend bookmarking the [Cybrid LinkTree](https://linktr.ee/cybridtechnologies) which contains many helpful links to platform resources. ## Getting Started This is Cybrid's public interactive API documentation, which allows you to fully test our APIs. If you'd like to use a different tool to exercise our APIs, you can download the [Open API 3.0 yaml](https://bank.production.cybrid.app/api/schema/v1/swagger.yaml) for import. If you're new to our APIs and the Cybrid Platform, follow the below guides to get set up and familiar with the platform: 1. [Understanding the Platform](https://kb.cybrid.xyz/understanding-the-platform) 2. [Getting Started in the Cybrid Sandbox](https://kb.cybrid.xyz/getting-started-guide) 3. [Getting Ready for Trading](https://kb.cybrid.xyz/getting-ready-for-trading) 4. [Running the Web Demo App](https://kb.cybrid.xyz/locally-running-the-web-demo-app) (or, alternatively, [Testing with Hosted Web Demo App](https://kb.cybrid.xyz/testing-with-hosted-web-demo-app)) In [Getting Started in the Cybrid Sandbox](https://kb.cybrid.xyz/getting-started-guide), we walk you through how to use the [Cybrid Sandbox](https://id.sandbox.cybrid.app/) to create a test bank and generate API keys. In [Getting Ready for Trading](https://kb.cybrid.xyz/getting-ready-for-trading), we walk through creating customers, customer identities, accounts, as well as executing quotes and trades. If you've already run through the first two guides, you can follow the [Running the Web Demo App](https://kb.cybrid.xyz/locally-running-the-web-demo-app) guide to test our web SDK with your sandbox `bank` and `customer`. ## Working with the Cybrid Platform There are three primary ways you can interact with the Cybrid platform: 1. Directly via our RESTful API (this documentation) 2. Using our API clients available in a variety of languages ([Angular](https://github.com/Cybrid-app/cybrid-api-bank-angular), [Java](https://github.com/Cybrid-app/cybrid-api-bank-java), [Kotlin](https://github.com/Cybrid-app/cybrid-api-bank-kotlin), [Python](https://github.com/Cybrid-app/cybrid-api-bank-python), [Ruby](https://github.com/Cybrid-app/cybrid-api-bank-ruby), [Swift](https://github.com/Cybrid-app/cybrid-api-bank-swift) or [Typescript](https://github.com/Cybrid-app/cybrid-api-bank-typescript)) 3. Integrating a platform specific SDK ([Web](https://github.com/Cybrid-app/cybrid-sdk-web), [Android](https://github.com/Cybrid-app/cybrid-sdk-android), [iOS](https://github.com/Cybrid-app/cybrid-sdk-ios)) Our complete set of APIs allows you to manage resources across three distinct areas: your `Organization`, your `Banks` and your `Identities`. For most of your testing and interaction you'll be using the `Bank` API, which is where the majority of APIs reside. *The complete set of APIs can be found on the following pages:* | API | Description | |------------------------------------------------------------------|-------------------------------------------------------------| | [Organization API](https://organization.production.cybrid.app/api/schema/swagger-ui) | APIs to manage organizations | | [Bank API](https://bank.production.cybrid.app/api/schema/swagger-ui) | APIs to manage banks (and all downstream customer activity) | | [Identities API](https://id.production.cybrid.app/api/schema/swagger-ui) | APIs to manage organization and bank identities | For questions please contact [Support](mailto:support@cybrid.xyz) at any time for assistance, or contact the [Product Team](mailto:product@cybrid.xyz) for product suggestions. ## Authenticating with the API The Cybrid Platform uses OAuth 2.0 Bearer Tokens to authenticate requests to the platform. Credentials to create `Organization` and `Bank` tokens can be generated via the [Cybrid Sandbox](https://id.production.cybrid.app). Access tokens can be generated for a `Customer` as well via the [Cybrid IdP](https://id.production.cybrid.app) as well. An `Organization` access token applies broadly to the whole Organization and all of its `Banks`, whereas, a `Bank` access token is specific to an individual Bank. `Customer` tokens, similarly, are scoped to a specific customer in a bank. Both `Organization` and `Bank` tokens can be created using the OAuth Client Credential Grant flow. Each Organization and Bank has its own unique `Client ID` and `Secret` that allows for machine-to-machine authentication. A `Bank` can then generate `Customer` access tokens via API using our [Identities API](https://id.production.cybrid.app/api/schema/swagger-ui). <font color=\"orange\">**⚠️ Never share your Client ID or Secret publicly or in your source code repository.**</font> Your `Client ID` and `Secret` can be exchanged for a time-limited `Bearer Token` by interacting with the Cybrid Identity Provider or through interacting with the **Authorize** button in this document. The following curl command can be used to quickly generate a `Bearer Token` for use in testing the API or demo applications. ``` # Example request when using Bank credentials curl -X POST https://id.production.cybrid.app/oauth/token -d '{ \"grant_type\": \"client_credentials\", \"client_id\": \"<Your Client ID>\", \"client_secret\": \"<Your Secret>\", \"scope\": \"banks:read banks:write bank_applications:execute accounts:read accounts:execute counterparties:read counterparties:write counterparties:execute customers:read customers:write customers:execute prices:read quotes:execute quotes:read trades:execute trades:read transfers:execute transfers:read external_bank_accounts:read external_bank_accounts:write external_bank_accounts:execute external_wallets:read external_wallets:execute workflows:read workflows:execute deposit_addresses:read deposit_addresses:execute deposit_bank_accounts:read deposit_bank_accounts:execute invoices:read invoices:write invoices:execute identity_verifications:read identity_verifications:write identity_verifications:execute\" }' -H \"Content-Type: application/json\" # When using Organization credentials set `scope` to 'organizations:read organizations:write organization_applications:execute banks:read banks:write banks:execute bank_applications:execute users:read users:execute counterparties:read customers:read accounts:read prices:read quotes:execute quotes:read trades:execute trades:read transfers:read transfers:execute external_bank_accounts:read external_wallets:read workflows:read deposit_addresses:read deposit_bank_accounts:read invoices:read subscriptions:read subscriptions:write subscriptions:execute subscription_events:read subscription_events:execute identity_verifications:read' ``` <font color=\"orange\">**⚠️ Note: The above curl will create a bearer token with full scope access. Delete scopes if you'd like to restrict access.**</font> ## Authentication Scopes The Cybrid platform supports the use of scopes to control the level of access a token is limited to. Scopes do not grant access to resources; instead, they provide limits, in support of the least privilege principal. The following scopes are available on the platform and can be requested when generating either an Organization, Bank or Customer token. Generally speaking, the _Read_ scope is required to read and list resources, the _Write_ scope is required to update a resource and the _Execute_ scope is required to create a resource. | Resource | Read scope (Token Type) | Write scope (Token Type) | Execute scope (Token Type) | |-----------------------|------------------------------------------------------------|-----------------------------------------------|--------------------------------------------------| | Account | accounts:read (Organization, Bank, Customer) | | accounts:execute (Bank, Customer) | | Bank | banks:read (Organization, Bank) | banks:write (Organization, Bank) | banks:execute (Organization) | | Customer | customers:read (Organization, Bank, Customer) | customers:write (Bank, Customer) | customers:execute (Bank) | | Counterparty | counterparties:read (Organization, Bank, Customer) | counterparties:write (Bank, Customer) | counterparties:execute (Bank) | | Deposit Address | deposit_addresses:read (Organization, Bank, Customer) | deposit_addresses:write (Bank, Customer) | deposit_addresses:execute (Bank, Customer) | | External Bank Account | external_bank_accounts:read (Organization, Bank, Customer) | external_bank_accounts:write (Bank, Customer) | external_bank_accounts:execute (Bank, Customer) | | External Wallet | external_wallet:read (Organization, Bank, Customer) | | external_wallet:execute (Bank, Customer) | | Organization | organizations:read (Organization) | organizations:write (Organization) | | | User | users:read (Organization) | | users:execute (Organization) | | Price | prices:read (Bank, Customer) | | | | Quote | quotes:read (Organization, Bank, Customer) | | quotes:execute (Organization, Bank, Customer) | | Trade | trades:read (Organization, Bank, Customer) | | trades:execute (Organization, Bank, Customer) | | Transfer | transfers:read (Organization, Bank, Customer) | | transfers:execute (Organization, Bank, Customer) | | Workflow | workflows:read (Organization, Bank, Customer) | | workflows:execute (Bank, Customer) | | Invoice | invoices:read (Organization, Bank, Customer) | invoices:write (Bank, Customer) | invoices:execute (Bank, Customer) | ## Available Endpoints The available APIs for the [Identity](https://id.production.cybrid.app/api/schema/swagger-ui), [Organization](https://organization.production.cybrid.app/api/schema/swagger-ui) and [Bank](https://bank.production.cybrid.app/api/schema/swagger-ui) API services are listed below: | API Service | Model | API Endpoint Path | Description | |--------------|----------------------|--------------------------------|---------------------------------------------------------------------------------------------------| | Identity | Bank | /api/bank_applications | Create and list banks | | Identity | CustomerToken | /api/customer_tokens | Create customer JWT access tokens | | Identity | Organization | /api/organization_applications | Create and list organizations | | Identity | Organization | /api/users | Create and list organization users | | Organization | Organization | /api/organizations | APIs to retrieve and update organization name | | Bank | Account | /api/accounts | Create and list accounts, which hold a specific asset for a customers | | Bank | Asset | /api/assets | Get a list of assets supported by the platform (ex: BTC, ETH) | | Bank | Bank | /api/banks | Create, update and list banks, the parent to customers, accounts, etc | | Bank | Customer | /api/customers | Create and list customers | | Bank | Counterparty | /api/counterparties | Create and list counterparties | | Bank | DepositAddress | /api/deposit_addresses | Create, get and list deposit addresses | | Bank | ExternalBankAccount | /api/external_bank_accounts | Create, get and list external bank accounts, which connect customer bank accounts to the platform | | Bank | ExternalWallet | /api/external_wallets | Create, get, list and delete external wallets, which connect customer wallets to the platform | | Bank | IdentityVerification | /api/identity_verifications | Create and list identity verifications, which are performed on customers for KYC | | Bank | Invoice | /api/invoices | Create, get, cancel and list invoices | | Bank | PaymentInstruction | /api/payment_instructions | Create, get and list payment instructions for invoices | | Bank | Price | /api/prices | Get the current prices for assets on the platform | | Bank | Quote | /api/quotes | Create and list quotes, which are required to execute trades | | Bank | Symbol | /api/symbols | Get a list of symbols supported for trade (ex: BTC-USD) | | Bank | Trade | /api/trades | Create and list trades, which buy or sell cryptocurrency | | Bank | Transfer | /api/transfers | Create, get and list transfers (e.g., funding, book) | | Bank | Workflow | /api/workflows | Create, get and list workflows | ## Understanding Object Models & Endpoints **Organizations** An `Organization` is meant to represent the organization partnering with Cybrid to use our platform. An `Organization` typically does not directly interact with `customers`. Instead, an Organization has one or more `banks`, which encompass the financial service offerings of the platform. **Banks** A `Bank` is owned by an `Organization` and can be thought of as an environment or container for `customers` and product offerings. Banks are created in either `Sandbox` or `Production` mode, where `Sandbox` is the environment that you would test, prototype and build in prior to moving to `Production`. An `Organization` can have multiple `banks`, in either `Sandbox` or `Production` environments. A `Sandbox Bank` will be backed by stubbed data and process flows. For instance, funding source transfer processes as well as trades will be simulated rather than performed, however asset prices are representative of real-world values. You have an unlimited amount of simulated fiat currency for testing purposes. **Customers** `Customers` represent your banking users on the platform. At present, we offer support for `Individuals` as Customers. `Customers` must be verified (i.e., KYC'd) in our system before they can play any part on the platform, which means they must have an associated and a passing `Identity Verification`. See the Identity Verifications section for more details on how a customer can be verified. `Customers` must also have an `Account` to be able to transact, in the desired asset class. See the Accounts APIs for more details on setting up accounts for the customer.
5
+
6
+ The version of the OpenAPI document: v0.118.125
7
+ Contact: support@cybrid.app
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module CybridApiOrganization
17
+ class SubscriptionEventListOrganizationModel
18
+ # The total number of records available.
19
+ attr_accessor :total
20
+
21
+ # The page index to retrieve.
22
+ attr_accessor :page
23
+
24
+ # The number of entities per page to return.
25
+ attr_accessor :per_page
26
+
27
+ attr_accessor :objects
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'total' => :'total',
33
+ :'page' => :'page',
34
+ :'per_page' => :'per_page',
35
+ :'objects' => :'objects'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'total' => :'Integer',
48
+ :'page' => :'Integer',
49
+ :'per_page' => :'Integer',
50
+ :'objects' => :'Array<SubscriptionEventOrganizationModel>'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CybridApiOrganization::SubscriptionEventListOrganizationModel` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CybridApiOrganization::SubscriptionEventListOrganizationModel`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'total')
76
+ self.total = attributes[:'total']
77
+ end
78
+
79
+ if attributes.key?(:'page')
80
+ self.page = attributes[:'page']
81
+ end
82
+
83
+ if attributes.key?(:'per_page')
84
+ self.per_page = attributes[:'per_page']
85
+ end
86
+
87
+ if attributes.key?(:'objects')
88
+ if (value = attributes[:'objects']).is_a?(Array)
89
+ self.objects = value
90
+ end
91
+ end
92
+ end
93
+
94
+ # Show invalid properties with the reasons. Usually used together with valid?
95
+ # @return Array for valid properties with the reasons
96
+ def list_invalid_properties
97
+ invalid_properties = Array.new
98
+ if @total.nil?
99
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
100
+ end
101
+
102
+ if @total < 0
103
+ invalid_properties.push('invalid value for "total", must be greater than or equal to 0.')
104
+ end
105
+
106
+ if @page.nil?
107
+ invalid_properties.push('invalid value for "page", page cannot be nil.')
108
+ end
109
+
110
+ if @page < 0
111
+ invalid_properties.push('invalid value for "page", must be greater than or equal to 0.')
112
+ end
113
+
114
+ if @per_page.nil?
115
+ invalid_properties.push('invalid value for "per_page", per_page cannot be nil.')
116
+ end
117
+
118
+ if @per_page < 0
119
+ invalid_properties.push('invalid value for "per_page", must be greater than or equal to 0.')
120
+ end
121
+
122
+ if @objects.nil?
123
+ invalid_properties.push('invalid value for "objects", objects cannot be nil.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ return false if @total.nil?
133
+ return false if @total < 0
134
+ return false if @page.nil?
135
+ return false if @page < 0
136
+ return false if @per_page.nil?
137
+ return false if @per_page < 0
138
+ return false if @objects.nil?
139
+ true
140
+ end
141
+
142
+ # Custom attribute writer method with validation
143
+ # @param [Object] total Value to be assigned
144
+ def total=(total)
145
+ if total.nil?
146
+ fail ArgumentError, 'total cannot be nil'
147
+ end
148
+
149
+ if total < 0
150
+ fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.'
151
+ end
152
+
153
+ @total = total
154
+ end
155
+
156
+ # Custom attribute writer method with validation
157
+ # @param [Object] page Value to be assigned
158
+ def page=(page)
159
+ if page.nil?
160
+ fail ArgumentError, 'page cannot be nil'
161
+ end
162
+
163
+ if page < 0
164
+ fail ArgumentError, 'invalid value for "page", must be greater than or equal to 0.'
165
+ end
166
+
167
+ @page = page
168
+ end
169
+
170
+ # Custom attribute writer method with validation
171
+ # @param [Object] per_page Value to be assigned
172
+ def per_page=(per_page)
173
+ if per_page.nil?
174
+ fail ArgumentError, 'per_page cannot be nil'
175
+ end
176
+
177
+ if per_page < 0
178
+ fail ArgumentError, 'invalid value for "per_page", must be greater than or equal to 0.'
179
+ end
180
+
181
+ @per_page = per_page
182
+ end
183
+
184
+ # Checks equality by comparing each attribute.
185
+ # @param [Object] Object to be compared
186
+ def ==(o)
187
+ return true if self.equal?(o)
188
+ self.class == o.class &&
189
+ total == o.total &&
190
+ page == o.page &&
191
+ per_page == o.per_page &&
192
+ objects == o.objects
193
+ end
194
+
195
+ # @see the `==` method
196
+ # @param [Object] Object to be compared
197
+ def eql?(o)
198
+ self == o
199
+ end
200
+
201
+ # Calculates hash code according to all attributes.
202
+ # @return [Integer] Hash code
203
+ def hash
204
+ [total, page, per_page, objects].hash
205
+ end
206
+
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
210
+ def self.build_from_hash(attributes)
211
+ new.build_from_hash(attributes)
212
+ end
213
+
214
+ # Builds the object from hash
215
+ # @param [Hash] attributes Model attributes in the form of hash
216
+ # @return [Object] Returns the model itself
217
+ def build_from_hash(attributes)
218
+ return nil unless attributes.is_a?(Hash)
219
+ attributes = attributes.transform_keys(&:to_sym)
220
+ self.class.openapi_types.each_pair do |key, type|
221
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
222
+ self.send("#{key}=", nil)
223
+ elsif type =~ /\AArray<(.*)>/i
224
+ # check to ensure the input is an array given that the attribute
225
+ # is documented as an array but the input is not
226
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
227
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
228
+ end
229
+ elsif !attributes[self.class.attribute_map[key]].nil?
230
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
231
+ end
232
+ end
233
+
234
+ self
235
+ end
236
+
237
+ # Deserializes the data based on type
238
+ # @param string type Data type
239
+ # @param string value Value to be deserialized
240
+ # @return [Object] Deserialized data
241
+ def _deserialize(type, value)
242
+ case type.to_sym
243
+ when :Time
244
+ Time.parse(value)
245
+ when :Date
246
+ Date.parse(value)
247
+ when :String
248
+ value.to_s
249
+ when :Integer
250
+ value.to_i
251
+ when :Float
252
+ value.to_f
253
+ when :Boolean
254
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
255
+ true
256
+ else
257
+ false
258
+ end
259
+ when :Object
260
+ # generic object (usually a Hash), return directly
261
+ value
262
+ when /\AArray<(?<inner_type>.+)>\z/
263
+ inner_type = Regexp.last_match[:inner_type]
264
+ value.map { |v| _deserialize(inner_type, v) }
265
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
266
+ k_type = Regexp.last_match[:k_type]
267
+ v_type = Regexp.last_match[:v_type]
268
+ {}.tap do |hash|
269
+ value.each do |k, v|
270
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
271
+ end
272
+ end
273
+ else # model
274
+ # models (e.g. Pet) or oneOf
275
+ klass = CybridApiOrganization.const_get(type)
276
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
277
+ end
278
+ end
279
+
280
+ # Returns the string representation of the object
281
+ # @return [String] String presentation of the object
282
+ def to_s
283
+ to_hash.to_s
284
+ end
285
+
286
+ # to_body is an alias to to_hash (backward compatibility)
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_body
289
+ to_hash
290
+ end
291
+
292
+ # Returns the object in the form of hash
293
+ # @return [Hash] Returns the object in the form of hash
294
+ def to_hash
295
+ hash = {}
296
+ self.class.attribute_map.each_pair do |attr, param|
297
+ value = self.send(attr)
298
+ if value.nil?
299
+ is_nullable = self.class.openapi_nullable.include?(attr)
300
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
301
+ end
302
+
303
+ hash[param] = _to_hash(value)
304
+ end
305
+ hash
306
+ end
307
+
308
+ # Outputs non-array value in the form of hash
309
+ # For object, use to_hash. Otherwise, just return the value
310
+ # @param [Object] value Any valid value
311
+ # @return [Hash] Returns the value in the form of hash
312
+ def _to_hash(value)
313
+ if value.is_a?(Array)
314
+ value.compact.map { |v| _to_hash(v) }
315
+ elsif value.is_a?(Hash)
316
+ {}.tap do |hash|
317
+ value.each { |k, v| hash[k] = _to_hash(v) }
318
+ end
319
+ elsif value.respond_to? :to_hash
320
+ value.to_hash
321
+ else
322
+ value
323
+ end
324
+ end
325
+
326
+ end
327
+
328
+ end