pp-adaptive 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +54 -0
- data/Rakefile +8 -0
- data/lib/pp-adaptive/abstract_request.rb +44 -0
- data/lib/pp-adaptive/abstract_response.rb +46 -0
- data/lib/pp-adaptive/cancel_preapproval_request.rb +7 -0
- data/lib/pp-adaptive/cancel_preapproval_response.rb +7 -0
- data/lib/pp-adaptive/client.rb +56 -0
- data/lib/pp-adaptive/convert_currency_request.rb +33 -0
- data/lib/pp-adaptive/convert_currency_response.rb +11 -0
- data/lib/pp-adaptive/execute_payment_request.rb +9 -0
- data/lib/pp-adaptive/execute_payment_response.rb +12 -0
- data/lib/pp-adaptive/get_payment_options_request.rb +7 -0
- data/lib/pp-adaptive/get_payment_options_response.rb +32 -0
- data/lib/pp-adaptive/pay_request.rb +64 -0
- data/lib/pp-adaptive/pay_response.rb +29 -0
- data/lib/pp-adaptive/payment_details_request.rb +9 -0
- data/lib/pp-adaptive/payment_details_response.rb +53 -0
- data/lib/pp-adaptive/preapproval_details_request.rb +8 -0
- data/lib/pp-adaptive/preapproval_details_response.rb +35 -0
- data/lib/pp-adaptive/preapproval_request.rb +36 -0
- data/lib/pp-adaptive/preapproval_response.rb +7 -0
- data/lib/pp-adaptive/refund_request.rb +14 -0
- data/lib/pp-adaptive/refund_response.rb +12 -0
- data/lib/pp-adaptive/set_payment_options_request.rb +33 -0
- data/lib/pp-adaptive/set_payment_options_response.rb +7 -0
- data/lib/pp-adaptive/support/aliases.rb +33 -0
- data/lib/pp-adaptive/support/coerced_array.rb +52 -0
- data/lib/pp-adaptive/support/json_model.rb +140 -0
- data/lib/pp-adaptive/support/node.rb +45 -0
- data/lib/pp-adaptive/support/node_list.rb +45 -0
- data/lib/pp-adaptive/types/account_identifier.rb +6 -0
- data/lib/pp-adaptive/types/address.rb +17 -0
- data/lib/pp-adaptive/types/address_list.rb +5 -0
- data/lib/pp-adaptive/types/aliases/receiver_aliases.rb +15 -0
- data/lib/pp-adaptive/types/aliases/receiver_list_aliases.rb +32 -0
- data/lib/pp-adaptive/types/base_address.rb +11 -0
- data/lib/pp-adaptive/types/client_details_type.rb +12 -0
- data/lib/pp-adaptive/types/currency_code.rb +5 -0
- data/lib/pp-adaptive/types/currency_conversion.rb +17 -0
- data/lib/pp-adaptive/types/currency_conversion_list.rb +15 -0
- data/lib/pp-adaptive/types/currency_conversion_table.rb +5 -0
- data/lib/pp-adaptive/types/currency_list.rb +5 -0
- data/lib/pp-adaptive/types/currency_type.rb +6 -0
- data/lib/pp-adaptive/types/display_options.rb +8 -0
- data/lib/pp-adaptive/types/error_data.rb +11 -0
- data/lib/pp-adaptive/types/error_list.rb +5 -0
- data/lib/pp-adaptive/types/fault_message.rb +23 -0
- data/lib/pp-adaptive/types/funding_constraint.rb +5 -0
- data/lib/pp-adaptive/types/funding_plan.rb +28 -0
- data/lib/pp-adaptive/types/funding_plan_charge.rb +11 -0
- data/lib/pp-adaptive/types/funding_source.rb +9 -0
- data/lib/pp-adaptive/types/funding_type_info.rb +5 -0
- data/lib/pp-adaptive/types/funding_type_list.rb +5 -0
- data/lib/pp-adaptive/types/initiating_entity.rb +15 -0
- data/lib/pp-adaptive/types/institution_customer.rb +11 -0
- data/lib/pp-adaptive/types/invoice_data.rb +7 -0
- data/lib/pp-adaptive/types/invoice_item.rb +9 -0
- data/lib/pp-adaptive/types/pay_error.rb +18 -0
- data/lib/pp-adaptive/types/pay_error_list.rb +5 -0
- data/lib/pp-adaptive/types/payment_info.rb +16 -0
- data/lib/pp-adaptive/types/payment_info_list.rb +5 -0
- data/lib/pp-adaptive/types/phone_number_type.rb +7 -0
- data/lib/pp-adaptive/types/receiver.rb +17 -0
- data/lib/pp-adaptive/types/receiver_identifier.rb +12 -0
- data/lib/pp-adaptive/types/receiver_list.rb +5 -0
- data/lib/pp-adaptive/types/receiver_options.rb +21 -0
- data/lib/pp-adaptive/types/refund_info.rb +20 -0
- data/lib/pp-adaptive/types/refund_info_list.rb +5 -0
- data/lib/pp-adaptive/types/request_envelope.rb +6 -0
- data/lib/pp-adaptive/types/response_envelope.rb +13 -0
- data/lib/pp-adaptive/types/sender_identifier.rb +5 -0
- data/lib/pp-adaptive/types/sender_options.rb +5 -0
- data/lib/pp-adaptive/version.rb +3 -0
- data/lib/pp-adaptive.rb +75 -0
- data/pp-adaptive.gemspec +25 -0
- data/spec/public/cancel_preapproval_request_spec.rb +15 -0
- data/spec/public/cancel_preapproval_response_spec.rb +6 -0
- data/spec/public/client_spec.rb +85 -0
- data/spec/public/convert_currency_request_spec.rb +29 -0
- data/spec/public/convert_currency_response_spec.rb +62 -0
- data/spec/public/execute_payment_request_spec.rb +30 -0
- data/spec/public/execute_payment_response_spec.rb +66 -0
- data/spec/public/get_payment_options_request_spec.rb +15 -0
- data/spec/public/get_payment_options_response_spec.rb +141 -0
- data/spec/public/json_model_spec.rb +56 -0
- data/spec/public/node_list_spec.rb +58 -0
- data/spec/public/node_spec.rb +54 -0
- data/spec/public/pay_request_spec.rb +150 -0
- data/spec/public/pay_response_spec.rb +197 -0
- data/spec/public/payment_details_request_spec.rb +30 -0
- data/spec/public/payment_details_response_spec.rb +211 -0
- data/spec/public/preapproval_details_request_spec.rb +25 -0
- data/spec/public/preapproval_details_response_spec.rb +200 -0
- data/spec/public/preapproval_request_spec.rb +110 -0
- data/spec/public/preapproval_response_spec.rb +14 -0
- data/spec/public/refund_request_spec.rb +57 -0
- data/spec/public/refund_response_spec.rb +116 -0
- data/spec/public/set_payment_options_request_spec.rb +136 -0
- data/spec/public/set_payment_options_response_spec.rb +6 -0
- data/spec/shared/a_fault_message.rb +60 -0
- data/spec/shared/a_request_envelope.rb +14 -0
- data/spec/shared/a_response_envelope.rb +36 -0
- data/spec/spec_helper.rb +6 -0
- metadata +225 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class SetPaymentOptionsRequest < AbstractRequest
|
3
|
+
operation :SetPaymentOptions
|
4
|
+
|
5
|
+
attribute :pay_key, String, :param => "payKey"
|
6
|
+
attribute :initiating_entity, Node[InitiatingEntity], :param => "initiatingEntity"
|
7
|
+
attribute :display_options, Node[DisplayOptions], :param => "displayOptions"
|
8
|
+
attribute :shipping_address_id, String, :param => "shippingAddressId"
|
9
|
+
attribute :sender_options, Node[SenderOptions], :param => "senderOptions"
|
10
|
+
attribute :receiver_options, NodeList[ReceiverOptions], :param => "receiverOptions"
|
11
|
+
|
12
|
+
alias_params :initiating_entity, {
|
13
|
+
:institution_id => :institution_id,
|
14
|
+
:customer_first_name => :customer_first_name,
|
15
|
+
:customer_last_name => :customer_last_name,
|
16
|
+
:customer_display_name => :customer_display_name,
|
17
|
+
:institution_customer_id => :institution_customer_id,
|
18
|
+
:customer_country_code => :customer_country_code,
|
19
|
+
:customer_email => :customer_email
|
20
|
+
}
|
21
|
+
|
22
|
+
alias_params :display_options, {
|
23
|
+
:email_header_image_url => :email_header_image_url,
|
24
|
+
:email_marketing_image_url => :email_marketing_image_url,
|
25
|
+
:header_image_url => :header_image_url,
|
26
|
+
:business_name => :business_name
|
27
|
+
}
|
28
|
+
|
29
|
+
alias_params :sender_options, {
|
30
|
+
:require_shipping_address_selection => :require_shipping_address_selection
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require "virtus"
|
3
|
+
|
4
|
+
module AdaptivePayments
|
5
|
+
# Provides an interface to create shortcuts to child nodes without traversing an object graph
|
6
|
+
module Aliases
|
7
|
+
include Forwardable
|
8
|
+
|
9
|
+
# Invoke alias_name as if original_name were invoked on attr
|
10
|
+
#
|
11
|
+
# @param [Symbol] attr
|
12
|
+
# the name of the attribute containing the child node
|
13
|
+
# @param [Symbol] alias_name
|
14
|
+
# the name of the alias method to define
|
15
|
+
# @param [Symbol] original_name
|
16
|
+
# the name of the original method in attr
|
17
|
+
def alias_param(attr, alias_name, original_name)
|
18
|
+
def_delegator attr, original_name, alias_name
|
19
|
+
def_delegator attr, :"#{original_name}=", :"#{alias_name}="
|
20
|
+
def_delegator attr, :"#{original_name}?", :"#{alias_name}?" # FIXME: Only alias this for Booleans
|
21
|
+
end
|
22
|
+
|
23
|
+
# Shortcut for definining multiple aliases in a single call
|
24
|
+
#
|
25
|
+
# @param [Symbol] attr
|
26
|
+
# the name of the attribute containing the child node
|
27
|
+
# @param [Hash] aliases
|
28
|
+
# a Hash mapping { :alias_name => :original_name }
|
29
|
+
def alias_params(attr, aliases)
|
30
|
+
aliases.each { |k, v| alias_param(attr, k, v) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
# Array that coerces all input values to a JsonModel of the given type
|
3
|
+
class CoercedArray < Array
|
4
|
+
# Initialize the CoercedArray for the given type
|
5
|
+
#
|
6
|
+
# @param [Class<JsonModel>] type
|
7
|
+
# the JsonModel descendant to coerce to
|
8
|
+
def initialize(type)
|
9
|
+
raise ArgumentError, "The type in a CoercedArray must be a JsonModel" unless type <= JsonModel
|
10
|
+
|
11
|
+
super()
|
12
|
+
@type = type
|
13
|
+
end
|
14
|
+
|
15
|
+
# Append the given value to the Array
|
16
|
+
# The value may be a Hash to coerce, or a valid JsonModel
|
17
|
+
#
|
18
|
+
# @param [Hash, JsonModel] object
|
19
|
+
# the object to append
|
20
|
+
#
|
21
|
+
# @return CoercedArray
|
22
|
+
def push(object)
|
23
|
+
object = @type.new(object) unless object.kind_of?(@type)
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method :<<, :push
|
28
|
+
|
29
|
+
# Concatenate another Array with this one and return the result as a new Array
|
30
|
+
# All items in other will be coerced to the correct type
|
31
|
+
#
|
32
|
+
# @param [Array] other
|
33
|
+
# another Array to concatenate with
|
34
|
+
#
|
35
|
+
# @return CoercedArray
|
36
|
+
def +(other)
|
37
|
+
raise ArgumentError, "Cannot union #{other.class} with #{self.class}<#{@type}>" unless other.kind_of?(Array)
|
38
|
+
super(CoercedArray.new(@type).concat(other))
|
39
|
+
end
|
40
|
+
|
41
|
+
# Concatenate another Array with this one and modify the Array in place
|
42
|
+
#
|
43
|
+
# @param [Array] other
|
44
|
+
# another Array to concatenate with
|
45
|
+
#
|
46
|
+
# @return CoercedArray
|
47
|
+
def concat(other)
|
48
|
+
raise ArgumentError, "Cannot append #{other.class} to #{self.class}<#{@type}>" unless other.kind_of?(Array)
|
49
|
+
super(other.inject(CoercedArray.new(@type)) { |ary, v| ary.push(v) })
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require "virtus"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module AdaptivePayments
|
5
|
+
# A client-side, nestable, model based on Virtus, mapping JSON parameters to method names and vice-versa
|
6
|
+
#
|
7
|
+
# All types defined in the Adaptive Payments API documentation (both request and response) are built from this class.
|
8
|
+
#
|
9
|
+
# class CurrencyConversion < JsonModel
|
10
|
+
# attribute :from, Node[CurrencyType]
|
11
|
+
# attribute :to, Node[CurrencyType]
|
12
|
+
# attribute :exchange_rate, Decimal, :param => "exchangeRate"
|
13
|
+
#
|
14
|
+
# alias_params :from, {
|
15
|
+
# :from_amount => :amount,
|
16
|
+
# :from_currency_code => :code
|
17
|
+
# }
|
18
|
+
#
|
19
|
+
# alias_params :to, {
|
20
|
+
# :to_amount => :amount,
|
21
|
+
# :to_currency_code => :code
|
22
|
+
# }
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# Virtus will allow varying input types and will cast them accordingly, so assigning '0.8767' to #exchange_rate in the
|
26
|
+
# above example will actually store BigDecimal('0.8767') in the model.
|
27
|
+
#
|
28
|
+
# The optional :param option defines the name of the property in the JSON representation, if it is different from the
|
29
|
+
# name of the attribute itself.
|
30
|
+
#
|
31
|
+
# In the above example, #alias_params has been used to create shortcuts to the #amount and #code attributes of the
|
32
|
+
# two [CurrencyType] attributes, #from and #to. So:
|
33
|
+
#
|
34
|
+
# conversion.from_amount == conversion.from.amount
|
35
|
+
# conversion.from_currency_code == conversion.from.code
|
36
|
+
#
|
37
|
+
# It's possible to repeatedly create aliases like this, by chaining them together through multiple levels of the object
|
38
|
+
# graph. The Adaptive Payments API is rather deeply nested and verbose by default, so to be a little easier to use and
|
39
|
+
# feel more ruby-esque, pp-adaptive define aliases where it seems logical to do so. The fully qualified paths will always
|
40
|
+
# work, however.
|
41
|
+
class JsonModel
|
42
|
+
include Virtus
|
43
|
+
extend Aliases
|
44
|
+
|
45
|
+
# Methods used for building a JsonModel given a JSON string.
|
46
|
+
module Parsing
|
47
|
+
# Process JSON input and return a JsonModel for the data.
|
48
|
+
#
|
49
|
+
# This method must be invoked on a subclass of the correct type. Invoking it on JsonModel itself will do nothing.
|
50
|
+
# All parameters in the JSON are recursively mapped to their attribute names, based on :param on the attribute.
|
51
|
+
# Unknown parameters are ignored.
|
52
|
+
#
|
53
|
+
# @param [String] json
|
54
|
+
# the raw JSON string as returned by the API
|
55
|
+
#
|
56
|
+
# @return [JsonModel]
|
57
|
+
# a JsonModel mapped against the provided JSON
|
58
|
+
def from_json(json)
|
59
|
+
new(to_attributes(JSON.parse(json)))
|
60
|
+
end
|
61
|
+
|
62
|
+
# Given a ruby Hash representation of raw JSON from the API (or a subset thereof), map all JSON parameter keys to attribute names
|
63
|
+
#
|
64
|
+
# @param [Hash] json
|
65
|
+
# a ruby Hash representing a subset of the overall JSON structure
|
66
|
+
#
|
67
|
+
# @return [Hash]
|
68
|
+
# a new Hash with all keys mapped to their attribute names
|
69
|
+
def to_attributes(json)
|
70
|
+
json = {} unless json.kind_of?(Hash)
|
71
|
+
json.inject({}) { |hash, (key, value)| (attr_value = attribute_value(key, value)) ? hash.merge(attribute_key(key) => attr_value) : hash }
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def attribute_key(key)
|
77
|
+
Hash[attributes.map { |attr| [attr.options.fetch(:param, attr.name).to_s, attr.name.to_sym] }][key] || key.to_sym
|
78
|
+
end
|
79
|
+
|
80
|
+
def attribute_value(key, value)
|
81
|
+
return unless attribute = attributes[attribute_key(key)]
|
82
|
+
|
83
|
+
case attribute
|
84
|
+
when Node
|
85
|
+
attribute.type.to_attributes(value)
|
86
|
+
when NodeList
|
87
|
+
value.map { |v| attribute.type.to_attributes(v) } if value.kind_of?(Array)
|
88
|
+
else
|
89
|
+
value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Methods for converting a JsonModel into a JSON string for transport to the API
|
95
|
+
module Writing
|
96
|
+
# Recursively read all attributes in a ruby Hash, mapping attribute names to JSON parameters, according to the :param option
|
97
|
+
#
|
98
|
+
# @return [Hash]
|
99
|
+
# the JSON representation in ruby Hash form
|
100
|
+
def to_hash
|
101
|
+
attributes.inject({}) { |hash, (key, value)| value.nil? ? hash : hash.merge(json_key(key) => json_value(value)) } \
|
102
|
+
.reject { |key, value| value.kind_of?(Enumerable) && value.none? }
|
103
|
+
end
|
104
|
+
|
105
|
+
# Convert this JsonModel into a JSON string for transport to the PayPal API
|
106
|
+
#
|
107
|
+
# @return [String]
|
108
|
+
# the JSON string, containing all children, if any
|
109
|
+
def to_json(*)
|
110
|
+
to_hash.to_json
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def json_key(key)
|
116
|
+
if self.class.attributes[key]
|
117
|
+
self.class.attributes[key].options.fetch(:param, key).to_s
|
118
|
+
else
|
119
|
+
key.to_s
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def json_value(value)
|
124
|
+
case value
|
125
|
+
when JsonModel
|
126
|
+
value.to_hash
|
127
|
+
when CoercedArray
|
128
|
+
value.collect { |v| v.to_hash }
|
129
|
+
when BigDecimal, Float
|
130
|
+
"%.2f" % value
|
131
|
+
else
|
132
|
+
value
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
include Writing
|
138
|
+
extend Parsing
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "virtus"
|
2
|
+
|
3
|
+
module AdaptivePayments
|
4
|
+
# A Virtus Attribute used to box a type from the API to an Attribute in a JsonModel
|
5
|
+
#
|
6
|
+
# The Node type should not be used directly. Instead it should be given a type to box.
|
7
|
+
#
|
8
|
+
# attribute :child, Node[Child], :param => "childItem"
|
9
|
+
#
|
10
|
+
# In the above, the model gets an Attribute named #child, mapping to a JSON parameter named 'childItem'.
|
11
|
+
# The object at `model.child` is present by default, and is an object of type Child.
|
12
|
+
#
|
13
|
+
# Assigning a Hash directly to the attribute will store an object of the boxed type, based on the elements
|
14
|
+
# in the Hash.
|
15
|
+
class Node < Virtus::Attribute::Object
|
16
|
+
# Provide access to the boxed type
|
17
|
+
attr_reader :type
|
18
|
+
|
19
|
+
class << self
|
20
|
+
# Returns a descendant of Node, boxing the given type
|
21
|
+
#
|
22
|
+
# @param [Class<JsonModel>] type
|
23
|
+
# the class definition to box
|
24
|
+
#
|
25
|
+
# @return [Node<type>]
|
26
|
+
# an anonymous descendant of Node boxing the given type
|
27
|
+
def [](type)
|
28
|
+
raise ArgumentError, "Child nodes may only be other JsonModel classes" unless type <= JsonModel
|
29
|
+
|
30
|
+
@generated_class_map ||= {}
|
31
|
+
@generated_class_map[type] ||= Class.new(self) do
|
32
|
+
default lambda { |m, a| type.new }
|
33
|
+
|
34
|
+
define_method :type do
|
35
|
+
type
|
36
|
+
end
|
37
|
+
|
38
|
+
define_method :coerce do |value|
|
39
|
+
value.kind_of?(Hash) ? type.new(value) : value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "virtus"
|
2
|
+
|
3
|
+
module AdaptivePayments
|
4
|
+
# A Virtus Attribute used to hold a collection of objects boxed to a given type.
|
5
|
+
#
|
6
|
+
# The NodeList Attribute should not be used directly. Instead, it should be given a type to box.
|
7
|
+
#
|
8
|
+
# attribute :children, NodeList[Child], :param => "child"
|
9
|
+
#
|
10
|
+
# In the above, the model gets an Array accessible through model.children. All objects contained
|
11
|
+
# in the Array will be coerced to the boxed type. If an Array is assigned directly to the attribute,
|
12
|
+
# all items inside it will be coerced to the boxed type. If a Hash is pushed onto the existing
|
13
|
+
# Array, it will be coerced to the boxed type.
|
14
|
+
class NodeList < Virtus::Attribute::Object
|
15
|
+
primitive ::Array
|
16
|
+
|
17
|
+
# Allow access to the boxed type
|
18
|
+
attr_reader :type
|
19
|
+
|
20
|
+
class << self
|
21
|
+
# Return a descendant of NodeList boxing the given type.
|
22
|
+
#
|
23
|
+
# @param [Class<JsonModel>] type
|
24
|
+
# the type to box
|
25
|
+
#
|
26
|
+
# @return [NodeList]
|
27
|
+
# an anonymous descendant of NodeList boxing the given type
|
28
|
+
def [](type)
|
29
|
+
raise ArgumentError, "Lists may only be created from JsonModel classes" unless type <= JsonModel
|
30
|
+
|
31
|
+
Class.new(self) do
|
32
|
+
default lambda { |m, a| CoercedArray.new(type) }
|
33
|
+
|
34
|
+
define_method :type do
|
35
|
+
type
|
36
|
+
end
|
37
|
+
|
38
|
+
define_method :coerce do |value|
|
39
|
+
CoercedArray.new(type) + Array(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class Address < JsonModel
|
3
|
+
attribute :id, String, :param => "addressId"
|
4
|
+
attribute :addressee_name, String, :param => "addresseeName"
|
5
|
+
attribute :base_address, Node[BaseAddress], :param => "baseAddress"
|
6
|
+
|
7
|
+
alias_params :base_address, {
|
8
|
+
:line1 => :line1,
|
9
|
+
:line2 => :line2,
|
10
|
+
:city => :city,
|
11
|
+
:state => :state,
|
12
|
+
:postal_code => :postal_code,
|
13
|
+
:country_code => :country_code,
|
14
|
+
:type => :type
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
module ReceiverAliases
|
3
|
+
def self.included(base)
|
4
|
+
base.instance_eval do
|
5
|
+
alias_params :receiver, {
|
6
|
+
:receiver_email => :email,
|
7
|
+
:receiver_amount => :amount,
|
8
|
+
:payment_type => :payment_type,
|
9
|
+
:payment_subtype => :payment_subtype,
|
10
|
+
:invoice_id => :invoice_id
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
module ReceiverListAliases
|
3
|
+
def self.included(base)
|
4
|
+
base.instance_eval do
|
5
|
+
alias_params :receiver_list, {
|
6
|
+
:receivers => :receivers
|
7
|
+
}
|
8
|
+
|
9
|
+
alias_params :first_receiver, {
|
10
|
+
:receiver_email => :email,
|
11
|
+
:receiver_amount => :amount,
|
12
|
+
:payment_type => :payment_type,
|
13
|
+
:payment_subtype => :payment_subtype,
|
14
|
+
:invoice_id => :invoice_id,
|
15
|
+
:receiver_phone => :phone
|
16
|
+
}
|
17
|
+
|
18
|
+
alias_params :receiver_phone, {
|
19
|
+
:receiver_phone_number => :phone_number,
|
20
|
+
:receiver_phone_country_code => :country_code,
|
21
|
+
:receiver_phone_extension => :extension
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def first_receiver
|
29
|
+
receivers[0] ||= Receiver.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class BaseAddress < JsonModel
|
3
|
+
attribute :line1, String
|
4
|
+
attribute :line2, String
|
5
|
+
attribute :city, String
|
6
|
+
attribute :state, String
|
7
|
+
attribute :postal_code, String, :param => "postalCode"
|
8
|
+
attribute :country_code, String, :param => "countryCode"
|
9
|
+
attribute :type, String
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class ClientDetailsType < JsonModel
|
3
|
+
attribute :ip_address, String, :param => "ipAddress"
|
4
|
+
attribute :device_id, String, :param => "deviceId"
|
5
|
+
attribute :application_id, String, :param => "applicationId"
|
6
|
+
attribute :model, String
|
7
|
+
attribute :geo_location, String, :param => "geoLocation"
|
8
|
+
attribute :customer_type, String, :param => "customerType"
|
9
|
+
attribute :partner_name, String, :param => "partnerName"
|
10
|
+
attribute :customer_id, String, :param => "customerId"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class CurrencyConversion < JsonModel
|
3
|
+
attribute :from, Node[CurrencyType]
|
4
|
+
attribute :to, Node[CurrencyType]
|
5
|
+
attribute :exchange_rate, Decimal, :param => "exchangeRate"
|
6
|
+
|
7
|
+
alias_params :from, {
|
8
|
+
:from_currency_amount => :amount,
|
9
|
+
:from_currency_code => :code
|
10
|
+
}
|
11
|
+
|
12
|
+
alias_params :to, {
|
13
|
+
:to_currency_amount => :amount,
|
14
|
+
:to_currency_code => :code
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class CurrencyConversionList < JsonModel
|
3
|
+
attribute :base_amount, Node[CurrencyType], :param => 'baseAmount'
|
4
|
+
attribute :currency_list, Node[CurrencyList], :param => 'currencyList'
|
5
|
+
|
6
|
+
alias_params :base_amount, {
|
7
|
+
:base_currency_code => :code,
|
8
|
+
:base_currency_amount => :amount
|
9
|
+
}
|
10
|
+
|
11
|
+
alias_params :currency_list, {
|
12
|
+
:currencies => :currencies
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class DisplayOptions < JsonModel
|
3
|
+
attribute :email_header_image_url, String, :param => "emailHeaderImageUrl"
|
4
|
+
attribute :email_marketing_image_url, String, :param => "emailMarketingImageUrl"
|
5
|
+
attribute :header_image_url, String, :param => "headerImageUrl"
|
6
|
+
attribute :business_name, String, :param => "businessName"
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class ErrorData < JsonModel
|
3
|
+
attribute :id, Integer, :param => "errorId"
|
4
|
+
attribute :domain, String, :param => "domain"
|
5
|
+
attribute :subdomain, String, :param => "subdomain"
|
6
|
+
attribute :severity, String, :param => "severity"
|
7
|
+
attribute :category, String, :param => "category"
|
8
|
+
attribute :message, String, :param => "message"
|
9
|
+
attribute :parameters, Array, :param => "parameter", :default => lambda { |m, a| [] }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
module FaultMessage
|
3
|
+
def self.included(base)
|
4
|
+
base.instance_eval do
|
5
|
+
attribute :errors, NodeList[ErrorData], :param => "error"
|
6
|
+
|
7
|
+
alias_params :first_error, {
|
8
|
+
:error_id => :id,
|
9
|
+
:error_domain => :domain,
|
10
|
+
:error_subdomain => :subdomain,
|
11
|
+
:error_severity => :severity,
|
12
|
+
:error_category => :category,
|
13
|
+
:error_message => :message,
|
14
|
+
:error_parameters => :parameters
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def first_error
|
20
|
+
errors.first || ErrorData.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class FundingPlan < JsonModel
|
3
|
+
attribute :id, String, :param => "fundingPlanId"
|
4
|
+
attribute :funding_amount, Node[CurrencyType], :param => "fundingAmount"
|
5
|
+
attribute :backup_funding_source, Node[FundingSource], :param => "backupFundingSource"
|
6
|
+
attribute :sender_fees, Node[CurrencyType], :param => "senderFees"
|
7
|
+
attribute :currency_conversion, Node[CurrencyConversion], :param => "currencyConversion"
|
8
|
+
attribute :charges, NodeList[FundingPlanCharge], :param => "charge"
|
9
|
+
|
10
|
+
alias_params :funding_amount, {
|
11
|
+
:amount => :amount,
|
12
|
+
:currency_code => :code
|
13
|
+
}
|
14
|
+
|
15
|
+
alias_params :sender_fees, {
|
16
|
+
:sender_fees_amount => :amount,
|
17
|
+
:sender_fees_currency_code => :code
|
18
|
+
}
|
19
|
+
|
20
|
+
alias_params :currency_conversion, {
|
21
|
+
:from_currency_amount => :from_currency_amount,
|
22
|
+
:from_currency_code => :from_currency_code,
|
23
|
+
:to_currency_amount => :to_currency_amount,
|
24
|
+
:to_currency_code => :to_currency_code,
|
25
|
+
:exchange_rate => :exchange_rate
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class FundingPlanCharge < JsonModel
|
3
|
+
attribute :charge, Node[CurrencyType]
|
4
|
+
attribute :funding_source, Node[FundingSource], :param => "fundingSource"
|
5
|
+
|
6
|
+
alias_params :charge, {
|
7
|
+
:amount => :amount,
|
8
|
+
:currency_code => :code
|
9
|
+
}
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module AdaptivePayments
|
2
|
+
class FundingSource < JsonModel
|
3
|
+
attribute :id, String, :param => "fundingSourceId"
|
4
|
+
attribute :last_four_digits_of_account, String, :param => "lastFourOfAccountNumber"
|
5
|
+
attribute :type, String
|
6
|
+
attribute :display_name, String, :param => "displayName"
|
7
|
+
attribute :allowed, Boolean
|
8
|
+
end
|
9
|
+
end
|