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,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
- # Represents the details of a cash tender.
13
+ # Represents the details of a tender with `type` `CASH`.
15
14
  class TenderCashDetails
16
- # The total amount provided by the buyer for this tender, before change is given.
15
+ # The total amount of cash provided by the buyer, before change is given.
17
16
  attr_accessor :buyer_tendered_money
18
17
 
19
- # The change returned to the buyer for this tender. This amount should be >= 0.
18
+ # The amount of change returned to the buyer.
20
19
  attr_accessor :change_back_money
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
  :'buyer_tendered_money' => :'buyer_tendered_money',
27
-
28
26
  :'change_back_money' => :'change_back_money'
29
-
30
27
  }
31
28
  end
32
29
 
@@ -35,28 +32,42 @@ module SquareConnect
35
32
  {
36
33
  :'buyer_tendered_money' => :'Money',
37
34
  :'change_back_money' => :'Money'
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[:'buyer_tendered_money']
46
+ if attributes.has_key?(:'buyer_tendered_money')
50
47
  self.buyer_tendered_money = attributes[:'buyer_tendered_money']
51
48
  end
52
-
53
- if attributes[:'change_back_money']
49
+
50
+ if attributes.has_key?(:'change_back_money')
54
51
  self.change_back_money = attributes[:'change_back_money']
55
52
  end
56
-
53
+
54
+ end
55
+
56
+ # Show invalid properties with the reasons. Usually used together with valid?
57
+ # @return Array for valid properies with the reasons
58
+ def list_invalid_properties
59
+ invalid_properties = Array.new
60
+ return invalid_properties
57
61
  end
58
62
 
59
- # Check equality by comparing each attribute.
63
+ # Check to see if the all the properties in the model are valid
64
+ # @return true if the model is valid
65
+ def valid?
66
+ return true
67
+ end
68
+
69
+ # Checks equality by comparing each attribute.
70
+ # @param [Object] Object to be compared
60
71
  def ==(o)
61
72
  return true if self.equal?(o)
62
73
  self.class == o.class &&
@@ -65,35 +76,41 @@ module SquareConnect
65
76
  end
66
77
 
67
78
  # @see the `==` method
79
+ # @param [Object] Object to be compared
68
80
  def eql?(o)
69
81
  self == o
70
82
  end
71
83
 
72
- # Calculate hash code according to all attributes.
84
+ # Calculates hash code according to all attributes.
85
+ # @return [Fixnum] Hash code
73
86
  def hash
74
87
  [buyer_tendered_money, change_back_money].hash
75
88
  end
76
89
 
77
- # build the object from hash
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
78
93
  def build_from_hash(attributes)
79
94
  return nil unless attributes.is_a?(Hash)
80
95
  self.class.swagger_types.each_pair do |key, type|
81
- if type =~ /^Array<(.*)>/i
96
+ if type =~ /\AArray<(.*)>/i
97
+ # check to ensure the input is an array given that the the attribute
98
+ # is documented as an array but the input is not
82
99
  if attributes[self.class.attribute_map[key]].is_a?(Array)
83
100
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
84
- else
85
- #TODO show warning in debug mode
86
101
  end
87
102
  elsif !attributes[self.class.attribute_map[key]].nil?
88
103
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
89
- else
90
- # data not found in attributes(hash), not an issue as the data can be optional
91
- end
104
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
92
105
  end
93
106
 
94
107
  self
95
108
  end
96
109
 
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
97
114
  def _deserialize(type, value)
98
115
  case type.to_sym
99
116
  when :DateTime
@@ -107,15 +124,18 @@ module SquareConnect
107
124
  when :Float
108
125
  value.to_f
109
126
  when :BOOLEAN
110
- if value.to_s =~ /^(true|t|yes|y|1)$/i
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
111
128
  true
112
129
  else
113
130
  false
114
131
  end
132
+ when :Object
133
+ # generic object (usually a Hash), return directly
134
+ value
115
135
  when /\AArray<(?<inner_type>.+)>\z/
116
136
  inner_type = Regexp.last_match[:inner_type]
117
137
  value.map { |v| _deserialize(inner_type, v) }
118
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
138
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
119
139
  k_type = Regexp.last_match[:k_type]
120
140
  v_type = Regexp.last_match[:v_type]
121
141
  {}.tap do |hash|
@@ -124,21 +144,25 @@ module SquareConnect
124
144
  end
125
145
  end
126
146
  else # model
127
- _model = SquareConnect.const_get(type).new
128
- _model.build_from_hash(value)
147
+ temp_model = SquareConnect.const_get(type).new
148
+ temp_model.build_from_hash(value)
129
149
  end
130
150
  end
131
151
 
152
+ # Returns the string representation of the object
153
+ # @return [String] String presentation of the object
132
154
  def to_s
133
155
  to_hash.to_s
134
156
  end
135
157
 
136
- # to_body is an alias to to_body (backward compatibility))
158
+ # to_body is an alias to to_hash (backward compatibility)
159
+ # @return [Hash] Returns the object in the form of hash
137
160
  def to_body
138
161
  to_hash
139
162
  end
140
163
 
141
- # return the object in the form of hash
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
142
166
  def to_hash
143
167
  hash = {}
144
168
  self.class.attribute_map.each_pair do |attr, param|
@@ -149,8 +173,10 @@ module SquareConnect
149
173
  hash
150
174
  end
151
175
 
152
- # Method to output non-array value in the form of hash
176
+ # Outputs non-array value in the form of hash
153
177
  # For object, use to_hash. Otherwise, just return the value
178
+ # @param [Object] value Any valid value
179
+ # @return [Hash] Returns the value in the form of hash
154
180
  def _to_hash(value)
155
181
  if value.is_a?(Array)
156
182
  value.compact.map{ |v| _to_hash(v) }
@@ -166,4 +192,5 @@ module SquareConnect
166
192
  end
167
193
 
168
194
  end
195
+
169
196
  end
@@ -1,147 +1,23 @@
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 TenderType
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
+ CARD = "CARD".freeze
16
+ CASH = "CASH".freeze
17
+ THIRD_PARTY_CARD = "THIRD_PARTY_CARD".freeze
18
+ SQUARE_GIFT_CARD = "SQUARE_GIFT_CARD".freeze
19
+ NO_SALE = "NO_SALE".freeze
20
+ OTHER = "OTHER".freeze
146
21
  end
22
+
147
23
  end
@@ -1,19 +1,18 @@
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 transaction processed with Square, either with the\nConnect API or with Square Register.
13
+ # Represents a transaction processed with Square, either with the Connect API or with Square Register. The `tenders` field of this object lists all methods of payment used to pay in the transaction.
15
14
  class Transaction
16
- # The transaction's unique ID.
15
+ # The transaction's unique ID, issued by Square payments servers.
17
16
  attr_accessor :id
18
17
 
19
18
  # The ID of the transaction's associated location.
@@ -22,36 +21,62 @@ module SquareConnect
22
21
  # The time when the transaction was created, in RFC 3339 format.
23
22
  attr_accessor :created_at
24
23
 
25
- # Descriptions of the tenders used to pay for the transaction.
24
+ # The tenders used to pay in the transaction.
26
25
  attr_accessor :tenders
27
26
 
28
- # An array of any refunds associated with the transaction.
27
+ # Refunds that have been applied to any tender in the transaction.
29
28
  attr_accessor :refunds
30
29
 
31
- # If the transaction was created with the **Charge** endpoint, this\nvalue is the same as the value provided as the `reference_id` parameter\nin the request to that endpoint.
30
+ # If the transaction was created with the [Charge](#endpoint-charge) endpoint, this value is the same as the value provided for the `reference_id` parameter in the request to that endpoint. Otherwise, it is not set.
32
31
  attr_accessor :reference_id
33
32
 
34
- # The product that processed the transaction.
33
+ # The Square product that processed the transaction.
35
34
  attr_accessor :product
36
35
 
36
+ # If the transaction was created in the Square Register app, this value is the ID generated for the transaction by Square Register. This ID has no relationship to the transaction's canonical `id`, which is generated by Square's backend servers. This value is generated for bookkeeping purposes, in case the transaction cannot immediately be completed (for example, if the transaction is processed in offline mode). It is not currently possible with the Connect API to perform a transaction lookup by this value.
37
+ attr_accessor :client_id
38
+
39
+ # The order associated with this transaction, if any.
40
+ attr_accessor :order
41
+
42
+ # The shipping address provided in the request, if any.
43
+ attr_accessor :shipping_address
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
37
67
  # Attribute mapping from ruby-style variable name to JSON key.
38
68
  def self.attribute_map
39
69
  {
40
-
41
70
  :'id' => :'id',
42
-
43
71
  :'location_id' => :'location_id',
44
-
45
72
  :'created_at' => :'created_at',
46
-
47
73
  :'tenders' => :'tenders',
48
-
49
74
  :'refunds' => :'refunds',
50
-
51
75
  :'reference_id' => :'reference_id',
52
-
53
- :'product' => :'product'
54
-
76
+ :'product' => :'product',
77
+ :'client_id' => :'client_id',
78
+ :'order' => :'order',
79
+ :'shipping_address' => :'shipping_address'
55
80
  }
56
81
  end
57
82
 
@@ -64,62 +89,94 @@ module SquareConnect
64
89
  :'tenders' => :'Array<Tender>',
65
90
  :'refunds' => :'Array<Refund>',
66
91
  :'reference_id' => :'String',
67
- :'product' => :'String'
68
-
92
+ :'product' => :'String',
93
+ :'client_id' => :'String',
94
+ :'order' => :'Order',
95
+ :'shipping_address' => :'Address'
69
96
  }
