square_connect 2.1.1.106 → 2.2.0.110

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -4
  3. data/docs/Card.md +1 -0
  4. data/docs/CatalogApi.md +4 -4
  5. data/docs/CatalogItem.md +1 -1
  6. data/docs/CatalogItemProductType.md +1 -1
  7. data/docs/CatalogItemVariation.md +1 -1
  8. data/docs/CatalogObject.md +3 -3
  9. data/docs/CatalogQuery.md +2 -2
  10. data/docs/CatalogTax.md +1 -1
  11. data/docs/CatalogV1Id.md +2 -2
  12. data/docs/CreateCheckoutRequest.md +1 -1
  13. data/docs/{CreateOrderRequestOrder.md → CreateOrderRequest.md} +4 -2
  14. data/docs/CreateOrderRequestDiscount.md +14 -0
  15. data/docs/CreateOrderRequestLineItem.md +4 -2
  16. data/docs/CreateOrderRequestTax.md +14 -0
  17. data/docs/CustomersApi.md +2 -2
  18. data/docs/ErrorCode.md +1 -0
  19. data/docs/ItemVariationLocationOverrides.md +5 -5
  20. data/docs/Order.md +2 -1
  21. data/docs/OrderLineItem.md +5 -2
  22. data/docs/OrderLineItemDiscount.md +17 -0
  23. data/docs/OrderLineItemDiscountScope.md +13 -0
  24. data/docs/OrderLineItemDiscountType.md +16 -0
  25. data/docs/OrderLineItemTax.md +15 -0
  26. data/docs/OrderLineItemTaxType.md +14 -0
  27. data/docs/RetrieveCatalogObjectRequest.md +1 -1
  28. data/docs/SearchCatalogObjectsRequest.md +1 -1
  29. data/docs/Transaction.md +2 -2
  30. data/docs/TransactionsApi.md +1 -1
  31. data/lib/square_connect.rb +8 -1
  32. data/lib/square_connect/api/catalog_api.rb +6 -6
  33. data/lib/square_connect/api/customers_api.rb +4 -4
  34. data/lib/square_connect/api/transactions_api.rb +2 -2
  35. data/lib/square_connect/api_client.rb +1 -1
  36. data/lib/square_connect/models/card.rb +14 -4
  37. data/lib/square_connect/models/catalog_item.rb +1 -1
  38. data/lib/square_connect/models/catalog_item_variation.rb +1 -1
  39. data/lib/square_connect/models/catalog_object.rb +3 -3
  40. data/lib/square_connect/models/catalog_query.rb +2 -2
  41. data/lib/square_connect/models/catalog_tax.rb +1 -1
  42. data/lib/square_connect/models/catalog_v1_id.rb +2 -2
  43. data/lib/square_connect/models/create_checkout_request.rb +1 -1
  44. data/lib/square_connect/models/{create_order_request_order.rb → create_order_request.rb} +30 -6
  45. data/lib/square_connect/models/create_order_request_discount.rb +222 -0
  46. data/lib/square_connect/models/create_order_request_line_item.rb +31 -29
  47. data/lib/square_connect/models/create_order_request_tax.rb +255 -0
  48. data/lib/square_connect/models/error.rb +2 -2
  49. data/lib/square_connect/models/error_code.rb +1 -0
  50. data/lib/square_connect/models/item_variation_location_overrides.rb +5 -5
  51. data/lib/square_connect/models/order.rb +24 -14
  52. data/lib/square_connect/models/order_line_item.rb +46 -12
  53. data/lib/square_connect/models/order_line_item_discount.rb +281 -0
  54. data/lib/square_connect/models/order_line_item_discount_scope.rb +19 -0
  55. data/lib/square_connect/models/order_line_item_discount_type.rb +22 -0
  56. data/lib/square_connect/models/order_line_item_tax.rb +249 -0
  57. data/lib/square_connect/models/order_line_item_tax_type.rb +20 -0
  58. data/lib/square_connect/models/retrieve_catalog_object_request.rb +1 -1
  59. data/lib/square_connect/models/search_catalog_objects_request.rb +1 -1
  60. data/lib/square_connect/models/transaction.rb +2 -2
  61. data/lib/square_connect/version.rb +1 -1
  62. metadata +17 -3
@@ -12,18 +12,27 @@ require 'date'
12
12
  module SquareConnect
13
13
  # Represents a line item in an order. Each line item describes a different product to purchase, with its own quantity and price details.
14
14
  class OrderLineItem
15
- # The line item's ID, unique only within this order.
16
- attr_accessor :id
17
-
18
15
  # The name of the line item.
