square_connect 2.0.0 → 2.0.2.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -0
  3. data/README.md +151 -9
  4. data/Rakefile +8 -0
  5. data/docs/Address.md +26 -0
  6. data/docs/CaptureTransactionRequest.md +11 -0
  7. data/docs/CaptureTransactionResponse.md +12 -0
  8. data/docs/Card.md +18 -0
  9. data/docs/CardBrand.md +20 -0
  10. data/docs/ChargeRequest.md +22 -0
  11. data/docs/ChargeResponse.md +13 -0
  12. data/docs/Checkout.md +20 -0
  13. data/docs/CheckoutApi.md +62 -0
  14. data/docs/Country.md +261 -0
  15. data/docs/CreateCheckoutRequest.md +18 -0
  16. data/docs/CreateCheckoutResponse.md +13 -0
  17. data/docs/CreateCustomerCardRequest.md +14 -0
  18. data/docs/CreateCustomerCardResponse.md +13 -0
  19. data/docs/CreateCustomerRequest.md +20 -0
  20. data/docs/CreateCustomerResponse.md +13 -0
  21. data/docs/CreateOrderRequest.md +13 -0
  22. data/docs/CreateOrderRequestLineItem.md +14 -0
  23. data/docs/CreateOrderRequestOrder.md +13 -0
  24. data/docs/CreateRefundRequest.md +15 -0
  25. data/docs/CreateRefundResponse.md +13 -0
  26. data/docs/Currency.md +191 -0
  27. data/docs/Customer.md +26 -0
  28. data/docs/CustomerApi.md +267 -0
  29. data/docs/CustomerCardApi.md +116 -0
  30. data/docs/CustomerGroupInfo.md +13 -0
  31. data/docs/CustomerPreferences.md +12 -0
  32. data/docs/DeleteCustomerCardRequest.md +11 -0
  33. data/docs/DeleteCustomerCardResponse.md +12 -0
  34. data/docs/DeleteCustomerRequest.md +11 -0
  35. data/docs/DeleteCustomerResponse.md +12 -0
  36. data/docs/Error.md +15 -0
  37. data/docs/ErrorCategory.md +17 -0
  38. data/docs/ErrorCode.md +83 -0
  39. data/docs/ListCustomersRequest.md +12 -0
  40. data/docs/ListCustomersResponse.md +14 -0
  41. data/docs/ListLocationsRequest.md +11 -0
  42. data/docs/ListLocationsResponse.md +13 -0
  43. data/docs/ListRefundsRequest.md +15 -0
  44. data/docs/ListRefundsResponse.md +14 -0
  45. data/docs/ListTransactionsRequest.md +15 -0
  46. data/docs/ListTransactionsResponse.md +14 -0
  47. data/docs/Location.md +16 -0
  48. data/docs/LocationApi.md +56 -0
  49. data/docs/LocationCapability.md +12 -0
  50. data/docs/Money.md +13 -0
  51. data/docs/Order.md +16 -0
  52. data/docs/OrderLineItem.md +16 -0
  53. data/docs/Refund.md +20 -0
  54. data/docs/RefundApi.md +126 -0
  55. data/docs/RefundStatus.md +15 -0
  56. data/docs/RetrieveCustomerRequest.md +11 -0
  57. data/docs/RetrieveCustomerResponse.md +13 -0
  58. data/docs/RetrieveTransactionRequest.md +11 -0
  59. data/docs/RetrieveTransactionResponse.md +13 -0
  60. data/docs/SortOrder.md +13 -0
  61. data/docs/Tender.md +22 -0
  62. data/docs/TenderCardDetails.md +14 -0
  63. data/docs/TenderCardDetailsEntryMethod.md +16 -0
  64. data/docs/TenderCardDetailsStatus.md +15 -0
  65. data/docs/TenderCashDetails.md +13 -0
  66. data/docs/TenderType.md +17 -0
  67. data/docs/Transaction.md +21 -0
  68. data/docs/TransactionApi.md +285 -0
  69. data/docs/TransactionProduct.md +19 -0
  70. data/docs/UpdateCustomerRequest.md +20 -0
  71. data/docs/UpdateCustomerResponse.md +13 -0
  72. data/docs/VoidTransactionRequest.md +11 -0
  73. data/docs/VoidTransactionResponse.md +12 -0
  74. data/lib/square_connect.rb +33 -16
  75. data/lib/square_connect/api/checkout_api.rb +82 -0
  76. data/lib/square_connect/api/customer_api.rb +121 -162
  77. data/lib/square_connect/api/customer_card_api.rb +31 -50
  78. data/lib/square_connect/api/location_api.rb +12 -20
  79. data/lib/square_connect/api/refund_api.rb +70 -90
  80. data/lib/square_connect/api/transaction_api.rb +119 -165
  81. data/lib/square_connect/api_client.rb +64 -17
  82. data/lib/square_connect/api_error.rb +7 -3
  83. data/lib/square_connect/configuration.rb +31 -1
  84. data/lib/square_connect/models/address.rb +149 -78
  85. data/lib/square_connect/models/capture_transaction_request.rb +176 -0
  86. data/lib/square_connect/models/capture_transaction_response.rb +54 -26
  87. data/lib/square_connect/models/card.rb +98 -52
  88. data/lib/square_connect/models/card_brand.rb +12 -133
  89. data/lib/square_connect/models/charge_request.rb +106 -67
  90. data/lib/square_connect/models/charge_response.rb +57 -30
  91. data/lib/square_connect/models/checkout.rb +266 -0
  92. data/lib/square_connect/models/country.rb +253 -133
  93. data/lib/square_connect/models/create_checkout_request.rb +316 -0
  94. data/lib/square_connect/models/create_checkout_response.rb +198 -0
  95. data/lib/square_connect/models/create_customer_card_request.rb +66 -35
  96. data/lib/square_connect/models/create_customer_card_response.rb +58 -31
  97. data/lib/square_connect/models/create_customer_request.rb +79 -59
  98. data/lib/square_connect/models/create_customer_response.rb +58 -31
  99. data/lib/square_connect/models/create_order_request.rb +234 -0
  100. data/lib/square_connect/models/create_order_request_line_item.rb +268 -0
  101. data/lib/square_connect/models/create_order_request_order.rb +219 -0
  102. data/lib/square_connect/models/create_refund_request.rb +79 -39
  103. data/lib/square_connect/models/create_refund_response.rb +57 -30
  104. data/lib/square_connect/models/currency.rb +183 -133
  105. data/lib/square_connect/models/customer.rb +130 -77
  106. data/lib/square_connect/models/customer_group_info.rb +206 -0
  107. data/lib/square_connect/models/customer_preferences.rb +186 -0
  108. data/lib/square_connect/models/delete_customer_card_request.rb +176 -0
  109. data/lib/square_connect/models/delete_customer_card_response.rb +55 -27
  110. data/lib/square_connect/models/delete_customer_request.rb +176 -0
  111. data/lib/square_connect/models/delete_customer_response.rb +55 -27
  112. data/lib/square_connect/models/error.rb +107 -45
  113. data/lib/square_connect/models/error_category.rb +9 -133
  114. data/lib/square_connect/models/error_code.rb +75 -133
  115. data/lib/square_connect/models/list_customers_request.rb +55 -27
  116. data/lib/square_connect/models/list_customers_response.rb +61 -35
  117. data/lib/square_connect/models/list_locations_request.rb +176 -0
  118. data/lib/square_connect/models/list_locations_response.rb +57 -30
  119. data/lib/square_connect/models/list_refunds_request.rb +91 -42
  120. data/lib/square_connect/models/list_refunds_response.rb +59 -33
  121. data/lib/square_connect/models/list_transactions_request.rb +91 -42
  122. data/lib/square_connect/models/list_transactions_response.rb +59 -33
  123. data/lib/square_connect/models/location.rb +86 -41
  124. data/lib/square_connect/models/location_capability.rb +4 -133
  125. data/lib/square_connect/models/money.rb +85 -34
  126. data/lib/square_connect/models/order.rb +228 -0
  127. data/lib/square_connect/models/order_line_item.rb +226 -0
  128. data/lib/square_connect/models/refund.rb +138 -59
  129. data/lib/square_connect/models/refund_status.rb +7 -133
  130. data/lib/square_connect/models/retrieve_customer_request.rb +176 -0
  131. data/lib/square_connect/models/retrieve_customer_response.rb +58 -31
  132. data/lib/square_connect/models/retrieve_transaction_request.rb +176 -0
  133. data/lib/square_connect/models/retrieve_transaction_response.rb +57 -30
  134. data/lib/square_connect/models/sort_order.rb +5 -133
  135. data/lib/square_connect/models/tender.rb +112 -65
  136. data/lib/square_connect/models/tender_card_details.rb +93 -40
  137. data/lib/square_connect/models/tender_card_details_entry_method.rb +8 -133
  138. data/lib/square_connect/models/tender_card_details_status.rb +7 -133
  139. data/lib/square_connect/models/tender_cash_details.rb +58 -31
  140. data/lib/square_connect/models/tender_type.rb +9 -133
  141. data/lib/square_connect/models/transaction.rb +132 -56
  142. data/lib/square_connect/models/transaction_product.rb +11 -133
  143. data/lib/square_connect/models/update_customer_request.rb +79 -59
  144. data/lib/square_connect/models/update_customer_response.rb +58 -31
  145. data/lib/square_connect/models/void_transaction_request.rb +176 -0
  146. data/lib/square_connect/models/void_transaction_response.rb +54 -26
  147. data/lib/square_connect/version.rb +2 -3
  148. data/spec/api/checkout_api_spec.rb +53 -0
  149. data/spec/api/customer_api_spec.rb +121 -0
  150. data/spec/api/customer_card_api_spec.rb +71 -0
  151. data/spec/api/location_api_spec.rb +58 -0
  152. data/spec/api/refund_api_spec.rb +75 -0
  153. data/spec/api/transaction_api_spec.rb +128 -0
  154. data/spec/api_client_spec.rb +226 -0
  155. data/spec/configuration_spec.rb +42 -0
  156. data/spec/models/address_spec.rb +186 -0
  157. data/spec/models/capture_transaction_request_spec.rb +36 -0
  158. data/spec/models/capture_transaction_response_spec.rb +46 -0
  159. data/spec/models/card_brand_spec.rb +36 -0
  160. data/spec/models/card_spec.rb +106 -0
  161. data/spec/models/charge_request_spec.rb +146 -0
  162. data/spec/models/charge_response_spec.rb +56 -0
  163. data/spec/models/checkout_spec.rb +126 -0
  164. data/spec/models/country_spec.rb +36 -0
  165. data/spec/models/create_checkout_request_spec.rb +106 -0
  166. data/spec/models/create_checkout_response_spec.rb +56 -0
  167. data/spec/models/create_customer_card_request_spec.rb +66 -0
  168. data/spec/models/create_customer_card_response_spec.rb +56 -0
  169. data/spec/models/create_customer_request_spec.rb +126 -0
  170. data/spec/models/create_customer_response_spec.rb +56 -0
  171. data/spec/models/create_order_request_line_item_spec.rb +66 -0
  172. data/spec/models/create_order_request_order_spec.rb +56 -0
  173. data/spec/models/create_order_request_spec.rb +56 -0
  174. data/spec/models/create_refund_request_spec.rb +76 -0
  175. data/spec/models/create_refund_response_spec.rb +56 -0
  176. data/spec/models/currency_spec.rb +36 -0
  177. data/spec/models/customer_group_info_spec.rb +56 -0
  178. data/spec/models/customer_preferences_spec.rb +46 -0
  179. data/spec/models/customer_spec.rb +186 -0
  180. data/spec/models/delete_customer_card_request_spec.rb +36 -0
  181. data/spec/models/delete_customer_card_response_spec.rb +46 -0
  182. data/spec/models/delete_customer_request_spec.rb +36 -0
  183. data/spec/models/delete_customer_response_spec.rb +46 -0
  184. data/spec/models/error_category_spec.rb +36 -0
  185. data/spec/models/error_code_spec.rb +36 -0
  186. data/spec/models/error_spec.rb +76 -0
  187. data/spec/models/list_customers_request_spec.rb +46 -0
  188. data/spec/models/list_customers_response_spec.rb +66 -0
  189. data/spec/models/list_locations_request_spec.rb +36 -0
  190. data/spec/models/list_locations_response_spec.rb +56 -0
  191. data/spec/models/list_refunds_request_spec.rb +76 -0
  192. data/spec/models/list_refunds_response_spec.rb +66 -0
  193. data/spec/models/list_transactions_request_spec.rb +76 -0
  194. data/spec/models/list_transactions_response_spec.rb +66 -0
  195. data/spec/models/location_capability_spec.rb +36 -0
  196. data/spec/models/location_spec.rb +86 -0
  197. data/spec/models/money_spec.rb +56 -0
  198. data/spec/models/order_line_item_spec.rb +86 -0
  199. data/spec/models/order_spec.rb +86 -0
  200. data/spec/models/refund_spec.rb +126 -0
  201. data/spec/models/refund_status_spec.rb +36 -0
  202. data/spec/models/retrieve_customer_request_spec.rb +36 -0
  203. data/spec/models/retrieve_customer_response_spec.rb +56 -0
  204. data/spec/models/retrieve_transaction_request_spec.rb +36 -0
  205. data/spec/models/retrieve_transaction_response_spec.rb +56 -0
  206. data/spec/models/sort_order_spec.rb +36 -0
  207. data/spec/models/tender_card_details_entry_method_spec.rb +36 -0
  208. data/spec/models/tender_card_details_spec.rb +66 -0
  209. data/spec/models/tender_card_details_status_spec.rb +36 -0
  210. data/spec/models/tender_cash_details_spec.rb +56 -0
  211. data/spec/models/tender_spec.rb +146 -0
  212. data/spec/models/tender_type_spec.rb +36 -0
  213. data/spec/models/transaction_product_spec.rb +36 -0
  214. data/spec/models/transaction_spec.rb +136 -0
  215. data/spec/models/update_customer_request_spec.rb +126 -0
  216. data/spec/models/update_customer_response_spec.rb +56 -0
  217. data/spec/models/void_transaction_request_spec.rb +36 -0
  218. data/spec/models/void_transaction_response_spec.rb +46 -0
  219. data/spec/spec_helper.rb +115 -0
  220. data/square_connect.gemspec +22 -11
  221. data/travis-ci/accounts.enc +0 -0
  222. metadata +264 -31
