square_connect 2.20190410.1.300 → 2.20190508.0.304

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +10 -0
  3. data/README.md +32 -1
  4. data/docs/BatchRetrieveOrdersResponse.md +1 -0
  5. data/docs/BusinessHours.md +12 -0
  6. data/docs/BusinessHoursPeriod.md +14 -0
  7. data/docs/ChargeRequest.md +3 -3
  8. data/docs/CreateOrderRequest.md +1 -1
  9. data/docs/CreateOrderRequestTax.md +1 -1
  10. data/docs/DayOfWeek.md +18 -0
  11. data/docs/ErrorCode.md +2 -0
  12. data/docs/InventoryAdjustment.md +1 -1
  13. data/docs/InventoryCount.md +2 -2
  14. data/docs/InventoryPhysicalCount.md +2 -2
  15. data/docs/InventoryTransfer.md +1 -1
  16. data/docs/Location.md +1 -0
  17. data/docs/MeasurementUnit.md +16 -0
  18. data/docs/MeasurementUnitArea.md +19 -0
  19. data/docs/MeasurementUnitCustom.md +13 -0
  20. data/docs/MeasurementUnitLength.md +19 -0
  21. data/docs/MeasurementUnitVolume.md +22 -0
  22. data/docs/MeasurementUnitWeight.md +17 -0
  23. data/docs/Order.md +12 -1
  24. data/docs/OrderEntry.md +13 -0
  25. data/docs/OrderLineItem.md +5 -2
  26. data/docs/OrderLineItemDiscount.md +2 -1
  27. data/docs/OrderLineItemModifier.md +2 -1
  28. data/docs/OrderLineItemTax.md +1 -0
  29. data/docs/OrderMoneyAmounts.md +16 -0
  30. data/docs/OrderQuantityUnit.md +13 -0
  31. data/docs/OrderReturn.md +18 -0
  32. data/docs/OrderReturnDiscount.md +20 -0
  33. data/docs/OrderReturnLineItem.md +28 -0
  34. data/docs/OrderReturnLineItemModifier.md +17 -0
  35. data/docs/OrderReturnTax.md +19 -0
  36. data/docs/OrderRoundingAdjustment.md +14 -0
  37. data/docs/OrderSource.md +1 -1
  38. data/docs/OrderState.md +14 -0
  39. data/docs/OrdersApi.md +54 -1
  40. data/docs/SearchOrdersCustomerFilter.md +12 -0
  41. data/docs/SearchOrdersDateTimeFilter.md +14 -0
  42. data/docs/SearchOrdersFilter.md +16 -0
  43. data/docs/SearchOrdersFulfillmentFilter.md +13 -0
  44. data/docs/SearchOrdersQuery.md +13 -0
  45. data/docs/SearchOrdersRequest.md +16 -0
  46. data/docs/SearchOrdersResponse.md +16 -0
  47. data/docs/SearchOrdersSort.md +13 -0
  48. data/docs/SearchOrdersSortField.md +14 -0
  49. data/docs/SearchOrdersSourceFilter.md +12 -0
  50. data/docs/SearchOrdersStateFilter.md +12 -0
  51. data/docs/TransactionsApi.md +1 -1
  52. data/lib/square_connect.rb +30 -0
  53. data/lib/square_connect/api/apple_pay_api.rb +1 -1
  54. data/lib/square_connect/api/catalog_api.rb +11 -11
  55. data/lib/square_connect/api/checkout_api.rb +1 -1
  56. data/lib/square_connect/api/customers_api.rb +8 -8
  57. data/lib/square_connect/api/employees_api.rb +2 -2
  58. data/lib/square_connect/api/inventory_api.rb +7 -7
  59. data/lib/square_connect/api/labor_api.rb +14 -14
  60. data/lib/square_connect/api/locations_api.rb +1 -1
  61. data/lib/square_connect/api/mobile_authorization_api.rb +1 -1
  62. data/lib/square_connect/api/o_auth_api.rb +3 -3
  63. data/lib/square_connect/api/orders_api.rb +59 -4
  64. data/lib/square_connect/api/reporting_api.rb +2 -2
  65. data/lib/square_connect/api/transactions_api.rb +9 -9
  66. data/lib/square_connect/api/v1_employees_api.rb +16 -16
  67. data/lib/square_connect/api/v1_items_api.rb +40 -40
  68. data/lib/square_connect/api/v1_locations_api.rb +2 -2
  69. data/lib/square_connect/api/v1_transactions_api.rb +11 -11
  70. data/lib/square_connect/api_client.rb +1 -1
  71. data/lib/square_connect/models/batch_retrieve_orders_response.rb +16 -4
  72. data/lib/square_connect/models/business_hours.rb +188 -0
  73. data/lib/square_connect/models/business_hours_period.rb +239 -0
  74. data/lib/square_connect/models/charge_request.rb +3 -3
  75. data/lib/square_connect/models/create_order_request.rb +1 -1
  76. data/lib/square_connect/models/create_order_request_tax.rb +1 -1
  77. data/lib/square_connect/models/day_of_week.rb +24 -0
  78. data/lib/square_connect/models/error.rb +2 -2
  79. data/lib/square_connect/models/error_code.rb +2 -0
  80. data/lib/square_connect/models/inventory_adjustment.rb +1 -1
  81. data/lib/square_connect/models/inventory_count.rb +2 -2
  82. data/lib/square_connect/models/inventory_physical_count.rb +2 -2
  83. data/lib/square_connect/models/inventory_transfer.rb +1 -1
  84. data/lib/square_connect/models/location.rb +14 -4
  85. data/lib/square_connect/models/measurement_unit.rb +295 -0
  86. data/lib/square_connect/models/measurement_unit_area.rb +25 -0
  87. data/lib/square_connect/models/measurement_unit_custom.rb +206 -0
  88. data/lib/square_connect/models/measurement_unit_length.rb +25 -0
  89. data/lib/square_connect/models/measurement_unit_volume.rb +28 -0
  90. data/lib/square_connect/models/measurement_unit_weight.rb +23 -0
  91. data/lib/square_connect/models/order.rb +151 -2
  92. data/lib/square_connect/models/order_entry.rb +196 -0
  93. data/lib/square_connect/models/order_line_item.rb +54 -8
  94. data/lib/square_connect/models/order_line_item_discount.rb +28 -2
  95. data/lib/square_connect/models/order_line_item_modifier.rb +28 -2
  96. data/lib/square_connect/models/order_line_item_tax.rb +27 -1
  97. data/lib/square_connect/models/order_money_amounts.rb +226 -0
  98. data/lib/square_connect/models/order_quantity_unit.rb +196 -0
  99. data/lib/square_connect/models/order_return.rb +268 -0
  100. data/lib/square_connect/models/order_return_discount.rb +391 -0
  101. data/lib/square_connect/models/order_return_line_item.rb +481 -0
  102. data/lib/square_connect/models/order_return_line_item_modifier.rb +300 -0
  103. data/lib/square_connect/models/order_return_tax.rb +381 -0
  104. data/lib/square_connect/models/order_rounding_adjustment.rb +222 -0
  105. data/lib/square_connect/models/order_source.rb +1 -1
  106. data/lib/square_connect/models/order_state.rb +20 -0
  107. data/lib/square_connect/models/search_orders_customer_filter.rb +188 -0
  108. data/lib/square_connect/models/search_orders_date_time_filter.rb +206 -0
  109. data/lib/square_connect/models/search_orders_filter.rb +226 -0
  110. data/lib/square_connect/models/search_orders_fulfillment_filter.rb +226 -0
  111. data/lib/square_connect/models/search_orders_query.rb +196 -0
  112. data/lib/square_connect/models/search_orders_request.rb +244 -0
  113. data/lib/square_connect/models/search_orders_response.rb +234 -0
  114. data/lib/square_connect/models/search_orders_sort.rb +246 -0
  115. data/lib/square_connect/models/search_orders_sort_field.rb +20 -0
  116. data/lib/square_connect/models/search_orders_source_filter.rb +188 -0
  117. data/lib/square_connect/models/search_orders_state_filter.rb +214 -0
  118. data/lib/square_connect/version.rb +1 -1
  119. data/spec/models/business_hours_period_spec.rb +55 -0
  120. data/spec/models/business_hours_spec.rb +39 -0
  121. data/spec/models/day_of_week_spec.rb +33 -0
  122. data/spec/models/measurement_unit_area_spec.rb +33 -0
  123. data/spec/models/measurement_unit_custom_spec.rb +45 -0
  124. data/spec/models/measurement_unit_length_spec.rb +33 -0
  125. data/spec/models/measurement_unit_spec.rb +79 -0
  126. data/spec/models/measurement_unit_volume_spec.rb +33 -0
  127. data/spec/models/measurement_unit_weight_spec.rb +33 -0
  128. data/spec/models/order_entry_spec.rb +45 -0
  129. data/spec/models/order_money_amounts_spec.rb +63 -0
  130. data/spec/models/order_quantity_unit_spec.rb +45 -0
  131. data/spec/models/order_return_discount_spec.rb +95 -0
  132. data/spec/models/order_return_line_item_modifier_spec.rb +69 -0
  133. data/spec/models/order_return_line_item_spec.rb +135 -0
  134. data/spec/models/order_return_spec.rb +75 -0
  135. data/spec/models/order_return_tax_spec.rb +89 -0
  136. data/spec/models/order_rounding_adjustment_spec.rb +51 -0
  137. data/spec/models/order_state_spec.rb +33 -0
  138. data/spec/models/search_orders_customer_filter_spec.rb +39 -0
  139. data/spec/models/search_orders_date_time_filter_spec.rb +51 -0
  140. data/spec/models/search_orders_filter_spec.rb +63 -0
  141. data/spec/models/search_orders_fulfillment_filter_spec.rb +53 -0
  142. data/spec/models/search_orders_query_spec.rb +45 -0
  143. data/spec/models/search_orders_request_spec.rb +63 -0
  144. data/spec/models/search_orders_response_spec.rb +63 -0
  145. data/spec/models/search_orders_sort_field_spec.rb +33 -0
  146. data/spec/models/search_orders_sort_spec.rb +53 -0
  147. data/spec/models/search_orders_source_filter_spec.rb +39 -0
  148. data/spec/models/search_orders_state_filter_spec.rb +43 -0
  149. metadata +122 -2
