mollie-api-ruby 4.9.0 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +25 -0
  3. data/CHANGELOG.md +22 -0
  4. data/README.md +1 -1
  5. data/examples/methods/list.rb +4 -0
  6. data/examples/orders/create-payment.rb +1 -0
  7. data/examples/orders/get.rb +4 -1
  8. data/examples/orders/update-orderline.rb +7 -0
  9. data/examples/organisations/get-partner.rb +1 -0
  10. data/examples/profiles/create.rb +6 -6
  11. data/lib/mollie/list.rb +4 -2
  12. data/lib/mollie/method.rb +7 -1
  13. data/lib/mollie/onboarding.rb +1 -1
  14. data/lib/mollie/order/line.rb +4 -0
  15. data/lib/mollie/order/payment.rb +6 -0
  16. data/lib/mollie/order.rb +29 -1
  17. data/lib/mollie/partner.rb +52 -0
  18. data/lib/mollie/payment.rb +6 -1
  19. data/lib/mollie/profile.rb +3 -1
  20. data/lib/mollie/version.rb +1 -1
  21. data/lib/mollie.rb +2 -0
  22. data/test/fixtures/customer/get.json +36 -0
  23. data/test/fixtures/customer/list-payments-next.json +30 -0
  24. data/test/fixtures/customer/list-payments.json +30 -0
  25. data/test/fixtures/methods/all.json +92 -0
  26. data/test/fixtures/onboarding/me.json +1 -1
  27. data/test/fixtures/orders/create_payment.json +38 -0
  28. data/test/fixtures/orders/get.json +0 -38
  29. data/test/fixtures/orders/get_embedded_resources.json +369 -0
  30. data/test/fixtures/orders/update_line.json +226 -0
  31. data/test/fixtures/organizations/partner.json +26 -0
  32. data/test/mollie/list_test.rb +60 -0
  33. data/test/mollie/method_test.rb +13 -0
  34. data/test/mollie/order/create_payment_test.rb +20 -0
  35. data/test/mollie/order/line_test.rb +18 -0
  36. data/test/mollie/order_test.rb +33 -0
  37. data/test/mollie/partner_test.rb +47 -0
  38. data/test/mollie/profile_test.rb +2 -0
  39. metadata +27 -1
@@ -83,5 +83,65 @@ module Mollie
83
83
  list = Mollie::List.new(attributes, Payment)
84
84
  assert_equal 2, list.previous.count
85
85
  end
86
+
87
+ def test_pagination_for_nested_resources
88
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U')
89
+ .to_return(
90
+ status: 200,
91
+ body: read_fixture('customer/get.json'),
92
+ headers: {}
93
+ )
94
+
95
+ # First page of customer payments
96
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?limit=2')
97
+ .to_return(
98
+ status: 200,
99
+ body: read_fixture('customer/list-payments.json'),
100
+ headers: {}
101
+ )
102
+
103
+ # Second page
104
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_3&limit=2')
105
+ .to_return(
106
+ status: 200,
107
+ body: read_fixture('customer/list-payments-next.json'),
108
+ headers: {}
109
+ )
110
+
111
+ # Previous page
112
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_1&limit=2')
113
+ .to_return(
114
+ status: 200,
115
+ body: read_fixture('customer/list-payments.json'),
116
+ headers: {}
117
+ )
118
+
119
+ customer = Mollie::Customer.get('cst_8wmqcHMN4U')
120
+
121
+ # First page of customer payments
122
+ payments = customer.payments(limit: 2)
123
+
124
+ assert_equal ["tr_1", "tr_2"], payments.map { |p| p.id }
125
+ assert_equal "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_3&limit=2",
126
+ payments.links["next"]["href"]
127
+ assert_equal nil, payments.links["previous"]
128
+
129
+ # Second page
130
+ payments = payments.next
131
+
132
+ assert_equal ["tr_3", "tr_4"], payments.map { |p| p.id }
133
+ assert_equal nil, payments.links["next"]
134
+ assert_equal "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_1&limit=2",
135
+ payments.links["previous"]["href"]
136
+
137
+ # Previous page
138
+ payments = payments.previous
139
+
140
+ assert_equal ["tr_1", "tr_2"], payments.map { |p| p.id }
141
+ assert_equal "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_3&limit=2",
142
+ payments.links["next"]["href"]
143
+ assert_equal nil, payments.links["previous"]
144
+ end
145
+
86
146
  end