@@ -1,42 +1,58 @@
1
1
  =begin
2
- Square Connect API
2
+ #Square Connect API
3
3
 
4
4
  OpenAPI spec version: 2.0
5
5
 
6
6
  Generated by: https://github.com/swagger-api/swagger-codegen.git
7
7
 
8
-
9
8
  =end
10
9
 
11
10
  require 'date'
12
11
 
13
12
  module SquareConnect
14
- # Defines the query parameters that can be included in\na request to the **ListTransactions** endpoint.
13
+ # Defines the query parameters that can be included in a request to the [ListTransactions](#endpoint-listtransactions) endpoint.
15
14
  class ListTransactionsRequest
16
- # The beginning of the requested reporting period, in RFC 3339 format.
15
+ # The beginning of the requested reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for details on date inclusivity/exclusivity. Default value: The current time minus one year.
17
16
  attr_accessor :begin_time
18
17
 
19
- # The end of the requested reporting period, in RFC 3339 format.
18
+ # The end of the requested reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for details on date inclusivity/exclusivity. Default value: The current time.
20
19
  attr_accessor :end_time
21
20
 
22
- # The order in which results are listed in the response (`ASC` for\nchronological, `DESC` for reverse-chronological).
21
+ # The order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first). Default value: `DESC`
23
22
  attr_accessor :sort_order
