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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +20 -1
  3. data/README.md +33 -1
  4. data/docs/BatchChangeInventoryRequest.md +14 -0
  5. data/docs/BatchChangeInventoryResponse.md +13 -0
  6. data/docs/BatchRetrieveInventoryChangesRequest.md +18 -0
  7. data/docs/BatchRetrieveInventoryChangesResponse.md +14 -0
  8. data/docs/BatchRetrieveInventoryCountsRequest.md +15 -0
  9. data/docs/BatchRetrieveInventoryCountsResponse.md +14 -0
  10. data/docs/Card.md +1 -1
  11. data/docs/CreateCustomerRequest.md +1 -0
  12. data/docs/Customer.md +1 -0
  13. data/docs/CustomersApi.md +2 -2
  14. data/docs/ErrorCode.md +2 -0
  15. data/docs/InventoryAdjustment.md +28 -0
  16. data/docs/InventoryApi.md +391 -0
  17. data/docs/InventoryChange.md +15 -0
  18. data/docs/InventoryChangeType.md +14 -0
  19. data/docs/InventoryCount.md +17 -0
  20. data/docs/InventoryPhysicalCount.md +22 -0
  21. data/docs/InventoryState.md +23 -0
  22. data/docs/InventoryTransfer.md +23 -0
  23. data/docs/Product.md +19 -0
  24. data/docs/RetrieveInventoryAdjustmentRequest.md +11 -0
  25. data/docs/RetrieveInventoryAdjustmentResponse.md +13 -0
  26. data/docs/RetrieveInventoryChangesRequest.md +13 -0
  27. data/docs/RetrieveInventoryChangesResponse.md +14 -0
  28. data/docs/RetrieveInventoryCountRequest.md +13 -0
  29. data/docs/RetrieveInventoryCountResponse.md +14 -0
  30. data/docs/RetrieveInventoryPhysicalCountRequest.md +11 -0
  31. data/docs/RetrieveInventoryPhysicalCountResponse.md +13 -0
  32. data/docs/SourceApplication.md +14 -0
  33. data/docs/TransactionsApi.md +1 -1
  34. data/docs/UpdateCustomerRequest.md +1 -0
  35. data/docs/V1Timecard.md +4 -1
  36. data/lib/square_connect.rb +24 -0
  37. data/lib/square_connect/api/apple_pay_api.rb +1 -1
  38. data/lib/square_connect/api/catalog_api.rb +11 -11
  39. data/lib/square_connect/api/checkout_api.rb +1 -1
  40. data/lib/square_connect/api/customers_api.rb +12 -12
  41. data/lib/square_connect/api/inventory_api.rb +417 -0
  42. data/lib/square_connect/api/locations_api.rb +1 -1
  43. data/lib/square_connect/api/mobile_authorization_api.rb +1 -1
  44. data/lib/square_connect/api/o_auth_api.rb +3 -3
  45. data/lib/square_connect/api/orders_api.rb +2 -2
  46. data/lib/square_connect/api/reporting_api.rb +2 -2
  47. data/lib/square_connect/api/transactions_api.rb +9 -9
  48. data/lib/square_connect/api_client.rb +1 -1
  49. data/lib/square_connect/models/batch_change_inventory_request.rb +208 -0
  50. data/lib/square_connect/models/batch_change_inventory_response.rb +200 -0
  51. data/lib/square_connect/models/batch_retrieve_inventory_changes_request.rb +275 -0
  52. data/lib/square_connect/models/batch_retrieve_inventory_changes_response.rb +210 -0
  53. data/lib/square_connect/models/batch_retrieve_inventory_counts_request.rb +220 -0
  54. data/lib/square_connect/models/batch_retrieve_inventory_counts_response.rb +210 -0
  55. data/lib/square_connect/models/card.rb +1 -1
  56. data/lib/square_connect/models/create_customer_request.rb +14 -4
  57. data/lib/square_connect/models/customer.rb +11 -1
  58. data/lib/square_connect/models/error.rb +2 -2
  59. data/lib/square_connect/models/error_code.rb +2 -0
  60. data/lib/square_connect/models/inventory_adjustment.rb +391 -0
  61. data/lib/square_connect/models/inventory_change.rb +249 -0
  62. data/lib/square_connect/models/inventory_change_type.rb +20 -0
  63. data/lib/square_connect/models/inventory_count.rb +269 -0
  64. data/lib/square_connect/models/inventory_physical_count.rb +319 -0
  65. data/lib/square_connect/models/inventory_state.rb +29 -0
  66. data/lib/square_connect/models/inventory_transfer.rb +329 -0
  67. data/lib/square_connect/models/money.rb +0 -9
  68. data/lib/square_connect/models/product.rb +25 -0
  69. data/lib/square_connect/models/retrieve_inventory_adjustment_request.rb +176 -0
  70. data/lib/square_connect/models/retrieve_inventory_adjustment_response.rb +198 -0
  71. data/lib/square_connect/models/retrieve_inventory_changes_request.rb +196 -0
  72. data/lib/square_connect/models/retrieve_inventory_changes_response.rb +210 -0
  73. data/lib/square_connect/models/retrieve_inventory_count_request.rb +196 -0
  74. data/lib/square_connect/models/retrieve_inventory_count_response.rb +210 -0
  75. data/lib/square_connect/models/retrieve_inventory_physical_count_request.rb +176 -0
  76. data/lib/square_connect/models/retrieve_inventory_physical_count_response.rb +198 -0
  77. data/lib/square_connect/models/source_application.rb +239 -0
  78. data/lib/square_connect/models/update_customer_request.rb +14 -4
  79. data/lib/square_connect/models/v1_timecard.rb +35 -5
  80. data/lib/square_connect/version.rb +1 -1
  81. data/spec/api/inventory_api_spec.rb +120 -0
  82. data/spec/models/batch_change_inventory_request_spec.rb +51 -0
  83. data/spec/models/batch_change_inventory_response_spec.rb +45 -0
  84. data/spec/models/batch_retrieve_inventory_changes_request_spec.rb +83 -0
  85. data/spec/models/batch_retrieve_inventory_changes_response_spec.rb +51 -0
  86. data/spec/models/batch_retrieve_inventory_counts_request_spec.rb +57 -0
  87. data/spec/models/batch_retrieve_inventory_counts_response_spec.rb +51 -0
  88. data/spec/models/inventory_adjustment_spec.rb +143 -0
  89. data/spec/models/inventory_change_spec.rb +61 -0
  90. data/spec/models/inventory_change_type_spec.rb +33 -0
  91. data/spec/models/inventory_count_spec.rb +73 -0
  92. data/spec/models/inventory_physical_count_spec.rb +103 -0
  93. data/spec/models/inventory_state_spec.rb +33 -0
  94. data/spec/models/inventory_transfer_spec.rb +109 -0
  95. data/spec/models/product_spec.rb +33 -0
  96. data/spec/models/retrieve_inventory_adjustment_request_spec.rb +33 -0
  97. data/spec/models/retrieve_inventory_adjustment_response_spec.rb +45 -0
  98. data/spec/models/retrieve_inventory_changes_request_spec.rb +45 -0
  99. data/spec/models/retrieve_inventory_changes_response_spec.rb +51 -0
  100. data/spec/models/retrieve_inventory_count_request_spec.rb +45 -0
  101. data/spec/models/retrieve_inventory_count_response_spec.rb +51 -0
  102. data/spec/models/retrieve_inventory_physical_count_request_spec.rb +33 -0
  103. data/spec/models/retrieve_inventory_physical_count_response_spec.rb +45 -0
  104. data/spec/models/source_application_spec.rb +55 -0
  105. metadata +99 -3
