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,196 @@
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
+ # Contains query criteria for the search.
14
+ class SearchOrdersQuery
15
+ # Criteria to filter results by.
16
+ attr_accessor :filter
17
+
18
+ # Criteria to sort results by.
19
+ attr_accessor :sort
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'filter' => :'filter',
26
+ :'sort' => :'sort'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'filter' => :'SearchOrdersFilter',
34
+ :'sort' => :'SearchOrdersSort'
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?(:'filter')
47
+ self.filter = attributes[:'filter']
48
+ end
49
+
50
+ if attributes.has_key?(:'sort')
51
+ self.sort = attributes[:'sort']
52
+ end
53
+
54
+ end
55
+
56
+ # Show invalid properties with the reasons. Usually used together with valid?
57
+ # @return Array for valid properies with the reasons
58
+ def list_invalid_properties
59
+ invalid_properties = Array.new
60
+ return invalid_properties
61
+ end
62
+
63
+ # Check to see if the all the properties in the model are valid
64
+ # @return true if the model is valid
65
+ def valid?
66
+ return true
67
+ end
68
+
69
+ # Checks equality by comparing each attribute.
70
+ # @param [Object] Object to be compared
71
+ def ==(o)
72
+ return true if self.equal?(o)
73
+ self.class == o.class &&
74
+ filter == o.filter &&
75
+ sort == o.sort
76
+ end
77
+
78
+ # @see the `==` method
79
+ # @param [Object] Object to be compared
80
+ def eql?(o)
81
+ self == o
82
+ end
83
+
84
+ # Calculates hash code according to all attributes.
85
+ # @return [Fixnum] Hash code
86
+ def hash
87
+ [filter, sort].hash
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ self.class.swagger_types.each_pair do |key, type|
96
+ if type =~ /\AArray<(.*)>/i
97
+ # check to ensure the input is an array given that the the attribute
98
+ # is documented as an array but the input is not
99
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
100
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
101
+ end
102
+ elsif !attributes[self.class.attribute_map[key]].nil?
103
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
104
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
105
+ end
106
+
107
+ self
108
+ end
109
+
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
114
+ def _deserialize(type, value)
115
+ case type.to_sym
116
+ when :DateTime
117
+ DateTime.parse(value)
118
+ when :Date
119
+ Date.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :BOOLEAN
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+ when :Object
133
+ # generic object (usually a Hash), return directly
134
+ value
135
+ when /\AArray<(?<inner_type>.+)>\z/
136
+ inner_type = Regexp.last_match[:inner_type]
137
+ value.map { |v| _deserialize(inner_type, v) }
138
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
139
+ k_type = Regexp.last_match[:k_type]
140
+ v_type = Regexp.last_match[:v_type]
141
+ {}.tap do |hash|
142
+ value.each do |k, v|
143
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
144
+ end
145
+ end
146
+ else # model
147
+ temp_model = SquareConnect.const_get(type).new
148
+ temp_model.build_from_hash(value)
149
+ end
150
+ end
151
+
152
+ # Returns the string representation of the object
153
+ # @return [String] String presentation of the object
154
+ def to_s
155
+ to_hash.to_s
156
+ end
157
+
158
+ # to_body is an alias to to_hash (backward compatibility)
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_body
161
+ to_hash
162
+ end
163
+
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_hash
167
+ hash = {}
168
+ self.class.attribute_map.each_pair do |attr, param|
169
+ value = self.send(attr)
170
+ next if value.nil?
171
+ hash[param] = _to_hash(value)
172
+ end
173
+ hash
174
+ end
175
+
176
+ # Outputs non-array value in the form of hash
177
+ # For object, use to_hash. Otherwise, just return the value
178
+ # @param [Object] value Any valid value
179
+ # @return [Hash] Returns the value in the form of hash
180
+ def _to_hash(value)
181
+ if value.is_a?(Array)
182
+ value.compact.map{ |v| _to_hash(v) }
183
+ elsif value.is_a?(Hash)
184
+ {}.tap do |hash|
185
+ value.each { |k, v| hash[k] = _to_hash(v) }
186
+ end
187
+ elsif value.respond_to? :to_hash
188
+ value.to_hash
189
+ else
190
+ value
191
+ end
192
+ end
193
+
194
+ end
195
+
196
+ end
@@ -0,0 +1,244 @@
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
+ # The request does not have any required fields. When given no query criteria, SearchOrders will return all results for all of the merchant’s locations. When fetching additional pages using a `cursor`, the `query` must be equal to the `query` used to fetch the first page of results.
14
+ class SearchOrdersRequest
15
+ # The location IDs for the orders to query. The caller must have access to all provided locations. Min: 1 `location_ids`. Max: 10 `location_ids`.
16
+ attr_accessor :location_ids
17
+
18
+ # A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Pagination](/basics/api101/pagination) for more information.
19
+ attr_accessor :cursor
20
+
21
+ # Query conditions used to filter or sort the results. Note that when fetching additional pages using a `cursor`, the `query` must be equal to the `query` used to fetch the first page of results.
22
+ attr_accessor :query
23
+
24
+ # Number of results to be returned in a single page. SearchOrders may use a smaller limit than specified depending on server load. If the response includes a `cursor` field, you can use it to retrieve the next set of results. Default: `500`
25
+ attr_accessor :limit
26
+
27
+ # If set to `true`, SearchOrders will return [`OrderEntry`](#type-orderentry) objects instead of `Order` objects. `OrderEntry` objects are lightweight descriptions of orders that include `order_id`s. Default: `false`.
28
+ attr_accessor :return_entries
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'location_ids' => :'location_ids',
35
+ :'cursor' => :'cursor',
36
+ :'query' => :'query',
37
+ :'limit' => :'limit',
38
+ :'return_entries' => :'return_entries'
39
+ }
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.swagger_types
44
+ {
45
+ :'location_ids' => :'Array<String>',
46
+ :'cursor' => :'String',
47
+ :'query' => :'SearchOrdersQuery',
48
+ :'limit' => :'Integer',
49
+ :'return_entries' => :'BOOLEAN'
50
+ }
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ return unless attributes.is_a?(Hash)
57
+
58
+ # convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
60
+
61
+ if attributes.has_key?(:'location_ids')
62
+ if (value = attributes[:'location_ids']).is_a?(Array)
63
+ self.location_ids = value
64
+ end
65
+ end
66
+
67
+ if attributes.has_key?(:'cursor')
68
+ self.cursor = attributes[:'cursor']
69
+ end
70
+
71
+ if attributes.has_key?(:'query')
72
+ self.query = attributes[:'query']
73
+ end
74
+
75
+ if attributes.has_key?(:'limit')
76
+ self.limit = attributes[:'limit']
77
+ end
78
+
79
+ if attributes.has_key?(:'return_entries')
80
+ self.return_entries = attributes[:'return_entries']
81
+ end
82
+
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properies with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ if !@limit.nil? && @limit < 1
90
+ invalid_properties.push("invalid value for 'limit', must be greater than or equal to 1.")
91
+ end
92
+
93
+ return invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ return false if !@limit.nil? && @limit < 1
100
+ return true
101
+ end
102
+
103
+ # Custom attribute writer method with validation
104
+ # @param [Object] limit Value to be assigned
105
+ def limit=(limit)
106
+
107
+ if !limit.nil? && limit < 1
108
+ fail ArgumentError, "invalid value for 'limit', must be greater than or equal to 1."
109
+ end
110
+
111
+ @limit = limit
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ location_ids == o.location_ids &&
120
+ cursor == o.cursor &&
121
+ query == o.query &&
122
+ limit == o.limit &&
123
+ return_entries == o.return_entries
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Fixnum] Hash code
134
+ def hash
135
+ [location_ids, cursor, query, limit, return_entries].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ self.class.swagger_types.each_pair do |key, type|
144
+ if type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
148
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
149
+ end
150
+ elsif !attributes[self.class.attribute_map[key]].nil?
151
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :DateTime
165
+ DateTime.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :BOOLEAN
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ temp_model = SquareConnect.const_get(type).new
196
+ temp_model.build_from_hash(value)
197
+ end
198
+ end
199
+
200
+ # Returns the string representation of the object
201
+ # @return [String] String presentation of the object
202
+ def to_s
203
+ to_hash.to_s
204
+ end
205
+
206
+ # to_body is an alias to to_hash (backward compatibility)
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_body
209
+ to_hash
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = self.send(attr)
218
+ next if value.nil?
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value)
229
+ if value.is_a?(Array)
230
+ value.compact.map{ |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to? :to_hash
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+
242
+ end
243
+
244
+ end
@@ -0,0 +1,234 @@
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
+ # Only one of `order_entries` or `orders` fields will be set, depending on whether `return_entries` was set on the [SearchOrdersRequest](#type-searchorderrequest).
14
+ class SearchOrdersResponse
15
+ # List of [OrderEntries](#type-orderentry) that fit the query conditions. Populated only if `order_entries` was set to `true` in the request.
16
+ attr_accessor :order_entries
17
+
18
+ # List of [Orders](#type-order) that match query conditions. Populated only if `return_entries` in the request is set to `false`.
19
+ attr_accessor :orders
20
+
21
+ # The pagination cursor to be used in a subsequent request. If unset, this is the final response. See [Pagination](/basics/api101/pagination) for more information.
22
+ attr_accessor :cursor
23
+
24
+ # [Errors](#type-error) encountered during the search.
25
+ attr_accessor :errors
26
+
27
+ # List of transaction IDs identifying transactions that could not be converted to an `Order`. Empty if `return_entries` is true, however, attempts to retrieve those orders may encounter subsequent `unconvertible_transcation_ids` Note that this field will not be present after SearchOrders moves from BETA to GA.
28
+ attr_accessor :unconvertible_transaction_ids
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'order_entries' => :'order_entries',
35
+ :'orders' => :'orders',
36
+ :'cursor' => :'cursor',
37
+ :'errors' => :'errors',
38
+ :'unconvertible_transaction_ids' => :'unconvertible_transaction_ids'
39
+ }
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.swagger_types
44
+ {
45
+ :'order_entries' => :'Array<OrderEntry>',
46
+ :'orders' => :'Array<Order>',
47
+ :'cursor' => :'String',
48
+ :'errors' => :'Array<Error>',
49
+ :'unconvertible_transaction_ids' => :'Array<String>'
50
+ }
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ return unless attributes.is_a?(Hash)
57
+
58
+ # convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
60
+
61
+ if attributes.has_key?(:'order_entries')
62
+ if (value = attributes[:'order_entries']).is_a?(Array)
63
+ self.order_entries = value
64
+ end
65
+ end
66
+
67
+ if attributes.has_key?(:'orders')
68
+ if (value = attributes[:'orders']).is_a?(Array)
69
+ self.orders = value
70
+ end
71
+ end
72
+
73
+ if attributes.has_key?(:'cursor')
74
+ self.cursor = attributes[:'cursor']
75
+ end
76
+
77
+ if attributes.has_key?(:'errors')
78
+ if (value = attributes[:'errors']).is_a?(Array)
79
+ self.errors = value
80
+ end
81
+ end
82
+
83
+ if attributes.has_key?(:'unconvertible_transaction_ids')
84
+ if (value = attributes[:'unconvertible_transaction_ids']).is_a?(Array)
85
+ self.unconvertible_transaction_ids = value
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properies with the reasons
93
+ def list_invalid_properties
94
+ invalid_properties = Array.new
95
+ return invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ return true
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ order_entries == o.order_entries &&
110
+ orders == o.orders &&
111
+ cursor == o.cursor &&
112
+ errors == o.errors &&
113
+ unconvertible_transaction_ids == o.unconvertible_transaction_ids
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Fixnum] Hash code
124
+ def hash
125
+ [order_entries, orders, cursor, errors, unconvertible_transaction_ids].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ self.class.swagger_types.each_pair do |key, type|
134
+ if type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
138
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
139
+ end
140
+ elsif !attributes[self.class.attribute_map[key]].nil?
141
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :DateTime
155
+ DateTime.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :BOOLEAN
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ temp_model = SquareConnect.const_get(type).new
186
+ temp_model.build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ next if value.nil?
209
+ hash[param] = _to_hash(value)
210
+ end
211
+ hash
212
+ end
213
+
214
+ # Outputs non-array value in the form of hash
215
+ # For object, use to_hash. Otherwise, just return the value
216
+ # @param [Object] value Any valid value
217
+ # @return [Hash] Returns the value in the form of hash
218
+ def _to_hash(value)
219
+ if value.is_a?(Array)
220
+ value.compact.map{ |v| _to_hash(v) }
221
+ elsif value.is_a?(Hash)
222
+ {}.tap do |hash|
223
+ value.each { |k, v| hash[k] = _to_hash(v) }
224
+ end
225
+ elsif value.respond_to? :to_hash
226
+ value.to_hash
227
+ else
228
+ value
229
+ end
230
+ end
231
+
232
+ end
233
+
234
+ end