24
23
 
25
- # A pagination cursor to retrieve the next set of results for your\noriginal query to the endpoint.
24
+ # 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 [Paginating results](#paginatingresults) for more information.
26
25
  attr_accessor :cursor
27
26
 
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
28
49
  # Attribute mapping from ruby-style variable name to JSON key.
29
50
  def self.attribute_map
30
51
  {
31
-
32
52
  :'begin_time' => :'begin_time',
33
-
34
53
  :'end_time' => :'end_time',
35
-
36
54
  :'sort_order' => :'sort_order',
37
-
38
55
  :'cursor' => :'cursor'
39
-
40
56
  }
41
57
  end
42
58
 
@@ -47,45 +63,62 @@ module SquareConnect
47
63
  :'end_time' => :'String',
48
64
  :'sort_order' => :'String',
49
65
  :'cursor' => :'String'
50
-
51
66
  }
52
67
  end
53
68
 
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
54
71
  def initialize(attributes = {})
55
72
  return unless attributes.is_a?(Hash)
56
73
 
57
74
  # convert string to symbol for hash key
58
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
75
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
59
76
 
60
-
61
- if attributes[:'begin_time']
77
+ if attributes.has_key?(:'begin_time')
62
78
  self.begin_time = attributes[:'begin_time']
63
79
  end