@@ -47,7 +47,7 @@ module SquareConnect
47
47
  # HTTP header 'Content-Type'
48
48
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
49
49
 
50
- header_params['Square-Version'] = "2018-07-12"
50
+ header_params['Square-Version'] = "2018-09-18"
51
51
 
52
52
  # form parameters
53
53
  form_params = {}
@@ -51,7 +51,7 @@ module SquareConnect
51
51
  # HTTP header 'Content-Type'
52
52
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
53
53
 
54
- header_params['Square-Version'] = "2018-07-12"
54
+ header_params['Square-Version'] = "2018-09-18"
55
55
 
56
56
  # form parameters
57
57
  form_params = {}
@@ -51,7 +51,7 @@ module SquareConnect
51
51
  # HTTP header 'Content-Type'
52
52
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
53
53
 
54
- header_params['Square-Version'] = "2018-07-12"
54
+ header_params['Square-Version'] = "2018-09-18"
55
55
 
56
56
  # form parameters
57
57
  form_params = {}
@@ -110,7 +110,7 @@ module SquareConnect
110
110
  # HTTP header 'Content-Type'
111
111
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
112
112
 
113
- header_params['Square-Version'] = "2018-07-12"
113
+ header_params['Square-Version'] = "2018-09-18"
114
114
 
115
115
  # form parameters
116
116
  form_params = {}
@@ -165,7 +165,7 @@ module SquareConnect
165
165
  # HTTP header 'Content-Type'
