budgea_client 4.0.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +50 -5
  4. data/budgea_openapi.json +1888 -383
  5. data/docs/Account.md +2 -0
  6. data/docs/AccountLog.md +1 -0
  7. data/docs/AdministrationApi.md +366 -55
  8. data/docs/AuthenticationApi.md +15 -13
  9. data/docs/BanksApi.md +988 -194
  10. data/docs/Client.md +1 -1
  11. data/docs/Connection.md +2 -0
  12. data/docs/ConnectionLog.md +1 -0
  13. data/docs/ConnectionSource.md +18 -0
  14. data/docs/ConnectionsApi.md +618 -25
  15. data/docs/Connector.md +1 -1
  16. data/docs/ConnectorSource.md +15 -0
  17. data/docs/DocumentsApi.md +72 -72
  18. data/docs/Field.md +1 -0
  19. data/docs/InlineResponse20011.md +1 -1
  20. data/docs/InlineResponse20012.md +1 -1
  21. data/docs/InlineResponse20013.md +1 -1
  22. data/docs/InlineResponse20014.md +1 -1
  23. data/docs/InlineResponse20015.md +1 -1
  24. data/docs/InlineResponse20016.md +1 -1
  25. data/docs/InlineResponse20017.md +1 -1
  26. data/docs/InlineResponse20018.md +1 -1
  27. data/docs/InlineResponse20019.md +2 -1
  28. data/docs/InlineResponse20030.md +1 -1
  29. data/docs/InlineResponse20031.md +1 -1
  30. data/docs/InlineResponse20032.md +1 -1
  31. data/docs/InlineResponse20033.md +1 -1
  32. data/docs/InlineResponse20034.md +1 -1
  33. data/docs/InlineResponse20035.md +1 -1
  34. data/docs/InlineResponse20036.md +1 -1
  35. data/docs/InlineResponse20037.md +1 -1
  36. data/docs/InlineResponse20038.md +1 -1
  37. data/docs/InlineResponse20039.md +1 -1
  38. data/docs/InlineResponse20040.md +1 -1
  39. data/docs/InlineResponse20041.md +9 -0
  40. data/docs/InlineResponse20042.md +9 -0
  41. data/docs/OIDCApi.md +3 -3
  42. data/docs/Order.md +14 -0
  43. data/docs/PFMApi.md +87 -39
  44. data/docs/ProvidersApi.md +979 -122
  45. data/docs/RecipientsApi.md +4 -4
  46. data/docs/Subscription.md +1 -0
  47. data/docs/SubscriptionLog.md +15 -0
  48. data/docs/TermsApi.md +3 -3
  49. data/docs/Transaction.md +1 -0
  50. data/docs/Transfer.md +5 -1
  51. data/docs/TransferApi.md +77 -0
  52. data/docs/TransfersApi.md +39 -39
  53. data/docs/UsersManagementApi.md +13 -13
  54. data/docs/WealthApi.md +24 -24
  55. data/lib/budgea_client.rb +7 -2
  56. data/lib/budgea_client/api/administration_api.rb +381 -71
  57. data/lib/budgea_client/api/authentication_api.rb +16 -13
  58. data/lib/budgea_client/api/banks_api.rb +1034 -211
  59. data/lib/budgea_client/api/connections_api.rb +648 -30
  60. data/lib/budgea_client/api/documents_api.rb +85 -85
  61. data/lib/budgea_client/api/oidc_api.rb +3 -3
  62. data/lib/budgea_client/api/pfm_api.rb +87 -40
  63. data/lib/budgea_client/api/providers_api.rb +1045 -151
  64. data/lib/budgea_client/api/recipients_api.rb +4 -4
  65. data/lib/budgea_client/api/terms_api.rb +3 -3
  66. data/lib/budgea_client/api/transfer_api.rb +94 -0
  67. data/lib/budgea_client/api/transfers_api.rb +39 -39
  68. data/lib/budgea_client/api/users_management_api.rb +14 -14
  69. data/lib/budgea_client/api/wealth_api.rb +25 -25
  70. data/lib/budgea_client/models/account.rb +24 -4
  71. data/lib/budgea_client/models/account_log.rb +16 -1
  72. data/lib/budgea_client/models/client.rb +11 -11
  73. data/lib/budgea_client/models/connection.rb +23 -4
  74. data/lib/budgea_client/models/connection_log.rb +11 -1
  75. data/lib/budgea_client/models/connection_source.rb +309 -0
  76. data/lib/budgea_client/models/connector.rb +18 -15
  77. data/lib/budgea_client/models/connector_source.rb +273 -0
  78. data/lib/budgea_client/models/field.rb +14 -4
  79. data/lib/budgea_client/models/inline_response_200_11.rb +18 -18
  80. data/lib/budgea_client/models/inline_response_200_12.rb +11 -11
  81. data/lib/budgea_client/models/inline_response_200_13.rb +11 -11
  82. data/lib/budgea_client/models/inline_response_200_14.rb +18 -18
  83. data/lib/budgea_client/models/inline_response_200_15.rb +11 -11
  84. data/lib/budgea_client/models/inline_response_200_16.rb +11 -11
  85. data/lib/budgea_client/models/inline_response_200_17.rb +11 -11
  86. data/lib/budgea_client/models/inline_response_200_18.rb +18 -18
  87. data/lib/budgea_client/models/inline_response_200_19.rb +21 -11
  88. data/lib/budgea_client/models/inline_response_200_30.rb +18 -18
  89. data/lib/budgea_client/models/inline_response_200_31.rb +11 -11
  90. data/lib/budgea_client/models/inline_response_200_32.rb +18 -18
  91. data/lib/budgea_client/models/inline_response_200_33.rb +18 -18
  92. data/lib/budgea_client/models/inline_response_200_34.rb +11 -11
  93. data/lib/budgea_client/models/inline_response_200_35.rb +18 -18
  94. data/lib/budgea_client/models/inline_response_200_36.rb +18 -18
  95. data/lib/budgea_client/models/inline_response_200_37.rb +11 -11
  96. data/lib/budgea_client/models/inline_response_200_38.rb +18 -18
  97. data/lib/budgea_client/models/inline_response_200_39.rb +11 -11
  98. data/lib/budgea_client/models/inline_response_200_40.rb +18 -18
  99. data/lib/budgea_client/models/inline_response_200_41.rb +200 -0
  100. data/lib/budgea_client/models/inline_response_200_42.rb +200 -0
  101. data/lib/budgea_client/models/order.rb +259 -0
  102. data/lib/budgea_client/models/subscription.rb +11 -1
  103. data/lib/budgea_client/models/subscription_log.rb +269 -0
  104. data/lib/budgea_client/models/transaction.rb +11 -1
  105. data/lib/budgea_client/models/transfer.rb +49 -2
  106. data/lib/budgea_client/models/user.rb +2 -2
  107. data/lib/budgea_client/version.rb +1 -1
  108. data/original_budgea_openapi.json +1980 -351
  109. data/pkg/budgea_client-2.0.0.gem +0 -0
  110. data/pkg/budgea_client-3.0.1.gem +0 -0
  111. data/pkg/budgea_client-4.0.0.gem +0 -0
  112. data/spec/api/transfer_api_spec.rb +54 -0
  113. data/spec/models/connection_source_spec.rb +101 -0
  114. data/spec/models/connector_source_spec.rb +83 -0
  115. data/spec/models/inline_response_200_41_spec.rb +47 -0
  116. data/spec/models/inline_response_200_42_spec.rb +47 -0
  117. data/spec/models/order_spec.rb +77 -0
  118. data/spec/models/subscription_log_spec.rb +83 -0
  119. metadata +34 -9
  120. data/config.yaml +0 -15
  121. data/pkg/budgea_client-2.0.1.gem +0 -0
  122. data/pkg/budgea_client-2.0.2.gem +0 -0
  123. data/pkg/budgea_client-3.0.0.gem +0 -0
  124. data/pkg/budgea_client-4.0.1.gem +0 -0
  125. data/pkg/budgea_client-4.0.2.gem +0 -0
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #Budgea API Documentation
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BudgeaClient
16
+ class Order
17
+ # ID of the order
18
+ attr_accessor :id
19
+
20
+ # id of the merchant who initiated the order
21
+ attr_accessor :id_merchant
22
+
23
+ # id of the transfer used to pay this the order
24
+ attr_accessor :id_transfer
25
+
26
+ # State of the order (result of the recipient adding and the transfer execution)
27
+ attr_accessor :state
28
+
29
+ # more information on the state if something went wrong during the order
30
+ attr_accessor :error_message
31
+
32
+ # set by the webview, indicates at which step of the payment the user has left the order
33
+ attr_accessor :opt_out_cause
34
+
35
+ # Amount refunded
36
+ attr_accessor :refund_value
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'id' => :'id',
42
+ :'id_merchant' => :'id_merchant',
43
+ :'id_transfer' => :'id_transfer',
44
+ :'state' => :'state',
45
+ :'error_message' => :'error_message',
46
+ :'opt_out_cause' => :'opt_out_cause',
47
+ :'refund_value' => :'refund_value'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.swagger_types
53
+ {
54
+ :'id' => :'Integer',
55
+ :'id_merchant' => :'Integer',
56
+ :'id_transfer' => :'Integer',
57
+ :'state' => :'String',
58
+ :'error_message' => :'String',
59
+ :'opt_out_cause' => :'String',
60
+ :'refund_value' => :'Float'
61
+ }
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ return unless attributes.is_a?(Hash)
68
+
69
+ # convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
71
+
72
+ if attributes.has_key?(:'id')
73
+ self.id = attributes[:'id']
74
+ end
75
+
76
+ if attributes.has_key?(:'id_merchant')
77
+ self.id_merchant = attributes[:'id_merchant']
78
+ end
79
+
80
+ if attributes.has_key?(:'id_transfer')
81
+ self.id_transfer = attributes[:'id_transfer']
82
+ end
83
+
84
+ if attributes.has_key?(:'state')
85
+ self.state = attributes[:'state']
86
+ end
87
+
88
+ if attributes.has_key?(:'error_message')
89
+ self.error_message = attributes[:'error_message']
90
+ end
91
+
92
+ if attributes.has_key?(:'opt_out_cause')
93
+ self.opt_out_cause = attributes[:'opt_out_cause']
94
+ end
95
+
96
+ if attributes.has_key?(:'refund_value')
97
+ self.refund_value = attributes[:'refund_value']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ if @id.nil?
106
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
107
+ end
108
+
109
+ if @id_merchant.nil?
110
+ invalid_properties.push('invalid value for "id_merchant", id_merchant cannot be nil.')
111
+ end
112
+
113
+ if @id_transfer.nil?
114
+ invalid_properties.push('invalid value for "id_transfer", id_transfer cannot be nil.')
115
+ end
116
+
117
+ invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ return false if @id.nil?
124
+ return false if @id_merchant.nil?
125
+ return false if @id_transfer.nil?
126
+ true
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(o)
132
+ return true if self.equal?(o)
133
+ self.class == o.class &&
134
+ id == o.id &&
135
+ id_merchant == o.id_merchant &&
136
+ id_transfer == o.id_transfer &&
137
+ state == o.state &&
138
+ error_message == o.error_message &&
139
+ opt_out_cause == o.opt_out_cause &&
140
+ refund_value == o.refund_value
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Fixnum] Hash code
151
+ def hash
152
+ [id, id_merchant, id_transfer, state, error_message, opt_out_cause, refund_value].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ self.class.swagger_types.each_pair do |key, type|
161
+ if type =~ /\AArray<(.*)>/i
162
+ # check to ensure the input is an array given that the the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
166
+ end
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
170
+ end
171
+
172
+ self
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def _deserialize(type, value)
180
+ case type.to_sym
181
+ when :DateTime
182
+ DateTime.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :BOOLEAN
192
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
212
+ temp_model = BudgeaClient.const_get(type).new
213
+ temp_model.build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ next if value.nil?
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+ end
259
+ end
@@ -23,6 +23,9 @@ module BudgeaClient
23
23
  # ID of related user
