square_connect 2.2.1.145 → 2.3.0.153

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -1
  3. data/docs/BatchRetrieveOrdersRequest.md +12 -0
  4. data/docs/BatchRetrieveOrdersResponse.md +13 -0
  5. data/docs/CatalogItemVariation.md +1 -1
  6. data/docs/CatalogObject.md +1 -1
  7. data/docs/CatalogV1Id.md +2 -2
  8. data/docs/CreateOrderRequest.md +5 -4
  9. data/docs/CreateOrderRequestDiscount.md +5 -4
  10. data/docs/CreateOrderRequestLineItem.md +10 -6
  11. data/docs/CreateOrderRequestModifier.md +12 -0
  12. data/docs/CreateOrderRequestTax.md +5 -4
  13. data/docs/CreateOrderResponse.md +13 -0
  14. data/docs/Currency.md +1 -0
  15. data/docs/CustomersApi.md +1 -1
  16. data/docs/ErrorCode.md +2 -0
  17. data/docs/ItemVariationLocationOverrides.md +5 -5
  18. data/docs/Location.md +9 -1
  19. data/docs/LocationStatus.md +13 -0
  20. data/docs/Order.md +1 -0
  21. data/docs/OrderLineItem.md +6 -1
  22. data/docs/OrderLineItemDiscount.md +1 -0
  23. data/docs/OrderLineItemDiscountScope.md +1 -0
  24. data/docs/OrderLineItemDiscountType.md +1 -1
  25. data/docs/OrderLineItemModifier.md +15 -0
  26. data/docs/OrderLineItemTax.md +1 -0
  27. data/docs/OrderLineItemTaxType.md +1 -1
  28. data/docs/OrdersApi.md +120 -0
  29. data/docs/SearchCatalogObjectsRequest.md +1 -1
  30. data/docs/Transaction.md +1 -1
  31. data/docs/TransactionsApi.md +1 -1
  32. data/docs/V1Payment.md +3 -3
  33. data/docs/V1Refund.md +0 -5
  34. data/lib/square_connect/api/customers_api.rb +2 -2
  35. data/lib/square_connect/api/orders_api.rb +134 -0
  36. data/lib/square_connect/api/transactions_api.rb +2 -2
  37. data/lib/square_connect/api_client.rb +1 -1
  38. data/lib/square_connect/models/batch_retrieve_orders_request.rb +193 -0
  39. data/lib/square_connect/models/batch_retrieve_orders_response.rb +200 -0
  40. data/lib/square_connect/models/catalog_item_variation.rb +1 -1
  41. data/lib/square_connect/models/catalog_object.rb +1 -1
  42. data/lib/square_connect/models/catalog_v1_id.rb +2 -2
  43. data/lib/square_connect/models/charge_request.rb +108 -0
  44. data/lib/square_connect/models/create_checkout_request.rb +16 -0
  45. data/lib/square_connect/models/create_order_request.rb +31 -5
  46. data/lib/square_connect/models/create_order_request_discount.rb +47 -5
  47. data/lib/square_connect/models/create_order_request_line_item.rb +106 -7
  48. data/lib/square_connect/models/create_order_request_modifier.rb +219 -0
  49. data/lib/square_connect/models/create_order_request_tax.rb +49 -7
  50. data/lib/square_connect/models/create_order_response.rb +198 -0
  51. data/lib/square_connect/models/create_refund_request.rb +72 -0
  52. data/lib/square_connect/models/currency.rb +1 -0
  53. data/lib/square_connect/models/error.rb +2 -2
  54. data/lib/square_connect/models/error_code.rb +2 -0
  55. data/lib/square_connect/models/item_variation_location_overrides.rb +5 -5
  56. data/lib/square_connect/models/location.rb +121 -5
  57. data/lib/square_connect/models/location_status.rb +19 -0
  58. data/lib/square_connect/models/money.rb +27 -2
  59. data/lib/square_connect/models/order.rb +11 -1
  60. data/lib/square_connect/models/order_line_item.rb +54 -2
  61. data/lib/square_connect/models/order_line_item_discount.rb +15 -5
  62. data/lib/square_connect/models/order_line_item_discount_scope.rb +1 -0
  63. data/lib/square_connect/models/order_line_item_discount_type.rb +1 -1
  64. data/lib/square_connect/models/order_line_item_modifier.rb +216 -0
  65. data/lib/square_connect/models/order_line_item_tax.rb +13 -3
  66. data/lib/square_connect/models/order_line_item_tax_type.rb +1 -1
  67. data/lib/square_connect/models/search_catalog_objects_request.rb +1 -1
  68. data/lib/square_connect/models/transaction.rb +14 -14
  69. data/lib/square_connect/models/v1_payment.rb +3 -0
  70. data/lib/square_connect/models/v1_refund.rb +1 -51
  71. data/lib/square_connect/version.rb +1 -1
  72. data/lib/square_connect.rb +7 -0
  73. metadata +17 -3
