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 V1CashDrawerEvent
|
15
|
+
# The event's unique ID.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The ID of the employee that created the event.
|
19
|
+
attr_accessor :employee_id
|
20
|
+
|
21
|
+
# The type of event that occurred.
|
22
|
+
attr_accessor :event_type
|
23
|
+
|
24
|
+
# The amount of money that was added to or removed from the cash drawer because of the event. This value can be positive (for added money) or negative (for removed money).
|
25
|
+
attr_accessor :event_money
|
26
|
+
|
27
|
+
# The time when the event occurred, in ISO 8601 format.
|
28
|
+
attr_accessor :created_at
|
29
|
+
|
30
|
+
# An optional description of the event, entered by the employee that created it.
|
31
|
+
attr_accessor :description
|
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
|
+
:'employee_id' => :'employee_id',
|
60
|
+
:'event_type' => :'event_type',
|
61
|
+
:'event_money' => :'event_money',
|
62
|
+
:'created_at' => :'created_at',
|
63
|
+
:'description' => :'description'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute type mapping.
|
68
|
+
def self.swagger_types
|
69
|
+
{
|
70
|
+
:'id' => :'String',
|
71
|
+
:'employee_id' => :'String',
|
72
|
+
:'event_type' => :'String',
|
73
|
+
:'event_money' => :'V1Money',
|
74
|
+
:'created_at' => :'String',
|
75
|
+
:'description' => :'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?(:'employee_id')
|
92
|
+
self.employee_id = attributes[:'employee_id']
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.has_key?(:'event_type')
|
96
|
+
self.event_type = attributes[:'event_type']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.has_key?(:'event_money')
|
100
|
+
self.event_money = attributes[:'event_money']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.has_key?(:'created_at')
|
104
|
+
self.created_at = attributes[:'created_at']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.has_key?(:'description')
|
108
|
+
self.description = attributes[:'description']
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
114
|
+
# @return Array for valid properies with the reasons
|
115
|
+
def list_invalid_properties
|
116
|
+
invalid_properties = Array.new
|
117
|
+
return invalid_properties
|
118
|
+
end
|
119
|
+
|
120
|
+
# Check to see if the all the properties in the model are valid
|
121
|
+
# @return true if the model is valid
|
122
|
+
def valid?
|
123
|
+
event_type_validator = EnumAttributeValidator.new('String', ["NO_SALE", "CASH_TENDER_PAYMENT", "OTHER_TENDER_PAYMENT", "CASH_TENDER_CANCELED_PAYMENT", "OTHER_TENDER_CANCELED_PAYMENT", "CASH_TENDER_REFUND", "OTHER_TENDER_REFUND", "PAID_IN", "PAID_OUT"])
|
124
|
+
return false unless event_type_validator.valid?(@event_type)
|
125
|
+
return true
|
126
|
+
end
|
127
|
+
|
128
|
+
# Custom attribute writer method checking allowed values (enum).
|
129
|
+
# @param [Object] event_type Object to be assigned
|
130
|
+
def event_type=(event_type)
|
131
|
+
validator = EnumAttributeValidator.new('String', ["NO_SALE", "CASH_TENDER_PAYMENT", "OTHER_TENDER_PAYMENT", "CASH_TENDER_CANCELED_PAYMENT", "OTHER_TENDER_CANCELED_PAYMENT", "CASH_TENDER_REFUND", "OTHER_TENDER_REFUND", "PAID_IN", "PAID_OUT"])
|
132
|
+
unless validator.valid?(event_type)
|
133
|
+
fail ArgumentError, "invalid value for 'event_type', must be one of #{validator.allowable_values}."
|
134
|
+
end
|
135
|
+
@event_type = event_type
|
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
|
+
employee_id == o.employee_id &&
|
145
|
+
event_type == o.event_type &&
|
146
|
+
event_money == o.event_money &&
|
147
|
+
created_at == o.created_at &&
|
148
|
+
description == o.description
|
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, employee_id, event_type, event_money, created_at, description].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,403 @@
|
|
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 V1CashDrawerShift
|
15
|
+
# The shift's unique ID.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The shift's current state.
|
19
|
+
attr_accessor :event_type
|
20
|
+
|
21
|
+
# The time when the shift began, in ISO 8601 format.
|
22
|
+
attr_accessor :opened_at
|
23
|
+
|
24
|
+
# The time when the shift ended, in ISO 8601 format.
|
25
|
+
attr_accessor :ended_at
|
26
|
+
|
27
|
+
# The time when the shift was closed, in ISO 8601 format.
|
28
|
+
attr_accessor :closed_at
|
29
|
+
|
30
|
+
# The IDs of all employees that were logged into Square Register at some point during the cash drawer shift.
|
31
|
+
attr_accessor :employee_ids
|
32
|
+
|
33
|
+
# The ID of the employee that started the cash drawer shift.
|
34
|
+
attr_accessor :opening_employee_id
|
35
|
+
|
36
|
+
# The ID of the employee that ended the cash drawer shift.
|
37
|
+
attr_accessor :ending_employee_id
|
38
|
+
|
39
|
+
# The ID of the employee that closed the cash drawer shift by auditing the cash drawer's contents.
|
40
|
+
attr_accessor :closing_employee_id
|
41
|
+
|
42
|
+
# The time when the timecard was created, in ISO 8601 format.
|
43
|
+
attr_accessor :description
|
44
|
+
|
45
|
+
# The amount of money in the cash drawer at the start of the shift.
|
46
|
+
attr_accessor :starting_cash_money
|
47
|
+
|
48
|
+
# The amount of money added to the cash drawer from cash payments.
|
49
|
+
attr_accessor :cash_payment_money
|
50
|
+
|
51
|
+
# The amount of money removed from the cash drawer from cash refunds. This value is always negative or zero.
|
52
|
+
attr_accessor :cash_refunds_money
|
53
|
+
|
54
|
+
# The amount of money added to the cash drawer for reasons other than cash payments.
|
55
|
+
attr_accessor :cash_paid_in_money
|
56
|
+
|
57
|
+
# The amount of money removed from the cash drawer for reasons other than cash refunds.
|
58
|
+
attr_accessor :cash_paid_out_money
|
59
|
+
|
60
|
+
# The amount of money that should be in the cash drawer at the end of the shift, based on the shift's other money amounts.
|
61
|
+
attr_accessor :expected_cash_money
|
62
|
+
|
63
|
+
# The amount of money found in the cash drawer at the end of the shift by an auditing employee.
|
64
|
+
attr_accessor :closed_cash_money
|
65
|
+
|
66
|
+
# The device running Square Register that was connected to the cash drawer.
|
67
|
+
attr_accessor :device
|
68
|
+
|
69
|
+
# All of the events (payments, refunds, and so on) that involved the cash drawer during the shift.
|
70
|
+
attr_accessor :events
|
71
|
+
|
72
|
+
class EnumAttributeValidator
|
73
|
+
attr_reader :datatype
|
74
|
+
attr_reader :allowable_values
|
75
|
+
|
76
|
+
def initialize(datatype, allowable_values)
|
77
|
+
@allowable_values = allowable_values.map do |value|
|
78
|
+
case datatype.to_s
|
79
|
+
when /Integer/i
|
80
|
+
value.to_i
|
81
|
+
when /Float/i
|
82
|
+
value.to_f
|
83
|
+
else
|
84
|
+
value
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def valid?(value)
|
90
|
+
!value || allowable_values.include?(value)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
95
|
+
def self.attribute_map
|
96
|
+
{
|
97
|
+
:'id' => :'id',
|
98
|
+
:'event_type' => :'event_type',
|
99
|
+
:'opened_at' => :'opened_at',
|
100
|
+
:'ended_at' => :'ended_at',
|
101
|
+
:'closed_at' => :'closed_at',
|
102
|
+
:'employee_ids' => :'employee_ids',
|
103
|
+
:'opening_employee_id' => :'opening_employee_id',
|
104
|
+
:'ending_employee_id' => :'ending_employee_id',
|
105
|
+
:'closing_employee_id' => :'closing_employee_id',
|
106
|
+
:'description' => :'description',
|
107
|
+
:'starting_cash_money' => :'starting_cash_money',
|
108
|
+
:'cash_payment_money' => :'cash_payment_money',
|
109
|
+
:'cash_refunds_money' => :'cash_refunds_money',
|
110
|
+
:'cash_paid_in_money' => :'cash_paid_in_money',
|
111
|
+
:'cash_paid_out_money' => :'cash_paid_out_money',
|
112
|
+
:'expected_cash_money' => :'expected_cash_money',
|
113
|
+
:'closed_cash_money' => :'closed_cash_money',
|
114
|
+
:'device' => :'device',
|
115
|
+
:'events' => :'events'
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
# Attribute type mapping.
|
120
|
+
def self.swagger_types
|
121
|
+
{
|
122
|
+
:'id' => :'String',
|
123
|
+
:'event_type' => :'String',
|
124
|
+
:'opened_at' => :'String',
|
125
|
+
:'ended_at' => :'BOOLEAN',
|
126
|
+
:'closed_at' => :'String',
|
127
|
+
:'employee_ids' => :'Array<String>',
|
128
|
+
:'opening_employee_id' => :'String',
|
129
|
+
:'ending_employee_id' => :'String',
|
130
|
+
:'closing_employee_id' => :'String',
|
131
|
+
:'description' => :'String',
|
132
|
+
:'starting_cash_money' => :'V1Money',
|
133
|
+
:'cash_payment_money' => :'V1Money',
|
134
|
+
:'cash_refunds_money' => :'V1Money',
|
135
|
+
:'cash_paid_in_money' => :'V1Money',
|
136
|
+
:'cash_paid_out_money' => :'V1Money',
|
137
|
+
:'expected_cash_money' => :'V1Money',
|
138
|
+
:'closed_cash_money' => :'V1Money',
|
139
|
+
:'device' => :'Device',
|
140
|
+
:'events' => :'Array<V1CashDrawerEvent>'
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
# Initializes the object
|
145
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
146
|
+
def initialize(attributes = {})
|
147
|
+
return unless attributes.is_a?(Hash)
|
148
|
+
|
149
|
+
# convert string to symbol for hash key
|
150
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
151
|
+
|
152
|
+
if attributes.has_key?(:'id')
|
153
|
+
self.id = attributes[:'id']
|
154
|
+
end
|
155
|
+
|
156
|
+
if attributes.has_key?(:'event_type')
|
157
|
+
self.event_type = attributes[:'event_type']
|
158
|
+
end
|
159
|
+
|
160
|
+
if attributes.has_key?(:'opened_at')
|
161
|
+
self.opened_at = attributes[:'opened_at']
|
162
|
+
end
|
163
|
+
|
164
|
+
if attributes.has_key?(:'ended_at')
|
165
|
+
self.ended_at = attributes[:'ended_at']
|
166
|
+
end
|
167
|
+
|
168
|
+
if attributes.has_key?(:'closed_at')
|
169
|
+
self.closed_at = attributes[:'closed_at']
|
170
|
+
end
|
171
|
+
|
172
|
+
if attributes.has_key?(:'employee_ids')
|
173
|
+
if (value = attributes[:'employee_ids']).is_a?(Array)
|
174
|
+
self.employee_ids = value
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
if attributes.has_key?(:'opening_employee_id')
|
179
|
+
self.opening_employee_id = attributes[:'opening_employee_id']
|
180
|
+
end
|
181
|
+
|
182
|
+
if attributes.has_key?(:'ending_employee_id')
|
183
|
+
self.ending_employee_id = attributes[:'ending_employee_id']
|
184
|
+
end
|
185
|
+
|
186
|
+
if attributes.has_key?(:'closing_employee_id')
|
187
|
+
self.closing_employee_id = attributes[:'closing_employee_id']
|
188
|
+
end
|
189
|
+
|
190
|
+
if attributes.has_key?(:'description')
|
191
|
+
self.description = attributes[:'description']
|
192
|
+
end
|
193
|
+
|
194
|
+
if attributes.has_key?(:'starting_cash_money')
|
195
|
+
self.starting_cash_money = attributes[:'starting_cash_money']
|
196
|
+
end
|
197
|
+
|
198
|
+
if attributes.has_key?(:'cash_payment_money')
|
199
|
+
self.cash_payment_money = attributes[:'cash_payment_money']
|
200
|
+
end
|
201
|
+
|
202
|
+
if attributes.has_key?(:'cash_refunds_money')
|
203
|
+
self.cash_refunds_money = attributes[:'cash_refunds_money']
|
204
|
+
end
|
205
|
+
|
206
|
+
if attributes.has_key?(:'cash_paid_in_money')
|
207
|
+
self.cash_paid_in_money = attributes[:'cash_paid_in_money']
|
208
|
+
end
|
209
|
+
|
210
|
+
if attributes.has_key?(:'cash_paid_out_money')
|
211
|
+
self.cash_paid_out_money = attributes[:'cash_paid_out_money']
|
212
|
+
end
|
213
|
+
|
214
|
+
if attributes.has_key?(:'expected_cash_money')
|
215
|
+
self.expected_cash_money = attributes[:'expected_cash_money']
|
216
|
+
end
|
217
|
+
|
218
|
+
if attributes.has_key?(:'closed_cash_money')
|
219
|
+
self.closed_cash_money = attributes[:'closed_cash_money']
|
220
|
+
end
|
221
|
+
|
222
|
+
if attributes.has_key?(:'device')
|
223
|
+
self.device = attributes[:'device']
|
224
|
+
end
|
225
|
+
|
226
|
+
if attributes.has_key?(:'events')
|
227
|
+
if (value = attributes[:'events']).is_a?(Array)
|
228
|
+
self.events = value
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
235
|
+
# @return Array for valid properies with the reasons
|
236
|
+
def list_invalid_properties
|
237
|
+
invalid_properties = Array.new
|
238
|
+
return invalid_properties
|
239
|
+
end
|
240
|
+
|
241
|
+
# Check to see if the all the properties in the model are valid
|
242
|
+
# @return true if the model is valid
|
243
|
+
def valid?
|
244
|
+
event_type_validator = EnumAttributeValidator.new('String', ["OPEN", "ENDED", "CLOSED"])
|
245
|
+
return false unless event_type_validator.valid?(@event_type)
|
246
|
+
return true
|
247
|
+
end
|
248
|
+
|
249
|
+
# Custom attribute writer method checking allowed values (enum).
|
250
|
+
# @param [Object] event_type Object to be assigned
|
251
|
+
def event_type=(event_type)
|
252
|
+
validator = EnumAttributeValidator.new('String', ["OPEN", "ENDED", "CLOSED"])
|
253
|
+
unless validator.valid?(event_type)
|
254
|
+
fail ArgumentError, "invalid value for 'event_type', must be one of #{validator.allowable_values}."
|
255
|
+
end
|
256
|
+
@event_type = event_type
|
257
|
+
end
|
258
|
+
|
259
|
+
# Checks equality by comparing each attribute.
|
260
|
+
# @param [Object] Object to be compared
|
261
|
+
def ==(o)
|
262
|
+
return true if self.equal?(o)
|
263
|
+
self.class == o.class &&
|
264
|
+
id == o.id &&
|
265
|
+
event_type == o.event_type &&
|
266
|
+
opened_at == o.opened_at &&
|
267
|
+
ended_at == o.ended_at &&
|
268
|
+
closed_at == o.closed_at &&
|
269
|
+
employee_ids == o.employee_ids &&
|
270
|
+
opening_employee_id == o.opening_employee_id &&
|
271
|
+
ending_employee_id == o.ending_employee_id &&
|
272
|
+
closing_employee_id == o.closing_employee_id &&
|
273
|
+
description == o.description &&
|
274
|
+
starting_cash_money == o.starting_cash_money &&
|
275
|
+
cash_payment_money == o.cash_payment_money &&
|
276
|
+
cash_refunds_money == o.cash_refunds_money &&
|
277
|
+
cash_paid_in_money == o.cash_paid_in_money &&
|
278
|
+
cash_paid_out_money == o.cash_paid_out_money &&
|
279
|
+
expected_cash_money == o.expected_cash_money &&
|
280
|
+
closed_cash_money == o.closed_cash_money &&
|
281
|
+
device == o.device &&
|
282
|
+
events == o.events
|
283
|
+
end
|
284
|
+
|
285
|
+
# @see the `==` method
|
286
|
+
# @param [Object] Object to be compared
|
287
|
+
def eql?(o)
|
288
|
+
self == o
|
289
|
+
end
|
290
|
+
|
291
|
+
# Calculates hash code according to all attributes.
|
292
|
+
# @return [Fixnum] Hash code
|
293
|
+
def hash
|
294
|
+
[id, event_type, opened_at, ended_at, closed_at, employee_ids, opening_employee_id, ending_employee_id, closing_employee_id, description, starting_cash_money, cash_payment_money, cash_refunds_money, cash_paid_in_money, cash_paid_out_money, expected_cash_money, closed_cash_money, device, events].hash
|
295
|
+
end
|
296
|
+
|
297
|
+
# Builds the object from hash
|
298
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
299
|
+
# @return [Object] Returns the model itself
|
300
|
+
def build_from_hash(attributes)
|
301
|
+
return nil unless attributes.is_a?(Hash)
|
302
|
+
self.class.swagger_types.each_pair do |key, type|
|
303
|
+
if type =~ /\AArray<(.*)>/i
|
304
|
+
# check to ensure the input is an array given that the the attribute
|
305
|
+
# is documented as an array but the input is not
|
306
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
307
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
308
|
+
end
|
309
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
310
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
311
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
312
|
+
end
|
313
|
+
|
314
|
+
self
|
315
|
+
end
|
316
|
+
|
317
|
+
# Deserializes the data based on type
|
318
|
+
# @param string type Data type
|
319
|
+
# @param string value Value to be deserialized
|
320
|
+
# @return [Object] Deserialized data
|
321
|
+
def _deserialize(type, value)
|
322
|
+
case type.to_sym
|
323
|
+
when :DateTime
|
324
|
+
DateTime.parse(value)
|
325
|
+
when :Date
|
326
|
+
Date.parse(value)
|
327
|
+
when :String
|
328
|
+
value.to_s
|
329
|
+
when :Integer
|
330
|
+
value.to_i
|
331
|
+
when :Float
|
332
|
+
value.to_f
|
333
|
+
when :BOOLEAN
|
334
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
335
|
+
true
|
336
|
+
else
|
337
|
+
false
|
338
|
+
end
|
339
|
+
when :Object
|
340
|
+
# generic object (usually a Hash), return directly
|
341
|
+
value
|
342
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
343
|
+
inner_type = Regexp.last_match[:inner_type]
|
344
|
+
value.map { |v| _deserialize(inner_type, v) }
|
345
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
346
|
+
k_type = Regexp.last_match[:k_type]
|
347
|
+
v_type = Regexp.last_match[:v_type]
|
348
|
+
{}.tap do |hash|
|
349
|
+
value.each do |k, v|
|
350
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
else # model
|
354
|
+
temp_model = SquareConnect.const_get(type).new
|
355
|
+
temp_model.build_from_hash(value)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
# Returns the string representation of the object
|
360
|
+
# @return [String] String presentation of the object
|
361
|
+
def to_s
|
362
|
+
to_hash.to_s
|
363
|
+
end
|
364
|
+
|
365
|
+
# to_body is an alias to to_hash (backward compatibility)
|
366
|
+
# @return [Hash] Returns the object in the form of hash
|
367
|
+
def to_body
|
368
|
+
to_hash
|
369
|
+
end
|
370
|
+
|
371
|
+
# Returns the object in the form of hash
|
372
|
+
# @return [Hash] Returns the object in the form of hash
|
373
|
+
def to_hash
|
374
|
+
hash = {}
|
375
|
+
self.class.attribute_map.each_pair do |attr, param|
|
376
|
+
value = self.send(attr)
|
377
|
+
next if value.nil?
|
378
|
+
hash[param] = _to_hash(value)
|
379
|
+
end
|
380
|
+
hash
|
381
|
+
end
|
382
|
+
|
383
|
+
# Outputs non-array value in the form of hash
|
384
|
+
# For object, use to_hash. Otherwise, just return the value
|
385
|
+
# @param [Object] value Any valid value
|
386
|
+
# @return [Hash] Returns the value in the form of hash
|
387
|
+
def _to_hash(value)
|
388
|
+
if value.is_a?(Array)
|
389
|
+
value.compact.map{ |v| _to_hash(v) }
|
390
|
+
elsif value.is_a?(Hash)
|
391
|
+
{}.tap do |hash|
|
392
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
393
|
+
end
|
394
|
+
elsif value.respond_to? :to_hash
|
395
|
+
value.to_hash
|
396
|
+
else
|
397
|
+
value
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
end
|
402
|
+
|
403
|
+
end
|