166
166
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
167
167
 
168
- header_params['Square-Version'] = "2018-07-12"
168
+ header_params['Square-Version'] = "2018-09-18"
169
169
 
170
170
  # form parameters
171
171
  form_params = {}
@@ -55,7 +55,7 @@ module SquareConnect
55
55
  # HTTP header 'Content-Type'
56
56
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
57
57
 
58
- header_params['Square-Version'] = "2018-07-12"
58
+ header_params['Square-Version'] = "2018-09-18"
59
59
 
60
60
  # form parameters
61
61
  form_params = {}
@@ -114,7 +114,7 @@ module SquareConnect
114
114
  # HTTP header 'Content-Type'
115
115
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
116
116
 
117
- header_params['Square-Version'] = "2018-07-12"
117
+ header_params['Square-Version'] = "2018-09-18"
118
118
 
119
119
  # form parameters
120
120
  form_params = {}
@@ -66,7 +66,7 @@ module SquareConnect
66
66
  # HTTP header 'Content-Type'
67
67
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
68
68
 
69
- header_params['Square-Version'] = "2018-07-12"
69
+ header_params['Square-Version'] = "2018-09-18"
70
70
 
71
71
  # form parameters
72
72
  form_params = {}
@@ -136,7 +136,7 @@ module SquareConnect
136
136
  # HTTP header 'Content-Type'
137
137
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
138
138
 
139
- header_params['Square-Version'] = "2018-07-12"
139
+ header_params['Square-Version'] = "2018-09-18"
140
140
 
141
141
  # form parameters
142
142
  form_params = {}
@@ -55,7 +55,7 @@ module SquareConnect
55
55
  # HTTP header 'Content-Type'
56
56
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
57
57
 
58
- header_params['Square-Version'] = "2018-07-12"
58
+ header_params['Square-Version'] = "2018-09-18"
59
59
 
60
60
  # form parameters
61
61
  form_params = {}
@@ -114,7 +114,7 @@ module SquareConnect
114
114
  # HTTP header 'Content-Type'
115
115
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
116
116
 
117
- header_params['Square-Version'] = "2018-07-12"
117
+ header_params['Square-Version'] = "2018-09-18"
118
118
 
119
119
  # form parameters
120
120
  form_params = {}
@@ -136,7 +136,7 @@ module SquareConnect
136
136
  end
137
137
 
138
138
  # CreateRefund
139
- # Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See [this article](https://squareup.com/help/us/en/article/5060) for more information on refund behavior. *NOTE**: Card-present transactions with Interac credit cards **cannot be refunded using the Connect API**. Interac transactions must refunded in-person (e.g., dipping the card using POS app).
139
+ # Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See [this article](https://squareup.com/help/us/en/article/5060) for more information on refund behavior. NOTE: Card-present transactions with Interac credit cards **cannot be refunded using the Connect API**. Interac transactions must refunded in-person (e.g., dipping the card using POS app).
140
140
  # @param location_id The ID of the original transaction's associated location.
141
141
  # @param transaction_id The ID of the original transaction that includes the tender to refund.
142
142
  # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@@ -148,7 +148,7 @@ module SquareConnect
148
148
  end
149
149
 
150
150
  # CreateRefund
151
- # Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See [this article](https://squareup.com/help/us/en/article/5060) for more information on refund behavior. *NOTE**: Card-present transactions with Interac credit cards **cannot be refunded using the Connect API**. Interac transactions must refunded in-person (e.g., dipping the card using POS app).
151
+ # Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See [this article](https://squareup.com/help/us/en/article/5060) for more information on refund behavior. NOTE: Card-present transactions with Interac credit cards **cannot be refunded using the Connect API**. Interac transactions must refunded in-person (e.g., dipping the card using POS app).
152
152
  # @param location_id The ID of the original transaction's associated location.
153
153
  # @param transaction_id The ID of the original transaction that includes the tender to refund.
154
154
  # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@@ -177,7 +177,7 @@ module SquareConnect
177
177
  # HTTP header 'Content-Type'
178
178
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
179
179
 
180
- header_params['Square-Version'] = "2018-07-12"
180
+ header_params['Square-Version'] = "2018-09-18"
181
181
 
182
182
  # form parameters
183
183
  form_params = {}
@@ -247,7 +247,7 @@ module SquareConnect
247
247
  # HTTP header 'Content-Type'
248
248
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
249
249
 
250
- header_params['Square-Version'] = "2018-07-12"
250
+ header_params['Square-Version'] = "2018-09-18"
251
251
 