87
147
  end
@@ -8,6 +8,7 @@ module Mollie
8
8
  description: 'Credit card',
9
9
  minimum_amount: { value: '0.01', currency: 'EUR' },
10
10
  maximum_amount: { value: '2000.00', currency: 'EUR' },
11
+ status: 'approved',
11
12
  image: {
12
13
  'size1x' => 'https://www.mollie.com/external/icons/payment-methods/creditcard.png',
13
14
  'size2x' => 'https://www.mollie.com/external/icons/payment-methods/creditcard%402x.png',
@@ -23,11 +24,23 @@ module Mollie
23
24
  assert_equal 'EUR', method.minimum_amount.currency
24
25
  assert_equal BigDecimal('2000.00'), method.maximum_amount.value
25
26
  assert_equal 'EUR', method.maximum_amount.currency
27
+ assert_equal 'approved', method.status
26
28
  assert_equal 'https://www.mollie.com/external/icons/payment-methods/creditcard.png', method.normal_image
27
29
  assert_equal 'https://www.mollie.com/external/icons/payment-methods/creditcard%402x.png', method.bigger_image
28
30
  assert_equal 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', method.image['svg']
29
31
  end
30
32
 
33
+ def test_all_available
34
+ stub_request(:get, 'https://api.mollie.com/v2/methods/all')
35
+ .to_return(status: 200, body: read_fixture('methods/all.json'), headers: {})
36
+
37
+ available_methods = Method.all_available
38
+ assert_equal 3, available_methods.size
39
+
40
+ ideal_method = available_methods.first
41
+ assert_equal "pending-boarding", ideal_method.status
42
+ end
43
+
31
44
  def test_pricing
32
45
  stub_request(:get, 'https://api.mollie.com/v2/methods/creditcard?include=pricing')
33
46
  .to_return(status: 200, body: read_fixture('methods/get-includes-pricing.json'), headers: {})
@@ -0,0 +1,20 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class Order
5
+ class PaymentTest < Test::Unit::TestCase
6
+ CREATE_PAYMENT = read_fixture("orders/create_payment.json")
7
+
8
+ def test_create_payment
9
+ stub_request(:post, "https://api.mollie.com/v2/orders/ord_kEn1PlbGa/payments")
10
+ .to_return(status: 201, body: CREATE_PAYMENT, headers: {})
11
+
12
+ payment = Order::Payment.create(order_id: "ord_kEn1PlbGa")
13
+
14
+ assert_kind_of Order::Payment, payment
15
+ assert_equal "tr_ncaPcAhuUV", payment.id
16
+ assert_equal "ord_kEn1PlbGa", payment.order_id
17
+ end
18
+ end
19
+ end
20
+ end
@@ -6,6 +6,7 @@ module Mollie
6
6
  GET_ORDER = read_fixture('orders/get.json')
7
7
  CANCEL_LINE = read_fixture('orders/cancel_line.json')
8
8
  CANCEL_QTY = read_fixture('orders/cancel_line_qty.json')
9
+ UPDATE_LINE = read_fixture('orders/update_line.json')
9
10
 
10
11
  def test_discounted
11
12
  stub_request(:get, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa')
@@ -40,6 +41,23 @@ module Mollie
40
41
  assert_nil order.lines.first.cancel(quantity: 1)
41
42
  end
42
43
 
44
+ def test_update_orderline
45
+ stub_request(:patch, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa/lines/odl_dgtxyl')
46
+ .with(body: { sku: "new-sku-12345678" }.to_json)
47
+ .to_return(status: 200, body: UPDATE_LINE, headers: {})
48
+
49
+ order = Mollie::Order::Line.update(
50
+ 'odl_dgtxyl',
51
+ order_id: 'ord_kEn1PlbGa',
52
+ sku: "new-sku-12345678"
53
+ )
54
+
55
+ # The `update order line`-API returns an `order` instead of `orderline`
56
+ assert_equal Mollie::Order, order.class
57
+
58
+ line = order.lines.find { |line| line.id == 'odl_dgtxyl' }
59
+ assert_equal "new-sku-12345678", line.sku
60
+ end
43
61
  end
44
62
  end
45
63
  end
@@ -7,6 +7,9 @@ module Mollie
7
7
  UPDATE_ORDER = read_fixture('orders/update.json')
8
8
  LIST_ORDER = read_fixture('orders/list.json')
9
9
 
10
+ GET_ORDER_WITH_EMBEDDED_RESOURCES =
11
+ read_fixture('orders/get_embedded_resources.json')
12
+
10
13
  # Refunds
11
14
  CREATE_ORDER_REFUND = read_fixture('orders/create_refund.json')
12
15
  REFUND_ALL_LINES = read_fixture('orders/refund_all.json')
@@ -82,6 +85,36 @@ module Mollie
82
85
  assert_equal Time.parse('2018-08-28T09:29:56+00:00'), order.completed_at
83
86
  end
84
87
 
88
+ def test_embedded_payments
89
+ stub_request(:get, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa')
90
+ .to_return(status: 200, body: GET_ORDER_WITH_EMBEDDED_RESOURCES, headers: {})
91
+
92
+ order = Order.get('ord_kEn1PlbGa')
93
+
94
+ assert_equal 'tr_ncaPcAhuUV', order.payments.first.id
95
+ assert_equal 1, order.payments.size
96
+ end
97
+
98
+ def test_embedded_refunds
99
+ stub_request(:get, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa')
100
+ .to_return(status: 200, body: GET_ORDER_WITH_EMBEDDED_RESOURCES, headers: {})
101
+
102
+ order = Order.get('ord_kEn1PlbGa')
103
+
104
+ assert_equal 're_vD3Jm32wQt', order.refunds.first.id
105
+ assert_equal 1, order.refunds.size
106
+ end
107
+
108
+ def test_embedded_shipments
109
+ stub_request(:get, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa')
110
+ .to_return(status: 200, body: GET_ORDER_WITH_EMBEDDED_RESOURCES, headers: {})
111
+
112
+ order = Order.get('ord_kEn1PlbGa')
113
+
114
+ assert_equal 'shp_3wmsgCJN4U', order.shipments.first.id
115
+ assert_equal 1, order.shipments.size
116
+ end
117
+
85
118
  def test_cancelable?
86
119
  stub_request(:get, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa')
87
120
  .to_return(status: 200, body: GET_ORDER, headers: {})
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class PartnerTest < Test::Unit::TestCase
5
+ def setup
6
+ stub_request(:get, 'https://api.mollie.com/v2/organizations/me/partner')
7
+ .to_return(status: 200, body: read_fixture('organizations/partner.json'), headers: {})
8
+ end
9
+
10
+ def test_class_type
11
+ partner = Partner.current
12
+ assert_equal Mollie::Partner, partner.class
13
+ end
14
+
15
+ def test_partner_type
16
+ partner = Partner.current
17
+ assert_equal 'signuplink', partner.type
18
+ end
19
+
20
+ def test_commision_partner
21
+ partner = Partner.current
22
+ assert partner.commission_partner?
23
+ end
24
+
25
+ def test_contract_signed_at
26
+ partner = Partner.current
27
+ assert_equal Time.parse('2018-03-20T13:13:37+00:00'), partner.contract_signed_at
28
+ end
29
+
30
+ def test_contract_update_available?
31
+ partner = Partner.current
32
+ assert partner.contract_update_available?
33
+ end
34
+
35
+ def test_signuplink
36
+ partner = Partner.current
37
+ assert_equal 'https://www.mollie.com/dashboard/signup/myCode?lang=en', partner.signuplink
38
+ end
39
+
40
+ def test_user_agent_tokens
41
+ token = Partner.current.user_agent_tokens.first
42
+ assert_equal 'unique-token', token.token
43
+ assert_equal Time.parse('2018-03-20T13:13:37+00:00'), token.starts_at
44
+ assert_nil nil, token.ends_at
45
+ end
46
+ end
47
+ end
@@ -10,6 +10,7 @@ module Mollie
10
10
  website: 'https://www.mywebsite.com',
11
11
  email: 'info@mywebsite.com',
12
12
  phone: '+31208202070',
13
+ business_category: 'OTHER_MERCHANDISE',
13
14
  category_code: 5399,
14
15
  status: 'unverified',
15
16
  review: {
@@ -56,6 +57,7 @@ module Mollie
56
57
  assert_equal 'https://www.mywebsite.com', profile.website
57
58
  assert_equal 'info@mywebsite.com', profile.email
58
59
  assert_equal '+31208202070', profile.phone
60
+ assert_equal 'OTHER_MERCHANDISE', profile.business_category
59
61
  assert_equal 5399, profile.category_code
60
62
  assert_equal Profile::STATUS_UNVERIFIED, profile.status
61
63
  assert_equal Profile::REVIEW_STATUS_PENDING, profile.review.status
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mollie-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.9.0
4
+ version: 4.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mollie B.V.
@@ -79,6 +79,7 @@ executables: []
79
79
  extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
+ - ".github/workflows/build.yml"
82
83
  - ".gitignore"
83
84
  - ".rubocop.yml"
84
85
  - ".rubocop_todo.yml"
@@ -121,13 +122,16 @@ files:
121
122
  - examples/onboarding/submit.rb
122
123
  - examples/orders/cancel-lines.rb
123
124
  - examples/orders/cancel.rb
125
+ - examples/orders/create-payment.rb
124
126
  - examples/orders/create-refund.rb
125
127
  - examples/orders/create.rb
126
128
  - examples/orders/get.rb
127
129
  - examples/orders/list-refunds.rb
128
130
  - examples/orders/list.rb
131
+ - examples/orders/update-orderline.rb
129
132
  - examples/orders/update.rb
130
133
  - examples/organisations/get-current.rb
134
+ - examples/organisations/get-partner.rb
131
135
  - examples/organisations/get.rb
132
136
  - examples/payments/create.rb
133
137
  - examples/payments/delete.rb
@@ -193,9 +197,11 @@ files:
193
197
  - lib/mollie/onboarding.rb
194
198
  - lib/mollie/order.rb
195
199
  - lib/mollie/order/line.rb
200
+ - lib/mollie/order/payment.rb
196
201
  - lib/mollie/order/refund.rb
197
202
  - lib/mollie/order/shipment.rb
198
203
  - lib/mollie/organization.rb
204
+ - lib/mollie/partner.rb
199
205
  - lib/mollie/payment.rb
200
206
  - lib/mollie/payment/capture.rb
201
207
  - lib/mollie/payment/chargeback.rb
@@ -214,19 +220,27 @@ files:
214
220
  - mollie-api-ruby.gemspec
215
221
  - test/fixtures/captures/get.json
216
222
  - test/fixtures/captures/list.json
223
+ - test/fixtures/customer/get.json
224
+ - test/fixtures/customer/list-payments-next.json
225
+ - test/fixtures/customer/list-payments.json
226
+ - test/fixtures/methods/all.json
217
227
  - test/fixtures/methods/get-includes-pricing.json
218
228
  - test/fixtures/onboarding/me.json
219
229
  - test/fixtures/onboarding/submit.json
220
230
  - test/fixtures/orders/cancel_line.json
221
231
  - test/fixtures/orders/cancel_line_qty.json
222
232
  - test/fixtures/orders/create.json
233
+ - test/fixtures/orders/create_payment.json
223
234
  - test/fixtures/orders/create_refund.json
224
235
  - test/fixtures/orders/get.json
236
+ - test/fixtures/orders/get_embedded_resources.json
225
237
  - test/fixtures/orders/list.json
226
238
  - test/fixtures/orders/list_refunds.json
227
239
  - test/fixtures/orders/refund.json
228
240
  - test/fixtures/orders/refund_all.json
229
241
  - test/fixtures/orders/update.json
242
+ - test/fixtures/orders/update_line.json
243
+ - test/fixtures/organizations/partner.json
230
244
  - test/fixtures/payments/get.json
231
245
  - test/fixtures/refunds/get.json
232
246
  - test/fixtures/shipments/create.json
@@ -248,10 +262,12 @@ files:
248
262
  - test/mollie/list_test.rb
249
263
  - test/mollie/method_test.rb
250
264
  - test/mollie/onboarding_test.rb
265
+ - test/mollie/order/create_payment_test.rb
251
266
  - test/mollie/order/line_test.rb
252
267
  - test/mollie/order/shipment_test.rb
253
268
  - test/mollie/order_test.rb
254
269
  - test/mollie/organization_test.rb
270
+ - test/mollie/partner_test.rb
255
271
  - test/mollie/payment/capture_test.rb
256
272
  - test/mollie/payment/chargeback_test.rb
257
273
  - test/mollie/payment/refund_test.rb
@@ -291,19 +307,27 @@ summary: Official Mollie API Client for Ruby
291
307
  test_files:
292
308
  - test/fixtures/captures/get.json
293
309
  - test/fixtures/captures/list.json
310
+ - test/fixtures/customer/get.json
311
+ - test/fixtures/customer/list-payments-next.json
312
+ - test/fixtures/customer/list-payments.json
313
+ - test/fixtures/methods/all.json
294
314
  - test/fixtures/methods/get-includes-pricing.json
295
315
  - test/fixtures/onboarding/me.json
296
316
  - test/fixtures/onboarding/submit.json
297
317
  - test/fixtures/orders/cancel_line.json
298
318
  - test/fixtures/orders/cancel_line_qty.json
299
319
  - test/fixtures/orders/create.json
320
+ - test/fixtures/orders/create_payment.json
300
321
  - test/fixtures/orders/create_refund.json
301
322
  - test/fixtures/orders/get.json
323
+ - test/fixtures/orders/get_embedded_resources.json
302
324
  - test/fixtures/orders/list.json
303
325
  - test/fixtures/orders/list_refunds.json
304
326
  - test/fixtures/orders/refund.json
305
327
  - test/fixtures/orders/refund_all.json
306
328
  - test/fixtures/orders/update.json
329
+ - test/fixtures/orders/update_line.json
330
+ - test/fixtures/organizations/partner.json
307
331
  - test/fixtures/payments/get.json
308
332
  - test/fixtures/refunds/get.json
309
333
  - test/fixtures/shipments/create.json
@@ -325,10 +349,12 @@ test_files:
325
349
  - test/mollie/list_test.rb
326
350
  - test/mollie/method_test.rb
327
351
  - test/mollie/onboarding_test.rb
352
+ - test/mollie/order/create_payment_test.rb
328
353
  - test/mollie/order/line_test.rb
329
354
  - test/mollie/order/shipment_test.rb
330
355
  - test/mollie/order_test.rb
331
356
  - test/mollie/organization_test.rb
357
+ - test/mollie/partner_test.rb
332
358
  - test/mollie/payment/capture_test.rb
333
359
  - test/mollie/payment/chargeback_test.rb
334
360
  - test/mollie/payment/refund_test.rb