taxamo 1.0.6.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/taxamo.rb +52 -10
- data/lib/taxamo/models/calculatesimpletaxout.rb +14 -2
- data/lib/taxamo/models/calculatetaxout.rb +14 -2
- data/lib/taxamo/models/confirmtransactionout.rb +14 -2
- data/lib/taxamo/models/country.rb +6 -1
- data/lib/taxamo/models/countryschema.rb +6 -1
- data/lib/taxamo/models/createtransactionout.rb +14 -2
- data/lib/taxamo/models/gettransactionout.rb +14 -2
- data/lib/taxamo/models/gettransactionsstatsbycountryout.rb +63 -0
- data/lib/taxamo/models/inputtransaction.rb +16 -1
- data/lib/taxamo/models/inputtransactionline.rb +6 -1
- data/lib/taxamo/models/inputtransactionupdate.rb +16 -1
- data/lib/taxamo/models/report.rb +28 -18
- data/lib/taxamo/models/storagerequiredfields.rb +62 -0
- data/lib/taxamo/models/summary.rb +11 -1
- data/lib/taxamo/models/taxdataschema.rb +62 -0
- data/lib/taxamo/models/taxrequiredfields.rb +62 -0
- data/lib/taxamo/models/transaction.rb +26 -1
- data/lib/taxamo/models/transactionlines.rb +6 -1
- data/lib/taxamo/models/transactions.rb +26 -1
- data/lib/taxamo/models/unconfirmtransactionout.rb +14 -2
- data/lib/taxamo/models/updatetransactionout.rb +14 -2
- data/lib/taxamo/models/ustaxexemptioncertificatedetailsschema.rb +138 -0
- data/lib/taxamo/models/ustaxexemptioncertificateschema.rb +67 -0
- data/lib/taxamo/models/ustaxexemptstate.rb +72 -0
- data/lib/taxamo/models/ustaxid.rb +72 -0
- data/lib/taxamo/version.rb +1 -1
- data/test/taxamo/tax_test.rb +14 -9
- data/test/taxamo/transactions_api_test.rb +37 -28
- metadata +10 -2
@@ -11,7 +11,7 @@
|
|
11
11
|
# limitations under the License.
|
12
12
|
|
13
13
|
class TransactionLines
|
14
|
-
attr_accessor :product_type, :deducted_tax_amount, :supply_date, :id, :unit_price, :unit_of_measure, :quantity, :custom_fields, :line_key, :tax_name, :product_code, :amount, :custom_id, :informative, :tax_amount, :tax_rate, :additional_currencies, :total_amount, :refunded_tax_amount, :description, :refunded_total_amount
|
14
|
+
attr_accessor :product_type, :deducted_tax_amount, :supply_date, :id, :unit_price, :unit_of_measure, :quantity, :custom_fields, :line_key, :tax_name, :product_code, :amount, :custom_id, :informative, :tax_amount, :tax_rate, :additional_currencies, :total_amount, :product_tax_code, :refunded_tax_amount, :description, :refunded_total_amount
|
15
15
|
|
16
16
|
# :internal => :external
|
17
17
|
def self.attribute_map
|
@@ -34,6 +34,7 @@ class TransactionLines
|
|
34
34
|
:tax_rate => :tax_rate,
|
35
35
|
:additional_currencies => :additional_currencies,
|
36
36
|
:total_amount => :total_amount,
|
37
|
+
:product_tax_code => :product_tax_code,
|
37
38
|
:refunded_tax_amount => :refunded_tax_amount,
|
38
39
|
:description => :description,
|
39
40
|
:refunded_total_amount => :refunded_total_amount
|
@@ -116,6 +117,10 @@ class TransactionLines
|
|
116
117
|
if attributes["total_amount"]
|
117
118
|
@total_amount = attributes["total_amount"]
|
118
119
|
|
120
|
+
end
|
121
|
+
if attributes["product_tax_code"]
|
122
|
+
@product_tax_code = attributes["product_tax_code"]
|
123
|
+
|
119
124
|
end
|
120
125
|
if attributes["refunded_tax_amount"]
|
121
126
|
@refunded_tax_amount = attributes["refunded_tax_amount"]
|
@@ -11,12 +11,13 @@
|
|
11
11
|
# limitations under the License.
|
12
12
|
|
13
13
|
class Transactions
|
14
|
-
attr_accessor :confirm_timestamp, :deducted_tax_amount, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :create_timestamp, :currency_code, :supply_date, :invoice_image_url, :key, :invoice_address, :buyer_tax_number_valid, :verification_token, :tax_supported, :transaction_lines, :buyer_tax_number, :status, :custom_fields, :force_country_code, :countries, :invoice_number, :order_date, :source, :amount, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :tax_amount, :additional_currencies, :invoice_place, :total_amount, :tax_entity_name, :evidence, :refunded_tax_amount, :manual, :tax_timezone, :description, :test, :tax_deducted, :tax_country_code, :refunded_total_amount
|
14
|
+
attr_accessor :confirm_timestamp, :fully_informative, :deducted_tax_amount, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :create_timestamp, :currency_code, :supply_date, :invoice_image_url, :key, :invoice_address, :buyer_tax_number_valid, :verification_token, :tax_supported, :tax_data, :transaction_lines, :buyer_tax_number, :external_key, :status, :custom_fields, :force_country_code, :countries, :invoice_number, :order_date, :customer_id, :kind, :source, :amount, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :tax_amount, :additional_currencies, :invoice_place, :total_amount, :tax_entity_name, :evidence, :refunded_tax_amount, :manual, :tax_timezone, :description, :test, :tax_deducted, :tax_country_code, :refunded_total_amount
|
15
15
|
|
16
16
|
# :internal => :external
|
17
17
|
def self.attribute_map
|
18
18
|
{
|
19
19
|
:confirm_timestamp => :confirm_timestamp,
|
20
|
+
:fully_informative => :fully_informative,
|
20
21
|
:deducted_tax_amount => :deducted_tax_amount,
|
21
22
|
:buyer_credit_card_prefix => :buyer_credit_card_prefix,
|
22
23
|
:custom_data => :custom_data,
|
@@ -31,14 +32,18 @@ class Transactions
|
|
31
32
|
:buyer_tax_number_valid => :buyer_tax_number_valid,
|
32
33
|
:verification_token => :verification_token,
|
33
34
|
:tax_supported => :tax_supported,
|
35
|
+
:tax_data => :tax_data,
|
34
36
|
:transaction_lines => :transaction_lines,
|
35
37
|
:buyer_tax_number => :buyer_tax_number,
|
38
|
+
:external_key => :external_key,
|
36
39
|
:status => :status,
|
37
40
|
:custom_fields => :custom_fields,
|
38
41
|
:force_country_code => :force_country_code,
|
39
42
|
:countries => :countries,
|
40
43
|
:invoice_number => :invoice_number,
|
41
44
|
:order_date => :order_date,
|
45
|
+
:customer_id => :customer_id,
|
46
|
+
:kind => :kind,
|
42
47
|
:source => :source,
|
43
48
|
:amount => :amount,
|
44
49
|
:buyer_ip => :buyer_ip,
|
@@ -70,6 +75,10 @@ class Transactions
|
|
70
75
|
if attributes["confirm_timestamp"]
|
71
76
|
@confirm_timestamp = attributes["confirm_timestamp"]
|
72
77
|
|
78
|
+
end
|
79
|
+
if attributes["fully_informative"]
|
80
|
+
@fully_informative = attributes["fully_informative"]
|
81
|
+
|
73
82
|
end
|
74
83
|
if attributes["deducted_tax_amount"]
|
75
84
|
@deducted_tax_amount = attributes["deducted_tax_amount"]
|
@@ -126,6 +135,10 @@ class Transactions
|
|
126
135
|
if attributes["tax_supported"]
|
127
136
|
@tax_supported = attributes["tax_supported"]
|
128
137
|
|
138
|
+
end
|
139
|
+
if attributes["tax_data"]
|
140
|
+
@tax_data = TaxDataSchema.new(attributes["tax_data"])
|
141
|
+
|
129
142
|
end
|
130
143
|
if attributes["transaction_lines"]
|
131
144
|
if (value = attributes["transaction_lines"]).is_a?(Array)
|
@@ -135,6 +148,10 @@ class Transactions
|
|
135
148
|
if attributes["buyer_tax_number"]
|
136
149
|
@buyer_tax_number = attributes["buyer_tax_number"]
|
137
150
|
|
151
|
+
end
|
152
|
+
if attributes["external_key"]
|
153
|
+
@external_key = attributes["external_key"]
|
154
|
+
|
138
155
|
end
|
139
156
|
if attributes["status"]
|
140
157
|
@status = attributes["status"]
|
@@ -160,6 +177,14 @@ class Transactions
|
|
160
177
|
if attributes["order_date"]
|
161
178
|
@order_date = attributes["order_date"]
|
162
179
|
|
180
|
+
end
|
181
|
+
if attributes["customer_id"]
|
182
|
+
@customer_id = attributes["customer_id"]
|
183
|
+
|
184
|
+
end
|
185
|
+
if attributes["kind"]
|
186
|
+
@kind = attributes["kind"]
|
187
|
+
|
163
188
|
end
|
164
189
|
if attributes["source"]
|
165
190
|
@source = attributes["source"]
|
@@ -11,12 +11,14 @@
|
|
11
11
|
# limitations under the License.
|
12
12
|
|
13
13
|
class UnconfirmTransactionOut
|
14
|
-
attr_accessor :transaction
|
14
|
+
attr_accessor :transaction, :tax_required_fields, :storage_required_fields
|
15
15
|
|
16
16
|
# :internal => :external
|
17
17
|
def self.attribute_map
|
18
18
|
{
|
19
|
-
:transaction => :transaction
|
19
|
+
:transaction => :transaction,
|
20
|
+
:tax_required_fields => :tax_required_fields,
|
21
|
+
:storage_required_fields => :storage_required_fields
|
20
22
|
|
21
23
|
}
|
22
24
|
end
|
@@ -28,6 +30,16 @@ class UnconfirmTransactionOut
|
|
28
30
|
@transaction = Transaction.new(attributes["transaction"])
|
29
31
|
|
30
32
|
end
|
33
|
+
if attributes["tax_required_fields"]
|
34
|
+
if (value = attributes["tax_required_fields"]).is_a?(Array)
|
35
|
+
@tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
if attributes["storage_required_fields"]
|
39
|
+
if (value = attributes["storage_required_fields"]).is_a?(Array)
|
40
|
+
@storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
|
41
|
+
end
|
42
|
+
end
|
31
43
|
|
32
44
|
|
33
45
|
end
|
@@ -11,12 +11,14 @@
|
|
11
11
|
# limitations under the License.
|
12
12
|
|
13
13
|
class UpdateTransactionOut
|
14
|
-
attr_accessor :transaction
|
14
|
+
attr_accessor :transaction, :tax_required_fields, :storage_required_fields
|
15
15
|
|
16
16
|
# :internal => :external
|
17
17
|
def self.attribute_map
|
18
18
|
{
|
19
|
-
:transaction => :transaction
|
19
|
+
:transaction => :transaction,
|
20
|
+
:tax_required_fields => :tax_required_fields,
|
21
|
+
:storage_required_fields => :storage_required_fields
|
20
22
|
|
21
23
|
}
|
22
24
|
end
|
@@ -28,6 +30,16 @@ class UpdateTransactionOut
|
|
28
30
|
@transaction = Transaction.new(attributes["transaction"])
|
29
31
|
|
30
32
|
end
|
33
|
+
if attributes["tax_required_fields"]
|
34
|
+
if (value = attributes["tax_required_fields"]).is_a?(Array)
|
35
|
+
@tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
if attributes["storage_required_fields"]
|
39
|
+
if (value = attributes["storage_required_fields"]).is_a?(Array)
|
40
|
+
@storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
|
41
|
+
end
|
42
|
+
end
|
31
43
|
|
32
44
|
|
33
45
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# Copyright 2014-2015 Taxamo, Ltd.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
class UsTaxExemptionCertificateDetailsSchema
|
14
|
+
attr_accessor :single_purchase_order_identifier, :purchaser_business_type, :purchaser_exemption_reason_value, :purchaser_state, :purchaser_zip, :purchaser_city, :purchaser_last_name, :purchaser_exemption_reason, :single_purchase, :purchaser_tax_id, :purchaser_address2, :purchaser_address1, :purchaser_business_type_other_value, :purchaser_first_name, :exempt_states, :purchaser_title
|
15
|
+
|
16
|
+
# :internal => :external
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:single_purchase_order_identifier => :single_purchase_order_identifier,
|
20
|
+
:purchaser_business_type => :purchaser_business_type,
|
21
|
+
:purchaser_exemption_reason_value => :purchaser_exemption_reason_value,
|
22
|
+
:purchaser_state => :purchaser_state,
|
23
|
+
:purchaser_zip => :purchaser_zip,
|
24
|
+
:purchaser_city => :purchaser_city,
|
25
|
+
:purchaser_last_name => :purchaser_last_name,
|
26
|
+
:purchaser_exemption_reason => :purchaser_exemption_reason,
|
27
|
+
:single_purchase => :single_purchase,
|
28
|
+
:purchaser_tax_id => :purchaser_tax_id,
|
29
|
+
:purchaser_address2 => :purchaser_address2,
|
30
|
+
:purchaser_address1 => :purchaser_address1,
|
31
|
+
:purchaser_business_type_other_value => :purchaser_business_type_other_value,
|
32
|
+
:purchaser_first_name => :purchaser_first_name,
|
33
|
+
:exempt_states => :exempt_states,
|
34
|
+
:purchaser_title => :purchaser_title
|
35
|
+
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return if attributes.empty?
|
41
|
+
# Morph attribute keys into undescored rubyish style
|
42
|
+
if attributes["single_purchase_order_identifier"]
|
43
|
+
@single_purchase_order_identifier = attributes["single_purchase_order_identifier"]
|
44
|
+
|
45
|
+
end
|
46
|
+
if attributes["purchaser_business_type"]
|
47
|
+
@purchaser_business_type = attributes["purchaser_business_type"]
|
48
|
+
|
49
|
+
end
|
50
|
+
if attributes["purchaser_exemption_reason_value"]
|
51
|
+
@purchaser_exemption_reason_value = attributes["purchaser_exemption_reason_value"]
|
52
|
+
|
53
|
+
end
|
54
|
+
if attributes["purchaser_state"]
|
55
|
+
@purchaser_state = attributes["purchaser_state"]
|
56
|
+
|
57
|
+
end
|
58
|
+
if attributes["purchaser_zip"]
|
59
|
+
@purchaser_zip = attributes["purchaser_zip"]
|
60
|
+
|
61
|
+
end
|
62
|
+
if attributes["purchaser_city"]
|
63
|
+
@purchaser_city = attributes["purchaser_city"]
|
64
|
+
|
65
|
+
end
|
66
|
+
if attributes["purchaser_last_name"]
|
67
|
+
@purchaser_last_name = attributes["purchaser_last_name"]
|
68
|
+
|
69
|
+
end
|
70
|
+
if attributes["purchaser_exemption_reason"]
|
71
|
+
@purchaser_exemption_reason = attributes["purchaser_exemption_reason"]
|
72
|
+
|
73
|
+
end
|
74
|
+
if attributes["single_purchase"]
|
75
|
+
@single_purchase = attributes["single_purchase"]
|
76
|
+
|
77
|
+
end
|
78
|
+
if attributes["purchaser_tax_id"]
|
79
|
+
@purchaser_tax_id = UsTaxId.new(attributes["purchaser_tax_id"])
|
80
|
+
|
81
|
+
end
|
82
|
+
if attributes["purchaser_address2"]
|
83
|
+
@purchaser_address2 = attributes["purchaser_address2"]
|
84
|
+
|
85
|
+
end
|
86
|
+
if attributes["purchaser_address1"]
|
87
|
+
@purchaser_address1 = attributes["purchaser_address1"]
|
88
|
+
|
89
|
+
end
|
90
|
+
if attributes["purchaser_business_type_other_value"]
|
91
|
+
@purchaser_business_type_other_value = attributes["purchaser_business_type_other_value"]
|
92
|
+
|
93
|
+
end
|
94
|
+
if attributes["purchaser_first_name"]
|
95
|
+
@purchaser_first_name = attributes["purchaser_first_name"]
|
96
|
+
|
97
|
+
end
|
98
|
+
if attributes["exempt_states"]
|
99
|
+
if (value = attributes["exempt_states"]).is_a?(Array)
|
100
|
+
@exempt_states = value.map{ |v| UsTaxExemptState.new(v) }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
if attributes["purchaser_title"]
|
104
|
+
@purchaser_title = attributes["purchaser_title"]
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_body
|
112
|
+
body = {}
|
113
|
+
self.class.attribute_map.each_pair do |key, value|
|
114
|
+
v = self.send(key)
|
115
|
+
unless v.nil?
|
116
|
+
if v.is_a?(Array)
|
117
|
+
array = Array.new
|
118
|
+
v.each do |item|
|
119
|
+
if item.respond_to?("to_body".to_sym)
|
120
|
+
array.push item.to_body
|
121
|
+
else
|
122
|
+
array.push item
|
123
|
+
end
|
124
|
+
end
|
125
|
+
body[value] = array
|
126
|
+
else
|
127
|
+
if v.respond_to?("to_body".to_sym)
|
128
|
+
body[value] = v.to_body
|
129
|
+
else
|
130
|
+
body[value] = v
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
body
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Copyright 2014-2015 Taxamo, Ltd.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
class UsTaxExemptionCertificateSchema
|
14
|
+
attr_accessor :certificate_id, :detail
|
15
|
+
|
16
|
+
# :internal => :external
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:certificate_id => :certificate_id,
|
20
|
+
:detail => :detail
|
21
|
+
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
return if attributes.empty?
|
27
|
+
# Morph attribute keys into undescored rubyish style
|
28
|
+
if attributes["certificate_id"]
|
29
|
+
@certificate_id = attributes["certificate_id"]
|
30
|
+
|
31
|
+
end
|
32
|
+
if attributes["detail"]
|
33
|
+
@detail = UsTaxExemptionCertificateDetailsSchema.new(attributes["detail"])
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_body
|
41
|
+
body = {}
|
42
|
+
self.class.attribute_map.each_pair do |key, value|
|
43
|
+
v = self.send(key)
|
44
|
+
unless v.nil?
|
45
|
+
if v.is_a?(Array)
|
46
|
+
array = Array.new
|
47
|
+
v.each do |item|
|
48
|
+
if item.respond_to?("to_body".to_sym)
|
49
|
+
array.push item.to_body
|
50
|
+
else
|
51
|
+
array.push item
|
52
|
+
end
|
53
|
+
end
|
54
|
+
body[value] = array
|
55
|
+
else
|
56
|
+
if v.respond_to?("to_body".to_sym)
|
57
|
+
body[value] = v.to_body
|
58
|
+
else
|
59
|
+
body[value] = v
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
body
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Copyright 2014-2015 Taxamo, Ltd.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
class UsTaxExemptState
|
14
|
+
attr_accessor :state_abbr, :reason_for_exemption, :identifier_for_exemption_reason
|
15
|
+
|
16
|
+
# :internal => :external
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:state_abbr => :state_abbr,
|
20
|
+
:reason_for_exemption => :reason_for_exemption,
|
21
|
+
:identifier_for_exemption_reason => :identifier_for_exemption_reason
|
22
|
+
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(attributes = {})
|
27
|
+
return if attributes.empty?
|
28
|
+
# Morph attribute keys into undescored rubyish style
|
29
|
+
if attributes["state_abbr"]
|
30
|
+
@state_abbr = attributes["state_abbr"]
|
31
|
+
|
32
|
+
end
|
33
|
+
if attributes["reason_for_exemption"]
|
34
|
+
@reason_for_exemption = attributes["reason_for_exemption"]
|
35
|
+
|
36
|
+
end
|
37
|
+
if attributes["identifier_for_exemption_reason"]
|
38
|
+
@identifier_for_exemption_reason = attributes["identifier_for_exemption_reason"]
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_body
|
46
|
+
body = {}
|
47
|
+
self.class.attribute_map.each_pair do |key, value|
|
48
|
+
v = self.send(key)
|
49
|
+
unless v.nil?
|
50
|
+
if v.is_a?(Array)
|
51
|
+
array = Array.new
|
52
|
+
v.each do |item|
|
53
|
+
if item.respond_to?("to_body".to_sym)
|
54
|
+
array.push item.to_body
|
55
|
+
else
|
56
|
+
array.push item
|
57
|
+
end
|
58
|
+
end
|
59
|
+
body[value] = array
|
60
|
+
else
|
61
|
+
if v.respond_to?("to_body".to_sym)
|
62
|
+
body[value] = v.to_body
|
63
|
+
else
|
64
|
+
body[value] = v
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
body
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|