trolley 1.0.3 → 1.1.0

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trolley/Client.rb +6 -1
  3. data/lib/trolley/Gateway.rb +7 -1
  4. data/lib/trolley/InvoicePayment.rb +6 -1
  5. data/lib/trolley/OfflinePayment.rb +2 -1
  6. data/lib/trolley/Payment.rb +4 -1
  7. data/lib/trolley/Recipient.rb +0 -2
  8. data/lib/trolley/RecipientAccount.rb +4 -1
  9. data/lib/trolley/RecipientLog.rb +12 -0
  10. data/lib/trolley/gateways/BalanceGateway.rb +18 -1
  11. data/lib/trolley/gateways/PaymentGateway.rb +5 -0
  12. data/lib/trolley/gateways/RecipientGateway.rb +5 -1
  13. data/lib/trolley/gateways/VerificationGateway.rb +40 -0
  14. data/lib/trolley/utils/PaginatedArray.rb +8 -3
  15. data/lib/trolley/utils/ResponseMapper.rb +1 -0
  16. data/lib/trolley.rb +3 -1
  17. data/test/fixtures/BalanceTest/test_find.yml +71 -0
  18. data/test/fixtures/BalanceTest/test_find_with_term.yml +71 -0
  19. data/test/fixtures/BatchTest/test_create.yml +150 -0
  20. data/test/fixtures/BatchTest/test_create_with_payments.yml +541 -0
  21. data/test/fixtures/BatchTest/test_delete_multiple.yml +209 -0
  22. data/test/fixtures/BatchTest/test_payments.yml +434 -0
  23. data/test/fixtures/BatchTest/test_processing.yml +578 -0
  24. data/test/fixtures/BatchTest/test_summary.yml +440 -0
  25. data/test/fixtures/BatchTest/test_update.yml +356 -0
  26. data/test/fixtures/InvoicePaymentTest/test_create.yml +489 -0
  27. data/test/fixtures/InvoicePaymentTest/test_delete.yml +634 -0
  28. data/test/fixtures/InvoicePaymentTest/test_find.yml +420 -0
  29. data/test/fixtures/InvoicePaymentTest/test_update.yml +634 -0
  30. data/test/fixtures/InvoiceTest/test_create.yml +293 -0
  31. data/test/fixtures/InvoiceTest/test_create_line.yml +353 -0
  32. data/test/fixtures/InvoiceTest/test_delete.yml +433 -0
  33. data/test/fixtures/InvoiceTest/test_delete_line.yml +353 -0
  34. data/test/fixtures/InvoiceTest/test_find.yml +284 -0
  35. data/test/fixtures/InvoiceTest/test_search.yml +293 -0
  36. data/test/fixtures/InvoiceTest/test_support_error_arrays.yml +71 -0
  37. data/test/fixtures/InvoiceTest/test_update.yml +428 -0
  38. data/test/fixtures/InvoiceTest/test_update_line.yml +422 -0
  39. data/test/fixtures/OfflinePaymentTest/test_create.yml +213 -0
  40. data/test/fixtures/OfflinePaymentTest/test_delete.yml +281 -0
  41. data/test/fixtures/OfflinePaymentTest/test_search.yml +281 -0
  42. data/test/fixtures/OfflinePaymentTest/test_update.yml +281 -0
  43. data/test/fixtures/PaymentTest/test_crud.yml +510 -0
  44. data/test/fixtures/PaymentTest/test_search.yml +366 -0
  45. data/test/fixtures/RecipientAccountTest/test_basic_crud.yml +351 -0
  46. data/test/fixtures/RecipientTest/test_account.yml +499 -0
  47. data/test/fixtures/RecipientTest/test_create.yml +72 -0
  48. data/test/fixtures/RecipientTest/test_delete_multiple.yml +347 -0
  49. data/test/fixtures/RecipientTest/test_find_logs.yml +278 -0
  50. data/test/fixtures/RecipientTest/test_find_payments.yml +512 -0
  51. data/test/fixtures/RecipientTest/test_lifecycle.yml +347 -0
  52. data/test/integration/BalanceTest.rb +22 -0
  53. data/test/integration/BatchTest.rb +157 -0
  54. data/test/integration/InvoicePaymentTest.rb +109 -0
  55. data/test/integration/InvoiceTest.rb +156 -0
  56. data/test/integration/OfflinePaymentTest.rb +109 -0
  57. data/test/integration/PaymentTest.rb +73 -0
  58. data/test/integration/RecipientAccountTest.rb +52 -0
  59. data/test/integration/RecipientTest.rb +176 -0
  60. data/test/test_helper.rb +45 -0
  61. data/test/unit/ClientRequestTest.rb +54 -0
  62. data/{spec → test}/unit/ConfigurationTest.rb +1 -1
  63. data/test/unit/GatewayParityTest.rb +184 -0
  64. data/{spec → test}/unit/PaginatedArrayTest.rb +3 -1
  65. data/{spec → test}/unit/TrolleyTest.rb +1 -1
  66. data/trolley.gemspec +10 -7
  67. metadata +101 -17
  68. data/spec/integration/BatchTest.rb +0 -126
  69. data/spec/integration/InvoicePaymentTest.rb +0 -92
  70. data/spec/integration/InvoiceTest.rb +0 -128
  71. data/spec/integration/RecipientAccountTest.rb +0 -48
  72. data/spec/integration/RecipientTest.rb +0 -159
  73. data/spec/integration/helper.rb +0 -19
  74. /data/{spec → test}/unit/ResponseMapperTest.rb +0 -0
