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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -49
  3. data/Rakefile +6 -3
  4. data/lib/fidor_api/client/authentication.rb +63 -0
  5. data/lib/fidor_api/client/configuration.rb +32 -0
  6. data/lib/fidor_api/client/connection.rb +56 -0
  7. data/lib/fidor_api/client/dsl/confirmable_actions.rb +19 -0
  8. data/lib/fidor_api/client/dsl/core_data.rb +19 -0
  9. data/lib/fidor_api/client/dsl/messages.rb +31 -0
  10. data/lib/fidor_api/client/dsl/transactions.rb +15 -0
  11. data/lib/fidor_api/client/dsl/transfers/classic.rb +29 -0
  12. data/lib/fidor_api/client/dsl/transfers/generic.rb +34 -0
  13. data/lib/fidor_api/client/dsl/transfers.rb +22 -0
  14. data/lib/fidor_api/client/dsl.rb +59 -0
  15. data/lib/fidor_api/client.rb +17 -21
  16. data/lib/fidor_api/collection/kaminari_support.rb +17 -0
  17. data/lib/fidor_api/collection.rb +18 -34
  18. data/lib/fidor_api/environment/base.rb +21 -0
  19. data/lib/fidor_api/environment/fidor_de/production.rb +23 -0
  20. data/lib/fidor_api/environment/fidor_de/sandbox.rb +23 -0
  21. data/lib/fidor_api/environment/fidor_de.rb +8 -0
  22. data/lib/fidor_api/environment/future.rb +21 -0
  23. data/lib/fidor_api/environment.rb +7 -0
  24. data/lib/fidor_api/errors.rb +3 -26
  25. data/lib/fidor_api/model/account.rb +25 -0
  26. data/lib/fidor_api/model/base.rb +44 -0
  27. data/lib/fidor_api/model/confirmable_action.rb +9 -0
  28. data/lib/fidor_api/model/customer.rb +36 -0
  29. data/lib/fidor_api/model/helpers/action_view_support.rb +21 -0
  30. data/lib/fidor_api/model/helpers/attribute_decimal_methods.rb +32 -0
  31. data/lib/fidor_api/model/helpers.rb +8 -0
  32. data/lib/fidor_api/model/message.rb +23 -0
  33. data/lib/fidor_api/model/transaction.rb +21 -0
  34. data/lib/fidor_api/model/transfer/classic/base.rb +15 -0
  35. data/lib/fidor_api/model/transfer/classic/internal.rb +20 -0
  36. data/lib/fidor_api/model/transfer/classic/sepa.rb +11 -0
  37. data/lib/fidor_api/model/transfer/classic.rb +11 -0
  38. data/lib/fidor_api/model/transfer/generic.rb +71 -0
  39. data/lib/fidor_api/model/transfer.rb +8 -0
  40. data/lib/fidor_api/model/user.rb +10 -0
  41. data/lib/fidor_api/model.rb +13 -0
  42. data/lib/fidor_api/token.rb +13 -18
  43. data/lib/fidor_api/version.rb +1 -1
  44. data/lib/fidor_api.rb +14 -58
  45. metadata +152 -89
  46. data/.gitignore +0 -11
  47. data/.rspec +0 -2
  48. data/.ruby-gemset +0 -1
  49. data/.ruby-version +0 -1
  50. data/.travis.yml +0 -20
  51. data/CHANGELOG.md +0 -129
  52. data/Gemfile +0 -15
  53. data/LICENSE.txt +0 -21
  54. data/bin/console +0 -14
  55. data/bin/setup +0 -7
  56. data/fidor_api.gemspec +0 -24
  57. data/lib/fidor_api/account.rb +0 -45
  58. data/lib/fidor_api/amount_attributes.rb +0 -30
  59. data/lib/fidor_api/approval_required.rb +0 -9
  60. data/lib/fidor_api/auth.rb +0 -45
  61. data/lib/fidor_api/beneficiary/ach.rb +0 -39
  62. data/lib/fidor_api/beneficiary/base.rb +0 -118
  63. data/lib/fidor_api/beneficiary/generic.rb +0 -24
  64. data/lib/fidor_api/beneficiary/p2p_account_number.rb +0 -14
  65. data/lib/fidor_api/beneficiary/p2p_phone.rb +0 -14
  66. data/lib/fidor_api/beneficiary/p2p_username.rb +0 -14
  67. data/lib/fidor_api/beneficiary/swift.rb +0 -35
  68. data/lib/fidor_api/beneficiary/unknown.rb +0 -16
  69. data/lib/fidor_api/beneficiary/utility.rb +0 -35
  70. data/lib/fidor_api/beneficiary.rb +0 -27
  71. data/lib/fidor_api/card.rb +0 -77
  72. data/lib/fidor_api/card_limit_attribute.rb +0 -52
  73. data/lib/fidor_api/card_limits.rb +0 -14
  74. data/lib/fidor_api/confirmable_action.rb +0 -45
  75. data/lib/fidor_api/connectivity/connection.rb +0 -113
  76. data/lib/fidor_api/connectivity/endpoint.rb +0 -82
  77. data/lib/fidor_api/connectivity/resource.rb +0 -76
  78. data/lib/fidor_api/connectivity.rb +0 -17
  79. data/lib/fidor_api/constants.rb +0 -3
  80. data/lib/fidor_api/customer.rb +0 -140
  81. data/lib/fidor_api/customers/confirmations.rb +0 -19
  82. data/lib/fidor_api/message.rb +0 -52
  83. data/lib/fidor_api/msisdn.rb +0 -45
  84. data/lib/fidor_api/password.rb +0 -29
  85. data/lib/fidor_api/preauth.rb +0 -33
  86. data/lib/fidor_api/preauth_details.rb +0 -97
  87. data/lib/fidor_api/session_token.rb +0 -20
  88. data/lib/fidor_api/transaction.rb +0 -37
  89. data/lib/fidor_api/transaction_details.rb +0 -119
  90. data/lib/fidor_api/transfer/ach.rb +0 -46
  91. data/lib/fidor_api/transfer/bank_internal.rb +0 -37
  92. data/lib/fidor_api/transfer/base.rb +0 -36
  93. data/lib/fidor_api/transfer/fps.rb +0 -56
  94. data/lib/fidor_api/transfer/generic.rb +0 -134
  95. data/lib/fidor_api/transfer/internal.rb +0 -53
  96. data/lib/fidor_api/transfer/p2p_account_number.rb +0 -45
  97. data/lib/fidor_api/transfer/p2p_phone.rb +0 -45
  98. data/lib/fidor_api/transfer/p2p_username.rb +0 -45
  99. data/lib/fidor_api/transfer/sepa.rb +0 -56
  100. data/lib/fidor_api/transfer/swift.rb +0 -49
  101. data/lib/fidor_api/transfer/utility.rb +0 -50
  102. data/lib/fidor_api/transfer.rb +0 -17
  103. 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,8 @@
