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.
- 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
@@ -0,0 +1,176 @@
|
|
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
|
+
#
|
14
|
+
class DeleteCustomerRequest
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attribute type mapping.
|
23
|
+
def self.swagger_types
|
24
|
+
{
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Initializes the object
|
29
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
30
|
+
def initialize(attributes = {})
|
31
|
+
return unless attributes.is_a?(Hash)
|
32
|
+
|
33
|
+
# convert string to symbol for hash key
|
34
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
39
|
+
# @return Array for valid properies with the reasons
|
40
|
+
def list_invalid_properties
|
41
|
+
invalid_properties = Array.new
|
42
|
+
return invalid_properties
|
43
|
+
end
|
44
|
+
|
45
|
+
# Check to see if the all the properties in the model are valid
|
46
|
+
# @return true if the model is valid
|
47
|
+
def valid?
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
|
51
|
+
# Checks equality by comparing each attribute.
|
52
|
+
# @param [Object] Object to be compared
|
53
|
+
def ==(o)
|
54
|
+
return true if self.equal?(o)
|
55
|
+
self.class == o.class
|
56
|
+
end
|
57
|
+
|
58
|
+
# @see the `==` method
|
59
|
+
# @param [Object] Object to be compared
|
60
|
+
def eql?(o)
|
61
|
+
self == o
|
62
|
+
end
|
63
|
+
|
64
|
+
# Calculates hash code according to all attributes.
|
65
|
+
# @return [Fixnum] Hash code
|
66
|
+
def hash
|
67
|
+
[].hash
|
68
|
+
end
|
69
|
+
|
70
|
+
# Builds the object from hash
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
72
|
+
# @return [Object] Returns the model itself
|
73
|
+
def build_from_hash(attributes)
|
74
|
+
return nil unless attributes.is_a?(Hash)
|
75
|
+
self.class.swagger_types.each_pair do |key, type|
|
76
|
+
if type =~ /\AArray<(.*)>/i
|
77
|
+
# check to ensure the input is an array given that the the attribute
|
78
|
+
# is documented as an array but the input is not
|
79
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
80
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
81
|
+
end
|
82
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
83
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
84
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
85
|
+
end
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
# Deserializes the data based on type
|
91
|
+
# @param string type Data type
|
92
|
+
# @param string value Value to be deserialized
|
93
|
+
# @return [Object] Deserialized data
|
94
|
+
def _deserialize(type, value)
|
95
|
+
case type.to_sym
|
96
|
+
when :DateTime
|
97
|
+
DateTime.parse(value)
|
98
|
+
when :Date
|
99
|
+
Date.parse(value)
|
100
|
+
when :String
|
101
|
+
value.to_s
|
102
|
+
when :Integer
|
103
|
+
value.to_i
|
104
|
+
when :Float
|
105
|
+
value.to_f
|
106
|
+
when :BOOLEAN
|
107
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
108
|
+
true
|
109
|
+
else
|
110
|
+
false
|
111
|
+
end
|
112
|
+
when :Object
|
113
|
+
# generic object (usually a Hash), return directly
|
114
|
+
value
|
115
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
116
|
+
inner_type = Regexp.last_match[:inner_type]
|
117
|
+
value.map { |v| _deserialize(inner_type, v) }
|
118
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
119
|
+
k_type = Regexp.last_match[:k_type]
|
120
|
+
v_type = Regexp.last_match[:v_type]
|
121
|
+
{}.tap do |hash|
|
122
|
+
value.each do |k, v|
|
123
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
else # model
|
127
|
+
temp_model = SquareConnect.const_get(type).new
|
128
|
+
temp_model.build_from_hash(value)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns the string representation of the object
|
133
|
+
# @return [String] String presentation of the object
|
134
|
+
def to_s
|
135
|
+
to_hash.to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
# to_body is an alias to to_hash (backward compatibility)
|
139
|
+
# @return [Hash] Returns the object in the form of hash
|
140
|
+
def to_body
|
141
|
+
to_hash
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the object in the form of hash
|
145
|
+
# @return [Hash] Returns the object in the form of hash
|
146
|
+
def to_hash
|
147
|
+
hash = {}
|
148
|
+
self.class.attribute_map.each_pair do |attr, param|
|
149
|
+
value = self.send(attr)
|
150
|
+
next if value.nil?
|
151
|
+
hash[param] = _to_hash(value)
|
152
|
+
end
|
153
|
+
hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# Outputs non-array value in the form of hash
|
157
|
+
# For object, use to_hash. Otherwise, just return the value
|
158
|
+
# @param [Object] value Any valid value
|
159
|
+
# @return [Hash] Returns the value in the form of hash
|
160
|
+
def _to_hash(value)
|
161
|
+
if value.is_a?(Array)
|
162
|
+
value.compact.map{ |v| _to_hash(v) }
|
163
|
+
elsif value.is_a?(Hash)
|
164
|
+
{}.tap do |hash|
|
165
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
166
|
+
end
|
167
|
+
elsif value.respond_to? :to_hash
|
168
|
+
value.to_hash
|
169
|
+
else
|
170
|
+
value
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
@@ -1,27 +1,25 @@
|
|
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
|
13
|
+
# Defines the fields that are included in the response body of a request to the [DeleteCustomer](#endpoint-deletecustomer) endpoint.
|
15
14
|
class DeleteCustomerResponse
|
16
|
-
#
|
15
|
+
# Any errors that occurred during the request.
|
17
16
|
attr_accessor :errors
|
18
17
|
|
18
|
+
|
19
19
|
# Attribute mapping from ruby-style variable name to JSON key.
|
20
20
|
def self.attribute_map
|
21
21
|
{
|
22
|
-
|
23
22
|
:'errors' => :'errors'
|
24
|
-
|
25
23
|
}
|
26
24
|
end
|
27
25
|
|
@@ -29,26 +27,40 @@ module SquareConnect
|
|
29
27
|
def self.swagger_types
|
30
28
|
{
|
31
29
|
:'errors' => :'Array<Error>'
|
32
|
-
|
33
30
|
}
|
34
31
|
end
|
35
32
|
|
33
|
+
# Initializes the object
|
34
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
35
|
def initialize(attributes = {})
|
37
36
|
return unless attributes.is_a?(Hash)
|
38
37
|
|
39
38
|
# convert string to symbol for hash key
|
40
|
-
attributes = attributes.
|
39
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
41
40
|
|
42
|
-
|
43
|
-
if attributes[:'errors']
|
41
|
+
if attributes.has_key?(:'errors')
|
44
42
|
if (value = attributes[:'errors']).is_a?(Array)
|
45
43
|
self.errors = value
|
46
44
|
end
|
47
45
|
end
|
48
|
-
|
46
|
+
|
49
47
|
end
|
50
48
|
|
51
|
-
#
|
49
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
50
|
+
# @return Array for valid properies with the reasons
|
51
|
+
def list_invalid_properties
|
52
|
+
invalid_properties = Array.new
|
53
|
+
return invalid_properties
|
54
|
+
end
|
55
|
+
|
56
|
+
# Check to see if the all the properties in the model are valid
|
57
|
+
# @return true if the model is valid
|
58
|
+
def valid?
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks equality by comparing each attribute.
|
63
|
+
# @param [Object] Object to be compared
|
52
64
|
def ==(o)
|
53
65
|
return true if self.equal?(o)
|
54
66
|
self.class == o.class &&
|
@@ -56,35 +68,41 @@ module SquareConnect
|
|
56
68
|
end
|
57
69
|
|
58
70
|
# @see the `==` method
|
71
|
+
# @param [Object] Object to be compared
|
59
72
|
def eql?(o)
|
60
73
|
self == o
|
61
74
|
end
|
62
75
|
|
63
|
-
#
|
76
|
+
# Calculates hash code according to all attributes.
|
77
|
+
# @return [Fixnum] Hash code
|
64
78
|
def hash
|
65
79
|
[errors].hash
|
66
80
|
end
|
67
81
|
|
68
|
-
#
|
82
|
+
# Builds the object from hash
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
# @return [Object] Returns the model itself
|
69
85
|
def build_from_hash(attributes)
|
70
86
|
return nil unless attributes.is_a?(Hash)
|
71
87
|
self.class.swagger_types.each_pair do |key, type|
|
72
|
-
if type =~
|
88
|
+
if type =~ /\AArray<(.*)>/i
|
89
|
+
# check to ensure the input is an array given that the the attribute
|
90
|
+
# is documented as an array but the input is not
|
73
91
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
74
92
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
75
|
-
else
|
76
|
-
#TODO show warning in debug mode
|
77
93
|
end
|
78
94
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
79
95
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
80
|
-
else
|
81
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
82
|
-
end
|
96
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
83
97
|
end
|
84
98
|
|
85
99
|
self
|
86
100
|
end
|
87
101
|
|
102
|
+
# Deserializes the data based on type
|
103
|
+
# @param string type Data type
|
104
|
+
# @param string value Value to be deserialized
|
105
|
+
# @return [Object] Deserialized data
|
88
106
|
def _deserialize(type, value)
|
89
107
|
case type.to_sym
|
90
108
|
when :DateTime
|
@@ -98,15 +116,18 @@ module SquareConnect
|
|
98
116
|
when :Float
|
99
117
|
value.to_f
|
100
118
|
when :BOOLEAN
|
101
|
-
if value.to_s =~
|
119
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
102
120
|
true
|
103
121
|
else
|
104
122
|
false
|
105
123
|
end
|
124
|
+
when :Object
|
125
|
+
# generic object (usually a Hash), return directly
|
126
|
+
value
|
106
127
|
when /\AArray<(?<inner_type>.+)>\z/
|
107
128
|
inner_type = Regexp.last_match[:inner_type]
|
108
129
|
value.map { |v| _deserialize(inner_type, v) }
|
109
|
-
when /\AHash<(?<k_type
|
130
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
110
131
|
k_type = Regexp.last_match[:k_type]
|
111
132
|
v_type = Regexp.last_match[:v_type]
|
112
133
|
{}.tap do |hash|
|
@@ -115,21 +136,25 @@ module SquareConnect
|
|
115
136
|
end
|
116
137
|
end
|
117
138
|
else # model
|
118
|
-
|
119
|
-
|
139
|
+
temp_model = SquareConnect.const_get(type).new
|
140
|
+
temp_model.build_from_hash(value)
|
120
141
|
end
|
121
142
|
end
|
122
143
|
|
144
|
+
# Returns the string representation of the object
|
145
|
+
# @return [String] String presentation of the object
|
123
146
|
def to_s
|
124
147
|
to_hash.to_s
|
125
148
|
end
|
126
149
|
|
127
|
-
# to_body is an alias to
|
150
|
+
# to_body is an alias to to_hash (backward compatibility)
|
151
|
+
# @return [Hash] Returns the object in the form of hash
|
128
152
|
def to_body
|
129
153
|
to_hash
|
130
154
|
end
|
131
155
|
|
132
|
-
#
|
156
|
+
# Returns the object in the form of hash
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
133
158
|
def to_hash
|
134
159
|
hash = {}
|
135
160
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -140,8 +165,10 @@ module SquareConnect
|
|
140
165
|
hash
|
141
166
|
end
|
142
167
|
|
143
|
-
#
|
168
|
+
# Outputs non-array value in the form of hash
|
144
169
|
# For object, use to_hash. Otherwise, just return the value
|
170
|
+
# @param [Object] value Any valid value
|
171
|
+
# @return [Hash] Returns the value in the form of hash
|
145
172
|
def _to_hash(value)
|
146
173
|
if value.is_a?(Array)
|
147
174
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -157,4 +184,5 @@ module SquareConnect
|
|
157
184
|
end
|
158
185
|
|
159
186
|
end
|
187
|
+
|
160
188
|
end
|
@@ -1,42 +1,58 @@
|
|
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 error encountered during a request to the Connect API. See [Handling errors](#handlingerrors) for more information.
|
15
14
|
class Error
|
16
|
-
#
|
15
|
+
# The error's high-level category. See [ErrorCategory](#type-errorcategory) for possible values.
|
17
16
|
attr_accessor :category
|
18
17
|
|
19
|
-
#
|
18
|
+
# The error's specific code. See [ErrorCode](#type-errorcode) for possible values
|
20
19
|
attr_accessor :code
|
21
20
|
|
22
|
-
#
|
21
|
+
# A human-readable description of the error for debugging purposes.
|
23
22
|
attr_accessor :detail
|
24
23
|
|
25
|
-
#
|
24
|
+
# The name of the field provided in the original request that the error pertains to, if any.
|
26
25
|
attr_accessor :field
|
27
26
|
|
27
|
+
class EnumAttributeValidator
|
28
|
+
attr_reader :datatype
|
29
|
+
attr_reader :allowable_values
|
30
|
+
|
31
|
+
def initialize(datatype, allowable_values)
|
32
|
+
@allowable_values = allowable_values.map do |value|
|
33
|
+
case datatype.to_s
|
34
|
+
when /Integer/i
|
35
|
+
value.to_i
|
36
|
+
when /Float/i
|
37
|
+
value.to_f
|
38
|
+
else
|
39
|
+
value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def valid?(value)
|
45
|
+
!value || allowable_values.include?(value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
28
49
|
# Attribute mapping from ruby-style variable name to JSON key.
|
29
50
|
def self.attribute_map
|
30
51
|
{
|
31
|
-
|
32
52
|
:'category' => :'category',
|
33
|
-
|
34
53
|
:'code' => :'code',
|
35
|
-
|
36
54
|
:'detail' => :'detail',
|
37
|
-
|
38
55
|
:'field' => :'field'
|
39
|
-
|
40
56
|
}
|
41
57
|
end
|
42
58
|
|
@@ -47,54 +63,84 @@ module SquareConnect
|
|
47
63
|
:'code' => :'String',
|
48
64
|
:'detail' => :'String',
|
49
65
|
:'field' => :'String'
|
50
|
-
|
51
66
|
}
|
52
67
|
end
|
53
68
|
|
69
|
+
# Initializes the object
|
70
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
54
71
|
def initialize(attributes = {})
|
55
72
|
return unless attributes.is_a?(Hash)
|
56
73
|
|
57
74
|
# convert string to symbol for hash key
|
58
|
-
attributes = attributes.
|
75
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
59
76
|
|
60
|
-
|
61
|
-
if attributes[:'category']
|
77
|
+
if attributes.has_key?(:'category')
|
62
78
|
self.category = attributes[:'category']
|
63
79
|
end
|
64
|
-
|
65
|
-
if attributes
|
80
|
+
|
81
|
+
if attributes.has_key?(:'code')
|
66
82
|
self.code = attributes[:'code']
|
67
83
|
end
|
68
|
-
|
69
|
-
if attributes
|
84
|
+
|
85
|
+
if attributes.has_key?(:'detail')
|
70
86
|
self.detail = attributes[:'detail']
|
71
87
|
end
|
72
|
-
|
73
|
-
if attributes
|
88
|
+
|
89
|
+
if attributes.has_key?(:'field')
|
74
90
|
self.field = attributes[:'field']
|
75
91
|
end
|
76
|
-
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
96
|
+
# @return Array for valid properies with the reasons
|
97
|
+
def list_invalid_properties
|
98
|
+
invalid_properties = Array.new
|
99
|
+
if @category.nil?
|
100
|
+
invalid_properties.push("invalid value for 'category', category cannot be nil.")
|
101
|
+
end
|
102
|
+
|
103
|
+
if @code.nil?
|
104
|
+
invalid_properties.push("invalid value for 'code', code cannot be nil.")
|
105
|
+
end
|
106
|
+
|
107
|
+
return invalid_properties
|
108
|
+
end
|
109
|
+
|
110
|
+
# Check to see if the all the properties in the model are valid
|
111
|
+
# @return true if the model is valid
|
112
|
+
def valid?
|
113
|
+
return false if @category.nil?
|
114
|
+
category_validator = EnumAttributeValidator.new('String', ["API_ERROR", "AUTHENTICATION_ERROR", "INVALID_REQUEST_ERROR", "RATE_LIMIT_ERROR", "PAYMENT_METHOD_ERROR", "REFUND_ERROR"])
|
115
|
+
return false unless category_validator.valid?(@category)
|
116
|
+
return false if @code.nil?
|
117
|
+
code_validator = EnumAttributeValidator.new('String', ["INTERNAL_SERVER_ERROR", "UNAUTHORIZED", "ACCESS_TOKEN_EXPIRED", "ACCESS_TOKEN_REVOKED", "FORBIDDEN", "INSUFFICIENT_SCOPES", "APPLICATION_DISABLED", "V1_APPLICATION", "V1_ACCESS_TOKEN", "CARD_PROCESSING_NOT_ENABLED", "BAD_REQUEST", "MISSING_REQUIRED_PARAMETER", "INCORRECT_TYPE", "INVALID_TIME", "INVALID_TIME_RANGE", "INVALID_VALUE", "INVALID_CURSOR", "UNKNOWN_QUERY_PARAMETER", "CONFLICTING_PARAMETERS", "EXPECTED_JSON_BODY", "INVALID_SORT_ORDER", "VALUE_REGEX_MISMATCH", "VALUE_TOO_SHORT", "VALUE_TOO_LONG", "VALUE_TOO_LOW", "VALUE_TOO_HIGH", "VALUE_EMPTY", "ARRAY_EMPTY", "EXPECTED_BOOLEAN", "EXPECTED_INTEGER", "EXPECTED_FLOAT", "EXPECTED_STRING", "EXPECTED_OBJECT", "EXPECTED_ARRAY", "EXPECTED_BASE64_ENCODED_BYTE_ARRAY", "INVALID_ARRAY_VALUE", "INVALID_ENUM_VALUE", "INVALID_CONTENT_TYPE", "INVALID_FORM_VALUE", "ONE_INSTRUMENT_EXPECTED", "NO_FIELDS_SET", "CARD_EXPIRED", "INVALID_EXPIRATION", "INVALID_EXPIRATION_YEAR", "INVALID_EXPIRATION_DATE", "UNSUPPORTED_CARD_BRAND", "INVALID_CARD", "DELAYED_TRANSACTION_EXPIRED", "DELAYED_TRANSACTION_CANCELED", "DELAYED_TRANSACTION_CAPTURED", "DELAYED_TRANSACTION_FAILED", "CARD_TOKEN_EXPIRED", "CARD_TOKEN_USED", "AMOUNT_TOO_HIGH", "UNSUPPORTED_INSTRUMENT_TYPE", "REFUND_AMOUNT_INVALID", "REFUND_ALREADY_PENDING", "PAYMENT_NOT_REFUNDABLE", "INVALID_CARD_DATA", "IDEMPOTENCY_KEY_REUSED", "CARD_DECLINED", "VERIFY_CVV_FAILURE", "VERIFY_AVS_FAILURE", "CARD_DECLINED_CALL_ISSUER", "NOT_FOUND", "REQUEST_TIMEOUT", "CONFLICT", "REQUEST_ENTITY_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "RATE_LIMITED", "NOT_IMPLEMENTED", "SERVICE_UNAVAILABLE"])
|
118
|
+
return false unless code_validator.valid?(@code)
|
119
|
+
return true
|
77
120
|
end
|
78
121
|
|
79
122
|
# Custom attribute writer method checking allowed values (enum).
|
123
|
+
# @param [Object] category Object to be assigned
|
80
124
|
def category=(category)
|
81
|
-
|
82
|
-
|
83
|
-
fail "invalid value for 'category', must be one of #{
|
125
|
+
validator = EnumAttributeValidator.new('String', ["API_ERROR", "AUTHENTICATION_ERROR", "INVALID_REQUEST_ERROR", "RATE_LIMIT_ERROR", "PAYMENT_METHOD_ERROR", "REFUND_ERROR"])
|
126
|
+
unless validator.valid?(category)
|
127
|
+
fail ArgumentError, "invalid value for 'category', must be one of #{validator.allowable_values}."
|
84
128
|
end
|
85
129
|
@category = category
|
86
130
|
end
|
87
131
|
|
88
132
|
# Custom attribute writer method checking allowed values (enum).
|
133
|
+
# @param [Object] code Object to be assigned
|
89
134
|
def code=(code)
|
90
|
-
|
91
|
-
|
92
|
-
fail "invalid value for 'code', must be one of #{
|
135
|
+
validator = EnumAttributeValidator.new('String', ["INTERNAL_SERVER_ERROR", "UNAUTHORIZED", "ACCESS_TOKEN_EXPIRED", "ACCESS_TOKEN_REVOKED", "FORBIDDEN", "INSUFFICIENT_SCOPES", "APPLICATION_DISABLED", "V1_APPLICATION", "V1_ACCESS_TOKEN", "CARD_PROCESSING_NOT_ENABLED", "BAD_REQUEST", "MISSING_REQUIRED_PARAMETER", "INCORRECT_TYPE", "INVALID_TIME", "INVALID_TIME_RANGE", "INVALID_VALUE", "INVALID_CURSOR", "UNKNOWN_QUERY_PARAMETER", "CONFLICTING_PARAMETERS", "EXPECTED_JSON_BODY", "INVALID_SORT_ORDER", "VALUE_REGEX_MISMATCH", "VALUE_TOO_SHORT", "VALUE_TOO_LONG", "VALUE_TOO_LOW", "VALUE_TOO_HIGH", "VALUE_EMPTY", "ARRAY_EMPTY", "EXPECTED_BOOLEAN", "EXPECTED_INTEGER", "EXPECTED_FLOAT", "EXPECTED_STRING", "EXPECTED_OBJECT", "EXPECTED_ARRAY", "EXPECTED_BASE64_ENCODED_BYTE_ARRAY", "INVALID_ARRAY_VALUE", "INVALID_ENUM_VALUE", "INVALID_CONTENT_TYPE", "INVALID_FORM_VALUE", "ONE_INSTRUMENT_EXPECTED", "NO_FIELDS_SET", "CARD_EXPIRED", "INVALID_EXPIRATION", "INVALID_EXPIRATION_YEAR", "INVALID_EXPIRATION_DATE", "UNSUPPORTED_CARD_BRAND", "INVALID_CARD", "DELAYED_TRANSACTION_EXPIRED", "DELAYED_TRANSACTION_CANCELED", "DELAYED_TRANSACTION_CAPTURED", "DELAYED_TRANSACTION_FAILED", "CARD_TOKEN_EXPIRED", "CARD_TOKEN_USED", "AMOUNT_TOO_HIGH", "UNSUPPORTED_INSTRUMENT_TYPE", "REFUND_AMOUNT_INVALID", "REFUND_ALREADY_PENDING", "PAYMENT_NOT_REFUNDABLE", "INVALID_CARD_DATA", "IDEMPOTENCY_KEY_REUSED", "CARD_DECLINED", "VERIFY_CVV_FAILURE", "VERIFY_AVS_FAILURE", "CARD_DECLINED_CALL_ISSUER", "NOT_FOUND", "REQUEST_TIMEOUT", "CONFLICT", "REQUEST_ENTITY_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "RATE_LIMITED", "NOT_IMPLEMENTED", "SERVICE_UNAVAILABLE"])
|
136
|
+
unless validator.valid?(code)
|
137
|
+
fail ArgumentError, "invalid value for 'code', must be one of #{validator.allowable_values}."
|
93
138
|
end
|
94
139
|
@code = code
|
95
140
|
end
|
96
141
|
|
97
|
-
#
|
142
|
+
# Checks equality by comparing each attribute.
|
143
|
+
# @param [Object] Object to be compared
|
98
144
|
def ==(o)
|
99
145
|
return true if self.equal?(o)
|
100
146
|
self.class == o.class &&
|
@@ -105,35 +151,41 @@ module SquareConnect
|
|
105
151
|
end
|
106
152
|
|
107
153
|
# @see the `==` method
|
154
|
+
# @param [Object] Object to be compared
|
108
155
|
def eql?(o)
|
109
156
|
self == o
|
110
157
|
end
|
111
158
|
|
112
|
-
#
|
159
|
+
# Calculates hash code according to all attributes.
|
160
|
+
# @return [Fixnum] Hash code
|
113
161
|
def hash
|
114
162
|
[category, code, detail, field].hash
|
115
163
|
end
|
116
164
|
|
117
|
-
#
|
165
|
+
# Builds the object from hash
|
166
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
167
|
+
# @return [Object] Returns the model itself
|
118
168
|
def build_from_hash(attributes)
|
119
169
|
return nil unless attributes.is_a?(Hash)
|
120
170
|
self.class.swagger_types.each_pair do |key, type|
|
121
|
-
if type =~
|
171
|
+
if type =~ /\AArray<(.*)>/i
|
172
|
+
# check to ensure the input is an array given that the the attribute
|
173
|
+
# is documented as an array but the input is not
|
122
174
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
123
175
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
124
|
-
else
|
125
|
-
#TODO show warning in debug mode
|
126
176
|
end
|
127
177
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
128
178
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
129
|
-
else
|
130
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
131
|
-
end
|
179
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
132
180
|
end
|
133
181
|
|
134
182
|
self
|
135
183
|
end
|
136
184
|
|
185
|
+
# Deserializes the data based on type
|
186
|
+
# @param string type Data type
|
187
|
+
# @param string value Value to be deserialized
|
188
|
+
# @return [Object] Deserialized data
|
137
189
|
def _deserialize(type, value)
|
138
190
|
case type.to_sym
|
139
191
|
when :DateTime
|
@@ -147,15 +199,18 @@ module SquareConnect
|
|
147
199
|
when :Float
|
148
200
|
value.to_f
|
149
201
|
when :BOOLEAN
|
150
|
-
if value.to_s =~
|
202
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
151
203
|
true
|
152
204
|
else
|
153
205
|
false
|
154
206
|
end
|
207
|
+
when :Object
|
208
|
+
# generic object (usually a Hash), return directly
|
209
|
+
value
|
155
210
|
when /\AArray<(?<inner_type>.+)>\z/
|
156
211
|
inner_type = Regexp.last_match[:inner_type]
|
157
212
|
value.map { |v| _deserialize(inner_type, v) }
|
158
|
-
when /\AHash<(?<k_type
|
213
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
159
214
|
k_type = Regexp.last_match[:k_type]
|
160
215
|
v_type = Regexp.last_match[:v_type]
|
161
216
|
{}.tap do |hash|
|
@@ -164,21 +219,25 @@ module SquareConnect
|
|
164
219
|
end
|
165
220
|
end
|
166
221
|
else # model
|
167
|
-
|
168
|
-
|
222
|
+
temp_model = SquareConnect.const_get(type).new
|
223
|
+
temp_model.build_from_hash(value)
|
169
224
|
end
|
170
225
|
end
|
171
226
|
|
227
|
+
# Returns the string representation of the object
|
228
|
+
# @return [String] String presentation of the object
|
172
229
|
def to_s
|
173
230
|
to_hash.to_s
|
174
231
|
end
|
175
232
|
|
176
|
-
# to_body is an alias to
|
233
|
+
# to_body is an alias to to_hash (backward compatibility)
|
234
|
+
# @return [Hash] Returns the object in the form of hash
|
177
235
|
def to_body
|
178
236
|
to_hash
|
179
237
|
end
|
180
238
|
|
181
|
-
#
|
239
|
+
# Returns the object in the form of hash
|
240
|
+
# @return [Hash] Returns the object in the form of hash
|
182
241
|
def to_hash
|
183
242
|
hash = {}
|
184
243
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -189,8 +248,10 @@ module SquareConnect
|
|
189
248
|
hash
|
190
249
|
end
|
191
250
|
|
192
|
-
#
|
251
|
+
# Outputs non-array value in the form of hash
|
193
252
|
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
194
255
|
def _to_hash(value)
|
195
256
|
if value.is_a?(Array)
|
196
257
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -206,4 +267,5 @@ module SquareConnect
|
|
206
267
|
end
|
207
268
|
|
208
269
|
end
|
270
|
+
|
209
271
|
end
|