data/docs/V1Refund.md CHANGED
@@ -8,11 +8,6 @@ Name | Type | Description | Notes
8
8
  **type** | **String** | The type of refund | [optional]
9
9
  **reason** | **String** | The merchant-specified reason for the refund. | [optional]
10
10
  **refunded_money** | [**V1Money**](V1Money.md) | The amount of money refunded. This amount is always negative. | [optional]
11
- **refunded_processing_fee_money** | [**V1Money**](V1Money.md) | The amount of processing fee money refunded. | [optional]
12
- **refunded_additive_tax_money** | [**V1Money**](V1Money.md) | The amount of additive tax money refunded. | [optional]
13
- **refunded_inclusive_tax_money** | [**V1Money**](V1Money.md) | The amount of inclusive tax money refunded. | [optional]
14
- **refunded_tip_money** | [**V1Money**](V1Money.md) | The amount of tip money refunded. | [optional]
15
- **refunded_discount_money** | [**V1Money**](V1Money.md) | The amount of discount money refunded. | [optional]
16
11
  **created_at** | **String** | The time when the merchant initiated the refund for Square to process, in ISO 8601 format.. | [optional]
17
12
  **processed_at** | **String** | The time when Square processed the refund on behalf of the merchant, in ISO 8601 format. | [optional]
18
13
  **payment_id** | **String** | The Square-issued ID of the payment the refund is applied to. | [optional]
@@ -71,7 +71,7 @@ module SquareConnect
71
71
  end
72
72
 
73
73
  # CreateCustomerCard
74
- # Adds a card on file to an existing customer. In the United States Square takes care of automatically updating any cards on file that might have expired since you first attached them to a customer.
74
+ # Adds a card on file to an existing customer. In the United States Square takes care of automatically updating any cards on file that might have expired since you first attached them to a customer. As with charges, calls to `CreateCustomerCard` are idempotent. Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the _first_ call.
75
75
  # @param customer_id The ID of the customer to link the card on file to.
76
76
  # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
77
77
  # @param [Hash] opts the optional parameters
@@ -82,7 +82,7 @@ module SquareConnect
82
82
  end
83
83
 
84
84
  # CreateCustomerCard
85
- # Adds a card on file to an existing customer. In the United States Square takes care of automatically updating any cards on file that might have expired since you first attached them to a customer.
85
+ # Adds a card on file to an existing customer. In the United States Square takes care of automatically updating any cards on file that might have expired since you first attached them to a customer. As with charges, calls to `CreateCustomerCard` are idempotent. Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the _first_ call.
86
86
  # @param customer_id The ID of the customer to link the card on file to.
87
87
  # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
88
88
  # @param [Hash] opts the optional parameters