1
+ module FidorApi
2
+ module Environment
3
+ module FidorDE
4
+ autoload :Sandbox, 'fidor_api/environment/fidor_de/sandbox'
5
+ autoload :Production, 'fidor_api/environment/fidor_de/production'
6
+ end
7
+ end
8
+ 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
@@ -0,0 +1,7 @@
1
+ module FidorApi
2
+ module Environment
3
+ autoload :Base, 'fidor_api/environment/base'
4
+ autoload :FidorDE, 'fidor_api/environment/fidor_de'
5
+ autoload :Future, 'fidor_api/environment/future'
6
+ end
7
+ end
@@ -1,29 +1,6 @@
1
1
  module FidorApi
2
-
3
- Error = Class.new(StandardError)
4
- ClientError = Class.new(Error)
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,9 @@
1
+ module FidorApi
2
+ module Model
3
+ class ConfirmableAction < Base
4
+ attribute :id, :string
5
+ attribute :type, :string
6
+ attribute :otp, :string
7
+ end
8
+ end
9
+ 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,8 @@
1
+ module FidorApi
2
+ module Model
3
+ module Helpers
4
+ autoload :ActionViewSupport, 'fidor_api/model/helpers/action_view_support'
5
+ autoload :AttributeDecimalMethods, 'fidor_api/model/helpers/attribute_decimal_methods'
6
+ end
7
+ end
8
+ 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,15 @@
1
+ module FidorApi
2
+ module Model
3
+ module Transfer
4
+ module Classic
5
+ class Base < Model::Base
6
+ class << self
7
+ def resource_name
8
+ name.sub('FidorApi::Model::Transfer::Classic::', 'Transfer::')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ 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
+ class SEPA < Base
6
+ attribute :id, :integer
7
+ end
8
+ end
9
+ end
10
+ end
11
+ 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,8 @@
1
+ module FidorApi
2
+ module Model
3
+ module Transfer
4
+ autoload :Classic, 'fidor_api/model/transfer/classic'
5
+ autoload :Generic, 'fidor_api/model/transfer/generic'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module FidorApi
2
+ module Model
3
+ class User < Base
4
+ attribute :id, :integer
5
+ attribute :email, :string
6
+ attribute :affiliate_uid, :string
7
+ attribute :msisdn, :string
8
+ end
9
+ end
10
+ 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
@@ -1,27 +1,22 @@
1
1
  module FidorApi
2
-
3
2
  class Token
4
- include ActiveModel::Model
5
-
6
- attr_accessor :access_token, :expires_at, :token_type, :refresh_token, :state
3
+ ATTRIBUTES = %i[
4
+ access_token
5
+ expires_in
6
+ token_type
7
+ refresh_token
8
+ ].freeze
7
9
 
8
- def valid?
9
- expires_at >= Time.now
10
- end
10
+ attr_accessor(*ATTRIBUTES)
11
11
 
12
- def expires_in=(value)
13
- self.expires_at = Time.now + value.seconds
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 to_hash
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
@@ -1,3 +1,3 @@
1
1
  module FidorApi
2
- VERSION = "1.0.0"
2
+ VERSION = '2.0.0.alpha1'.freeze
3
3
  end
data/lib/fidor_api.rb CHANGED
@@ -1,62 +1,18 @@
1
- require "faraday"
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
- module FidorApi
9
- extend self
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
- class Configuration
41
- attr_accessor :callback_url, :oauth_url, :api_url, :api_path, :client_id, :client_secret, :htauth_user, :htauth_password, :affiliate_uid, :os_type, :logging, :logger, :verify_ssl
42
- end
6
+ require 'active_model'
7
+ require 'faraday'
8
+ require 'faraday_middleware'
9
+ require 'model_attribute'
43
10
 
44
- def configure
45
- self.configuration = Configuration.new.tap do |config|
46
- config.logging = true
47
- config.logger = Logger.new(STDOUT)
48
- config.os_type = "iOS" # NOTE: As long as there is only iOS or Android we have to tell a fib ;)
49
- config.verify_ssl = true
50
- end
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"