square_connect 2.0.0

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +5 -0
  3. data/CONTRIBUTING.md +5 -0
  4. data/LICENSE.txt +202 -0
  5. data/README.md +47 -0
  6. data/lib/square_connect.rb +88 -0
  7. data/lib/square_connect/api/customer_api.rb +354 -0
  8. data/lib/square_connect/api/customer_card_api.rb +163 -0
  9. data/lib/square_connect/api/location_api.rb +82 -0
  10. data/lib/square_connect/api/refund_api.rb +179 -0
  11. data/lib/square_connect/api/transaction_api.rb +387 -0
  12. data/lib/square_connect/api_client.rb +337 -0
  13. data/lib/square_connect/api_error.rb +31 -0
  14. data/lib/square_connect/configuration.rb +163 -0
  15. data/lib/square_connect/models/address.rb +288 -0
  16. data/lib/square_connect/models/capture_transaction_response.rb +160 -0
  17. data/lib/square_connect/models/card.rb +233 -0
  18. data/lib/square_connect/models/card_brand.rb +147 -0
  19. data/lib/square_connect/models/charge_request.rb +257 -0
  20. data/lib/square_connect/models/charge_response.rb +171 -0
  21. data/lib/square_connect/models/country.rb +147 -0
  22. data/lib/square_connect/models/create_customer_card_request.rb +180 -0
  23. data/lib/square_connect/models/create_customer_card_response.rb +171 -0
  24. data/lib/square_connect/models/create_customer_request.rb +246 -0
  25. data/lib/square_connect/models/create_customer_response.rb +171 -0
  26. data/lib/square_connect/models/create_refund_request.rb +191 -0
  27. data/lib/square_connect/models/create_refund_response.rb +171 -0
  28. data/lib/square_connect/models/currency.rb +147 -0
  29. data/lib/square_connect/models/customer.rb +292 -0
  30. data/lib/square_connect/models/delete_customer_card_response.rb +160 -0
  31. data/lib/square_connect/models/delete_customer_response.rb +160 -0
  32. data/lib/square_connect/models/error.rb +209 -0
  33. data/lib/square_connect/models/error_category.rb +147 -0
  34. data/lib/square_connect/models/error_code.rb +147 -0
  35. data/lib/square_connect/models/list_customers_request.rb +158 -0
  36. data/lib/square_connect/models/list_customers_response.rb +184 -0
  37. data/lib/square_connect/models/list_locations_response.rb +173 -0
  38. data/lib/square_connect/models/list_refunds_request.rb +200 -0
  39. data/lib/square_connect/models/list_refunds_response.rb +184 -0
  40. data/lib/square_connect/models/list_transactions_request.rb +200 -0
  41. data/lib/square_connect/models/list_transactions_response.rb +184 -0
  42. data/lib/square_connect/models/location.rb +204 -0
  43. data/lib/square_connect/models/location_capability.rb +147 -0
  44. data/lib/square_connect/models/money.rb +178 -0
  45. data/lib/square_connect/models/refund.rb +255 -0
  46. data/lib/square_connect/models/refund_status.rb +147 -0
  47. data/lib/square_connect/models/retrieve_customer_response.rb +171 -0
  48. data/lib/square_connect/models/retrieve_transaction_response.rb +171 -0
  49. data/lib/square_connect/models/sort_order.rb +147 -0
  50. data/lib/square_connect/models/tender.rb +277 -0
  51. data/lib/square_connect/models/tender_card_details.rb +198 -0
  52. data/lib/square_connect/models/tender_card_details_entry_method.rb +147 -0
  53. data/lib/square_connect/models/tender_card_details_status.rb +147 -0
  54. data/lib/square_connect/models/tender_cash_details.rb +169 -0
  55. data/lib/square_connect/models/tender_type.rb +147 -0
  56. data/lib/square_connect/models/transaction.rb +237 -0
  57. data/lib/square_connect/models/transaction_product.rb +147 -0
  58. data/lib/square_connect/models/update_customer_request.rb +246 -0
  59. data/lib/square_connect/models/update_customer_response.rb +171 -0
  60. data/lib/square_connect/models/void_transaction_response.rb +160 -0
  61. data/lib/square_connect/version.rb +13 -0
  62. data/square_connect.gemspec +32 -0
  63. metadata +286 -0