64
-
65
- if attributes[:'end_time']
80
+
81
+ if attributes.has_key?(:'end_time')
66
82
  self.end_time = attributes[:'end_time']
67
83
  end
68
-
69
- if attributes[:'sort_order']
84
+
85
+ if attributes.has_key?(:'sort_order')
70
86
  self.sort_order = attributes[:'sort_order']
71
87
  end
72
-
73
- if attributes[:'cursor']
88
+
89
+ if attributes.has_key?(:'cursor')
74
90
  self.cursor = attributes[:'cursor']
75
91
  end
76
-
92
+
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properies with the reasons
97
+ def list_invalid_properties
98
+ invalid_properties = Array.new
99
+ return invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ sort_order_validator = EnumAttributeValidator.new('String', ["DESC", "ASC"])
106
+ return false unless sort_order_validator.valid?(@sort_order)
107
+ return true
77
108
  end
78
109
 
79
110
  # Custom attribute writer method checking allowed values (enum).
111
+ # @param [Object] sort_order Object to be assigned
80
112
  def sort_order=(sort_order)
81
- allowed_values = ["DESC", "ASC"]
82
- if sort_order && !allowed_values.include?(sort_order)
83
- fail "invalid value for 'sort_order', must be one of #{allowed_values}"
113
+ validator = EnumAttributeValidator.new('String', ["DESC", "ASC"])
114
+ unless validator.valid?(sort_order)
115
+ fail ArgumentError, "invalid value for 'sort_order', must be one of #{validator.allowable_values}."
84
116
  end