24
24
  attr_accessor :id_user
25
25
 
26
+ # ID of the related connection source
27
+ attr_accessor :id_source
28
+
26
29
  # Subscription's number
27
30
  attr_accessor :number
28
31
 
@@ -56,6 +59,7 @@ module BudgeaClient
56
59
  :'id' => :'id',
57
60
  :'id_connection' => :'id_connection',
58
61
  :'id_user' => :'id_user',
62
+ :'id_source' => :'id_source',
59
63
  :'number' => :'number',
60
64
  :'label' => :'label',
61
65
  :'subscriber' => :'subscriber',
@@ -74,6 +78,7 @@ module BudgeaClient
74
78
  :'id' => :'Integer',
75
79
  :'id_connection' => :'Integer',
76
80
  :'id_user' => :'Integer',
81
+ :'id_source' => :'Integer',
77
82
  :'number' => :'String',
78
83
  :'label' => :'String',
79
84
  :'subscriber' => :'String',
@@ -106,6 +111,10 @@ module BudgeaClient
106
111
  self.id_user = attributes[:'id_user']
107
112
  end
108
113
 
114
+ if attributes.has_key?(:'id_source')
115
+ self.id_source = attributes[:'id_source']
116
+ end
117
+
109
118
  if attributes.has_key?(:'number')