@@ -0,0 +1,184 @@
1
+ require_relative '../../lib/trolley'
2
+ require 'test/unit'
3
+ require 'webmock/test_unit'
4
+
5
+ class GatewayParityTest < Test::Unit::TestCase
6
+ API_BASE = 'http://api.local.dev:3000'.freeze
7
+
8
+ def setup
9
+ @gateway = Trolley.client('key', 'secret', api_base: API_BASE)
10
+ end
11
+
12
+ def test_balance_aliases_call_documented_endpoints
13
+ stub_request(:get, "#{API_BASE}/v1/balances").to_return(status: 200, body: '{"ok":true}')
14
+ stub_request(:get, "#{API_BASE}/v1/balances/paymentrails").to_return(status: 200, body: '{"ok":true}')
15
+ stub_request(:get, "#{API_BASE}/v1/balances/paypal").to_return(status: 200, body: '{"ok":true}')
16
+
17
+ assert_equal true, @gateway.balance.all.ok
18
+ assert_equal true, @gateway.balance.paymentrails.ok
19
+ assert_equal true, @gateway.balance.paypal.ok
20
+ end
21
+
22
+ def test_payment_find_by_id_calls_top_level_payment_endpoint
23
+ stub_request(:get, "#{API_BASE}/v1/payments/P-123")
24
+ .to_return(status: 200, body: '{"payment":{"id":"P-123"}}')
25
+
26
+ payment = @gateway.payment.find_by_id('P-123')
27
+
28
+ assert_equal 'P-123', payment.id
29
+ end
30
+
31
+ def test_recipient_find_logs_returns_paginated_logs
32
+ stub_request(:get, "#{API_BASE}/v1/recipients/R-123/logs")
33
+ .to_return(status: 200, body: recipient_logs_response)
34
+
35
+ logs = @gateway.recipient.find_logs('R-123')
36
+
37
+ assert_equal Trolley::Utils::PaginatedArray, logs.class
38
+ assert_equal true, logs.ok
39
+ assert_equal logs, logs.recipientLogs
40
+ assert_equal 1, logs.page
41
+ assert_equal 1, logs.pages
42
+ assert_equal 1, logs.records
43
+ assert_equal Trolley::RecipientLog, logs.first.class
44
+ assert_equal 'create', logs.first.type
45
+ assert_equal '2023-07-07T14:52:45.901Z', logs.first.createdAt
46
+ end
47
+
48
+ def test_verification_gateway_calls_documented_trust_endpoints
49
+ stub_request(:get, "#{API_BASE}/v1/verifications?verificationType=watchlist&page=1&pageSize=10")
50
+ .to_return(status: 200, body: verification_response)
51
+ stub_request(:patch, "#{API_BASE}/v1/verifications/expire")
52
+ .with(body: '{"type":"individual","verificationIds":["IV-123"]}')
53
+ .to_return(status: 200, body: verification_response)
54
+ stub_request(:post, "#{API_BASE}/v1/verifications/watchlist/trigger")
55
+ .with(body: '{"recipientIds":["R-123"]}')
56
+ .to_return(status: 200, body: verification_response)
57
+ stub_request(:post, "#{API_BASE}/v1/verifications/individual/trigger")
58
+ .with(body: '{"recipientIds":["R-123"]}')
59
+ .to_return(status: 200, body: verification_response)
60
+
61
+ assert_equal 'WV-123', @gateway.verification.search(verificationType: 'watchlist', page: 1, pageSize: 10).verifications.first.id
62
+ assert_equal 'WV-123', @gateway.verification.expire(type: 'individual', verificationIds: ['IV-123']).verifications.first.id
63
+ assert_equal 'WV-123', @gateway.verification.trigger_watchlist(recipientIds: ['R-123']).verifications.first.id
64
+ assert_equal 'WV-123', @gateway.trust.trigger('individual', recipientIds: ['R-123']).verifications.first.id
65
+ end
66
+
67
+ def test_existing_deletes_support_single_and_multiple_ids
68
+ stub_request(:delete, "#{API_BASE}/v1/batches/B-123").to_return(status: 200, body: '{"ok":true}')
69
+ stub_request(:delete, "#{API_BASE}/v1/batches/")
70
+ .with(body: '{"ids":["B-123","B-456"]}')
71
+ .to_return(status: 200, body: '{"ok":true}')
72
+ stub_request(:delete, "#{API_BASE}/v1/recipients/R-123").to_return(status: 200, body: '{"ok":true}')
73
+ stub_request(:delete, "#{API_BASE}/v1/recipients/")
74
+ .with(body: '{"ids":["R-123","R-456"]}')
75
+ .to_return(status: 200, body: '{"ok":true}')
76
+
77
+ assert_equal true, @gateway.batch.delete('B-123')
78
+ assert_equal true, @gateway.batch.delete(%w[B-123 B-456])
79
+ assert_equal true, @gateway.recipient.delete('R-123')
80
+ assert_equal true, @gateway.recipient.delete(%w[R-123 R-456])
81
+ end
82
+
83
+ def test_documented_body_fields_pass_through
84
+ recipient_body = {
85
+ referenceId: 'ref-123',
86
+ type: 'individual',
87
+ firstName: 'Ada',
88
+ governmentIds: [{ type: 'ssn', value: '1234' }],
89
+ tags: ['new']
90
+ }
91
+ stub_request(:post, "#{API_BASE}/v1/recipients/")
92
+ .with(body: recipient_body.to_json)
93
+ .to_return(status: 200, body: '{"recipient":{"id":"R-123"}}')
94
+
95
+ payment_body = {
96
+ recipient: { id: 'R-123' },
97
+ amount: '10.00',
98
+ currency: 'USD',
99
+ tags: ['docs'],
100
+ forceUsTaxActivity: true
101
+ }
102
+ stub_request(:post, "#{API_BASE}/v1/batches/B-123/payments")
103
+ .with(body: payment_body.to_json)
104
+ .to_return(status: 200, body: '{"payment":{"id":"P-123"}}')
105
+
106
+ assert_equal 'R-123', @gateway.recipient.create(recipient_body).id
107
+ assert_equal 'P-123', @gateway.payment.create('B-123', payment_body).id
108
+ end
109
+
110
+ def test_invoice_payment_response_fields_are_mapped
111
+ stub_request(:post, "#{API_BASE}/v1/invoices/payment/search")
112
+ .with(body: '{"invoiceIds":["I-123"]}')
113
+ .to_return(status: 200, body: invoice_payment_search_response)
114
+
115
+ invoice_payment = @gateway.invoice_payment.search(invoiceIds: ['I-123']).first
116
+
117
+ assert_equal 'pending', invoice_payment.status
118
+ assert_equal 'payment memo', invoice_payment.memo
119
+ assert_equal 'payment-external-id_123', invoice_payment.externalId
120
+ assert_equal ['invoice_payment', 'royalty invoice'], invoice_payment.tags
121
+ assert_equal true, invoice_payment.coverFees
122
+ end
123
+
124
+ def test_payment_response_fields_are_mapped
125
+ stub_request(:get, "#{API_BASE}/v1/payments/P-123")
126
+ .to_return(status: 200, body: payment_response)
127
+
128
+ payment = @gateway.payment.find_by_id('P-123')
129
+
130
+ assert_equal 'US Dollar', payment.sourceCurrencyName
131
+ assert_equal 'Canadian Dollar', payment.targetCurrencyName
132
+ assert_equal false, payment.visibleToRecipient
133
+ end
134
+
135
+ def test_offline_payment_response_fields_are_mapped
136
+ stub_request(:get, "#{API_BASE}/v1/offline-payments?page=1&pageSize=10&search=")
137
+ .to_return(status: 200, body: offline_payments_response)
138
+
139
+ offline_payment = @gateway.offline_payment.search.first
140
+
141
+ assert_equal 2, offline_payment.activityCount
142
+ end
143
+
144
+ def test_recipient_account_response_fields_are_mapped
145
+ stub_request(:get, "#{API_BASE}/v1/recipients/R-123/accounts/A-123")
146
+ .to_return(status: 200, body: recipient_account_response)
147
+
148
+ account = @gateway.recipient_account.find('R-123', 'A-123')
149
+
150
+ assert_equal({ 'brand' => 'visa', 'last4' => '4242' }, account.cardDetails)
151
+ assert_equal({ 'city' => 'San Francisco', 'country' => 'US' }, account.mailing)
152
+ assert_equal '+15555550123', account.phoneNumber
153
+ end
154
+
155
+ def test_gateway_exposes_verification_and_trust_aliases
156
+ assert_same @gateway.verification, @gateway.trust
157
+ end
158
+
159
+ private
160
+
161
+ def verification_response
162
+ '{"ok":true,"verifications":[{"id":"WV-123","type":"watchlist"}],"meta":{"page":1,"pages":1,"records":1}}'
163
+ end
164
+
165
+ def recipient_logs_response
166
+ '{"ok":true,"recipientLogs":[{"via":"apikey","ipAddress":"23.93.176.55","userId":"user@example.com","type":"create","fields":[{"name":"referenceId","oldValue":null,"newValue":"external-reference-id"}],"createdAt":"2023-07-07T14:52:45.901Z"}],"meta":{"page":1,"pages":1,"records":1}}'
167
+ end
168
+
169
+ def invoice_payment_search_response
170
+ '{"ok":true,"invoicePayments":[{"invoiceId":"I-123","invoiceLineId":"IL-123","paymentId":"P-123","amount":{"value":"150.00","currency":"EUR"},"status":"pending","memo":"payment memo","externalId":"payment-external-id_123","tags":["invoice_payment","royalty invoice"],"coverFees":true}]}'
171
+ end
172
+
173
+ def payment_response
174
+ '{"ok":true,"payment":{"id":"P-123","sourceCurrency":"USD","sourceCurrencyName":"US Dollar","targetCurrency":"CAD","targetCurrencyName":"Canadian Dollar","visibleToRecipient":false}}'
175
+ end
176
+
177
+ def offline_payments_response
178
+ '{"ok":true,"offlinePayments":[{"id":"OP-123","recipientId":"R-123","amount":"10.00","currency":"USD","activityCount":2}]}'
179
+ end
180
+
181
+ def recipient_account_response
182
+ '{"ok":true,"account":{"id":"A-123","recipientId":"R-123","cardDetails":{"brand":"visa","last4":"4242"},"mailing":{"city":"San Francisco","country":"US"},"phoneNumber":"+15555550123"}}'
183
+ end
184
+ end
@@ -11,11 +11,13 @@ class PaginatedArrayTest < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_from_response
14
- response = '{"meta":{"page":1,"pages":2,"records":3},"batches":[{"id":1},{"id":2},{"id":3}]}'
14
+ response = '{"ok":true,"meta":{"page":1,"pages":2,"records":3},"batches":[{"id":1},{"id":2},{"id":3}]}'
15
15
  paginated_array = Trolley::Utils::PaginatedArray.from_response(response, Trolley::Batch)
