square_connect 2.0.0 → 2.0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,32 +1,29 @@
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 **RetrieveTransaction** endpoint.\n\nOne of `errors` or `transaction` is present in a given response (never both).
13
+ # Defines the fields that are included in the response body of a request to the [RetrieveTransaction](#endpont-retrievetransaction) endpoint. One of `errors` or `transaction` is present in a given response (never both).
15
14
  class RetrieveTransactionResponse
16
15
  # Any errors that occurred during the request.
17
16
  attr_accessor :errors
18
17
 
19
- # The details of the requested transaction.
18
+ # The requested transaction.
20
19
  attr_accessor :transaction
21
20
 
21
+
22
22
  # Attribute mapping from ruby-style variable name to JSON key.
23
23
  def self.attribute_map
24
24
  {
25
-
26
25
  :'errors' => :'errors',
27
-
28
26
  :'transaction' => :'transaction'
29
-
30
27
  }
31
28
  end
32
29
 
@@ -35,30 +32,44 @@ module SquareConnect
35
32
  {
36
33
  :'errors' => :'Array<Error>',
37
34
  :'transaction' => :'Transaction'
38
-
39
35
  }
40
36
  end
41
37
 
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
42
40
  def initialize(attributes = {})
43
41
  return unless attributes.is_a?(Hash)
44
42
 
45
43
  # convert string to symbol for hash key
46
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
44
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
47
45
 
48
-
49
- if attributes[:'errors']
46
+ if attributes.has_key?(:'errors')
50
47
  if (value = attributes[:'errors']).is_a?(Array)
51
48
  self.errors = value
52
49
  end
53
50
  end
54
-
55
- if attributes[:'transaction']
51
+
52
+ if attributes.has_key?(:'transaction')
56
53
  self.transaction = attributes[:'transaction']
57
54
  end
58
-
55
+
56
+ end
57
+
58
+ # Show invalid properties with the reasons. Usually used together with valid?
59
+ # @return Array for valid properies with the reasons
60
+ def list_invalid_properties
61
+ invalid_properties = Array.new
62
+ return invalid_properties
59
63
  end
60
64
 
61
- # Check equality by comparing each attribute.
65
+ # Check to see if the all the properties in the model are valid
66
+ # @return true if the model is valid
67
+ def valid?
68
+ return true
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
62
73
  def ==(o)
63
74
  return true if self.equal?(o)
64
75
  self.class == o.class &&
@@ -67,35 +78,41 @@ module SquareConnect
67
78
  end
68
79
 
69
80
  # @see the `==` method
81
+ # @param [Object] Object to be compared
70
82
  def eql?(o)
71
83
  self == o
72
84
  end
73
85
 
74
- # Calculate hash code according to all attributes.
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Fixnum] Hash code
75
88
  def hash
76
89
  [errors, transaction].hash
77
90
  end
78
91
 
79
- # build the object from hash
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
80
95
  def build_from_hash(attributes)
81
96
  return nil unless attributes.is_a?(Hash)
82
97
  self.class.swagger_types.each_pair do |key, type|
83
- if type =~ /^Array<(.*)>/i
98
+ if type =~ /\AArray<(.*)>/i
99
+ # check to ensure the input is an array given that the the attribute
100
+ # is documented as an array but the input is not
84
101
  if attributes[self.class.attribute_map[key]].is_a?(Array)
85
102
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
86
- else
87
- #TODO show warning in debug mode
88
103
  end
89
104
  elsif !attributes[self.class.attribute_map[key]].nil?
90
105
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
91
- else
92
- # data not found in attributes(hash), not an issue as the data can be optional
93
- end
106
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
94
107
  end
95
108
 
96
109
  self
97
110
  end
98
111
 
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
99
116
  def _deserialize(type, value)
100
117
  case type.to_sym
101
118
  when :DateTime
@@ -109,15 +126,18 @@ module SquareConnect
109
126
  when :Float
110
127
  value.to_f
111
128
  when :BOOLEAN
112
- if value.to_s =~ /^(true|t|yes|y|1)$/i
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
113
130
  true
114
131
  else
115
132
  false
116
133
  end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
117
137
  when /\AArray<(?<inner_type>.+)>\z/
118
138
  inner_type = Regexp.last_match[:inner_type]
119
139
  value.map { |v| _deserialize(inner_type, v) }
120
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
121
141
  k_type = Regexp.last_match[:k_type]
122
142
  v_type = Regexp.last_match[:v_type]
123
143
  {}.tap do |hash|
@@ -126,21 +146,25 @@ module SquareConnect
126
146
  end
127
147
  end
128
148
  else # model
129
- _model = SquareConnect.const_get(type).new
130
- _model.build_from_hash(value)
149
+ temp_model = SquareConnect.const_get(type).new
150
+ temp_model.build_from_hash(value)
131
151
  end
132
152
  end
133
153
 
154
+ # Returns the string representation of the object
155
+ # @return [String] String presentation of the object
134
156
  def to_s
135
157
  to_hash.to_s
136
158
  end
137
159
 
138
- # to_body is an alias to to_body (backward compatibility))
160
+ # to_body is an alias to to_hash (backward compatibility)
161
+ # @return [Hash] Returns the object in the form of hash
139
162
  def to_body
140
163
  to_hash
141
164
  end
142
165
 
143
- # return the object in the form of hash
166
+ # Returns the object in the form of hash
167
+ # @return [Hash] Returns the object in the form of hash
144
168
  def to_hash
145
169
  hash = {}
146
170
  self.class.attribute_map.each_pair do |attr, param|
@@ -151,8 +175,10 @@ module SquareConnect
151
175
  hash
152
176
  end
153
177
 
154
- # Method to output non-array value in the form of hash
178
+ # Outputs non-array value in the form of hash
155
179
  # For object, use to_hash. Otherwise, just return the value
180
+ # @param [Object] value Any valid value
181
+ # @return [Hash] Returns the value in the form of hash
156
182
  def _to_hash(value)
157
183
  if value.is_a?(Array)
158
184
  value.compact.map{ |v| _to_hash(v) }
@@ -168,4 +194,5 @@ module SquareConnect
168
194
  end
169
195
 
170
196
  end
197
+
171
198
  end
@@ -1,147 +1,19 @@
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
- #
15
13
  class SortOrder
16
- # Attribute mapping from ruby-style variable name to JSON key.
17
- def self.attribute_map
18
- {
19
-
20
- }
21
- end
22
-
23
- # Attribute type mapping.
24
- def self.swagger_types
25
- {
26
-
27
- }
28
- end
29
-
30
- def initialize(attributes = {})
31
- return unless attributes.is_a?(Hash)
32
-
33
- # convert string to symbol for hash key
34
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
35
-
36
-
37
- end
38
-
39
- # Check equality by comparing each attribute.
40
- def ==(o)
41
- return true if self.equal?(o)
42
- self.class == o.class
43
- end
44
-
45
- # @see the `==` method
46
- def eql?(o)
47
- self == o
48
- end
49
-
50
- # Calculate hash code according to all attributes.
51
- def hash
52
- [].hash
53
- end
54
-
55
- # build the object from hash
56
- def build_from_hash(attributes)
57
- return nil unless attributes.is_a?(Hash)
58
- self.class.swagger_types.each_pair do |key, type|
59
- if type =~ /^Array<(.*)>/i
60
- if attributes[self.class.attribute_map[key]].is_a?(Array)
61
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
62
- else
63
- #TODO show warning in debug mode
64
- end
65
- elsif !attributes[self.class.attribute_map[key]].nil?
66
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
67
- else
68
- # data not found in attributes(hash), not an issue as the data can be optional
69
- end
70
- end
71
-
72
- self
73
- end
74
-
75
- def _deserialize(type, value)
76
- case type.to_sym
77
- when :DateTime
78
- DateTime.parse(value)
79
- when :Date
80
- Date.parse(value)
81
- when :String
82
- value.to_s
83
- when :Integer
84
- value.to_i
85
- when :Float
86
- value.to_f
87
- when :BOOLEAN
88
- if value.to_s =~ /^(true|t|yes|y|1)$/i
89
- true
90
- else
91
- false
92
- end
93
- when /\AArray<(?<inner_type>.+)>\z/
94
- inner_type = Regexp.last_match[:inner_type]
95
- value.map { |v| _deserialize(inner_type, v) }
96
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
97
- k_type = Regexp.last_match[:k_type]
98
- v_type = Regexp.last_match[:v_type]
99
- {}.tap do |hash|
100
- value.each do |k, v|
101
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
102
- end
103
- end
104
- else # model
105
- _model = SquareConnect.const_get(type).new
106
- _model.build_from_hash(value)
107
- end
108
- end
109
-
110
- def to_s
111
- to_hash.to_s
112
- end
113
-
114
- # to_body is an alias to to_body (backward compatibility))
115
- def to_body
116
- to_hash
117
- end
118
-
119
- # return the object in the form of hash
120
- def to_hash
121
- hash = {}
122
- self.class.attribute_map.each_pair do |attr, param|
123
- value = self.send(attr)
124
- next if value.nil?
125
- hash[param] = _to_hash(value)
126
- end
127
- hash
128
- end
129
-
130
- # Method to output non-array value in the form of hash
131
- # For object, use to_hash. Otherwise, just return the value
132
- def _to_hash(value)
133
- if value.is_a?(Array)
134
- value.compact.map{ |v| _to_hash(v) }
135
- elsif value.is_a?(Hash)
136
- {}.tap do |hash|
137
- value.each { |k, v| hash[k] = _to_hash(v) }
138
- end
139
- elsif value.respond_to? :to_hash
140
- value.to_hash
141
- else
142
- value
143
- end
144
- end
145
-
14
+
15
+ DESC = "DESC".freeze
16
+ ASC = "ASC".freeze
146
17
  end
18
+
147
19
  end
@@ -1,22 +1,21 @@
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
- # Represents a form of tender used to pay in a transaction.
13
+ # Represents a tender (i.e., a method of payment) used in a Square transaction.
15
14
  class Tender
16
15
  # The tender's unique ID.
17
16
  attr_accessor :id
18
17
 
19
- # The ID of the tender's associated location.
18
+ # The ID of the transaction's associated location.
20
19
  attr_accessor :location_id
21
20
 
22
21
  # The ID of the tender's associated transaction.
@@ -31,47 +30,57 @@ module SquareConnect
31
30
  # The amount of the tender.
32
31
  attr_accessor :amount_money
33
32
 
34
- # The amount of any Square processing fees applied to the tender.
33
+ # The amount of any Square processing fees applied to the tender. This field is not immediately populated when a new transaction is created. It is usually available after about ten seconds.
35
34
  attr_accessor :processing_fee_money
36
35
 
37
- # If the tender represents a customer's card on file, this is\nthe ID of the associated customer.
36
+ # If the tender is associated with a customer or represents a customer's card on file, this is the ID of the associated customer.
38
37
  attr_accessor :customer_id
39
38
 
40
- # The type of tender.
39
+ # The type of tender, such as `CARD` or `CASH`.
41
40
  attr_accessor :type
42
41
 
43
- # The details of the card tender.\nThis value is present only if the value of `type` is `CARD`.
42
+ # The details of the card tender. This value is present only if the value of `type` is `CARD`.
44
43
  attr_accessor :card_details
45
44
 
46
- # The details of the cash tender.\nThis value is present only if the value of `type` is `CASH`.
45
+ # The details of the cash tender. This value is present only if the value of `type` is `CASH`.
47
46
  attr_accessor :cash_details
48
47
 
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
49
70
  # Attribute mapping from ruby-style variable name to JSON key.
50
71
  def self.attribute_map
51
72
  {
52
-
53
73
  :'id' => :'id',
54
-
55
74
  :'location_id' => :'location_id',
56
-
57
75
  :'transaction_id' => :'transaction_id',
58
-
59
76
  :'created_at' => :'created_at',
60
-
61
77
  :'note' => :'note',
62
-
63
78
  :'amount_money' => :'amount_money',
64
-
65
79
  :'processing_fee_money' => :'processing_fee_money',
66
-
67
80
  :'customer_id' => :'customer_id',
68
-
69
81
  :'type' => :'type',
70
-
71
82
  :'card_details' => :'card_details',
72
-
73
83
  :'cash_details' => :'cash_details'
74
-
75
84
  }
76
85
  end
77
86
 
@@ -89,73 +98,95 @@ module SquareConnect
89
98
  :'type' => :'String',
90
99
  :'card_details' => :'TenderCardDetails',
91
100
  :'cash_details' => :'TenderCashDetails'
92
-
93
101
  }
94
102
  end
95
103
 
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
96
106
  def initialize(attributes = {})
97
107
  return unless attributes.is_a?(Hash)
98
108
 
99
109
  # convert string to symbol for hash key
100
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
110
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
101
111
 
102
-
103
- if attributes[:'id']
112
+ if attributes.has_key?(:'id')
104
113
  self.id = attributes[:'id']
105
114
  end
106
-
107
- if attributes[:'location_id']
115
+
116
+ if attributes.has_key?(:'location_id')
108
117
  self.location_id = attributes[:'location_id']
109
118
  end
110
-
111
- if attributes[:'transaction_id']
119
+
120
+ if attributes.has_key?(:'transaction_id')
112
121
  self.transaction_id = attributes[:'transaction_id']
113
122
  end
114
-
115
- if attributes[:'created_at']
123
+
124
+ if attributes.has_key?(:'created_at')
116
125
  self.created_at = attributes[:'created_at']
117
126
  end
118
-
119
- if attributes[:'note']
127
+
128
+ if attributes.has_key?(:'note')
120
129
  self.note = attributes[:'note']
121
130
  end
122
-
123
- if attributes[:'amount_money']
131
+
132
+ if attributes.has_key?(:'amount_money')
124
133
  self.amount_money = attributes[:'amount_money']
125
134
  end
126
-
127
- if attributes[:'processing_fee_money']
135
+
136
+ if attributes.has_key?(:'processing_fee_money')
128
137
  self.processing_fee_money = attributes[:'processing_fee_money']
129
138
  end
130
-
131
- if attributes[:'customer_id']
139
+
140
+ if attributes.has_key?(:'customer_id')
132
141
  self.customer_id = attributes[:'customer_id']
133
142
  end
134
-
135
- if attributes[:'type']
143
+
144
+ if attributes.has_key?(:'type')
136
145
  self.type = attributes[:'type']
137
146
  end
138
-
139
- if attributes[:'card_details']
147
+
148
+ if attributes.has_key?(:'card_details')
140
149
  self.card_details = attributes[:'card_details']
141
150
  end
142
-
143
- if attributes[:'cash_details']
151
+
152
+ if attributes.has_key?(:'cash_details')
144
153
  self.cash_details = attributes[:'cash_details']
145
154
  end
146
-
155
+
156
+ end
157
+
158
+ # Show invalid properties with the reasons. Usually used together with valid?
159
+ # @return Array for valid properies with the reasons
160
+ def list_invalid_properties
161
+ invalid_properties = Array.new
162
+ if @type.nil?
163
+ invalid_properties.push("invalid value for 'type', type cannot be nil.")
164
+ end
165
+
166
+ return invalid_properties
167
+ end
168
+
169
+ # Check to see if the all the properties in the model are valid
170
+ # @return true if the model is valid
171
+ def valid?
172
+ return false if @type.nil?
173
+ type_validator = EnumAttributeValidator.new('String', ["CARD", "CASH", "THIRD_PARTY_CARD", "SQUARE_GIFT_CARD", "NO_SALE", "OTHER"])
174
+ return false unless type_validator.valid?(@type)
175
+ return true
147
176
  end
148
177
 
149
178
  # Custom attribute writer method checking allowed values (enum).
179
+ # @param [Object] type Object to be assigned
150
180
  def type=(type)
151
- allowed_values = ["OTHER", "CARD", "CASH", "THIRD_PARTY_CARD", "SQUARE_GIFT_CARD", "NO_SALE"]
152
- if type && !allowed_values.include?(type)
153
- fail "invalid value for 'type', must be one of #{allowed_values}"
181
+ validator = EnumAttributeValidator.new('String', ["CARD", "CASH", "THIRD_PARTY_CARD", "SQUARE_GIFT_CARD", "NO_SALE", "OTHER"])
182
+ unless validator.valid?(type)
183
+ fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
154
184
  end
155
185
  @type = type
156
186
  end
157
187
 
158
- # Check equality by comparing each attribute.
188
+ # Checks equality by comparing each attribute.
189
+ # @param [Object] Object to be compared
159
190
  def ==(o)
160
191
  return true if self.equal?(o)
161
192
  self.class == o.class &&
@@ -173,35 +204,41 @@ module SquareConnect
173
204
  end
174
205
 
175
206
  # @see the `==` method
207
+ # @param [Object] Object to be compared
176
208
  def eql?(o)
177
209
  self == o
178
210
  end
179
211
 
180
- # Calculate hash code according to all attributes.
212
+ # Calculates hash code according to all attributes.
213
+ # @return [Fixnum] Hash code
181
214
  def hash
182
215
  [id, location_id, transaction_id, created_at, note, amount_money, processing_fee_money, customer_id, type, card_details, cash_details].hash
183
216
  end
184
217
 
185
- # build the object from hash
218
+ # Builds the object from hash
219
+ # @param [Hash] attributes Model attributes in the form of hash
220
+ # @return [Object] Returns the model itself
186
221
  def build_from_hash(attributes)
187
222
  return nil unless attributes.is_a?(Hash)
188
223
  self.class.swagger_types.each_pair do |key, type|
189
- if type =~ /^Array<(.*)>/i
224
+ if type =~ /\AArray<(.*)>/i
225
+ # check to ensure the input is an array given that the the attribute
226
+ # is documented as an array but the input is not
190
227
  if attributes[self.class.attribute_map[key]].is_a?(Array)
191
228
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
192
- else
193
- #TODO show warning in debug mode
194
229
  end
195
230
  elsif !attributes[self.class.attribute_map[key]].nil?
196
231
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
197
- else
198
- # data not found in attributes(hash), not an issue as the data can be optional
199
- end
232
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
200
233
  end
201
234
 
202
235
  self
203
236
  end
204
237
 
238
+ # Deserializes the data based on type
239
+ # @param string type Data type
240
+ # @param string value Value to be deserialized
241
+ # @return [Object] Deserialized data
205
242
  def _deserialize(type, value)
206
243
  case type.to_sym
207
244
  when :DateTime
@@ -215,15 +252,18 @@ module SquareConnect
215
252
  when :Float
216
253
  value.to_f
217
254
  when :BOOLEAN
218
- if value.to_s =~ /^(true|t|yes|y|1)$/i
255
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
256
  true
220
257
  else
221
258
  false
222
259
  end
260
+ when :Object
261
+ # generic object (usually a Hash), return directly
262
+ value
223
263
  when /\AArray<(?<inner_type>.+)>\z/
224
264
  inner_type = Regexp.last_match[:inner_type]
225
265
  value.map { |v| _deserialize(inner_type, v) }
226
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
266
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
267
  k_type = Regexp.last_match[:k_type]
228
268
  v_type = Regexp.last_match[:v_type]
229
269
  {}.tap do |hash|
@@ -232,21 +272,25 @@ module SquareConnect
232
272
  end
233
273
  end
234
274
  else # model
235
- _model = SquareConnect.const_get(type).new
236
- _model.build_from_hash(value)
275
+ temp_model = SquareConnect.const_get(type).new
276
+ temp_model.build_from_hash(value)
237
277
  end
238
278
  end
239
279
 
280
+ # Returns the string representation of the object
281
+ # @return [String] String presentation of the object
240
282
  def to_s
241
283
  to_hash.to_s
242
284
  end
243
285
 
244
- # to_body is an alias to to_body (backward compatibility))
286
+ # to_body is an alias to to_hash (backward compatibility)
287
+ # @return [Hash] Returns the object in the form of hash
245
288
  def to_body
246
289
  to_hash
247
290
  end
248
291
 
249
- # return the object in the form of hash
292
+ # Returns the object in the form of hash
293
+ # @return [Hash] Returns the object in the form of hash
250
294
  def to_hash
251
295
  hash = {}
252
296
  self.class.attribute_map.each_pair do |attr, param|
@@ -257,8 +301,10 @@ module SquareConnect
257
301
  hash
258
302
  end
259
303
 
260
- # Method to output non-array value in the form of hash
304
+ # Outputs non-array value in the form of hash
261
305
  # For object, use to_hash. Otherwise, just return the value
306
+ # @param [Object] value Any valid value
307
+ # @return [Hash] Returns the value in the form of hash
262
308
  def _to_hash(value)
263
309
  if value.is_a?(Array)
264
310
  value.compact.map{ |v| _to_hash(v) }
@@ -274,4 +320,5 @@ module SquareConnect
274
320
  end
275
321
 
276
322
  end
323
+
277
324
  end