@@ -0,0 +1,222 @@
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
+ # A rounding adjustment of the money being returned. Commonly used to apply Cash Rounding when the minimum unit of account is smaller than the lowest physical denomination of currency.
14
+ class OrderRoundingAdjustment
15
+ # The rounding adjustment's Unique identifier, unique only within this order. This field is read-only.
16
+ attr_accessor :uid
17
+
18
+ # The name of the rounding adjustment from the original sale Order.
19
+ attr_accessor :name
20
+
21
+ # Actual rounding adjustment amount.
22
+ attr_accessor :amount_money
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'uid' => :'uid',
29
+ :'name' => :'name',
30
+ :'amount_money' => :'amount_money'
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'uid' => :'String',
38
+ :'name' => :'String',
39
+ :'amount_money' => :'Money'
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?(:'uid')
52
+ self.uid = attributes[:'uid']
53
+ end
54
+
55
+ if attributes.has_key?(:'name')
56
+ self.name = attributes[:'name']
57
+ end
58
+
59
+ if attributes.has_key?(:'amount_money')
60
+ self.amount_money = attributes[:'amount_money']
61
+ end
62
+
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properies with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ if !@uid.nil? && @uid.to_s.length > 60
70
+ invalid_properties.push("invalid value for 'uid', the character length must be smaller than or equal to 60.")
71
+ end
72
+
73
+ return invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ return false if !@uid.nil? && @uid.to_s.length > 60
80
+ return true
81
+ end
82
+
83
+ # Custom attribute writer method with validation
84
+ # @param [Object] uid Value to be assigned
85
+ def uid=(uid)
86
+
87
+ if !uid.nil? && uid.to_s.length > 60
88
+ fail ArgumentError, "invalid value for 'uid', the character length must be smaller than or equal to 60."
89
+ end
90
+
91
+ @uid = uid
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ uid == o.uid &&
100
+ name == o.name &&
101
+ amount_money == o.amount_money
102
+ end
103
+
104
+ # @see the `==` method
105
+ # @param [Object] Object to be compared
106
+ def eql?(o)
107
+ self == o
108
+ end
109
+
110
+ # Calculates hash code according to all attributes.
111
+ # @return [Fixnum] Hash code
112
+ def hash
113
+ [uid, name, amount_money].hash
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def build_from_hash(attributes)
120
+ return nil unless attributes.is_a?(Hash)
121
+ self.class.swagger_types.each_pair do |key, type|
122
+ if type =~ /\AArray<(.*)>/i
123
+ # check to ensure the input is an array given that the the attribute
124
+ # is documented as an array but the input is not
125
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
126
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
127
+ end
128
+ elsif !attributes[self.class.attribute_map[key]].nil?
129
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
130
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
131
+ end
132
+
133
+ self
134
+ end
135
+
136
+ # Deserializes the data based on type
137
+ # @param string type Data type
138
+ # @param string value Value to be deserialized
139
+ # @return [Object] Deserialized data
140
+ def _deserialize(type, value)
141
+ case type.to_sym
142
+ when :DateTime
143
+ DateTime.parse(value)
144
+ when :Date
145
+ Date.parse(value)
146
+ when :String
147
+ value.to_s
148
+ when :Integer
149
+ value.to_i
150
+ when :Float
151
+ value.to_f
152
+ when :BOOLEAN
153
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154
+ true
155
+ else
156
+ false
157
+ end
158
+ when :Object
159
+ # generic object (usually a Hash), return directly
160
+ value
161
+ when /\AArray<(?<inner_type>.+)>\z/
162
+ inner_type = Regexp.last_match[:inner_type]
163
+ value.map { |v| _deserialize(inner_type, v) }
164
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
165
+ k_type = Regexp.last_match[:k_type]
166
+ v_type = Regexp.last_match[:v_type]
167
+ {}.tap do |hash|
168
+ value.each do |k, v|
169
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
170
+ end
171
+ end
172
+ else # model
173
+ temp_model = SquareConnect.const_get(type).new
174
+ temp_model.build_from_hash(value)
175
+ end
176
+ end
177
+
178
+ # Returns the string representation of the object
179
+ # @return [String] String presentation of the object
180
+ def to_s
181
+ to_hash.to_s
182
+ end
183
+
184
+ # to_body is an alias to to_hash (backward compatibility)
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_body
187
+ to_hash
188
+ end
189
+
190
+ # Returns the object in the form of hash
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_hash
193
+ hash = {}
194
+ self.class.attribute_map.each_pair do |attr, param|
195
+ value = self.send(attr)
196
+ next if value.nil?
197
+ hash[param] = _to_hash(value)
198
+ end
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map{ |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+ end
221
+
222
+ end
@@ -12,7 +12,7 @@ require 'date'
12
12
  module SquareConnect
13
13
  # Represents the origination details of an order.
14
14
  class OrderSource
15
- # The name used to identify the place (physical or digital) that an order originates. If unset, the name defaults to the name of the application that created the order.
15
+ # The name used to identify the place (physical or digital) that an order originates. If unset, the name defaults to the name of the application that created the order.
16
16
  attr_accessor :name
17
17
 
18
18
 
@@ -0,0 +1,20 @@
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 OrderState
14
+
15
+ OPEN = "OPEN".freeze
16
+ COMPLETED = "COMPLETED".freeze
17
+ CANCELED = "CANCELED".freeze
18
+ end
19
+
20
+ end
@@ -0,0 +1,188 @@
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
+ # Filter based on Order `customer_id` and any Tender `customer_id` associated with the Order. Does not filter based on the [FulfillmentRecipient](#type-orderfulfillmentrecipient) `customer_id`.
14
+ class SearchOrdersCustomerFilter
15
+ # Filter by orders with any of the listed `customer_id`s. Max: 10 `customer_id`s.
16
+ attr_accessor :customer_ids
17
+
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'customer_ids' => :'customer_ids'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'customer_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?(:'customer_ids')
42
+ if (value = attributes[:'customer_ids']).is_a?(Array)
43
+ self.customer_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
+ return invalid_properties
54
+ end
55
+
56
+ # Check to see if the all the properties in the model are valid
57
+ # @return true if the model is valid
58
+ def valid?
59
+ return true
60
+ end
61
+
62
+ # Checks equality by comparing each attribute.
63
+ # @param [Object] Object to be compared
64
+ def ==(o)
65
+ return true if self.equal?(o)
66
+ self.class == o.class &&
67
+ customer_ids == o.customer_ids
68
+ end
69
+
70
+ # @see the `==` method
71
+ # @param [Object] Object to be compared
72
+ def eql?(o)
73
+ self == o
74
+ end
75
+
76
+ # Calculates hash code according to all attributes.
77
+ # @return [Fixnum] Hash code
78
+ def hash
79
+ [customer_ids].hash
80
+ end
81
+
82
+ # Builds the object from hash
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ # @return [Object] Returns the model itself
85
+ def build_from_hash(attributes)
86
+ return nil unless attributes.is_a?(Hash)
87
+ self.class.swagger_types.each_pair do |key, type|
88
+ if type =~ /\AArray<(.*)>/i
89
+ # check to ensure the input is an array given that the the attribute
90
+ # is documented as an array but the input is not
91
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
92
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
93
+ end
94
+ elsif !attributes[self.class.attribute_map[key]].nil?
95
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
96
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
97
+ end
98
+
99
+ self
100
+ end
101
+
102
+ # Deserializes the data based on type
103
+ # @param string type Data type
104
+ # @param string value Value to be deserialized
105
+ # @return [Object] Deserialized data
106
+ def _deserialize(type, value)
107
+ case type.to_sym
108
+ when :DateTime
109
+ DateTime.parse(value)
110
+ when :Date
111
+ Date.parse(value)
112
+ when :String
113
+ value.to_s
114
+ when :Integer
115
+ value.to_i
116
+ when :Float
117
+ value.to_f
118
+ when :BOOLEAN
119
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
120
+ true
121
+ else
122
+ false
123
+ end
124
+ when :Object
125
+ # generic object (usually a Hash), return directly
126
+ value
127
+ when /\AArray<(?<inner_type>.+)>\z/
128
+ inner_type = Regexp.last_match[:inner_type]
129
+ value.map { |v| _deserialize(inner_type, v) }
130
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
131
+ k_type = Regexp.last_match[:k_type]
132
+ v_type = Regexp.last_match[:v_type]
133
+ {}.tap do |hash|
134
+ value.each do |k, v|
135
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
136
+ end
137
+ end
138
+ else # model
139
+ temp_model = SquareConnect.const_get(type).new
140
+ temp_model.build_from_hash(value)
141
+ end
142
+ end
143
+
144
+ # Returns the string representation of the object
145
+ # @return [String] String presentation of the object
146
+ def to_s
147
+ to_hash.to_s
148
+ end
149
+
150
+ # to_body is an alias to to_hash (backward compatibility)
151
+ # @return [Hash] Returns the object in the form of hash
152
+ def to_body
153
+ to_hash
154
+ end
155
+
156
+ # Returns the object in the form of hash
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_hash
159
+ hash = {}
160
+ self.class.attribute_map.each_pair do |attr, param|
161
+ value = self.send(attr)
162
+ next if value.nil?
163
+ hash[param] = _to_hash(value)
164
+ end
165
+ hash
166
+ end
167
+
168
+ # Outputs non-array value in the form of hash
169
+ # For object, use to_hash. Otherwise, just return the value
170
+ # @param [Object] value Any valid value
171
+ # @return [Hash] Returns the value in the form of hash
172
+ def _to_hash(value)
173
+ if value.is_a?(Array)
174
+ value.compact.map{ |v| _to_hash(v) }
175
+ elsif value.is_a?(Hash)
176
+ {}.tap do |hash|
177
+ value.each { |k, v| hash[k] = _to_hash(v) }
178
+ end
179
+ elsif value.respond_to? :to_hash
180
+ value.to_hash
181
+ else
182
+ value
183
+ end
184
+ end
185
+
186
+ end
187
+
188
+ end
@@ -0,0 +1,206 @@
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
+ # Filter for `Order` objects based on whether their `CREATED_AT`, `CLOSED_AT` or `UPDATED_AT` timestamps fall within a specified time range. You can specify the time range and which timestamp to filter for. You can filter for only one time range at a time. For each time range, the start time and end time are inclusive. If the end time is absent, it defaults to the time of the first request for the cursor. __Important:__ If you use the DateTimeFilter to filter for `CLOSED_AT` or `UPDATED_AT`, you must also set the [OrdersSort](#type-searchorderordersort). The TimeRange used in DateTimeFilter must correspond to the `sort_field` in the [OrdersSort](#type-searchorderordersort) object.
14
+ class SearchOrdersDateTimeFilter
15
+ # Time range for filtering on the `created_at` timestamp.
16
+ attr_accessor :created_at
17
+
18
+ # Time range for filtering on the `updated_at` timestamp.
19
+ attr_accessor :updated_at
20
+
21
+ # Time range for filtering on the `closed_at` timestamp.
22
+ attr_accessor :closed_at
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'created_at' => :'created_at',
29
+ :'updated_at' => :'updated_at',
30
+ :'closed_at' => :'closed_at'
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'created_at' => :'TimeRange',
38
+ :'updated_at' => :'TimeRange',
39
+ :'closed_at' => :'TimeRange'
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?(:'created_at')
52
+ self.created_at = attributes[:'created_at']
53
+ end
54
+
55
+ if attributes.has_key?(:'updated_at')
56
+ self.updated_at = attributes[:'updated_at']
57
+ end
58
+
59
+ if attributes.has_key?(:'closed_at')
60
+ self.closed_at = attributes[:'closed_at']
61
+ end
62
+
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properies with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ return invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ return true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ created_at == o.created_at &&
84
+ updated_at == o.updated_at &&
85
+ closed_at == o.closed_at
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Fixnum] Hash code
96
+ def hash
97
+ [created_at, updated_at, closed_at].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def build_from_hash(attributes)
104
+ return nil unless attributes.is_a?(Hash)
105
+ self.class.swagger_types.each_pair do |key, type|
106
+ if type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
110
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
111
+ end
112
+ elsif !attributes[self.class.attribute_map[key]].nil?
113
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
114
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def _deserialize(type, value)
125
+ case type.to_sym
126
+ when :DateTime
127
+ DateTime.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :BOOLEAN
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ temp_model = SquareConnect.const_get(type).new
158
+ temp_model.build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map{ |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+
206
+ end