fidor_api 1.0.0 → 2.0.0.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -49
- data/Rakefile +6 -3
- data/lib/fidor_api/client/authentication.rb +63 -0
- data/lib/fidor_api/client/configuration.rb +32 -0
- data/lib/fidor_api/client/connection.rb +56 -0
- data/lib/fidor_api/client/dsl/confirmable_actions.rb +19 -0
- data/lib/fidor_api/client/dsl/core_data.rb +19 -0
- data/lib/fidor_api/client/dsl/messages.rb +31 -0
- data/lib/fidor_api/client/dsl/transactions.rb +15 -0
- data/lib/fidor_api/client/dsl/transfers/classic.rb +29 -0
- data/lib/fidor_api/client/dsl/transfers/generic.rb +34 -0
- data/lib/fidor_api/client/dsl/transfers.rb +22 -0
- data/lib/fidor_api/client/dsl.rb +59 -0
- data/lib/fidor_api/client.rb +17 -21
- data/lib/fidor_api/collection/kaminari_support.rb +17 -0
- data/lib/fidor_api/collection.rb +18 -34
- data/lib/fidor_api/environment/base.rb +21 -0
- data/lib/fidor_api/environment/fidor_de/production.rb +23 -0
- data/lib/fidor_api/environment/fidor_de/sandbox.rb +23 -0
- data/lib/fidor_api/environment/fidor_de.rb +8 -0
- data/lib/fidor_api/environment/future.rb +21 -0
- data/lib/fidor_api/environment.rb +7 -0
- data/lib/fidor_api/errors.rb +3 -26
- data/lib/fidor_api/model/account.rb +25 -0
- data/lib/fidor_api/model/base.rb +44 -0
- data/lib/fidor_api/model/confirmable_action.rb +9 -0
- data/lib/fidor_api/model/customer.rb +36 -0
- data/lib/fidor_api/model/helpers/action_view_support.rb +21 -0
- data/lib/fidor_api/model/helpers/attribute_decimal_methods.rb +32 -0
- data/lib/fidor_api/model/helpers.rb +8 -0
- data/lib/fidor_api/model/message.rb +23 -0
- data/lib/fidor_api/model/transaction.rb +21 -0
- data/lib/fidor_api/model/transfer/classic/base.rb +15 -0
- data/lib/fidor_api/model/transfer/classic/internal.rb +20 -0
- data/lib/fidor_api/model/transfer/classic/sepa.rb +11 -0
- data/lib/fidor_api/model/transfer/classic.rb +11 -0
- data/lib/fidor_api/model/transfer/generic.rb +71 -0
- data/lib/fidor_api/model/transfer.rb +8 -0
- data/lib/fidor_api/model/user.rb +10 -0
- data/lib/fidor_api/model.rb +13 -0
- data/lib/fidor_api/token.rb +13 -18
- data/lib/fidor_api/version.rb +1 -1
- data/lib/fidor_api.rb +14 -58
- metadata +152 -89
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -20
- data/CHANGELOG.md +0 -129
- data/Gemfile +0 -15
- data/LICENSE.txt +0 -21
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/fidor_api.gemspec +0 -24
- data/lib/fidor_api/account.rb +0 -45
- data/lib/fidor_api/amount_attributes.rb +0 -30
- data/lib/fidor_api/approval_required.rb +0 -9
- data/lib/fidor_api/auth.rb +0 -45
- data/lib/fidor_api/beneficiary/ach.rb +0 -39
- data/lib/fidor_api/beneficiary/base.rb +0 -118
- data/lib/fidor_api/beneficiary/generic.rb +0 -24
- data/lib/fidor_api/beneficiary/p2p_account_number.rb +0 -14
- data/lib/fidor_api/beneficiary/p2p_phone.rb +0 -14
- data/lib/fidor_api/beneficiary/p2p_username.rb +0 -14
- data/lib/fidor_api/beneficiary/swift.rb +0 -35
- data/lib/fidor_api/beneficiary/unknown.rb +0 -16
- data/lib/fidor_api/beneficiary/utility.rb +0 -35
- data/lib/fidor_api/beneficiary.rb +0 -27
- data/lib/fidor_api/card.rb +0 -77
- data/lib/fidor_api/card_limit_attribute.rb +0 -52
- data/lib/fidor_api/card_limits.rb +0 -14
- data/lib/fidor_api/confirmable_action.rb +0 -45
- data/lib/fidor_api/connectivity/connection.rb +0 -113
- data/lib/fidor_api/connectivity/endpoint.rb +0 -82
- data/lib/fidor_api/connectivity/resource.rb +0 -76
- data/lib/fidor_api/connectivity.rb +0 -17
- data/lib/fidor_api/constants.rb +0 -3
- data/lib/fidor_api/customer.rb +0 -140
- data/lib/fidor_api/customers/confirmations.rb +0 -19
- data/lib/fidor_api/message.rb +0 -52
- data/lib/fidor_api/msisdn.rb +0 -45
- data/lib/fidor_api/password.rb +0 -29
- data/lib/fidor_api/preauth.rb +0 -33
- data/lib/fidor_api/preauth_details.rb +0 -97
- data/lib/fidor_api/session_token.rb +0 -20
- data/lib/fidor_api/transaction.rb +0 -37
- data/lib/fidor_api/transaction_details.rb +0 -119
- data/lib/fidor_api/transfer/ach.rb +0 -46
- data/lib/fidor_api/transfer/bank_internal.rb +0 -37
- data/lib/fidor_api/transfer/base.rb +0 -36
- data/lib/fidor_api/transfer/fps.rb +0 -56
- data/lib/fidor_api/transfer/generic.rb +0 -134
- data/lib/fidor_api/transfer/internal.rb +0 -53
- data/lib/fidor_api/transfer/p2p_account_number.rb +0 -45
- data/lib/fidor_api/transfer/p2p_phone.rb +0 -45
- data/lib/fidor_api/transfer/p2p_username.rb +0 -45
- data/lib/fidor_api/transfer/sepa.rb +0 -56
- data/lib/fidor_api/transfer/swift.rb +0 -49
- data/lib/fidor_api/transfer/utility.rb +0 -50
- data/lib/fidor_api/transfer.rb +0 -17
- data/lib/fidor_api/user.rb +0 -24
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
|
|
3
|
-
module PreauthDetails
|
|
4
|
-
|
|
5
|
-
def self.build(type, hash)
|
|
6
|
-
implementation(type).new(hash)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class Base
|
|
10
|
-
def initialize(attributes = {})
|
|
11
|
-
set_attributes(attributes)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def description
|
|
15
|
-
"-"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
class CreditCard < Base
|
|
20
|
-
extend ModelAttribute
|
|
21
|
-
|
|
22
|
-
attribute :cc_category, :string
|
|
23
|
-
attribute :cc_merchant_category, :string
|
|
24
|
-
attribute :cc_merchant_name, :string
|
|
25
|
-
attribute :cc_sequence, :string
|
|
26
|
-
attribute :cc_type, :string
|
|
27
|
-
attribute :pos_code, :string
|
|
28
|
-
attribute :financial_network_code, :string
|
|
29
|
-
|
|
30
|
-
def description
|
|
31
|
-
cc_merchant_name.presence || super
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
class InternalTransfer < Base
|
|
36
|
-
extend ModelAttribute
|
|
37
|
-
|
|
38
|
-
attribute :internal_transfer_id, :string
|
|
39
|
-
attribute :remote_account_id, :string
|
|
40
|
-
attribute :remote_bic, :string
|
|
41
|
-
attribute :remote_iban, :string
|
|
42
|
-
attribute :remote_name, :string
|
|
43
|
-
attribute :remote_nick, :string
|
|
44
|
-
attribute :remote_subject, :string
|
|
45
|
-
|
|
46
|
-
def description
|
|
47
|
-
remote_name || remote_nick || super
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
class CapitalBond < Base
|
|
52
|
-
extend ModelAttribute
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
class CurrencyOrder < Base
|
|
56
|
-
extend ModelAttribute
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
class Gmt < Base
|
|
60
|
-
extend ModelAttribute
|
|
61
|
-
|
|
62
|
-
attribute :destination_country, :string
|
|
63
|
-
attribute :destination_currency, :string
|
|
64
|
-
attribute :amount_in_destination_currency, :string
|
|
65
|
-
attribute :exchange_rate, :string
|
|
66
|
-
attribute :fee_transaction_id, :string
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
class Ripple < Base
|
|
70
|
-
extend ModelAttribute
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
class Unknown < Base
|
|
74
|
-
extend ModelAttribute
|
|
75
|
-
|
|
76
|
-
def method_missing(method, *args)
|
|
77
|
-
return if method[-1] == "="
|
|
78
|
-
super
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
private
|
|
83
|
-
|
|
84
|
-
def self.implementation(type)
|
|
85
|
-
{
|
|
86
|
-
"creditcard_preauth" => CreditCard,
|
|
87
|
-
"internal_transfer_preauth" => InternalTransfer,
|
|
88
|
-
"capital_bond_preauth" => CapitalBond,
|
|
89
|
-
"currency_order_preauth" => CurrencyOrder,
|
|
90
|
-
"gmt_preauth" => Gmt,
|
|
91
|
-
"ripple_preauth" => Ripple
|
|
92
|
-
}.fetch(type, Unknown)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
class SessionToken < Connectivity::Resource
|
|
3
|
-
extend ModelAttribute
|
|
4
|
-
extend AmountAttributes
|
|
5
|
-
|
|
6
|
-
attribute :token, :string
|
|
7
|
-
|
|
8
|
-
self.endpoint = Connectivity::Endpoint.new('/session_tokens', :collection)
|
|
9
|
-
|
|
10
|
-
def self.create(access_token)
|
|
11
|
-
new endpoint.for(self).post(payload: {access_token: access_token}).body
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module ClientSupport
|
|
15
|
-
def create_session_token
|
|
16
|
-
SessionToken.create(token.access_token)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
class Transaction < Connectivity::Resource
|
|
3
|
-
extend ModelAttribute
|
|
4
|
-
extend AmountAttributes
|
|
5
|
-
|
|
6
|
-
self.endpoint = Connectivity::Endpoint.new('/transactions', :collection)
|
|
7
|
-
|
|
8
|
-
attribute :id, :integer
|
|
9
|
-
attribute :account_id, :string
|
|
10
|
-
attribute :transaction_type, :string
|
|
11
|
-
attribute :transaction_type_details, :json
|
|
12
|
-
attribute :subject, :string
|
|
13
|
-
attribute :currency, :string
|
|
14
|
-
attribute :booking_date, :time
|
|
15
|
-
attribute :value_date, :time
|
|
16
|
-
attribute :booking_code, :string
|
|
17
|
-
attribute :return_transaction_id, :string
|
|
18
|
-
attribute :created_at, :time
|
|
19
|
-
attribute :updated_at, :time
|
|
20
|
-
amount_attribute :amount
|
|
21
|
-
|
|
22
|
-
def transaction_type_details
|
|
23
|
-
@_transaction_type_details ||= TransactionDetails.build(@transaction_type, @transaction_type_details)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
module ClientSupport
|
|
27
|
-
def transactions(options = {})
|
|
28
|
-
Transaction.all(options)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def transaction(id)
|
|
32
|
-
Transaction.find(id)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
|
|
3
|
-
module TransactionDetails
|
|
4
|
-
|
|
5
|
-
def self.build(type, hash)
|
|
6
|
-
implementation(type).new(hash)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class Base
|
|
10
|
-
def initialize(attributes = {})
|
|
11
|
-
set_attributes(attributes)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def remote_display_name
|
|
15
|
-
"Fidor Bank"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
class Transfer < Base
|
|
20
|
-
extend ModelAttribute
|
|
21
|
-
|
|
22
|
-
attribute :internal_transfer_id, :string
|
|
23
|
-
attribute :sepa_credit_transfer_id, :string
|
|
24
|
-
attribute :remote_account_id, :string
|
|
25
|
-
attribute :remote_bic, :string
|
|
26
|
-
attribute :remote_iban, :string
|
|
27
|
-
attribute :remote_name, :string
|
|
28
|
-
attribute :remote_nick, :string
|
|
29
|
-
attribute :remote_subject, :string
|
|
30
|
-
|
|
31
|
-
def remote_display_name
|
|
32
|
-
remote_name.presence || remote_nick.presence || super
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class CreditCard < Base
|
|
37
|
-
extend ModelAttribute
|
|
38
|
-
|
|
39
|
-
attribute :cc_category, :string
|
|
40
|
-
attribute :cc_merchant_category, :string
|
|
41
|
-
attribute :cc_merchant_name, :string
|
|
42
|
-
attribute :cc_sequence, :string
|
|
43
|
-
attribute :cc_type, :string
|
|
44
|
-
|
|
45
|
-
def remote_display_name
|
|
46
|
-
cc_merchant_name.presence || super
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
class Gmt < Base
|
|
51
|
-
extend ModelAttribute
|
|
52
|
-
|
|
53
|
-
attribute :destination_country, :string
|
|
54
|
-
attribute :destination_currency, :string
|
|
55
|
-
attribute :amount_in_destination_currency, :string
|
|
56
|
-
attribute :exchange_rate, :string
|
|
57
|
-
attribute :fee_transaction_id, :string
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
class Bonus < Base
|
|
61
|
-
extend ModelAttribute
|
|
62
|
-
|
|
63
|
-
attribute :affiliate_id, :string
|
|
64
|
-
attribute :affiliate_name, :string
|
|
65
|
-
attribute :affiliate_transaction_type_id, :string
|
|
66
|
-
attribute :affiliate_transaction_type_name, :string
|
|
67
|
-
attribute :affiliate_transaction_type_category, :string
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
class MobileTopup < Base
|
|
71
|
-
extend ModelAttribute
|
|
72
|
-
|
|
73
|
-
attribute :provider, :string
|
|
74
|
-
attribute :phone_number, :string
|
|
75
|
-
attribute :topup_subject, :string
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
class Unknown < Base
|
|
79
|
-
extend ModelAttribute
|
|
80
|
-
|
|
81
|
-
def method_missing(method, *args)
|
|
82
|
-
return if method[-1] == "="
|
|
83
|
-
super
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
def self.implementation(type)
|
|
90
|
-
{
|
|
91
|
-
"fidor_payin" => Transfer,
|
|
92
|
-
"fidor_payout" => Transfer,
|
|
93
|
-
"emoney_payin" => Transfer,
|
|
94
|
-
"sepa_payin" => Transfer,
|
|
95
|
-
"payout" => Transfer,
|
|
96
|
-
"creditcard_preauth" => CreditCard,
|
|
97
|
-
"creditcard_release" => CreditCard,
|
|
98
|
-
"creditcard_payout" => CreditCard,
|
|
99
|
-
"creditcard_payin" => CreditCard,
|
|
100
|
-
"creditcard_annual_fee" => CreditCard,
|
|
101
|
-
"creditcard_foreign_exchange_fee" => CreditCard,
|
|
102
|
-
"creditcard_order_fee" => CreditCard,
|
|
103
|
-
"creditcard_order_cancellation" => CreditCard,
|
|
104
|
-
"creditcard_order_withdrawal_fee" => CreditCard,
|
|
105
|
-
"creditcard_atm_fee" => CreditCard,
|
|
106
|
-
"creditcard_notification_fee" => CreditCard,
|
|
107
|
-
"sepa_core_direct_debit" => Transfer,
|
|
108
|
-
"sepa_b2b_direct_debit" => Transfer,
|
|
109
|
-
"gmt_payout" => Gmt,
|
|
110
|
-
"gmt_refund" => Gmt,
|
|
111
|
-
"gmt_fee" => Gmt,
|
|
112
|
-
"bonus" => Bonus,
|
|
113
|
-
"prepaid_mobile_topup" => MobileTopup
|
|
114
|
-
}.fetch(type, Unknown)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
class ACH < Base
|
|
4
|
-
include Generic
|
|
5
|
-
|
|
6
|
-
attribute :account_number, :string
|
|
7
|
-
attribute :routing_code, :string
|
|
8
|
-
|
|
9
|
-
validates :contact_name, presence: true, unless: :beneficiary_reference_passed?
|
|
10
|
-
validates :account_number, presence: true, unless: :beneficiary_reference_passed?
|
|
11
|
-
validates :routing_code, presence: true, unless: :beneficiary_reference_passed?
|
|
12
|
-
|
|
13
|
-
def set_attributes(attrs = {})
|
|
14
|
-
set_beneficiary_attributes(attrs)
|
|
15
|
-
self.account_number = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["account_number"]
|
|
16
|
-
self.routing_code = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["routing_code"]
|
|
17
|
-
super(attrs.except("beneficiary"))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def as_json_routing_type
|
|
21
|
-
"ACH"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def as_json_routing_info
|
|
25
|
-
{
|
|
26
|
-
account_number: account_number,
|
|
27
|
-
routing_code: routing_code
|
|
28
|
-
}
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
module ClientSupport
|
|
32
|
-
def ach_transfers(options = {})
|
|
33
|
-
Transfer::ACH.all(options)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def ach_transfer(id)
|
|
37
|
-
Transfer::ACH.find(id)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def build_ach_transfer(attributes = {})
|
|
41
|
-
Transfer::ACH.new(attributes)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
class BankInternal < Base
|
|
4
|
-
include Generic
|
|
5
|
-
attribute :account_number, :string
|
|
6
|
-
|
|
7
|
-
validates :account_number, presence: true, unless: :beneficiary_reference_passed?
|
|
8
|
-
|
|
9
|
-
def set_attributes(attrs = {})
|
|
10
|
-
self.account_number = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["account_number"]
|
|
11
|
-
super(attrs)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def as_json_routing_type
|
|
15
|
-
'BANK_INTERNAL'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def as_json_routing_info
|
|
19
|
-
{
|
|
20
|
-
account_number: account_number
|
|
21
|
-
}
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def remote_create
|
|
27
|
-
response = endpoint.for(self).post(payload: self.as_json)
|
|
28
|
-
|
|
29
|
-
if path = response.headers["X-Fidor-Confirmation-Path"]
|
|
30
|
-
self.confirmable_action = ConfirmableAction.new(id: path.split("/").last)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
response
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
class Base < Connectivity::Resource
|
|
4
|
-
self.endpoint = Connectivity::Endpoint.new('/transfers', :collection)
|
|
5
|
-
|
|
6
|
-
attr_accessor :confirmable_action
|
|
7
|
-
|
|
8
|
-
def save
|
|
9
|
-
fail InvalidRecordError unless valid?
|
|
10
|
-
super
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def needs_confirmation?
|
|
14
|
-
self.confirmable_action.present?
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def remote_create
|
|
20
|
-
response = super
|
|
21
|
-
if path = response.headers["X-Fidor-Confirmation-Path"]
|
|
22
|
-
self.confirmable_action = ConfirmableAction.new(id: path.split("/").last)
|
|
23
|
-
end
|
|
24
|
-
response
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def remote_update(*attributes)
|
|
28
|
-
response = super
|
|
29
|
-
if path = response.headers["X-Fidor-Confirmation-Path"]
|
|
30
|
-
self.confirmable_action = ConfirmableAction.new(id: path.split("/").last)
|
|
31
|
-
end
|
|
32
|
-
response
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
class FPS < Base
|
|
4
|
-
extend ModelAttribute
|
|
5
|
-
extend AmountAttributes
|
|
6
|
-
|
|
7
|
-
self.endpoint = Connectivity::Endpoint.new('/fps_transfers', :collection)
|
|
8
|
-
|
|
9
|
-
attribute :id, :integer
|
|
10
|
-
attribute :account_id, :string
|
|
11
|
-
attribute :user_id, :string
|
|
12
|
-
attribute :transaction_id, :string
|
|
13
|
-
attribute :remote_account, :string
|
|
14
|
-
attribute :remote_sort_code, :string
|
|
15
|
-
attribute :remote_name, :string
|
|
16
|
-
attribute :external_uid, :string
|
|
17
|
-
attribute :subject, :string
|
|
18
|
-
attribute :currency, :string
|
|
19
|
-
attribute :subject, :string
|
|
20
|
-
attribute :state, :string
|
|
21
|
-
attribute :created_at, :time
|
|
22
|
-
attribute :updated_at, :time
|
|
23
|
-
amount_attribute :amount
|
|
24
|
-
|
|
25
|
-
def self.required_attributes
|
|
26
|
-
[ :account_id, :external_uid, :remote_account, :remote_sort_code, :remote_name, :amount, :subject ]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.writeable_attributes
|
|
30
|
-
required_attributes
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
validates *required_attributes, presence: true
|
|
34
|
-
|
|
35
|
-
def as_json
|
|
36
|
-
attributes.slice *self.class.writeable_attributes
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
module ClientSupport
|
|
42
|
-
def fps_transfers(options = {})
|
|
43
|
-
Transfer::FPS.all(options)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def fps_transfer(id)
|
|
47
|
-
Transfer::FPS.find(id)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def build_fps_transfer(attributes = {})
|
|
51
|
-
Transfer::FPS.new(attributes)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
module Generic
|
|
4
|
-
ROUTING_INFO_ERROR_PREFIX = "beneficiary.routing_info.".freeze
|
|
5
|
-
|
|
6
|
-
def self.included(base)
|
|
7
|
-
base.extend ModelAttribute
|
|
8
|
-
base.extend AmountAttributes
|
|
9
|
-
|
|
10
|
-
base.validates *required_attributes, presence: true
|
|
11
|
-
base.validates :beneficiary_unique_name, presence: true, if: -> { create_beneficiary && !beneficiary_reference_passed? }
|
|
12
|
-
|
|
13
|
-
base.attribute :id, :string
|
|
14
|
-
base.attribute :account_id, :string
|
|
15
|
-
base.attribute :external_uid, :string
|
|
16
|
-
base.attribute :subject, :string
|
|
17
|
-
base.attribute :currency, :string
|
|
18
|
-
base.attribute :exchange_rate, :string
|
|
19
|
-
base.attribute :subject, :string
|
|
20
|
-
base.attribute :state, :string
|
|
21
|
-
base.amount_attribute :amount
|
|
22
|
-
|
|
23
|
-
base.attribute :beneficiary_unique_name, :string
|
|
24
|
-
base.attribute :contact_name, :string
|
|
25
|
-
base.attribute :contact_address_line_1, :string
|
|
26
|
-
base.attribute :contact_address_line_2, :string
|
|
27
|
-
base.attribute :contact_city, :string
|
|
28
|
-
base.attribute :contact_country, :string
|
|
29
|
-
base.attribute :bank_name, :string
|
|
30
|
-
base.attribute :bank_address_line_1, :string
|
|
31
|
-
base.attribute :bank_address_line_2, :string
|
|
32
|
-
base.attribute :bank_city, :string
|
|
33
|
-
base.attribute :bank_country, :string
|
|
34
|
-
base.attribute :create_beneficiary, :boolean
|
|
35
|
-
|
|
36
|
-
base.attribute :beneficiary_id, :string
|
|
37
|
-
|
|
38
|
-
base.attribute :created_at, :time
|
|
39
|
-
base.attribute :updated_at, :time
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def self.required_attributes
|
|
43
|
-
[ :account_id, :external_uid, :amount, :subject, :currency ]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def as_json
|
|
47
|
-
transfer_json_params.merge(beneficiary_json_params)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def beneficiary_reference_passed?
|
|
53
|
-
beneficiary_id.present?
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def transfer_json_params
|
|
57
|
-
{
|
|
58
|
-
account_id: account_id,
|
|
59
|
-
external_uid: external_uid,
|
|
60
|
-
amount: (amount * 100).to_i,
|
|
61
|
-
currency: currency,
|
|
62
|
-
subject: subject
|
|
63
|
-
}
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def beneficiary_json_params
|
|
67
|
-
if beneficiary_reference_passed?
|
|
68
|
-
{
|
|
69
|
-
beneficiary_id: beneficiary_id
|
|
70
|
-
}
|
|
71
|
-
else
|
|
72
|
-
{
|
|
73
|
-
beneficiary: {
|
|
74
|
-
unique_name: beneficiary_unique_name.presence,
|
|
75
|
-
contact: {
|
|
76
|
-
name: contact_name,
|
|
77
|
-
address_line_1: contact_address_line_1,
|
|
78
|
-
address_line_2: contact_address_line_2,
|
|
79
|
-
city: contact_city,
|
|
80
|
-
country: contact_country
|
|
81
|
-
}.compact,
|
|
82
|
-
bank: {
|
|
83
|
-
name: bank_name,
|
|
84
|
-
address_line_1: bank_address_line_1,
|
|
85
|
-
address_line_2: bank_address_line_2,
|
|
86
|
-
city: bank_city,
|
|
87
|
-
country: bank_country
|
|
88
|
-
}.compact,
|
|
89
|
-
routing_type: as_json_routing_type,
|
|
90
|
-
routing_info: as_json_routing_info
|
|
91
|
-
},
|
|
92
|
-
create_beneficiary: create_beneficiary
|
|
93
|
-
}.compact
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def set_beneficiary_attributes(attrs)
|
|
98
|
-
self.beneficiary_unique_name = attrs.fetch("beneficiary", {})["unique_name"]
|
|
99
|
-
|
|
100
|
-
self.contact_name = attrs.fetch("beneficiary", {}).fetch("contact", {})["name"]
|
|
101
|
-
self.contact_address_line_1 = attrs.fetch("beneficiary", {}).fetch("contact", {})["address_line_1"]
|
|
102
|
-
self.contact_address_line_2 = attrs.fetch("beneficiary", {}).fetch("contact", {})["address_line_2"]
|
|
103
|
-
self.contact_city = attrs.fetch("beneficiary", {}).fetch("contact", {})["city"]
|
|
104
|
-
self.contact_country = attrs.fetch("beneficiary", {}).fetch("contact", {})["country"]
|
|
105
|
-
|
|
106
|
-
self.bank_name = attrs.fetch("beneficiary", {}).fetch("bank", {})["name"]
|
|
107
|
-
self.bank_address_line_1 = attrs.fetch("beneficiary", {}).fetch("bank", {})["address_line_1"]
|
|
108
|
-
self.bank_address_line_2 = attrs.fetch("beneficiary", {}).fetch("bank", {})["address_line_2"]
|
|
109
|
-
self.bank_city = attrs.fetch("beneficiary", {}).fetch("bank", {})["city"]
|
|
110
|
-
self.bank_country = attrs.fetch("beneficiary", {}).fetch("bank", {})["country"]
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def map_errors(fields)
|
|
114
|
-
fields.each do |hash|
|
|
115
|
-
field = hash["field"].to_sym
|
|
116
|
-
key = hash["key"].try :to_sym
|
|
117
|
-
|
|
118
|
-
if field == :base || respond_to?(field)
|
|
119
|
-
if key
|
|
120
|
-
errors.add(field, key, message: hash["message"])
|
|
121
|
-
else
|
|
122
|
-
errors.add(field, hash["message"])
|
|
123
|
-
end
|
|
124
|
-
elsif hash["field"] == "beneficiary.unique_name"
|
|
125
|
-
errors.add(:beneficiary_unique_name, hash["message"])
|
|
126
|
-
elsif hash["field"].start_with?(ROUTING_INFO_ERROR_PREFIX)
|
|
127
|
-
invalid_field = hash["field"][ROUTING_INFO_ERROR_PREFIX.size..-1]
|
|
128
|
-
errors.add(invalid_field, hash["key"].to_sym, message: hash["message"])
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
class Internal < Base
|
|
4
|
-
extend ModelAttribute
|
|
5
|
-
extend AmountAttributes
|
|
6
|
-
|
|
7
|
-
self.endpoint = Connectivity::Endpoint.new('/internal_transfers', :collection)
|
|
8
|
-
|
|
9
|
-
attribute :id, :integer
|
|
10
|
-
attribute :account_id, :string
|
|
11
|
-
attribute :user_id, :string
|
|
12
|
-
attribute :transaction_id, :string
|
|
13
|
-
attribute :receiver, :string
|
|
14
|
-
attribute :external_uid, :string
|
|
15
|
-
attribute :currency, :string
|
|
16
|
-
attribute :subject, :string
|
|
17
|
-
attribute :state, :string
|
|
18
|
-
attribute :created_at, :time
|
|
19
|
-
attribute :updated_at, :time
|
|
20
|
-
amount_attribute :amount
|
|
21
|
-
|
|
22
|
-
def self.required_attributes
|
|
23
|
-
[ :account_id, :receiver, :external_uid, :amount, :subject ]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def self.writeable_attributes
|
|
27
|
-
required_attributes
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
validates *required_attributes, presence: true
|
|
31
|
-
|
|
32
|
-
def as_json
|
|
33
|
-
attributes.slice *self.class.writeable_attributes
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
module ClientSupport
|
|
39
|
-
def internal_transfers(options = {})
|
|
40
|
-
Transfer::Internal.all(options)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def internal_transfer(id)
|
|
44
|
-
Transfer::Internal.find(id)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def build_internal_transfer(attributes = {})
|
|
48
|
-
Transfer::Internal.new(attributes)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
module FidorApi
|
|
2
|
-
module Transfer
|
|
3
|
-
class P2pAccountNumber < Base
|
|
4
|
-
include Generic
|
|
5
|
-
|
|
6
|
-
attribute :account_number, :string
|
|
7
|
-
|
|
8
|
-
validates :account_number, presence: true, unless: :beneficiary_reference_passed?
|
|
9
|
-
|
|
10
|
-
def set_attributes(attrs = {})
|
|
11
|
-
set_beneficiary_attributes(attrs)
|
|
12
|
-
self.account_number = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["account_number"]
|
|
13
|
-
super(attrs.except("beneficiary"))
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def as_json_routing_type
|
|
17
|
-
"FOS_P2P_ACCOUNT_NUMBER".freeze
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def as_json_routing_info
|
|
21
|
-
{
|
|
22
|
-
account_number: account_number
|
|
23
|
-
}
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
module ClientSupport
|
|
27
|
-
def p2p_account_number_transfers(options = {})
|
|
28
|
-
Transfer::P2pAccountNumber.all(options)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def p2p_account_number_transfer(id)
|
|
32
|
-
Transfer::P2pAccountNumber.find(id)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def build_p2p_account_number_transfer(attributes = {})
|
|
36
|
-
Transfer::P2pAccountNumber.new(attributes)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def update_p2p_account_number_transfer(id, attributes = {})
|
|
40
|
-
Transfer::P2pAccountNumber.new(attributes.merge(id: id))
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|