19
16
  attr_accessor :name
20
17
 
21
18
  # The quantity of the product to purchase. Currently, this string must have an integer value.
22
19
  attr_accessor :quantity
23
20
 
24
- # The base price for a single unit of the line item's associated variation. If a line item represents a Custom Amount instead of a particular product, this field indicates that amount.
21
+ # The taxes applied to this line item.
22
+ attr_accessor :taxes
23
+
24
+ # The discounts applied to this line item.
25
+ attr_accessor :discounts
26
+
27
+ # The base price for a single unit of the line item.
25
28
  attr_accessor :base_price_money
26
29
 
30
+ # The total tax amount of money to collect for the line item.
31
+ attr_accessor :total_tax_money
32
+
33
+ # The total discount amount of money to collect for the line item.
34
+ attr_accessor :total_discount_money
35
+
27
36
  # The total amount of money to collect for this line item.
28
37
  attr_accessor :total_money
29
38
 
@@ -31,10 +40,13 @@ module SquareConnect
31
40
  # Attribute mapping from ruby-style variable name to JSON key.
32
41
  def self.attribute_map
33
42
  {
34
- :'id' => :'id',
35
43
  :'name' => :'name',
36
44
  :'quantity' => :'quantity',
45
+ :'taxes' => :'taxes',
46
+ :'discounts' => :'discounts',
37
47
  :'base_price_money' => :'base_price_money',
48
+ :'total_tax_money' => :'total_tax_money',
49
+ :'total_discount_money' => :'total_discount_money',
38
50
  :'total_money' => :'total_money'
39
51
  }
40
52
  end
@@ -42,10 +54,13 @@ module SquareConnect
42
54
  # Attribute type mapping.
43
55
  def self.swagger_types
44
56
  {
45
- :'id' => :'String',
46
57
  :'name' => :'String',
47
58
  :'quantity' => :'String',
59
+ :'taxes' => :'Array<OrderLineItemTax>',
60
+ :'discounts' => :'Array<OrderLineItemDiscount>',
48
61
  :'base_price_money' => :'Money',
62
+ :'total_tax_money' => :'Money',
63
+ :'total_discount_money' => :'Money',
49
64
  :'total_money' => :'Money'
50
65
  }
51
66
  end
@@ -58,10 +73,6 @@ module SquareConnect
58
73
  # convert string to symbol for hash key
59
74
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
60
75
 
61
- if attributes.has_key?(:'id')
62
- self.id = attributes[:'id']
63
- end
64
-
65
76
  if attributes.has_key?(:'name')
66
77
  self.name = attributes[:'name']
67
78
  end
@@ -70,10 +81,30 @@ module SquareConnect
70
81
  self.quantity = attributes[:'quantity']
71
82
  end
72
83
 
84
+ if attributes.has_key?(:'taxes')
85
+ if (value = attributes[:'taxes']).is_a?(Array)
86
+ self.taxes = value
87
+ end
88
+ end
89
+
90
+ if attributes.has_key?(:'discounts')
91
+ if (value = attributes[:'discounts']).is_a?(Array)
92
+ self.discounts = value
93
+ end
94
+ end
95
+
73
96
  if attributes.has_key?(:'base_price_money')
74
97
  self.base_price_money = attributes[:'base_price_money']
75
98
  end
76
99
 
100
+ if attributes.has_key?(:'total_tax_money')
101
+ self.total_tax_money = attributes[:'total_tax_money']
102
+ end
103
+
104
+ if attributes.has_key?(:'total_discount_money')
105
+ self.total_discount_money = attributes[:'total_discount_money']
106
+ end
107
+
77
108
  if attributes.has_key?(:'total_money')
78
109
  self.total_money = attributes[:'total_money']
79
110
  end
@@ -98,10 +129,13 @@ module SquareConnect
98
129
  def ==(o)
99
130
  return true if self.equal?(o)
100
131
  self.class == o.class &&
101
- id == o.id &&
102
132
  name == o.name &&
103
133
  quantity == o.quantity &&
134
+ taxes == o.taxes &&
135
+ discounts == o.discounts &&
104
136
  base_price_money == o.base_price_money &&
137
+ total_tax_money == o.total_tax_money &&
138
+ total_discount_money == o.total_discount_money &&
105
139
  total_money == o.total_money
106
140
  end
107
141
 
@@ -114,7 +148,7 @@ module SquareConnect
114
148
  # Calculates hash code according to all attributes.
115
149
  # @return [Fixnum] Hash code
116
150
  def hash
117
- [id, name, quantity, base_price_money, total_money].hash
151
+ [name, quantity, taxes, discounts, base_price_money, total_tax_money, total_discount_money, total_money].hash
118
152
  end
