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,291 @@
|
|
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 V1Discount
|
15
|
+
# The discount's unique ID.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The discount's name.
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# The rate of the discount, as a string representation of a decimal number. A value of 0.07 corresponds to a rate of 7%. This rate is 0 if discount_type is VARIABLE_PERCENTAGE.
|
22
|
+
attr_accessor :rate
|
23
|
+
|
24
|
+
# The amount of the discount. This amount is 0 if discount_type is VARIABLE_AMOUNT. This field is not included for rate-based discounts.
|
25
|
+
attr_accessor :amount_money
|
26
|
+
|
27
|
+
# Indicates whether the discount is a FIXED value or entered at the time of sale.
|
28
|
+
attr_accessor :discount_type
|
29
|
+
|
30
|
+
# Indicates whether a mobile staff member needs to enter their PIN to apply the discount to a payment.
|
31
|
+
attr_accessor :pin_required
|
32
|
+
|
33
|
+
# The color of the discount's display label in Square Register, if not the default color. The default color is 9da2a6.
|
34
|
+
attr_accessor :color
|
35
|
+
|
36
|
+
class EnumAttributeValidator
|
37
|
+
attr_reader :datatype
|
38
|
+
attr_reader :allowable_values
|
39
|
+
|
40
|
+
def initialize(datatype, allowable_values)
|
41
|
+
@allowable_values = allowable_values.map do |value|
|
42
|
+
case datatype.to_s
|
43
|
+
when /Integer/i
|
44
|
+
value.to_i
|
45
|
+
when /Float/i
|
46
|
+
value.to_f
|
47
|
+
else
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def valid?(value)
|
54
|
+
!value || allowable_values.include?(value)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
59
|
+
def self.attribute_map
|
60
|
+
{
|
61
|
+
:'id' => :'id',
|
62
|
+
:'name' => :'name',
|
63
|
+
:'rate' => :'rate',
|
64
|
+
:'amount_money' => :'amount_money',
|
65
|
+
:'discount_type' => :'discount_type',
|
66
|
+
:'pin_required' => :'pin_required',
|
67
|
+
:'color' => :'color'
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Attribute type mapping.
|
72
|
+
def self.swagger_types
|
73
|
+
{
|
74
|
+
:'id' => :'String',
|
75
|
+
:'name' => :'String',
|
76
|
+
:'rate' => :'String',
|
77
|
+
:'amount_money' => :'V1Money',
|
78
|
+
:'discount_type' => :'String',
|
79
|
+
:'pin_required' => :'BOOLEAN',
|
80
|
+
:'color' => :'String'
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
# Initializes the object
|
85
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
86
|
+
def initialize(attributes = {})
|
87
|
+
return unless attributes.is_a?(Hash)
|
88
|
+
|
89
|
+
# convert string to symbol for hash key
|
90
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
91
|
+
|
92
|
+
if attributes.has_key?(:'id')
|
93
|
+
self.id = attributes[:'id']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.has_key?(:'name')
|
97
|
+
self.name = attributes[:'name']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.has_key?(:'rate')
|
101
|
+
self.rate = attributes[:'rate']
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.has_key?(:'amount_money')
|
105
|
+
self.amount_money = attributes[:'amount_money']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.has_key?(:'discount_type')
|
109
|
+
self.discount_type = attributes[:'discount_type']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.has_key?(:'pin_required')
|
113
|
+
self.pin_required = attributes[:'pin_required']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.has_key?(:'color')
|
117
|
+
self.color = attributes[:'color']
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
123
|
+
# @return Array for valid properies with the reasons
|
124
|
+
def list_invalid_properties
|
125
|
+
invalid_properties = Array.new
|
126
|
+
return invalid_properties
|
127
|
+
end
|
128
|
+
|
129
|
+
# Check to see if the all the properties in the model are valid
|
130
|
+
# @return true if the model is valid
|
131
|
+
def valid?
|
132
|
+
discount_type_validator = EnumAttributeValidator.new('String', ["FIXED", "VARIABLE_PERCENTAGE", "VARIABLE_AMOUNT"])
|
133
|
+
return false unless discount_type_validator.valid?(@discount_type)
|
134
|
+
color_validator = EnumAttributeValidator.new('String', ["9da2a6", "4ab200", "0b8000", "2952cc", "a82ee5", "e5457a", "b21212", "593c00", "e5BF00"])
|
135
|
+
return false unless color_validator.valid?(@color)
|
136
|
+
return true
|
137
|
+
end
|
138
|
+
|
139
|
+
# Custom attribute writer method checking allowed values (enum).
|
140
|
+
# @param [Object] discount_type Object to be assigned
|
141
|
+
def discount_type=(discount_type)
|
142
|
+
validator = EnumAttributeValidator.new('String', ["FIXED", "VARIABLE_PERCENTAGE", "VARIABLE_AMOUNT"])
|
143
|
+
unless validator.valid?(discount_type)
|
144
|
+
fail ArgumentError, "invalid value for 'discount_type', must be one of #{validator.allowable_values}."
|
145
|
+
end
|
146
|
+
@discount_type = discount_type
|
147
|
+
end
|
148
|
+
|
149
|
+
# Custom attribute writer method checking allowed values (enum).
|
150
|
+
# @param [Object] color Object to be assigned
|
151
|
+
def color=(color)
|
152
|
+
validator = EnumAttributeValidator.new('String', ["9da2a6", "4ab200", "0b8000", "2952cc", "a82ee5", "e5457a", "b21212", "593c00", "e5BF00"])
|
153
|
+
unless validator.valid?(color)
|
154
|
+
fail ArgumentError, "invalid value for 'color', must be one of #{validator.allowable_values}."
|
155
|
+
end
|
156
|
+
@color = color
|
157
|
+
end
|
158
|
+
|
159
|
+
# Checks equality by comparing each attribute.
|
160
|
+
# @param [Object] Object to be compared
|
161
|
+
def ==(o)
|
162
|
+
return true if self.equal?(o)
|
163
|
+
self.class == o.class &&
|
164
|
+
id == o.id &&
|
165
|
+
name == o.name &&
|
166
|
+
rate == o.rate &&
|
167
|
+
amount_money == o.amount_money &&
|
168
|
+
discount_type == o.discount_type &&
|
169
|
+
pin_required == o.pin_required &&
|
170
|
+
color == o.color
|
171
|
+
end
|
172
|
+
|
173
|
+
# @see the `==` method
|
174
|
+
# @param [Object] Object to be compared
|
175
|
+
def eql?(o)
|
176
|
+
self == o
|
177
|
+
end
|
178
|
+
|
179
|
+
# Calculates hash code according to all attributes.
|
180
|
+
# @return [Fixnum] Hash code
|
181
|
+
def hash
|
182
|
+
[id, name, rate, amount_money, discount_type, pin_required, color].hash
|
183
|
+
end
|
184
|
+
|
185
|
+
# Builds the object from hash
|
186
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
187
|
+
# @return [Object] Returns the model itself
|
188
|
+
def build_from_hash(attributes)
|
189
|
+
return nil unless attributes.is_a?(Hash)
|
190
|
+
self.class.swagger_types.each_pair do |key, type|
|
191
|
+
if type =~ /\AArray<(.*)>/i
|
192
|
+
# check to ensure the input is an array given that the the attribute
|
193
|
+
# is documented as an array but the input is not
|
194
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
195
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
196
|
+
end
|
197
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
198
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
199
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
200
|
+
end
|
201
|
+
|
202
|
+
self
|
203
|
+
end
|
204
|
+
|
205
|
+
# Deserializes the data based on type
|
206
|
+
# @param string type Data type
|
207
|
+
# @param string value Value to be deserialized
|
208
|
+
# @return [Object] Deserialized data
|
209
|
+
def _deserialize(type, value)
|
210
|
+
case type.to_sym
|
211
|
+
when :DateTime
|
212
|
+
DateTime.parse(value)
|
213
|
+
when :Date
|
214
|
+
Date.parse(value)
|
215
|
+
when :String
|
216
|
+
value.to_s
|
217
|
+
when :Integer
|
218
|
+
value.to_i
|
219
|
+
when :Float
|
220
|
+
value.to_f
|
221
|
+
when :BOOLEAN
|
222
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
223
|
+
true
|
224
|
+
else
|
225
|
+
false
|
226
|
+
end
|
227
|
+
when :Object
|
228
|
+
# generic object (usually a Hash), return directly
|
229
|
+
value
|
230
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
231
|
+
inner_type = Regexp.last_match[:inner_type]
|
232
|
+
value.map { |v| _deserialize(inner_type, v) }
|
233
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
234
|
+
k_type = Regexp.last_match[:k_type]
|
235
|
+
v_type = Regexp.last_match[:v_type]
|
236
|
+
{}.tap do |hash|
|
237
|
+
value.each do |k, v|
|
238
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
else # model
|
242
|
+
temp_model = SquareConnect.const_get(type).new
|
243
|
+
temp_model.build_from_hash(value)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# Returns the string representation of the object
|
248
|
+
# @return [String] String presentation of the object
|
249
|
+
def to_s
|
250
|
+
to_hash.to_s
|
251
|
+
end
|
252
|
+
|
253
|
+
# to_body is an alias to to_hash (backward compatibility)
|
254
|
+
# @return [Hash] Returns the object in the form of hash
|
255
|
+
def to_body
|
256
|
+
to_hash
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns the object in the form of hash
|
260
|
+
# @return [Hash] Returns the object in the form of hash
|
261
|
+
def to_hash
|
262
|
+
hash = {}
|
263
|
+
self.class.attribute_map.each_pair do |attr, param|
|
264
|
+
value = self.send(attr)
|
265
|
+
next if value.nil?
|
266
|
+
hash[param] = _to_hash(value)
|
267
|
+
end
|
268
|
+
hash
|
269
|
+
end
|
270
|
+
|
271
|
+
# Outputs non-array value in the form of hash
|
272
|
+
# For object, use to_hash. Otherwise, just return the value
|
273
|
+
# @param [Object] value Any valid value
|
274
|
+
# @return [Hash] Returns the value in the form of hash
|
275
|
+
def _to_hash(value)
|
276
|
+
if value.is_a?(Array)
|
277
|
+
value.compact.map{ |v| _to_hash(v) }
|
278
|
+
elsif value.is_a?(Hash)
|
279
|
+
{}.tap do |hash|
|
280
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
281
|
+
end
|
282
|
+
elsif value.respond_to? :to_hash
|
283
|
+
value.to_hash
|
284
|
+
else
|
285
|
+
value
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
@@ -0,0 +1,323 @@
|
|
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
|
+
# Represents one of a business's employees.
|
14
|
+
class V1Employee
|
15
|
+
# The employee's unique ID.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The employee's first name.
|
19
|
+
attr_accessor :first_name
|
20
|
+
|
21
|
+
# The employee's last name.
|
22
|
+
attr_accessor :last_name
|
23
|
+
|
24
|
+
# The ids of the employee's associated roles. Currently, you can specify only one or zero roles per employee.
|
25
|
+
attr_accessor :role_ids
|
26
|
+
|
27
|
+
# The IDs of the locations the employee is allowed to clock in at.
|
28
|
+
attr_accessor :authorized_location_ids
|
29
|
+
|
30
|
+
# The employee's email address.
|
31
|
+
attr_accessor :email
|
32
|
+
|
33
|
+
# CWhether the employee is ACTIVE or INACTIVE. Inactive employees cannot sign in to Square Register.Merchants update this field from the Square Dashboard.
|
34
|
+
attr_accessor :status
|
35
|
+
|
36
|
+
# An ID the merchant can set to associate the employee with an entity in another system.
|
37
|
+
attr_accessor :external_id
|
38
|
+
|
39
|
+
# The time when the employee entity was created, in ISO 8601 format.
|
40
|
+
attr_accessor :created_at
|
41
|
+
|
42
|
+
# The time when the employee entity was most recently updated, in ISO 8601 format.
|
43
|
+
attr_accessor :updated_at
|
44
|
+
|
45
|
+
class EnumAttributeValidator
|
46
|
+
attr_reader :datatype
|
47
|
+
attr_reader :allowable_values
|
48
|
+
|
49
|
+
def initialize(datatype, allowable_values)
|
50
|
+
@allowable_values = allowable_values.map do |value|
|
51
|
+
case datatype.to_s
|
52
|
+
when /Integer/i
|
53
|
+
value.to_i
|
54
|
+
when /Float/i
|
55
|
+
value.to_f
|
56
|
+
else
|
57
|
+
value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def valid?(value)
|
63
|
+
!value || allowable_values.include?(value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
68
|
+
def self.attribute_map
|
69
|
+
{
|
70
|
+
:'id' => :'id',
|
71
|
+
:'first_name' => :'first_name',
|
72
|
+
:'last_name' => :'last_name',
|
73
|
+
:'role_ids' => :'role_ids',
|
74
|
+
:'authorized_location_ids' => :'authorized_location_ids',
|
75
|
+
:'email' => :'email',
|
76
|
+
:'status' => :'status',
|
77
|
+
:'external_id' => :'external_id',
|
78
|
+
:'created_at' => :'created_at',
|
79
|
+
:'updated_at' => :'updated_at'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# Attribute type mapping.
|
84
|
+
def self.swagger_types
|
85
|
+
{
|
86
|
+
:'id' => :'String',
|
87
|
+
:'first_name' => :'String',
|
88
|
+
:'last_name' => :'String',
|
89
|
+
:'role_ids' => :'Array<String>',
|
90
|
+
:'authorized_location_ids' => :'Array<String>',
|
91
|
+
:'email' => :'String',
|
92
|
+
:'status' => :'String',
|
93
|
+
:'external_id' => :'String',
|
94
|
+
:'created_at' => :'String',
|
95
|
+
:'updated_at' => :'String'
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
# Initializes the object
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
101
|
+
def initialize(attributes = {})
|
102
|
+
return unless attributes.is_a?(Hash)
|
103
|
+
|
104
|
+
# convert string to symbol for hash key
|
105
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
106
|
+
|
107
|
+
if attributes.has_key?(:'id')
|
108
|
+
self.id = attributes[:'id']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.has_key?(:'first_name')
|
112
|
+
self.first_name = attributes[:'first_name']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.has_key?(:'last_name')
|
116
|
+
self.last_name = attributes[:'last_name']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.has_key?(:'role_ids')
|
120
|
+
if (value = attributes[:'role_ids']).is_a?(Array)
|
121
|
+
self.role_ids = value
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'authorized_location_ids')
|
126
|
+
if (value = attributes[:'authorized_location_ids']).is_a?(Array)
|
127
|
+
self.authorized_location_ids = value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.has_key?(:'email')
|
132
|
+
self.email = attributes[:'email']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.has_key?(:'status')
|
136
|
+
self.status = attributes[:'status']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.has_key?(:'external_id')
|
140
|
+
self.external_id = attributes[:'external_id']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.has_key?(:'created_at')
|
144
|
+
self.created_at = attributes[:'created_at']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.has_key?(:'updated_at')
|
148
|
+
self.updated_at = attributes[:'updated_at']
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
154
|
+
# @return Array for valid properies with the reasons
|
155
|
+
def list_invalid_properties
|
156
|
+
invalid_properties = Array.new
|
157
|
+
if @first_name.nil?
|
158
|
+
invalid_properties.push("invalid value for 'first_name', first_name cannot be nil.")
|
159
|
+
end
|
160
|
+
|
161
|
+
if @last_name.nil?
|
162
|
+
invalid_properties.push("invalid value for 'last_name', last_name cannot be nil.")
|
163
|
+
end
|
164
|
+
|
165
|
+
return invalid_properties
|
166
|
+
end
|
167
|
+
|
168
|
+
# Check to see if the all the properties in the model are valid
|
169
|
+
# @return true if the model is valid
|
170
|
+
def valid?
|
171
|
+
return false if @first_name.nil?
|
172
|
+
return false if @last_name.nil?
|
173
|
+
status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE"])
|
174
|
+
return false unless status_validator.valid?(@status)
|
175
|
+
return true
|
176
|
+
end
|
177
|
+
|
178
|
+
# Custom attribute writer method checking allowed values (enum).
|
179
|
+
# @param [Object] status Object to be assigned
|
180
|
+
def status=(status)
|
181
|
+
validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE"])
|
182
|
+
unless validator.valid?(status)
|
183
|
+
fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}."
|
184
|
+
end
|
185
|
+
@status = status
|
186
|
+
end
|
187
|
+
|
188
|
+
# Checks equality by comparing each attribute.
|
189
|
+
# @param [Object] Object to be compared
|
190
|
+
def ==(o)
|
191
|
+
return true if self.equal?(o)
|
192
|
+
self.class == o.class &&
|
193
|
+
id == o.id &&
|
194
|
+
first_name == o.first_name &&
|
195
|
+
last_name == o.last_name &&
|
196
|
+
role_ids == o.role_ids &&
|
197
|
+
authorized_location_ids == o.authorized_location_ids &&
|
198
|
+
email == o.email &&
|
199
|
+
status == o.status &&
|
200
|
+
external_id == o.external_id &&
|
201
|
+
created_at == o.created_at &&
|
202
|
+
updated_at == o.updated_at
|
203
|
+
end
|
204
|
+
|
205
|
+
# @see the `==` method
|
206
|
+
# @param [Object] Object to be compared
|
207
|
+
def eql?(o)
|
208
|
+
self == o
|
209
|
+
end
|
210
|
+
|
211
|
+
# Calculates hash code according to all attributes.
|
212
|
+
# @return [Fixnum] Hash code
|
213
|
+
def hash
|
214
|
+
[id, first_name, last_name, role_ids, authorized_location_ids, email, status, external_id, created_at, updated_at].hash
|
215
|
+
end
|
216
|
+
|
217
|
+
# Builds the object from hash
|
218
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
219
|
+
# @return [Object] Returns the model itself
|
220
|
+
def build_from_hash(attributes)
|
221
|
+
return nil unless attributes.is_a?(Hash)
|
222
|
+
self.class.swagger_types.each_pair do |key, type|
|
223
|
+
if type =~ /\AArray<(.*)>/i
|
224
|
+
# check to ensure the input is an array given that the the attribute
|
225
|
+
# is documented as an array but the input is not
|
226
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
227
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
228
|
+
end
|
229
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
230
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
231
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
232
|
+
end
|
233
|
+
|
234
|
+
self
|
235
|
+
end
|
236
|
+
|
237
|
+
# Deserializes the data based on type
|
238
|
+
# @param string type Data type
|
239
|
+
# @param string value Value to be deserialized
|
240
|
+
# @return [Object] Deserialized data
|
241
|
+
def _deserialize(type, value)
|
242
|
+
case type.to_sym
|
243
|
+
when :DateTime
|
244
|
+
DateTime.parse(value)
|
245
|
+
when :Date
|
246
|
+
Date.parse(value)
|
247
|
+
when :String
|
248
|
+
value.to_s
|
249
|
+
when :Integer
|
250
|
+
value.to_i
|
251
|
+
when :Float
|
252
|
+
value.to_f
|
253
|
+
when :BOOLEAN
|
254
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
255
|
+
true
|
256
|
+
else
|
257
|
+
false
|
258
|
+
end
|
259
|
+
when :Object
|
260
|
+
# generic object (usually a Hash), return directly
|
261
|
+
value
|
262
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
263
|
+
inner_type = Regexp.last_match[:inner_type]
|
264
|
+
value.map { |v| _deserialize(inner_type, v) }
|
265
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
266
|
+
k_type = Regexp.last_match[:k_type]
|
267
|
+
v_type = Regexp.last_match[:v_type]
|
268
|
+
{}.tap do |hash|
|
269
|
+
value.each do |k, v|
|
270
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
else # model
|
274
|
+
temp_model = SquareConnect.const_get(type).new
|
275
|
+
temp_model.build_from_hash(value)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
# Returns the string representation of the object
|
280
|
+
# @return [String] String presentation of the object
|
281
|
+
def to_s
|
282
|
+
to_hash.to_s
|
283
|
+
end
|
284
|
+
|
285
|
+
# to_body is an alias to to_hash (backward compatibility)
|
286
|
+
# @return [Hash] Returns the object in the form of hash
|
287
|
+
def to_body
|
288
|
+
to_hash
|
289
|
+
end
|
290
|
+
|
291
|
+
# Returns the object in the form of hash
|
292
|
+
# @return [Hash] Returns the object in the form of hash
|
293
|
+
def to_hash
|
294
|
+
hash = {}
|
295
|
+
self.class.attribute_map.each_pair do |attr, param|
|
296
|
+
value = self.send(attr)
|
297
|
+
next if value.nil?
|
298
|
+
hash[param] = _to_hash(value)
|
299
|
+
end
|
300
|
+
hash
|
301
|
+
end
|
302
|
+
|
303
|
+
# Outputs non-array value in the form of hash
|
304
|
+
# For object, use to_hash. Otherwise, just return the value
|
305
|
+
# @param [Object] value Any valid value
|
306
|
+
# @return [Hash] Returns the value in the form of hash
|
307
|
+
def _to_hash(value)
|
308
|
+
if value.is_a?(Array)
|
309
|
+
value.compact.map{ |v| _to_hash(v) }
|
310
|
+
elsif value.is_a?(Hash)
|
311
|
+
{}.tap do |hash|
|
312
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
313
|
+
end
|
314
|
+
elsif value.respond_to? :to_hash
|
315
|
+
value.to_hash
|
316
|
+
else
|
317
|
+
value
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
end
|