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
@@ -0,0 +1,198 @@
1
+ =begin
2
+ #Square Connect API
3
+
4
+ OpenAPI spec version: 2.0
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ =end
9
+
10
+ require 'date'
11
+
12
+ module SquareConnect
13
+ # Defines the fields that are included in the response body of a request to the [CreateCheckout](#endpoint-createcheckout) endpoint.
14
+ class CreateCheckoutResponse
15
+ # The newly created checkout. If the same request was made with the same idempotency_key, this will be the checkout created with the idempotency_key.
16
+ attr_accessor :checkout
17
+
18
+ # Any errors that occurred during the request.
19
+ attr_accessor :errors
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'checkout' => :'checkout',
26
+ :'errors' => :'errors'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'checkout' => :'Checkout',
34
+ :'errors' => :'Array<Error>'
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?(:'checkout')
47
+ self.checkout = attributes[:'checkout']
48
+ end
49
+
50
+ if attributes.has_key?(:'errors')
51
+ if (value = attributes[:'errors']).is_a?(Array)
52
+ self.errors = value
53
+ end
54
+ end
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
63
+ end
64
+
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
73
+ def ==(o)
74
+ return true if self.equal?(o)
75
+ self.class == o.class &&
76
+ checkout == o.checkout &&
77
+ errors == o.errors
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(o)
83
+ self == o
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Fixnum] Hash code
88
+ def hash
89
+ [checkout, errors].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ self.class.swagger_types.each_pair do |key, type|
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
101
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
102
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
103
+ end
104
+ elsif !attributes[self.class.attribute_map[key]].nil?
105
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
106
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
107
+ end
108
+
109
+ self
110
+ end
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
116
+ def _deserialize(type, value)
117
+ case type.to_sym
118
+ when :DateTime
119
+ DateTime.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :BOOLEAN
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ else # model
149
+ temp_model = SquareConnect.const_get(type).new
150
+ temp_model.build_from_hash(value)
151
+ end
152
+ end
153
+
154
+ # Returns the string representation of the object
155
+ # @return [String] String presentation of the object
156
+ def to_s
157
+ to_hash.to_s
158
+ end
159
+
160
+ # to_body is an alias to to_hash (backward compatibility)
161
+ # @return [Hash] Returns the object in the form of hash
162
+ def to_body
163
+ to_hash
164
+ end
165
+
166
+ # Returns the object in the form of hash
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_hash
169
+ hash = {}
170
+ self.class.attribute_map.each_pair do |attr, param|
171
+ value = self.send(attr)
172
+ next if value.nil?
173
+ hash[param] = _to_hash(value)
174
+ end
175
+ hash
176
+ end
177
+
178
+ # Outputs non-array value in the form of hash
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
182
+ def _to_hash(value)
183
+ if value.is_a?(Array)
184
+ value.compact.map{ |v| _to_hash(v) }
185
+ elsif value.is_a?(Hash)
186
+ {}.tap do |hash|
187
+ value.each { |k, v| hash[k] = _to_hash(v) }
188
+ end
189
+ elsif value.respond_to? :to_hash
190
+ value.to_hash
191
+ else
192
+ value
193
+ end
194
+ end
195
+
196
+ end
197
+
198
+ end
@@ -1,37 +1,33 @@
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
- #
13
+ # Defines the fields that are included in the request body of a request to the [CreateCustomerCard](#endpoint-createcustomercard) endpoint.
15
14
  class CreateCustomerCardRequest
16
- # A card nonce representing the card data to link to the customer.
15
+ # A card nonce representing the credit card to link to the customer. Card nonces are generated by the `SqPaymentForm` that buyers enter their card information into. See [Embedding the payment form](/articles/adding-payment-form/) for more information.
17
16
  attr_accessor :card_nonce
18
17
 
19
- # Postal code in the address is required for US and Canada payments.
18
+ # Address information for the card on file. Only the `postal_code` field is required for payments in the US and Canada.
20
19
  attr_accessor :billing_address
21
20
 
22
- # The cardholder name.
21
+ # The cardholder's name.
23
22
  attr_accessor :cardholder_name
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
  :'card_nonce' => :'card_nonce',
30
-
31
29
  :'billing_address' => :'billing_address',
32
-
33
30
  :'cardholder_name' => :'cardholder_name'
34
-
35
31
  }
36
32
  end
37
33
 
@@ -41,32 +37,51 @@ module SquareConnect
41
37
  :'card_nonce' => :'String',
42
38
  :'billing_address' => :'Address',
43
39
  :'cardholder_name' => :'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[:'card_nonce']
51
+ if attributes.has_key?(:'card_nonce')
56
52
  self.card_nonce = attributes[:'card_nonce']
57
53
  end
58
-
59
- if attributes[:'billing_address']
54
+
55
+ if attributes.has_key?(:'billing_address')
60
56
  self.billing_address = attributes[:'billing_address']