16
16
  assert_equal 3, paginated_array.count
17
17
  assert_equal Trolley::Batch, paginated_array.first.class
18
18
 
19
+ assert_equal true, paginated_array.ok
20
+ assert_equal paginated_array, paginated_array.batches
19
21
  assert_equal 1, paginated_array.page
20
22
  assert_equal 2, paginated_array.pages
21
23
  assert_equal 3, paginated_array.records
@@ -9,7 +9,7 @@ class TrolleyTest < Test::Unit::TestCase
9
9
  def test_client_invalid_proxy_uri
10
10
  proxy_uri = 'not_://*a_valid_proxy'
11
11
  assert_raise Trolley::Configuration::InvalidProxyAddress.new("Invalid proxy provided to configuration: #{proxy_uri}") do
12
- Trolley.client('k', 's', proxy_uri: proxy_uri)
12
+ Trolley.client('k', 's', proxy_uri:)
13
13
  end
14
14
  end
15
15
  end
data/trolley.gemspec CHANGED
@@ -4,22 +4,25 @@ Gem::Specification.new do |s|
4
4
  s.name = 'trolley'
5
5
  s.summary = 'Trolley Ruby SDK'
6
6
  s.description = 'Ruby SDK for interacting with the Trolley API'
7
- s.version = '1.0.3'
7
+ s.version = '1.1.0'
8
8
  s.homepage = "https://github.com/trolley/ruby-sdk"
