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.
Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +133 -21
  3. data/docs/ChargeRequest.md +1 -1
  4. data/docs/CheckoutApi.md +8 -6
  5. data/docs/CustomersApi.md +389 -0
  6. data/docs/Device.md +11 -0
  7. data/docs/LocationsApi.md +55 -0
  8. data/docs/TransactionsApi.md +417 -0
  9. data/docs/V1AdjustInventoryRequest.md +12 -0
  10. data/docs/V1BankAccount.md +17 -0
  11. data/docs/V1CashDrawerEvent.md +15 -0
  12. data/docs/V1CashDrawerShift.md +28 -0
  13. data/docs/V1Category.md +11 -0
  14. data/docs/V1CreateRefundRequest.md +14 -0
  15. data/docs/V1Discount.md +16 -0
  16. data/docs/V1Employee.md +21 -0
  17. data/docs/V1EmployeeRole.md +15 -0
  18. data/docs/V1EmployeesApi.md +915 -0
  19. data/docs/V1Fee.md +18 -0
  20. data/docs/V1InventoryEntry.md +11 -0
  21. data/docs/V1Item.md +23 -0
  22. data/docs/V1ItemImage.md +11 -0
  23. data/docs/V1ItemsApi.md +2297 -0
  24. data/docs/V1LocationApi.md +102 -0
  25. data/docs/V1LocationsApi.md +102 -0
  26. data/docs/V1Merchant.md +26 -0
  27. data/docs/V1MerchantLocationDetails.md +12 -0
  28. data/docs/V1ModifierList.md +13 -0
  29. data/docs/V1ModifierOption.md +15 -0
  30. data/docs/V1Money.md +13 -0
  31. data/docs/V1Order.md +34 -0
  32. data/docs/V1OrderHistoryEntry.md +11 -0
  33. data/docs/V1Page.md +13 -0
  34. data/docs/V1PageCell.md +15 -0
  35. data/docs/V1Payment.md +33 -0
  36. data/docs/V1PaymentDiscount.md +12 -0
  37. data/docs/V1PaymentItemDetail.md +13 -0
  38. data/docs/V1PaymentItemization.md +23 -0
  39. data/docs/V1PaymentModifier.md +12 -0
  40. data/docs/V1PaymentTax.md +15 -0
  41. data/docs/V1PhoneNumber.md +13 -0
  42. data/docs/V1Refund.md +16 -0
  43. data/docs/V1Settlement.md +15 -0
  44. data/docs/V1SettlementEntry.md +13 -0
  45. data/docs/V1Tender.md +22 -0
  46. data/docs/V1Timecard.md +20 -0
  47. data/docs/V1TimecardEvent.md +14 -0
  48. data/docs/V1TransactionsApi.md +650 -0
  49. data/docs/V1UpdateModifierListRequest.md +11 -0
  50. data/docs/V1UpdateOrderRequest.md +14 -0
  51. data/docs/V1Variation.md +20 -0
  52. data/lib/.DS_Store +0 -0
  53. data/lib/square_connect.rb +46 -5
  54. data/lib/square_connect/.DS_Store +0 -0
  55. data/lib/square_connect/api/checkout_api.rb +4 -9
  56. data/lib/square_connect/api/{customer_api.rb → customers_api.rb} +150 -61
  57. data/lib/square_connect/api/{location_api.rb → locations_api.rb} +7 -12
  58. data/lib/square_connect/api/{transaction_api.rb → transactions_api.rb} +169 -65
  59. data/lib/square_connect/api/v1_employees_api.rb +974 -0
  60. data/lib/square_connect/api/v1_items_api.rb +2365 -0
  61. data/lib/square_connect/api/v1_locations_api.rb +118 -0
  62. data/lib/square_connect/api/v1_transactions_api.rb +707 -0
  63. data/lib/square_connect/api_client.rb +1 -1
  64. data/lib/square_connect/models/charge_request.rb +1 -1
  65. data/lib/square_connect/models/device.rb +196 -0
  66. data/lib/square_connect/models/v1_adjust_inventory_request.rb +206 -0
  67. data/lib/square_connect/models/v1_bank_account.rb +289 -0
  68. data/lib/square_connect/models/v1_cash_drawer_event.rb +269 -0
  69. data/lib/square_connect/models/v1_cash_drawer_shift.rb +403 -0
  70. data/lib/square_connect/models/v1_category.rb +196 -0
  71. data/lib/square_connect/models/v1_create_refund_request.rb +274 -0
  72. data/lib/square_connect/models/v1_discount.rb +291 -0
  73. data/lib/square_connect/models/v1_employee.rb +323 -0
  74. data/lib/square_connect/models/v1_employee_role.rb +269 -0
  75. data/lib/square_connect/models/v1_fee.rb +335 -0
  76. data/lib/square_connect/models/v1_inventory_entry.rb +196 -0
  77. data/lib/square_connect/models/v1_item.rb +379 -0
  78. data/lib/square_connect/models/v1_item_image.rb +196 -0
  79. data/lib/square_connect/models/v1_merchant.rb +372 -0
  80. data/lib/square_connect/models/v1_merchant_location_details.rb +186 -0
  81. data/lib/square_connect/models/v1_modifier_list.rb +251 -0
  82. data/lib/square_connect/models/v1_modifier_option.rb +236 -0
  83. data/lib/square_connect/models/v1_money.rb +229 -0
  84. data/lib/square_connect/models/v1_order.rb +463 -0
  85. data/lib/square_connect/models/v1_order_history_entry.rb +229 -0
  86. data/lib/square_connect/models/v1_page.rb +218 -0
  87. data/lib/square_connect/models/v1_page_cell.rb +261 -0
  88. data/lib/square_connect/models/v1_payment.rb +423 -0
  89. data/lib/square_connect/models/v1_payment_discount.rb +206 -0
  90. data/lib/square_connect/models/v1_payment_item_detail.rb +216 -0
  91. data/lib/square_connect/models/v1_payment_itemization.rb +355 -0
  92. data/lib/square_connect/models/v1_payment_modifier.rb +206 -0
  93. data/lib/square_connect/models/v1_payment_tax.rb +271 -0
  94. data/lib/square_connect/models/v1_phone_number.rb +206 -0
  95. data/lib/square_connect/models/v1_refund.rb +279 -0
  96. data/lib/square_connect/models/v1_settlement.rb +271 -0
  97. data/lib/square_connect/models/v1_settlement_entry.rb +249 -0
  98. data/lib/square_connect/models/v1_tender.rb +363 -0
  99. data/lib/square_connect/models/v1_timecard.rb +271 -0
  100. data/lib/square_connect/models/v1_timecard_event.rb +259 -0
  101. data/lib/square_connect/models/v1_update_modifier_list_request.rb +229 -0
  102. data/lib/square_connect/models/v1_update_order_request.rb +264 -0
  103. data/lib/square_connect/models/v1_variation.rb +331 -0
  104. data/lib/square_connect/version.rb +1 -1
  105. data/spec/.DS_Store +0 -0
  106. data/spec/api/checkout_api_spec.rb +4 -12
  107. data/spec/api/{customer_api_spec.rb → customers_api_spec.rb} +39 -41
  108. data/spec/api/{location_api_spec.rb → locations_api_spec.rb} +9 -15
  109. data/spec/api/{transaction_api_spec.rb → transactions_api_spec.rb} +43 -41
  110. data/spec/api/v1_employees_api_spec.rb +250 -0
  111. data/spec/api/v1_items_api_spec.rb +568 -0
  112. data/spec/api/v1_locations_api_spec.rb +54 -0
  113. data/spec/api/v1_transactions_api_spec.rb +186 -0
  114. data/spec/models/address_spec.rb +22 -81
  115. data/spec/models/capture_transaction_request_spec.rb +3 -6
  116. data/spec/models/capture_transaction_response_spec.rb +4 -11
  117. data/spec/models/card_brand_spec.rb +3 -6
  118. data/spec/models/card_spec.rb +14 -41
  119. data/spec/models/charge_request_spec.rb +14 -61
  120. data/spec/models/charge_response_spec.rb +5 -16
  121. data/spec/models/checkout_spec.rb +12 -51
  122. data/spec/models/country_spec.rb +3 -6
  123. data/spec/models/create_checkout_request_spec.rb +10 -41
  124. data/spec/models/create_checkout_response_spec.rb +5 -16
  125. data/spec/models/create_customer_card_request_spec.rb +6 -21
  126. data/spec/models/create_customer_card_response_spec.rb +5 -16
  127. data/spec/models/create_customer_request_spec.rb +12 -51
  128. data/spec/models/create_customer_response_spec.rb +5 -16
  129. data/spec/models/create_order_request_line_item_spec.rb +6 -21
  130. data/spec/models/create_order_request_order_spec.rb +5 -16
  131. data/spec/models/create_order_request_spec.rb +5 -16
  132. data/spec/models/create_refund_request_spec.rb +7 -26
  133. data/spec/models/create_refund_response_spec.rb +5 -16
  134. data/spec/models/currency_spec.rb +3 -6
  135. data/spec/models/customer_group_info_spec.rb +5 -16
  136. data/spec/models/customer_preferences_spec.rb +4 -11
  137. data/spec/models/customer_spec.rb +18 -81
  138. data/spec/models/delete_customer_card_request_spec.rb +3 -6
  139. data/spec/models/delete_customer_card_response_spec.rb +4 -11
  140. data/spec/models/delete_customer_request_spec.rb +3 -6
  141. data/spec/models/delete_customer_response_spec.rb +4 -11
  142. data/spec/models/device_spec.rb +45 -0
  143. data/spec/models/error_category_spec.rb +3 -6
  144. data/spec/models/error_code_spec.rb +3 -6
  145. data/spec/models/error_spec.rb +15 -26
  146. data/spec/models/list_customers_request_spec.rb +4 -11
  147. data/spec/models/list_customers_response_spec.rb +6 -21
  148. data/spec/models/list_locations_request_spec.rb +3 -6
  149. data/spec/models/list_locations_response_spec.rb +5 -16
  150. data/spec/models/list_refunds_request_spec.rb +11 -26
  151. data/spec/models/list_refunds_response_spec.rb +6 -21
  152. data/spec/models/list_transactions_request_spec.rb +11 -26
  153. data/spec/models/list_transactions_response_spec.rb +6 -21
  154. data/spec/models/location_capability_spec.rb +3 -6
  155. data/spec/models/location_spec.rb +12 -31
  156. data/spec/models/money_spec.rb +9 -16
  157. data/spec/models/order_line_item_spec.rb +8 -31
  158. data/spec/models/order_spec.rb +8 -31
  159. data/spec/models/refund_spec.rb +16 -51
  160. data/spec/models/refund_status_spec.rb +3 -6
  161. data/spec/models/retrieve_customer_request_spec.rb +3 -6
  162. data/spec/models/retrieve_customer_response_spec.rb +5 -16
  163. data/spec/models/retrieve_transaction_request_spec.rb +3 -6
  164. data/spec/models/retrieve_transaction_response_spec.rb +5 -16
  165. data/spec/models/sort_order_spec.rb +3 -6
  166. data/spec/models/tender_card_details_entry_method_spec.rb +3 -6
  167. data/spec/models/tender_card_details_spec.rb +14 -21
  168. data/spec/models/tender_card_details_status_spec.rb +3 -6
  169. data/spec/models/tender_cash_details_spec.rb +5 -16
  170. data/spec/models/tender_spec.rb +18 -61
  171. data/spec/models/tender_type_spec.rb +3 -6
  172. data/spec/models/transaction_product_spec.rb +3 -6
  173. data/spec/models/transaction_spec.rb +17 -56
  174. data/spec/models/update_customer_request_spec.rb +12 -51
  175. data/spec/models/update_customer_response_spec.rb +5 -16
  176. data/spec/models/v1_adjust_inventory_request_spec.rb +51 -0
  177. data/spec/models/v1_bank_account_spec.rb +85 -0
  178. data/spec/models/v1_cash_drawer_event_spec.rb +73 -0
  179. data/spec/models/v1_cash_drawer_shift_spec.rb +151 -0
  180. data/spec/models/v1_category_spec.rb +45 -0
  181. data/spec/models/v1_create_refund_request_spec.rb +67 -0
  182. data/spec/models/v1_discount_spec.rb +83 -0
  183. data/spec/models/v1_employee_role_spec.rb +73 -0
  184. data/spec/models/v1_employee_spec.rb +97 -0
  185. data/spec/models/v1_fee_spec.rb +103 -0
  186. data/spec/models/v1_inventory_entry_spec.rb +45 -0
  187. data/spec/models/v1_item_image_spec.rb +45 -0
  188. data/spec/models/v1_item_spec.rb +129 -0
  189. data/spec/models/v1_merchant_location_details_spec.rb +39 -0
  190. data/spec/models/v1_merchant_spec.rb +131 -0
  191. data/spec/models/v1_modifier_list_spec.rb +61 -0
  192. data/spec/models/v1_modifier_option_spec.rb +69 -0
  193. data/spec/models/v1_money_spec.rb +49 -0
  194. data/spec/models/v1_order_history_entry_spec.rb +49 -0
  195. data/spec/models/v1_order_spec.rb +187 -0
  196. data/spec/models/v1_page_cell_spec.rb +77 -0
  197. data/spec/models/v1_page_spec.rb +57 -0
  198. data/spec/models/v1_payment_discount_spec.rb +51 -0
  199. data/spec/models/v1_payment_item_detail_spec.rb +57 -0
  200. data/spec/models/v1_payment_itemization_spec.rb +121 -0
  201. data/spec/models/v1_payment_modifier_spec.rb +51 -0
  202. data/spec/models/v1_payment_spec.rb +177 -0
  203. data/spec/models/v1_payment_tax_spec.rb +73 -0
  204. data/spec/models/v1_phone_number_spec.rb +45 -0
  205. data/spec/models/v1_refund_spec.rb +79 -0
  206. data/spec/models/v1_settlement_entry_spec.rb +61 -0
  207. data/spec/models/v1_settlement_spec.rb +73 -0
  208. data/spec/models/v1_tender_spec.rb +123 -0
  209. data/spec/models/v1_timecard_event_spec.rb +67 -0
  210. data/spec/models/v1_timecard_spec.rb +87 -0
  211. data/spec/models/v1_update_modifier_list_request_spec.rb +49 -0
  212. data/spec/models/v1_update_order_request_spec.rb +67 -0
  213. data/spec/models/v1_variation_spec.rb +107 -0
  214. data/spec/models/void_transaction_request_spec.rb +3 -6
  215. data/spec/models/void_transaction_response_spec.rb +4 -11
  216. data/spec/spec_helper.rb +10 -0
  217. data/square_connect-2.0.2.gem +0 -0
  218. data/square_connect-2.1.0.gem +0 -0
  219. data/square_connect-2.1.0beta.gem +0 -0
  220. data/square_connect.gemspec +1 -1
  221. data/travis-ci/accounts.enc +0 -0
  222. metadata +197 -26
  223. data/docs/CustomerApi.md +0 -267
  224. data/docs/CustomerCardApi.md +0 -116
  225. data/docs/LocationApi.md +0 -56
  226. data/docs/RefundApi.md +0 -126
  227. data/docs/TransactionApi.md +0 -285
  228. data/lib/square_connect/api/customer_card_api.rb +0 -144
  229. data/lib/square_connect/api/refund_api.rb +0 -159
  230. data/spec/api/customer_card_api_spec.rb +0 -71
  231. 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