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
@@ -1,45 +0,0 @@
1
- module FidorApi
2
- module Transfer
3
- class P2pPhone < Base
4
- include Generic
5
-
6
- attribute :mobile_phone_number, :string
7
-
8
- validates :mobile_phone_number, presence: true, unless: :beneficiary_reference_passed?
9
-
10
- def set_attributes(attrs = {})
11
- set_beneficiary_attributes(attrs)
12
- self.mobile_phone_number = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["mobile_phone_number"]
13
- super(attrs.except("beneficiary"))
14
- end
15
-
16
- def as_json_routing_type
17
- "FOS_P2P_PHONE"
18
- end
19
-
20
- def as_json_routing_info
21
- {
22
- mobile_phone_number: mobile_phone_number
23
- }
24
- end
25
-
26
- module ClientSupport
27
- def p2p_phone_transfers(options = {})
28
- Transfer::P2pPhone.all(options)
29
- end
30
-
31
- def p2p_phone_transfer(id)
32
- Transfer::P2pPhone.find(id)
33
- end
34
-
35
- def build_p2p_phone_transfer(attributes = {})
36
- Transfer::P2pPhone.new(attributes)
37
- end
38
-
39
- def update_p2p_phone_transfer(id, attributes = {})
40
- Transfer::P2pPhone.new(attributes.merge(id: id))
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,45 +0,0 @@
1
- module FidorApi
2
- module Transfer
3
- class P2pUsername < Base
4
- include Generic
5
-
6
- attribute :username, :string
7
-
8
- validates :username, presence: true, unless: :beneficiary_reference_passed?
9
-
10
- def set_attributes(attrs = {})
11
- set_beneficiary_attributes(attrs)
12
- self.username = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["username"]
13
- super(attrs.except("beneficiary"))
14
- end
15
-
16
- def as_json_routing_type
17
- "FOS_P2P_USERNAME"
18
- end
19
-
20
- def as_json_routing_info
21
- {
22
- username: username
23
- }
24
- end
25
-
26
- module ClientSupport
27
- def p2p_username_transfers(options = {})
28
- Transfer::P2pUsername.all(options)
29
- end
30
-
31
- def p2p_username_transfer(id)
32
- Transfer::P2pUsername.find(id)
33
- end
34
-
35
- def build_p2p_username_transfer(attributes = {})
36
- Transfer::P2pUsername.new(attributes)
37
- end
38
-
39
- def update_p2p_username_transfer(id, attributes = {})
40
- Transfer::P2pUsername.new(attributes.merge(id: id))
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,56 +0,0 @@
1
- module FidorApi
2
- module Transfer
3
- class SEPA < Base
4
- extend ModelAttribute
5
- extend AmountAttributes
6
-
7
- self.endpoint = Connectivity::Endpoint.new('/sepa_credit_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_iban, :string
14
- attribute :remote_bic, :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_iban, :remote_name, :amount, :subject ]
27
- end
28
-
29
- def self.writeable_attributes
30
- required_attributes + [:remote_bic]
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 sepa_transfers(options = {})
43
- Transfer::SEPA.all(options)
44
- end
45
-
46
- def sepa_transfer(id)
47
- Transfer::SEPA.find(id)
48
- end
49
-
50
- def build_sepa_transfer(attributes = {})
51
- Transfer::SEPA.new(attributes)
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,49 +0,0 @@
1
- module FidorApi
2
- module Transfer
3
- class Swift < Base
4
- include Generic
5
-
6
- validates :contact_name, presence: true, unless: :beneficiary_reference_passed?
7
-
8
- attribute :account_number, :string
9
- attribute :swift_code, :string
10
- attribute :account_currency, :string
11
-
12
- validates :account_number, presence: true, unless: :beneficiary_reference_passed?
13
- validates :swift_code, presence: true, unless: :beneficiary_reference_passed?
14
- validates :account_currency, presence: true, unless: :beneficiary_reference_passed?
15
-
16
- def set_attributes(attrs = {})
17
- set_beneficiary_attributes(attrs)
18
- self.account_number = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["account_number"]
19
- self.swift_code = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["swift_code"]
20
- self.account_currency = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["account_currency"]
21
- super(attrs.except("beneficiary"))
22
- end
23
-
24
- def as_json_routing_type
25
- "SWIFT"
26
- end
27
-
28
- def as_json_routing_info
29
- {
30
- account_number: account_number,
31
- swift_code: swift_code,
32
- account_currency: account_currency
33
- }
34
- end
35
-
36
- private
37
-
38
- def remote_create
39
- response = endpoint.for(self).post(payload: self.as_json)
40
-
41
- if path = response.headers["X-Fidor-Confirmation-Path"]
42
- self.confirmable_action = ConfirmableAction.new(id: path.split("/").last)
43
- end
44
-
45
- response
46
- end
47
- end
48
- end
49
- end
@@ -1,50 +0,0 @@
1
- module FidorApi
2
- module Transfer
3
- class Utility < Base
4
- include Generic
5
-
6
- attribute :utility_provider, :string
7
- attribute :utility_service, :string
8
- attribute :utility_service_number, :string
9
- attribute :inquiry_ref_num, :string
10
-
11
- validates :utility_provider, presence: true
12
- validates :utility_service, presence: true
13
- validates :utility_service_number, presence: true
14
- validates :inquiry_ref_num, presence: true
15
-
16
- def set_attributes(attrs = {})
17
- self.utility_provider = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["utility_provider"]
18
- self.utility_service = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["utility_service"]
19
- self.utility_service_number = attrs.fetch("beneficiary", {}).fetch("routing_info", {})["utility_service_number"]
20
- self.inquiry_ref_num = attrs.fetch("routing_info", {})["inquiry_ref_num"]
21
- super(attrs.except("routing_type", "routing_info"))
22
- end
23
-
24
- def as_json_routing_type
25
- "UTILITY"
26
- end
27
-
28
- def as_json_routing_info
29
- {
30
- utility_provider: utility_provider,
31
- utility_service: utility_service,
32
- utility_service_number: utility_service_number,
33
- inquiry_ref_num: inquiry_ref_num
34
- }
35
- end
36
-
37
- private
38
-
39
- def remote_create
40
- response = endpoint.for(self).post(payload: self.as_json)
41
-
42
- if path = response.headers["X-Fidor-Confirmation-Path"]
43
- self.confirmable_action = ConfirmableAction.new(id: path.split("/").last)
44
- end
45
-
46
- response
47
- end
48
- end
49
- end
50
- end
@@ -1,17 +0,0 @@
1
- module FidorApi
2
- module Transfer
3
- autoload :ACH, 'fidor_api/transfer/ach'
4
- autoload :Base, 'fidor_api/transfer/base'
5
- autoload :FPS, 'fidor_api/transfer/fps'
6
- autoload :Generic, 'fidor_api/transfer/generic'
7
- autoload :Internal, 'fidor_api/transfer/internal'
8
- autoload :P2pAccountNumber, 'fidor_api/transfer/p2p_account_number'
9
- autoload :P2pPhone, 'fidor_api/transfer/p2p_phone'
10
- autoload :P2pUsername, 'fidor_api/transfer/p2p_username'
11
- autoload :Pending, 'fidor_api/transfer/pending'
12
- autoload :SEPA, 'fidor_api/transfer/sepa'
13
- autoload :Swift, 'fidor_api/transfer/swift'
14
- autoload :BankInternal, 'fidor_api/transfer/bank_internal'
15
- autoload :Utility, 'fidor_api/transfer/utility'
16
- end
17
- end
@@ -1,24 +0,0 @@
1
- module FidorApi
2
- class User < Connectivity::Resource
3
- extend ModelAttribute
4
-
5
- self.endpoint = Connectivity::Endpoint.new('/users/current', :resource)
6
-
7
- attribute :id, :integer
8
- attribute :email, :string
9
- attribute :msisdn_activated_at, :time
10
- attribute :last_sign_in_at, :string
11
- attribute :created_at, :time
12
- attribute :updated_at, :time
13
-
14
- def self.current
15
- new endpoint.for(self).get.body
16
- end
17
-
18
- module ClientSupport
19
- def current_user
20
- User.current
21
- end
22
- end
23
- end
24
- end