61
57
  end
62
-
63
- if attributes[:'cardholder_name']
58
+
59
+ if attributes.has_key?(:'cardholder_name')
64
60
  self.cardholder_name = attributes[:'cardholder_name']
65
61
  end
66
-
62
+
67
63
  end
68
64
 
69
- # Check equality by comparing each attribute.
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properies with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ if @card_nonce.nil?
70
+ invalid_properties.push("invalid value for 'card_nonce', card_nonce cannot be nil.")
71
+ end
72
+
73
+ return invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ return false if @card_nonce.nil?
80
+ return true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
70
85
  def ==(o)
71
86
  return true if self.equal?(o)
72
87
  self.class == o.class &&
@@ -76,35 +91,41 @@ module SquareConnect
76
91
  end
77
92
 
78
93
  # @see the `==` method
94
+ # @param [Object] Object to be compared
79
95
  def eql?(o)
80
96
  self == o
81
97
  end
82
98
 
83
- # Calculate hash code according to all attributes.
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Fixnum] Hash code
84
101
  def hash
85
102
  [card_nonce, billing_address, cardholder_name].hash
86
103
  end
87
104
 
88
- # build the object from hash
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
89
108
  def build_from_hash(attributes)
90
109
  return nil unless attributes.is_a?(Hash)
91
110
  self.class.swagger_types.each_pair do |key, type|
92
- if type =~ /^Array<(.*)>/i
111
+ if type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the the attribute
113
+ # is documented as an array but the input is not
93
114
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
115
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
95
- else
96
- #TODO show warning in debug mode
97
116
  end
98
117
  elsif !attributes[self.class.attribute_map[key]].nil?
99
118
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
100
- else
101
- # data not found in attributes(hash), not an issue as the data can be optional
102
- end
119
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
120
  end
104
121
 
105
122
  self
106
123
  end
107
124
 
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
108
129
  def _deserialize(type, value)
109
130
  case type.to_sym
110
131
  when :DateTime
@@ -118,15 +139,18 @@ module SquareConnect
118
139
  when :Float
119
140
  value.to_f
120
141
  when :BOOLEAN
121
- if value.to_s =~ /^(true|t|yes|y|1)$/i
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
143
  true
123
144
  else
124
145
  false
125
146
  end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
126
150
  when /\AArray<(?<inner_type>.+)>\z/
127
151
  inner_type = Regexp.last_match[:inner_type]
128
152
  value.map { |v| _deserialize(inner_type, v) }
129
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
130
154
  k_type = Regexp.last_match[:k_type]
131
155
  v_type = Regexp.last_match[:v_type]
132
156
  {}.tap do |hash|
@@ -135,21 +159,25 @@ module SquareConnect
135
159
  end
136
160
  end
137
161
  else # model
138
- _model = SquareConnect.const_get(type).new
139
- _model.build_from_hash(value)
162
+ temp_model = SquareConnect.const_get(type).new
163
+ temp_model.build_from_hash(value)
140
164
  end
141
165
  end
142
166
 
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
143
169
  def to_s
144
170
  to_hash.to_s
145
171
  end
146
172
 
147
- # to_body is an alias to to_body (backward compatibility))
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
148
175
  def to_body
149
176
  to_hash
150
177
  end
151
178
 
152
- # return the object in the form of hash
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
153
181
  def to_hash
154
182
  hash = {}
155
183
  self.class.attribute_map.each_pair do |attr, param|
@@ -160,8 +188,10 @@ module SquareConnect
160
188
  hash
161
189
  end
162
190
 
163
- # Method to output non-array value in the form of hash
191
+ # Outputs non-array value in the form of hash
164
192
  # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
165
195
  def _to_hash(value)
166
196
  if value.is_a?(Array)
167
197
  value.compact.map{ |v| _to_hash(v) }
@@ -177,4 +207,5 @@ module SquareConnect
177
207
  end
178
208
 
179
209
  end
210
+
180
211
  end
@@ -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 **CreateCustomerCard** endpoint.\n\nOne of `errors` or `card` is present in a given response (never both).
13
+ # Defines the fields that are included in the response body of a request to the [CreateCustomerCard](#endpoint-createcustomercard) endpoint. One of `errors` or `card` is present in a given response (never both).
15
14
  class CreateCustomerCardResponse
16
- #
15
+ # Any errors that occurred during the request.
17
16
  attr_accessor :errors
18
17
 
19
- #
18
+ # The created card on file.
20
19
  attr_accessor :card
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
  :'card' => :'card'
29
-
30
27
  }
31
28
  end
32
29
 
@@ -35,30 +32,44 @@ module SquareConnect
35
32
  {
36
33
  :'errors' => :'Array<Error>',
37
34
  :'card' => :'Card'
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[:'card']
51
+
52
+ if attributes.has_key?(:'card')
56
53
  self.card = attributes[:'card']
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, card].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