zip_money 1.2.1
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 +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/README.md +128 -0
- data/Rakefile +8 -0
- data/docs/Address.md +15 -0
- data/docs/Authority.md +9 -0
- data/docs/CaptureChargeRequest.md +8 -0
- data/docs/Charge.md +17 -0
- data/docs/ChargeCollection.md +8 -0
- data/docs/ChargeOrder.md +11 -0
- data/docs/ChargesApi.md +307 -0
- data/docs/Checkout.md +18 -0
- data/docs/CheckoutConfiguration.md +8 -0
- data/docs/CheckoutFeatures.md +8 -0
- data/docs/CheckoutFeaturesTokenisation.md +8 -0
- data/docs/CheckoutOrder.md +13 -0
- data/docs/CheckoutsApi.md +119 -0
- data/docs/CreateChargeRequest.md +14 -0
- data/docs/CreateCheckoutRequest.md +13 -0
- data/docs/CreateCheckoutRequestFeatures.md +8 -0
- data/docs/CreateCheckoutRequestFeaturesTokenisation.md +8 -0
- data/docs/CreateRefundRequest.md +11 -0
- data/docs/CreateTokenRequest.md +8 -0
- data/docs/Customer.md +15 -0
- data/docs/CustomersApi.md +96 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/ErrorResponseError.md +10 -0
- data/docs/ErrorResponseErrorDetails.md +9 -0
- data/docs/InlineResponse200.md +8 -0
- data/docs/Metadata.md +7 -0
- data/docs/OrderItem.md +16 -0
- data/docs/OrderShipping.md +10 -0
- data/docs/OrderShippingTracking.md +10 -0
- data/docs/Refund.md +13 -0
- data/docs/RefundsApi.md +181 -0
- data/docs/SettlementsApi.md +96 -0
- data/docs/Shopper.md +17 -0
- data/docs/ShopperStatistics.md +16 -0
- data/docs/Token.md +11 -0
- data/docs/TokensApi.md +66 -0
- data/lib/zip_money.rb +68 -0
- data/lib/zip_money/api/charges_api.rb +301 -0
- data/lib/zip_money/api/checkouts_api.rb +120 -0
- data/lib/zip_money/api/customers_api.rb +116 -0
- data/lib/zip_money/api/refunds_api.rb +181 -0
- data/lib/zip_money/api/settlements_api.rb +116 -0
- data/lib/zip_money/api/tokens_api.rb +70 -0
- data/lib/zip_money/api_client.rb +386 -0
- data/lib/zip_money/api_error.rb +31 -0
- data/lib/zip_money/configuration.rb +238 -0
- data/lib/zip_money/models/address.rb +413 -0
- data/lib/zip_money/models/authority.rb +235 -0
- data/lib/zip_money/models/capture_charge_request.rb +206 -0
- data/lib/zip_money/models/charge.rb +369 -0
- data/lib/zip_money/models/charge_collection.rb +188 -0
- data/lib/zip_money/models/charge_order.rb +250 -0
- data/lib/zip_money/models/checkout.rb +344 -0
- data/lib/zip_money/models/checkout_configuration.rb +187 -0
- data/lib/zip_money/models/checkout_features.rb +181 -0
- data/lib/zip_money/models/checkout_features_tokenisation.rb +184 -0
- data/lib/zip_money/models/checkout_order.rb +299 -0
- data/lib/zip_money/models/create_charge_request.rb +289 -0
- data/lib/zip_money/models/create_checkout_request.rb +272 -0
- data/lib/zip_money/models/create_checkout_request_features.rb +181 -0
- data/lib/zip_money/models/create_checkout_request_features_tokenisation.rb +189 -0
- data/lib/zip_money/models/create_refund_request.rb +246 -0
- data/lib/zip_money/models/create_token_request.rb +186 -0
- data/lib/zip_money/models/customer.rb +310 -0
- data/lib/zip_money/models/error_response.rb +181 -0
- data/lib/zip_money/models/error_response_error.rb +211 -0
- data/lib/zip_money/models/error_response_error_details.rb +190 -0
- data/lib/zip_money/models/inline_response_200.rb +188 -0
- data/lib/zip_money/models/metadata.rb +172 -0
- data/lib/zip_money/models/order_item.rb +333 -0
- data/lib/zip_money/models/order_shipping.rb +200 -0
- data/lib/zip_money/models/order_shipping_tracking.rb +247 -0
- data/lib/zip_money/models/refund.rb +252 -0
- data/lib/zip_money/models/shopper.rb +339 -0
- data/lib/zip_money/models/shopper_statistics.rb +295 -0
- data/lib/zip_money/models/token.rb +228 -0
- data/lib/zip_money/version.rb +8 -0
- data/spec/api/charges_api_spec.rb +114 -0
- data/spec/api/checkouts_api_spec.rb +54 -0
- data/spec/api/customers_api_spec.rb +51 -0
- data/spec/api/refunds_api_spec.rb +67 -0
- data/spec/api/settlements_api_spec.rb +51 -0
- data/spec/api/tokens_api_spec.rb +41 -0
- data/spec/api_client_spec.rb +219 -0
- data/spec/configuration_spec.rb +50 -0
- data/spec/models/address_spec.rb +77 -0
- data/spec/models/authority_spec.rb +45 -0
- data/spec/models/capture_charge_request_spec.rb +35 -0
- data/spec/models/charge_collection_spec.rb +35 -0
- data/spec/models/charge_order_spec.rb +53 -0
- data/spec/models/charge_spec.rb +93 -0
- data/spec/models/checkout_configuration_spec.rb +35 -0
- data/spec/models/checkout_features_spec.rb +35 -0
- data/spec/models/checkout_features_tokenisation_spec.rb +35 -0
- data/spec/models/checkout_order_spec.rb +65 -0
- data/spec/models/checkout_spec.rb +103 -0
- data/spec/models/create_charge_request_spec.rb +75 -0
- data/spec/models/create_checkout_request_features_spec.rb +35 -0
- data/spec/models/create_checkout_request_features_tokenisation_spec.rb +35 -0
- data/spec/models/create_checkout_request_spec.rb +69 -0
- data/spec/models/create_refund_request_spec.rb +53 -0
- data/spec/models/create_token_request_spec.rb +35 -0
- data/spec/models/customer_spec.rb +81 -0
- data/spec/models/error_response_error_details_spec.rb +41 -0
- data/spec/models/error_response_error_spec.rb +47 -0
- data/spec/models/error_response_spec.rb +35 -0
- data/spec/models/inline_response_200_spec.rb +35 -0
- data/spec/models/metadata_spec.rb +29 -0
- data/spec/models/order_item_spec.rb +87 -0
- data/spec/models/order_shipping_spec.rb +47 -0
- data/spec/models/order_shipping_tracking_spec.rb +47 -0
- data/spec/models/refund_spec.rb +65 -0
- data/spec/models/shopper_spec.rb +92 -0
- data/spec/models/shopper_statistics_spec.rb +86 -0
- data/spec/models/token_spec.rb +52 -0
- data/spec/payload_helper.rb +96 -0
- data/spec/spec_helper.rb +104 -0
- data/zip_money.gemspec +38 -0
- metadata +380 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
|
|
8
|
+
module ZipMoney
|
|
9
|
+
|
|
10
|
+
class ChargeCollection
|
|
11
|
+
attr_accessor :items
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
15
|
+
def self.attribute_map
|
|
16
|
+
{
|
|
17
|
+
:'items' => :'items'
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Attribute type mapping.
|
|
22
|
+
def self.zip_types
|
|
23
|
+
{
|
|
24
|
+
:'items' => :'Array<Charge>'
|
|
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
|
+
if attributes.has_key?(:'items')
|
|
37
|
+
if (value = attributes[:'items']).is_a?(Array)
|
|
38
|
+
self.items = value
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
45
|
+
# @return Array for valid properies with the reasons
|
|
46
|
+
def list_invalid_properties
|
|
47
|
+
invalid_properties = Array.new
|
|
48
|
+
if @items.nil?
|
|
49
|
+
invalid_properties.push("invalid value for 'items', items cannot be nil.")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
return invalid_properties
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Check to see if the all the properties in the model are valid
|
|
56
|
+
# @return true if the model is valid
|
|
57
|
+
def valid?
|
|
58
|
+
return false if @items.nil?
|
|
59
|
+
return true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Checks equality by comparing each attribute.
|
|
63
|
+
# @param [Object] Object to be compared
|
|
64
|
+
def ==(o)
|
|
65
|
+
return true if self.equal?(o)
|
|
66
|
+
self.class == o.class &&
|
|
67
|
+
items == o.items
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @see the `==` method
|
|
71
|
+
# @param [Object] Object to be compared
|
|
72
|
+
def eql?(o)
|
|
73
|
+
self == o
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Calculates hash code according to all attributes.
|
|
77
|
+
# @return [Fixnum] Hash code
|
|
78
|
+
def hash
|
|
79
|
+
[items].hash
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Builds the object from hash
|
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
84
|
+
# @return [Object] Returns the model itself
|
|
85
|
+
def build_from_hash(attributes)
|
|
86
|
+
return nil unless attributes.is_a?(Hash)
|
|
87
|
+
self.class.zip_types.each_pair do |key, 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
|
|
91
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
92
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
93
|
+
end
|
|
94
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
95
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
96
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
self
|
|
100
|
+
end
|
|
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
|
|
106
|
+
def _deserialize(type, value)
|
|
107
|
+
case type.to_sym
|
|
108
|
+
when :DateTime
|
|
109
|
+
DateTime.parse(value)
|
|
110
|
+
when :Date
|
|
111
|
+
Date.parse(value)
|
|
112
|
+
when :String
|
|
113
|
+
value.to_s
|
|
114
|
+
when :Integer
|
|
115
|
+
value.to_i
|
|
116
|
+
when :Float
|
|
117
|
+
value.to_f
|
|
118
|
+
when :BOOLEAN
|
|
119
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
120
|
+
true
|
|
121
|
+
else
|
|
122
|
+
false
|
|
123
|
+
end
|
|
124
|
+
when :Object
|
|
125
|
+
# generic object (usually a Hash), return directly
|
|
126
|
+
value
|
|
127
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
128
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
129
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
130
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
131
|
+
k_type = Regexp.last_match[:k_type]
|
|
132
|
+
v_type = Regexp.last_match[:v_type]
|
|
133
|
+
{}.tap do |hash|
|
|
134
|
+
value.each do |k, v|
|
|
135
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
else # model
|
|
139
|
+
temp_model = ZipMoney.const_get(type).new
|
|
140
|
+
temp_model.build_from_hash(value)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Returns the string representation of the object
|
|
145
|
+
# @return [String] String presentation of the object
|
|
146
|
+
def to_s
|
|
147
|
+
to_hash.to_s
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
151
|
+
# @return [Hash] Returns the object in the form of hash
|
|
152
|
+
def to_body
|
|
153
|
+
to_hash
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Returns the object in the form of hash
|
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
|
158
|
+
def to_hash
|
|
159
|
+
hash = {}
|
|
160
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
161
|
+
value = self.send(attr)
|
|
162
|
+
next if value.nil?
|
|
163
|
+
hash[param] = _to_hash(value)
|
|
164
|
+
end
|
|
165
|
+
hash
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Outputs non-array value in the form of hash
|
|
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
|
|
172
|
+
def _to_hash(value)
|
|
173
|
+
if value.is_a?(Array)
|
|
174
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
175
|
+
elsif value.is_a?(Hash)
|
|
176
|
+
{}.tap do |hash|
|
|
177
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
178
|
+
end
|
|
179
|
+
elsif value.respond_to? :to_hash
|
|
180
|
+
value.to_hash
|
|
181
|
+
else
|
|
182
|
+
value
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
|
|
8
|
+
module ZipMoney
|
|
9
|
+
|
|
10
|
+
class ChargeOrder
|
|
11
|
+
# The order id in the eCommerce system
|
|
12
|
+
attr_accessor :reference
|
|
13
|
+
|
|
14
|
+
attr_accessor :shipping
|
|
15
|
+
|
|
16
|
+
# The order item breakdown
|
|
17
|
+
attr_accessor :items
|
|
18
|
+
|
|
19
|
+
# The shopping cart reference id
|
|
20
|
+
attr_accessor :cart_reference
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
24
|
+
def self.attribute_map
|
|
25
|
+
{
|
|
26
|
+
:'reference' => :'reference',
|
|
27
|
+
:'shipping' => :'shipping',
|
|
28
|
+
:'items' => :'items',
|
|
29
|
+
:'cart_reference' => :'cart_reference'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Attribute type mapping.
|
|
34
|
+
def self.zip_types
|
|
35
|
+
{
|
|
36
|
+
:'reference' => :'String',
|
|
37
|
+
:'shipping' => :'OrderShipping',
|
|
38
|
+
:'items' => :'Array<OrderItem>',
|
|
39
|
+
:'cart_reference' => :'String'
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Initializes the object
|
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
45
|
+
def initialize(attributes = {})
|
|
46
|
+
return unless attributes.is_a?(Hash)
|
|
47
|
+
|
|
48
|
+
# convert string to symbol for hash key
|
|
49
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
|
50
|
+
|
|
51
|
+
if attributes.has_key?(:'reference')
|
|
52
|
+
self.reference = attributes[:'reference']
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if attributes.has_key?(:'shipping')
|
|
56
|
+
self.shipping = attributes[:'shipping']
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
if attributes.has_key?(:'items')
|
|
60
|
+
if (value = attributes[:'items']).is_a?(Array)
|
|
61
|
+
self.items = value
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if attributes.has_key?(:'cart_reference')
|
|
66
|
+
self.cart_reference = attributes[:'cart_reference']
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
72
|
+
# @return Array for valid properies with the reasons
|
|
73
|
+
def list_invalid_properties
|
|
74
|
+
invalid_properties = Array.new
|
|
75
|
+
if !@reference.nil? && @reference.to_s.length > 50
|
|
76
|
+
invalid_properties.push("invalid value for 'reference', the character length must be smaller than or equal to 50.")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
if @shipping.nil?
|
|
80
|
+
invalid_properties.push("invalid value for 'shipping', shipping cannot be nil.")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
if !@cart_reference.nil? && @cart_reference.to_s.length > 100
|
|
84
|
+
invalid_properties.push("invalid value for 'cart_reference', the character length must be smaller than or equal to 100.")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
return invalid_properties
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Check to see if the all the properties in the model are valid
|
|
91
|
+
# @return true if the model is valid
|
|
92
|
+
def valid?
|
|
93
|
+
return false if !@reference.nil? && @reference.to_s.length > 50
|
|
94
|
+
return false if @shipping.nil?
|
|
95
|
+
return false if !@cart_reference.nil? && @cart_reference.to_s.length > 100
|
|
96
|
+
return true
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Custom attribute writer method with validation
|
|
100
|
+
# @param [Object] reference Value to be assigned
|
|
101
|
+
def reference=(reference)
|
|
102
|
+
|
|
103
|
+
if !reference.nil? && reference.to_s.length > 50
|
|
104
|
+
fail ArgumentError, "invalid value for 'reference', the character length must be smaller than or equal to 50."
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
@reference = reference
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Custom attribute writer method with validation
|
|
111
|
+
# @param [Object] cart_reference Value to be assigned
|
|
112
|
+
def cart_reference=(cart_reference)
|
|
113
|
+
|
|
114
|
+
if !cart_reference.nil? && cart_reference.to_s.length > 100
|
|
115
|
+
fail ArgumentError, "invalid value for 'cart_reference', the character length must be smaller than or equal to 100."
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
@cart_reference = cart_reference
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Checks equality by comparing each attribute.
|
|
122
|
+
# @param [Object] Object to be compared
|
|
123
|
+
def ==(o)
|
|
124
|
+
return true if self.equal?(o)
|
|
125
|
+
self.class == o.class &&
|
|
126
|
+
reference == o.reference &&
|
|
127
|
+
shipping == o.shipping &&
|
|
128
|
+
items == o.items &&
|
|
129
|
+
cart_reference == o.cart_reference
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# @see the `==` method
|
|
133
|
+
# @param [Object] Object to be compared
|
|
134
|
+
def eql?(o)
|
|
135
|
+
self == o
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Calculates hash code according to all attributes.
|
|
139
|
+
# @return [Fixnum] Hash code
|
|
140
|
+
def hash
|
|
141
|
+
[reference, shipping, items, cart_reference].hash
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Builds the object from hash
|
|
145
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
146
|
+
# @return [Object] Returns the model itself
|
|
147
|
+
def build_from_hash(attributes)
|
|
148
|
+
return nil unless attributes.is_a?(Hash)
|
|
149
|
+
self.class.zip_types.each_pair do |key, type|
|
|
150
|
+
if type =~ /\AArray<(.*)>/i
|
|
151
|
+
# check to ensure the input is an array given that the the attribute
|
|
152
|
+
# is documented as an array but the input is not
|
|
153
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
154
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
155
|
+
end
|
|
156
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
157
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
158
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
self
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Deserializes the data based on type
|
|
165
|
+
# @param string type Data type
|
|
166
|
+
# @param string value Value to be deserialized
|
|
167
|
+
# @return [Object] Deserialized data
|
|
168
|
+
def _deserialize(type, value)
|
|
169
|
+
case type.to_sym
|
|
170
|
+
when :DateTime
|
|
171
|
+
DateTime.parse(value)
|
|
172
|
+
when :Date
|
|
173
|
+
Date.parse(value)
|
|
174
|
+
when :String
|
|
175
|
+
value.to_s
|
|
176
|
+
when :Integer
|
|
177
|
+
value.to_i
|
|
178
|
+
when :Float
|
|
179
|
+
value.to_f
|
|
180
|
+
when :BOOLEAN
|
|
181
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
182
|
+
true
|
|
183
|
+
else
|
|
184
|
+
false
|
|
185
|
+
end
|
|
186
|
+
when :Object
|
|
187
|
+
# generic object (usually a Hash), return directly
|
|
188
|
+
value
|
|
189
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
190
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
191
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
192
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
193
|
+
k_type = Regexp.last_match[:k_type]
|
|
194
|
+
v_type = Regexp.last_match[:v_type]
|
|
195
|
+
{}.tap do |hash|
|
|
196
|
+
value.each do |k, v|
|
|
197
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
else # model
|
|
201
|
+
temp_model = ZipMoney.const_get(type).new
|
|
202
|
+
temp_model.build_from_hash(value)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Returns the string representation of the object
|
|
207
|
+
# @return [String] String presentation of the object
|
|
208
|
+
def to_s
|
|
209
|
+
to_hash.to_s
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
|
214
|
+
def to_body
|
|
215
|
+
to_hash
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Returns the object in the form of hash
|
|
219
|
+
# @return [Hash] Returns the object in the form of hash
|
|
220
|
+
def to_hash
|
|
221
|
+
hash = {}
|
|
222
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
223
|
+
value = self.send(attr)
|
|
224
|
+
next if value.nil?
|
|
225
|
+
hash[param] = _to_hash(value)
|
|
226
|
+
end
|
|
227
|
+
hash
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Outputs non-array value in the form of hash
|
|
231
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
232
|
+
# @param [Object] value Any valid value
|
|
233
|
+
# @return [Hash] Returns the value in the form of hash
|
|
234
|
+
def _to_hash(value)
|
|
235
|
+
if value.is_a?(Array)
|
|
236
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
237
|
+
elsif value.is_a?(Hash)
|
|
238
|
+
{}.tap do |hash|
|
|
239
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
240
|
+
end
|
|
241
|
+
elsif value.respond_to? :to_hash
|
|
242
|
+
value.to_hash
|
|
243
|
+
else
|
|
244
|
+
value
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
end
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
|
|
8
|
+
module ZipMoney
|
|
9
|
+
# The checkout request
|
|
10
|
+
class Checkout
|
|
11
|
+
# The checkout id
|
|
12
|
+
attr_accessor :id
|
|
13
|
+
|
|
14
|
+
# The uri to redirect the user to in order to approve this checkout.
|
|
15
|
+
attr_accessor :uri
|
|
16
|
+
|
|
17
|
+
# The type of checkout
|
|
18
|
+
attr_accessor :type
|
|
19
|
+
|
|
20
|
+
attr_accessor :shopper
|
|
21
|
+
|
|
22
|
+
attr_accessor :order
|
|
23
|
+
|
|
24
|
+
attr_accessor :features
|
|
25
|
+
|
|
26
|
+
attr_accessor :config
|
|
27
|
+
|
|
28
|
+
# Date the checkout was created
|
|
29
|
+
attr_accessor :created
|
|
30
|
+
|
|
31
|
+
# Current state of the checkout
|
|
32
|
+
attr_accessor :state
|
|
33
|
+
|
|
34
|
+
# The id of the customer who has approved this checkout request. Only present if approved.
|
|
35
|
+
attr_accessor :customer_id
|
|
36
|
+
|
|
37
|
+
attr_accessor :metadata
|
|
38
|
+
|
|
39
|
+
class EnumAttributeValidator
|
|
40
|
+
attr_reader :datatype
|
|
41
|
+
attr_reader :allowable_values
|
|
42
|
+
|
|
43
|
+
def initialize(datatype, allowable_values)
|
|
44
|
+
@allowable_values = allowable_values.map do |value|
|
|
45
|
+
case datatype.to_s
|
|
46
|
+
when /Integer/i
|
|
47
|
+
value.to_i
|
|
48
|
+
when /Float/i
|
|
49
|
+
value.to_f
|
|
50
|
+
else
|
|
51
|
+
value
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def valid?(value)
|
|
57
|
+
!value || allowable_values.include?(value)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
62
|
+
def self.attribute_map
|
|
63
|
+
{
|
|
64
|
+
:'id' => :'id',
|
|
65
|
+
:'uri' => :'uri',
|
|
66
|
+
:'type' => :'type',
|
|
67
|
+
:'shopper' => :'shopper',
|
|
68
|
+
:'order' => :'order',
|
|
69
|
+
:'features' => :'features',
|
|
70
|
+
:'config' => :'config',
|
|
71
|
+
:'created' => :'created',
|
|
72
|
+
:'state' => :'state',
|
|
73
|
+
:'customer_id' => :'customer_id',
|
|
74
|
+
:'metadata' => :'metadata'
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Attribute type mapping.
|
|
79
|
+
def self.zip_types
|
|
80
|
+
{
|
|
81
|
+
:'id' => :'String',
|
|
82
|
+
:'uri' => :'String',
|
|
83
|
+
:'type' => :'String',
|
|
84
|
+
:'shopper' => :'Shopper',
|
|
85
|
+
:'order' => :'CheckoutOrder',
|
|
86
|
+
:'features' => :'CheckoutFeatures',
|
|
87
|
+
:'config' => :'CheckoutConfiguration',
|
|
88
|
+
:'created' => :'DateTime',
|
|
89
|
+
:'state' => :'String',
|
|
90
|
+
:'customer_id' => :'String',
|
|
91
|
+
:'metadata' => :'Metadata'
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Initializes the object
|
|
96
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
97
|
+
def initialize(attributes = {})
|
|
98
|
+
return unless attributes.is_a?(Hash)
|
|
99
|
+
|
|
100
|
+
# convert string to symbol for hash key
|
|
101
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
|
102
|
+
|
|
103
|
+
if attributes.has_key?(:'id')
|
|
104
|
+
self.id = attributes[:'id']
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if attributes.has_key?(:'uri')
|
|
108
|
+
self.uri = attributes[:'uri']
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if attributes.has_key?(:'type')
|
|
112
|
+
self.type = attributes[:'type']
|
|
113
|
+
else
|
|
114
|
+
self.type = "standard"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if attributes.has_key?(:'shopper')
|
|
118
|
+
self.shopper = attributes[:'shopper']
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.has_key?(:'order')
|
|
122
|
+
self.order = attributes[:'order']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if attributes.has_key?(:'features')
|
|
126
|
+
self.features = attributes[:'features']
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
if attributes.has_key?(:'config')
|
|
130
|
+
self.config = attributes[:'config']
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
if attributes.has_key?(:'created')
|
|
134
|
+
self.created = attributes[:'created']
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if attributes.has_key?(:'state')
|
|
138
|
+
self.state = attributes[:'state']
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
if attributes.has_key?(:'customer_id')
|
|
142
|
+
self.customer_id = attributes[:'customer_id']
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
if attributes.has_key?(:'metadata')
|
|
146
|
+
self.metadata = attributes[:'metadata']
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
152
|
+
# @return Array for valid properies with the reasons
|
|
153
|
+
def list_invalid_properties
|
|
154
|
+
invalid_properties = Array.new
|
|
155
|
+
if @id.nil?
|
|
156
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
if @uri.nil?
|
|
160
|
+
invalid_properties.push("invalid value for 'uri', uri cannot be nil.")
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
if @created.nil?
|
|
164
|
+
invalid_properties.push("invalid value for 'created', created cannot be nil.")
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if @state.nil?
|
|
168
|
+
invalid_properties.push("invalid value for 'state', state cannot be nil.")
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
return invalid_properties
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Check to see if the all the properties in the model are valid
|
|
175
|
+
# @return true if the model is valid
|
|
176
|
+
def valid?
|
|
177
|
+
return false if @id.nil?
|
|
178
|
+
return false if @uri.nil?
|
|
179
|
+
type_validator = EnumAttributeValidator.new('String', ["standard", "express"])
|
|
180
|
+
return false unless type_validator.valid?(@type)
|
|
181
|
+
return false if @created.nil?
|
|
182
|
+
return false if @state.nil?
|
|
183
|
+
state_validator = EnumAttributeValidator.new('String', ["created", "expired", "approved", "completed"])
|
|
184
|
+
return false unless state_validator.valid?(@state)
|
|
185
|
+
return true
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
189
|
+
# @param [Object] type Object to be assigned
|
|
190
|
+
def type=(type)
|
|
191
|
+
validator = EnumAttributeValidator.new('String', ["standard", "express"])
|
|
192
|
+
unless validator.valid?(type)
|
|
193
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
|
194
|
+
end
|
|
195
|
+
@type = type
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
199
|
+
# @param [Object] state Object to be assigned
|
|
200
|
+
def state=(state)
|
|
201
|
+
validator = EnumAttributeValidator.new('String', ["created", "expired", "approved", "completed"])
|
|
202
|
+
unless validator.valid?(state)
|
|
203
|
+
fail ArgumentError, "invalid value for 'state', must be one of #{validator.allowable_values}."
|
|
204
|
+
end
|
|
205
|
+
@state = state
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Checks equality by comparing each attribute.
|
|
209
|
+
# @param [Object] Object to be compared
|
|
210
|
+
def ==(o)
|
|
211
|
+
return true if self.equal?(o)
|
|
212
|
+
self.class == o.class &&
|
|
213
|
+
id == o.id &&
|
|
214
|
+
uri == o.uri &&
|
|
215
|
+
type == o.type &&
|
|
216
|
+
shopper == o.shopper &&
|
|
217
|
+
order == o.order &&
|
|
218
|
+
features == o.features &&
|
|
219
|
+
config == o.config &&
|
|
220
|
+
created == o.created &&
|
|
221
|
+
state == o.state &&
|
|
222
|
+
customer_id == o.customer_id &&
|
|
223
|
+
metadata == o.metadata
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# @see the `==` method
|
|
227
|
+
# @param [Object] Object to be compared
|
|
228
|
+
def eql?(o)
|
|
229
|
+
self == o
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Calculates hash code according to all attributes.
|
|
233
|
+
# @return [Fixnum] Hash code
|
|
234
|
+
def hash
|
|
235
|
+
[id, uri, type, shopper, order, features, config, created, state, customer_id, metadata].hash
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Builds the object from hash
|
|
239
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
240
|
+
# @return [Object] Returns the model itself
|
|
241
|
+
def build_from_hash(attributes)
|
|
242
|
+
return nil unless attributes.is_a?(Hash)
|
|
243
|
+
self.class.zip_types.each_pair do |key, type|
|
|
244
|
+
if type =~ /\AArray<(.*)>/i
|
|
245
|
+
# check to ensure the input is an array given that the the attribute
|
|
246
|
+
# is documented as an array but the input is not
|
|
247
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
248
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
249
|
+
end
|
|
250
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
251
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
252
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
self
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Deserializes the data based on type
|
|
259
|
+
# @param string type Data type
|
|
260
|
+
# @param string value Value to be deserialized
|
|
261
|
+
# @return [Object] Deserialized data
|
|
262
|
+
def _deserialize(type, value)
|
|
263
|
+
case type.to_sym
|
|
264
|
+
when :DateTime
|
|
265
|
+
DateTime.parse(value)
|
|
266
|
+
when :Date
|
|
267
|
+
Date.parse(value)
|
|
268
|
+
when :String
|
|
269
|
+
value.to_s
|
|
270
|
+
when :Integer
|
|
271
|
+
value.to_i
|
|
272
|
+
when :Float
|
|
273
|
+
value.to_f
|
|
274
|
+
when :BOOLEAN
|
|
275
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
276
|
+
true
|
|
277
|
+
else
|
|
278
|
+
false
|
|
279
|
+
end
|
|
280
|
+
when :Object
|
|
281
|
+
# generic object (usually a Hash), return directly
|
|
282
|
+
value
|
|
283
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
284
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
285
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
286
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
287
|
+
k_type = Regexp.last_match[:k_type]
|
|
288
|
+
v_type = Regexp.last_match[:v_type]
|
|
289
|
+
{}.tap do |hash|
|
|
290
|
+
value.each do |k, v|
|
|
291
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
else # model
|
|
295
|
+
temp_model = ZipMoney.const_get(type).new
|
|
296
|
+
temp_model.build_from_hash(value)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# Returns the string representation of the object
|
|
301
|
+
# @return [String] String presentation of the object
|
|
302
|
+
def to_s
|
|
303
|
+
to_hash.to_s
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
307
|
+
# @return [Hash] Returns the object in the form of hash
|
|
308
|
+
def to_body
|
|
309
|
+
to_hash
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# Returns the object in the form of hash
|
|
313
|
+
# @return [Hash] Returns the object in the form of hash
|
|
314
|
+
def to_hash
|
|
315
|
+
hash = {}
|
|
316
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
317
|
+
value = self.send(attr)
|
|
318
|
+
next if value.nil?
|
|
319
|
+
hash[param] = _to_hash(value)
|
|
320
|
+
end
|
|
321
|
+
hash
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Outputs non-array value in the form of hash
|
|
325
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
326
|
+
# @param [Object] value Any valid value
|
|
327
|
+
# @return [Hash] Returns the value in the form of hash
|
|
328
|
+
def _to_hash(value)
|
|
329
|
+
if value.is_a?(Array)
|
|
330
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
331
|
+
elsif value.is_a?(Hash)
|
|
332
|
+
{}.tap do |hash|
|
|
333
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
334
|
+
end
|
|
335
|
+
elsif value.respond_to? :to_hash
|
|
336
|
+
value.to_hash
|
|
337
|
+
else
|
|
338
|
+
value
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
end
|