9
9
  s.email = ['developer-tools@trolley.com']
10
10
  s.license = 'MIT'
11
11
  s.authors = ['Trolley']
12
- s.files = Dir.glob ['README.rdoc', 'LICENSE', 'lib/**/*.{rb,crt}', 'spec/**/*', '*.gemspec']
13
- s.required_ruby_version = '>= 2.7'
12
+ s.files = Dir.glob ['README.rdoc', 'LICENSE', 'lib/**/*.{rb,crt}', 'test/**/*', '*.gemspec']
13
+ s.required_ruby_version = '>= 3.2.2'
14
14
  s.add_development_dependency 'dotenv', '~> 2'
15
15
  s.add_development_dependency 'rake', '~> 13'
16
16
  s.add_development_dependency 'rubocop', '~> 1'
17
+ s.add_development_dependency 'simplecov', '~> 0.22'
17
18
  s.add_development_dependency 'test-unit', '~> 3'
19
+ s.add_development_dependency 'vcr', '~> 6.2'
20
+ s.add_development_dependency 'webmock', '~> 3.18'
18
21
  s.metadata = {
19
- "bug_tracker_uri" => "https://github.com/trolley/ruby-sdk/issues",
20
- "changelog_uri" => "https://github.com/trolley/ruby-sdk/releases",
22
+ "bug_tracker_uri" => "https://github.com/trolley/ruby-sdk/issues",
23
+ "changelog_uri" => "https://github.com/trolley/ruby-sdk/releases",
21
24
  "documentation_uri" => "https://docs.trolley.com",
22
- "homepage_uri" => "https://github.com/trolley/ruby-sdk/",
23
- "source_code_uri" => "https://github.com/trolley/ruby-sdk.git",
25
+ "homepage_uri" => "https://github.com/trolley/ruby-sdk/",
26
+ "source_code_uri" => "https://github.com/trolley/ruby-sdk.git"
24
27
  }