@@ -0,0 +1,134 @@
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 "uri"
11
+
12
+ module SquareConnect
13
+ class OrdersApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+
20
+ # BatchRetrieveOrders
21
+ # Retrieves a set of [Order](#type-order)s by their IDs. Only orders that have been successfully charged are included in the response. If any of the order IDs in the request do not exist, or are associated with uncharged orders, then those orders will not be included in the set of orders in the response. Note that in the future, uncharged orders may be returned by this endpoint.
22
+ # @param location_id The ID of the orders' associated location.
23
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [BatchRetrieveOrdersResponse]
26
+ def batch_retrieve_orders(location_id, body, opts = {})
27
+ data, _status_code, _headers = batch_retrieve_orders_with_http_info(location_id, body, opts)
28
+ return data
29
+ end
30
+
31
+ # BatchRetrieveOrders
32
+ # Retrieves a set of [Order](#type-order)s by their IDs. Only orders that have been successfully charged are included in the response. If any of the order IDs in the request do not exist, or are associated with uncharged orders, then those orders will not be included in the set of orders in the response. Note that in the future, uncharged orders may be returned by this endpoint.
33
+ # @param location_id The ID of the orders' associated location.
34
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(BatchRetrieveOrdersResponse, Fixnum, Hash)>] BatchRetrieveOrdersResponse data, response status code and response headers
37
+ def batch_retrieve_orders_with_http_info(location_id, body, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug "Calling API: OrdersApi.batch_retrieve_orders ..."
40
+ end
41
+ # verify the required parameter 'location_id' is set
42
+ fail ArgumentError, "Missing the required parameter 'location_id' when calling OrdersApi.batch_retrieve_orders" if location_id.nil?
43
+ # verify the required parameter 'body' is set
44
+ fail ArgumentError, "Missing the required parameter 'body' when calling OrdersApi.batch_retrieve_orders" if body.nil?
45
+ # resource path
46
+ local_var_path = "/v2/locations/{location_id}/orders/batch-retrieve".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s)
47
+
48
+ # query parameters
49
+ query_params = {}
50
+
51
+ # header parameters
52
+ header_params = {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+ # HTTP header 'Content-Type'
56
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
57
+
58
+ # form parameters
59
+ form_params = {}
60
+
61
+ # http body (model)
62
+ post_body = @api_client.object_to_http_body(body)
63
+ auth_names = ['oauth2']
64
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
65
+ :header_params => header_params,
66
+ :query_params => query_params,
67
+ :form_params => form_params,
68
+ :body => post_body,
69
+ :auth_names => auth_names,
70
+ :return_type => 'BatchRetrieveOrdersResponse')
71
+ if @api_client.config.debugging
72
+ @api_client.config.logger.debug "API called: OrdersApi#batch_retrieve_orders\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
73
+ end
74
+ return data, status_code, headers
75
+ end
76
+
77
+ # CreateOrder
78
+ # Creates an [Order](#type-order) that can then be referenced as `order_id` in a request to the [Charge](#endpoint-charge) endpoint. Orders specify products for purchase, along with discounts, taxes, and other settings to apply to the purchase. To associate a created order with a request to the Charge endpoint, provide the order's `id` in the `order_id` field of your request. You cannot modify an order after you create it. If you need to modify an order, instead create a new order with modified details. To learn more about the Orders API, see the [Orders API Overview](https://docs.connect.squareup.com/articles/orders-overview).
79
+ # @param location_id The ID of the business location to associate the order with.
80
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
81
+ # @param [Hash] opts the optional parameters
82
+ # @return [CreateOrderResponse]
83
+ def create_order(location_id, body, opts = {})
84
+ data, _status_code, _headers = create_order_with_http_info(location_id, body, opts)
85
+ return data
86
+ end
87
+
88
+ # CreateOrder
89
+ # Creates an [Order](#type-order) that can then be referenced as &#x60;order_id&#x60; in a request to the [Charge](#endpoint-charge) endpoint. Orders specify products for purchase, along with discounts, taxes, and other settings to apply to the purchase. To associate a created order with a request to the Charge endpoint, provide the order&#39;s &#x60;id&#x60; in the &#x60;order_id&#x60; field of your request. You cannot modify an order after you create it. If you need to modify an order, instead create a new order with modified details. To learn more about the Orders API, see the [Orders API Overview](https://docs.connect.squareup.com/articles/orders-overview).
90
+ # @param location_id The ID of the business location to associate the order with.
91
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Array<(CreateOrderResponse, Fixnum, Hash)>] CreateOrderResponse data, response status code and response headers
94
+ def create_order_with_http_info(location_id, body, opts = {})
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug "Calling API: OrdersApi.create_order ..."
97
+ end
98
+ # verify the required parameter 'location_id' is set
99
+ fail ArgumentError, "Missing the required parameter 'location_id' when calling OrdersApi.create_order" if location_id.nil?
100
+ # verify the required parameter 'body' is set
101
+ fail ArgumentError, "Missing the required parameter 'body' when calling OrdersApi.create_order" if body.nil?
102
+ # resource path
103
+ local_var_path = "/v2/locations/{location_id}/orders".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s)
104
+
105
+ # query parameters
106
+ query_params = {}
107
+
108
+ # header parameters
109
+ header_params = {}
110
+ # HTTP header 'Accept' (if needed)
111
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
112
+ # HTTP header 'Content-Type'
113
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
114
+
115
+ # form parameters
116
+ form_params = {}
117
+
118
+ # http body (model)
119
+ post_body = @api_client.object_to_http_body(body)
120
+ auth_names = ['oauth2']
121
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
122
+ :header_params => header_params,
123
+ :query_params => query_params,
124
+ :form_params => form_params,
125
+ :body => post_body,
126
+ :auth_names => auth_names,
127
+ :return_type => 'CreateOrderResponse')
128
+ if @api_client.config.debugging
129
+ @api_client.config.logger.debug "API called: OrdersApi#create_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
130
+ end
131
+ return data, status_code, headers
132
+ end
133
+ end
134
+ end
@@ -132,7 +132,7 @@ module SquareConnect
132
132
  end
