modulr-api 0.0.15 → 0.0.17
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/Gemfile.lock +1 -1
- data/README.md +14 -1
- data/lib/modulr/api/accounts_service.rb +2 -2
- data/lib/modulr/api/customers_service.rb +1 -1
- data/lib/modulr/api/notifications_service.rb +13 -3
- data/lib/modulr/api/payments_service.rb +3 -3
- data/lib/modulr/api/transactions_service.rb +1 -1
- data/lib/modulr/auth/signature.rb +1 -1
- data/lib/modulr/client.rb +4 -0
- data/lib/modulr/resources/accounts/account.rb +3 -3
- data/lib/modulr/resources/accounts/identifiers.rb +2 -2
- data/lib/modulr/resources/base.rb +7 -4
- data/lib/modulr/resources/base_collection.rb +5 -4
- data/lib/modulr/resources/notifications/collection.rb +2 -2
- data/lib/modulr/resources/notifications/notification.rb +3 -3
- data/lib/modulr/resources/payments/collection.rb +2 -2
- data/lib/modulr/resources/payments/counterparty.rb +19 -0
- data/lib/modulr/resources/payments/details/incoming/general.rb +40 -0
- data/lib/modulr/resources/payments/details/outgoing/general.rb +25 -0
- data/lib/modulr/resources/payments/payment.rb +12 -3
- data/lib/modulr/resources/transactions/collection.rb +2 -2
- data/lib/modulr/resources/transactions/transaction.rb +2 -2
- data/lib/modulr/version.rb +1 -1
- metadata +5 -3
- data/lib/modulr/resources/payments/details.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 756d629d0ce81b092c226a12364e51addeb7df40d6101fa9a2f195e5da406fac
|
4
|
+
data.tar.gz: ae23bf413271bf36cd6d256f5cfac0edd588377cb17a6fa2c2eb12163b4b5052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13b76b1d357a1c7175fc8e2740d77f66aec500fc88172bbba17130a1bdc9afd788f82352a1bb5f963512226c687e9ab80121aa413c41dc8bb176845396041b1a
|
7
|
+
data.tar.gz: 21f648f6656e2c933c8fc076b543da98b9e063dd28988d1ca48111ddbe579c5f6eafd913b0bff057e4b607c7d5936109d8464524ee9fc2773ae003c0ae4f11fb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,13 @@ client.payments.list(from: DateTime.now - 1, to: DateTime.now)
|
|
56
56
|
client.payments.create(account_id: "A2188C26", currency: "EUR", amount: 0.01, destination: { type: "IBAN", iban: "ES8601280011390100072676", name: "Aitor García Rey" }, reference: "The reference")
|
57
57
|
```
|
58
58
|
|
59
|
+
### Transactions
|
60
|
+
|
61
|
+
```rb
|
62
|
+
# List transactions
|
63
|
+
client.transactions.list(account_id: "A2188C26", credit: true)
|
64
|
+
```
|
65
|
+
|
59
66
|
### Notifications
|
60
67
|
|
61
68
|
### Supported event types per channel
|
@@ -89,9 +96,15 @@ Supported via email:
|
|
89
96
|
|
90
97
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
91
98
|
|
92
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
99
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
100
|
+
|
101
|
+
To release a new version, on main branch update the version number in `version.rb`, then:
|
93
102
|
|
94
103
|
```git
|
104
|
+
bundle exec rake install
|
105
|
+
git add .
|
106
|
+
git commit -m 'Update version file and gemfile'
|
107
|
+
git push
|
95
108
|
git tag vx.x.x main
|
96
109
|
git push origin vx.x.x
|
97
110
|
```
|
@@ -5,7 +5,7 @@ module Modulr
|
|
5
5
|
class AccountsService < Service
|
6
6
|
def find(id:)
|
7
7
|
response = client.get("/accounts/#{id}")
|
8
|
-
Resources::Accounts::Account.new(response, response.body)
|
8
|
+
Resources::Accounts::Account.new(response.env[:raw_body], response.body)
|
9
9
|
end
|
10
10
|
|
11
11
|
def create(customer_id:, currency:, product_code:, **opts)
|
@@ -16,7 +16,7 @@ module Modulr
|
|
16
16
|
payload[:externalReference] = opts[:external_reference] if opts[:external_reference]
|
17
17
|
|
18
18
|
response = client.post("/customers/#{customer_id}/accounts", payload)
|
19
|
-
Resources::Accounts::Account.new(response, response.body)
|
19
|
+
Resources::Accounts::Account.new(response.env[:raw_body], response.body)
|
20
20
|
end
|
21
21
|
|
22
22
|
def close(account_id:)
|
@@ -5,7 +5,7 @@ module Modulr
|
|
5
5
|
class CustomersService < Service
|
6
6
|
def find(id:)
|
7
7
|
response = client.get("/customers/#{id}")
|
8
|
-
Resources::Customers::Customer.new(response, response.body)
|
8
|
+
Resources::Customers::Customer.new(response.env[:raw_body], response.body)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -5,12 +5,12 @@ module Modulr
|
|
5
5
|
class NotificationsService < Service
|
6
6
|
def find(id:, **opts)
|
7
7
|
response = client.get("#{base_notification_url(opts)}/notifications/#{id}")
|
8
|
-
Resources::Notifications::Notification.new(response, response.body)
|
8
|
+
Resources::Notifications::Notification.new(response.env[:raw_body], response.body)
|
9
9
|
end
|
10
10
|
|
11
11
|
def list(**opts)
|
12
12
|
response = client.get("#{base_notification_url(opts)}/notifications")
|
13
|
-
Resources::Notifications::Collection.new(response, response.body)
|
13
|
+
Resources::Notifications::Collection.new(response.env[:raw_body], response.body)
|
14
14
|
end
|
15
15
|
|
16
16
|
def create(type:, channel:, destinations:, config:, **opts)
|
@@ -21,7 +21,17 @@ module Modulr
|
|
21
21
|
config: config,
|
22
22
|
}
|
23
23
|
response = client.post("#{base_notification_url(opts)}/notifications", payload)
|
24
|
-
Resources::Notifications::Notification.new(response, response.body)
|
24
|
+
Resources::Notifications::Notification.new(response.env[:raw_body], response.body)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update(id:, status:, destinations:, config:, **opts)
|
28
|
+
payload = {
|
29
|
+
status: status,
|
30
|
+
destinations: destinations,
|
31
|
+
config: config,
|
32
|
+
}
|
33
|
+
response = client.put("#{base_notification_url(opts)}/notifications/#{id}", payload)
|
34
|
+
Resources::Notifications::Notification.new(response.env[:raw_body], response.body)
|
25
35
|
end
|
26
36
|
|
27
37
|
protected def base_notification_url(opts)
|
@@ -8,14 +8,14 @@ module Modulr
|
|
8
8
|
payment_attributes = response.body[:content]&.first
|
9
9
|
raise NotFoundError, "Payment #{id} not found" unless payment_attributes
|
10
10
|
|
11
|
-
Resources::Payments::Payment.new(response, payment_attributes)
|
11
|
+
Resources::Payments::Payment.new(response.env[:raw_body], payment_attributes)
|
12
12
|
end
|
13
13
|
|
14
14
|
def list(**opts)
|
15
15
|
return find(id: opts[:id]) if opts[:id]
|
16
16
|
|
17
17
|
response = client.get("/payments", build_query_params(opts))
|
18
|
-
Resources::Payments::Collection.new(response, response.body[:content])
|
18
|
+
Resources::Payments::Collection.new(response.env[:raw_body], response.body[:content])
|
19
19
|
end
|
20
20
|
|
21
21
|
# rubocop:disable Metrics/ParameterLists
|
@@ -32,7 +32,7 @@ module Modulr
|
|
32
32
|
payload[:endToEndReference] = opts[:e2e_reference] if opts[:e2e_reference]
|
33
33
|
|
34
34
|
response = client.post("/payments", payload)
|
35
|
-
Resources::Payments::Payment.new(response, response.body)
|
35
|
+
Resources::Payments::Payment.new(response.env[:raw_body], response.body)
|
36
36
|
end
|
37
37
|
# rubocop:enable Metrics/ParameterLists
|
38
38
|
|
@@ -5,7 +5,7 @@ module Modulr
|
|
5
5
|
class TransactionsService < Service
|
6
6
|
def list(account_id:, **opts)
|
7
7
|
response = client.get("/accounts/#{account_id}/transactions", build_query_params(opts))
|
8
|
-
Resources::Transactions::Transactions.new(response, response.body[:content])
|
8
|
+
Resources::Transactions::Transactions.new(response.env[:raw_body], response.body[:content])
|
9
9
|
end
|
10
10
|
|
11
11
|
private def build_query_params(opts) # rubocop:disable Metrics/AbcSize
|
@@ -30,7 +30,7 @@ module Modulr
|
|
30
30
|
apisecret.dup.force_encoding("UTF-8"),
|
31
31
|
signature_string.dup.force_encoding("UTF-8")
|
32
32
|
)
|
33
|
-
b64 = Base64.
|
33
|
+
b64 = Base64.strict_encode64(digest)
|
34
34
|
url_safe_code = ERB::Util.url_encode(b64.strip)
|
35
35
|
|
36
36
|
new(apikey: apikey, nonce: nonce, signature: url_safe_code, timestamp: timestamp)
|
data/lib/modulr/client.rb
CHANGED
@@ -23,9 +23,9 @@ module Modulr
|
|
23
23
|
map :createdDate, :created_at
|
24
24
|
map :directDebit, :direct_debit
|
25
25
|
|
26
|
-
def initialize(
|
27
|
-
super(
|
28
|
-
@identifiers = Accounts::Identifiers.new(
|
26
|
+
def initialize(raw_response, attributes = {})
|
27
|
+
super(raw_response, attributes)
|
28
|
+
@identifiers = Accounts::Identifiers.new(nil, attributes[:identifiers])
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -4,8 +4,8 @@ module Modulr
|
|
4
4
|
module Resources
|
5
5
|
module Accounts
|
6
6
|
class Identifiers < BaseCollection
|
7
|
-
def initialize(
|
8
|
-
super(
|
7
|
+
def initialize(raw_response, attributes_collection)
|
8
|
+
super(raw_response, Identifier, attributes_collection)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -3,10 +3,11 @@
|
|
3
3
|
module Modulr
|
4
4
|
module Resources
|
5
5
|
class Base
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :raw_response
|
7
|
+
|
8
|
+
def initialize(raw_response, attributes = {})
|
9
|
+
@raw_response = raw_response
|
7
10
|
|
8
|
-
def initialize(response, attributes = {})
|
9
|
-
@response = response
|
10
11
|
attributes.each do |key, value|
|
11
12
|
m = "#{key}=".to_sym
|
12
13
|
send(m, value) if respond_to?(m)
|
@@ -34,7 +35,9 @@ require_relative "notifications/notification"
|
|
34
35
|
require_relative "notifications/config"
|
35
36
|
require_relative "notifications/collection"
|
36
37
|
require_relative "payments/payment"
|
37
|
-
require_relative "payments/
|
38
|
+
require_relative "payments/counterparty"
|
39
|
+
require_relative "payments/details/incoming/general"
|
40
|
+
require_relative "payments/details/outgoing/general"
|
38
41
|
require_relative "payments/destination"
|
39
42
|
require_relative "payments/collection"
|
40
43
|
require_relative "transactions/transaction"
|
@@ -3,13 +3,14 @@
|
|
3
3
|
module Modulr
|
4
4
|
module Resources
|
5
5
|
class BaseCollection
|
6
|
+
attr_reader :raw_response
|
7
|
+
|
6
8
|
include Enumerable
|
7
|
-
attr_reader :response
|
8
9
|
|
9
|
-
def initialize(
|
10
|
-
@
|
10
|
+
def initialize(raw_response, item_klass, attributes_collection = [])
|
11
|
+
@raw_response = raw_response
|
11
12
|
@attributes_collection = attributes_collection
|
12
|
-
@items = attributes_collection.map { |attributes_item| item_klass.new(
|
13
|
+
@items = attributes_collection.map { |attributes_item| item_klass.new(nil, attributes_item) }
|
13
14
|
end
|
14
15
|
|
15
16
|
def each(&block)
|
@@ -4,8 +4,8 @@ module Modulr
|
|
4
4
|
module Resources
|
5
5
|
module Notifications
|
6
6
|
class Collection < BaseCollection
|
7
|
-
def initialize(
|
8
|
-
super(
|
7
|
+
def initialize(raw_response, attributes_collection)
|
8
|
+
super(raw_response, Notification, attributes_collection)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -12,9 +12,9 @@ module Modulr
|
|
12
12
|
map :status
|
13
13
|
map :destinations
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
super(
|
17
|
-
@config = Config.new(
|
15
|
+
def initialize(raw_response, attributes = {})
|
16
|
+
super(raw_response, attributes)
|
17
|
+
@config = Config.new(nil, attributes[:config])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -4,8 +4,8 @@ module Modulr
|
|
4
4
|
module Resources
|
5
5
|
module Payments
|
6
6
|
class Collection < BaseCollection
|
7
|
-
def initialize(
|
8
|
-
super(
|
7
|
+
def initialize(raw_response, attributes_collection)
|
8
|
+
super(raw_response, Payment, attributes_collection)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Modulr
|
4
|
+
module Resources
|
5
|
+
module Payments
|
6
|
+
class Counterparty < Base
|
7
|
+
attr_reader :identifier
|
8
|
+
|
9
|
+
map :name
|
10
|
+
map :address
|
11
|
+
|
12
|
+
def initialize(raw_response, attributes = {})
|
13
|
+
super(raw_response, attributes)
|
14
|
+
@identifier = Accounts::Identifier.new(nil, attributes[:identifier])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Modulr
|
4
|
+
module Resources
|
5
|
+
module Payments
|
6
|
+
module Details
|
7
|
+
module Incoming
|
8
|
+
class General < Base
|
9
|
+
attr_reader :payer, :payee
|
10
|
+
|
11
|
+
map :created, :created_at
|
12
|
+
map :posted, :posted_at
|
13
|
+
map :retryCount, :retry_count
|
14
|
+
map :reprocess
|
15
|
+
map :sourceService, :source_service
|
16
|
+
map :providerCode, :provider_code
|
17
|
+
map :ledgerBankCode, :ledger_bank_code
|
18
|
+
map :clearingRequired, :clearing_required
|
19
|
+
map :requestReference, :request_reference
|
20
|
+
map :accountNumber, :account_number
|
21
|
+
map :type
|
22
|
+
map :amount
|
23
|
+
map :currency
|
24
|
+
map :description
|
25
|
+
map :originalReference, :original_reference
|
26
|
+
map :schemeId, :scheme_id
|
27
|
+
map :schemeType, :scheme_type
|
28
|
+
map :details, :raw_details
|
29
|
+
|
30
|
+
def initialize(raw_response, attributes = {})
|
31
|
+
super(raw_response, attributes)
|
32
|
+
@payer = Counterparty.new(nil, attributes[:payer])
|
33
|
+
@payee = Counterparty.new(nil, attributes[:payee])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Modulr
|
4
|
+
module Resources
|
5
|
+
module Payments
|
6
|
+
module Details
|
7
|
+
module Outgoing
|
8
|
+
class General < Base
|
9
|
+
attr_reader :destination
|
10
|
+
|
11
|
+
map :sourceAccountId, :source_account_id
|
12
|
+
map :currency
|
13
|
+
map :amount
|
14
|
+
map :reference
|
15
|
+
|
16
|
+
def initialize(raw_response, attributes = {})
|
17
|
+
super(raw_response, attributes)
|
18
|
+
@destination = Destination.new(nil, attributes[:destination])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -13,9 +13,18 @@ module Modulr
|
|
13
13
|
map :createdDate, :created_at
|
14
14
|
map :approvalStatus, :approval_status
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
super(
|
18
|
-
@details =
|
16
|
+
def initialize(raw_response, attributes = {})
|
17
|
+
super(raw_response, attributes)
|
18
|
+
@details = parse_details(attributes[:details])
|
19
|
+
end
|
20
|
+
|
21
|
+
private def parse_details(details)
|
22
|
+
case details[:type]
|
23
|
+
when "PI_SEPA_INST", "PI_FAST"
|
24
|
+
Details::Incoming::General.new(nil, details)
|
25
|
+
else
|
26
|
+
Details::Outgoing::General.new(nil, details)
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -4,8 +4,8 @@ module Modulr
|
|
4
4
|
module Resources
|
5
5
|
module Transactions
|
6
6
|
class Transactions < BaseCollection
|
7
|
-
def initialize(
|
8
|
-
super(
|
7
|
+
def initialize(raw_response, attributes_collection)
|
8
|
+
super(raw_response, Transaction, attributes_collection)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -18,8 +18,8 @@ module Modulr
|
|
18
18
|
map :sourceExternalReference, :external_reference
|
19
19
|
map :additionalInfo, :additional_info
|
20
20
|
|
21
|
-
def initialize(
|
22
|
-
super(
|
21
|
+
def initialize(raw_response, attributes = {})
|
22
|
+
super(raw_response, attributes)
|
23
23
|
|
24
24
|
@balance = attributes[:account][:balance]
|
25
25
|
@available_balance = attributes[:account][:availableBalance]
|
data/lib/modulr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modulr-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aitor García Rey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -223,8 +223,10 @@ files:
|
|
223
223
|
- lib/modulr/resources/notifications/config.rb
|
224
224
|
- lib/modulr/resources/notifications/notification.rb
|
225
225
|
- lib/modulr/resources/payments/collection.rb
|
226
|
+
- lib/modulr/resources/payments/counterparty.rb
|
226
227
|
- lib/modulr/resources/payments/destination.rb
|
227
|
-
- lib/modulr/resources/payments/details.rb
|
228
|
+
- lib/modulr/resources/payments/details/incoming/general.rb
|
229
|
+
- lib/modulr/resources/payments/details/outgoing/general.rb
|
228
230
|
- lib/modulr/resources/payments/payment.rb
|
229
231
|
- lib/modulr/resources/transactions/collection.rb
|
230
232
|
- lib/modulr/resources/transactions/transaction.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Modulr
|
4
|
-
module Resources
|
5
|
-
module Payments
|
6
|
-
class Details < Base
|
7
|
-
attr_reader :destination
|
8
|
-
|
9
|
-
map :sourceAccountId, :source_account_id
|
10
|
-
map :currency
|
11
|
-
map :amount
|
12
|
-
map :reference
|
13
|
-
|
14
|
-
def initialize(response, attributes = {})
|
15
|
-
super(response, attributes)
|
16
|
-
@destination = Destination.new(response, attributes[:destination])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|