modulr-api 0.0.6 → 0.0.11

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: aab231f807a74a8bcbfa325435643cc639e6a5dc546f756dff2c8632044c5f83
4
- data.tar.gz: dca07503d073c6d48f7556b5ede035cf1c596ac535774fe33409d9fbd3c61f86
3
+ metadata.gz: 3f5558adb23b165b565033e9a96d4dcf729e489fb0060abe0b56c22a1158135d
4
+ data.tar.gz: 99460f8fc2f1e2f8404e8e0bfa2cef8f9e9f66ae1dd359a11556b7de8497bcc2
5
5
  SHA512:
6
- metadata.gz: 8cdaa03c41360d271822cfe63117e8559341686902a76861fec81eb8de8349558450f5a14e8f08d77842eb62cd1002697310ef761acde375bc8529eea689d9ef
7
- data.tar.gz: 4797ea33e24b82ea71273b795e3e6e579c58fb203407d25d255e2e72ec41f3b9bcfd39885fc1bd3d080b7ee692a2d6ffb20ee4746adab4543c5b4794f8c66b23
6
+ metadata.gz: 04735f27f41e13507ef0cd1834f76f5b2e60b656314ee1bb4bbd795cafdef1f2e4d515249f1a17877c42667f8c877d851f55184dc9ee48ac78b39f0191d8cdbb
7
+ data.tar.gz: 4298076a4b9957f7ecb6dcf67641f5a95f3ff1517a6d946e583bc3ea26a21a3da0fe937a9ac3c12cf29d81c072cdc21aa352a09bc6a8c82bc86939e4716aaa00
data/.rubocop_devengo.yml CHANGED
@@ -48,6 +48,9 @@ Metrics/BlockLength:
48
48
  - "**/*.rake"
49
49
  - "spec/**/*.rb"
50
50
 
51
+ Metrics/ClassLength:
52
+ Max: 500
53
+
51
54
  Metrics/MethodLength:
52
55
  Max: 50
53
56
 
@@ -159,25 +162,25 @@ Style/RedundantSelfAssignment:
159
162
  Style/SoleNestedConditional:
160
163
  Enabled: true
161
164
 
162
- Style/ArgumentsForwarding: # (new in 1.1)
165
+ Style/ArgumentsForwarding: # (new in 1.1)
163
166
  Enabled: true
164
167
 
165
- Style/DocumentDynamicEvalDefinition: # (new in 1.1)
168
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
166
169
  Enabled: true
167
170
 
168
- Style/SwapValues: # (new in 1.1)
171
+ Style/SwapValues: # (new in 1.1)
169
172
  Enabled: true
170
173
 
171
- Style/CollectionCompact: # (new in 1.2)
174
+ Style/CollectionCompact: # (new in 1.2)
172
175
  Enabled: true
173
176
 
174
- Style/NegatedIfElseCondition: # (new in 1.2)
177
+ Style/NegatedIfElseCondition: # (new in 1.2)
175
178
  Enabled: true
176
179
 
177
- Style/NilLambda: # (new in 1.3)
180
+ Style/NilLambda: # (new in 1.3)
178
181
  Enabled: true
179
182
 
180
- Style/RedundantArgument: # (new in 1.4)
183
+ Style/RedundantArgument: # (new in 1.4)
181
184
  Enabled: true
182
185
 
183
186
  Style/FetchEnvVar:
@@ -252,28 +255,28 @@ Lint/UselessMethodDefinition:
252
255
  Lint/UselessTimes:
253
256
  Enabled: true
254
257
 
255
- Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
258
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
256
259
  Enabled: true
257
260
 
258
- Lint/EmptyBlock: # (new in 1.1)
261
+ Lint/EmptyBlock: # (new in 1.1)
259
262
  Enabled: true
260
263
 
261
- Lint/ToEnumArguments: # (new in 1.1)
264
+ Lint/ToEnumArguments: # (new in 1.1)
262
265
  Enabled: true
263
266
 
264
- Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
267
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
265
268
  Enabled: true
266
269
 
267
- Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
270
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
268
271
  Enabled: true
269
272
 
270
- Lint/DuplicateBranch: # (new in 1.3)
273
+ Lint/DuplicateBranch: # (new in 1.3)
271
274
  Enabled: true
272
275
 
273
- Lint/EmptyClass: # (new in 1.3)
276
+ Lint/EmptyClass: # (new in 1.3)
274
277
  Enabled: true
275
278
 
276
- Lint/UnexpectedBlockArity: # (new in 1.5)
279
+ Lint/UnexpectedBlockArity: # (new in 1.5)
277
280
  Enabled: true
278
281
 
279
282
  RSpec/AggregateExamples:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- modulr-api (0.0.6)
4
+ modulr-api (0.0.11)
5
5
  faraday (~> 1.0)
6
6
  faraday_middleware (~> 1.0)
7
7
 
@@ -15,7 +15,7 @@ GEM
15
15
  crack (0.4.5)
16
16
  rexml
17
17
  diff-lcs (1.5.0)
18
- faraday (1.10.2)
18
+ faraday (1.10.3)
19
19
  faraday-em_http (~> 1.0)
20
20
  faraday-em_synchrony (~> 1.0)
21
21
  faraday-excon (~> 1.1)
@@ -63,7 +63,7 @@ GEM
63
63
  rb-inotify (~> 0.9, >= 0.9.10)
64
64
  lumberjack (1.2.8)
65
65
  method_source (1.0.0)
66
- multipart-post (2.2.3)
66
+ multipart-post (2.3.0)
67
67
  nenv (0.3.0)
68
68
  notiffany (0.1.3)
69
69
  nenv (~> 0.1)
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Ruby client for Modulr (cf. <https://modulr.readme.io/docs>)
4
4
 
5
- Run `bin/console` for an interactive prompt to experiment with the code.
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
@@ -24,6 +22,69 @@ Or install it yourself as:
24
22
  gem install modulr-api
25
23
  ```
26
24
 
25
+ ## Usage
26
+
27
+ Run `bin/console` for an interactive prompt to experiment with the code.
28
+
29
+ ### Customers
30
+
31
+ ```rb
32
+ # Find a customer
33
+ client.customers.find(id: "C2188C26")
34
+ ```
35
+
36
+ ### Accounts
37
+
38
+ ```rb
39
+ # Find an account
40
+ client.accounts.find(id: "A2188C26")
41
+
42
+ # Create an account
43
+ client.accounts.create(customer_id: "C2188C26", currency: "EUR", product_code: "YOUR_PRODUCT_CODE", external_reference: "My new account")
44
+ ```
45
+
46
+ ### Payments
47
+
48
+ ```rb
49
+ # Find a payment
50
+ client.payments.find(id: "P210FFT5AW")
51
+
52
+ # List payments
53
+ client.payments.list(from: DateTime.now - 1, to: DateTime.now)
54
+
55
+ # Create a payment
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
+ ```
58
+
59
+ ### Notifications
60
+
61
+ ### Supported event types per channel
62
+
63
+ Not all notifications can be sent to any channel. Check the following list for a quick view and the [original](https://modulr.readme.io/docs/notifications-1) reference for an up-to-date list
64
+
65
+ Supported via webhook:
66
+
67
+ - ACCOUNT_SWITCH_UPDATE
68
+ - DDMANDATE
69
+ - DD_FAILED_CLAIM
70
+ - DD_FUNDS_RETURNED
71
+ - DD_INCOMING_DEBIT
72
+ - DD_COLLECTION_STATUS
73
+ - PAYIN
74
+ - PAYOUT
75
+ - UPCOMING_CREDIT
76
+ - UPCOMING_COLLECTION_CREDIT
77
+ - UPCOMING_COLLECTION_DEBIT
78
+ - PAYMENT_COMPLIANCE_STATUS
79
+ - PAYMENT_FILE_UPLOAD
80
+
81
+ Supported via email:
82
+
83
+ - ACCOUNT_STATEMENT
84
+ - PENDING_PAYMENTS
85
+ - BALANCE
86
+ - CUSTVSTAT
87
+
27
88
  ## Release
28
89
 
29
90
  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.
@@ -37,7 +98,7 @@ git push origin vx.x.x
37
98
 
38
99
  The tagging will trigger the GitHub action defined in `release.yml`, pushing the gem to [rubygems.org](https://rubygems.org).
39
100
 
40
- ## Tooling
101
+ ## Tooling for manual API testing
41
102
 
42
103
  We have a tooling system based on HTTP request files which allow developers to run pre-format Modulr API requests easily. These HTTP request files are stored inside `doc/modulr_requests` directory. Find the service you want to run and run the specific HTTP file to execute the request locally.
43
104
 
@@ -51,13 +112,13 @@ Configure all variables by environment and you are ready to use your HTTP files.
51
112
  Any change should be tested. Builds with failures would not be allowed to merge.
52
113
  To run your test suite locally using Rspec:
53
114
 
54
- ```ruby
115
+ ```rb
55
116
  bundle exec rspec
56
117
  ```
57
118
 
58
119
  To prepare your environment to listen for your local code changes use Guard instead:
59
120
 
60
- ```ruby
121
+ ```rb
61
122
  bundle exec guard
62
123
  ```
63
124
 
@@ -3,13 +3,19 @@
3
3
  module Modulr
4
4
  module API
5
5
  class AccountsService < Service
6
- def create(customer_id:, currency:, product_code:, options: {})
7
- data = {
6
+ def find(id:)
7
+ response = client.get("/accounts/#{id}")
8
+ Resources::Accounts::Account.new(response, response.body)
9
+ end
10
+
11
+ def create(customer_id:, currency:, product_code:, **opts)
12
+ payload = {
8
13
  currency: currency,
9
14
  productCode: product_code,
10
15
  }
11
- data[:externalReference] = options[:external_reference] if options[:external_reference]
12
- response = client.post("/customers/#{customer_id}/accounts", data, options)
16
+ payload[:externalReference] = opts[:external_reference] if opts[:external_reference]
17
+
18
+ response = client.post("/customers/#{customer_id}/accounts", payload)
13
19
  Resources::Accounts::Account.new(response, response.body)
14
20
  end
15
21
 
@@ -18,11 +24,6 @@ module Modulr
18
24
 
19
25
  nil
20
26
  end
21
-
22
- def info(account_id:)
23
- response = client.get("/accounts/#{account_id}")
24
- Resources::Accounts::Account.new(response, response.body)
25
- end
26
27
  end
27
28
  end
28
29
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module API
5
+ class CustomersService < Service
6
+ def find(id:)
7
+ response = client.get("/customers/#{id}")
8
+ Resources::Customers::Customer.new(response, response.body)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module API
5
+ class NotificationsService < Service
6
+ def find(id:, **opts)
7
+ response = client.get("#{base_notification_url(opts)}/notifications/#{id}")
8
+ Resources::Notifications::Notification.new(response, response.body)
9
+ end
10
+
11
+ def list(**opts)
12
+ response = client.get("#{base_notification_url(opts)}/notifications")
13
+ Resources::Notifications::Collection.new(response, response.body)
14
+ end
15
+
16
+ def create(type:, channel:, destinations:, config:, **opts)
17
+ payload = {
18
+ type: type,
19
+ channel: channel,
20
+ destinations: destinations,
21
+ config: config,
22
+ }
23
+ response = client.post("#{base_notification_url(opts)}/notifications", payload)
24
+ Resources::Notifications::Notification.new(response, response.body)
25
+ end
26
+
27
+ protected def base_notification_url(opts)
28
+ opts[:partner_id] ? "/partners/#{opts[:partner_id]}" : "/customers/#{opts[:customer_id]}"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -3,30 +3,55 @@
3
3
  module Modulr
4
4
  module API
5
5
  class PaymentsService < Service
6
- def create( # rubocop:disable Metrics/ParameterLists
7
- account_id:,
8
- currency:,
9
- amount:,
10
- destination:,
11
- reference:,
12
- options: {}
13
- )
14
- data = {
6
+ def find(id:)
7
+ response = client.get("/payments", { id: id })
8
+ payment_attributes = response.body[:content]&.first
9
+ raise NotFoundError, "Payment #{id} not found" unless payment_attributes
10
+
11
+ Resources::Payments::Payment.new(response, payment_attributes)
12
+ end
13
+
14
+ def list(**opts)
15
+ return find(id: opts[:id]) if opts[:id]
16
+
17
+ response = client.get("/payments", build_query_params(opts))
18
+ Resources::Payments::Collection.new(response, response.body[:content])
19
+ end
20
+
21
+ # rubocop:disable Metrics/ParameterLists
22
+ def create(account_id:, destination:, reference:, currency:, amount:, **opts)
23
+ payload = {
15
24
  sourceAccountId: account_id,
25
+ destination: destination,
26
+ reference: reference,
16
27
  currency: currency,
17
28
  amount: amount,
18
- reference: reference,
19
- destination: {
20
- type: destination[:type],
21
- iban: destination[:iban],
22
- name: destination[:name],
23
- },
24
29
  }
25
- data[:externalReference] = options[:external_reference] if options[:external_reference]
26
30
 
27
- response = client.post("/payments", data, options)
31
+ payload[:externalReference] = opts[:external_reference] if opts[:external_reference]
32
+ payload[:endToEndReference] = opts[:e2e_reference] if opts[:e2e_reference]
33
+
34
+ response = client.post("/payments", payload)
28
35
  Resources::Payments::Payment.new(response, response.body)
29
36
  end
37
+ # rubocop:enable Metrics/ParameterLists
38
+
39
+ # rubocop:disable Metrics/AbcSize
40
+ private def build_query_params(opts)
41
+ same_name_params = [:type, :status]
42
+ date_params = { to: :toCreatedDate, from: :fromCreatedDate, updated_since: :modifiedSince }
43
+ mapped_params = {
44
+ external_reference: :externalReference,
45
+ has_external_reference: :hasExternalReference,
46
+ account_id: :sourceAccountId,
47
+ }
48
+ {}.tap do |params|
49
+ same_name_params.each { |param| params[param] = opts[param] if opts[param] }
50
+ date_params.each { |original, mapped| params[mapped] = format_datetime(opts[original]) if opts[original] }
51
+ mapped_params.each { |original, mapped| params[mapped] = opts[original] if opts[original] }
52
+ end
53
+ end
54
+ # rubocop:enable Metrics/AbcSize
30
55
  end
31
56
  end
32
57
  end
@@ -8,6 +8,10 @@ module Modulr
8
8
  def initialize(client)
9
9
  @client = client
10
10
  end
11
+
12
+ def format_datetime(datetime)
13
+ datetime.strftime("%Y-%m-%dT%l:%M:%S%z")
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -12,10 +12,18 @@ module Modulr
12
12
  @services[:accounts] ||= API::AccountsService.new(self)
13
13
  end
14
14
 
15
+ def customers
16
+ @services[:customers] ||= API::CustomersService.new(self)
17
+ end
18
+
15
19
  def payments
16
20
  @services[:payments] ||= API::PaymentsService.new(self)
17
21
  end
18
22
 
23
+ def notifications
24
+ @services[:notifications] ||= API::NotificationsService.new(self)
25
+ end
26
+
19
27
  def transactions
20
28
  @services[:transactions] ||= API::TransactionsService.new(self)
21
29
  end
data/lib/modulr/client.rb CHANGED
@@ -60,7 +60,9 @@ module Modulr
60
60
  uri = "#{base_url}#{path}"
61
61
 
62
62
  begin
63
- connection.run_request(method, uri, request_options[:body], request_options[:headers])
63
+ connection.run_request(method, uri, request_options[:body], request_options[:headers]) do |request|
64
+ request.params.update(options) if options
65
+ end
64
66
  rescue StandardError => e
65
67
  handle_request_error(e)
66
68
  end
@@ -91,28 +93,22 @@ module Modulr
91
93
  end
92
94
 
93
95
  def handle_request_error(error)
96
+ response = error.response
94
97
  case error
95
98
  when Faraday::ClientError
96
- if error.response
97
- handle_error_response(error)
99
+ case response[:status]
100
+ when 403
101
+ raise ForbiddenError, response
102
+ when 404
103
+ raise NotFoundError, response
98
104
  else
99
- handle_network_error(error)
105
+ raise RequestError, response
100
106
  end
101
107
  else
102
- raise error
108
+ raise Error, response
103
109
  end
104
110
  end
105
111
 
106
- def handle_error_response(error)
107
- puts "Client Error: #{error.response}"
108
- raise error
109
- end
110
-
111
- def handle_network_error(error)
112
- puts "Network error: #{error.response}"
113
- raise error
114
- end
115
-
116
112
  def default_origin
117
113
  "Modulr/#{Modulr::VERSION} Ruby Client (Faraday/#{Faraday::VERSION})"
118
114
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ class Error < StandardError
5
+ end
6
+
7
+ class RequestError < Error
8
+ attr_reader :response, :errors
9
+
10
+ def initialize(response)
11
+ @response = response
12
+ @errors = extract_errors
13
+ super(message_from(response))
14
+ end
15
+
16
+ private def extract_errors
17
+ return unless json?
18
+
19
+ response[:body]
20
+ end
21
+
22
+ private def message_from(response)
23
+ return response if response.is_a?(String)
24
+
25
+ if errors
26
+ errors.map { |error| "#{error[:field]} #{error[:code]} #{error[:message]}" }.join(", ")
27
+ else
28
+ "#{response[:status]} #{response[:body]}"
29
+ end
30
+ end
31
+
32
+ private def json?
33
+ return unless response.is_a?(Hash)
34
+
35
+ content_type = response[:headers]["content-type"]
36
+ content_type&.start_with?("application/json")
37
+ end
38
+ end
39
+
40
+ class NotFoundError < RequestError
41
+ end
42
+
43
+ class ForbiddenError < RequestError
44
+ end
45
+ end
@@ -12,11 +12,11 @@ module Modulr
12
12
  closed: "CLOSED",
13
13
  client_blocked: "CLIENT_BLOCKED",
14
14
  }.freeze
15
- map :id, :id
16
- map :balance, :balance
15
+ map :id
16
+ map :balance
17
+ map :currency
18
+ map :status
17
19
  map :availableBalance, :available_balance
18
- map :currency, :currency
19
- map :status, :status
20
20
  map :customerId, :customer_id
21
21
  map :customerName, :customer_name
22
22
  map :externalReference, :external_reference
@@ -4,12 +4,12 @@ module Modulr
4
4
  module Resources
5
5
  module Accounts
6
6
  class Identifier < Base
7
- map :type, :type
7
+ map :type
8
+ map :iban
9
+ map :bic
10
+ map :currency
8
11
  map :accountNumber, :account_number
9
12
  map :sortCode, :sort_code
10
- map :iban, :iban
11
- map :bic, :bic
12
- map :currency, :currency
13
13
  map :countrySpecificDetails, :country_details
14
14
  map :providerExtraInfo, :provider_extra_info
15
15
  end
@@ -3,7 +3,7 @@
3
3
  module Modulr
4
4
  module Resources
5
5
  module Accounts
6
- class Identifiers < Collection
6
+ class Identifiers < BaseCollection
7
7
  def initialize(response, attributes_collection)
8
8
  super(response, Identifier, attributes_collection)
9
9
  end
@@ -13,8 +13,9 @@ module Modulr
13
13
  end
14
14
  end
15
15
 
16
- def self.map(original_attribute, mapped_attributes)
16
+ def self.map(original_attribute, mapped_attributes = nil)
17
17
  class_eval { attr_writer original_attribute.to_sym }
18
+ mapped_attributes ||= original_attribute
18
19
  mapped_attributes = [mapped_attributes].flatten
19
20
  mapped_attributes.each do |mapped_attribute|
20
21
  define_method(mapped_attribute) { instance_variable_get("@#{original_attribute}") }
@@ -24,10 +25,17 @@ module Modulr
24
25
  end
25
26
  end
26
27
 
27
- require_relative "collection"
28
+ require_relative "base_collection"
28
29
  require_relative "accounts/account"
29
30
  require_relative "accounts/identifier"
30
31
  require_relative "accounts/identifiers"
32
+ require_relative "customers/customer"
33
+ require_relative "notifications/notification"
34
+ require_relative "notifications/config"
35
+ require_relative "notifications/collection"
31
36
  require_relative "payments/payment"
32
- require_relative "transactions/transactions"
37
+ require_relative "payments/details"
38
+ require_relative "payments/destination"
39
+ require_relative "payments/collection"
33
40
  require_relative "transactions/transaction"
41
+ require_relative "transactions/collection"
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Modulr
4
4
  module Resources
5
- class Collection
5
+ class BaseCollection
6
6
  include Enumerable
7
7
  attr_reader :response
8
8
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Customers
6
+ class Customer < Base
7
+ map :id
8
+ map :name
9
+ map :type
10
+ map :status
11
+ map :verificationStatus, :verification_status
12
+ map :companyRegNumber, :taxid
13
+ map :expectedMonthlySpend, :expected_monthly_spend
14
+ map :partnerId, :partner_id
15
+ map :industryCode, :industry_code
16
+ map :tcsVersion, :tcs_version
17
+ map :externalReference, :external_reference
18
+ map :createdDate, :created_at
19
+ map :holdPaymentsForFunds, :hold_payments_for_funds
20
+ map :cardConstraintsBid, :card_constraints_bid
21
+ map :needAddressVerification, :need_address_verification
22
+ map :accessGroupsVisible, :access_groups_visible
23
+ map :legalEntity, :legal_entity
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Notifications
6
+ class Collection < BaseCollection
7
+ def initialize(response, attributes_collection)
8
+ super(response, Notification, attributes_collection)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Notifications
6
+ class Config < Base
7
+ map :retry
8
+ map :secret
9
+ map :hmacAlgorithm, :hmac_algorithm
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Notifications
6
+ class Notification < Base
7
+ attr_reader :config
8
+
9
+ map :id
10
+ map :type
11
+ map :channel
12
+ map :status
13
+ map :destinations
14
+
15
+ def initialize(response, attributes = {})
16
+ super(response, attributes)
17
+ @config = Config.new(response, attributes[:config])
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Payments
6
+ class Collection < BaseCollection
7
+ def initialize(response, attributes_collection)
8
+ super(response, Payment, attributes_collection)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Payments
6
+ class Destination < Base
7
+ map :type
8
+ map :iban
9
+ map :name
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
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
@@ -4,9 +4,19 @@ module Modulr
4
4
  module Resources
5
5
  module Payments
6
6
  class Payment < Base
7
+ attr_reader :details
8
+
7
9
  map :id, [:id, :payment_reference_id]
8
- map :status, :status
10
+ map :status
11
+ map :reference
9
12
  map :externalReference, :external_reference
13
+ map :createdDate, :created_at
14
+ map :approvalStatus, :approval_status
15
+
16
+ def initialize(response, attributes = {})
17
+ super(response, attributes)
18
+ @details = Details.new(response, attributes[:details])
19
+ end
10
20
  end
11
21
  end
12
22
  end
@@ -3,7 +3,7 @@
3
3
  module Modulr
4
4
  module Resources
5
5
  module Transactions
6
- class Transactions < Collection
6
+ class Transactions < BaseCollection
7
7
  def initialize(response, attributes_collection)
8
8
  super(response, Transaction, attributes_collection)
9
9
  end
@@ -6,14 +6,14 @@ module Modulr
6
6
  class Transaction < Base
7
7
  attr_reader :balance, :available_balance
8
8
 
9
- map :id, :id
10
- map :amount, :amount
11
- map :currency, :currency
12
- map :description, :description
9
+ map :id
10
+ map :amount
11
+ map :currency
12
+ map :description
13
+ map :credit
14
+ map :type
13
15
  map :transactionDate, :created_at
14
- map :postedDate, :date
15
- map :credit, :credit
16
- map :type, :type
16
+ map :postedDate, :posted_date
17
17
  map :sourceId, :source_id
18
18
  map :sourceExternalReference, :external_reference
19
19
  map :additionalInfo, :additional_info
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulr
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.11"
5
5
  end
data/lib/modulr.rb CHANGED
@@ -3,8 +3,15 @@
3
3
  require_relative "modulr/version"
4
4
 
5
5
  require_relative "modulr/auth/signature"
6
- require_relative "modulr/client"
7
6
 
8
- module Modulr
9
- class Error < StandardError; end
10
- end
7
+ require_relative "modulr/api/service"
8
+ require_relative "modulr/api/services"
9
+ require_relative "modulr/api/accounts_service"
10
+ require_relative "modulr/api/customers_service"
11
+ require_relative "modulr/api/payments_service"
12
+ require_relative "modulr/api/notifications_service"
13
+
14
+ require_relative "modulr/resources/base"
15
+
16
+ require_relative "modulr/error"
17
+ require_relative "modulr/client"
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.6
4
+ version: 0.0.11
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: 2022-08-26 00:00:00.000000000 Z
11
+ date: 2023-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -204,20 +204,30 @@ files:
204
204
  - doc/modulr_requests/transactions/history.http
205
205
  - lib/modulr.rb
206
206
  - lib/modulr/api/accounts_service.rb
207
+ - lib/modulr/api/customers_service.rb
208
+ - lib/modulr/api/notifications_service.rb
207
209
  - lib/modulr/api/payments_service.rb
208
210
  - lib/modulr/api/service.rb
209
211
  - lib/modulr/api/services.rb
210
212
  - lib/modulr/api/transactions_service.rb
211
213
  - lib/modulr/auth/signature.rb
212
214
  - lib/modulr/client.rb
215
+ - lib/modulr/error.rb
213
216
  - lib/modulr/resources/accounts/account.rb
214
217
  - lib/modulr/resources/accounts/identifier.rb
215
218
  - lib/modulr/resources/accounts/identifiers.rb
216
219
  - lib/modulr/resources/base.rb
217
- - lib/modulr/resources/collection.rb
220
+ - lib/modulr/resources/base_collection.rb
221
+ - lib/modulr/resources/customers/customer.rb
222
+ - lib/modulr/resources/notifications/collection.rb
223
+ - lib/modulr/resources/notifications/config.rb
224
+ - lib/modulr/resources/notifications/notification.rb
225
+ - lib/modulr/resources/payments/collection.rb
226
+ - lib/modulr/resources/payments/destination.rb
227
+ - lib/modulr/resources/payments/details.rb
218
228
  - lib/modulr/resources/payments/payment.rb
229
+ - lib/modulr/resources/transactions/collection.rb
219
230
  - lib/modulr/resources/transactions/transaction.rb
220
- - lib/modulr/resources/transactions/transactions.rb
221
231
  - lib/modulr/version.rb
222
232
  - modulr.gemspec
223
233
  - sig/modulr.rbs
@@ -244,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
254
  - !ruby/object:Gem::Version
245
255
  version: '0'
246
256
  requirements: []
247
- rubygems_version: 3.3.7
257
+ rubygems_version: 3.4.6
248
258
  signing_key:
249
259
  specification_version: 4
250
260
  summary: Ruby client for Modulr Finance API.