85
117
  @sort_order = sort_order
86
118
  end
87
119
 
88
- # Check equality by comparing each attribute.
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
89
122
  def ==(o)
90
123
  return true if self.equal?(o)
91
124
  self.class == o.class &&
@@ -96,35 +129,41 @@ module SquareConnect
96
129
  end
97
130
 
98
131
  # @see the `==` method
132
+ # @param [Object] Object to be compared
99
133
  def eql?(o)
100
134
  self == o
101
135
  end
102
136
 
103
- # Calculate hash code according to all attributes.
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Fixnum] Hash code
104
139
  def hash
105
140
  [begin_time, end_time, sort_order, cursor].hash
106
141
  end
107
142
 
108
- # build the object from hash
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
109
146
  def build_from_hash(attributes)
110
147
  return nil unless attributes.is_a?(Hash)
111
148
  self.class.swagger_types.each_pair do |key, type|
112
- if type =~ /^Array<(.*)>/i
149
+ if type =~ /\AArray<(.*)>/i
150
+ # check to ensure the input is an array given that the the attribute
151
+ # is documented as an array but the input is not
113
152
  if attributes[self.class.attribute_map[key]].is_a?(Array)
114
153
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
115
- else
116
- #TODO show warning in debug mode
117
154
  end
118
155
  elsif !attributes[self.class.attribute_map[key]].nil?
119
156
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
- else
121
- # data not found in attributes(hash), not an issue as the data can be optional
122
- end
157
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
123
158
  end
124
159
 
125
160
  self
126
161
  end
127
162
 
163
+ # Deserializes the data based on type
164
+ # @param string type Data type
165
+ # @param string value Value to be deserialized
166
+ # @return [Object] Deserialized data
128
167
  def _deserialize(type, value)
129
168
  case type.to_sym
130
169
  when :DateTime
@@ -138,15 +177,18 @@ module SquareConnect
138
177
  when :Float
139
178
  value.to_f
140
179
  when :BOOLEAN
141
- if value.to_s =~ /^(true|t|yes|y|1)$/i
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
181
  true
143
182
  else
144
183
  false
145
184
  end
185
+ when :Object
186
+ # generic object (usually a Hash), return directly
187
+ value
146
188
  when /\AArray<(?<inner_type>.+)>\z/
147
189
  inner_type = Regexp.last_match[:inner_type]
148
190
  value.map { |v| _deserialize(inner_type, v) }
