dear-inventory-ruby 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/README.md +8 -4
- data/dear-inventory-ruby.gemspec +1 -1
- data/docs/Account.md +15 -15
- data/docs/Accounts.md +3 -3
- data/docs/Address.md +9 -9
- data/docs/Contact.md +9 -9
- data/docs/Customer.md +31 -31
- data/docs/Customers.md +3 -3
- data/docs/DimensionsUnit.md +16 -0
- data/docs/Error.md +2 -2
- data/docs/InventoryApi.md +54 -0
- data/docs/Me.md +29 -0
- data/docs/PaymentTerm.md +6 -6
- data/docs/PaymentTerms.md +3 -3
- data/docs/Success.md +1 -1
- data/docs/Tax.md +9 -9
- data/docs/TaxComponent.md +4 -4
- data/docs/Taxes.md +3 -3
- data/docs/WeightUnit.md +16 -0
- data/lib/dear-inventory-ruby.rb +4 -1
- data/lib/dear-inventory-ruby/api/inventory_api.rb +55 -1
- data/lib/dear-inventory-ruby/api_client.rb +1 -1
- data/lib/dear-inventory-ruby/api_error.rb +1 -1
- data/lib/dear-inventory-ruby/configuration.rb +1 -1
- data/lib/dear-inventory-ruby/models/account.rb +1 -1
- data/lib/dear-inventory-ruby/models/accounts.rb +1 -1
- data/lib/dear-inventory-ruby/models/address.rb +1 -1
- data/lib/dear-inventory-ruby/models/contact.rb +1 -1
- data/lib/dear-inventory-ruby/models/currency_code.rb +1 -1
- data/lib/dear-inventory-ruby/models/customer.rb +1 -1
- data/lib/dear-inventory-ruby/models/customers.rb +1 -1
- data/lib/dear-inventory-ruby/models/dimensions_unit.rb +42 -0
- data/lib/dear-inventory-ruby/models/error.rb +1 -1
- data/lib/dear-inventory-ruby/models/me.rb +264 -0
- data/lib/dear-inventory-ruby/models/payment_term.rb +1 -1
- data/lib/dear-inventory-ruby/models/payment_terms.rb +1 -1
- data/lib/dear-inventory-ruby/models/success.rb +1 -1
- data/lib/dear-inventory-ruby/models/tax.rb +1 -1
- data/lib/dear-inventory-ruby/models/tax_component.rb +1 -1
- data/lib/dear-inventory-ruby/models/taxes.rb +1 -1
- data/lib/dear-inventory-ruby/models/weight_unit.rb +39 -0
- data/lib/dear-inventory-ruby/version.rb +2 -2
- data/spec/api/inventory_api_spec.rb +11 -1
- data/spec/api_client_spec.rb +2 -2
- data/spec/configuration_spec.rb +1 -1
- data/spec/models/account_spec.rb +1 -1
- data/spec/models/accounts_spec.rb +1 -1
- data/spec/models/address_spec.rb +1 -1
- data/spec/models/contact_spec.rb +1 -1
- data/spec/models/currency_code_spec.rb +1 -1
- data/spec/models/customer_spec.rb +1 -1
- data/spec/models/customers_spec.rb +1 -1
- data/spec/models/dimensions_unit_spec.rb +35 -0
- data/spec/models/error_spec.rb +1 -1
- data/spec/models/me_spec.rb +77 -0
- data/spec/models/payment_term_spec.rb +1 -1
- data/spec/models/payment_terms_spec.rb +1 -1
- data/spec/models/success_spec.rb +1 -1
- data/spec/models/tax_component_spec.rb +1 -1
- data/spec/models/tax_spec.rb +1 -1
- data/spec/models/taxes_spec.rb +1 -1
- data/spec/models/weight_unit_spec.rb +35 -0
- data/spec/spec_helper.rb +1 -1
- metadata +14 -2
data/docs/Success.md
CHANGED
data/docs/Tax.md
CHANGED
@@ -19,15 +19,15 @@ Name | Type | Description | Notes
|
|
19
19
|
```ruby
|
20
20
|
require 'DearInventoryRuby'
|
21
21
|
|
22
|
-
instance = DearInventoryRuby::Tax.new(id:
|
23
|
-
name:
|
24
|
-
account:
|
25
|
-
is_active:
|
26
|
-
tax_inclusive:
|
27
|
-
tax_percent:
|
28
|
-
is_tax_for_sale:
|
29
|
-
is_tax_for_purchase:
|
30
|
-
components:
|
22
|
+
instance = DearInventoryRuby::Tax.new(id: nil,
|
23
|
+
name: nil,
|
24
|
+
account: nil,
|
25
|
+
is_active: nil,
|
26
|
+
tax_inclusive: nil,
|
27
|
+
tax_percent: nil,
|
28
|
+
is_tax_for_sale: nil,
|
29
|
+
is_tax_for_purchase: nil,
|
30
|
+
components: nil)
|
31
31
|
```
|
32
32
|
|
33
33
|
|
data/docs/TaxComponent.md
CHANGED
@@ -14,10 +14,10 @@ Name | Type | Description | Notes
|
|
14
14
|
```ruby
|
15
15
|
require 'DearInventoryRuby'
|
16
16
|
|
17
|
-
instance = DearInventoryRuby::TaxComponent.new(name:
|
18
|
-
percent:
|
19
|
-
account_code:
|
20
|
-
component_order:
|
17
|
+
instance = DearInventoryRuby::TaxComponent.new(name: nil,
|
18
|
+
percent: nil,
|
19
|
+
account_code: nil,
|
20
|
+
component_order: nil)
|
21
21
|
```
|
22
22
|
|
23
23
|
|
data/docs/Taxes.md
CHANGED
@@ -13,9 +13,9 @@ Name | Type | Description | Notes
|
|
13
13
|
```ruby
|
14
14
|
require 'DearInventoryRuby'
|
15
15
|
|
16
|
-
instance = DearInventoryRuby::Taxes.new(total:
|
17
|
-
page:
|
18
|
-
tax_rule_list:
|
16
|
+
instance = DearInventoryRuby::Taxes.new(total: nil,
|
17
|
+
page: nil,
|
18
|
+
tax_rule_list: nil)
|
19
19
|
```
|
20
20
|
|
21
21
|
|
data/docs/WeightUnit.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# DearInventoryRuby::WeightUnit
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
|
8
|
+
## Code Sample
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
require 'DearInventoryRuby'
|
12
|
+
|
13
|
+
instance = DearInventoryRuby::WeightUnit.new()
|
14
|
+
```
|
15
|
+
|
16
|
+
|
data/lib/dear-inventory-ruby.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: 2.0.0
|
7
7
|
Contact: nnhansg@gmail.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.3.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -24,13 +24,16 @@ require 'dear-inventory-ruby/models/contact'
|
|
24
24
|
require 'dear-inventory-ruby/models/currency_code'
|
25
25
|
require 'dear-inventory-ruby/models/customer'
|
26
26
|
require 'dear-inventory-ruby/models/customers'
|
27
|
+
require 'dear-inventory-ruby/models/dimensions_unit'
|
27
28
|
require 'dear-inventory-ruby/models/error'
|
29
|
+
require 'dear-inventory-ruby/models/me'
|
28
30
|
require 'dear-inventory-ruby/models/payment_term'
|
29
31
|
require 'dear-inventory-ruby/models/payment_terms'
|
30
32
|
require 'dear-inventory-ruby/models/success'
|
31
33
|
require 'dear-inventory-ruby/models/tax'
|
32
34
|
require 'dear-inventory-ruby/models/tax_component'
|
33
35
|
require 'dear-inventory-ruby/models/taxes'
|
36
|
+
require 'dear-inventory-ruby/models/weight_unit'
|
34
37
|
|
35
38
|
# APIs
|
36
39
|
require 'dear-inventory-ruby/api/inventory_api'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: 2.0.0
|
7
7
|
Contact: nnhansg@gmail.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.3.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -537,6 +537,60 @@ module DearInventoryRuby
|
|
537
537
|
return data, status_code, headers
|
538
538
|
end
|
539
539
|
|
540
|
+
# Allows you to retrieve your information
|
541
|
+
# @param [Hash] opts the optional parameters
|
542
|
+
# @return [Me]
|
543
|
+
def get_me(opts = {})
|
544
|
+
data, _status_code, _headers = get_me_with_http_info(opts)
|
545
|
+
data
|
546
|
+
end
|
547
|
+
|
548
|
+
# Allows you to retrieve your information
|
549
|
+
# @param [Hash] opts the optional parameters
|
550
|
+
# @return [Array<(Me, Integer, Hash)>] Me data, response status code and response headers
|
551
|
+
def get_me_with_http_info(opts = {})
|
552
|
+
if @api_client.config.debugging
|
553
|
+
@api_client.config.logger.debug 'Calling API: InventoryApi.get_me ...'
|
554
|
+
end
|
555
|
+
# resource path
|
556
|
+
local_var_path = '/me'
|
557
|
+
|
558
|
+
# query parameters
|
559
|
+
query_params = opts[:query_params] || {}
|
560
|
+
|
561
|
+
# header parameters
|
562
|
+
header_params = opts[:header_params] || {}
|
563
|
+
# HTTP header 'Accept' (if needed)
|
564
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
565
|
+
|
566
|
+
# form parameters
|
567
|
+
form_params = opts[:form_params] || {}
|
568
|
+
|
569
|
+
# http body (model)
|
570
|
+
post_body = opts[:body]
|
571
|
+
|
572
|
+
# return_type
|
573
|
+
return_type = opts[:return_type] || 'Me'
|
574
|
+
|
575
|
+
# auth_names
|
576
|
+
auth_names = opts[:auth_names] || ['accountID', 'appKey']
|
577
|
+
|
578
|
+
new_options = opts.merge(
|
579
|
+
:header_params => header_params,
|
580
|
+
:query_params => query_params,
|
581
|
+
:form_params => form_params,
|
582
|
+
:body => post_body,
|
583
|
+
:auth_names => auth_names,
|
584
|
+
:return_type => return_type
|
585
|
+
)
|
586
|
+
|
587
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
588
|
+
if @api_client.config.debugging
|
589
|
+
@api_client.config.logger.debug "API called: InventoryApi#get_me\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
590
|
+
end
|
591
|
+
return data, status_code, headers
|
592
|
+
end
|
593
|
+
|
540
594
|
# Allows you to retrieve the payment terms
|
541
595
|
# @param [Hash] opts the optional parameters
|
542
596
|
# @option opts [String] :page Default is 1 (default to '1')
|
@@ -0,0 +1,42 @@
|
|
1
|
+
=begin
|
2
|
+
#DEAR Inventory API
|
3
|
+
|
4
|
+
#This specifing endpoints for DEAR Inventory API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: nnhansg@gmail.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DearInventoryRuby
|
16
|
+
class DimensionsUnit
|
17
|
+
M = "m".freeze
|
18
|
+
CM = "cm".freeze
|
19
|
+
MI = "mi".freeze
|
20
|
+
MM = "mm".freeze
|
21
|
+
IN = "in".freeze
|
22
|
+
FT = "ft".freeze
|
23
|
+
YD = "yd".freeze
|
24
|
+
KM = "km".freeze
|
25
|
+
|
26
|
+
# Builds the enum from string
|
27
|
+
# @param [String] The enum value in the form of the string
|
28
|
+
# @return [String] The enum value
|
29
|
+
def self.build_from_hash(value)
|
30
|
+
new.build_from_hash(value)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Builds the enum from string
|
34
|
+
# @param [String] The enum value in the form of the string
|
35
|
+
# @return [String] The enum value
|
36
|
+
def build_from_hash(value)
|
37
|
+
constantValues = DimensionsUnit.constants.select { |c| DimensionsUnit::const_get(c) == value }
|
38
|
+
raise "Invalid ENUM value #{value} for class #DimensionsUnit" if constantValues.empty?
|
39
|
+
value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
=begin
|
2
|
+
#DEAR Inventory API
|
3
|
+
|
4
|
+
#This specifing endpoints for DEAR Inventory API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: nnhansg@gmail.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DearInventoryRuby
|
16
|
+
class Me
|
17
|
+
# Your company name
|
18
|
+
attr_accessor :company
|
19
|
+
|
20
|
+
attr_accessor :currency
|
21
|
+
|
22
|
+
# Time Zone where your company located
|
23
|
+
attr_accessor :time_zone
|
24
|
+
|
25
|
+
attr_accessor :default_weight_units
|
26
|
+
|
27
|
+
attr_accessor :default_dimensions_units
|
28
|
+
|
29
|
+
# Financial settings option. Indicates date period start from what you can change transactional data. Formatted in Tenant date format
|
30
|
+
attr_accessor :lock_date
|
31
|
+
|
32
|
+
# Date of opening balances in the system. Formatted in Tenant date format
|
33
|
+
attr_accessor :opening_balance_date
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:'company' => :'Company',
|
39
|
+
:'currency' => :'Currency',
|
40
|
+
:'time_zone' => :'TimeZone',
|
41
|
+
:'default_weight_units' => :'DefaultWeightUnits',
|
42
|
+
:'default_dimensions_units' => :'DefaultDimensionsUnits',
|
43
|
+
:'lock_date' => :'LockDate',
|
44
|
+
:'opening_balance_date' => :'OpeningBalanceDate'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute type mapping.
|
49
|
+
def self.openapi_types
|
50
|
+
{
|
51
|
+
:'company' => :'String',
|
52
|
+
:'currency' => :'CurrencyCode',
|
53
|
+
:'time_zone' => :'String',
|
54
|
+
:'default_weight_units' => :'WeightUnit',
|
55
|
+
:'default_dimensions_units' => :'DimensionsUnit',
|
56
|
+
:'lock_date' => :'Date',
|
57
|
+
:'opening_balance_date' => :'Date'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# List of attributes with nullable: true
|
62
|
+
def self.openapi_nullable
|
63
|
+
Set.new([
|
64
|
+
])
|
65
|
+
end
|
66
|
+
|
67
|
+
# Initializes the object
|
68
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
69
|
+
def initialize(attributes = {})
|
70
|
+
if (!attributes.is_a?(Hash))
|
71
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Me` initialize method"
|
72
|
+
end
|
73
|
+
|
74
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
75
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
76
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
77
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Me`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
78
|
+
end
|
79
|
+
h[k.to_sym] = v
|
80
|
+
}
|
81
|
+
|
82
|
+
if attributes.key?(:'company')
|
83
|
+
self.company = attributes[:'company']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'currency')
|
87
|
+
self.currency = attributes[:'currency']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'time_zone')
|
91
|
+
self.time_zone = attributes[:'time_zone']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'default_weight_units')
|
95
|
+
self.default_weight_units = attributes[:'default_weight_units']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'default_dimensions_units')
|
99
|
+
self.default_dimensions_units = attributes[:'default_dimensions_units']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'lock_date')
|
103
|
+
self.lock_date = attributes[:'lock_date']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'opening_balance_date')
|
107
|
+
self.opening_balance_date = attributes[:'opening_balance_date']
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
112
|
+
# @return Array for valid properties with the reasons
|
113
|
+
def list_invalid_properties
|
114
|
+
invalid_properties = Array.new
|
115
|
+
invalid_properties
|
116
|
+
end
|
117
|
+
|
118
|
+
# Check to see if the all the properties in the model are valid
|
119
|
+
# @return true if the model is valid
|
120
|
+
def valid?
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
# Checks equality by comparing each attribute.
|
125
|
+
# @param [Object] Object to be compared
|
126
|
+
def ==(o)
|
127
|
+
return true if self.equal?(o)
|
128
|
+
self.class == o.class &&
|
129
|
+
company == o.company &&
|
130
|
+
currency == o.currency &&
|
131
|
+
time_zone == o.time_zone &&
|
132
|
+
default_weight_units == o.default_weight_units &&
|
133
|
+
default_dimensions_units == o.default_dimensions_units &&
|
134
|
+
lock_date == o.lock_date &&
|
135
|
+
opening_balance_date == o.opening_balance_date
|
136
|
+
end
|
137
|
+
|
138
|
+
# @see the `==` method
|
139
|
+
# @param [Object] Object to be compared
|
140
|
+
def eql?(o)
|
141
|
+
self == o
|
142
|
+
end
|
143
|
+
|
144
|
+
# Calculates hash code according to all attributes.
|
145
|
+
# @return [Integer] Hash code
|
146
|
+
def hash
|
147
|
+
[company, currency, time_zone, default_weight_units, default_dimensions_units, lock_date, opening_balance_date].hash
|
148
|
+
end
|
149
|
+
|
150
|
+
# Builds the object from hash
|
151
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
152
|
+
# @return [Object] Returns the model itself
|
153
|
+
def self.build_from_hash(attributes)
|
154
|
+
new.build_from_hash(attributes)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Builds the object from hash
|
158
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
159
|
+
# @return [Object] Returns the model itself
|
160
|
+
def build_from_hash(attributes)
|
161
|
+
return nil unless attributes.is_a?(Hash)
|
162
|
+
self.class.openapi_types.each_pair do |key, type|
|
163
|
+
if type =~ /\AArray<(.*)>/i
|
164
|
+
# check to ensure the input is an array given that the attribute
|
165
|
+
# is documented as an array but the input is not
|
166
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
167
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
168
|
+
end
|
169
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
170
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
171
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
172
|
+
end
|
173
|
+
|
174
|
+
self
|
175
|
+
end
|
176
|
+
|
177
|
+
# Deserializes the data based on type
|
178
|
+
# @param string type Data type
|
179
|
+
# @param string value Value to be deserialized
|
180
|
+
# @return [Object] Deserialized data
|
181
|
+
def _deserialize(type, value)
|
182
|
+
case type.to_sym
|
183
|
+
when :DateTime
|
184
|
+
DateTime.parse(value)
|
185
|
+
when :Date
|
186
|
+
Date.parse(value)
|
187
|
+
when :String
|
188
|
+
value.to_s
|
189
|
+
when :Integer
|
190
|
+
value.to_i
|
191
|
+
when :Float
|
192
|
+
value.to_f
|
193
|
+
when :Boolean
|
194
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
195
|
+
true
|
196
|
+
else
|
197
|
+
false
|
198
|
+
end
|
199
|
+
when :Object
|
200
|
+
# generic object (usually a Hash), return directly
|
201
|
+
value
|
202
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
203
|
+
inner_type = Regexp.last_match[:inner_type]
|
204
|
+
value.map { |v| _deserialize(inner_type, v) }
|
205
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
206
|
+
k_type = Regexp.last_match[:k_type]
|
207
|
+
v_type = Regexp.last_match[:v_type]
|
208
|
+
{}.tap do |hash|
|
209
|
+
value.each do |k, v|
|
210
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
else # model
|
214
|
+
DearInventoryRuby.const_get(type).build_from_hash(value)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns the string representation of the object
|
219
|
+
# @return [String] String presentation of the object
|
220
|
+
def to_s
|
221
|
+
to_hash.to_s
|
222
|
+
end
|
223
|
+
|
224
|
+
# to_body is an alias to to_hash (backward compatibility)
|
225
|
+
# @return [Hash] Returns the object in the form of hash
|
226
|
+
def to_body
|
227
|
+
to_hash
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns the object in the form of hash
|
231
|
+
# @return [Hash] Returns the object in the form of hash
|
232
|
+
def to_hash
|
233
|
+
hash = {}
|
234
|
+
self.class.attribute_map.each_pair do |attr, param|
|
235
|
+
value = self.send(attr)
|
236
|
+
if value.nil?
|
237
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
238
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
239
|
+
end
|
240
|
+
|
241
|
+
hash[param] = _to_hash(value)
|
242
|
+
end
|
243
|
+
hash
|
244
|
+
end
|
245
|
+
|
246
|
+
# Outputs non-array value in the form of hash
|
247
|
+
# For object, use to_hash. Otherwise, just return the value
|
248
|
+
# @param [Object] value Any valid value
|
249
|
+
# @return [Hash] Returns the value in the form of hash
|
250
|
+
def _to_hash(value)
|
251
|
+
if value.is_a?(Array)
|
252
|
+
value.compact.map { |v| _to_hash(v) }
|
253
|
+
elsif value.is_a?(Hash)
|
254
|
+
{}.tap do |hash|
|
255
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
256
|
+
end
|
257
|
+
elsif value.respond_to? :to_hash
|
258
|
+
value.to_hash
|
259
|
+
else
|
260
|
+
value
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|