square_connect 2.20180712.2.237 → 2.20180918.0.244
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +20 -1
- data/README.md +33 -1
- data/docs/BatchChangeInventoryRequest.md +14 -0
- data/docs/BatchChangeInventoryResponse.md +13 -0
- data/docs/BatchRetrieveInventoryChangesRequest.md +18 -0
- data/docs/BatchRetrieveInventoryChangesResponse.md +14 -0
- data/docs/BatchRetrieveInventoryCountsRequest.md +15 -0
- data/docs/BatchRetrieveInventoryCountsResponse.md +14 -0
- data/docs/Card.md +1 -1
- data/docs/CreateCustomerRequest.md +1 -0
- data/docs/Customer.md +1 -0
- data/docs/CustomersApi.md +2 -2
- data/docs/ErrorCode.md +2 -0
- data/docs/InventoryAdjustment.md +28 -0
- data/docs/InventoryApi.md +391 -0
- data/docs/InventoryChange.md +15 -0
- data/docs/InventoryChangeType.md +14 -0
- data/docs/InventoryCount.md +17 -0
- data/docs/InventoryPhysicalCount.md +22 -0
- data/docs/InventoryState.md +23 -0
- data/docs/InventoryTransfer.md +23 -0
- data/docs/Product.md +19 -0
- data/docs/RetrieveInventoryAdjustmentRequest.md +11 -0
- data/docs/RetrieveInventoryAdjustmentResponse.md +13 -0
- data/docs/RetrieveInventoryChangesRequest.md +13 -0
- data/docs/RetrieveInventoryChangesResponse.md +14 -0
- data/docs/RetrieveInventoryCountRequest.md +13 -0
- data/docs/RetrieveInventoryCountResponse.md +14 -0
- data/docs/RetrieveInventoryPhysicalCountRequest.md +11 -0
- data/docs/RetrieveInventoryPhysicalCountResponse.md +13 -0
- data/docs/SourceApplication.md +14 -0
- data/docs/TransactionsApi.md +1 -1
- data/docs/UpdateCustomerRequest.md +1 -0
- data/docs/V1Timecard.md +4 -1
- data/lib/square_connect.rb +24 -0
- data/lib/square_connect/api/apple_pay_api.rb +1 -1
- data/lib/square_connect/api/catalog_api.rb +11 -11
- data/lib/square_connect/api/checkout_api.rb +1 -1
- data/lib/square_connect/api/customers_api.rb +12 -12
- data/lib/square_connect/api/inventory_api.rb +417 -0
- data/lib/square_connect/api/locations_api.rb +1 -1
- data/lib/square_connect/api/mobile_authorization_api.rb +1 -1
- data/lib/square_connect/api/o_auth_api.rb +3 -3
- data/lib/square_connect/api/orders_api.rb +2 -2
- data/lib/square_connect/api/reporting_api.rb +2 -2
- data/lib/square_connect/api/transactions_api.rb +9 -9
- data/lib/square_connect/api_client.rb +1 -1
- data/lib/square_connect/models/batch_change_inventory_request.rb +208 -0
- data/lib/square_connect/models/batch_change_inventory_response.rb +200 -0
- data/lib/square_connect/models/batch_retrieve_inventory_changes_request.rb +275 -0
- data/lib/square_connect/models/batch_retrieve_inventory_changes_response.rb +210 -0
- data/lib/square_connect/models/batch_retrieve_inventory_counts_request.rb +220 -0
- data/lib/square_connect/models/batch_retrieve_inventory_counts_response.rb +210 -0
- data/lib/square_connect/models/card.rb +1 -1
- data/lib/square_connect/models/create_customer_request.rb +14 -4
- data/lib/square_connect/models/customer.rb +11 -1
- data/lib/square_connect/models/error.rb +2 -2
- data/lib/square_connect/models/error_code.rb +2 -0
- data/lib/square_connect/models/inventory_adjustment.rb +391 -0
- data/lib/square_connect/models/inventory_change.rb +249 -0
- data/lib/square_connect/models/inventory_change_type.rb +20 -0
- data/lib/square_connect/models/inventory_count.rb +269 -0
- data/lib/square_connect/models/inventory_physical_count.rb +319 -0
- data/lib/square_connect/models/inventory_state.rb +29 -0
- data/lib/square_connect/models/inventory_transfer.rb +329 -0
- data/lib/square_connect/models/money.rb +0 -9
- data/lib/square_connect/models/product.rb +25 -0
- data/lib/square_connect/models/retrieve_inventory_adjustment_request.rb +176 -0
- data/lib/square_connect/models/retrieve_inventory_adjustment_response.rb +198 -0
- data/lib/square_connect/models/retrieve_inventory_changes_request.rb +196 -0
- data/lib/square_connect/models/retrieve_inventory_changes_response.rb +210 -0
- data/lib/square_connect/models/retrieve_inventory_count_request.rb +196 -0
- data/lib/square_connect/models/retrieve_inventory_count_response.rb +210 -0
- data/lib/square_connect/models/retrieve_inventory_physical_count_request.rb +176 -0
- data/lib/square_connect/models/retrieve_inventory_physical_count_response.rb +198 -0
- data/lib/square_connect/models/source_application.rb +239 -0
- data/lib/square_connect/models/update_customer_request.rb +14 -4
- data/lib/square_connect/models/v1_timecard.rb +35 -5
- data/lib/square_connect/version.rb +1 -1
- data/spec/api/inventory_api_spec.rb +120 -0
- data/spec/models/batch_change_inventory_request_spec.rb +51 -0
- data/spec/models/batch_change_inventory_response_spec.rb +45 -0
- data/spec/models/batch_retrieve_inventory_changes_request_spec.rb +83 -0
- data/spec/models/batch_retrieve_inventory_changes_response_spec.rb +51 -0
- data/spec/models/batch_retrieve_inventory_counts_request_spec.rb +57 -0
- data/spec/models/batch_retrieve_inventory_counts_response_spec.rb +51 -0
- data/spec/models/inventory_adjustment_spec.rb +143 -0
- data/spec/models/inventory_change_spec.rb +61 -0
- data/spec/models/inventory_change_type_spec.rb +33 -0
- data/spec/models/inventory_count_spec.rb +73 -0
- data/spec/models/inventory_physical_count_spec.rb +103 -0
- data/spec/models/inventory_state_spec.rb +33 -0
- data/spec/models/inventory_transfer_spec.rb +109 -0
- data/spec/models/product_spec.rb +33 -0
- data/spec/models/retrieve_inventory_adjustment_request_spec.rb +33 -0
- data/spec/models/retrieve_inventory_adjustment_response_spec.rb +45 -0
- data/spec/models/retrieve_inventory_changes_request_spec.rb +45 -0
- data/spec/models/retrieve_inventory_changes_response_spec.rb +51 -0
- data/spec/models/retrieve_inventory_count_request_spec.rb +45 -0
- data/spec/models/retrieve_inventory_count_response_spec.rb +51 -0
- data/spec/models/retrieve_inventory_physical_count_request_spec.rb +33 -0
- data/spec/models/retrieve_inventory_physical_count_response_spec.rb +45 -0
- data/spec/models/source_application_spec.rb +55 -0
- metadata +99 -3
@@ -0,0 +1,319 @@
|
|
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 a verified (re)count of items in a given state at a specific location. For example, the quantity of items currently on hand at a physical store).
|
14
|
+
class InventoryPhysicalCount
|
15
|
+
# A unique ID generated by Square for the [InventoryPhysicalCount](#type-inventoryphysicalcount).
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# An optional ID provided by the application to tie the [InventoryPhysicalCount](#type-inventoryphysicalcount) to an external system.
|
19
|
+
attr_accessor :reference_id
|
20
|
+
|
21
|
+
# The Square generated ID of the [CatalogObject](#type-catalogobject) being tracked.
|
22
|
+
attr_accessor :catalog_object_id
|
23
|
+
|
24
|
+
# The [CatalogObjectType](#type-catalogobjecttype) of the [CatalogObject](#type-catalogobject) being tracked. Tracking is only supported for the `ITEM_VARIATION` type.
|
25
|
+
attr_accessor :catalog_object_type
|
26
|
+
|
27
|
+
# The current [InventoryState](#type-inventorystate) for the related quantity of items.
|
28
|
+
attr_accessor :state
|
29
|
+
|
30
|
+
# The Square ID of the [Location](#type-location) where the related quantity of items are being tracked.
|
31
|
+
attr_accessor :location_id
|
32
|
+
|
33
|
+
# The number of items affected by the physical count as a decimal string. Fractional quantities are not supported.
|
34
|
+
attr_accessor :quantity
|
35
|
+
|
36
|
+
# Read-only information about the application that submitted the physical count.
|
37
|
+
attr_accessor :source
|
38
|
+
|
39
|
+
# The Square ID of the [Employee](#type-employee) responsible for the physical count.
|
40
|
+
attr_accessor :employee_id
|
41
|
+
|
42
|
+
# A client-generated timestamp in RFC 3339 format that indicates when the physical count took place. For write actions, the `occurred_at` timestamp cannot be older than 24 hours or in the future relative to the time of the request.
|
43
|
+
attr_accessor :occurred_at
|
44
|
+
|
45
|
+
# A read-only timestamp in RFC 3339 format that indicates when Square received the physical count.
|
46
|
+
attr_accessor :created_at
|
47
|
+
|
48
|
+
class EnumAttributeValidator
|
49
|
+
attr_reader :datatype
|
50
|
+
attr_reader :allowable_values
|
51
|
+
|
52
|
+
def initialize(datatype, allowable_values)
|
53
|
+
@allowable_values = allowable_values.map do |value|
|
54
|
+
case datatype.to_s
|
55
|
+
when /Integer/i
|
56
|
+
value.to_i
|
57
|
+
when /Float/i
|
58
|
+
value.to_f
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def valid?(value)
|
66
|
+
!value || allowable_values.include?(value)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
71
|
+
def self.attribute_map
|
72
|
+
{
|
73
|
+
:'id' => :'id',
|
74
|
+
:'reference_id' => :'reference_id',
|
75
|
+
:'catalog_object_id' => :'catalog_object_id',
|
76
|
+
:'catalog_object_type' => :'catalog_object_type',
|
77
|
+
:'state' => :'state',
|
78
|
+
:'location_id' => :'location_id',
|
79
|
+
:'quantity' => :'quantity',
|
80
|
+
:'source' => :'source',
|
81
|
+
:'employee_id' => :'employee_id',
|
82
|
+
:'occurred_at' => :'occurred_at',
|
83
|
+
:'created_at' => :'created_at'
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
# Attribute type mapping.
|
88
|
+
def self.swagger_types
|
89
|
+
{
|
90
|
+
:'id' => :'String',
|
91
|
+
:'reference_id' => :'String',
|
92
|
+
:'catalog_object_id' => :'String',
|
93
|
+
:'catalog_object_type' => :'String',
|
94
|
+
:'state' => :'String',
|
95
|
+
:'location_id' => :'String',
|
96
|
+
:'quantity' => :'String',
|
97
|
+
:'source' => :'SourceApplication',
|
98
|
+
:'employee_id' => :'String',
|
99
|
+
:'occurred_at' => :'String',
|
100
|
+
:'created_at' => :'String'
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
# Initializes the object
|
105
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
106
|
+
def initialize(attributes = {})
|
107
|
+
return unless attributes.is_a?(Hash)
|
108
|
+
|
109
|
+
# convert string to symbol for hash key
|
110
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
111
|
+
|
112
|
+
if attributes.has_key?(:'id')
|
113
|
+
self.id = attributes[:'id']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.has_key?(:'reference_id')
|
117
|
+
self.reference_id = attributes[:'reference_id']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.has_key?(:'catalog_object_id')
|
121
|
+
self.catalog_object_id = attributes[:'catalog_object_id']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.has_key?(:'catalog_object_type')
|
125
|
+
self.catalog_object_type = attributes[:'catalog_object_type']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.has_key?(:'state')
|
129
|
+
self.state = attributes[:'state']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.has_key?(:'location_id')
|
133
|
+
self.location_id = attributes[:'location_id']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.has_key?(:'quantity')
|
137
|
+
self.quantity = attributes[:'quantity']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.has_key?(:'source')
|
141
|
+
self.source = attributes[:'source']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.has_key?(:'employee_id')
|
145
|
+
self.employee_id = attributes[:'employee_id']
|
146
|
+
end
|
147
|
+
|
148
|
+
if attributes.has_key?(:'occurred_at')
|
149
|
+
self.occurred_at = attributes[:'occurred_at']
|
150
|
+
end
|
151
|
+
|
152
|
+
if attributes.has_key?(:'created_at')
|
153
|
+
self.created_at = attributes[:'created_at']
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
159
|
+
# @return Array for valid properies with the reasons
|
160
|
+
def list_invalid_properties
|
161
|
+
invalid_properties = Array.new
|
162
|
+
return invalid_properties
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check to see if the all the properties in the model are valid
|
166
|
+
# @return true if the model is valid
|
167
|
+
def valid?
|
168
|
+
state_validator = EnumAttributeValidator.new('String', ["CUSTOM", "IN_STOCK", "SOLD", "RETURNED_BY_CUSTOMER", "RESERVED_FOR_SALE", "SOLD_ONLINE", "ORDERED_FROM_VENDOR", "RECEIVED_FROM_VENDOR", "IN_TRANSIT_TO", "NONE", "WASTE", "UNLINKED_RETURN"])
|
169
|
+
return false unless state_validator.valid?(@state)
|
170
|
+
return true
|
171
|
+
end
|
172
|
+
|
173
|
+
# Custom attribute writer method checking allowed values (enum).
|
174
|
+
# @param [Object] state Object to be assigned
|
175
|
+
def state=(state)
|
176
|
+
validator = EnumAttributeValidator.new('String', ["CUSTOM", "IN_STOCK", "SOLD", "RETURNED_BY_CUSTOMER", "RESERVED_FOR_SALE", "SOLD_ONLINE", "ORDERED_FROM_VENDOR", "RECEIVED_FROM_VENDOR", "IN_TRANSIT_TO", "NONE", "WASTE", "UNLINKED_RETURN"])
|
177
|
+
unless validator.valid?(state)
|
178
|
+
fail ArgumentError, "invalid value for 'state', must be one of #{validator.allowable_values}."
|
179
|
+
end
|
180
|
+
@state = state
|
181
|
+
end
|
182
|
+
|
183
|
+
# Checks equality by comparing each attribute.
|
184
|
+
# @param [Object] Object to be compared
|
185
|
+
def ==(o)
|
186
|
+
return true if self.equal?(o)
|
187
|
+
self.class == o.class &&
|
188
|
+
id == o.id &&
|
189
|
+
reference_id == o.reference_id &&
|
190
|
+
catalog_object_id == o.catalog_object_id &&
|
191
|
+
catalog_object_type == o.catalog_object_type &&
|
192
|
+
state == o.state &&
|
193
|
+
location_id == o.location_id &&
|
194
|
+
quantity == o.quantity &&
|
195
|
+
source == o.source &&
|
196
|
+
employee_id == o.employee_id &&
|
197
|
+
occurred_at == o.occurred_at &&
|
198
|
+
created_at == o.created_at
|
199
|
+
end
|
200
|
+
|
201
|
+
# @see the `==` method
|
202
|
+
# @param [Object] Object to be compared
|
203
|
+
def eql?(o)
|
204
|
+
self == o
|
205
|
+
end
|
206
|
+
|
207
|
+
# Calculates hash code according to all attributes.
|
208
|
+
# @return [Fixnum] Hash code
|
209
|
+
def hash
|
210
|
+
[id, reference_id, catalog_object_id, catalog_object_type, state, location_id, quantity, source, employee_id, occurred_at, created_at].hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Builds the object from hash
|
214
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
215
|
+
# @return [Object] Returns the model itself
|
216
|
+
def build_from_hash(attributes)
|
217
|
+
return nil unless attributes.is_a?(Hash)
|
218
|
+
self.class.swagger_types.each_pair do |key, type|
|
219
|
+
if type =~ /\AArray<(.*)>/i
|
220
|
+
# check to ensure the input is an array given that the the attribute
|
221
|
+
# is documented as an array but the input is not
|
222
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
223
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
224
|
+
end
|
225
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
226
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
227
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
228
|
+
end
|
229
|
+
|
230
|
+
self
|
231
|
+
end
|
232
|
+
|
233
|
+
# Deserializes the data based on type
|
234
|
+
# @param string type Data type
|
235
|
+
# @param string value Value to be deserialized
|
236
|
+
# @return [Object] Deserialized data
|
237
|
+
def _deserialize(type, value)
|
238
|
+
case type.to_sym
|
239
|
+
when :DateTime
|
240
|
+
DateTime.parse(value)
|
241
|
+
when :Date
|
242
|
+
Date.parse(value)
|
243
|
+
when :String
|
244
|
+
value.to_s
|
245
|
+
when :Integer
|
246
|
+
value.to_i
|
247
|
+
when :Float
|
248
|
+
value.to_f
|
249
|
+
when :BOOLEAN
|
250
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
251
|
+
true
|
252
|
+
else
|
253
|
+
false
|
254
|
+
end
|
255
|
+
when :Object
|
256
|
+
# generic object (usually a Hash), return directly
|
257
|
+
value
|
258
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
259
|
+
inner_type = Regexp.last_match[:inner_type]
|
260
|
+
value.map { |v| _deserialize(inner_type, v) }
|
261
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
262
|
+
k_type = Regexp.last_match[:k_type]
|
263
|
+
v_type = Regexp.last_match[:v_type]
|
264
|
+
{}.tap do |hash|
|
265
|
+
value.each do |k, v|
|
266
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
else # model
|
270
|
+
temp_model = SquareConnect.const_get(type).new
|
271
|
+
temp_model.build_from_hash(value)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
# Returns the string representation of the object
|
276
|
+
# @return [String] String presentation of the object
|
277
|
+
def to_s
|
278
|
+
to_hash.to_s
|
279
|
+
end
|
280
|
+
|
281
|
+
# to_body is an alias to to_hash (backward compatibility)
|
282
|
+
# @return [Hash] Returns the object in the form of hash
|
283
|
+
def to_body
|
284
|
+
to_hash
|
285
|
+
end
|
286
|
+
|
287
|
+
# Returns the object in the form of hash
|
288
|
+
# @return [Hash] Returns the object in the form of hash
|
289
|
+
def to_hash
|
290
|
+
hash = {}
|
291
|
+
self.class.attribute_map.each_pair do |attr, param|
|
292
|
+
value = self.send(attr)
|
293
|
+
next if value.nil?
|
294
|
+
hash[param] = _to_hash(value)
|
295
|
+
end
|
296
|
+
hash
|
297
|
+
end
|
298
|
+
|
299
|
+
# Outputs non-array value in the form of hash
|
300
|
+
# For object, use to_hash. Otherwise, just return the value
|
301
|
+
# @param [Object] value Any valid value
|
302
|
+
# @return [Hash] Returns the value in the form of hash
|
303
|
+
def _to_hash(value)
|
304
|
+
if value.is_a?(Array)
|
305
|
+
value.compact.map{ |v| _to_hash(v) }
|
306
|
+
elsif value.is_a?(Hash)
|
307
|
+
{}.tap do |hash|
|
308
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
309
|
+
end
|
310
|
+
elsif value.respond_to? :to_hash
|
311
|
+
value.to_hash
|
312
|
+
else
|
313
|
+
value
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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
|
+
class InventoryState
|
14
|
+
|
15
|
+
CUSTOM = "CUSTOM".freeze
|
16
|
+
IN_STOCK = "IN_STOCK".freeze
|
17
|
+
SOLD = "SOLD".freeze
|
18
|
+
RETURNED_BY_CUSTOMER = "RETURNED_BY_CUSTOMER".freeze
|
19
|
+
RESERVED_FOR_SALE = "RESERVED_FOR_SALE".freeze
|
20
|
+
SOLD_ONLINE = "SOLD_ONLINE".freeze
|
21
|
+
ORDERED_FROM_VENDOR = "ORDERED_FROM_VENDOR".freeze
|
22
|
+
RECEIVED_FROM_VENDOR = "RECEIVED_FROM_VENDOR".freeze
|
23
|
+
IN_TRANSIT_TO = "IN_TRANSIT_TO".freeze
|
24
|
+
NONE = "NONE".freeze
|
25
|
+
WASTE = "WASTE".freeze
|
26
|
+
UNLINKED_RETURN = "UNLINKED_RETURN".freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,329 @@
|
|
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 the transfer of a quantity of product inventory at a particular time from one location to another.
|
14
|
+
class InventoryTransfer
|
15
|
+
# A unique ID generated by Square for the [InventoryTransfer](#type-inventorytransfer).
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# An optional ID provided by the application to tie the [InventoryTransfer](#type-inventorytransfer) to an external system.
|
19
|
+
attr_accessor :reference_id
|
20
|
+
|
21
|
+
# The [InventoryState](#type-inventorystate) for the quantity of items being transfered.
|
22
|
+
attr_accessor :state
|
23
|
+
|
24
|
+
# The Square ID of the [Location](#type-location) where the related quantity of items were tracked before the transfer.
|
25
|
+
attr_accessor :from_location_id
|
26
|
+
|
27
|
+
# The Square ID of the [Location](#type-location) where the related quantity of items were tracked after the transfer.
|
28
|
+
attr_accessor :to_location_id
|
29
|
+
|
30
|
+
# The Square generated ID of the [CatalogObject](#type-catalogobject) being tracked.
|
31
|
+
attr_accessor :catalog_object_id
|
32
|
+
|
33
|
+
# The [CatalogObjectType](#type-catalogobjecttype) of the [CatalogObject](#type-catalogobject) being tracked.Tracking is only supported for the `ITEM_VARIATION` type.
|
34
|
+
attr_accessor :catalog_object_type
|
35
|
+
|
36
|
+
# The number of items affected by the transfer as a decimal string. Fractional quantities are not supported.
|
37
|
+
attr_accessor :quantity
|
38
|
+
|
39
|
+
# A client-generated timestamp in RFC 3339 format that indicates when the transfer took place. For write actions, the `occurred_at` timestamp cannot be older than 24 hours or in the future relative to the time of the request.
|
40
|
+
attr_accessor :occurred_at
|
41
|
+
|
42
|
+
# A read-only timestamp in RFC 3339 format that indicates when Square received the transfer request.
|
43
|
+
attr_accessor :created_at
|
44
|
+
|
45
|
+
# Read-only information about the application that initiated the inventory transfer.
|
46
|
+
attr_accessor :source
|
47
|
+
|
48
|
+
# The Square ID of the [Employee](#type-employee) responsible for the inventory transfer.
|
49
|
+
attr_accessor :employee_id
|
50
|
+
|
51
|
+
class EnumAttributeValidator
|
52
|
+
attr_reader :datatype
|
53
|
+
attr_reader :allowable_values
|
54
|
+
|
55
|
+
def initialize(datatype, allowable_values)
|
56
|
+
@allowable_values = allowable_values.map do |value|
|
57
|
+
case datatype.to_s
|
58
|
+
when /Integer/i
|
59
|
+
value.to_i
|
60
|
+
when /Float/i
|
61
|
+
value.to_f
|
62
|
+
else
|
63
|
+
value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def valid?(value)
|
69
|
+
!value || allowable_values.include?(value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
74
|
+
def self.attribute_map
|
75
|
+
{
|
76
|
+
:'id' => :'id',
|
77
|
+
:'reference_id' => :'reference_id',
|
78
|
+
:'state' => :'state',
|
79
|
+
:'from_location_id' => :'from_location_id',
|
80
|
+
:'to_location_id' => :'to_location_id',
|
81
|
+
:'catalog_object_id' => :'catalog_object_id',
|
82
|
+
:'catalog_object_type' => :'catalog_object_type',
|
83
|
+
:'quantity' => :'quantity',
|
84
|
+
:'occurred_at' => :'occurred_at',
|
85
|
+
:'created_at' => :'created_at',
|
86
|
+
:'source' => :'source',
|
87
|
+
:'employee_id' => :'employee_id'
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
# Attribute type mapping.
|
92
|
+
def self.swagger_types
|
93
|
+
{
|
94
|
+
:'id' => :'String',
|
95
|
+
:'reference_id' => :'String',
|
96
|
+
:'state' => :'String',
|
97
|
+
:'from_location_id' => :'String',
|
98
|
+
:'to_location_id' => :'String',
|
99
|
+
:'catalog_object_id' => :'String',
|
100
|
+
:'catalog_object_type' => :'String',
|
101
|
+
:'quantity' => :'String',
|
102
|
+
:'occurred_at' => :'String',
|
103
|
+
:'created_at' => :'String',
|
104
|
+
:'source' => :'SourceApplication',
|
105
|
+
:'employee_id' => :'String'
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
# Initializes the object
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
def initialize(attributes = {})
|
112
|
+
return unless attributes.is_a?(Hash)
|
113
|
+
|
114
|
+
# convert string to symbol for hash key
|
115
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
116
|
+
|
117
|
+
if attributes.has_key?(:'id')
|
118
|
+
self.id = attributes[:'id']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'reference_id')
|
122
|
+
self.reference_id = attributes[:'reference_id']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'state')
|
126
|
+
self.state = attributes[:'state']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'from_location_id')
|
130
|
+
self.from_location_id = attributes[:'from_location_id']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.has_key?(:'to_location_id')
|
134
|
+
self.to_location_id = attributes[:'to_location_id']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.has_key?(:'catalog_object_id')
|
138
|
+
self.catalog_object_id = attributes[:'catalog_object_id']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.has_key?(:'catalog_object_type')
|
142
|
+
self.catalog_object_type = attributes[:'catalog_object_type']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.has_key?(:'quantity')
|
146
|
+
self.quantity = attributes[:'quantity']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.has_key?(:'occurred_at')
|
150
|
+
self.occurred_at = attributes[:'occurred_at']
|
151
|
+
end
|
152
|
+
|
153
|
+
if attributes.has_key?(:'created_at')
|
154
|
+
self.created_at = attributes[:'created_at']
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.has_key?(:'source')
|
158
|
+
self.source = attributes[:'source']
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.has_key?(:'employee_id')
|
162
|
+
self.employee_id = attributes[:'employee_id']
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
168
|
+
# @return Array for valid properies with the reasons
|
169
|
+
def list_invalid_properties
|
170
|
+
invalid_properties = Array.new
|
171
|
+
return invalid_properties
|
172
|
+
end
|
173
|
+
|
174
|
+
# Check to see if the all the properties in the model are valid
|
175
|
+
# @return true if the model is valid
|
176
|
+
def valid?
|
177
|
+
state_validator = EnumAttributeValidator.new('String', ["CUSTOM", "IN_STOCK", "SOLD", "RETURNED_BY_CUSTOMER", "RESERVED_FOR_SALE", "SOLD_ONLINE", "ORDERED_FROM_VENDOR", "RECEIVED_FROM_VENDOR", "IN_TRANSIT_TO", "NONE", "WASTE", "UNLINKED_RETURN"])
|
178
|
+
return false unless state_validator.valid?(@state)
|
179
|
+
return true
|
180
|
+
end
|
181
|
+
|
182
|
+
# Custom attribute writer method checking allowed values (enum).
|
183
|
+
# @param [Object] state Object to be assigned
|
184
|
+
def state=(state)
|
185
|
+
validator = EnumAttributeValidator.new('String', ["CUSTOM", "IN_STOCK", "SOLD", "RETURNED_BY_CUSTOMER", "RESERVED_FOR_SALE", "SOLD_ONLINE", "ORDERED_FROM_VENDOR", "RECEIVED_FROM_VENDOR", "IN_TRANSIT_TO", "NONE", "WASTE", "UNLINKED_RETURN"])
|
186
|
+
unless validator.valid?(state)
|
187
|
+
fail ArgumentError, "invalid value for 'state', must be one of #{validator.allowable_values}."
|
188
|
+
end
|
189
|
+
@state = state
|
190
|
+
end
|
191
|
+
|
192
|
+
# Checks equality by comparing each attribute.
|
193
|
+
# @param [Object] Object to be compared
|
194
|
+
def ==(o)
|
195
|
+
return true if self.equal?(o)
|
196
|
+
self.class == o.class &&
|
197
|
+
id == o.id &&
|
198
|
+
reference_id == o.reference_id &&
|
199
|
+
state == o.state &&
|
200
|
+
from_location_id == o.from_location_id &&
|
201
|
+
to_location_id == o.to_location_id &&
|
202
|
+
catalog_object_id == o.catalog_object_id &&
|
203
|
+
catalog_object_type == o.catalog_object_type &&
|
204
|
+
quantity == o.quantity &&
|
205
|
+
occurred_at == o.occurred_at &&
|
206
|
+
created_at == o.created_at &&
|
207
|
+
source == o.source &&
|
208
|
+
employee_id == o.employee_id
|
209
|
+
end
|
210
|
+
|
211
|
+
# @see the `==` method
|
212
|
+
# @param [Object] Object to be compared
|
213
|
+
def eql?(o)
|
214
|
+
self == o
|
215
|
+
end
|
216
|
+
|
217
|
+
# Calculates hash code according to all attributes.
|
218
|
+
# @return [Fixnum] Hash code
|
219
|
+
def hash
|
220
|
+
[id, reference_id, state, from_location_id, to_location_id, catalog_object_id, catalog_object_type, quantity, occurred_at, created_at, source, employee_id].hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Builds the object from hash
|
224
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
225
|
+
# @return [Object] Returns the model itself
|
226
|
+
def build_from_hash(attributes)
|
227
|
+
return nil unless attributes.is_a?(Hash)
|
228
|
+
self.class.swagger_types.each_pair do |key, type|
|
229
|
+
if type =~ /\AArray<(.*)>/i
|
230
|
+
# check to ensure the input is an array given that the the attribute
|
231
|
+
# is documented as an array but the input is not
|
232
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
233
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
234
|
+
end
|
235
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
236
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
237
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
238
|
+
end
|
239
|
+
|
240
|
+
self
|
241
|
+
end
|
242
|
+
|
243
|
+
# Deserializes the data based on type
|
244
|
+
# @param string type Data type
|
245
|
+
# @param string value Value to be deserialized
|
246
|
+
# @return [Object] Deserialized data
|
247
|
+
def _deserialize(type, value)
|
248
|
+
case type.to_sym
|
249
|
+
when :DateTime
|
250
|
+
DateTime.parse(value)
|
251
|
+
when :Date
|
252
|
+
Date.parse(value)
|
253
|
+
when :String
|
254
|
+
value.to_s
|
255
|
+
when :Integer
|
256
|
+
value.to_i
|
257
|
+
when :Float
|
258
|
+
value.to_f
|
259
|
+
when :BOOLEAN
|
260
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
261
|
+
true
|
262
|
+
else
|
263
|
+
false
|
264
|
+
end
|
265
|
+
when :Object
|
266
|
+
# generic object (usually a Hash), return directly
|
267
|
+
value
|
268
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
269
|
+
inner_type = Regexp.last_match[:inner_type]
|
270
|
+
value.map { |v| _deserialize(inner_type, v) }
|
271
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
272
|
+
k_type = Regexp.last_match[:k_type]
|
273
|
+
v_type = Regexp.last_match[:v_type]
|
274
|
+
{}.tap do |hash|
|
275
|
+
value.each do |k, v|
|
276
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
else # model
|
280
|
+
temp_model = SquareConnect.const_get(type).new
|
281
|
+
temp_model.build_from_hash(value)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
# Returns the string representation of the object
|
286
|
+
# @return [String] String presentation of the object
|
287
|
+
def to_s
|
288
|
+
to_hash.to_s
|
289
|
+
end
|
290
|
+
|
291
|
+
# to_body is an alias to to_hash (backward compatibility)
|
292
|
+
# @return [Hash] Returns the object in the form of hash
|
293
|
+
def to_body
|
294
|
+
to_hash
|
295
|
+
end
|
296
|
+
|
297
|
+
# Returns the object in the form of hash
|
298
|
+
# @return [Hash] Returns the object in the form of hash
|
299
|
+
def to_hash
|
300
|
+
hash = {}
|
301
|
+
self.class.attribute_map.each_pair do |attr, param|
|
302
|
+
value = self.send(attr)
|
303
|
+
next if value.nil?
|
304
|
+
hash[param] = _to_hash(value)
|
305
|
+
end
|
306
|
+
hash
|
307
|
+
end
|
308
|
+
|
309
|
+
# Outputs non-array value in the form of hash
|
310
|
+
# For object, use to_hash. Otherwise, just return the value
|
311
|
+
# @param [Object] value Any valid value
|
312
|
+
# @return [Hash] Returns the value in the form of hash
|
313
|
+
def _to_hash(value)
|
314
|
+
if value.is_a?(Array)
|
315
|
+
value.compact.map{ |v| _to_hash(v) }
|
316
|
+
elsif value.is_a?(Hash)
|
317
|
+
{}.tap do |hash|
|
318
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
319
|
+
end
|
320
|
+
elsif value.respond_to? :to_hash
|
321
|
+
value.to_hash
|
322
|
+
else
|
323
|
+
value
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|