149
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
191
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
192
  k_type = Regexp.last_match[:k_type]
151
193
  v_type = Regexp.last_match[:v_type]
152
194
  {}.tap do |hash|
@@ -155,21 +197,25 @@ module SquareConnect
155
197
  end
156
198
  end
157
199
  else # model
158
- _model = SquareConnect.const_get(type).new
159
- _model.build_from_hash(value)
200
+ temp_model = SquareConnect.const_get(type).new
201
+ temp_model.build_from_hash(value)
160
202
  end
161
203
  end
162
204
 
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
163
207
  def to_s
164
208
  to_hash.to_s
165
209
  end
166
210
 
167
- # to_body is an alias to to_body (backward compatibility))
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
168
213
  def to_body
169
214
  to_hash
170
215
  end
171
216
 
172
- # return the object in the form of hash
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
173
219
  def to_hash
174
220
  hash = {}
175
221
  self.class.attribute_map.each_pair do |attr, param|
@@ -180,8 +226,10 @@ module SquareConnect
180
226
  hash
181
227
  end
182
228
 
183
- # Method to output non-array value in the form of hash
229
+ # Outputs non-array value in the form of hash
184
230
  # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
185
233
  def _to_hash(value)
186
234
  if value.is_a?(Array)
187
235
  value.compact.map{ |v| _to_hash(v) }
@@ -197,4 +245,5 @@ module SquareConnect
197
245
  end
198
246
 
199
247
  end
248
+
200
249
  end
@@ -1,17 +1,16 @@
1
1
  =begin
2
- Square Connect API
2
+ #Square Connect API
3
3
 
4
4
  OpenAPI spec version: 2.0
5
5
 
6
6
  Generated by: https://github.com/swagger-api/swagger-codegen.git
7
7
 
8
-
9
8
  =end
10
9
 
11
10
  require 'date'
12
11
 
13
12
  module SquareConnect
14
- # Defines the fields that are included in the response body of\na request to the **ListTransactions** endpoint.\n\nOne of `errors` or `transactions` is present in a given response (never both).
13
+ # Defines the fields that are included in the response body of a request to the [ListTransactions](#endpoint-listtransactions) endpoint. One of `errors` or `transactions` is present in a given response (never both).
15
14
  class ListTransactionsResponse
16
15
  # Any errors that occurred during the request.
17
16
  attr_accessor :errors
@@ -19,19 +18,16 @@ module SquareConnect
19
18
  # An array of transactions that match your query.
20
19
  attr_accessor :transactions
21
20
 
22
- # A pagination cursor for retrieving the next set of results,\nif any remain.\n\nProvide this value as the `cursor` parameter in a subsequent request\nto the **ListTransactions** endpoint.
21
+ # A pagination cursor for retrieving the next set of results, if any remain. Provide this value as the `cursor` parameter in a subsequent request to this endpoint. See [Paginating results](#paginatingresults) for more information.
23
22
  attr_accessor :cursor
24
23
 
24
+
25
25
  # Attribute mapping from ruby-style variable name to JSON key.
26
26
  def self.attribute_map
27
27
  {
28
-
29
28
  :'errors' => :'errors',
30
-
31
29
  :'transactions' => :'transactions',
32
-
33
30
  :'cursor' => :'cursor'
34
-
35
31
  }
36
32
  end
37
33
 
@@ -41,36 +37,50 @@ module SquareConnect
41
37
  :'errors' => :'Array<Error>',
42
38
  :'transactions' => :'Array<Transaction>',
43
39
  :'cursor' => :'String'
44
-
45
40
  }
46
41
  end
47
42
 
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
48
45
  def initialize(attributes = {})
49
46
  return unless attributes.is_a?(Hash)
50
47
 
51
48
  # convert string to symbol for hash key
52
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
49
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
50
 
54
-
55
- if attributes[:'errors']
51
+ if attributes.has_key?(:'errors')
56
52
  if (value = attributes[:'errors']).is_a?(Array)
57
53
  self.errors = value
58
54
  end
59
55
  end
60
-
61
- if attributes[:'transactions']
56
+
57
+ if attributes.has_key?(:'transactions')
62
58
  if (value = attributes[:'transactions']).is_a?(Array)
63
59
  self.transactions = value
64
60
  end
65
61
  end
