fidor_api 1.0.0 → 2.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,21 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Environment
|
3
|
+
class Base
|
4
|
+
def api_host
|
5
|
+
raise NotImplementedError
|
6
|
+
end
|
7
|
+
|
8
|
+
def auth_host
|
9
|
+
raise NotImplementedError
|
10
|
+
end
|
11
|
+
|
12
|
+
def auth_methods
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
def transfers_api
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Environment
|
3
|
+
module FidorDE
|
4
|
+
class Production < Base
|
5
|
+
def api_host
|
6
|
+
'https://api.fidor.de'.freeze
|
7
|
+
end
|
8
|
+
|
9
|
+
def auth_host
|
10
|
+
'https://apm.fidor.de'.freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
def auth_methods
|
14
|
+
%i[authorization_code].freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
def transfers_api
|
18
|
+
:classic
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Environment
|
3
|
+
module FidorDE
|
4
|
+
class Sandbox < Base
|
5
|
+
def api_host
|
6
|
+
'https://api.sandbox.fidor.com'.freeze
|
7
|
+
end
|
8
|
+
|
9
|
+
def auth_host
|
10
|
+
'https://apm.sandbox.fidor.com'.freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
def auth_methods
|
14
|
+
%i[authorization_code].freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
def transfers_api
|
18
|
+
:classic
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Environment
|
3
|
+
class Future < Base
|
4
|
+
def api_host
|
5
|
+
'https://api.example.com'.freeze
|
6
|
+
end
|
7
|
+
|
8
|
+
def auth_host
|
9
|
+
api_host
|
10
|
+
end
|
11
|
+
|
12
|
+
def auth_methods
|
13
|
+
%i[authorization_code resource_owner_password_credentials client_credentials].freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
def transfers_api
|
17
|
+
:generic
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/fidor_api/errors.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
module FidorApi
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
UnauthorizedTokenError = Class.new(Error)
|
6
|
-
InvalidRecordError = Class.new(Error)
|
7
|
-
NoUpdatesAllowedError = Class.new(Error)
|
8
|
-
|
9
|
-
class ForbiddenError < Error
|
10
|
-
attr_accessor :code, :key
|
11
|
-
|
12
|
-
def initialize(message, code, key)
|
13
|
-
super(message)
|
14
|
-
self.code = code
|
15
|
-
self.key = key
|
16
|
-
end
|
2
|
+
module Errors
|
3
|
+
Base = Class.new(StandardError)
|
4
|
+
NotSupported = Class.new(Base)
|
17
5
|
end
|
18
|
-
|
19
|
-
class ValidationError < Error
|
20
|
-
attr_accessor :fields, :error_keys
|
21
|
-
|
22
|
-
def initialize(message, fields, error_keys)
|
23
|
-
super(message)
|
24
|
-
self.fields = fields
|
25
|
-
self.error_keys = error_keys
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
6
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
class Account < Base
|
4
|
+
attribute :id, :integer
|
5
|
+
attribute :account_number, :string
|
6
|
+
attribute :iban, :string
|
7
|
+
attribute :bic, :string
|
8
|
+
attribute :balance, :integer
|
9
|
+
attribute :balance_available, :integer
|
10
|
+
attribute :overdraft, :integer
|
11
|
+
attribute :preauth_amount, :integer
|
12
|
+
attribute :cash_flow_per_year, :integer
|
13
|
+
attribute :is_debit_note_enabled, :string
|
14
|
+
attribute :is_trusted, :string
|
15
|
+
attribute :is_locked, :string
|
16
|
+
attribute :currency, :string
|
17
|
+
|
18
|
+
attribute_decimal_methods :balance
|
19
|
+
attribute_decimal_methods :balance_available
|
20
|
+
attribute_decimal_methods :overdraft
|
21
|
+
attribute_decimal_methods :preauth_amount
|
22
|
+
attribute_decimal_methods :cash_flow_per_year
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
class Base
|
4
|
+
class << self
|
5
|
+
def inherited(klass)
|
6
|
+
klass.include ActiveModel::Model
|
7
|
+
klass.include Helpers::ActionViewSupport
|
8
|
+
|
9
|
+
klass.extend ModelAttribute
|
10
|
+
klass.extend Helpers::AttributeDecimalMethods
|
11
|
+
|
12
|
+
klass.define_method :initialize do |attributes = {}|
|
13
|
+
set_attributes(attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource_name
|
18
|
+
name.sub('FidorApi::Model::', '')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :confirmable_action_id
|
23
|
+
|
24
|
+
def as_json
|
25
|
+
attributes.compact
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_errors(body) # rubocop:disable Metrics/AbcSize
|
29
|
+
Array(body['errors']).each do |hash|
|
30
|
+
field = hash.delete('field').to_sym
|
31
|
+
key = hash.delete('key')
|
32
|
+
|
33
|
+
next unless respond_to?(field) || field == :base
|
34
|
+
|
35
|
+
if key
|
36
|
+
errors.add(field, key.to_sym, hash.symbolize_keys)
|
37
|
+
else
|
38
|
+
errors.add(field, hash.delete('message'), hash.symbolize_keys)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
class Customer < Base
|
4
|
+
attribute :id, :integer
|
5
|
+
attribute :email, :string
|
6
|
+
attribute :first_name, :string
|
7
|
+
attribute :last_name, :string
|
8
|
+
attribute :additional_first_name, :string
|
9
|
+
attribute :gender, :string
|
10
|
+
attribute :title, :string
|
11
|
+
attribute :nick, :string
|
12
|
+
attribute :maiden_name, :string
|
13
|
+
attribute :adr_street, :string
|
14
|
+
attribute :adr_street_number, :string
|
15
|
+
attribute :adr_post_code, :string
|
16
|
+
attribute :adr_city, :string
|
17
|
+
attribute :birthplace, :string
|
18
|
+
attribute :country_of_birth, :string
|
19
|
+
attribute :adr_country, :string
|
20
|
+
attribute :adr_phone, :string
|
21
|
+
attribute :adr_mobile, :string
|
22
|
+
attribute :adr_fax, :string
|
23
|
+
attribute :adr_businessphone, :string
|
24
|
+
attribute :birthday, :string
|
25
|
+
attribute :is_verified, :string
|
26
|
+
attribute :nationality, :string
|
27
|
+
attribute :marital_status, :string
|
28
|
+
attribute :occupation, :string
|
29
|
+
attribute :religion, :string
|
30
|
+
attribute :id_card_registration_city, :string
|
31
|
+
attribute :id_card_number, :string
|
32
|
+
attribute :id_card_valid_until, :string
|
33
|
+
attribute :preferred_language, :string
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
module Helpers
|
4
|
+
module ActionViewSupport
|
5
|
+
def self.included(base)
|
6
|
+
base.define_singleton_method :model_name do
|
7
|
+
ActiveModel::Name.new(self, nil, resource_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
base.define_method :persisted? do
|
11
|
+
respond_to?(:id) && id.present?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def model_name
|
16
|
+
self.class.model_name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
module Helpers
|
4
|
+
module AttributeDecimalMethods
|
5
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
6
|
+
def attribute_decimal_methods(name)
|
7
|
+
define_method name do
|
8
|
+
value = read_attribute(name)
|
9
|
+
return if value.nil?
|
10
|
+
BigDecimal((value / 100.0).to_s)
|
11
|
+
end
|
12
|
+
|
13
|
+
define_method "#{name}=" do |value|
|
14
|
+
case value
|
15
|
+
when String
|
16
|
+
value = (BigDecimal(value) * 100.0).to_i
|
17
|
+
when Integer
|
18
|
+
value = value
|
19
|
+
when BigDecimal
|
20
|
+
value = (value * 100.0).to_i
|
21
|
+
else
|
22
|
+
raise ArgumentError
|
23
|
+
end
|
24
|
+
|
25
|
+
write_attribute(name, value)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
class Message < Base
|
4
|
+
attribute :id, :integer
|
5
|
+
attribute :subject, :string
|
6
|
+
attribute :type, :string
|
7
|
+
attribute :opened_at, :time
|
8
|
+
attribute :created_at, :time
|
9
|
+
attribute :updated_at, :time
|
10
|
+
attribute :category, :string
|
11
|
+
|
12
|
+
class Content < Base
|
13
|
+
attribute :raw, :string
|
14
|
+
end
|
15
|
+
|
16
|
+
class Attachment < Base
|
17
|
+
attribute :filename, :string
|
18
|
+
attribute :type, :string
|
19
|
+
attribute :content, :string
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
class Transaction < Base
|
4
|
+
attribute :id, :integer
|
5
|
+
attribute :account_id, :string
|
6
|
+
attribute :transaction_type, :string
|
7
|
+
attribute :transaction_type_details, :json
|
8
|
+
attribute :subject, :string
|
9
|
+
attribute :amount, :integer
|
10
|
+
attribute :booking_code, :string
|
11
|
+
attribute :booking_date, :string
|
12
|
+
attribute :value_date, :string
|
13
|
+
attribute :return_transaction_id, :string
|
14
|
+
attribute :currency, :string
|
15
|
+
attribute :created_at, :string
|
16
|
+
attribute :updated_at, :string
|
17
|
+
|
18
|
+
attribute_decimal_methods :amount
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
module Transfer
|
4
|
+
module Classic
|
5
|
+
class Internal < Base
|
6
|
+
attribute :id, :integer
|
7
|
+
attribute :account_id, :string
|
8
|
+
attribute :external_uid, :string
|
9
|
+
attribute :receiver, :string
|
10
|
+
attribute :amount, :integer
|
11
|
+
attribute :subject, :string
|
12
|
+
attribute :created_at, :time
|
13
|
+
attribute :updated_at, :time
|
14
|
+
|
15
|
+
attribute_decimal_methods :amount
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
module Transfer
|
4
|
+
module Classic
|
5
|
+
autoload :Base, 'fidor_api/model/transfer/classic/base'
|
6
|
+
autoload :Internal, 'fidor_api/model/transfer/classic/internal'
|
7
|
+
autoload :SEPA, 'fidor_api/model/transfer/classic/sepa'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
module Transfer
|
4
|
+
class Generic < Model::Base
|
5
|
+
# TODO: Not all params are part of routing_info :(
|
6
|
+
SUPPORTED_ROUTING_TYPES = {
|
7
|
+
'SEPA' => %w[contact_name remote_iban remote_bic bank_name],
|
8
|
+
'FOS_P2P_EMAIL' => %w[email],
|
9
|
+
'FOS_P2P_PHONE' => %w[mobile_phone_number],
|
10
|
+
'FOS_P2P_USERNAME' => %w[username],
|
11
|
+
'FPS' => %w[contact_name remote_account_number remote_sort_code]
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
attribute :id, :string
|
15
|
+
attribute :account_id, :string
|
16
|
+
attribute :external_uid, :string
|
17
|
+
attribute :amount, :integer
|
18
|
+
attribute :currency, :string
|
19
|
+
attribute :subject, :string
|
20
|
+
attribute :beneficiary, :json
|
21
|
+
|
22
|
+
attribute_decimal_methods :amount
|
23
|
+
|
24
|
+
def self.resource_name
|
25
|
+
'Transfer'
|
26
|
+
end
|
27
|
+
|
28
|
+
def beneficiary=(value)
|
29
|
+
write_attribute(:beneficiary, value)
|
30
|
+
define_methods_for(beneficiary['routing_type'])
|
31
|
+
end
|
32
|
+
|
33
|
+
def routing_type
|
34
|
+
@beneficiary ||= {}
|
35
|
+
@beneficiary.dig('routing_type')
|
36
|
+
end
|
37
|
+
|
38
|
+
def routing_type=(type)
|
39
|
+
raise Errors::NotSupported unless SUPPORTED_ROUTING_TYPES.key?(type)
|
40
|
+
@beneficiary ||= {}
|
41
|
+
@beneficiary['routing_type'] = type
|
42
|
+
define_methods_for(type)
|
43
|
+
end
|
44
|
+
|
45
|
+
def define_methods_for(type) # rubocop:disable Metrics/MethodLength
|
46
|
+
SUPPORTED_ROUTING_TYPES[type].each do |name|
|
47
|
+
next if respond_to?(name)
|
48
|
+
|
49
|
+
self.class.define_method name do
|
50
|
+
@beneficiary ||= {}
|
51
|
+
@beneficiary.dig('routing_info', name)
|
52
|
+
end
|
53
|
+
|
54
|
+
self.class.define_method "#{name}=" do |value|
|
55
|
+
@beneficiary ||= {}
|
56
|
+
@beneficiary['routing_info'] ||= {}
|
57
|
+
@beneficiary['routing_info'][name] = value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_errors(body)
|
63
|
+
body['errors'].each do |hash|
|
64
|
+
hash['field'].sub!('beneficiary.routing_info.', '')
|
65
|
+
end
|
66
|
+
super(body)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module FidorApi
|
2
|
+
module Model
|
3
|
+
autoload :Account, 'fidor_api/model/account'
|
4
|
+
autoload :Base, 'fidor_api/model/base'
|
5
|
+
autoload :ConfirmableAction, 'fidor_api/model/confirmable_action'
|
6
|
+
autoload :Customer, 'fidor_api/model/customer'
|
7
|
+
autoload :Helpers, 'fidor_api/model/helpers'
|
8
|
+
autoload :Message, 'fidor_api/model/message'
|
9
|
+
autoload :Transaction, 'fidor_api/model/transaction'
|
10
|
+
autoload :Transfer, 'fidor_api/model/transfer'
|
11
|
+
autoload :User, 'fidor_api/model/user'
|
12
|
+
end
|
13
|
+
end
|
data/lib/fidor_api/token.rb
CHANGED
@@ -1,27 +1,22 @@
|
|
1
1
|
module FidorApi
|
2
|
-
|
3
2
|
class Token
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
ATTRIBUTES = %i[
|
4
|
+
access_token
|
5
|
+
expires_in
|
6
|
+
token_type
|
7
|
+
refresh_token
|
8
|
+
].freeze
|
7
9
|
|
8
|
-
|
9
|
-
expires_at >= Time.now
|
10
|
-
end
|
10
|
+
attr_accessor(*ATTRIBUTES)
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def initialize(args = {})
|
13
|
+
args.each do |key, value|
|
14
|
+
instance_variable_set("@#{key}", value)
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
{
|
18
|
-
access_token: access_token,
|
19
|
-
expires_at: expires_at,
|
20
|
-
token_type: token_type,
|
21
|
-
refresh_token: refresh_token,
|
22
|
-
state: state
|
23
|
-
}
|
18
|
+
def to_h
|
19
|
+
Hash[ATTRIBUTES.map { |key| [key, instance_variable_get("@#{key}")] }]
|
24
20
|
end
|
25
21
|
end
|
26
|
-
|
27
22
|
end
|
data/lib/fidor_api/version.rb
CHANGED
data/lib/fidor_api.rb
CHANGED
@@ -1,62 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require "active_support"
|
3
|
-
require "active_support/core_ext"
|
4
|
-
require "active_model"
|
5
|
-
require "model_attribute"
|
6
|
-
require "json"
|
1
|
+
require 'fidor_api/version'
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
attr_accessor :configuration
|
12
|
-
|
13
|
-
autoload :Account, 'fidor_api/account'
|
14
|
-
autoload :AmountAttributes, 'fidor_api/amount_attributes'
|
15
|
-
autoload :ApprovalRequired, 'fidor_api/approval_required'
|
16
|
-
autoload :Auth, 'fidor_api/auth'
|
17
|
-
autoload :Beneficiary, 'fidor_api/beneficiary'
|
18
|
-
autoload :Card, 'fidor_api/card'
|
19
|
-
autoload :CardLimitAttribute, 'fidor_api/card_limit_attribute'
|
20
|
-
autoload :CardLimits, 'fidor_api/card_limits'
|
21
|
-
autoload :Client, 'fidor_api/client'
|
22
|
-
autoload :Collection, 'fidor_api/collection'
|
23
|
-
autoload :ConfirmableAction, 'fidor_api/confirmable_action'
|
24
|
-
autoload :Connectivity, 'fidor_api/connectivity'
|
25
|
-
autoload :Customer, 'fidor_api/customer'
|
26
|
-
autoload :Customers, 'fidor_api/customers/confirmations'
|
27
|
-
autoload :Message, 'fidor_api/message'
|
28
|
-
autoload :Msisdn, 'fidor_api/msisdn'
|
29
|
-
autoload :Password, 'fidor_api/password'
|
30
|
-
autoload :Preauth, 'fidor_api/preauth'
|
31
|
-
autoload :PreauthDetails, 'fidor_api/preauth_details'
|
32
|
-
autoload :SessionToken, 'fidor_api/session_token'
|
33
|
-
autoload :Token, 'fidor_api/token'
|
34
|
-
autoload :TransactionDetails, 'fidor_api/transaction_details'
|
35
|
-
autoload :Transaction, 'fidor_api/transaction'
|
36
|
-
autoload :Transfer, 'fidor_api/transfer'
|
37
|
-
autoload :User, 'fidor_api/user'
|
38
|
-
autoload :Version, 'fidor_api/version'
|
3
|
+
require 'securerandom'
|
4
|
+
require 'json'
|
39
5
|
|
40
|
-
|
41
|
-
|
42
|
-
|
6
|
+
require 'active_model'
|
7
|
+
require 'faraday'
|
8
|
+
require 'faraday_middleware'
|
9
|
+
require 'model_attribute'
|
43
10
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
yield configuration
|
52
|
-
|
53
|
-
begin
|
54
|
-
require "faraday/detailed_logger"
|
55
|
-
rescue LoadError
|
56
|
-
configuration.logger.debug "NOTE: Install `faraday-detailed_logger` gem to get detailed log-output for debugging."
|
57
|
-
end
|
58
|
-
end
|
11
|
+
module FidorApi
|
12
|
+
autoload :Client, 'fidor_api/client'
|
13
|
+
autoload :Collection, 'fidor_api/collection'
|
14
|
+
autoload :Environment, 'fidor_api/environment'
|
15
|
+
autoload :Errors, 'fidor_api/errors'
|
16
|
+
autoload :Model, 'fidor_api/model'
|
17
|
+
autoload :Token, 'fidor_api/token'
|
59
18
|
end
|
60
|
-
|
61
|
-
require "fidor_api/errors"
|
62
|
-
require "fidor_api/constants"
|