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.
- checksums.yaml +4 -4
- data/Gemfile +7 -0
- data/README.md +151 -9
- data/Rakefile +8 -0
- data/docs/Address.md +26 -0
- data/docs/CaptureTransactionRequest.md +11 -0
- data/docs/CaptureTransactionResponse.md +12 -0
- data/docs/Card.md +18 -0
- data/docs/CardBrand.md +20 -0
- data/docs/ChargeRequest.md +22 -0
- data/docs/ChargeResponse.md +13 -0
- data/docs/Checkout.md +20 -0
- data/docs/CheckoutApi.md +62 -0
- data/docs/Country.md +261 -0
- data/docs/CreateCheckoutRequest.md +18 -0
- data/docs/CreateCheckoutResponse.md +13 -0
- data/docs/CreateCustomerCardRequest.md +14 -0
- data/docs/CreateCustomerCardResponse.md +13 -0
- data/docs/CreateCustomerRequest.md +20 -0
- data/docs/CreateCustomerResponse.md +13 -0
- data/docs/CreateOrderRequest.md +13 -0
- data/docs/CreateOrderRequestLineItem.md +14 -0
- data/docs/CreateOrderRequestOrder.md +13 -0
- data/docs/CreateRefundRequest.md +15 -0
- data/docs/CreateRefundResponse.md +13 -0
- data/docs/Currency.md +191 -0
- data/docs/Customer.md +26 -0
- data/docs/CustomerApi.md +267 -0
- data/docs/CustomerCardApi.md +116 -0
- data/docs/CustomerGroupInfo.md +13 -0
- data/docs/CustomerPreferences.md +12 -0
- data/docs/DeleteCustomerCardRequest.md +11 -0
- data/docs/DeleteCustomerCardResponse.md +12 -0
- data/docs/DeleteCustomerRequest.md +11 -0
- data/docs/DeleteCustomerResponse.md +12 -0
- data/docs/Error.md +15 -0
- data/docs/ErrorCategory.md +17 -0
- data/docs/ErrorCode.md +83 -0
- data/docs/ListCustomersRequest.md +12 -0
- data/docs/ListCustomersResponse.md +14 -0
- data/docs/ListLocationsRequest.md +11 -0
- data/docs/ListLocationsResponse.md +13 -0
- data/docs/ListRefundsRequest.md +15 -0
- data/docs/ListRefundsResponse.md +14 -0
- data/docs/ListTransactionsRequest.md +15 -0
- data/docs/ListTransactionsResponse.md +14 -0
- data/docs/Location.md +16 -0
- data/docs/LocationApi.md +56 -0
- data/docs/LocationCapability.md +12 -0
- data/docs/Money.md +13 -0
- data/docs/Order.md +16 -0
- data/docs/OrderLineItem.md +16 -0
- data/docs/Refund.md +20 -0
- data/docs/RefundApi.md +126 -0
- data/docs/RefundStatus.md +15 -0
- data/docs/RetrieveCustomerRequest.md +11 -0
- data/docs/RetrieveCustomerResponse.md +13 -0
- data/docs/RetrieveTransactionRequest.md +11 -0
- data/docs/RetrieveTransactionResponse.md +13 -0
- data/docs/SortOrder.md +13 -0
- data/docs/Tender.md +22 -0
- data/docs/TenderCardDetails.md +14 -0
- data/docs/TenderCardDetailsEntryMethod.md +16 -0
- data/docs/TenderCardDetailsStatus.md +15 -0
- data/docs/TenderCashDetails.md +13 -0
- data/docs/TenderType.md +17 -0
- data/docs/Transaction.md +21 -0
- data/docs/TransactionApi.md +285 -0
- data/docs/TransactionProduct.md +19 -0
- data/docs/UpdateCustomerRequest.md +20 -0
- data/docs/UpdateCustomerResponse.md +13 -0
- data/docs/VoidTransactionRequest.md +11 -0
- data/docs/VoidTransactionResponse.md +12 -0
- data/lib/square_connect.rb +33 -16
- data/lib/square_connect/api/checkout_api.rb +82 -0
- data/lib/square_connect/api/customer_api.rb +121 -162
- data/lib/square_connect/api/customer_card_api.rb +31 -50
- data/lib/square_connect/api/location_api.rb +12 -20
- data/lib/square_connect/api/refund_api.rb +70 -90
- data/lib/square_connect/api/transaction_api.rb +119 -165
- data/lib/square_connect/api_client.rb +64 -17
- data/lib/square_connect/api_error.rb +7 -3
- data/lib/square_connect/configuration.rb +31 -1
- data/lib/square_connect/models/address.rb +149 -78
- data/lib/square_connect/models/capture_transaction_request.rb +176 -0
- data/lib/square_connect/models/capture_transaction_response.rb +54 -26
- data/lib/square_connect/models/card.rb +98 -52
- data/lib/square_connect/models/card_brand.rb +12 -133
- data/lib/square_connect/models/charge_request.rb +106 -67
- data/lib/square_connect/models/charge_response.rb +57 -30
- data/lib/square_connect/models/checkout.rb +266 -0
- data/lib/square_connect/models/country.rb +253 -133
- data/lib/square_connect/models/create_checkout_request.rb +316 -0
- data/lib/square_connect/models/create_checkout_response.rb +198 -0
- data/lib/square_connect/models/create_customer_card_request.rb +66 -35
- data/lib/square_connect/models/create_customer_card_response.rb +58 -31
- data/lib/square_connect/models/create_customer_request.rb +79 -59
- data/lib/square_connect/models/create_customer_response.rb +58 -31
- data/lib/square_connect/models/create_order_request.rb +234 -0
- data/lib/square_connect/models/create_order_request_line_item.rb +268 -0
- data/lib/square_connect/models/create_order_request_order.rb +219 -0
- data/lib/square_connect/models/create_refund_request.rb +79 -39
- data/lib/square_connect/models/create_refund_response.rb +57 -30
- data/lib/square_connect/models/currency.rb +183 -133
- data/lib/square_connect/models/customer.rb +130 -77
- data/lib/square_connect/models/customer_group_info.rb +206 -0
- data/lib/square_connect/models/customer_preferences.rb +186 -0
- data/lib/square_connect/models/delete_customer_card_request.rb +176 -0
- data/lib/square_connect/models/delete_customer_card_response.rb +55 -27
- data/lib/square_connect/models/delete_customer_request.rb +176 -0
- data/lib/square_connect/models/delete_customer_response.rb +55 -27
- data/lib/square_connect/models/error.rb +107 -45
- data/lib/square_connect/models/error_category.rb +9 -133
- data/lib/square_connect/models/error_code.rb +75 -133
- data/lib/square_connect/models/list_customers_request.rb +55 -27
- data/lib/square_connect/models/list_customers_response.rb +61 -35
- data/lib/square_connect/models/list_locations_request.rb +176 -0
- data/lib/square_connect/models/list_locations_response.rb +57 -30
- data/lib/square_connect/models/list_refunds_request.rb +91 -42
- data/lib/square_connect/models/list_refunds_response.rb +59 -33
- data/lib/square_connect/models/list_transactions_request.rb +91 -42
- data/lib/square_connect/models/list_transactions_response.rb +59 -33
- data/lib/square_connect/models/location.rb +86 -41
- data/lib/square_connect/models/location_capability.rb +4 -133
- data/lib/square_connect/models/money.rb +85 -34
- data/lib/square_connect/models/order.rb +228 -0
- data/lib/square_connect/models/order_line_item.rb +226 -0
- data/lib/square_connect/models/refund.rb +138 -59
- data/lib/square_connect/models/refund_status.rb +7 -133
- data/lib/square_connect/models/retrieve_customer_request.rb +176 -0
- data/lib/square_connect/models/retrieve_customer_response.rb +58 -31
- data/lib/square_connect/models/retrieve_transaction_request.rb +176 -0
- data/lib/square_connect/models/retrieve_transaction_response.rb +57 -30
- data/lib/square_connect/models/sort_order.rb +5 -133
- data/lib/square_connect/models/tender.rb +112 -65
- data/lib/square_connect/models/tender_card_details.rb +93 -40
- data/lib/square_connect/models/tender_card_details_entry_method.rb +8 -133
- data/lib/square_connect/models/tender_card_details_status.rb +7 -133
- data/lib/square_connect/models/tender_cash_details.rb +58 -31
- data/lib/square_connect/models/tender_type.rb +9 -133
- data/lib/square_connect/models/transaction.rb +132 -56
- data/lib/square_connect/models/transaction_product.rb +11 -133
- data/lib/square_connect/models/update_customer_request.rb +79 -59
- data/lib/square_connect/models/update_customer_response.rb +58 -31
- data/lib/square_connect/models/void_transaction_request.rb +176 -0
- data/lib/square_connect/models/void_transaction_response.rb +54 -26
- data/lib/square_connect/version.rb +2 -3
- data/spec/api/checkout_api_spec.rb +53 -0
- data/spec/api/customer_api_spec.rb +121 -0
- data/spec/api/customer_card_api_spec.rb +71 -0
- data/spec/api/location_api_spec.rb +58 -0
- data/spec/api/refund_api_spec.rb +75 -0
- data/spec/api/transaction_api_spec.rb +128 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/address_spec.rb +186 -0
- data/spec/models/capture_transaction_request_spec.rb +36 -0
- data/spec/models/capture_transaction_response_spec.rb +46 -0
- data/spec/models/card_brand_spec.rb +36 -0
- data/spec/models/card_spec.rb +106 -0
- data/spec/models/charge_request_spec.rb +146 -0
- data/spec/models/charge_response_spec.rb +56 -0
- data/spec/models/checkout_spec.rb +126 -0
- data/spec/models/country_spec.rb +36 -0
- data/spec/models/create_checkout_request_spec.rb +106 -0
- data/spec/models/create_checkout_response_spec.rb +56 -0
- data/spec/models/create_customer_card_request_spec.rb +66 -0
- data/spec/models/create_customer_card_response_spec.rb +56 -0
- data/spec/models/create_customer_request_spec.rb +126 -0
- data/spec/models/create_customer_response_spec.rb +56 -0
- data/spec/models/create_order_request_line_item_spec.rb +66 -0
- data/spec/models/create_order_request_order_spec.rb +56 -0
- data/spec/models/create_order_request_spec.rb +56 -0
- data/spec/models/create_refund_request_spec.rb +76 -0
- data/spec/models/create_refund_response_spec.rb +56 -0
- data/spec/models/currency_spec.rb +36 -0
- data/spec/models/customer_group_info_spec.rb +56 -0
- data/spec/models/customer_preferences_spec.rb +46 -0
- data/spec/models/customer_spec.rb +186 -0
- data/spec/models/delete_customer_card_request_spec.rb +36 -0
- data/spec/models/delete_customer_card_response_spec.rb +46 -0
- data/spec/models/delete_customer_request_spec.rb +36 -0
- data/spec/models/delete_customer_response_spec.rb +46 -0
- data/spec/models/error_category_spec.rb +36 -0
- data/spec/models/error_code_spec.rb +36 -0
- data/spec/models/error_spec.rb +76 -0
- data/spec/models/list_customers_request_spec.rb +46 -0
- data/spec/models/list_customers_response_spec.rb +66 -0
- data/spec/models/list_locations_request_spec.rb +36 -0
- data/spec/models/list_locations_response_spec.rb +56 -0
- data/spec/models/list_refunds_request_spec.rb +76 -0
- data/spec/models/list_refunds_response_spec.rb +66 -0
- data/spec/models/list_transactions_request_spec.rb +76 -0
- data/spec/models/list_transactions_response_spec.rb +66 -0
- data/spec/models/location_capability_spec.rb +36 -0
- data/spec/models/location_spec.rb +86 -0
- data/spec/models/money_spec.rb +56 -0
- data/spec/models/order_line_item_spec.rb +86 -0
- data/spec/models/order_spec.rb +86 -0
- data/spec/models/refund_spec.rb +126 -0
- data/spec/models/refund_status_spec.rb +36 -0
- data/spec/models/retrieve_customer_request_spec.rb +36 -0
- data/spec/models/retrieve_customer_response_spec.rb +56 -0
- data/spec/models/retrieve_transaction_request_spec.rb +36 -0
- data/spec/models/retrieve_transaction_response_spec.rb +56 -0
- data/spec/models/sort_order_spec.rb +36 -0
- data/spec/models/tender_card_details_entry_method_spec.rb +36 -0
- data/spec/models/tender_card_details_spec.rb +66 -0
- data/spec/models/tender_card_details_status_spec.rb +36 -0
- data/spec/models/tender_cash_details_spec.rb +56 -0
- data/spec/models/tender_spec.rb +146 -0
- data/spec/models/tender_type_spec.rb +36 -0
- data/spec/models/transaction_product_spec.rb +36 -0
- data/spec/models/transaction_spec.rb +136 -0
- data/spec/models/update_customer_request_spec.rb +126 -0
- data/spec/models/update_customer_response_spec.rb +56 -0
- data/spec/models/void_transaction_request_spec.rb +36 -0
- data/spec/models/void_transaction_response_spec.rb +46 -0
- data/spec/spec_helper.rb +115 -0
- data/square_connect.gemspec +22 -11
- data/travis-ci/accounts.enc +0 -0
- metadata +264 -31
@@ -1,11 +1,10 @@
|
|
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'
|
@@ -16,32 +15,48 @@ module SquareConnect
|
|
16
15
|
# The location's unique ID.
|
17
16
|
attr_accessor :id
|
18
17
|
|
19
|
-
# The name
|
18
|
+
# The location's name.
|
20
19
|
attr_accessor :name
|
21
20
|
|
22
|
-
# The
|
21
|
+
# The location's physical address.
|
23
22
|
attr_accessor :address
|
24
23
|
|
25
|
-
# The IANA Timezone Database identifier for the location's timezone.
|
24
|
+
# The [IANA Timezone Database](https://www.iana.org/time-zones) identifier for the location's timezone.
|
26
25
|
attr_accessor :timezone
|
27
26
|
|
28
|
-
# Indicates which Square features are enabled for the location
|
27
|
+
# Indicates which Square features are enabled for the location. See [LocationCapability](#type-locationcapability) for possible values.
|
29
28
|
attr_accessor :capabilities
|
30
29
|
|
30
|
+
class EnumAttributeValidator
|
31
|
+
attr_reader :datatype
|
32
|
+
attr_reader :allowable_values
|
33
|
+
|
34
|
+
def initialize(datatype, allowable_values)
|
35
|
+
@allowable_values = allowable_values.map do |value|
|
36
|
+
case datatype.to_s
|
37
|
+
when /Integer/i
|
38
|
+
value.to_i
|
39
|
+
when /Float/i
|
40
|
+
value.to_f
|
41
|
+
else
|
42
|
+
value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def valid?(value)
|
48
|
+
!value || allowable_values.include?(value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
31
52
|
# Attribute mapping from ruby-style variable name to JSON key.
|
32
53
|
def self.attribute_map
|
33
54
|
{
|
34
|
-
|
35
55
|
:'id' => :'id',
|
36
|
-
|
37
56
|
:'name' => :'name',
|
38
|
-
|
39
57
|
:'address' => :'address',
|
40
|
-
|
41
58
|
:'timezone' => :'timezone',
|
42
|
-
|
43
59
|
:'capabilities' => :'capabilities'
|
44
|
-
|
45
60
|
}
|
46
61
|
end
|
47
62
|
|
@@ -53,42 +68,56 @@ module SquareConnect
|
|
53
68
|
:'address' => :'Address',
|
54
69
|
:'timezone' => :'String',
|
55
70
|
:'capabilities' => :'Array<String>'
|
56
|
-
|
57
71
|
}
|
58
72
|
end
|
59
73
|
|
74
|
+
# Initializes the object
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
60
76
|
def initialize(attributes = {})
|
61
77
|
return unless attributes.is_a?(Hash)
|
62
78
|
|
63
79
|
# convert string to symbol for hash key
|
64
|
-
attributes = attributes.
|
80
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
65
81
|
|
66
|
-
|
67
|
-
if attributes[:'id']
|
82
|
+
if attributes.has_key?(:'id')
|
68
83
|
self.id = attributes[:'id']
|
69
84
|
end
|
70
|
-
|
71
|
-
if attributes
|
85
|
+
|
86
|
+
if attributes.has_key?(:'name')
|
72
87
|
self.name = attributes[:'name']
|
73
88
|
end
|
74
|
-
|
75
|
-
if attributes
|
89
|
+
|
90
|
+
if attributes.has_key?(:'address')
|
76
91
|
self.address = attributes[:'address']
|
77
92
|
end
|
78
|
-
|
79
|
-
if attributes
|
93
|
+
|
94
|
+
if attributes.has_key?(:'timezone')
|
80
95
|
self.timezone = attributes[:'timezone']
|
81
96
|
end
|
82
|
-
|
83
|
-
if attributes
|
97
|
+
|
98
|
+
if attributes.has_key?(:'capabilities')
|
84
99
|
if (value = attributes[:'capabilities']).is_a?(Array)
|
85
100
|
self.capabilities = value
|
86
101
|
end
|
87
102
|
end
|
88
|
-
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
107
|
+
# @return Array for valid properies with the reasons
|
108
|
+
def list_invalid_properties
|
109
|
+
invalid_properties = Array.new
|
110
|
+
return invalid_properties
|
111
|
+
end
|
112
|
+
|
113
|
+
# Check to see if the all the properties in the model are valid
|
114
|
+
# @return true if the model is valid
|
115
|
+
def valid?
|
116
|
+
return true
|
89
117
|
end
|
90
118
|
|
91
|
-
#
|
119
|
+
# Checks equality by comparing each attribute.
|
120
|
+
# @param [Object] Object to be compared
|
92
121
|
def ==(o)
|
93
122
|
return true if self.equal?(o)
|
94
123
|
self.class == o.class &&
|
@@ -100,35 +129,41 @@ module SquareConnect
|
|
100
129
|
end
|
101
130
|
|
102
131
|
# @see the `==` method
|
132
|
+
# @param [Object] Object to be compared
|
103
133
|
def eql?(o)
|
104
134
|
self == o
|
105
135
|
end
|
106
136
|
|
107
|
-
#
|
137
|
+
# Calculates hash code according to all attributes.
|
138
|
+
# @return [Fixnum] Hash code
|
108
139
|
def hash
|
109
140
|
[id, name, address, timezone, capabilities].hash
|
110
141
|
end
|
111
142
|
|
112
|
-
#
|
143
|
+
# Builds the object from hash
|
144
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
145
|
+
# @return [Object] Returns the model itself
|
113
146
|
def build_from_hash(attributes)
|
114
147
|
return nil unless attributes.is_a?(Hash)
|
115
148
|
self.class.swagger_types.each_pair do |key, type|
|
116
|
-
if type =~
|
149
|
+
if type =~ /\AArray<(.*)>/i
|
150
|
+
# check to ensure the input is an array given that the the attribute
|
151
|
+
# is documented as an array but the input is not
|
117
152
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
118
153
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
119
|
-
else
|
120
|
-
#TODO show warning in debug mode
|
121
154
|
end
|
122
155
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
123
156
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
124
|
-
else
|
125
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
126
|
-
end
|
157
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
127
158
|
end
|
128
159
|
|
129
160
|
self
|
130
161
|
end
|
131
162
|
|
163
|
+
# Deserializes the data based on type
|
164
|
+
# @param string type Data type
|
165
|
+
# @param string value Value to be deserialized
|
166
|
+
# @return [Object] Deserialized data
|
132
167
|
def _deserialize(type, value)
|
133
168
|
case type.to_sym
|
134
169
|
when :DateTime
|
@@ -142,15 +177,18 @@ module SquareConnect
|
|
142
177
|
when :Float
|
143
178
|
value.to_f
|
144
179
|
when :BOOLEAN
|
145
|
-
if value.to_s =~
|
180
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
146
181
|
true
|
147
182
|
else
|
148
183
|
false
|
149
184
|
end
|
185
|
+
when :Object
|
186
|
+
# generic object (usually a Hash), return directly
|
187
|
+
value
|
150
188
|
when /\AArray<(?<inner_type>.+)>\z/
|
151
189
|
inner_type = Regexp.last_match[:inner_type]
|
152
190
|
value.map { |v| _deserialize(inner_type, v) }
|
153
|
-
when /\AHash<(?<k_type
|
191
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
154
192
|
k_type = Regexp.last_match[:k_type]
|
155
193
|
v_type = Regexp.last_match[:v_type]
|
156
194
|
{}.tap do |hash|
|
@@ -159,21 +197,25 @@ module SquareConnect
|
|
159
197
|
end
|
160
198
|
end
|
161
199
|
else # model
|
162
|
-
|
163
|
-
|
200
|
+
temp_model = SquareConnect.const_get(type).new
|
201
|
+
temp_model.build_from_hash(value)
|
164
202
|
end
|
165
203
|
end
|
166
204
|
|
205
|
+
# Returns the string representation of the object
|
206
|
+
# @return [String] String presentation of the object
|
167
207
|
def to_s
|
168
208
|
to_hash.to_s
|
169
209
|
end
|
170
210
|
|
171
|
-
# to_body is an alias to
|
211
|
+
# to_body is an alias to to_hash (backward compatibility)
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
172
213
|
def to_body
|
173
214
|
to_hash
|
174
215
|
end
|
175
216
|
|
176
|
-
#
|
217
|
+
# Returns the object in the form of hash
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
177
219
|
def to_hash
|
178
220
|
hash = {}
|
179
221
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -184,8 +226,10 @@ module SquareConnect
|
|
184
226
|
hash
|
185
227
|
end
|
186
228
|
|
187
|
-
#
|
229
|
+
# Outputs non-array value in the form of hash
|
188
230
|
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
189
233
|
def _to_hash(value)
|
190
234
|
if value.is_a?(Array)
|
191
235
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -201,4 +245,5 @@ module SquareConnect
|
|
201
245
|
end
|
202
246
|
|
203
247
|
end
|
248
|
+
|
204
249
|
end
|
@@ -1,147 +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
|
-
#
|
15
13
|
class LocationCapability
|
16
|
-
|
17
|
-
|
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
|
+
PROCESSING = "CREDIT_CARD_PROCESSING".freeze
|
146
16
|
end
|
17
|
+
|
147
18
|
end
|
@@ -1,32 +1,50 @@
|
|
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
|
+
# Represents an amount of money. __Important:__ Unlike version 1 of the Connect API, __all monetary amounts returned by v2 endpoints are positive.__ (In v1, monetary amounts are negative if they represent money being paid _by_ a merchant, instead of money being paid _to_ a merchant.)
|
15
14
|
class Money
|
16
|
-
#
|
15
|
+
# The amount of money, in the smallest denomination of the currency indicated by `currency`. For example, when `currency` is `USD`, `amount` is in cents.
|
17
16
|
attr_accessor :amount
|
18
17
|
|
19
|
-
#
|
18
|
+
# The type of currency, in __ISO 4217 format__. For example, the currency code for US dollars is `USD`. See [Currency](#type-currency) for possible values.
|
20
19
|
attr_accessor :currency
|
21
20
|
|
21
|
+
class EnumAttributeValidator
|
22
|
+
attr_reader :datatype
|
23
|
+
attr_reader :allowable_values
|
24
|
+
|
25
|
+
def initialize(datatype, allowable_values)
|
26
|
+
@allowable_values = allowable_values.map do |value|
|
27
|
+
case datatype.to_s
|
28
|
+
when /Integer/i
|
29
|
+
value.to_i
|
30
|
+
when /Float/i
|
31
|
+
value.to_f
|
32
|
+
else
|
33
|
+
value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid?(value)
|
39
|
+
!value || allowable_values.include?(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
22
43
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
44
|
def self.attribute_map
|
24
45
|
{
|
25
|
-
|
26
46
|
:'amount' => :'amount',
|
27
|
-
|
28
47
|
:'currency' => :'currency'
|
29
|
-
|
30
48
|
}
|
31
49
|
end
|
32
50
|
|
@@ -35,37 +53,54 @@ module SquareConnect
|
|
35
53
|
{
|
36
54
|
:'amount' => :'Integer',
|
37
55
|
:'currency' => :'String'
|
38
|
-
|
39
56
|
}
|
40
57
|
end
|
41
58
|
|
59
|
+
# Initializes the object
|
60
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
42
61
|
def initialize(attributes = {})
|
43
62
|
return unless attributes.is_a?(Hash)
|
44
63
|
|
45
64
|
# convert string to symbol for hash key
|
46
|
-
attributes = attributes.
|
65
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
47
66
|
|
48
|
-
|
49
|
-
if attributes[:'amount']
|
67
|
+
if attributes.has_key?(:'amount')
|
50
68
|
self.amount = attributes[:'amount']
|
51
69
|
end
|
52
|
-
|
53
|
-
if attributes
|
70
|
+
|
71
|
+
if attributes.has_key?(:'currency')
|
54
72
|
self.currency = attributes[:'currency']
|
55
73
|
end
|
56
|
-
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
78
|
+
# @return Array for valid properies with the reasons
|
79
|
+
def list_invalid_properties
|
80
|
+
invalid_properties = Array.new
|
81
|
+
return invalid_properties
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check to see if the all the properties in the model are valid
|
85
|
+
# @return true if the model is valid
|
86
|
+
def valid?
|
87
|
+
currency_validator = EnumAttributeValidator.new('String', ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"])
|
88
|
+
return false unless currency_validator.valid?(@currency)
|
89
|
+
return true
|
57
90
|
end
|
58
91
|
|
59
92
|
# Custom attribute writer method checking allowed values (enum).
|
93
|
+
# @param [Object] currency Object to be assigned
|
60
94
|
def currency=(currency)
|
61
|
-
|
62
|
-
|
63
|
-
fail "invalid value for 'currency', must be one of #{
|
95
|
+
validator = EnumAttributeValidator.new('String', ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"])
|
96
|
+
unless validator.valid?(currency)
|
97
|
+
fail ArgumentError, "invalid value for 'currency', must be one of #{validator.allowable_values}."
|
64
98
|
end
|
65
99
|
@currency = currency
|
66
100
|
end
|
67
101
|
|
68
|
-
#
|
102
|
+
# Checks equality by comparing each attribute.
|
103
|
+
# @param [Object] Object to be compared
|
69
104
|
def ==(o)
|
70
105
|
return true if self.equal?(o)
|
71
106
|
self.class == o.class &&
|
@@ -74,35 +109,41 @@ module SquareConnect
|
|
74
109
|
end
|
75
110
|
|
76
111
|
# @see the `==` method
|
112
|
+
# @param [Object] Object to be compared
|
77
113
|
def eql?(o)
|
78
114
|
self == o
|
79
115
|
end
|
80
116
|
|
81
|
-
#
|
117
|
+
# Calculates hash code according to all attributes.
|
118
|
+
# @return [Fixnum] Hash code
|
82
119
|
def hash
|
83
120
|
[amount, currency].hash
|
84
121
|
end
|
85
122
|
|
86
|
-
#
|
123
|
+
# Builds the object from hash
|
124
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
125
|
+
# @return [Object] Returns the model itself
|
87
126
|
def build_from_hash(attributes)
|
88
127
|
return nil unless attributes.is_a?(Hash)
|
89
128
|
self.class.swagger_types.each_pair do |key, type|
|
90
|
-
if type =~
|
129
|
+
if type =~ /\AArray<(.*)>/i
|
130
|
+
# check to ensure the input is an array given that the the attribute
|
131
|
+
# is documented as an array but the input is not
|
91
132
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
133
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
93
|
-
else
|
94
|
-
#TODO show warning in debug mode
|
95
134
|
end
|
96
135
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
97
136
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
98
|
-
else
|
99
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
100
|
-
end
|
137
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
101
138
|
end
|
102
139
|
|
103
140
|
self
|
104
141
|
end
|
105
142
|
|
143
|
+
# Deserializes the data based on type
|
144
|
+
# @param string type Data type
|
145
|
+
# @param string value Value to be deserialized
|
146
|
+
# @return [Object] Deserialized data
|
106
147
|
def _deserialize(type, value)
|
107
148
|
case type.to_sym
|
108
149
|
when :DateTime
|
@@ -116,15 +157,18 @@ module SquareConnect
|
|
116
157
|
when :Float
|
117
158
|
value.to_f
|
118
159
|
when :BOOLEAN
|
119
|
-
if value.to_s =~
|
160
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
120
161
|
true
|
121
162
|
else
|
122
163
|
false
|
123
164
|
end
|
165
|
+
when :Object
|
166
|
+
# generic object (usually a Hash), return directly
|
167
|
+
value
|
124
168
|
when /\AArray<(?<inner_type>.+)>\z/
|
125
169
|
inner_type = Regexp.last_match[:inner_type]
|
126
170
|
value.map { |v| _deserialize(inner_type, v) }
|
127
|
-
when /\AHash<(?<k_type
|
171
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
128
172
|
k_type = Regexp.last_match[:k_type]
|
129
173
|
v_type = Regexp.last_match[:v_type]
|
130
174
|
{}.tap do |hash|
|
@@ -133,21 +177,25 @@ module SquareConnect
|
|
133
177
|
end
|
134
178
|
end
|
135
179
|
else # model
|
136
|
-
|
137
|
-
|
180
|
+
temp_model = SquareConnect.const_get(type).new
|
181
|
+
temp_model.build_from_hash(value)
|
138
182
|
end
|
139
183
|
end
|
140
184
|
|
185
|
+
# Returns the string representation of the object
|
186
|
+
# @return [String] String presentation of the object
|
141
187
|
def to_s
|
142
188
|
to_hash.to_s
|
143
189
|
end
|
144
190
|
|
145
|
-
# to_body is an alias to
|
191
|
+
# to_body is an alias to to_hash (backward compatibility)
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
146
193
|
def to_body
|
147
194
|
to_hash
|
148
195
|
end
|
149
196
|
|
150
|
-
#
|
197
|
+
# Returns the object in the form of hash
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
151
199
|
def to_hash
|
152
200
|
hash = {}
|
153
201
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -158,8 +206,10 @@ module SquareConnect
|
|
158
206
|
hash
|
159
207
|
end
|
160
208
|
|
161
|
-
#
|
209
|
+
# Outputs non-array value in the form of hash
|
162
210
|
# For object, use to_hash. Otherwise, just return the value
|
211
|
+
# @param [Object] value Any valid value
|
212
|
+
# @return [Hash] Returns the value in the form of hash
|
163
213
|
def _to_hash(value)
|
164
214
|
if value.is_a?(Array)
|
165
215
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -175,4 +225,5 @@ module SquareConnect
|
|
175
225
|
end
|
176
226
|
|
177
227
|
end
|
228
|
+
|
178
229
|
end
|