square_connect 2.0.2.69 → 2.1.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +133 -21
- data/docs/ChargeRequest.md +1 -1
- data/docs/CheckoutApi.md +8 -6
- data/docs/CustomersApi.md +389 -0
- data/docs/Device.md +11 -0
- data/docs/LocationsApi.md +55 -0
- data/docs/TransactionsApi.md +417 -0
- data/docs/V1AdjustInventoryRequest.md +12 -0
- data/docs/V1BankAccount.md +17 -0
- data/docs/V1CashDrawerEvent.md +15 -0
- data/docs/V1CashDrawerShift.md +28 -0
- data/docs/V1Category.md +11 -0
- data/docs/V1CreateRefundRequest.md +14 -0
- data/docs/V1Discount.md +16 -0
- data/docs/V1Employee.md +21 -0
- data/docs/V1EmployeeRole.md +15 -0
- data/docs/V1EmployeesApi.md +915 -0
- data/docs/V1Fee.md +18 -0
- data/docs/V1InventoryEntry.md +11 -0
- data/docs/V1Item.md +23 -0
- data/docs/V1ItemImage.md +11 -0
- data/docs/V1ItemsApi.md +2297 -0
- data/docs/V1LocationApi.md +102 -0
- data/docs/V1LocationsApi.md +102 -0
- data/docs/V1Merchant.md +26 -0
- data/docs/V1MerchantLocationDetails.md +12 -0
- data/docs/V1ModifierList.md +13 -0
- data/docs/V1ModifierOption.md +15 -0
- data/docs/V1Money.md +13 -0
- data/docs/V1Order.md +34 -0
- data/docs/V1OrderHistoryEntry.md +11 -0
- data/docs/V1Page.md +13 -0
- data/docs/V1PageCell.md +15 -0
- data/docs/V1Payment.md +33 -0
- data/docs/V1PaymentDiscount.md +12 -0
- data/docs/V1PaymentItemDetail.md +13 -0
- data/docs/V1PaymentItemization.md +23 -0
- data/docs/V1PaymentModifier.md +12 -0
- data/docs/V1PaymentTax.md +15 -0
- data/docs/V1PhoneNumber.md +13 -0
- data/docs/V1Refund.md +16 -0
- data/docs/V1Settlement.md +15 -0
- data/docs/V1SettlementEntry.md +13 -0
- data/docs/V1Tender.md +22 -0
- data/docs/V1Timecard.md +20 -0
- data/docs/V1TimecardEvent.md +14 -0
- data/docs/V1TransactionsApi.md +650 -0
- data/docs/V1UpdateModifierListRequest.md +11 -0
- data/docs/V1UpdateOrderRequest.md +14 -0
- data/docs/V1Variation.md +20 -0
- data/lib/.DS_Store +0 -0
- data/lib/square_connect.rb +46 -5
- data/lib/square_connect/.DS_Store +0 -0
- data/lib/square_connect/api/checkout_api.rb +4 -9
- data/lib/square_connect/api/{customer_api.rb → customers_api.rb} +150 -61
- data/lib/square_connect/api/{location_api.rb → locations_api.rb} +7 -12
- data/lib/square_connect/api/{transaction_api.rb → transactions_api.rb} +169 -65
- data/lib/square_connect/api/v1_employees_api.rb +974 -0
- data/lib/square_connect/api/v1_items_api.rb +2365 -0
- data/lib/square_connect/api/v1_locations_api.rb +118 -0
- data/lib/square_connect/api/v1_transactions_api.rb +707 -0
- data/lib/square_connect/api_client.rb +1 -1
- data/lib/square_connect/models/charge_request.rb +1 -1
- data/lib/square_connect/models/device.rb +196 -0
- data/lib/square_connect/models/v1_adjust_inventory_request.rb +206 -0
- data/lib/square_connect/models/v1_bank_account.rb +289 -0
- data/lib/square_connect/models/v1_cash_drawer_event.rb +269 -0
- data/lib/square_connect/models/v1_cash_drawer_shift.rb +403 -0
- data/lib/square_connect/models/v1_category.rb +196 -0
- data/lib/square_connect/models/v1_create_refund_request.rb +274 -0
- data/lib/square_connect/models/v1_discount.rb +291 -0
- data/lib/square_connect/models/v1_employee.rb +323 -0
- data/lib/square_connect/models/v1_employee_role.rb +269 -0
- data/lib/square_connect/models/v1_fee.rb +335 -0
- data/lib/square_connect/models/v1_inventory_entry.rb +196 -0
- data/lib/square_connect/models/v1_item.rb +379 -0
- data/lib/square_connect/models/v1_item_image.rb +196 -0
- data/lib/square_connect/models/v1_merchant.rb +372 -0
- data/lib/square_connect/models/v1_merchant_location_details.rb +186 -0
- data/lib/square_connect/models/v1_modifier_list.rb +251 -0
- data/lib/square_connect/models/v1_modifier_option.rb +236 -0
- data/lib/square_connect/models/v1_money.rb +229 -0
- data/lib/square_connect/models/v1_order.rb +463 -0
- data/lib/square_connect/models/v1_order_history_entry.rb +229 -0
- data/lib/square_connect/models/v1_page.rb +218 -0
- data/lib/square_connect/models/v1_page_cell.rb +261 -0
- data/lib/square_connect/models/v1_payment.rb +423 -0
- data/lib/square_connect/models/v1_payment_discount.rb +206 -0
- data/lib/square_connect/models/v1_payment_item_detail.rb +216 -0
- data/lib/square_connect/models/v1_payment_itemization.rb +355 -0
- data/lib/square_connect/models/v1_payment_modifier.rb +206 -0
- data/lib/square_connect/models/v1_payment_tax.rb +271 -0
- data/lib/square_connect/models/v1_phone_number.rb +206 -0
- data/lib/square_connect/models/v1_refund.rb +279 -0
- data/lib/square_connect/models/v1_settlement.rb +271 -0
- data/lib/square_connect/models/v1_settlement_entry.rb +249 -0
- data/lib/square_connect/models/v1_tender.rb +363 -0
- data/lib/square_connect/models/v1_timecard.rb +271 -0
- data/lib/square_connect/models/v1_timecard_event.rb +259 -0
- data/lib/square_connect/models/v1_update_modifier_list_request.rb +229 -0
- data/lib/square_connect/models/v1_update_order_request.rb +264 -0
- data/lib/square_connect/models/v1_variation.rb +331 -0
- data/lib/square_connect/version.rb +1 -1
- data/spec/.DS_Store +0 -0
- data/spec/api/checkout_api_spec.rb +4 -12
- data/spec/api/{customer_api_spec.rb → customers_api_spec.rb} +39 -41
- data/spec/api/{location_api_spec.rb → locations_api_spec.rb} +9 -15
- data/spec/api/{transaction_api_spec.rb → transactions_api_spec.rb} +43 -41
- data/spec/api/v1_employees_api_spec.rb +250 -0
- data/spec/api/v1_items_api_spec.rb +568 -0
- data/spec/api/v1_locations_api_spec.rb +54 -0
- data/spec/api/v1_transactions_api_spec.rb +186 -0
- data/spec/models/address_spec.rb +22 -81
- data/spec/models/capture_transaction_request_spec.rb +3 -6
- data/spec/models/capture_transaction_response_spec.rb +4 -11
- data/spec/models/card_brand_spec.rb +3 -6
- data/spec/models/card_spec.rb +14 -41
- data/spec/models/charge_request_spec.rb +14 -61
- data/spec/models/charge_response_spec.rb +5 -16
- data/spec/models/checkout_spec.rb +12 -51
- data/spec/models/country_spec.rb +3 -6
- data/spec/models/create_checkout_request_spec.rb +10 -41
- data/spec/models/create_checkout_response_spec.rb +5 -16
- data/spec/models/create_customer_card_request_spec.rb +6 -21
- data/spec/models/create_customer_card_response_spec.rb +5 -16
- data/spec/models/create_customer_request_spec.rb +12 -51
- data/spec/models/create_customer_response_spec.rb +5 -16
- data/spec/models/create_order_request_line_item_spec.rb +6 -21
- data/spec/models/create_order_request_order_spec.rb +5 -16
- data/spec/models/create_order_request_spec.rb +5 -16
- data/spec/models/create_refund_request_spec.rb +7 -26
- data/spec/models/create_refund_response_spec.rb +5 -16
- data/spec/models/currency_spec.rb +3 -6
- data/spec/models/customer_group_info_spec.rb +5 -16
- data/spec/models/customer_preferences_spec.rb +4 -11
- data/spec/models/customer_spec.rb +18 -81
- data/spec/models/delete_customer_card_request_spec.rb +3 -6
- data/spec/models/delete_customer_card_response_spec.rb +4 -11
- data/spec/models/delete_customer_request_spec.rb +3 -6
- data/spec/models/delete_customer_response_spec.rb +4 -11
- data/spec/models/device_spec.rb +45 -0
- data/spec/models/error_category_spec.rb +3 -6
- data/spec/models/error_code_spec.rb +3 -6
- data/spec/models/error_spec.rb +15 -26
- data/spec/models/list_customers_request_spec.rb +4 -11
- data/spec/models/list_customers_response_spec.rb +6 -21
- data/spec/models/list_locations_request_spec.rb +3 -6
- data/spec/models/list_locations_response_spec.rb +5 -16
- data/spec/models/list_refunds_request_spec.rb +11 -26
- data/spec/models/list_refunds_response_spec.rb +6 -21
- data/spec/models/list_transactions_request_spec.rb +11 -26
- data/spec/models/list_transactions_response_spec.rb +6 -21
- data/spec/models/location_capability_spec.rb +3 -6
- data/spec/models/location_spec.rb +12 -31
- data/spec/models/money_spec.rb +9 -16
- data/spec/models/order_line_item_spec.rb +8 -31
- data/spec/models/order_spec.rb +8 -31
- data/spec/models/refund_spec.rb +16 -51
- data/spec/models/refund_status_spec.rb +3 -6
- data/spec/models/retrieve_customer_request_spec.rb +3 -6
- data/spec/models/retrieve_customer_response_spec.rb +5 -16
- data/spec/models/retrieve_transaction_request_spec.rb +3 -6
- data/spec/models/retrieve_transaction_response_spec.rb +5 -16
- data/spec/models/sort_order_spec.rb +3 -6
- data/spec/models/tender_card_details_entry_method_spec.rb +3 -6
- data/spec/models/tender_card_details_spec.rb +14 -21
- data/spec/models/tender_card_details_status_spec.rb +3 -6
- data/spec/models/tender_cash_details_spec.rb +5 -16
- data/spec/models/tender_spec.rb +18 -61
- data/spec/models/tender_type_spec.rb +3 -6
- data/spec/models/transaction_product_spec.rb +3 -6
- data/spec/models/transaction_spec.rb +17 -56
- data/spec/models/update_customer_request_spec.rb +12 -51
- data/spec/models/update_customer_response_spec.rb +5 -16
- data/spec/models/v1_adjust_inventory_request_spec.rb +51 -0
- data/spec/models/v1_bank_account_spec.rb +85 -0
- data/spec/models/v1_cash_drawer_event_spec.rb +73 -0
- data/spec/models/v1_cash_drawer_shift_spec.rb +151 -0
- data/spec/models/v1_category_spec.rb +45 -0
- data/spec/models/v1_create_refund_request_spec.rb +67 -0
- data/spec/models/v1_discount_spec.rb +83 -0
- data/spec/models/v1_employee_role_spec.rb +73 -0
- data/spec/models/v1_employee_spec.rb +97 -0
- data/spec/models/v1_fee_spec.rb +103 -0
- data/spec/models/v1_inventory_entry_spec.rb +45 -0
- data/spec/models/v1_item_image_spec.rb +45 -0
- data/spec/models/v1_item_spec.rb +129 -0
- data/spec/models/v1_merchant_location_details_spec.rb +39 -0
- data/spec/models/v1_merchant_spec.rb +131 -0
- data/spec/models/v1_modifier_list_spec.rb +61 -0
- data/spec/models/v1_modifier_option_spec.rb +69 -0
- data/spec/models/v1_money_spec.rb +49 -0
- data/spec/models/v1_order_history_entry_spec.rb +49 -0
- data/spec/models/v1_order_spec.rb +187 -0
- data/spec/models/v1_page_cell_spec.rb +77 -0
- data/spec/models/v1_page_spec.rb +57 -0
- data/spec/models/v1_payment_discount_spec.rb +51 -0
- data/spec/models/v1_payment_item_detail_spec.rb +57 -0
- data/spec/models/v1_payment_itemization_spec.rb +121 -0
- data/spec/models/v1_payment_modifier_spec.rb +51 -0
- data/spec/models/v1_payment_spec.rb +177 -0
- data/spec/models/v1_payment_tax_spec.rb +73 -0
- data/spec/models/v1_phone_number_spec.rb +45 -0
- data/spec/models/v1_refund_spec.rb +79 -0
- data/spec/models/v1_settlement_entry_spec.rb +61 -0
- data/spec/models/v1_settlement_spec.rb +73 -0
- data/spec/models/v1_tender_spec.rb +123 -0
- data/spec/models/v1_timecard_event_spec.rb +67 -0
- data/spec/models/v1_timecard_spec.rb +87 -0
- data/spec/models/v1_update_modifier_list_request_spec.rb +49 -0
- data/spec/models/v1_update_order_request_spec.rb +67 -0
- data/spec/models/v1_variation_spec.rb +107 -0
- data/spec/models/void_transaction_request_spec.rb +3 -6
- data/spec/models/void_transaction_response_spec.rb +4 -11
- data/spec/spec_helper.rb +10 -0
- data/square_connect-2.0.2.gem +0 -0
- data/square_connect-2.1.0.gem +0 -0
- data/square_connect-2.1.0beta.gem +0 -0
- data/square_connect.gemspec +1 -1
- data/travis-ci/accounts.enc +0 -0
- metadata +197 -26
- data/docs/CustomerApi.md +0 -267
- data/docs/CustomerCardApi.md +0 -116
- data/docs/LocationApi.md +0 -56
- data/docs/RefundApi.md +0 -126
- data/docs/TransactionApi.md +0 -285
- data/lib/square_connect/api/customer_card_api.rb +0 -144
- data/lib/square_connect/api/refund_api.rb +0 -159
- data/spec/api/customer_card_api_spec.rb +0 -71
- data/spec/api/refund_api_spec.rb +0 -75
@@ -0,0 +1,229 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
|
12
|
+
module SquareConnect
|
13
|
+
#
|
14
|
+
class V1Money
|
15
|
+
# Amount in the lowest denominated value of this Currency. E.g. in USD these are cents, in JPY they are Yen (which do not have a 'cent' concept).
|
16
|
+
attr_accessor :amount
|
17
|
+
|
18
|
+
#
|
19
|
+
attr_accessor :currency_code
|
20
|
+
|
21
|
+
class EnumAttributeValidator
|
22
|
+
attr_reader :datatype
|
23
|
+
attr_reader :allowable_values
|
24
|
+
|
25
|
+
def initialize(datatype, allowable_values)
|
26
|
+
@allowable_values = allowable_values.map do |value|
|
27
|
+
case datatype.to_s
|
28
|
+
when /Integer/i
|
29
|
+
value.to_i
|
30
|
+
when /Float/i
|
31
|
+
value.to_f
|
32
|
+
else
|
33
|
+
value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid?(value)
|
39
|
+
!value || allowable_values.include?(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
44
|
+
def self.attribute_map
|
45
|
+
{
|
46
|
+
:'amount' => :'amount',
|
47
|
+
:'currency_code' => :'currency_code'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.swagger_types
|
53
|
+
{
|
54
|
+
:'amount' => :'Integer',
|
55
|
+
:'currency_code' => :'String'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initializes the object
|
60
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
61
|
+
def initialize(attributes = {})
|
62
|
+
return unless attributes.is_a?(Hash)
|
63
|
+
|
64
|
+
# convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
66
|
+
|
67
|
+
if attributes.has_key?(:'amount')
|
68
|
+
self.amount = attributes[:'amount']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.has_key?(:'currency_code')
|
72
|
+
self.currency_code = attributes[:'currency_code']
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
78
|
+
# @return Array for valid properies with the reasons
|
79
|
+
def list_invalid_properties
|
80
|
+
invalid_properties = Array.new
|
81
|
+
return invalid_properties
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check to see if the all the properties in the model are valid
|
85
|
+
# @return true if the model is valid
|
86
|
+
def valid?
|
87
|
+
currency_code_validator = EnumAttributeValidator.new('String', ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"])
|
88
|
+
return false unless currency_code_validator.valid?(@currency_code)
|
89
|
+
return true
|
90
|
+
end
|
91
|
+
|
92
|
+
# Custom attribute writer method checking allowed values (enum).
|
93
|
+
# @param [Object] currency_code Object to be assigned
|
94
|
+
def currency_code=(currency_code)
|
95
|
+
validator = EnumAttributeValidator.new('String', ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"])
|
96
|
+
unless validator.valid?(currency_code)
|
97
|
+
fail ArgumentError, "invalid value for 'currency_code', must be one of #{validator.allowable_values}."
|
98
|
+
end
|
99
|
+
@currency_code = currency_code
|
100
|
+
end
|
101
|
+
|
102
|
+
# Checks equality by comparing each attribute.
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def ==(o)
|
105
|
+
return true if self.equal?(o)
|
106
|
+
self.class == o.class &&
|
107
|
+
amount == o.amount &&
|
108
|
+
currency_code == o.currency_code
|
109
|
+
end
|
110
|
+
|
111
|
+
# @see the `==` method
|
112
|
+
# @param [Object] Object to be compared
|
113
|
+
def eql?(o)
|
114
|
+
self == o
|
115
|
+
end
|
116
|
+
|
117
|
+
# Calculates hash code according to all attributes.
|
118
|
+
# @return [Fixnum] Hash code
|
119
|
+
def hash
|
120
|
+
[amount, currency_code].hash
|
121
|
+
end
|
122
|
+
|
123
|
+
# Builds the object from hash
|
124
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
125
|
+
# @return [Object] Returns the model itself
|
126
|
+
def build_from_hash(attributes)
|
127
|
+
return nil unless attributes.is_a?(Hash)
|
128
|
+
self.class.swagger_types.each_pair do |key, type|
|
129
|
+
if type =~ /\AArray<(.*)>/i
|
130
|
+
# check to ensure the input is an array given that the the attribute
|
131
|
+
# is documented as an array but the input is not
|
132
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
133
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
134
|
+
end
|
135
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
136
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
137
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
138
|
+
end
|
139
|
+
|
140
|
+
self
|
141
|
+
end
|
142
|
+
|
143
|
+
# Deserializes the data based on type
|
144
|
+
# @param string type Data type
|
145
|
+
# @param string value Value to be deserialized
|
146
|
+
# @return [Object] Deserialized data
|
147
|
+
def _deserialize(type, value)
|
148
|
+
case type.to_sym
|
149
|
+
when :DateTime
|
150
|
+
DateTime.parse(value)
|
151
|
+
when :Date
|
152
|
+
Date.parse(value)
|
153
|
+
when :String
|
154
|
+
value.to_s
|
155
|
+
when :Integer
|
156
|
+
value.to_i
|
157
|
+
when :Float
|
158
|
+
value.to_f
|
159
|
+
when :BOOLEAN
|
160
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
161
|
+
true
|
162
|
+
else
|
163
|
+
false
|
164
|
+
end
|
165
|
+
when :Object
|
166
|
+
# generic object (usually a Hash), return directly
|
167
|
+
value
|
168
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
169
|
+
inner_type = Regexp.last_match[:inner_type]
|
170
|
+
value.map { |v| _deserialize(inner_type, v) }
|
171
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
172
|
+
k_type = Regexp.last_match[:k_type]
|
173
|
+
v_type = Regexp.last_match[:v_type]
|
174
|
+
{}.tap do |hash|
|
175
|
+
value.each do |k, v|
|
176
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
else # model
|
180
|
+
temp_model = SquareConnect.const_get(type).new
|
181
|
+
temp_model.build_from_hash(value)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the string representation of the object
|
186
|
+
# @return [String] String presentation of the object
|
187
|
+
def to_s
|
188
|
+
to_hash.to_s
|
189
|
+
end
|
190
|
+
|
191
|
+
# to_body is an alias to to_hash (backward compatibility)
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_body
|
194
|
+
to_hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the object in the form of hash
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_hash
|
200
|
+
hash = {}
|
201
|
+
self.class.attribute_map.each_pair do |attr, param|
|
202
|
+
value = self.send(attr)
|
203
|
+
next if value.nil?
|
204
|
+
hash[param] = _to_hash(value)
|
205
|
+
end
|
206
|
+
hash
|
207
|
+
end
|
208
|
+
|
209
|
+
# Outputs non-array value in the form of hash
|
210
|
+
# For object, use to_hash. Otherwise, just return the value
|
211
|
+
# @param [Object] value Any valid value
|
212
|
+
# @return [Hash] Returns the value in the form of hash
|
213
|
+
def _to_hash(value)
|
214
|
+
if value.is_a?(Array)
|
215
|
+
value.compact.map{ |v| _to_hash(v) }
|
216
|
+
elsif value.is_a?(Hash)
|
217
|
+
{}.tap do |hash|
|
218
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
219
|
+
end
|
220
|
+
elsif value.respond_to? :to_hash
|
221
|
+
value.to_hash
|
222
|
+
else
|
223
|
+
value
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
@@ -0,0 +1,463 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
|
12
|
+
module SquareConnect
|
13
|
+
|
14
|
+
class V1Order
|
15
|
+
# Any errors that occurred during the request.
|
16
|
+
attr_accessor :errors
|
17
|
+
|
18
|
+
# The order's unique identifier.
|
19
|
+
attr_accessor :id
|
20
|
+
|
21
|
+
# The email address of the order's buyer.
|
22
|
+
attr_accessor :buyer_email
|
23
|
+
|
24
|
+
# The name of the order's buyer.
|
25
|
+
attr_accessor :recipient_name
|
26
|
+
|
27
|
+
# The phone number to use for the order's delivery.
|
28
|
+
attr_accessor :recipient_phone_number
|
29
|
+
|
30
|
+
# Whether the tax is an ADDITIVE tax or an INCLUSIVE tax.
|
31
|
+
attr_accessor :state
|
32
|
+
|
33
|
+
# The address to ship the order to.
|
34
|
+
attr_accessor :shipping_address
|
35
|
+
|
36
|
+
# The amount of all items purchased in the order, before taxes and shipping.
|
37
|
+
attr_accessor :subtotal_money
|
38
|
+
|
39
|
+
# The shipping cost for the order.
|
40
|
+
attr_accessor :total_shipping_money
|
41
|
+
|
42
|
+
# The total of all taxes applied to the order.
|
43
|
+
attr_accessor :total_tax_money
|
44
|
+
|
45
|
+
# The total cost of the order.
|
46
|
+
attr_accessor :total_price_money
|
47
|
+
|
48
|
+
# The total of all discounts applied to the order.
|
49
|
+
attr_accessor :total_discount_money
|
50
|
+
|
51
|
+
# The time when the order was created, in ISO 8601 format.
|
52
|
+
attr_accessor :created_at
|
53
|
+
|
54
|
+
# The time when the order was last modified, in ISO 8601 format.
|
55
|
+
attr_accessor :updated_at
|
56
|
+
|
57
|
+
# The time when the order expires if no action is taken, in ISO 8601 format.
|
58
|
+
attr_accessor :expires_at
|
59
|
+
|
60
|
+
# The unique identifier of the payment associated with the order.
|
61
|
+
attr_accessor :payment_id
|
62
|
+
|
63
|
+
# A note provided by the buyer when the order was created, if any.
|
64
|
+
attr_accessor :buyer_note
|
65
|
+
|
66
|
+
# A note provided by the merchant when the order's state was set to COMPLETED, if any
|
67
|
+
attr_accessor :completed_note
|
68
|
+
|
69
|
+
# A note provided by the merchant when the order's state was set to REFUNDED, if any.
|
70
|
+
attr_accessor :refunded_note
|
71
|
+
|
72
|
+
# A note provided by the merchant when the order's state was set to CANCELED, if any.
|
73
|
+
attr_accessor :canceled_note
|
74
|
+
|
75
|
+
# The tender used to pay for the order.
|
76
|
+
attr_accessor :tender
|
77
|
+
|
78
|
+
# The history of actions associated with the order.
|
79
|
+
attr_accessor :order_history
|
80
|
+
|
81
|
+
# The promo code provided by the buyer, if any.
|
82
|
+
attr_accessor :promo_code
|
83
|
+
|
84
|
+
# For Bitcoin transactions, the address that the buyer sent Bitcoin to.
|
85
|
+
attr_accessor :btc_receive_address
|
86
|
+
|
87
|
+
# For Bitcoin transactions, the price of the buyer's order in satoshi (100 million satoshi equals 1 BTC).
|
88
|
+
attr_accessor :btc_price_satoshi
|
89
|
+
|
90
|
+
class EnumAttributeValidator
|
91
|
+
attr_reader :datatype
|
92
|
+
attr_reader :allowable_values
|
93
|
+
|
94
|
+
def initialize(datatype, allowable_values)
|
95
|
+
@allowable_values = allowable_values.map do |value|
|
96
|
+
case datatype.to_s
|
97
|
+
when /Integer/i
|
98
|
+
value.to_i
|
99
|
+
when /Float/i
|
100
|
+
value.to_f
|
101
|
+
else
|
102
|
+
value
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def valid?(value)
|
108
|
+
!value || allowable_values.include?(value)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
113
|
+
def self.attribute_map
|
114
|
+
{
|
115
|
+
:'errors' => :'errors',
|
116
|
+
:'id' => :'id',
|
117
|
+
:'buyer_email' => :'buyer_email',
|
118
|
+
:'recipient_name' => :'recipient_name',
|
119
|
+
:'recipient_phone_number' => :'recipient_phone_number',
|
120
|
+
:'state' => :'state',
|
121
|
+
:'shipping_address' => :'shipping_address',
|
122
|
+
:'subtotal_money' => :'subtotal_money',
|
123
|
+
:'total_shipping_money' => :'total_shipping_money',
|
124
|
+
:'total_tax_money' => :'total_tax_money',
|
125
|
+
:'total_price_money' => :'total_price_money',
|
126
|
+
:'total_discount_money' => :'total_discount_money',
|
127
|
+
:'created_at' => :'created_at',
|
128
|
+
:'updated_at' => :'updated_at',
|
129
|
+
:'expires_at' => :'expires_at',
|
130
|
+
:'payment_id' => :'payment_id',
|
131
|
+
:'buyer_note' => :'buyer_note',
|
132
|
+
:'completed_note' => :'completed_note',
|
133
|
+
:'refunded_note' => :'refunded_note',
|
134
|
+
:'canceled_note' => :'canceled_note',
|
135
|
+
:'tender' => :'tender',
|
136
|
+
:'order_history' => :'order_history',
|
137
|
+
:'promo_code' => :'promo_code',
|
138
|
+
:'btc_receive_address' => :'btc_receive_address',
|
139
|
+
:'btc_price_satoshi' => :'btc_price_satoshi'
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
# Attribute type mapping.
|
144
|
+
def self.swagger_types
|
145
|
+
{
|
146
|
+
:'errors' => :'Array<Error>',
|
147
|
+
:'id' => :'String',
|
148
|
+
:'buyer_email' => :'String',
|
149
|
+
:'recipient_name' => :'String',
|
150
|
+
:'recipient_phone_number' => :'String',
|
151
|
+
:'state' => :'String',
|
152
|
+
:'shipping_address' => :'Address',
|
153
|
+
:'subtotal_money' => :'V1Money',
|
154
|
+
:'total_shipping_money' => :'V1Money',
|
155
|
+
:'total_tax_money' => :'V1Money',
|
156
|
+
:'total_price_money' => :'V1Money',
|
157
|
+
:'total_discount_money' => :'V1Money',
|
158
|
+
:'created_at' => :'String',
|
159
|
+
:'updated_at' => :'String',
|
160
|
+
:'expires_at' => :'String',
|
161
|
+
:'payment_id' => :'String',
|
162
|
+
:'buyer_note' => :'String',
|
163
|
+
:'completed_note' => :'String',
|
164
|
+
:'refunded_note' => :'String',
|
165
|
+
:'canceled_note' => :'String',
|
166
|
+
:'tender' => :'V1Tender',
|
167
|
+
:'order_history' => :'Array<V1OrderHistoryEntry>',
|
168
|
+
:'promo_code' => :'String',
|
169
|
+
:'btc_receive_address' => :'String',
|
170
|
+
:'btc_price_satoshi' => :'Float'
|
171
|
+
}
|
172
|
+
end
|
173
|
+
|
174
|
+
# Initializes the object
|
175
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
176
|
+
def initialize(attributes = {})
|
177
|
+
return unless attributes.is_a?(Hash)
|
178
|
+
|
179
|
+
# convert string to symbol for hash key
|
180
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
181
|
+
|
182
|
+
if attributes.has_key?(:'errors')
|
183
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
184
|
+
self.errors = value
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
if attributes.has_key?(:'id')
|
189
|
+
self.id = attributes[:'id']
|
190
|
+
end
|
191
|
+
|
192
|
+
if attributes.has_key?(:'buyer_email')
|
193
|
+
self.buyer_email = attributes[:'buyer_email']
|
194
|
+
end
|
195
|
+
|
196
|
+
if attributes.has_key?(:'recipient_name')
|
197
|
+
self.recipient_name = attributes[:'recipient_name']
|
198
|
+
end
|
199
|
+
|
200
|
+
if attributes.has_key?(:'recipient_phone_number')
|
201
|
+
self.recipient_phone_number = attributes[:'recipient_phone_number']
|
202
|
+
end
|
203
|
+
|
204
|
+
if attributes.has_key?(:'state')
|
205
|
+
self.state = attributes[:'state']
|
206
|
+
end
|
207
|
+
|
208
|
+
if attributes.has_key?(:'shipping_address')
|
209
|
+
self.shipping_address = attributes[:'shipping_address']
|
210
|
+
end
|
211
|
+
|
212
|
+
if attributes.has_key?(:'subtotal_money')
|
213
|
+
self.subtotal_money = attributes[:'subtotal_money']
|
214
|
+
end
|
215
|
+
|
216
|
+
if attributes.has_key?(:'total_shipping_money')
|
217
|
+
self.total_shipping_money = attributes[:'total_shipping_money']
|
218
|
+
end
|
219
|
+
|
220
|
+
if attributes.has_key?(:'total_tax_money')
|
221
|
+
self.total_tax_money = attributes[:'total_tax_money']
|
222
|
+
end
|
223
|
+
|
224
|
+
if attributes.has_key?(:'total_price_money')
|
225
|
+
self.total_price_money = attributes[:'total_price_money']
|
226
|
+
end
|
227
|
+
|
228
|
+
if attributes.has_key?(:'total_discount_money')
|
229
|
+
self.total_discount_money = attributes[:'total_discount_money']
|
230
|
+
end
|
231
|
+
|
232
|
+
if attributes.has_key?(:'created_at')
|
233
|
+
self.created_at = attributes[:'created_at']
|
234
|
+
end
|
235
|
+
|
236
|
+
if attributes.has_key?(:'updated_at')
|
237
|
+
self.updated_at = attributes[:'updated_at']
|
238
|
+
end
|
239
|
+
|
240
|
+
if attributes.has_key?(:'expires_at')
|
241
|
+
self.expires_at = attributes[:'expires_at']
|
242
|
+
end
|
243
|
+
|
244
|
+
if attributes.has_key?(:'payment_id')
|
245
|
+
self.payment_id = attributes[:'payment_id']
|
246
|
+
end
|
247
|
+
|
248
|
+
if attributes.has_key?(:'buyer_note')
|
249
|
+
self.buyer_note = attributes[:'buyer_note']
|
250
|
+
end
|
251
|
+
|
252
|
+
if attributes.has_key?(:'completed_note')
|
253
|
+
self.completed_note = attributes[:'completed_note']
|
254
|
+
end
|
255
|
+
|
256
|
+
if attributes.has_key?(:'refunded_note')
|
257
|
+
self.refunded_note = attributes[:'refunded_note']
|
258
|
+
end
|
259
|
+
|
260
|
+
if attributes.has_key?(:'canceled_note')
|
261
|
+
self.canceled_note = attributes[:'canceled_note']
|
262
|
+
end
|
263
|
+
|
264
|
+
if attributes.has_key?(:'tender')
|
265
|
+
self.tender = attributes[:'tender']
|
266
|
+
end
|
267
|
+
|
268
|
+
if attributes.has_key?(:'order_history')
|
269
|
+
if (value = attributes[:'order_history']).is_a?(Array)
|
270
|
+
self.order_history = value
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
if attributes.has_key?(:'promo_code')
|
275
|
+
self.promo_code = attributes[:'promo_code']
|
276
|
+
end
|
277
|
+
|
278
|
+
if attributes.has_key?(:'btc_receive_address')
|
279
|
+
self.btc_receive_address = attributes[:'btc_receive_address']
|
280
|
+
end
|
281
|
+
|
282
|
+
if attributes.has_key?(:'btc_price_satoshi')
|
283
|
+
self.btc_price_satoshi = attributes[:'btc_price_satoshi']
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
289
|
+
# @return Array for valid properies with the reasons
|
290
|
+
def list_invalid_properties
|
291
|
+
invalid_properties = Array.new
|
292
|
+
return invalid_properties
|
293
|
+
end
|
294
|
+
|
295
|
+
# Check to see if the all the properties in the model are valid
|
296
|
+
# @return true if the model is valid
|
297
|
+
def valid?
|
298
|
+
state_validator = EnumAttributeValidator.new('String', ["PENDING", "OPEN", "COMPLETED", "CANCELED", "REFUNDED", "REJECTED"])
|
299
|
+
return false unless state_validator.valid?(@state)
|
300
|
+
return true
|
301
|
+
end
|
302
|
+
|
303
|
+
# Custom attribute writer method checking allowed values (enum).
|
304
|
+
# @param [Object] state Object to be assigned
|
305
|
+
def state=(state)
|
306
|
+
validator = EnumAttributeValidator.new('String', ["PENDING", "OPEN", "COMPLETED", "CANCELED", "REFUNDED", "REJECTED"])
|
307
|
+
unless validator.valid?(state)
|
308
|
+
fail ArgumentError, "invalid value for 'state', must be one of #{validator.allowable_values}."
|
309
|
+
end
|
310
|
+
@state = state
|
311
|
+
end
|
312
|
+
|
313
|
+
# Checks equality by comparing each attribute.
|
314
|
+
# @param [Object] Object to be compared
|
315
|
+
def ==(o)
|
316
|
+
return true if self.equal?(o)
|
317
|
+
self.class == o.class &&
|
318
|
+
errors == o.errors &&
|
319
|
+
id == o.id &&
|
320
|
+
buyer_email == o.buyer_email &&
|
321
|
+
recipient_name == o.recipient_name &&
|
322
|
+
recipient_phone_number == o.recipient_phone_number &&
|
323
|
+
state == o.state &&
|
324
|
+
shipping_address == o.shipping_address &&
|
325
|
+
subtotal_money == o.subtotal_money &&
|
326
|
+
total_shipping_money == o.total_shipping_money &&
|
327
|
+
total_tax_money == o.total_tax_money &&
|
328
|
+
total_price_money == o.total_price_money &&
|
329
|
+
total_discount_money == o.total_discount_money &&
|
330
|
+
created_at == o.created_at &&
|
331
|
+
updated_at == o.updated_at &&
|
332
|
+
expires_at == o.expires_at &&
|
333
|
+
payment_id == o.payment_id &&
|
334
|
+
buyer_note == o.buyer_note &&
|
335
|
+
completed_note == o.completed_note &&
|
336
|
+
refunded_note == o.refunded_note &&
|
337
|
+
canceled_note == o.canceled_note &&
|
338
|
+
tender == o.tender &&
|
339
|
+
order_history == o.order_history &&
|
340
|
+
promo_code == o.promo_code &&
|
341
|
+
btc_receive_address == o.btc_receive_address &&
|
342
|
+
btc_price_satoshi == o.btc_price_satoshi
|
343
|
+
end
|
344
|
+
|
345
|
+
# @see the `==` method
|
346
|
+
# @param [Object] Object to be compared
|
347
|
+
def eql?(o)
|
348
|
+
self == o
|
349
|
+
end
|
350
|
+
|
351
|
+
# Calculates hash code according to all attributes.
|
352
|
+
# @return [Fixnum] Hash code
|
353
|
+
def hash
|
354
|
+
[errors, id, buyer_email, recipient_name, recipient_phone_number, state, shipping_address, subtotal_money, total_shipping_money, total_tax_money, total_price_money, total_discount_money, created_at, updated_at, expires_at, payment_id, buyer_note, completed_note, refunded_note, canceled_note, tender, order_history, promo_code, btc_receive_address, btc_price_satoshi].hash
|
355
|
+
end
|
356
|
+
|
357
|
+
# Builds the object from hash
|
358
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
359
|
+
# @return [Object] Returns the model itself
|
360
|
+
def build_from_hash(attributes)
|
361
|
+
return nil unless attributes.is_a?(Hash)
|
362
|
+
self.class.swagger_types.each_pair do |key, type|
|
363
|
+
if type =~ /\AArray<(.*)>/i
|
364
|
+
# check to ensure the input is an array given that the the attribute
|
365
|
+
# is documented as an array but the input is not
|
366
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
367
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
368
|
+
end
|
369
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
370
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
371
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
372
|
+
end
|
373
|
+
|
374
|
+
self
|
375
|
+
end
|
376
|
+
|
377
|
+
# Deserializes the data based on type
|
378
|
+
# @param string type Data type
|
379
|
+
# @param string value Value to be deserialized
|
380
|
+
# @return [Object] Deserialized data
|
381
|
+
def _deserialize(type, value)
|
382
|
+
case type.to_sym
|
383
|
+
when :DateTime
|
384
|
+
DateTime.parse(value)
|
385
|
+
when :Date
|
386
|
+
Date.parse(value)
|
387
|
+
when :String
|
388
|
+
value.to_s
|
389
|
+
when :Integer
|
390
|
+
value.to_i
|
391
|
+
when :Float
|
392
|
+
value.to_f
|
393
|
+
when :BOOLEAN
|
394
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
395
|
+
true
|
396
|
+
else
|
397
|
+
false
|
398
|
+
end
|
399
|
+
when :Object
|
400
|
+
# generic object (usually a Hash), return directly
|
401
|
+
value
|
402
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
403
|
+
inner_type = Regexp.last_match[:inner_type]
|
404
|
+
value.map { |v| _deserialize(inner_type, v) }
|
405
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
406
|
+
k_type = Regexp.last_match[:k_type]
|
407
|
+
v_type = Regexp.last_match[:v_type]
|
408
|
+
{}.tap do |hash|
|
409
|
+
value.each do |k, v|
|
410
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
411
|
+
end
|
412
|
+
end
|
413
|
+
else # model
|
414
|
+
temp_model = SquareConnect.const_get(type).new
|
415
|
+
temp_model.build_from_hash(value)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
# Returns the string representation of the object
|
420
|
+
# @return [String] String presentation of the object
|
421
|
+
def to_s
|
422
|
+
to_hash.to_s
|
423
|
+
end
|
424
|
+
|
425
|
+
# to_body is an alias to to_hash (backward compatibility)
|
426
|
+
# @return [Hash] Returns the object in the form of hash
|
427
|
+
def to_body
|
428
|
+
to_hash
|
429
|
+
end
|
430
|
+
|
431
|
+
# Returns the object in the form of hash
|
432
|
+
# @return [Hash] Returns the object in the form of hash
|
433
|
+
def to_hash
|
434
|
+
hash = {}
|
435
|
+
self.class.attribute_map.each_pair do |attr, param|
|
436
|
+
value = self.send(attr)
|
437
|
+
next if value.nil?
|
438
|
+
hash[param] = _to_hash(value)
|
439
|
+
end
|
440
|
+
hash
|
441
|
+
end
|
442
|
+
|
443
|
+
# Outputs non-array value in the form of hash
|
444
|
+
# For object, use to_hash. Otherwise, just return the value
|
445
|
+
# @param [Object] value Any valid value
|
446
|
+
# @return [Hash] Returns the value in the form of hash
|
447
|
+
def _to_hash(value)
|
448
|
+
if value.is_a?(Array)
|
449
|
+
value.compact.map{ |v| _to_hash(v) }
|
450
|
+
elsif value.is_a?(Hash)
|
451
|
+
{}.tap do |hash|
|
452
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
453
|
+
end
|
454
|
+
elsif value.respond_to? :to_hash
|
455
|
+
value.to_hash
|
456
|
+
else
|
457
|
+
value
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
end
|
462
|
+
|
463
|
+
end
|