252
252
  # form parameters
253
253
  form_params = {}
@@ -317,7 +317,7 @@ module SquareConnect
317
317
  # HTTP header 'Content-Type'
318
318
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
319
319
 
320
- header_params['Square-Version'] = "2018-07-12"
320
+ header_params['Square-Version'] = "2018-09-18"
321
321
 
322
322
  # form parameters
323
323
  form_params = {}
@@ -376,7 +376,7 @@ module SquareConnect
376
376
  # HTTP header 'Content-Type'
377
377
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
378
378
 
379
- header_params['Square-Version'] = "2018-07-12"
379
+ header_params['Square-Version'] = "2018-09-18"
380
380
 
381
381
  # form parameters
382
382
  form_params = {}
@@ -435,7 +435,7 @@ module SquareConnect
435
435
  # HTTP header 'Content-Type'
436
436
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
437
437
 
438
- header_params['Square-Version'] = "2018-07-12"
438
+ header_params['Square-Version'] = "2018-09-18"
439
439
 
440
440
  # form parameters
441
441
  form_params = {}
@@ -30,7 +30,7 @@ module SquareConnect
30
30
  @config = config
31
31
 
32
32
  # Construct user agent string. Returns slightly different string for JRuby
33
- @user_agent = "Square-Connect-Ruby/2.20180712.2"
33
+ @user_agent = "Square-Connect-Ruby/2.20180918.0"
34
34
 