70
97
  end
71
98
 
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
72
101
  def initialize(attributes = {})
73
102
  return unless attributes.is_a?(Hash)
74
103
 
75
104
  # convert string to symbol for hash key
76
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
105
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
77
106
 
78
-
79
- if attributes[:'id']
107
+ if attributes.has_key?(:'id')
80
108
  self.id = attributes[:'id']
81
109
  end
82
-
83
- if attributes[:'location_id']
110
+
111
+ if attributes.has_key?(:'location_id')
84
112
  self.location_id = attributes[:'location_id']
85
113
  end
86
-
87
- if attributes[:'created_at']
114
+
115
+ if attributes.has_key?(:'created_at')
88
116
  self.created_at = attributes[:'created_at']
89
117
  end
90
-
91
- if attributes[:'tenders']
118
+
119
+ if attributes.has_key?(:'tenders')
92
120
  if (value = attributes[:'tenders']).is_a?(Array)
93
121
  self.tenders = value
94
122
  end
95
123
  end
96
-
97
- if attributes[:'refunds']
124
+
125
+ if attributes.has_key?(:'refunds')
98
126
  if (value = attributes[:'refunds']).is_a?(Array)
99
127
  self.refunds = value
100
128
  end
101
129
  end
102
-
103
- if attributes[:'reference_id']
130
+
131
+ if attributes.has_key?(:'reference_id')
104
132
  self.reference_id = attributes[:'reference_id']
