fidor_api 2.0.5 → 2.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8944ad25911d10532ed19ee8bbf5b6968439d9db016c97edce87d3d7da9a3ad1
4
- data.tar.gz: 23d49db5a67f42e7473125add78ca3e0b7e882a84208039fb578cc5e124322b7
3
+ metadata.gz: 5dd37e81db3e11e356adccfa11fb66235fa3370e1220581da482d88417b25442
4
+ data.tar.gz: 7fee31a5205c39f66d15dde3714d07cfbde6e414e6e1a48a0f4e8f7b45802e2d
5
5
  SHA512:
6
- metadata.gz: 8c62f6ccabf05f4e39bb5a9392bf7717e791f4aaf0f19d290e2ee1aa7132b3676c447fd19dc2311178908113eb55b3cd2cd191c970642b8fff510744c88d4e0a
7
- data.tar.gz: 071c692a57132772a0a464e6b4458c0d8ce7fa6f97189302903a3f6750893ed06406a492f76cba1634aa6336b66c884d3c85466712c297c694cbf51fc9555493
6
+ metadata.gz: 49ae375b0fd5100dc744a03713cba67cd77cbc2d4712e9369cf16bf8a7b4967a1e77777d50affd97aee9391cdce83dd6cf772b297b49db90552d3ca58bf10771
7
+ data.tar.gz: 1a0a82c9a8e80dc9dc9d31e6b4b4436c5683943eca65ca6aaea24d42268e60a65106adbac203e85393ba1d6e4b519d2ab9b2fac4fa4474abc8b6853dc50476ec
@@ -3,7 +3,7 @@ module FidorApi
3
3
  module DSL
4
4
  module Accounts
5
5
  def account_transactions(id, options = {})
6
- fetch(:collection, Model::Transaction, "/accounts/#{id}/transactions", options)
6
+ fetch(:collection, Model::Transaction, "accounts/#{id}/transactions", options)
7
7
  end
8
8
  end
9
9
  end
@@ -3,11 +3,11 @@ module FidorApi
3
3
  module DSL
4
4
  module Cards
5
5
  def cards(options = {})
6
- fetch(:collection, Model::Card, '/cards', options)
6
+ fetch(:collection, Model::Card, 'cards', options)
7
7
  end
8
8
 
9
9
  def card(id, options = {})
10
- fetch(:single, Model::Card, "/cards/#{id}", options)
10
+ fetch(:single, Model::Card, "cards/#{id}", options)
11
11
  end
12
12
  end
13
13
  end
@@ -3,15 +3,15 @@ module FidorApi
3
3
  module DSL
4
4
  module ConfirmableActions
5
5
  def confirmable_action(id, options = {})
6
- fetch(:single, Model::ConfirmableAction, "/confirmable/actions/#{id}", options)
6
+ fetch(:single, Model::ConfirmableAction, "confirmable/actions/#{id}", options)
7
7
  end
8
8
 
9
9
  def refresh_confirmable_action(id, options = {})
10
- update(Model::ConfirmableAction, "/confirmable/actions/#{id}/refresh", id, options)
10
+ update(Model::ConfirmableAction, "confirmable/actions/#{id}/refresh", id, options)
11
11
  end
12
12
 
13
13
  def update_confirmable_action(id, attributes = {})
14
- update(Model::ConfirmableAction, "/confirmable/actions/#{id}", id, attributes)
14
+ update(Model::ConfirmableAction, "confirmable/actions/#{id}", id, attributes)
15
15
  end
16
16
  end
17
17
  end
@@ -3,15 +3,15 @@ module FidorApi
3
3
  module DSL
4
4
  module CoreData
5
5
  def user(options = {})
6
- fetch(:single, Model::User, '/users/current', options)
6
+ fetch(:single, Model::User, 'users/current', options)
7
7
  end
8
8
 
9
9
  def customers(options = {})