35
35
  @default_headers = {
36
36
  'Content-Type' => "application/json",
@@ -0,0 +1,208 @@
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 BatchChangeInventoryRequest
15
+ # A client-supplied, universally unique identifier (UUID) for the request. See [Idempotency](/basics/api101/idempotency) in the [API Development 101](/basics/api101/overview) section for more information.
16
+ attr_accessor :idempotency_key
17
+
18
+ # The set of physical counts and inventory adjustments to be made. Changes are applied based on the client-supplied timestamp and may be sent out of order. Max size is 100 changes.
19
+ attr_accessor :changes
20
+
21
+ # Indicates whether the current physical count should be ignored if the quantity is unchanged since the last physical count. Default: `true`.
22
+ attr_accessor :ignore_unchanged_counts
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'idempotency_key' => :'idempotency_key',
29
+ :'changes' => :'changes',
30
+ :'ignore_unchanged_counts' => :'ignore_unchanged_counts'
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'idempotency_key' => :'String',
38
+ :'changes' => :'Array<InventoryChange>',
39
+ :'ignore_unchanged_counts' => :'BOOLEAN'
40
+ }
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ return unless attributes.is_a?(Hash)
47
+
48
+ # convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
50
+
51
+ if attributes.has_key?(:'idempotency_key')
52
+ self.idempotency_key = attributes[:'idempotency_key']
53
+ end
54
+
55
+ if attributes.has_key?(:'changes')
56
+ if (value = attributes[:'changes']).is_a?(Array)
57
+ self.changes = value
58
+ end
59
+ end
60
+
61
+ if attributes.has_key?(:'ignore_unchanged_counts')
62
+ self.ignore_unchanged_counts = attributes[:'ignore_unchanged_counts']
63
+ end
64
+
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properies with the reasons
69
+ def list_invalid_properties
70
+ invalid_properties = Array.new
71
+ return invalid_properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ return true
78
+ end
79
+
80
+ # Checks equality by comparing each attribute.
81
+ # @param [Object] Object to be compared
82
+ def ==(o)
83
+ return true if self.equal?(o)
84
+ self.class == o.class &&
85
+ idempotency_key == o.idempotency_key &&
86
+ changes == o.changes &&
87
+ ignore_unchanged_counts == o.ignore_unchanged_counts
88
+ end
89
+
90
+ # @see the `==` method
91
+ # @param [Object] Object to be compared
92
+ def eql?(o)
93
+ self == o
94
+ end
95
+
96
+ # Calculates hash code according to all attributes.
97
+ # @return [Fixnum] Hash code
98
+ def hash
99
+ [idempotency_key, changes, ignore_unchanged_counts].hash
100
+ end
101
+
102
+ # Builds the object from hash
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ # @return [Object] Returns the model itself
105
+ def build_from_hash(attributes)
106
+ return nil unless attributes.is_a?(Hash)
107
+ self.class.swagger_types.each_pair do |key, type|
108
+ if type =~ /\AArray<(.*)>/i
109
+ # check to ensure the input is an array given that the the attribute
110
+ # is documented as an array but the input is not
111
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
112
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
113
+ end
114
+ elsif !attributes[self.class.attribute_map[key]].nil?
115
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
116
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
117
+ end
118
+
119
+ self
120
+ end
121
+
122
+ # Deserializes the data based on type
123
+ # @param string type Data type
124
+ # @param string value Value to be deserialized
125
+ # @return [Object] Deserialized data
126
+ def _deserialize(type, value)
127
+ case type.to_sym
128
+ when :DateTime
129
+ DateTime.parse(value)
130
+ when :Date
131
+ Date.parse(value)
132
+ when :String
133
+ value.to_s
134
+ when :Integer
135
+ value.to_i
136
+ when :Float
137
+ value.to_f
138
+ when :BOOLEAN
139
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
140
+ true
141
+ else
142
+ false
143
+ end
144
+ when :Object
145
+ # generic object (usually a Hash), return directly
146
+ value
147
+ when /\AArray<(?<inner_type>.+)>\z/
148
+ inner_type = Regexp.last_match[:inner_type]
149
+ value.map { |v| _deserialize(inner_type, v) }
150
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
151
+ k_type = Regexp.last_match[:k_type]
152
+ v_type = Regexp.last_match[:v_type]
153
+ {}.tap do |hash|
154
+ value.each do |k, v|
155
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
156
+ end
157
+ end
158
+ else # model
159
+ temp_model = SquareConnect.const_get(type).new
160
+ temp_model.build_from_hash(value)
161
+ end
162
+ end
163
+
164
+ # Returns the string representation of the object
165
+ # @return [String] String presentation of the object
166
+ def to_s
167
+ to_hash.to_s
168
+ end
169
+
170
+ # to_body is an alias to to_hash (backward compatibility)
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_body
173
+ to_hash
174
+ end
175
+
176
+ # Returns the object in the form of hash
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_hash
179
+ hash = {}
180
+ self.class.attribute_map.each_pair do |attr, param|
181
+ value = self.send(attr)
182
+ next if value.nil?
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ # Outputs non-array value in the form of hash
189
+ # For object, use to_hash. Otherwise, just return the value
190
+ # @param [Object] value Any valid value
191
+ # @return [Hash] Returns the value in the form of hash
192
+ def _to_hash(value)
193
+ if value.is_a?(Array)
194
+ value.compact.map{ |v| _to_hash(v) }
195
+ elsif value.is_a?(Hash)
196
+ {}.tap do |hash|
197
+ value.each { |k, v| hash[k] = _to_hash(v) }
198
+ end
199
+ elsif value.respond_to? :to_hash
200
+ value.to_hash
201
+ else
202
+ value
203
+ end
204
+ end
205
+
206
+ end
207
+
208
+ end
@@ -0,0 +1,200 @@
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 BatchChangeInventoryResponse
15
+ # Any errors that occurred during the request.
16
+ attr_accessor :errors
17
+
18
+ # The current counts for all objects referenced in the request.
19
+ attr_accessor :counts
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'errors' => :'errors',
26
+ :'counts' => :'counts'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'errors' => :'Array<Error>',
34
+ :'counts' => :'Array<InventoryCount>'
35
+ }
36
+ end
37
+
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
40
+ def initialize(attributes = {})
41
+ return unless attributes.is_a?(Hash)
42
+
43
+ # convert string to symbol for hash key
44
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
45
+
46
+ if attributes.has_key?(:'errors')
47
+ if (value = attributes[:'errors']).is_a?(Array)
48
+ self.errors = value
49
+ end
50
+ end
51
+
52
+ if attributes.has_key?(:'counts')
53
+ if (value = attributes[:'counts']).is_a?(Array)
54
+ self.counts = value
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ # Show invalid properties with the reasons. Usually used together with valid?
61
+ # @return Array for valid properies with the reasons
62
+ def list_invalid_properties
63
+ invalid_properties = Array.new
64
+ return invalid_properties
65
+ end
66
+
67
+ # Check to see if the all the properties in the model are valid
68
+ # @return true if the model is valid
69
+ def valid?
70
+ return true
71
+ end
72
+
73
+ # Checks equality by comparing each attribute.
74
+ # @param [Object] Object to be compared
75
+ def ==(o)
76
+ return true if self.equal?(o)
77
+ self.class == o.class &&
78
+ errors == o.errors &&
79
+ counts == o.counts
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [errors, counts].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.swagger_types.each_pair do |key, type|
100
+ if type =~ /\AArray<(.*)>/i
101
+ # check to ensure the input is an array given that the the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :BOOLEAN
131
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ temp_model = SquareConnect.const_get(type).new
152
+ temp_model.build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map{ |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ end