modulr-api 0.0.16 → 0.0.19

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: e538f41d8e5d2d64dc75db3ec234e67367b592262530d926c622280d2557f08e
4
- data.tar.gz: 91a2fdd93f8ae2afc8cc94aad9a9884af13dc294666257fc16f105cfec7b7372
3
+ metadata.gz: 151fec1b59fee97d4c008e8c229acdf65fb948a632443a5bf431fd4ab99db5b2
4
+ data.tar.gz: edb08a27bdc84da31df9c2f3508ca72968546a988924e798ac6a2de0730b70a3
5
5
  SHA512:
6
- metadata.gz: 35612c3c6b7d42c447b14808f91c23955cb755ccd02759f0fc445568612374c8efabc74fd79b8f2bde46d353b1b2467e07db1de8f823ab6dfe623cde21782700
7
- data.tar.gz: 7194973cdbd13a67fcca831c92547df26f9ee0791c35cd64b1ac6d524dc74843dea2684a961de2d0d15d9966baa6dd1e8a526e6e0d7bb50d08490c1aa6ec7ab2
6
+ metadata.gz: 8c71349b26005bb7185807f5a3d7d7d474f9a71cf672f8f9b5013e1475f3581a886787a2dadc71e22d6f5f7ffc5c3007aee1a1a51f055d7186a7df4b8ad03c2e
7
+ data.tar.gz: a3519173719b22f64037939faf62c1efabd95fb7768933c37de3034ce74d26224f70ea068b1935f3d66f3cbfa5ea93ec73039043f294e14320a25626237ee3eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- modulr-api (0.0.16)
4
+ modulr-api (0.0.19)
5
5
  faraday (~> 1.0)
6
6
  faraday_middleware (~> 1.0)
7
7
 
data/README.md CHANGED
@@ -31,6 +31,85 @@ Run `bin/console` for an interactive prompt to experiment with the code.
31
31
  ```rb
32
32
  # Find a customer
33
33
  client.customers.find(id: "C2188C26")
34
+
35
+ # Create a customer
36
+ client.customers.create(
37
+ type: "LLC",
38
+ legal_entity: "GB",
39
+ external_reference: "My new customer",
40
+ name: "string",
41
+ company_reg_number: "2018123987165432",
42
+ registered_address: {
43
+ addressLine1: "string",
44
+ addressLine2: "string",
45
+ postTown: "string",
46
+ postCode: "string",
47
+ country: "GB",
48
+ countrySubDivision: "string"
49
+ },
50
+ trading_address: {
51
+ addressLine1: "string",
52
+ addressLine2: "string",
53
+ postTown: "string",
54
+ postCode: "string",
55
+ country: "GB",
56
+ countrySubDivision: "string"
57
+ },
58
+ industry_code: "string",
59
+ tcs_version: 0,
60
+ expected_monthly_spend: 0,
61
+ associates: [
62
+ {
63
+ type: "DIRECTOR",
64
+ firstName: "string",
65
+ middleName: "string",
66
+ lastName: "string",
67
+ dateOfBirth: "string",
68
+ ownership: 0,
69
+ homeAddress: {
70
+ addressLine1: "string",
71
+ addressLine2: "string",
72
+ postTown: "string",
73
+ postCode: "string",
74
+ country: "GB",
75
+ countrySubDivision: "string"
76
+ },
77
+ applicant: true,
78
+ email: "string",
79
+ phone: "string",
80
+ documentInfo: [
81
+ {
82
+ path: "string",
83
+ fileName: "string",
84
+ uploadedDate: "2017-01-28T01:01:01+0000"
85
+ }
86
+ ],
87
+ additionalIdentifiers: [
88
+ {
89
+ type: "BSN",
90
+ value: "string"
91
+ }
92
+ ],
93
+ complianceData: {
94
+ relationship: "string"
95
+ }
96
+ }
97
+ ],
98
+ document_info: [
99
+ {
100
+ path: "string",
101
+ fileName: "string",
102
+ uploadedDate: "2017-01-28T01:01:01+0000"
103
+ }
104
+ ],
105
+ provisional_customer_id: "string",
106
+ customer_trust: {
107
+ trustNature: "BARE_TRUSTS"
108
+ },
109
+ tax_profile: {
110
+ taxIdentifier: "string"
111
+ }
112
+ )
34
113
  ```