@@ -0,0 +1,147 @@
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
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module SquareConnect
14
+ #
15
+ class CardBrand
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
+
146
+ end
147
+ end
@@ -0,0 +1,257 @@
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
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module SquareConnect
14
+ # Defines the parameters that can be included in the body of\na request to the **Charge** endpoint.
15
+ class ChargeRequest
16
+ # A value you specify that uniquely identifies this\ntransaction among transactions you've created.\n\nIf you're unsure whether a particular transaction succeeded,\nyou can reattempt it with the same idempotency key without\nworrying about double-charging the buyer. Note that *all other fields*\nmust also remain identical in your followup request, or an error will occur.
17
+ attr_accessor :idempotency_key
18
+
19
+ # The amount of money to collect in the transaction.
20
+ attr_accessor :amount_money
21
+
22
+ # A nonce representing the credit card to charge for this transaction.\nDo not provide a value for this field if you provide a value for\n`customer_card_id`.
23
+ attr_accessor :card_nonce
24
+
25
+ # The ID of the customer card on file to charge for this transaction. Do\nnot provide a value for this field if you provide a value for `card_nonce`.
26
+ attr_accessor :customer_card_id
27
+
28
+ # If `true`, the request will only perform an Auth on the provided\ncard. You can then later perform either a Capture (with the\n*CaptureTransaction** endpoint) or a Void (with the **VoidTransation**\nendpoint.
29
+ attr_accessor :delay_capture
30
+
31
+ # An optional ID you can associate with the transaction for your own\npurposes (such as to associate the transaction with an entity ID in your\nown database).
32
+ attr_accessor :reference_id
33
+
34
+ # An optional note to associate with the transaction.
35
+ attr_accessor :note
36
+
37
+ # The ID of the customer to associate this transaction with. This field\nis required if you provide a value for `customer_card_id`, and optional\notherwise.
38
+ attr_accessor :customer_id
39
+
40
+ # If available, Postal code in the billing address for US and Canada payments may reduce decline rate.
41
+ attr_accessor :billing_address
42
+
43
+ #
44
+ attr_accessor :shipping_address
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+
50
+ :'idempotency_key' => :'idempotency_key',
51
+
52
+ :'amount_money' => :'amount_money',
53
+
54
+ :'card_nonce' => :'card_nonce',
55
+
56
+ :'customer_card_id' => :'customer_card_id',
57
+
58
+ :'delay_capture' => :'delay_capture',
59
+
60
+ :'reference_id' => :'reference_id',
61
+
62
+ :'note' => :'note',
63
+
64
+ :'customer_id' => :'customer_id',
65
+
66
+ :'billing_address' => :'billing_address',
67
+
68
+ :'shipping_address' => :'shipping_address'
69
+
70
+ }
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.swagger_types
75
+ {
76
+ :'idempotency_key' => :'String',
77
+ :'amount_money' => :'Money',
78
+ :'card_nonce' => :'String',
79
+ :'customer_card_id' => :'String',
80
+ :'delay_capture' => :'BOOLEAN',
81
+ :'reference_id' => :'String',
82
+ :'note' => :'String',
83
+ :'customer_id' => :'String',
84
+ :'billing_address' => :'Address',
85
+ :'shipping_address' => :'Address'
86
+
87
+ }
88
+ end
89
+
90
+ def initialize(attributes = {})
91
+ return unless attributes.is_a?(Hash)
92
+
93
+ # convert string to symbol for hash key
94
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
95
+
96
+
97
+ if attributes[:'idempotency_key']
98
+ self.idempotency_key = attributes[:'idempotency_key']
99
+ end
100
+
101
+ if attributes[:'amount_money']
102
+ self.amount_money = attributes[:'amount_money']
103
+ end
104
+
105
+ if attributes[:'card_nonce']
106
+ self.card_nonce = attributes[:'card_nonce']
107
+ end
108
+
109
+ if attributes[:'customer_card_id']
110
+ self.customer_card_id = attributes[:'customer_card_id']
111
+ end
112
+
113
+ if attributes[:'delay_capture']
114
+ self.delay_capture = attributes[:'delay_capture']
115
+ end
116
+
117
+ if attributes[:'reference_id']
118
+ self.reference_id = attributes[:'reference_id']
119
+ end
120
+
121
+ if attributes[:'note']
122
+ self.note = attributes[:'note']
123
+ end
124
+
125
+ if attributes[:'customer_id']
126
+ self.customer_id = attributes[:'customer_id']
127
+ end
128
+
129
+ if attributes[:'billing_address']
130
+ self.billing_address = attributes[:'billing_address']
131
+ end
132
+
133
+ if attributes[:'shipping_address']
134
+ self.shipping_address = attributes[:'shipping_address']
135
+ end
136
+
137
+ end
138
+
139
+ # Check equality by comparing each attribute.
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ idempotency_key == o.idempotency_key &&
144
+ amount_money == o.amount_money &&
145
+ card_nonce == o.card_nonce &&
146
+ customer_card_id == o.customer_card_id &&
147
+ delay_capture == o.delay_capture &&
148
+ reference_id == o.reference_id &&
149
+ note == o.note &&
150
+ customer_id == o.customer_id &&
151
+ billing_address == o.billing_address &&
152
+ shipping_address == o.shipping_address
153
+ end
154
+
155
+ # @see the `==` method
156
+ def eql?(o)
157
+ self == o
158
+ end
159
+
160
+ # Calculate hash code according to all attributes.
161
+ def hash
162
+ [idempotency_key, amount_money, card_nonce, customer_card_id, delay_capture, reference_id, note, customer_id, billing_address, shipping_address].hash
163
+ end
164
+
165
+ # build the object from hash
166
+ def build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ self.class.swagger_types.each_pair do |key, type|
169
+ if type =~ /^Array<(.*)>/i
170
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
171
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
172
+ else
173
+ #TODO show warning in debug mode
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ else
178
+ # data not found in attributes(hash), not an issue as the data can be optional
179
+ end
180
+ end
181
+
182
+ self
183
+ end
184
+
185
+ def _deserialize(type, value)
186
+ case type.to_sym
187
+ when :DateTime
188
+ DateTime.parse(value)
189
+ when :Date
190
+ Date.parse(value)
191
+ when :String
192
+ value.to_s
193
+ when :Integer
194
+ value.to_i
195
+ when :Float
196
+ value.to_f
197
+ when :BOOLEAN
198
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
199
+ true
200
+ else
201
+ false
202
+ end
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ _model = SquareConnect.const_get(type).new
216
+ _model.build_from_hash(value)
217
+ end
218
+ end
219
+
220
+ def to_s
221
+ to_hash.to_s
222
+ end
223
+
224
+ # to_body is an alias to to_body (backward compatibility))
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # return the object in the form of hash
230
+ def to_hash
231
+ hash = {}
232
+ self.class.attribute_map.each_pair do |attr, param|
233
+ value = self.send(attr)
234
+ next if value.nil?
235
+ hash[param] = _to_hash(value)
236
+ end
237
+ hash
238
+ end
239
+
240
+ # Method to output non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map{ |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+ end
@@ -0,0 +1,171 @@
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
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module SquareConnect
14
+ # Defines the fields that are included in the response body of\na request to the **Charge** endpoint.\n\nOne of `errors` or `transaction` is present in a given response (never both).
15
+ class ChargeResponse
16
+ # Any errors that occurred during the request.
17
+ attr_accessor :errors
18
+
19
+ # The details of the created transaction.
20
+ attr_accessor :transaction
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+
26
+ :'errors' => :'errors',
27
+
28
+ :'transaction' => :'transaction'
29
+
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'errors' => :'Array<Error>',
37
+ :'transaction' => :'Transaction'
38
+
39
+ }
40
+ end
41
+
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
47
+
48
+
49
+ if attributes[:'errors']
50
+ if (value = attributes[:'errors']).is_a?(Array)
51
+ self.errors = value
52
+ end
53
+ end
54
+
55
+ if attributes[:'transaction']
56
+ self.transaction = attributes[:'transaction']
57
+ end
58
+
59
+ end
60
+
61
+ # Check equality by comparing each attribute.
62
+ def ==(o)
63
+ return true if self.equal?(o)
64
+ self.class == o.class &&
65
+ errors == o.errors &&
66
+ transaction == o.transaction
67
+ end
68
+
69
+ # @see the `==` method
70
+ def eql?(o)
71
+ self == o
72
+ end
73
+
74
+ # Calculate hash code according to all attributes.
75
+ def hash
76
+ [errors, transaction].hash
77
+ end
78
+
79
+ # build the object from hash
80
+ def build_from_hash(attributes)
81
+ return nil unless attributes.is_a?(Hash)
82
+ self.class.swagger_types.each_pair do |key, type|
83
+ if type =~ /^Array<(.*)>/i
84
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
85
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
86
+ else
87
+ #TODO show warning in debug mode
88
+ end
89
+ elsif !attributes[self.class.attribute_map[key]].nil?
90
+ 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
94
+ end
95
+
96
+ self
97
+ end
98
+
99
+ def _deserialize(type, value)
100
+ case type.to_sym
101
+ when :DateTime
102
+ DateTime.parse(value)
103
+ when :Date
104
+ Date.parse(value)
105
+ when :String
106
+ value.to_s
107
+ when :Integer
108
+ value.to_i
109
+ when :Float
110
+ value.to_f
111
+ when :BOOLEAN
112
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
113
+ true
114
+ else
115
+ false
116
+ end
117
+ when /\AArray<(?<inner_type>.+)>\z/
118
+ inner_type = Regexp.last_match[:inner_type]
119
+ value.map { |v| _deserialize(inner_type, v) }
120
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
121
+ k_type = Regexp.last_match[:k_type]
122
+ v_type = Regexp.last_match[:v_type]
123
+ {}.tap do |hash|
124
+ value.each do |k, v|
125
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
126
+ end
127
+ end
128
+ else # model
129
+ _model = SquareConnect.const_get(type).new
130
+ _model.build_from_hash(value)
131
+ end
132
+ end
133
+
134
+ def to_s
135
+ to_hash.to_s
136
+ end
137
+
138
+ # to_body is an alias to to_body (backward compatibility))
139
+ def to_body
140
+ to_hash
141
+ end
142
+
143
+ # return the object in the form of hash
144
+ def to_hash
145
+ hash = {}
146
+ self.class.attribute_map.each_pair do |attr, param|
147
+ value = self.send(attr)
148
+ next if value.nil?
149
+ hash[param] = _to_hash(value)
150
+ end
151
+ hash
152
+ end
153
+
154
+ # Method to output non-array value in the form of hash
155
+ # For object, use to_hash. Otherwise, just return the value
156
+ def _to_hash(value)
157
+ if value.is_a?(Array)
158
+ value.compact.map{ |v| _to_hash(v) }
159
+ elsif value.is_a?(Hash)
160
+ {}.tap do |hash|
161
+ value.each { |k, v| hash[k] = _to_hash(v) }
162
+ end
163
+ elsif value.respond_to? :to_hash
164
+ value.to_hash
165
+ else
166
+ value
167
+ end
168
+ end
169
+
170
+ end
171
+ end