110
119
  self.number = attributes[:'number']
111
120
  end
@@ -179,6 +188,7 @@ module BudgeaClient
179
188
  id == o.id &&
180
189
  id_connection == o.id_connection &&
181
190
  id_user == o.id_user &&
191
+ id_source == o.id_source &&
182
192
  number == o.number &&
183
193
  label == o.label &&
184
194
  subscriber == o.subscriber &&
@@ -199,7 +209,7 @@ module BudgeaClient
199
209
  # Calculates hash code according to all attributes.
200
210
  # @return [Fixnum] Hash code
201
211
  def hash
202
- [id, id_connection, id_user, number, label, subscriber, validity, renewdate, last_update, deleted, disabled, error].hash
212
+ [id, id_connection, id_user, id_source, number, label, subscriber, validity, renewdate, last_update, deleted, disabled, error].hash
203
213
  end
204
214
 
205
215
  # Builds the object from hash
@@ -0,0 +1,269 @@
1
+ =begin
2
+ #Budgea API Documentation
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BudgeaClient
16
+ class SubscriptionLog
17
+ # ID of the log
18
+ attr_accessor :id
19
+
20
+ # ID of the related subscription
21
+ attr_accessor :id_subscription
22
+
23
+ # Timestamp of log
24
+ attr_accessor :timestamp
25
+
26
+ # Number of docs on the subscription
27
+ attr_accessor :nb_docs
28
+
29
+ # ID of the related connection log
30
+ attr_accessor :id_connection_log
31
+
32
+ # If fail, contains the error code
33
+ attr_accessor :error
34
+
35
+ # If fail, error message received from provider
36
+ attr_accessor :error_message
37
+
38
+ # ID of the related connection source
39
+ attr_accessor :id_source
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'id' => :'id',
45
+ :'id_subscription' => :'id_subscription',
46
+ :'timestamp' => :'timestamp',
47
+ :'nb_docs' => :'nb_docs',
48
+ :'id_connection_log' => :'id_connection_log',
49
+ :'error' => :'error',
50
+ :'error_message' => :'error_message',
51
+ :'id_source' => :'id_source'
52
+ }
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.swagger_types
57
+ {
58
+ :'id' => :'Integer',
59
+ :'id_subscription' => :'Integer',
60
+ :'timestamp' => :'DateTime',
61
+ :'nb_docs' => :'Integer',
62
+ :'id_connection_log' => :'Integer',
63
+ :'error' => :'String',
64
+ :'error_message' => :'String',
65
+ :'id_source' => :'Integer'
66
+ }
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ return unless attributes.is_a?(Hash)
73
+
74
+ # convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
76
+
77
+ if attributes.has_key?(:'id')
78
+ self.id = attributes[:'id']
79
+ end
80
+
81
+ if attributes.has_key?(:'id_subscription')
82
+ self.id_subscription = attributes[:'id_subscription']
83
+ end
84
+
85
+ if attributes.has_key?(:'timestamp')
86
+ self.timestamp = attributes[:'timestamp']
87
+ end
88
+
89
+ if attributes.has_key?(:'nb_docs')
90
+ self.nb_docs = attributes[:'nb_docs']
91
+ end
92
+
93
+ if attributes.has_key?(:'id_connection_log')
94
+ self.id_connection_log = attributes[:'id_connection_log']
95
+ end
96
+
97
+ if attributes.has_key?(:'error')
98
+ self.error = attributes[:'error']
99
+ end
100
+
101
+ if attributes.has_key?(:'error_message')
102
+ self.error_message = attributes[:'error_message']
103
+ end
104
+
105
+ if attributes.has_key?(:'id_source')
106
+ self.id_source = attributes[:'id_source']
107
+ end
108
+ end
109
+
110
+ # Show invalid properties with the reasons. Usually used together with valid?
111
+ # @return Array for valid properties with the reasons
112
+ def list_invalid_properties
113
+ invalid_properties = Array.new
114
+ if @id.nil?
115
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
116
+ end
117
+
118
+ if @id_subscription.nil?
119
+ invalid_properties.push('invalid value for "id_subscription", id_subscription cannot be nil.')
120
+ end
121
+
122
+ if @timestamp.nil?
123
+ invalid_properties.push('invalid value for "timestamp", timestamp 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 @id.nil?
133
+ return false if @id_subscription.nil?
134
+ return false if @timestamp.nil?
135
+ true
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ id == o.id &&
144
+ id_subscription == o.id_subscription &&
145
+ timestamp == o.timestamp &&
146
+ nb_docs == o.nb_docs &&
147
+ id_connection_log == o.id_connection_log &&
148
+ error == o.error &&
149
+ error_message == o.error_message &&
150
+ id_source == o.id_source
151
+ end
152
+
153
+ # @see the `==` method
154
+ # @param [Object] Object to be compared
155
+ def eql?(o)
156
+ self == o
157
+ end
158
+
159
+ # Calculates hash code according to all attributes.
160
+ # @return [Fixnum] Hash code
161
+ def hash
162
+ [id, id_subscription, timestamp, nb_docs, id_connection_log, error, error_message, id_source].hash
163
+ end
164
+
165
+ # Builds the object from hash
166
+ # @param [Hash] attributes Model attributes in the form of hash
167
+ # @return [Object] Returns the model itself
168
+ def build_from_hash(attributes)
169
+ return nil unless attributes.is_a?(Hash)
170
+ self.class.swagger_types.each_pair do |key, type|
171
+ if type =~ /\AArray<(.*)>/i
172
+ # check to ensure the input is an array given that the the attribute
173
+ # is documented as an array but the input is not
174
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
175
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
176
+ end
177
+ elsif !attributes[self.class.attribute_map[key]].nil?
178
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
179
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
180
+ end
181
+
182
+ self
183
+ end
184
+
185
+ # Deserializes the data based on type
186
+ # @param string type Data type
187
+ # @param string value Value to be deserialized
188
+ # @return [Object] Deserialized data
189
+ def _deserialize(type, value)
190
+ case type.to_sym
191
+ when :DateTime
192
+ DateTime.parse(value)
193
+ when :Date
194
+ Date.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :BOOLEAN
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ temp_model = BudgeaClient.const_get(type).new
223
+ temp_model.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ next if value.nil?
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ # Outputs non-array value in the form of hash
252
+ # For object, use to_hash. Otherwise, just return the value
253
+ # @param [Object] value Any valid value
254
+ # @return [Hash] Returns the value in the form of hash
255
+ def _to_hash(value)
256
+ if value.is_a?(Array)
257
+ value.compact.map { |v| _to_hash(v) }
258
+ elsif value.is_a?(Hash)
259
+ {}.tap do |hash|
260
+ value.each { |k, v| hash[k] = _to_hash(v) }
261
+ end
262
+ elsif value.respond_to? :to_hash
263
+ value.to_hash
264
+ else
265
+ value
266
+ end
267
+ end
268
+ end
269
+ end