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,269 @@
|
|
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 V1EmployeeRole
|
15
|
+
# The role's unique ID, Can only be set by Square.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The role's merchant-defined name.
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# The role's permissions.
|
22
|
+
attr_accessor :permissions
|
23
|
+
|
24
|
+
# If true, employees with this role have all permissions, regardless of the values indicated in permissions.
|
25
|
+
attr_accessor :is_owner
|
26
|
+
|
27
|
+
# The time when the employee entity was created, in ISO 8601 format. Is set by Square when the Role is created.
|
28
|
+
attr_accessor :created_at
|
29
|
+
|
30
|
+
# The time when the employee entity was most recently updated, in ISO 8601 format. Is set by Square when the Role updated.
|
31
|
+
attr_accessor :updated_at
|
32
|
+
|
33
|
+
class EnumAttributeValidator
|
34
|
+
attr_reader :datatype
|
35
|
+
attr_reader :allowable_values
|
36
|
+
|
37
|
+
def initialize(datatype, allowable_values)
|
38
|
+
@allowable_values = allowable_values.map do |value|
|
39
|
+
case datatype.to_s
|
40
|
+
when /Integer/i
|
41
|
+
value.to_i
|
42
|
+
when /Float/i
|
43
|
+
value.to_f
|
44
|
+
else
|
45
|
+
value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def valid?(value)
|
51
|
+
!value || allowable_values.include?(value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
56
|
+
def self.attribute_map
|
57
|
+
{
|
58
|
+
:'id' => :'id',
|
59
|
+
:'name' => :'name',
|
60
|
+
:'permissions' => :'permissions',
|
61
|
+
:'is_owner' => :'is_owner',
|
62
|
+
:'created_at' => :'created_at',
|
63
|
+
:'updated_at' => :'updated_at'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute type mapping.
|
68
|
+
def self.swagger_types
|
69
|
+
{
|
70
|
+
:'id' => :'String',
|
71
|
+
:'name' => :'String',
|
72
|
+
:'permissions' => :'Array<String>',
|
73
|
+
:'is_owner' => :'BOOLEAN',
|
74
|
+
:'created_at' => :'String',
|
75
|
+
:'updated_at' => :'String'
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
# Initializes the object
|
80
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
81
|
+
def initialize(attributes = {})
|
82
|
+
return unless attributes.is_a?(Hash)
|
83
|
+
|
84
|
+
# convert string to symbol for hash key
|
85
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
86
|
+
|
87
|
+
if attributes.has_key?(:'id')
|
88
|
+
self.id = attributes[:'id']
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.has_key?(:'name')
|
92
|
+
self.name = attributes[:'name']
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.has_key?(:'permissions')
|
96
|
+
if (value = attributes[:'permissions']).is_a?(Array)
|
97
|
+
self.permissions = value
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.has_key?(:'is_owner')
|
102
|
+
self.is_owner = attributes[:'is_owner']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.has_key?(:'created_at')
|
106
|
+
self.created_at = attributes[:'created_at']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.has_key?(:'updated_at')
|
110
|
+
self.updated_at = attributes[:'updated_at']
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
116
|
+
# @return Array for valid properies with the reasons
|
117
|
+
def list_invalid_properties
|
118
|
+
invalid_properties = Array.new
|
119
|
+
if @name.nil?
|
120
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
121
|
+
end
|
122
|
+
|
123
|
+
if @permissions.nil?
|
124
|
+
invalid_properties.push("invalid value for 'permissions', permissions cannot be nil.")
|
125
|
+
end
|
126
|
+
|
127
|
+
return invalid_properties
|
128
|
+
end
|
129
|
+
|
130
|
+
# Check to see if the all the properties in the model are valid
|
131
|
+
# @return true if the model is valid
|
132
|
+
def valid?
|
133
|
+
return false if @name.nil?
|
134
|
+
return false if @permissions.nil?
|
135
|
+
return true
|
136
|
+
end
|
137
|
+
|
138
|
+
# Checks equality by comparing each attribute.
|
139
|
+
# @param [Object] Object to be compared
|
140
|
+
def ==(o)
|
141
|
+
return true if self.equal?(o)
|
142
|
+
self.class == o.class &&
|
143
|
+
id == o.id &&
|
144
|
+
name == o.name &&
|
145
|
+
permissions == o.permissions &&
|
146
|
+
is_owner == o.is_owner &&
|
147
|
+
created_at == o.created_at &&
|
148
|
+
updated_at == o.updated_at
|
149
|
+
end
|
150
|
+
|
151
|
+
# @see the `==` method
|
152
|
+
# @param [Object] Object to be compared
|
153
|
+
def eql?(o)
|
154
|
+
self == o
|
155
|
+
end
|
156
|
+
|
157
|
+
# Calculates hash code according to all attributes.
|
158
|
+
# @return [Fixnum] Hash code
|
159
|
+
def hash
|
160
|
+
[id, name, permissions, is_owner, created_at, updated_at].hash
|
161
|
+
end
|
162
|
+
|
163
|
+
# Builds the object from hash
|
164
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
165
|
+
# @return [Object] Returns the model itself
|
166
|
+
def build_from_hash(attributes)
|
167
|
+
return nil unless attributes.is_a?(Hash)
|
168
|
+
self.class.swagger_types.each_pair do |key, type|
|
169
|
+
if type =~ /\AArray<(.*)>/i
|
170
|
+
# check to ensure the input is an array given that the the attribute
|
171
|
+
# is documented as an array but the input is not
|
172
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
173
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
174
|
+
end
|
175
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
176
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
177
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
178
|
+
end
|
179
|
+
|
180
|
+
self
|
181
|
+
end
|
182
|
+
|
183
|
+
# Deserializes the data based on type
|
184
|
+
# @param string type Data type
|
185
|
+
# @param string value Value to be deserialized
|
186
|
+
# @return [Object] Deserialized data
|
187
|
+
def _deserialize(type, value)
|
188
|
+
case type.to_sym
|
189
|
+
when :DateTime
|
190
|
+
DateTime.parse(value)
|
191
|
+
when :Date
|
192
|
+
Date.parse(value)
|
193
|
+
when :String
|
194
|
+
value.to_s
|
195
|
+
when :Integer
|
196
|
+
value.to_i
|
197
|
+
when :Float
|
198
|
+
value.to_f
|
199
|
+
when :BOOLEAN
|
200
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
201
|
+
true
|
202
|
+
else
|
203
|
+
false
|
204
|
+
end
|
205
|
+
when :Object
|
206
|
+
# generic object (usually a Hash), return directly
|
207
|
+
value
|
208
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
209
|
+
inner_type = Regexp.last_match[:inner_type]
|
210
|
+
value.map { |v| _deserialize(inner_type, v) }
|
211
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
212
|
+
k_type = Regexp.last_match[:k_type]
|
213
|
+
v_type = Regexp.last_match[:v_type]
|
214
|
+
{}.tap do |hash|
|
215
|
+
value.each do |k, v|
|
216
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
else # model
|
220
|
+
temp_model = SquareConnect.const_get(type).new
|
221
|
+
temp_model.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
|
+
next if value.nil?
|
244
|
+
hash[param] = _to_hash(value)
|
245
|
+
end
|
246
|
+
hash
|
247
|
+
end
|
248
|
+
|
249
|
+
# Outputs non-array value in the form of hash
|
250
|
+
# For object, use to_hash. Otherwise, just return the value
|
251
|
+
# @param [Object] value Any valid value
|
252
|
+
# @return [Hash] Returns the value in the form of hash
|
253
|
+
def _to_hash(value)
|
254
|
+
if value.is_a?(Array)
|
255
|
+
value.compact.map{ |v| _to_hash(v) }
|
256
|
+
elsif value.is_a?(Hash)
|
257
|
+
{}.tap do |hash|
|
258
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
259
|
+
end
|
260
|
+
elsif value.respond_to? :to_hash
|
261
|
+
value.to_hash
|
262
|
+
else
|
263
|
+
value
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
@@ -0,0 +1,335 @@
|
|
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 V1Fee
|
15
|
+
# The fee's unique ID.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The fee's name.
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# The rate of the fee, as a string representation of a decimal number. A value of 0.07 corresponds to a rate of 7%.
|
22
|
+
attr_accessor :rate
|
23
|
+
|
24
|
+
# Forthcoming
|
25
|
+
attr_accessor :calculation_phase
|
26
|
+
|
27
|
+
# The type of adjustment the fee applies to a payment. Currently, this value is TAX for all fees.
|
28
|
+
attr_accessor :adjustment_type
|
29
|
+
|
30
|
+
# If true, the fee applies to custom amounts entered into Square Register that are not associated with a particular item.
|
31
|
+
attr_accessor :applies_to_custom_amounts
|
32
|
+
|
33
|
+
# If true, the fee is applied to all appropriate items. If false, the fee is not applied at all.
|
34
|
+
attr_accessor :enabled
|
35
|
+
|
36
|
+
# Whether the fee is ADDITIVE or INCLUSIVE.
|
37
|
+
attr_accessor :inclusion_type
|
38
|
+
|
39
|
+
# In countries with multiple classifications for sales taxes, indicates which classification the fee falls under. Currently relevant only to Canadian merchants.
|
40
|
+
attr_accessor :type
|
41
|
+
|
42
|
+
class EnumAttributeValidator
|
43
|
+
attr_reader :datatype
|
44
|
+
attr_reader :allowable_values
|
45
|
+
|
46
|
+
def initialize(datatype, allowable_values)
|
47
|
+
@allowable_values = allowable_values.map do |value|
|
48
|
+
case datatype.to_s
|
49
|
+
when /Integer/i
|
50
|
+
value.to_i
|
51
|
+
when /Float/i
|
52
|
+
value.to_f
|
53
|
+
else
|
54
|
+
value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def valid?(value)
|
60
|
+
!value || allowable_values.include?(value)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
65
|
+
def self.attribute_map
|
66
|
+
{
|
67
|
+
:'id' => :'id',
|
68
|
+
:'name' => :'name',
|
69
|
+
:'rate' => :'rate',
|
70
|
+
:'calculation_phase' => :'calculation_phase',
|
71
|
+
:'adjustment_type' => :'adjustment_type',
|
72
|
+
:'applies_to_custom_amounts' => :'applies_to_custom_amounts',
|
73
|
+
:'enabled' => :'enabled',
|
74
|
+
:'inclusion_type' => :'inclusion_type',
|
75
|
+
:'type' => :'type'
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
# Attribute type mapping.
|
80
|
+
def self.swagger_types
|
81
|
+
{
|
82
|
+
:'id' => :'String',
|
83
|
+
:'name' => :'String',
|
84
|
+
:'rate' => :'String',
|
85
|
+
:'calculation_phase' => :'String',
|
86
|
+
:'adjustment_type' => :'String',
|
87
|
+
:'applies_to_custom_amounts' => :'BOOLEAN',
|
88
|
+
:'enabled' => :'BOOLEAN',
|
89
|
+
:'inclusion_type' => :'String',
|
90
|
+
:'type' => :'String'
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
# Initializes the object
|
95
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
96
|
+
def initialize(attributes = {})
|
97
|
+
return unless attributes.is_a?(Hash)
|
98
|
+
|
99
|
+
# convert string to symbol for hash key
|
100
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
101
|
+
|
102
|
+
if attributes.has_key?(:'id')
|
103
|
+
self.id = attributes[:'id']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.has_key?(:'name')
|
107
|
+
self.name = attributes[:'name']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.has_key?(:'rate')
|
111
|
+
self.rate = attributes[:'rate']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.has_key?(:'calculation_phase')
|
115
|
+
self.calculation_phase = attributes[:'calculation_phase']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.has_key?(:'adjustment_type')
|
119
|
+
self.adjustment_type = attributes[:'adjustment_type']
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.has_key?(:'applies_to_custom_amounts')
|
123
|
+
self.applies_to_custom_amounts = attributes[:'applies_to_custom_amounts']
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.has_key?(:'enabled')
|
127
|
+
self.enabled = attributes[:'enabled']
|
128
|
+
end
|
129
|
+
|
130
|
+
if attributes.has_key?(:'inclusion_type')
|
131
|
+
self.inclusion_type = attributes[:'inclusion_type']
|
132
|
+
end
|
133
|
+
|
134
|
+
if attributes.has_key?(:'type')
|
135
|
+
self.type = attributes[:'type']
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
141
|
+
# @return Array for valid properies with the reasons
|
142
|
+
def list_invalid_properties
|
143
|
+
invalid_properties = Array.new
|
144
|
+
return invalid_properties
|
145
|
+
end
|
146
|
+
|
147
|
+
# Check to see if the all the properties in the model are valid
|
148
|
+
# @return true if the model is valid
|
149
|
+
def valid?
|
150
|
+
calculation_phase_validator = EnumAttributeValidator.new('String', ["FEE_SUBTOTAL_PHASE", "OTHER", "FEE_TOTAL_PHASE"])
|
151
|
+
return false unless calculation_phase_validator.valid?(@calculation_phase)
|
152
|
+
adjustment_type_validator = EnumAttributeValidator.new('String', ["TAX"])
|
153
|
+
return false unless adjustment_type_validator.valid?(@adjustment_type)
|
154
|
+
inclusion_type_validator = EnumAttributeValidator.new('String', ["ADDITIVE", "INCLUSIVE"])
|
155
|
+
return false unless inclusion_type_validator.valid?(@inclusion_type)
|
156
|
+
type_validator = EnumAttributeValidator.new('String', ["CA_GST", "CA_HST", "CA_PST", "CA_QST", "JP_CONSUMPTION_TAX", "CA_PEI_PST", "US_SALES_TAX", "OTHER"])
|
157
|
+
return false unless type_validator.valid?(@type)
|
158
|
+
return true
|
159
|
+
end
|
160
|
+
|
161
|
+
# Custom attribute writer method checking allowed values (enum).
|
162
|
+
# @param [Object] calculation_phase Object to be assigned
|
163
|
+
def calculation_phase=(calculation_phase)
|
164
|
+
validator = EnumAttributeValidator.new('String', ["FEE_SUBTOTAL_PHASE", "OTHER", "FEE_TOTAL_PHASE"])
|
165
|
+
unless validator.valid?(calculation_phase)
|
166
|
+
fail ArgumentError, "invalid value for 'calculation_phase', must be one of #{validator.allowable_values}."
|
167
|
+
end
|
168
|
+
@calculation_phase = calculation_phase
|
169
|
+
end
|
170
|
+
|
171
|
+
# Custom attribute writer method checking allowed values (enum).
|
172
|
+
# @param [Object] adjustment_type Object to be assigned
|
173
|
+
def adjustment_type=(adjustment_type)
|
174
|
+
validator = EnumAttributeValidator.new('String', ["TAX"])
|
175
|
+
unless validator.valid?(adjustment_type)
|
176
|
+
fail ArgumentError, "invalid value for 'adjustment_type', must be one of #{validator.allowable_values}."
|
177
|
+
end
|
178
|
+
@adjustment_type = adjustment_type
|
179
|
+
end
|
180
|
+
|
181
|
+
# Custom attribute writer method checking allowed values (enum).
|
182
|
+
# @param [Object] inclusion_type Object to be assigned
|
183
|
+
def inclusion_type=(inclusion_type)
|
184
|
+
validator = EnumAttributeValidator.new('String', ["ADDITIVE", "INCLUSIVE"])
|
185
|
+
unless validator.valid?(inclusion_type)
|
186
|
+
fail ArgumentError, "invalid value for 'inclusion_type', must be one of #{validator.allowable_values}."
|
187
|
+
end
|
188
|
+
@inclusion_type = inclusion_type
|
189
|
+
end
|
190
|
+
|
191
|
+
# Custom attribute writer method checking allowed values (enum).
|
192
|
+
# @param [Object] type Object to be assigned
|
193
|
+
def type=(type)
|
194
|
+
validator = EnumAttributeValidator.new('String', ["CA_GST", "CA_HST", "CA_PST", "CA_QST", "JP_CONSUMPTION_TAX", "CA_PEI_PST", "US_SALES_TAX", "OTHER"])
|
195
|
+
unless validator.valid?(type)
|
196
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
197
|
+
end
|
198
|
+
@type = type
|
199
|
+
end
|
200
|
+
|
201
|
+
# Checks equality by comparing each attribute.
|
202
|
+
# @param [Object] Object to be compared
|
203
|
+
def ==(o)
|
204
|
+
return true if self.equal?(o)
|
205
|
+
self.class == o.class &&
|
206
|
+
id == o.id &&
|
207
|
+
name == o.name &&
|
208
|
+
rate == o.rate &&
|
209
|
+
calculation_phase == o.calculation_phase &&
|
210
|
+
adjustment_type == o.adjustment_type &&
|
211
|
+
applies_to_custom_amounts == o.applies_to_custom_amounts &&
|
212
|
+
enabled == o.enabled &&
|
213
|
+
inclusion_type == o.inclusion_type &&
|
214
|
+
type == o.type
|
215
|
+
end
|
216
|
+
|
217
|
+
# @see the `==` method
|
218
|
+
# @param [Object] Object to be compared
|
219
|
+
def eql?(o)
|
220
|
+
self == o
|
221
|
+
end
|
222
|
+
|
223
|
+
# Calculates hash code according to all attributes.
|
224
|
+
# @return [Fixnum] Hash code
|
225
|
+
def hash
|
226
|
+
[id, name, rate, calculation_phase, adjustment_type, applies_to_custom_amounts, enabled, inclusion_type, type].hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Builds the object from hash
|
230
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
231
|
+
# @return [Object] Returns the model itself
|
232
|
+
def build_from_hash(attributes)
|
233
|
+
return nil unless attributes.is_a?(Hash)
|
234
|
+
self.class.swagger_types.each_pair do |key, type|
|
235
|
+
if type =~ /\AArray<(.*)>/i
|
236
|
+
# check to ensure the input is an array given that the the attribute
|
237
|
+
# is documented as an array but the input is not
|
238
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
239
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
240
|
+
end
|
241
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
242
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
243
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
244
|
+
end
|
245
|
+
|
246
|
+
self
|
247
|
+
end
|
248
|
+
|
249
|
+
# Deserializes the data based on type
|
250
|
+
# @param string type Data type
|
251
|
+
# @param string value Value to be deserialized
|
252
|
+
# @return [Object] Deserialized data
|
253
|
+
def _deserialize(type, value)
|
254
|
+
case type.to_sym
|
255
|
+
when :DateTime
|
256
|
+
DateTime.parse(value)
|
257
|
+
when :Date
|
258
|
+
Date.parse(value)
|
259
|
+
when :String
|
260
|
+
value.to_s
|
261
|
+
when :Integer
|
262
|
+
value.to_i
|
263
|
+
when :Float
|
264
|
+
value.to_f
|
265
|
+
when :BOOLEAN
|
266
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
267
|
+
true
|
268
|
+
else
|
269
|
+
false
|
270
|
+
end
|
271
|
+
when :Object
|
272
|
+
# generic object (usually a Hash), return directly
|
273
|
+
value
|
274
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
275
|
+
inner_type = Regexp.last_match[:inner_type]
|
276
|
+
value.map { |v| _deserialize(inner_type, v) }
|
277
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
278
|
+
k_type = Regexp.last_match[:k_type]
|
279
|
+
v_type = Regexp.last_match[:v_type]
|
280
|
+
{}.tap do |hash|
|
281
|
+
value.each do |k, v|
|
282
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
else # model
|
286
|
+
temp_model = SquareConnect.const_get(type).new
|
287
|
+
temp_model.build_from_hash(value)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
# Returns the string representation of the object
|
292
|
+
# @return [String] String presentation of the object
|
293
|
+
def to_s
|
294
|
+
to_hash.to_s
|
295
|
+
end
|
296
|
+
|
297
|
+
# to_body is an alias to to_hash (backward compatibility)
|
298
|
+
# @return [Hash] Returns the object in the form of hash
|
299
|
+
def to_body
|
300
|
+
to_hash
|
301
|
+
end
|
302
|
+
|
303
|
+
# Returns the object in the form of hash
|
304
|
+
# @return [Hash] Returns the object in the form of hash
|
305
|
+
def to_hash
|
306
|
+
hash = {}
|
307
|
+
self.class.attribute_map.each_pair do |attr, param|
|
308
|
+
value = self.send(attr)
|
309
|
+
next if value.nil?
|
310
|
+
hash[param] = _to_hash(value)
|
311
|
+
end
|
312
|
+
hash
|
313
|
+
end
|
314
|
+
|
315
|
+
# Outputs non-array value in the form of hash
|
316
|
+
# For object, use to_hash. Otherwise, just return the value
|
317
|
+
# @param [Object] value Any valid value
|
318
|
+
# @return [Hash] Returns the value in the form of hash
|
319
|
+
def _to_hash(value)
|
320
|
+
if value.is_a?(Array)
|
321
|
+
value.compact.map{ |v| _to_hash(v) }
|
322
|
+
elsif value.is_a?(Hash)
|
323
|
+
{}.tap do |hash|
|
324
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
325
|
+
end
|
326
|
+
elsif value.respond_to? :to_hash
|
327
|
+
value.to_hash
|
328
|
+
else
|
329
|
+
value
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
334
|
+
|
335
|
+
end
|