105
133
  end
106
-
107
- if attributes[:'product']
134
+
135
+ if attributes.has_key?(:'product')
108
136
  self.product = attributes[:'product']
109
137
  end
110
-
138
+
139
+ if attributes.has_key?(:'client_id')
140
+ self.client_id = attributes[:'client_id']
141
+ end
142
+
143
+ if attributes.has_key?(:'order')
144
+ self.order = attributes[:'order']
145
+ end
146
+
147
+ if attributes.has_key?(:'shipping_address')
148
+ self.shipping_address = attributes[:'shipping_address']
149
+ end
150
+
151
+ end
152
+
153
+ # Show invalid properties with the reasons. Usually used together with valid?
154
+ # @return Array for valid properies with the reasons
155
+ def list_invalid_properties
156
+ invalid_properties = Array.new
157
+ return invalid_properties
158
+ end
159
+
160
+ # Check to see if the all the properties in the model are valid
161
+ # @return true if the model is valid
162
+ def valid?
163
+ product_validator = EnumAttributeValidator.new('String', ["REGISTER", "EXTERNAL_API", "BILLING", "APPOINTMENTS", "INVOICES", "ONLINE_STORE", "PAYROLL", "OTHER"])
164
+ return false unless product_validator.valid?(@product)
165
+ return true
111
166
  end
112
167
 
113
168
  # Custom attribute writer method checking allowed values (enum).
169
+ # @param [Object] product Object to be assigned
114
170
  def product=(product)
115
- allowed_values = ["REGISTER", "EXTERNAL_API", "BILLING", "APPOINTMENTS", "INVOICES", "ONLINE_STORE", "PAYROLL", "OTHER"]
116
- if product && !allowed_values.include?(product)
117
- fail "invalid value for 'product', must be one of #{allowed_values}"
171
+ validator = EnumAttributeValidator.new('String', ["REGISTER", "EXTERNAL_API", "BILLING", "APPOINTMENTS", "INVOICES", "ONLINE_STORE", "PAYROLL", "OTHER"])
172
+ unless validator.valid?(product)
173
+ fail ArgumentError, "invalid value for 'product', must be one of #{validator.allowable_values}."
118
174
  end
119
175
  @product = product
120
176
  end
121
177
 
122
- # Check equality by comparing each attribute.
178
+ # Checks equality by comparing each attribute.
179
+ # @param [Object] Object to be compared
123
180
  def ==(o)
124
181
  return true if self.equal?(o)
125
182
  self.class == o.class &&