10
- fetch(:collection, Model::Customer, '/customers', options)
10
+ fetch(:collection, Model::Customer, 'customers', options)
11
11
  end
12
12
 
13
13
  def accounts(options = {})
14
- fetch(:collection, Model::Account, '/accounts', options)
14
+ fetch(:collection, Model::Account, 'accounts', options)
15
15
  end
16
16
  end
17
17
  end
@@ -3,15 +3,15 @@ module FidorApi
3
3
  module DSL
4
4
  module Messages
5
5
  def messages(options = {})
6
- fetch(:collection, Model::Message, '/messages', options)
6
+ fetch(:collection, Model::Message, 'messages', options)
7
7
  end
8
8
 
9
9
  def message(id, options = {})
10
- fetch(:single, Model::Message, "/messages/#{id}", options)
10
+ fetch(:single, Model::Message, "messages/#{id}", options)
11
11
  end
12
12
 
13
13
  def message_attachment(id)
14
- response = connection.get("/messages/#{id}/attachment")
14
+ response = connection.get("messages/#{id}/attachment")
15
15
 
16
16
  Model::Message::Attachment.new(
17
17
  type: response.headers['content-type'],
@@ -21,7 +21,7 @@ module FidorApi
21
21
  end
22
22
 
23
23
  def message_content(id)
24
- response = connection.get("/messages/#{id}/content")
24
+ response = connection.get("messages/#{id}/content")
25
25
 
26
26
  Model::Message::Content.new(raw: response.body)
27
27
  end
@@ -3,11 +3,11 @@ module FidorApi
3
3
  module DSL
4
4
  module Preauths
5
5
  def preauths(options = {})
6
- fetch(:collection, Model::Preauth, '/preauths', options)
6
+ fetch(:collection, Model::Preauth, 'preauths', options)
7
7
  end
8
8
 
9
9
  def preauth(id, options = {})
10
- fetch(:single, Model::Preauth, "/preauths/#{id}", options)
10
+ fetch(:single, Model::Preauth, "preauths/#{id}", options)
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,19 @@
1
+ module FidorApi
2
+ class Client
3
+ module DSL
4
+ module StandingOrders
5
+ def standing_order(id, options = {})
6
+ fetch(:single, FidorApi::Model::StandingOrder, "standing_orders/#{id}", options)
7
+ end
8
+
9
+ def new_standing_order(attributes = {})
10
+ FidorApi::Model::StandingOrder.new(attributes)
11
+ end
12
+
13
+ def create_standing_order(attributes = {})
14
+ create(FidorApi::Model::StandingOrder, 'standing_orders', attributes)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,11 +3,11 @@ module FidorApi
3
3
  module DSL
4
4
  module Transactions
5
5
  def transactions(options = {})
6
- fetch(:collection, Model::Transaction, '/transactions', options)
6
+ fetch(:collection, Model::Transaction, 'transactions', options)
7
7
  end
8
8
 
9
9
  def transaction(id, options = {})
10
- fetch(:single, Model::Transaction, "/transactions/#{id}", options)
10
+ fetch(:single, Model::Transaction, "transactions/#{id}", options)
11
11
  end
12
12
  end
13
13
  end
@@ -5,12 +5,12 @@ module FidorApi
5
5
  module Classic
6
6
  def internal_transfers(options = {})
7
7
  check_transfer_support! :classic
8
- fetch(:collection, FidorApi::Model::Transfer::Classic::Internal, '/internal_transfers', options)
8
+ fetch(:collection, FidorApi::Model::Transfer::Classic::Internal, 'internal_transfers', options)
9
9
  end
10
10
 
11
11
  def internal_transfer(id, options = {})
12
12
  check_transfer_support! :classic
13
- fetch(:single, FidorApi::Model::Transfer::Classic::Internal, "/internal_transfers/#{id}", options)
13
+ fetch(:single, FidorApi::Model::Transfer::Classic::Internal, "internal_transfers/#{id}", options)
14
14
  end
15
15
 
16
16
  def new_internal_transfer(attributes = {})
@@ -20,17 +20,17 @@ module FidorApi
20
20
 
21
21
  def create_internal_transfer(attributes = {})
22
22
  check_transfer_support! :classic
23
- create(FidorApi::Model::Transfer::Classic::Internal, '/internal_transfers', attributes)
23
+ create(FidorApi::Model::Transfer::Classic::Internal, 'internal_transfers', attributes)
24
24
  end
25
25
 
26
26
  def sepa_transfers(options = {})
27
27
  check_transfer_support! :classic
28
- fetch(:collection, FidorApi::Model::Transfer::Classic::SEPA, '/sepa_credit_transfers', options)
28
+ fetch(:collection, FidorApi::Model::Transfer::Classic::SEPA, 'sepa_credit_transfers', options)
29
29
  end
30
30
 
31
31
  def sepa_transfer(id, options = {})
32
32
  check_transfer_support! :classic
33
- fetch(:single, FidorApi::Model::Transfer::Classic::SEPA, "/sepa_credit_transfers/#{id}", options)
33
+ fetch(:single, FidorApi::Model::Transfer::Classic::SEPA, "sepa_credit_transfers/#{id}", options)
34
34
  end
35
35
 
36
36
  def new_sepa_transfer(attributes = {})
@@ -40,7 +40,7 @@ module FidorApi
40
40
 
41
41
  def create_sepa_transfer(attributes = {})
42
42
  check_transfer_support! :classic
43
- create(FidorApi::Model::Transfer::Classic::SEPA, '/sepa_credit_transfers', attributes)
43
+ create(FidorApi::Model::Transfer::Classic::SEPA, 'sepa_credit_transfers', attributes)
44
44
  end
45
45
  end
46
46
  end
@@ -5,12 +5,12 @@ module FidorApi
5
5
  module Generic
6
6
  def transfers(options = {})
7
7
  check_transfer_support! :generic
8
- fetch(:collection, FidorApi::Model::Transfer::Generic, '/transfers', options)
8
+ fetch(:collection, FidorApi::Model::Transfer::Generic, 'transfers', options)
9
9
  end
10
10
 
11
11
  def transfer(id, options = {})
12
12
  check_transfer_support! :generic
13
- fetch(:single, FidorApi::Model::Transfer::Generic, "/transfers/#{id}", options)
13
+ fetch(:single, FidorApi::Model::Transfer::Generic, "transfers/#{id}", options)
14
14
  end
15
15
 
16
16
  def new_transfer(attributes = {})
@@ -18,14 +18,19 @@ module FidorApi
18
18
  Model::Transfer::Generic.new(attributes)
19
19
  end
20
20
 
21
- def create_transfer(attributes = {})
21
+ def create_transfer(attributes = {}, options = {})
22
22
  check_transfer_support! :generic
23
- create(FidorApi::Model::Transfer::Generic, '/transfers', attributes)
23
+ create(FidorApi::Model::Transfer::Generic, 'transfers', attributes, options)
24
24
  end
25
25
 
26
- def update_transfer(id, attributes = {})
26
+ def update_transfer(id, attributes = {}, options = {})
27
27
  check_transfer_support! :generic
28
- update(FidorApi::Model::Transfer::Generic, "/transfers/#{id}", id, attributes)
28
+ update(FidorApi::Model::Transfer::Generic, "transfers/#{id}", id, attributes, options)
29
+ end
30
+
31
+ def confirm_transfer(id, options = {})
32
+ check_transfer_support! :generic
33
+ request(:put, "/transfers/#{id}/confirm", {}, options.delete(:headers)).headers['Location']
29
34
  end
30
35
  end
31
36
  end
@@ -7,6 +7,7 @@ module FidorApi
7
7
  autoload :CoreData, 'fidor_api/client/dsl/core_data'
8
8
  autoload :Messages, 'fidor_api/client/dsl/messages'
9
9
  autoload :Preauths, 'fidor_api/client/dsl/preauths'
10
+ autoload :StandingOrders, 'fidor_api/client/dsl/standing_orders'
10
11
  autoload :Transactions, 'fidor_api/client/dsl/transactions'
11
12
  autoload :Transfers, 'fidor_api/client/dsl/transfers'
12
13
 
@@ -17,6 +18,7 @@ module FidorApi
17
18
  klass.include CoreData
18
19
  klass.include Messages
19
20
  klass.include Preauths
21
+ klass.include StandingOrders
20
22
  klass.include Transactions
21
23
  klass.include Transfers
22
24
  end
@@ -24,28 +26,34 @@ module FidorApi
24
26
  private
25
27
 
26
28
  def fetch(type, klass, endpoint, options)
29
+ headers = options.delete(:headers) || {}
30
+
27
31
  case type
28
32
  when :single
29
- klass.new(connection.get(endpoint, query: options).body)
33
+ klass.new(connection.get(endpoint, query: options, headers: headers).body)
30
34
  when :collection
31
- Collection.new(klass: klass, raw: connection.get(endpoint, query: options).body)
35
+ Collection.new(klass: klass, raw: connection.get(endpoint, query: options, headers: headers).body)
32
36
  else
33
37
  raise ArgumentError
34
38
  end
35
39
  end
36
40
 
37
- def create(klass, endpoint, attributes)
38
- request(klass, endpoint, :post, attributes)
41
+ def create(klass, endpoint, attributes, options = {})
42
+ headers = options.delete(:headers) || {}
43
+
44
+ request_model(klass, endpoint, :post, attributes, headers)
39
45
  end
40
46
 
41
- def update(klass, endpoint, id, attributes, headers = {})
42
- request(klass, endpoint, :put, attributes.merge(id: id), headers)
47
+ def update(klass, endpoint, id, attributes, options = {})
48
+ headers = options.delete(:headers) || {}
49
+
50
+ request_model(klass, endpoint, :put, attributes.merge(id: id), headers)
43
51
  end
44
52
 
45
- def request(klass, endpoint, method, attributes, headers = {}) # rubocop:disable Metrics/AbcSize
53
+ def request_model(klass, endpoint, method, attributes, headers = {}) # rubocop:disable Metrics/AbcSize
46
54
  model = klass.new(attributes)
47
55
  model.tap do |m|
48
- response = connection.public_send(method, endpoint, body: m.as_json, headers: headers)
56
+ response = request(method, endpoint, m.as_json, headers)
49
57
  m.set_attributes(response.body) if response.body.is_a?(Hash)
50
58
  m.confirmable_action_id = extract_confirmable_id(response.headers)
51
59
  end
@@ -55,6 +63,10 @@ module FidorApi
55
63
  model.tap { |m| m.parse_errors(e.response[:body]) }
56
64
  end
57
65
 
66
+ def request(method, endpoint, attributes, headers = {})
67
+ connection.public_send(method, endpoint, body: attributes, headers: headers)
68
+ end
69
+
58
70
  POSSIBLE_CONFIRMABLE_HEADERS = %w[x-fidor-confirmation-path location].freeze
59
71
 
60
72
  def extract_confirmable_id(headers)
@@ -0,0 +1,38 @@
1
+ module FidorApi
2
+ module Model
3
+ module BeneficiaryHelper
4
+ SUPPORTED_ROUTING_TYPES = {
5
+ 'SEPA' => %w[remote_iban remote_bic instant],
6
+ 'FOS_P2P_EMAIL' => %w[email],
7
+ 'FOS_P2P_PHONE' => %w[mobile_phone_number],
8
+ 'FOS_P2P_ACCOUNT_NUMBER' => %w[account_number],
9
+ 'FOS_P2P_USERNAME' => %w[username],
10
+ 'FPS' => %w[remote_account_number remote_sort_code instant]
11
+ }.freeze
12
+
13
+ def define_methods_for(properties) # rubocop:disable Metrics/MethodLength
14
+ properties.each do |name|
15
+ next if respond_to?(name)
16
+
17
+ self.class.define_method name do
18
+ @beneficiary ||= {}
19
+ @beneficiary.dig('routing_info', name)
20
+ end
21
+
22
+ self.class.define_method "#{name}=" do |value|
23
+ @beneficiary ||= {}
24
+ @beneficiary['routing_info'] ||= {}
25
+ @beneficiary['routing_info'][name] = value
26
+ end
27
+ end
28
+ end
29
+
30
+ def parse_errors(body)
31
+ body['errors'].each do |hash|
32
+ hash['field'].sub!('beneficiary.routing_info.', '')
33
+ end
34
+ super(body)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,50 @@
1
+ require 'fidor_api/model/beneficiary_helper'
2
+
3
+ module FidorApi
4
+ module Model
5
+ class StandingOrder < Model::Base
6
+ include BeneficiaryHelper
7
+
8
+ attribute :id, :string
9
+ attribute :account_id, :string
10
+ attribute :external_uid, :string
11
+ attribute :amount, :integer
12
+ attribute :currency, :string
13
+ attribute :subject, :string
14
+ attribute :beneficiary, :json
15
+ attribute :schedule, :json
16
+
17
+ attribute_decimal_methods :amount
18
+
19
+ def beneficiary=(value)
20
+ write_attribute(:beneficiary, value)
21
+ define_methods_for(SUPPORTED_ROUTING_TYPES[beneficiary['routing_type']])
22
+ end
23
+
24
+ def routing_type
25
+ @beneficiary ||= {}
26
+ @beneficiary.dig('routing_type')
27
+ end
28
+
29
+ def routing_type=(type)
30
+ raise Errors::NotSupported unless SUPPORTED_ROUTING_TYPES.key?(type)
31
+
32
+ @beneficiary ||= {}
33
+ @beneficiary['routing_type'] = type
34
+ define_methods_for(SUPPORTED_ROUTING_TYPES[type])
35
+ end
36
+
37
+ %w[rhythm runtime_day_of_month runtime_day_of_week start_date ultimate_run].each do |attribute|
38
+ define_method attribute do
39
+ @schedule ||= {}
40
+ @schedule[attribute]
41
+ end
42
+
43
+ define_method "#{attribute}=" do |value|
44
+ @schedule ||= {}
45
+ @schedule[attribute] = value
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,15 +1,10 @@
1
+ require 'fidor_api/model/beneficiary_helper'
2
+
1
3
  module FidorApi
2
4
  module Model
3
5
  module Transfer
4
6
  class Generic < Model::Base
5
- SUPPORTED_ROUTING_TYPES = {
6
- 'SEPA' => %w[remote_iban remote_bic instant],
7
- 'FOS_P2P_EMAIL' => %w[email],
8
- 'FOS_P2P_PHONE' => %w[mobile_phone_number],
9
- 'FOS_P2P_ACCOUNT_NUMBER' => %w[account_number],
10
- 'FOS_P2P_USERNAME' => %w[username],
11
- 'FPS' => %w[remote_account_number remote_sort_code instant]
12
- }.freeze
7
+ include BeneficiaryHelper
13
8
 
14
9
  attribute :id, :string
15
10
  attribute :account_id, :string
@@ -28,7 +23,7 @@ module FidorApi
28
23
 
29
24
  def beneficiary=(value)
30
25
  write_attribute(:beneficiary, value)
31
- define_methods_for(beneficiary['routing_type'])
26
+ define_methods_for(SUPPORTED_ROUTING_TYPES[beneficiary['routing_type']])
32
27
  end
33
28
 
34
29
  def routing_type
@@ -41,24 +36,7 @@ module FidorApi
41
36
 
42
37
  @beneficiary ||= {}
43
38
  @beneficiary['routing_type'] = type
44
- define_methods_for(type)
45
- end
46
-
47
- def define_methods_for(type) # rubocop:disable Metrics/MethodLength
48
- SUPPORTED_ROUTING_TYPES[type].each do |name|
49
- next if respond_to?(name)
50
-
51
- self.class.define_method name do
52
- @beneficiary ||= {}
53
- @beneficiary.dig('routing_info', name)
54
- end
55
-
56
- self.class.define_method "#{name}=" do |value|
57
- @beneficiary ||= {}
58
- @beneficiary['routing_info'] ||= {}
59
- @beneficiary['routing_info'][name] = value
60
- end
61
- end
39
+ define_methods_for(SUPPORTED_ROUTING_TYPES[type])
62
40
  end
63
41
 
64
42
  %w[bank contact].each do |category|
@@ -75,13 +53,6 @@ module FidorApi
75
53
  end
76
54
  end
77
55
  end
78
-
79
- def parse_errors(body)
80
- body['errors'].each do |hash|
81
- hash['field'].sub!('beneficiary.routing_info.', '')
82
- end
83
- super(body)
84
- end
85
56
  end
86
57
  end
87
58
  end
@@ -8,6 +8,7 @@ module FidorApi
8
8
  autoload :Helpers, 'fidor_api/model/helpers'
9
9
  autoload :Message, 'fidor_api/model/message'
10
10
  autoload :Preauth, 'fidor_api/model/preauth'
11
+ autoload :StandingOrder, 'fidor_api/model/standing_order'
11
12
  autoload :Transaction, 'fidor_api/model/transaction'
12
13
  autoload :Transfer, 'fidor_api/model/transfer'
13
14
  autoload :User, 'fidor_api/model/user'
@@ -1,3 +1,3 @@
1
1
  module FidorApi
2
- VERSION = '2.0.5'.freeze
2
+ VERSION = '2.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fidor_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fidor Solutions AG
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.2'
69
- - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.16'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.16'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: byebug
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +114,14 @@ dependencies:
128
114
  requirements:
129
115
  - - '='
130
116
  - !ruby/object:Gem::Version
131
- version: 0.60.0
117
+ version: 0.62.0
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - '='
137
123
  - !ruby/object:Gem::Version
138
- version: 0.60.0
124
+ version: 0.62.0
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: simplecov
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -185,6 +171,7 @@ files:
185
171
  - lib/fidor_api/client/dsl/core_data.rb
186
172
  - lib/fidor_api/client/dsl/messages.rb
187
173
  - lib/fidor_api/client/dsl/preauths.rb
174
+ - lib/fidor_api/client/dsl/standing_orders.rb
188
175
  - lib/fidor_api/client/dsl/transactions.rb
189
176
  - lib/fidor_api/client/dsl/transfers.rb
190
177
  - lib/fidor_api/client/dsl/transfers/classic.rb
@@ -201,6 +188,7 @@ files:
201
188
  - lib/fidor_api/model.rb
202
189
  - lib/fidor_api/model/account.rb
203
190
  - lib/fidor_api/model/base.rb
191
+ - lib/fidor_api/model/beneficiary_helper.rb
204
192
  - lib/fidor_api/model/card.rb
205
193
  - lib/fidor_api/model/confirmable_action.rb
206
194
  - lib/fidor_api/model/customer.rb
@@ -209,6 +197,7 @@ files:
209
197
  - lib/fidor_api/model/helpers/attribute_decimal_methods.rb
210
198
  - lib/fidor_api/model/message.rb
211
199
  - lib/fidor_api/model/preauth.rb
200
+ - lib/fidor_api/model/standing_order.rb
212
201
  - lib/fidor_api/model/transaction.rb
213
202
  - lib/fidor_api/model/transfer.rb
214
203
  - lib/fidor_api/model/transfer/classic.rb