133
133
 
134
134
  # CreateRefund
135
- # 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.
135
+ # 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.
136
136
  # @param location_id The ID of the original transaction&#39;s associated location.
137
137
  # @param transaction_id The ID of the original transaction that includes the tender to refund.
138
138
  # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@@ -144,7 +144,7 @@ module SquareConnect
144
144
  end
145
145
 
146
146
  # CreateRefund
147
- # 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.
147
+ # 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.
148
148
  # @param location_id The ID of the original transaction&#39;s associated location.
149
149
  # @param transaction_id The ID of the original transaction that includes the tender to refund.
150
150
  # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@@ -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.2.1"
33
+ @user_agent = "Square-Connect-Ruby/2.3.0"
34
34
 
35
35
  @default_headers = {
36
36
  'Content-Type' => "application/json",
@@ -0,0 +1,193 @@
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 BatchRetrieveOrdersRequest
15
+ # The IDs of the orders to retrieve. A maximum of 100 orders can be retrieved per request.
16
+ attr_accessor :order_ids
17
+
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'order_ids' => :'order_ids'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'order_ids' => :'Array<String>'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
40
+
41
+ if attributes.has_key?(:'order_ids')
42
+ if (value = attributes[:'order_ids']).is_a?(Array)
43
+ self.order_ids = value
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ # Show invalid properties with the reasons. Usually used together with valid?
50
+ # @return Array for valid properies with the reasons
51
+ def list_invalid_properties
52
+ invalid_properties = Array.new
53
+ if @order_ids.nil?
54
+ invalid_properties.push("invalid value for 'order_ids', order_ids cannot be nil.")
55
+ end
56
+
57
+ return invalid_properties
58
+ end
59
+
60
+ # Check to see if the all the properties in the model are valid
61
+ # @return true if the model is valid
62
+ def valid?
63
+ return false if @order_ids.nil?
64
+ return true
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ order_ids == o.order_ids
73
+ end
74
+
75
+ # @see the `==` method
76
+ # @param [Object] Object to be compared
77
+ def eql?(o)
78
+ self == o
79
+ end
80
+
81
+ # Calculates hash code according to all attributes.
82
+ # @return [Fixnum] Hash code
83
+ def hash
84
+ [order_ids].hash
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.swagger_types.each_pair do |key, type|
93
+ if type =~ /\AArray<(.*)>/i
94
+ # check to ensure the input is an array given that the the attribute
95
+ # is documented as an array but the input is not
96
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
97
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
102
+ end
103
+
104
+ self
105
+ end
106
+
107
+ # Deserializes the data based on type
108
+ # @param string type Data type
109
+ # @param string value Value to be deserialized
110
+ # @return [Object] Deserialized data
111
+ def _deserialize(type, value)
112
+ case type.to_sym
113
+ when :DateTime
114
+ DateTime.parse(value)
115
+ when :Date
116
+ Date.parse(value)
117
+ when :String
118
+ value.to_s
119
+ when :Integer
120
+ value.to_i
121
+ when :Float
122
+ value.to_f
123
+ when :BOOLEAN
124
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
125
+ true
126
+ else
127
+ false
128
+ end
129
+ when :Object
130
+ # generic object (usually a Hash), return directly
131
+ value
132
+ when /\AArray<(?<inner_type>.+)>\z/
133
+ inner_type = Regexp.last_match[:inner_type]
134
+ value.map { |v| _deserialize(inner_type, v) }
135
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
136
+ k_type = Regexp.last_match[:k_type]
137
+ v_type = Regexp.last_match[:v_type]
138
+ {}.tap do |hash|
139
+ value.each do |k, v|
140
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
141
+ end
142
+ end
143
+ else # model
144
+ temp_model = SquareConnect.const_get(type).new
145
+ temp_model.build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ next if value.nil?
168
+ hash[param] = _to_hash(value)
169
+ end
170
+ hash
171
+ end
172
+
173
+ # Outputs non-array value in the form of hash
174
+ # For object, use to_hash. Otherwise, just return the value
175
+ # @param [Object] value Any valid value
176
+ # @return [Hash] Returns the value in the form of hash
177
+ def _to_hash(value)
178
+ if value.is_a?(Array)
179
+ value.compact.map{ |v| _to_hash(v) }
180
+ elsif value.is_a?(Hash)
181
+ {}.tap do |hash|
182
+ value.each { |k, v| hash[k] = _to_hash(v) }
183
+ end
184
+ elsif value.respond_to? :to_hash
185
+ value.to_hash
186
+ else
187
+ value
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ 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
+ # Defines the fields that are included in the response body of a request to the [BatchRetrieveOrders](#endpoint-batchretrieveorders) endpoint.
14
+ class BatchRetrieveOrdersResponse
15
+ # The requested orders. This will omit any requested orders that do not exist or are not charged.
16
+ attr_accessor :orders
17
+
18
+ # Any errors that occurred during the request.
19
+ attr_accessor :errors
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'orders' => :'orders',
26
+ :'errors' => :'errors'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'orders' => :'Array<Order>',
34
+ :'errors' => :'Array<Error>'
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?(:'orders')
47
+ if (value = attributes[:'orders']).is_a?(Array)
48
+ self.orders = value
49
+ end
50
+ end
51
+
52
+ if attributes.has_key?(:'errors')
53
+ if (value = attributes[:'errors']).is_a?(Array)
54
+ self.errors = 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
+ orders == o.orders &&
79
+ errors == o.errors
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
+ [orders, errors].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
@@ -30,7 +30,7 @@ module SquareConnect
30
30
  # The item variation's price, if fixed pricing is used.
31
31
  attr_accessor :price_money
32
32
 
33
- # Per-[location][#type-location] price and inventory overrides.
33
+ # Per-[location](#type-location) price and inventory overrides.
34
34
  attr_accessor :location_overrides
35
35
 
36
36
  # If `true`, inventory tracking is active for the variation.
@@ -27,7 +27,7 @@ module SquareConnect
27
27
  # If `true`, the object has been deleted from the database. Must be `false` for new objects being inserted. When deleted, the `updated_at` field will equal the deletion time.
28
28
  attr_accessor :is_deleted
29
29
 
30
- # The Connect V1 IDs for this object at each [location][#type-location] where it is present, where they differ from the object's Connect V2 ID. The field will only be present for objects that have been created or modified by legacy APIs.
30
+ # The Connect V1 IDs for this object at each [location](#type-location) where it is present, where they differ from the object's Connect V2 ID. The field will only be present for objects that have been created or modified by legacy APIs.
31
31
  attr_accessor :catalog_v1_ids
32
32
 
33
33
  # If `true`, this object is present at all locations (including future locations), except where specified in the `absent_at_location_ids` field. If `false`, this object is not present at any locations (including future locations), except where specified in the `present_at_location_ids` field.
@@ -10,12 +10,12 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git
10
10
  require 'date'
11
11
 
12
12
  module SquareConnect
13
- # An Items Connect V1 object ID along with its associated [location][#type-location] ID.
13
+ # An Items Connect V1 object ID along with its associated [location](#type-location) ID.
14
14
  class CatalogV1Id
15
15
  # The ID for an object in Connect V1, if different from its Connect V2 ID.
16
16
  attr_accessor :catalog_v1_id
17
17
 
18
- # The ID of the [location][#type-location] this Connect V1 ID is associated with.
18
+ # The ID of the [location](#type-location) this Connect V1 ID is associated with.
19
19
  attr_accessor :location_id
20
20
 
21
21