@@ -129,39 +186,48 @@ module SquareConnect
129
186
  tenders == o.tenders &&
130
187
  refunds == o.refunds &&
131
188
  reference_id == o.reference_id &&
132
- product == o.product
189
+ product == o.product &&
190
+ client_id == o.client_id &&
191
+ order == o.order &&
192
+ shipping_address == o.shipping_address
133
193
  end
134
194
 
135
195
  # @see the `==` method
196
+ # @param [Object] Object to be compared
136
197
  def eql?(o)
137
198
  self == o
138
199
  end
139
200
 
140
- # Calculate hash code according to all attributes.
201
+ # Calculates hash code according to all attributes.
202
+ # @return [Fixnum] Hash code
141
203
  def hash
142
- [id, location_id, created_at, tenders, refunds, reference_id, product].hash
204
+ [id, location_id, created_at, tenders, refunds, reference_id, product, client_id, order, shipping_address].hash
143
205
  end
144
206
 
145
- # build the object from hash
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
146
210
  def build_from_hash(attributes)
147
211
  return nil unless attributes.is_a?(Hash)
148
212
  self.class.swagger_types.each_pair do |key, type|
149
- if type =~ /^Array<(.*)>/i
213
+ if type =~ /\AArray<(.*)>/i
214
+ # check to ensure the input is an array given that the the attribute
215
+ # is documented as an array but the input is not
150
216
  if attributes[self.class.attribute_map[key]].is_a?(Array)
151
217
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
152
- else
153
- #TODO show warning in debug mode
154
218
  end
155
219
  elsif !attributes[self.class.attribute_map[key]].nil?
156
220
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
157
- else
158
- # data not found in attributes(hash), not an issue as the data can be optional
159
- end
221
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
160
222
  end
161
223
 
162
224
  self
163
225
  end
164
226
 
227
+ # Deserializes the data based on type
228
+ # @param string type Data type
229
+ # @param string value Value to be deserialized
230
+ # @return [Object] Deserialized data
165
231
  def _deserialize(type, value)
166
232
  case type.to_sym
167
233
  when :DateTime
@@ -175,15 +241,18 @@ module SquareConnect
175
241
  when :Float
176
242
  value.to_f
177
243
  when :BOOLEAN
178
- if value.to_s =~ /^(true|t|yes|y|1)$/i
244
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
245
  true
180
246
  else
181
247
  false
182
248
  end
249
+ when :Object
250
+ # generic object (usually a Hash), return directly
251
+ value
183
252
  when /\AArray<(?<inner_type>.+)>\z/
184
253
  inner_type = Regexp.last_match[:inner_type]
185
254
  value.map { |v| _deserialize(inner_type, v) }
186
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
255
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
256
  k_type = Regexp.last_match[:k_type]
188
257
  v_type = Regexp.last_match[:v_type]
189
258
  {}.tap do |hash|
@@ -192,21 +261,25 @@ module SquareConnect
192
261
  end
193
262
  end
194
263
  else # model
195
- _model = SquareConnect.const_get(type).new
196
- _model.build_from_hash(value)
264
+ temp_model = SquareConnect.const_get(type).new
265
+ temp_model.build_from_hash(value)
197
266
  end
198
267
  end
199
268
 
269
+ # Returns the string representation of the object
270
+ # @return [String] String presentation of the object
200
271
  def to_s
201
272
  to_hash.to_s
202
273
  end
203
274
 
204
- # to_body is an alias to to_body (backward compatibility))
275
+ # to_body is an alias to to_hash (backward compatibility)
276
+ # @return [Hash] Returns the object in the form of hash
205
277
  def to_body
206
278
  to_hash
207
279
  end
208
280
 
209
- # return the object in the form of hash
281
+ # Returns the object in the form of hash
282
+ # @return [Hash] Returns the object in the form of hash
210
283
  def to_hash
211
284
  hash = {}
212
285
  self.class.attribute_map.each_pair do |attr, param|
@@ -217,8 +290,10 @@ module SquareConnect
217
290
  hash
218
291
  end
219
292
 
220
- # Method to output non-array value in the form of hash
293
+ # Outputs non-array value in the form of hash
221
294
  # For object, use to_hash. Otherwise, just return the value
295
+ # @param [Object] value Any valid value
296
+ # @return [Hash] Returns the value in the form of hash
222
297
  def _to_hash(value)
223
298
  if value.is_a?(Array)
224
299
  value.compact.map{ |v| _to_hash(v) }
@@ -234,4 +309,5 @@ module SquareConnect
234
309
  end
235
310
 
236
311
  end
312
+
237
313
  end