bb_payments 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +82 -0
- data/README.md +391 -0
- data/Rakefile +8 -0
- data/bb_payments.gemspec +30 -0
- data/docs/BankSlipsApi.md +178 -0
- data/docs/BarcodeCollectionFormsIDResponseObject.md +6 -0
- data/docs/BarcodeCollectionFormsIDResponseObjectListaGuiaCodigoBarra.md +10 -0
- data/docs/BarcodeCollectionFormsIDResponseObjectListaOcorrencia.md +9 -0
- data/docs/BarcodeCollectionFormsRequestObject.md +12 -0
- data/docs/BarcodecollectionformsCollectionFormDetailsList.md +12 -0
- data/docs/BatchtransfersPaymentsList.md +22 -0
- data/docs/BatchtransferscancelPaymentIds.md +7 -0
- data/docs/Body.md +13 -0
- data/docs/CancelApi.md +63 -0
- data/docs/CollectionFormsApi.md +184 -0
- data/docs/Error.md +7 -0
- data/docs/ErrorErrors.md +8 -0
- data/docs/ErrorOAuthUnauthorized.md +10 -0
- data/docs/ErrorOAuthUnauthorizedAttributes.md +7 -0
- data/docs/InlineResponse200.md +13 -0
- data/docs/InlineResponse2001.md +29 -0
- data/docs/InlineResponse2001OcurrencesList.md +9 -0
- data/docs/InlineResponse2002.md +12 -0
- data/docs/InlineResponse2002PaymentsList.md +26 -0
- data/docs/InlineResponse2003.md +26 -0
- data/docs/InlineResponse2003ListaBoleto.md +24 -0
- data/docs/InlineResponse2003ListaDevolucao.md +9 -0
- data/docs/InlineResponse200PaymentsList.md +15 -0
- data/docs/InlineResponse201.md +13 -0
- data/docs/InlineResponse2011.md +13 -0
- data/docs/InlineResponse2011PaymentsList.md +16 -0
- data/docs/InlineResponse201PaymentsList.md +26 -0
- data/docs/InlineResponse400.md +7 -0
- data/docs/InlineResponse401.md +10 -0
- data/docs/ReturnedsApi.md +78 -0
- data/docs/RootTypeForBankSlipList.md +29 -0
- data/docs/RootTypeForBankSlipsBatchPayment.md +12 -0
- data/docs/RootTypeForBankSlipsBatchPaymentResponseObject.md +12 -0
- data/docs/RootTypeForBatchTransferGETResponseObject.md +9 -0
- data/docs/RootTypeForBatchTransferPaymentsListGET.md +21 -0
- data/docs/RootTypeForBatchTransfersCancelPaymentsListObject.md +10 -0
- data/docs/RootTypeForBatchTransfersCancelRequestObject.md +12 -0
- data/docs/RootTypeForBatchTransfersCancelResponseObject.md +7 -0
- data/docs/RootTypeForReturnedPaymentsDetails.md +33 -0
- data/docs/RootTypeForReturnedPaymentsResponseObject.md +10 -0
- data/docs/RootTypeForSlipsDetailsObject.md +23 -0
- data/docs/TransfersApi.md +309 -0
- data/lib/bb_payments/api/base.rb +10 -0
- data/lib/bb_payments/api/base_api.rb +63 -0
- data/lib/bb_payments/api/batch_payments_api.rb +50 -0
- data/lib/bb_payments/api/payments.rb +114 -0
- data/lib/bb_payments/api/transfers.rb +33 -0
- data/lib/bb_payments/api/transfers_pix.rb +52 -0
- data/lib/bb_payments/api_client.rb +414 -0
- data/lib/bb_payments/api_error.rb +57 -0
- data/lib/bb_payments/configuration.rb +246 -0
- data/lib/bb_payments/models/base_model.rb +177 -0
- data/lib/bb_payments/models/batch_pix_body.rb +30 -0
- data/lib/bb_payments/models/batch_pix_response.rb +69 -0
- data/lib/bb_payments/models/batch_transfers_body.rb +30 -0
- data/lib/bb_payments/models/batch_transfers_response.rb +64 -0
- data/lib/bb_payments/models/batchtransfers_payments_list.rb +362 -0
- data/lib/bb_payments/models/batchtransferscancel_payment_ids.rb +212 -0
- data/lib/bb_payments/models/body.rb +274 -0
- data/lib/bb_payments/models/error.rb +210 -0
- data/lib/bb_payments/models/error_errors.rb +227 -0
- data/lib/bb_payments/models/error_o_auth_unauthorized.rb +257 -0
- data/lib/bb_payments/models/error_o_auth_unauthorized_attributes.rb +213 -0
- data/lib/bb_payments/models/find_batch_payment.rb +93 -0
- data/lib/bb_payments/models/find_batch_response.rb +71 -0
- data/lib/bb_payments/models/inline_response_200.rb +270 -0
- data/lib/bb_payments/models/inline_response_200_1.rb +430 -0
- data/lib/bb_payments/models/inline_response_200_1_ocurrences_list.rb +227 -0
- data/lib/bb_payments/models/inline_response_200_2.rb +260 -0
- data/lib/bb_payments/models/inline_response_200_2_payments_list.rb +399 -0
- data/lib/bb_payments/models/inline_response_200_3.rb +487 -0
- data/lib/bb_payments/models/inline_response_200_3_lista_boleto.rb +377 -0
- data/lib/bb_payments/models/inline_response_200_3_lista_devolucao.rb +227 -0
- data/lib/bb_payments/models/inline_response_200_payments_list.rb +289 -0
- data/lib/bb_payments/models/inline_response_201.rb +270 -0
- data/lib/bb_payments/models/inline_response_201_1.rb +270 -0
- data/lib/bb_payments/models/inline_response_201_1_payments_list.rb +299 -0
- data/lib/bb_payments/models/inline_response_201_payments_list.rb +399 -0
- data/lib/bb_payments/models/inline_response_400.rb +210 -0
- data/lib/bb_payments/models/inline_response_401.rb +257 -0
- data/lib/bb_payments/models/root_type_for_bank_slip_list.rb +430 -0
- data/lib/bb_payments/models/root_type_for_bank_slips_batch_payment.rb +270 -0
- data/lib/bb_payments/models/root_type_for_bank_slips_batch_payment_response_object.rb +260 -0
- data/lib/bb_payments/models/root_type_for_batch_transfer_get_response_object.rb +230 -0
- data/lib/bb_payments/models/root_type_for_batch_transfer_payments_list_get.rb +348 -0
- data/lib/bb_payments/models/root_type_for_batch_transfers_cancel_payments_list_object.rb +238 -0
- data/lib/bb_payments/models/root_type_for_batch_transfers_cancel_request_object.rb +275 -0
- data/lib/bb_payments/models/root_type_for_batch_transfers_cancel_response_object.rb +210 -0
- data/lib/bb_payments/models/root_type_for_returned_payments_details.rb +468 -0
- data/lib/bb_payments/models/root_type_for_returned_payments_response_object.rb +240 -0
- data/lib/bb_payments/models/root_type_for_slips_details_object.rb +408 -0
- data/lib/bb_payments/models/transfer_base.rb +128 -0
- data/lib/bb_payments/models/transfer_pix.rb +34 -0
- data/lib/bb_payments/models/transfer_pix_base.rb +146 -0
- data/lib/bb_payments/version.rb +3 -0
- data/lib/bb_payments.rb +85 -0
- data/spec/api/batch_payments_api_spec.rb +113 -0
- data/spec/api_client_spec.rb +225 -0
- data/spec/base_object_spec.rb +109 -0
- data/spec/configuration_spec.rb +41 -0
- data/spec/models/body_spec.rb +76 -0
- data/spec/models/error_errors_spec.rb +46 -0
- data/spec/models/error_o_auth_unauthorized_attributes_spec.rb +40 -0
- data/spec/models/error_o_auth_unauthorized_spec.rb +58 -0
- data/spec/models/error_spec.rb +40 -0
- data/spec/models/inline_response_200_1_ocurrences_list_spec.rb +52 -0
- data/spec/models/inline_response_200_1_spec.rb +172 -0
- data/spec/models/inline_response_200_2_payments_list_spec.rb +154 -0
- data/spec/models/inline_response_200_2_spec.rb +70 -0
- data/spec/models/inline_response_200_3_lista_boleto_spec.rb +142 -0
- data/spec/models/inline_response_200_3_lista_devolucao_spec.rb +52 -0
- data/spec/models/inline_response_200_3_spec.rb +154 -0
- data/spec/models/inline_response_200_payments_list_spec.rb +88 -0
- data/spec/models/inline_response_200_spec.rb +76 -0
- data/spec/models/inline_response_201_1_payments_list_spec.rb +94 -0
- data/spec/models/inline_response_201_1_spec.rb +76 -0
- data/spec/models/inline_response_201_payments_list_spec.rb +154 -0
- data/spec/models/inline_response_201_spec.rb +76 -0
- data/spec/models/inline_response_400_spec.rb +40 -0
- data/spec/models/inline_response_401_spec.rb +58 -0
- data/spec/models/root_type_for_bank_slip_list_spec.rb +172 -0
- data/spec/models/root_type_for_bank_slips_batch_payment_response_object_spec.rb +70 -0
- data/spec/models/root_type_for_bank_slips_batch_payment_spec.rb +70 -0
- data/spec/models/root_type_for_batch_transfer_get_response_object_spec.rb +52 -0
- data/spec/models/root_type_for_batch_transfer_payments_list_get_spec.rb +124 -0
- data/spec/models/root_type_for_batch_transfers_cancel_payments_list_object_spec.rb +58 -0
- data/spec/models/root_type_for_batch_transfers_cancel_request_object_spec.rb +70 -0
- data/spec/models/root_type_for_batch_transfers_cancel_response_object_spec.rb +40 -0
- data/spec/models/root_type_for_returned_payments_details_spec.rb +196 -0
- data/spec/models/root_type_for_returned_payments_response_object_spec.rb +58 -0
- data/spec/models/root_type_for_slips_details_object_spec.rb +136 -0
- data/spec/spec_helper.rb +110 -0
- metadata +292 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Payments-VPN
|
|
3
|
+
|
|
4
|
+
#Esta API fornece os serviços de pagamento do Banco do Brasil.
|
|
5
|
+
|
|
6
|
+
OpenAPI spec version: 3.5
|
|
7
|
+
|
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
9
|
+
Swagger Codegen version: 3.0.24
|
|
10
|
+
=end
|
|
11
|
+
|
|
12
|
+
require 'date'
|
|
13
|
+
|
|
14
|
+
module BancoBrasilPayments
|
|
15
|
+
# Representação dos campos de resposta de uma solicitação de recuperação de transferência em lote.
|
|
16
|
+
class InlineResponse200
|
|
17
|
+
# O valor desse campo é usado no parâmetro de consulta definido como \"index\" para recuperar a próxima ocorrência de pagamentos.
|
|
18
|
+
attr_accessor :next_index
|
|
19
|
+
|
|
20
|
+
# Código do estado da requisição a ser pesquisada: 1 - Requisição com todos os lançamentos com dados consistentes; 2 - Requisição com ao menos um dos lançamentos com dados inconsistentes; 3 - Requisição com todos os lançamentos com dados inconsistentes; 4 - Requisição pendente de ação pelo Conveniado - falta autorizar o pagamento; 5 - Requisição em processamento pelo Banco; 6 - Requisição Processada; 7 - Requisição Rejeitada, 8 - Preparando remessa não liberada, 9 - Requisição liberada via API, 10 - Preparando remessa liberada. As situações 1, 2 e 8 são transitórias e não requerem qualquer ação do Cliente Conveniado. situação 3 sempre será migrada para situação 7. A situação 4 Significa que, ao menos um lançamento, depende de ação do Cliente Conveniado, seja liberando ou cancelando os pagamentos. As situações 5, 6, 7, 9 e 10 não requerem qualquer ação do Cliente Conveniado. A situação 5 significa que, ao menos um lançamento, está agendado. As situações 6 e 7 são definitivas não havendo alteração posterior da situação da requisição.
|
|
21
|
+
attr_accessor :request_status
|
|
22
|
+
|
|
23
|
+
# Modalidade que representa o tipo de pagamento, sendo: 126 pagamento de fornecedores; 127 pagamento de salário e 128 pagamentos diversos
|
|
24
|
+
attr_accessor :payment_type
|
|
25
|
+
|
|
26
|
+
# Data da requisição (formato ddmmaaaa)
|
|
27
|
+
attr_accessor :request_date
|
|
28
|
+
|
|
29
|
+
# Quantidade total de pagamentos a serem processados em lote. Essa informação não é a quantidade de registros retornados em \"paymentsList\".
|
|
30
|
+
attr_accessor :payments_total_quantity
|
|
31
|
+
|
|
32
|
+
# Valor montante total dos pagamentos a serem processados em lote. Esta informação não é uma soma de valores do campo \"paymentValue\" em \"paymentsList\" (formato 0.00)
|
|
33
|
+
attr_accessor :payments_total_value
|
|
34
|
+
|
|
35
|
+
# Lista de pagamentos submetidos para processamento em lote. Essa lista pode ser parcial ou total, a depender da seguinte regra: se o valor do campo \"nextIndex\" for menor que o valor do campo \"paymentsTotalQuantity\", então trata-se de lista parcial; caso contrário, trata-se de lista com todos os pagamentos.
|
|
36
|
+
attr_accessor :payments_list
|
|
37
|
+
|
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
39
|
+
def self.attribute_map
|
|
40
|
+
{
|
|
41
|
+
:'next_index' => :'nextIndex',
|
|
42
|
+
:'request_status' => :'requestStatus',
|
|
43
|
+
:'payment_type' => :'paymentType',
|
|
44
|
+
:'request_date' => :'requestDate',
|
|
45
|
+
:'payments_total_quantity' => :'paymentsTotalQuantity',
|
|
46
|
+
:'payments_total_value' => :'paymentsTotalValue',
|
|
47
|
+
:'payments_list' => :'paymentsList'
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Attribute type mapping.
|
|
52
|
+
def self.openapi_types
|
|
53
|
+
{
|
|
54
|
+
:'next_index' => :'Object',
|
|
55
|
+
:'request_status' => :'Object',
|
|
56
|
+
:'payment_type' => :'Object',
|
|
57
|
+
:'request_date' => :'Object',
|
|
58
|
+
:'payments_total_quantity' => :'Object',
|
|
59
|
+
:'payments_total_value' => :'Object',
|
|
60
|
+
:'payments_list' => :'Object'
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# List of attributes with nullable: true
|
|
65
|
+
def self.openapi_nullable
|
|
66
|
+
Set.new([
|
|
67
|
+
])
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Initializes the object
|
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
72
|
+
def initialize(attributes = {})
|
|
73
|
+
if (!attributes.is_a?(Hash))
|
|
74
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BancoBrasilPayments::InlineResponse200` initialize method"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
78
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
79
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
80
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BancoBrasilPayments::InlineResponse200`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
81
|
+
end
|
|
82
|
+
h[k.to_sym] = v
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if attributes.key?(:'next_index')
|
|
86
|
+
self.next_index = attributes[:'next_index']
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
if attributes.key?(:'request_status')
|
|
90
|
+
self.request_status = attributes[:'request_status']
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
if attributes.key?(:'payment_type')
|
|
94
|
+
self.payment_type = attributes[:'payment_type']
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'request_date')
|
|
98
|
+
self.request_date = attributes[:'request_date']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'payments_total_quantity')
|
|
102
|
+
self.payments_total_quantity = attributes[:'payments_total_quantity']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'payments_total_value')
|
|
106
|
+
self.payments_total_value = attributes[:'payments_total_value']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'payments_list')
|
|
110
|
+
if (value = attributes[:'payments_list']).is_a?(Array)
|
|
111
|
+
self.payments_list = value
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
117
|
+
# @return Array for valid properties with the reasons
|
|
118
|
+
def list_invalid_properties
|
|
119
|
+
invalid_properties = Array.new
|
|
120
|
+
invalid_properties
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Check to see if the all the properties in the model are valid
|
|
124
|
+
# @return true if the model is valid
|
|
125
|
+
def valid?
|
|
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
|
+
next_index == o.next_index &&
|
|
135
|
+
request_status == o.request_status &&
|
|
136
|
+
payment_type == o.payment_type &&
|
|
137
|
+
request_date == o.request_date &&
|
|
138
|
+
payments_total_quantity == o.payments_total_quantity &&
|
|
139
|
+
payments_total_value == o.payments_total_value &&
|
|
140
|
+
payments_list == o.payments_list
|
|
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 [Integer] Hash code
|
|
151
|
+
def hash
|
|
152
|
+
[next_index, request_status, payment_type, request_date, payments_total_quantity, payments_total_value, payments_list].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 self.build_from_hash(attributes)
|
|
159
|
+
new.build_from_hash(attributes)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Builds the object from hash
|
|
163
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
164
|
+
# @return [Object] Returns the model itself
|
|
165
|
+
def build_from_hash(attributes)
|
|
166
|
+
return nil unless attributes.is_a?(Hash)
|
|
167
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
168
|
+
if type =~ /\AArray<(.*)>/i
|
|
169
|
+
# check to ensure the input is an array given that the attribute
|
|
170
|
+
# is documented as an array but the input is not
|
|
171
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
172
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
173
|
+
end
|
|
174
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
175
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
176
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
177
|
+
self.send("#{key}=", nil)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
self
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Deserializes the data based on type
|
|
185
|
+
# @param string type Data type
|
|
186
|
+
# @param string value Value to be deserialized
|
|
187
|
+
# @return [Object] Deserialized data
|
|
188
|
+
def _deserialize(type, value)
|
|
189
|
+
case type.to_sym
|
|
190
|
+
when :DateTime
|
|
191
|
+
DateTime.parse(value)
|
|
192
|
+
when :Date
|
|
193
|
+
Date.parse(value)
|
|
194
|
+
when :String
|
|
195
|
+
value.to_s
|
|
196
|
+
when :Integer
|
|
197
|
+
value.to_i
|
|
198
|
+
when :Float
|
|
199
|
+
value.to_f
|
|
200
|
+
when :Boolean
|
|
201
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
202
|
+
true
|
|
203
|
+
else
|
|
204
|
+
false
|
|
205
|
+
end
|
|
206
|
+
when :Object
|
|
207
|
+
# generic object (usually a Hash), return directly
|
|
208
|
+
value
|
|
209
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
210
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
211
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
212
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
213
|
+
k_type = Regexp.last_match[:k_type]
|
|
214
|
+
v_type = Regexp.last_match[:v_type]
|
|
215
|
+
{}.tap do |hash|
|
|
216
|
+
value.each do |k, v|
|
|
217
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
else # model
|
|
221
|
+
BancoBrasilPayments.const_get(type).build_from_hash(value)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Returns the string representation of the object
|
|
226
|
+
# @return [String] String presentation of the object
|
|
227
|
+
def to_s
|
|
228
|
+
to_hash.to_s
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
232
|
+
# @return [Hash] Returns the object in the form of hash
|
|
233
|
+
def to_body
|
|
234
|
+
to_hash
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Returns the object in the form of hash
|
|
238
|
+
# @return [Hash] Returns the object in the form of hash
|
|
239
|
+
def to_hash
|
|
240
|
+
hash = {}
|
|
241
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
242
|
+
value = self.send(attr)
|
|
243
|
+
if value.nil?
|
|
244
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
245
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
hash[param] = _to_hash(value)
|
|
249
|
+
end
|
|
250
|
+
hash
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Outputs non-array value in the form of hash
|
|
254
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
255
|
+
# @param [Object] value Any valid value
|
|
256
|
+
# @return [Hash] Returns the value in the form of hash
|
|
257
|
+
def _to_hash(value)
|
|
258
|
+
if value.is_a?(Array)
|
|
259
|
+
value.compact.map { |v| _to_hash(v) }
|
|
260
|
+
elsif value.is_a?(Hash)
|
|
261
|
+
{}.tap do |hash|
|
|
262
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
263
|
+
end
|
|
264
|
+
elsif value.respond_to? :to_hash
|
|
265
|
+
value.to_hash
|
|
266
|
+
else
|
|
267
|
+
value
|
|
268
|
+
end
|
|
269
|
+
end end
|
|
270
|
+
end
|