25
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trolley
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trolley
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2026-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.22'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.22'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: test-unit
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,34 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '6.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.18'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.18'
69
111
  description: Ruby SDK for interacting with the Trolley API
70
112
  email:
71
113
  - developer-tools@trolley.com
@@ -88,6 +130,7 @@ files:
88
130
  - lib/trolley/Payment.rb
89
131
  - lib/trolley/Recipient.rb
90
132
  - lib/trolley/RecipientAccount.rb
133
+ - lib/trolley/RecipientLog.rb
91
134
  - lib/trolley/gateways/BalanceGateway.rb
92
135
  - lib/trolley/gateways/BatchGateway.rb
93
136
  - lib/trolley/gateways/InvoiceGateway.rb
@@ -96,18 +139,59 @@ files:
96
139
  - lib/trolley/gateways/PaymentGateway.rb
97
140
  - lib/trolley/gateways/RecipientAccountGateway.rb
98
141
  - lib/trolley/gateways/RecipientGateway.rb
142
+ - lib/trolley/gateways/VerificationGateway.rb
99
143
  - lib/trolley/utils/PaginatedArray.rb
100
144
  - lib/trolley/utils/ResponseMapper.rb
101
- - spec/integration/BatchTest.rb
102
- - spec/integration/InvoicePaymentTest.rb
103
- - spec/integration/InvoiceTest.rb
104
- - spec/integration/RecipientAccountTest.rb
105
- - spec/integration/RecipientTest.rb
106
- - spec/integration/helper.rb
107
- - spec/unit/ConfigurationTest.rb
108
- - spec/unit/PaginatedArrayTest.rb
109
- - spec/unit/ResponseMapperTest.rb
110
- - spec/unit/TrolleyTest.rb
145
+ - test/fixtures/BalanceTest/test_find.yml
146
+ - test/fixtures/BalanceTest/test_find_with_term.yml
147
+ - test/fixtures/BatchTest/test_create.yml
148
+ - test/fixtures/BatchTest/test_create_with_payments.yml
149
+ - test/fixtures/BatchTest/test_delete_multiple.yml
150
+ - test/fixtures/BatchTest/test_payments.yml
151
+ - test/fixtures/BatchTest/test_processing.yml
152
+ - test/fixtures/BatchTest/test_summary.yml
153
+ - test/fixtures/BatchTest/test_update.yml
154
+ - test/fixtures/InvoicePaymentTest/test_create.yml
155
+ - test/fixtures/InvoicePaymentTest/test_delete.yml
156
+ - test/fixtures/InvoicePaymentTest/test_find.yml
157
+ - test/fixtures/InvoicePaymentTest/test_update.yml
158
+ - test/fixtures/InvoiceTest/test_create.yml
159
+ - test/fixtures/InvoiceTest/test_create_line.yml
160
+ - test/fixtures/InvoiceTest/test_delete.yml
161
+ - test/fixtures/InvoiceTest/test_delete_line.yml
162
+ - test/fixtures/InvoiceTest/test_find.yml
163
+ - test/fixtures/InvoiceTest/test_search.yml
164
+ - test/fixtures/InvoiceTest/test_support_error_arrays.yml
165
+ - test/fixtures/InvoiceTest/test_update.yml
166
+ - test/fixtures/InvoiceTest/test_update_line.yml
167
+ - test/fixtures/OfflinePaymentTest/test_create.yml
168
+ - test/fixtures/OfflinePaymentTest/test_delete.yml
169
+ - test/fixtures/OfflinePaymentTest/test_search.yml
170
+ - test/fixtures/OfflinePaymentTest/test_update.yml
171
+ - test/fixtures/PaymentTest/test_crud.yml
172
+ - test/fixtures/PaymentTest/test_search.yml
173
+ - test/fixtures/RecipientAccountTest/test_basic_crud.yml
174
+ - test/fixtures/RecipientTest/test_account.yml
175
+ - test/fixtures/RecipientTest/test_create.yml
176
+ - test/fixtures/RecipientTest/test_delete_multiple.yml
177
+ - test/fixtures/RecipientTest/test_find_logs.yml
178
+ - test/fixtures/RecipientTest/test_find_payments.yml
179
+ - test/fixtures/RecipientTest/test_lifecycle.yml
180
+ - test/integration/BalanceTest.rb
181
+ - test/integration/BatchTest.rb
182
+ - test/integration/InvoicePaymentTest.rb
183
+ - test/integration/InvoiceTest.rb
184
+ - test/integration/OfflinePaymentTest.rb
185
+ - test/integration/PaymentTest.rb
186
+ - test/integration/RecipientAccountTest.rb
187
+ - test/integration/RecipientTest.rb
188
+ - test/test_helper.rb
189
+ - test/unit/ClientRequestTest.rb
190
+ - test/unit/ConfigurationTest.rb
191
+ - test/unit/GatewayParityTest.rb
192
+ - test/unit/PaginatedArrayTest.rb
193
+ - test/unit/ResponseMapperTest.rb
194
+ - test/unit/TrolleyTest.rb
111
195
  - trolley.gemspec
112
196
  homepage: https://github.com/trolley/ruby-sdk
113
197
  licenses:
@@ -118,7 +202,7 @@ metadata:
118
202
  documentation_uri: https://docs.trolley.com
119
203
  homepage_uri: https://github.com/trolley/ruby-sdk/
120
204
  source_code_uri: https://github.com/trolley/ruby-sdk.git
121
- post_install_message:
205
+ post_install_message:
122
206
  rdoc_options: []
123
207
  require_paths:
124
208
  - lib
@@ -126,15 +210,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
210
  requirements:
127
211
  - - ">="
128
212
  - !ruby/object:Gem::Version
129
- version: '2.7'
213
+ version: 3.2.2
130
214
  required_rubygems_version: !ruby/object:Gem::Requirement
131
215
  requirements:
132
216
  - - ">="
133
217
  - !ruby/object:Gem::Version
134
218
  version: '0'
135
219
  requirements: []
136
- rubygems_version: 3.2.3
137
- signing_key:
220
+ rubygems_version: 3.4.22
221
+ signing_key:
138
222
  specification_version: 4
139
223
  summary: Trolley Ruby SDK
140
224
  test_files: []
@@ -1,126 +0,0 @@
1
- require_relative 'helper'
2
- class BatchTest < Test::Unit::TestCase
3
- include ApiClientHelper
4
-
5
- def create_recipient
6
- uuid = SecureRandom.uuid.to_s
7
- recipient = @client.recipient.create(
8
- type: 'individual',
9
- firstName: 'Tom',
10
- lastName: 'Jones',
11
- email: "test.batch#{uuid}@example.com",
12
- address: {
13
- street1: '123 Wolfstrasse',
14
- city: 'Berlin',
15
- country: 'DE',
16
- postalCode: '123123'
17
- }
18
- )
19
- @client.recipient_account.create(recipient.id, type: 'bank-transfer', currency: 'EUR', country: 'DE', iban: 'DE89 3704 0044 0532 0130 00')
20
- recipient
21
- end
22
-
23
- def test_create
24
- batch = @client.batch.create(sourceCurrency: 'USD', description: 'Integration Test Create')
25
- assert_not_nil(batch)
26
- assert_not_nil(batch.id)
27
-
28
- batch = @client.batch.all
29
- assert_true(batch.count > 0)
30
- end
31
-
32
- def test_update
33
- batch = @client.batch.create(sourceCurrency: 'USD', description: 'Integration Test Create')
34
- assert_not_nil(batch)
35
- assert_not_nil(batch.id)
36
-
37
- all = @client.batch.all
38
- assert_true(all.count > 0)
39
-
40
- response = @client.batch.update(batch.id, description: 'Integration Update')
41
- assert_true(response)
42
- findBatch = @client.batch.find(batch.id)
43
- assert_equal('Integration Update', findBatch.description)
44
- assert_equal('open', batch.status)
45
-
46
- response = @client.batch.delete(batch.id)
47
- assert_true(response)
48
- end
49
-
50
- def test_create_with_payments
51
- recipientAlpha = create_recipient
52
- recipientBeta = create_recipient
53
-
54
- batch = @client.batch.create(
55
- sourceCurrency: 'USD', description: 'Integration Test Payments', payments: [
56
- { targetAmount: '10.00', targetCurrency: 'EUR', recipient: { id: recipientAlpha.id } },
57
- { sourceAmount: '10.00', recipient: { id: recipientBeta.id } }
58
- ]
59
- )
60
-
61
- assert_not_nil(batch)
62
- assert_not_nil(batch.id)
63
-
64
- findBatch = @client.batch.find(batch.id)
65
- assert_not_nil(findBatch)
66
- assert_equal(2, findBatch.totalPayments)
67
-
68
- payments = @client.payment.search(batch.id)
69
- payments.each { |item| assert_equal('pending', item.status) }
70
- end
71
-
72
- def test_payments
73
- batch = @client.batch.create(sourceCurrency: 'USD', description: 'Integration Test Payments')
74
- assert_not_nil(batch)
75
- assert_not_nil(batch.id)
76
-
77
- recipient = create_recipient
78
-
79
- payment = @client.payment.create(batch.id, sourceAmount: '10.00', recipient: { id: recipient.id })
80
-
81
- assert_not_nil(payment)
82
- assert_not_nil(payment.id)
83
-
84
- response = @client.payment.update(batch.id, payment.id, sourceAmount: '20.00')
85
- assert_true(response)
86
-
87
- response = @client.payment.delete(batch.id, payment.id)
88
- assert_true(response)
89
- end
90
-
91
- def test_processing
92
- recipientAlpha = create_recipient
93
- recipientBeta = create_recipient
94
-
95
- batch = @client.batch.create(
96
- sourceCurrency: 'USD', description: 'Integration Test Payments', payments: [
97
- { targetAmount: '10.00', targetCurrency: 'EUR', recipient: { id: recipientAlpha.id } },
98
- { sourceAmount: '10.00', recipient: { id: recipientBeta.id } }
99
- ]
100
- )
101
- assert_not_nil(batch)
102
- assert_not_nil(batch.id)
103
-
104
- summary = @client.batch.summary(batch.id)
105
- assert_equal(2, summary.detail['bank-transfer']['count'])
106
-
107
- quote = @client.batch.generate_quote(batch.id)
108
- assert_not_nil(quote)
109
-
110
- start = @client.batch.start_processing(batch.id)
111
- assert_not_nil(start)
112
- end
113
-
114
- def test_delete_multiple
115
- batch = @client.batch.create(sourceCurrency: 'USD', description: 'Integration Test Create')
116
- assert_not_nil(batch)
117
- assert_not_nil(batch.id)
118
-
119
- batch2 = @client.batch.create(sourceCurrency: 'USD', description: 'Integration Test Create')
120
- assert_not_nil(batch2)
121
- assert_not_nil(batch2.id)
122
-
123
- response = @client.batch.delete([batch.id, batch2.id])
124
- assert_true(response)
125
- end
126
- end
@@ -1,92 +0,0 @@
1
- require_relative 'helper'
2
-
3
- class InvoicePaymentTest < Test::Unit::TestCase
4
- include ApiClientHelper
5
-
6
- def create_recipient
7
- uuid = SecureRandom.uuid.to_s
8
- recipient = @client.recipient.create(
9
- type: 'individual',
10
- firstName: 'Tom',
11
- lastName: 'Jones',
12
- email: "test.batch#{uuid}@example.com",
13
- address: {
14
- street1: '123 Wolfstrasse',
15
- city: 'Berlin',
16
- country: 'DE',
17
- postalCode: '123123'
18
- }
19
- )
20
- @client.recipient_account.create(recipient.id, type: 'bank-transfer', currency: 'EUR', country: 'DE', iban: 'DE89 3704 0044 0532 0130 00')
21
- recipient
22
- end
23
-
24
- def test_create
25
- recipient = create_recipient
26
- invoice = @client.invoice.create(recipientId: recipient.id, description: 'Integration Test Invoice Create')
27
- assert_not_nil(invoice)
28
- assert_not_nil(invoice.id)
29
- assert_equal('open', invoice.status)
30
-
31
- invoice_line = @client.invoice.create_line(invoiceId: invoice.id, lines: [{ unitAmount: { value: '2000', currency: 'USD' } }])
32
- assert_not_nil(invoice_line.lines)
33
- assert_not_nil(invoice_line.lines.first['id'])
34
-
35
- @client.invoice_payment.create(ids: [invoiceId: invoice.id])
36
- invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
37
- assert_true(invoice_payments.count > 0)
38
-
39
- findInvoice = @client.invoice.find(invoiceId: invoice.id)
40
- assert_equal('paid', findInvoice.status)
41
- end
42
-
43
- def test_update
44
- recipient = create_recipient
45
-
46
- invoice = @client.invoice.create(recipientId: recipient.id, description: 'Integration Test Invoice Create')
47
- assert_not_nil(invoice)
48
- assert_not_nil(invoice.id)
49
-
50
- invoices = @client.invoice.search({})
51
- assert_true(invoices.count > 0)
52
-
53
- invoice_line = @client.invoice.create_line(invoiceId: invoice.id, lines: [{ unitAmount: { value: '2000', currency: 'USD' } }])
54
- assert_not_nil(invoice_line.lines)
55
- assert_not_nil(invoice_line.lines.first['id'])
56
-
57
- invoice_payment = @client.invoice_payment.create(ids: [invoiceId: invoice.id])
58
- invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
59
- assert_true(invoice_payments.count > 0)
60
- assert_equal('2000.00', invoice_payments.first.amount['value'])
61
-
62
- response = @client.invoice_payment.update(paymentId: invoice_payment.paymentId, invoiceLineId: invoice_payment.invoicePayments.first['invoiceLineId'], amount: { value: '5000', currency: 'USD' })
63
- assert_true(response)
64
- invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
65
- assert_true(invoice_payments.count > 0)
66
- assert_equal('5000.00', invoice_payments.first.amount['value'])
67
- end
68
-
69
- def test_delete
70
- recipient = create_recipient
71
-
72
- invoice = @client.invoice.create(recipientId: recipient.id, description: 'Integration Test Invoice Create')
73
- assert_not_nil(invoice)
74
- assert_not_nil(invoice.id)
75
-
76
- invoices = @client.invoice.search({})
77
- assert_true(invoices.count > 0)
78
-
79
- invoice_line = @client.invoice.create_line(invoiceId: invoice.id, lines: [{ unitAmount: { value: '2000', currency: 'USD' } }])
80
- assert_not_nil(invoice_line.lines)
81
- assert_not_nil(invoice_line.lines.first['id'])
82
-
83
- invoice_payment = @client.invoice_payment.create(ids: [invoiceId: invoice.id])
84
- invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
85
- assert_true(invoice_payments.count > 0)
86
-
87
- response = @client.invoice_payment.delete(paymentId: invoice_payment.paymentId, invoiceLineIds: [invoice_payment.invoicePayments.first['invoiceLineId']])
88
- assert_true(response)
89
- invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
90
- assert_true(invoice_payments.count == 0)
91
- end
92
- end