119
153
 
120
154
  # Builds the object from hash
@@ -0,0 +1,281 @@
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 discount that applies to one or more line items in an order. Fixed-amount, order-level discounts are distributed across all non-zero line item totals. The amount distributed to each line item is relative to that item’s contribution to the order subtotal.
14
+ class OrderLineItemDiscount
15
+ # The discount's name.
16
+ attr_accessor :name
17
+
18
+ # The type of the discount. If it is created by API, it would be either `FIXED_PERCENTAGE` or `FIXED_AMOUNT`. VARIABLE_* is not supported in API because the order is created at the time of sale and either percentage or amount has to be specified. See [OrderLineItemDiscountType](#type-orderlineitemdiscounttype) for possible values.
19
+ attr_accessor :type
20
+
21
+ # The percentage of the tax, as a string representation of a decimal number. A value of `7.25` corresponds to a percentage of 7.25%. The percentage won't be set for an amount-based discount.
22
+ attr_accessor :percentage
23
+
24
+ # The total monetary amount of the applicable discount. If it is at order level, it is the value of the order level discount. If it is at line item level, it is the value of the line item level discount. The amount_money won't be set for a percentage-based discount.
25
+ attr_accessor :amount_money
26
+
27
+ # The amount of discount actually applied to this line item. Represents the amount of money applied to a line item as a discount When an amount-based discount is at order-level, this value is different from `amount_money` because the discount is distributed across the line items.
28
+ attr_accessor :applied_money
29
+
30
+ # Indicates the level at which the discount applies. See [OrderLineItemDiscountScope](#type-orderlineitemdiscountscope) for possible values.
31
+ attr_accessor :scope
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
+ :'name' => :'name',
59
+ :'type' => :'type',
60
+ :'percentage' => :'percentage',
61
+ :'amount_money' => :'amount_money',
62
+ :'applied_money' => :'applied_money',
63
+ :'scope' => :'scope'
64
+ }
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.swagger_types
69
+ {
70
+ :'name' => :'String',
71
+ :'type' => :'String',
72
+ :'percentage' => :'String',
73
+ :'amount_money' => :'Money',
74
+ :'applied_money' => :'Money',
75
+ :'scope' => :'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?(:'name')
88
+ self.name = attributes[:'name']
89
+ end
90
+
91
+ if attributes.has_key?(:'type')
92
+ self.type = attributes[:'type']
93
+ end
94
+
95
+ if attributes.has_key?(:'percentage')
96
+ self.percentage = attributes[:'percentage']
97
+ end
98
+
99
+ if attributes.has_key?(:'amount_money')
100
+ self.amount_money = attributes[:'amount_money']
101
+ end
102
+
103
+ if attributes.has_key?(:'applied_money')
104
+ self.applied_money = attributes[:'applied_money']
105
+ end
106
+
107
+ if attributes.has_key?(:'scope')
108
+ self.scope = attributes[:'scope']
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
+ type_validator = EnumAttributeValidator.new('String', ["UNKNOWN", "FIXED_PERCENTAGE", "FIXED_AMOUNT", "VARIABLE_PERCENTAGE", "VARIABLE_AMOUNT"])
124
+ return false unless type_validator.valid?(@type)
125
+ scope_validator = EnumAttributeValidator.new('String', ["LINE_ITEM", "ORDER"])
126
+ return false unless scope_validator.valid?(@scope)
127
+ return true
128
+ end
129
+
130
+ # Custom attribute writer method checking allowed values (enum).
131
+ # @param [Object] type Object to be assigned
132
+ def type=(type)
133
+ validator = EnumAttributeValidator.new('String', ["UNKNOWN", "FIXED_PERCENTAGE", "FIXED_AMOUNT", "VARIABLE_PERCENTAGE", "VARIABLE_AMOUNT"])
134
+ unless validator.valid?(type)
135
+ fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
136
+ end
137
+ @type = type
138
+ end
139
+
140
+ # Custom attribute writer method checking allowed values (enum).
141
+ # @param [Object] scope Object to be assigned
142
+ def scope=(scope)
143
+ validator = EnumAttributeValidator.new('String', ["LINE_ITEM", "ORDER"])
144
+ unless validator.valid?(scope)
145
+ fail ArgumentError, "invalid value for 'scope', must be one of #{validator.allowable_values}."
146
+ end
147
+ @scope = scope
148
+ end
149
+
150
+ # Checks equality by comparing each attribute.
151
+ # @param [Object] Object to be compared
152
+ def ==(o)
153
+ return true if self.equal?(o)
154
+ self.class == o.class &&
155
+ name == o.name &&
156
+ type == o.type &&
157
+ percentage == o.percentage &&
158
+ amount_money == o.amount_money &&
159
+ applied_money == o.applied_money &&
160
+ scope == o.scope
161
+ end
162
+
163
+ # @see the `==` method
164
+ # @param [Object] Object to be compared
165
+ def eql?(o)
166
+ self == o
167
+ end
168
+
169
+ # Calculates hash code according to all attributes.
170
+ # @return [Fixnum] Hash code
171
+ def hash
172
+ [name, type, percentage, amount_money, applied_money, scope].hash
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def build_from_hash(attributes)
179
+ return nil unless attributes.is_a?(Hash)
180
+ self.class.swagger_types.each_pair do |key, type|
181
+ if type =~ /\AArray<(.*)>/i
182
+ # check to ensure the input is an array given that the the attribute
183
+ # is documented as an array but the input is not
184
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
185
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
186
+ end
187
+ elsif !attributes[self.class.attribute_map[key]].nil?
188
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
189
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
190
+ end
191
+
192
+ self
193
+ end
194
+
195
+ # Deserializes the data based on type
196
+ # @param string type Data type
197
+ # @param string value Value to be deserialized
198
+ # @return [Object] Deserialized data
199
+ def _deserialize(type, value)
200
+ case type.to_sym
201
+ when :DateTime
202
+ DateTime.parse(value)
203
+ when :Date
204
+ Date.parse(value)
205
+ when :String
206
+ value.to_s
207
+ when :Integer
208
+ value.to_i
209
+ when :Float
210
+ value.to_f
211
+ when :BOOLEAN
212
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
213
+ true
214
+ else
215
+ false
216
+ end
217
+ when :Object
218
+ # generic object (usually a Hash), return directly
219
+ value
220
+ when /\AArray<(?<inner_type>.+)>\z/
221
+ inner_type = Regexp.last_match[:inner_type]
222
+ value.map { |v| _deserialize(inner_type, v) }
223
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
224
+ k_type = Regexp.last_match[:k_type]
225
+ v_type = Regexp.last_match[:v_type]
226
+ {}.tap do |hash|
227
+ value.each do |k, v|
228
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
229
+ end
230
+ end
231
+ else # model
232
+ temp_model = SquareConnect.const_get(type).new
233
+ temp_model.build_from_hash(value)
234
+ end
235
+ end
236
+
237
+ # Returns the string representation of the object
238
+ # @return [String] String presentation of the object
239
+ def to_s
240
+ to_hash.to_s
241
+ end
242
+
243
+ # to_body is an alias to to_hash (backward compatibility)
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_body
246
+ to_hash
247
+ end
248
+
249
+ # Returns the object in the form of hash
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_hash
252
+ hash = {}
253
+ self.class.attribute_map.each_pair do |attr, param|
254
+ value = self.send(attr)
255
+ next if value.nil?
256
+ hash[param] = _to_hash(value)
257
+ end
258
+ hash
259
+ end
260
+
261
+ # Outputs non-array value in the form of hash
262
+ # For object, use to_hash. Otherwise, just return the value
263
+ # @param [Object] value Any valid value
264
+ # @return [Hash] Returns the value in the form of hash
265
+ def _to_hash(value)
266
+ if value.is_a?(Array)
267
+ value.compact.map{ |v| _to_hash(v) }
268
+ elsif value.is_a?(Hash)
269
+ {}.tap do |hash|
270
+ value.each { |k, v| hash[k] = _to_hash(v) }
271
+ end
272
+ elsif value.respond_to? :to_hash
273
+ value.to_hash
274
+ else
275
+ value
276
+ end
277
+ end
278
+
279
+ end
280
+
281
+ end
@@ -0,0 +1,19 @@
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 OrderLineItemDiscountScope
14
+
15
+ LINE_ITEM = "LINE_ITEM".freeze
16
+ ORDER = "ORDER".freeze
17
+ end
18
+
19
+ end
@@ -0,0 +1,22 @@
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 OrderLineItemDiscountType
14
+
15
+ UNKNOWN = "UNKNOWN".freeze
16
+ FIXED_PERCENTAGE = "FIXED_PERCENTAGE".freeze
17
+ FIXED_AMOUNT = "FIXED_AMOUNT".freeze
18
+ VARIABLE_PERCENTAGE = "VARIABLE_PERCENTAGE".freeze
19
+ VARIABLE_AMOUNT = "VARIABLE_AMOUNT".freeze
20
+ end
21
+
22
+ end