35
114
 
36
115
  ### Accounts
@@ -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:)
@@ -1,12 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
4
+
3
5
  module Modulr
4
6
  module API
5
7
  class CustomersService < Service
6
8
  def find(id:)
7
9
  response = client.get("/customers/#{id}")
8
- Resources::Customers::Customer.new(response, response.body)
10
+ Resources::Customers::Customer.new(response.env[:raw_body], response.body)
11
+ end
12
+
13
+ def create(type:, legal_entity:, **opts)
14
+ payload = {
15
+ type: type,
16
+ legalEntity: legal_entity,
17
+ }
18
+
19
+ payload[:externalReference] = opts[:external_reference] if opts[:external_reference]
20
+ payload[:name] = opts[:name] if opts[:name]
21
+ payload[:companyRegNumber] = opts[:company_reg_number] if opts[:company_reg_number]
22
+ payload[:registeredAddress] = opts[:registered_address] if opts[:registered_address]
23
+ payload[:tradingAddress] = opts[:trading_address] if opts[:trading_address]
24
+ payload[:industryCode] = opts[:industry_code] if opts[:industry_code]
25
+ payload[:tcsVersion] = opts[:tcs_version] if opts[:tcs_version]
26
+ payload[:expectedMonthlySpend] = opts[:expected_monthly_spend] if opts[:expected_monthly_spend]
27
+ payload[:associates] = opts[:associates] if opts[:associates]
28
+ payload[:documentInfo] = opts[:document_info] if opts[:document_info]
29
+ payload[:provisionalCustomerId] = opts[:provisional_customer_id] if opts[:provisional_customer_id]
30
+ payload[:customerTrust] = opts[:customer_trust] if opts[:customer_trust]
31
+ payload[:taxProfile] = opts[:tax_profile] if opts[:tax_profile]
32
+
33
+ response = client.post("/customers", payload)
34
+ Resources::Customers::Customer.new(response.env[:raw_body], response.body)
9
35
  end
10
36
  end
11
37
  end
12
38
  end
39
+
40
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -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
data/lib/modulr/client.rb CHANGED
@@ -51,6 +51,10 @@ module Modulr
51
51
  execute :post, path, data, options
52
52
  end
53
53
 
54
+ def put(path, data = nil, options = {})
55
+ execute :put, path, data, options
56
+ end
57
+
54
58
  def execute(method, path, data = nil, options = {})
55
59
  request(method, path, data, options)
56
60
  end
@@ -23,9 +23,9 @@ module Modulr
23
23
  map :createdDate, :created_at
24
24
  map :directDebit, :direct_debit
25
25
 
26
- def initialize(response, attributes = {})
27
- super(response, attributes)
28
- @identifiers = Accounts::Identifiers.new(response, attributes[:identifiers])
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(response, attributes_collection)
8
- super(response, Identifier, attributes_collection)
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 :response
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/details"
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(response, item_klass, attributes_collection = [])
10
- @response = response
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(response, attributes_item) }
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(response, attributes_collection)
8
- super(response, Notification, attributes_collection)
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(response, attributes = {})
16
- super(response, attributes)
17
- @config = Config.new(response, attributes[:config])
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(response, attributes_collection)
8
- super(response, Payment, attributes_collection)
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(response, attributes = {})
17
- super(response, attributes)
18
- @details = Details.new(response, attributes[: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(response, attributes_collection)
8
- super(response, Transaction, attributes_collection)
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(response, attributes = {})
22
- super(response, attributes)
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]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulr
4
- VERSION = "0.0.16"
4
+ VERSION = "0.0.19"
5
5
  end
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.16
4
+ version: 0.0.19
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-10 00:00:00.000000000 Z
11
+ date: 2023-04-13 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
@@ -254,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
256
  - !ruby/object:Gem::Version
255
257
  version: '0'
256
258
  requirements: []
257
- rubygems_version: 3.4.6
259
+ rubygems_version: 3.4.10
258
260
  signing_key:
259
261
  specification_version: 4
260
262
  summary: Ruby client for Modulr Finance API.
@@ -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