66
-
67
- if attributes[:'cursor']
62
+
63
+ if attributes.has_key?(:'cursor')
68
64
  self.cursor = attributes[:'cursor']
69
65
  end
70
-
66
+
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properies with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ return invalid_properties
71
74
  end
72
75
 
73
- # Check equality by comparing each attribute.
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 true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
74
84
  def ==(o)
75
85
  return true if self.equal?(o)
76
86
  self.class == o.class &&
@@ -80,35 +90,41 @@ module SquareConnect
80
90
  end
81
91
 
82
92
  # @see the `==` method
93
+ # @param [Object] Object to be compared
83
94
  def eql?(o)
84
95
  self == o
85
96
  end
86
97
 
87
- # Calculate hash code according to all attributes.
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Fixnum] Hash code
88
100
  def hash
89
101
  [errors, transactions, cursor].hash
90
102
  end
91
103
 
92
- # build the object from hash
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
93
107
  def build_from_hash(attributes)
94
108
  return nil unless attributes.is_a?(Hash)
95
109
  self.class.swagger_types.each_pair do |key, type|
96
- if type =~ /^Array<(.*)>/i
110
+ if type =~ /\AArray<(.*)>/i
111
+ # check to ensure the input is an array given that the the attribute
112
+ # is documented as an array but the input is not
97
113
  if attributes[self.class.attribute_map[key]].is_a?(Array)
98
114
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
99
- else
100
- #TODO show warning in debug mode
101
115
  end
102
116
  elsif !attributes[self.class.attribute_map[key]].nil?
103
117
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
104
- else
105
- # data not found in attributes(hash), not an issue as the data can be optional
106
- end
118
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
107
119
  end
108
120
 
109
121
  self
110
122
  end
111
123
 
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
112
128
  def _deserialize(type, value)
113
129
  case type.to_sym
114
130
  when :DateTime
@@ -122,15 +138,18 @@ module SquareConnect
122
138
  when :Float
123
139
  value.to_f
124
140
  when :BOOLEAN
125
- if value.to_s =~ /^(true|t|yes|y|1)$/i
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
142
  true
127
143
  else
128
144
  false
129
145
  end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
130
149
  when /\AArray<(?<inner_type>.+)>\z/
131
150
  inner_type = Regexp.last_match[:inner_type]
132
151
  value.map { |v| _deserialize(inner_type, v) }
133
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
134
153
  k_type = Regexp.last_match[:k_type]
135
154
  v_type = Regexp.last_match[:v_type]
136
155
  {}.tap do |hash|
@@ -139,21 +158,25 @@ module SquareConnect
139
158
  end
140
159
  end
141
160
  else # model
142
- _model = SquareConnect.const_get(type).new
143
- _model.build_from_hash(value)
161
+ temp_model = SquareConnect.const_get(type).new
162
+ temp_model.build_from_hash(value)
144
163
  end
145
164
  end
146
165
 
166
+ # Returns the string representation of the object
167
+ # @return [String] String presentation of the object
147
168
  def to_s
148
169
  to_hash.to_s
149
170
  end
150
171
 
151
- # to_body is an alias to to_body (backward compatibility))
172
+ # to_body is an alias to to_hash (backward compatibility)
173
+ # @return [Hash] Returns the object in the form of hash
152
174
  def to_body
153
175
  to_hash
154
176
  end
155
177
 
156
- # return the object in the form of hash
178
+ # Returns the object in the form of hash
179
+ # @return [Hash] Returns the object in the form of hash
157
180
  def to_hash
158
181
  hash = {}
159
182
  self.class.attribute_map.each_pair do |attr, param|
@@ -164,8 +187,10 @@ module SquareConnect
164
187
  hash
165
188
  end
166
189
 
167
- # Method to output non-array value in the form of hash
190
+ # Outputs non-array value in the form of hash
168
191
  # For object, use to_hash. Otherwise, just return the value
192
+ # @param [Object] value Any valid value
193
+ # @return [Hash] Returns the value in the form of hash
169
194
  def _to_hash(value)
170
195
  if value.is_a?(Array)
171
196
  value.compact.map{ |v| _to_hash(v) }
@@ -181,4 +206,5 @@ module SquareConnect
181
206
  end
182
207
 
183
208
  end
209
+
184
210
  end