mollie-api-ruby 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +10 -0
  3. data/.rubocop_todo.yml +92 -0
  4. data/.travis.yml +3 -1
  5. data/CHANGELOG.md +1 -1
  6. data/Gemfile +1 -1
  7. data/Rakefile +1 -2
  8. data/bin/console +4 -4
  9. data/docs/migration_v2_2_x.md +1 -1
  10. data/docs/migration_v3_x.md +2 -2
  11. data/examples/chargebacks/get.rb +2 -2
  12. data/examples/customers/create-payment.rb +4 -4
  13. data/examples/customers/create.rb +3 -3
  14. data/examples/customers/delete.rb +1 -1
  15. data/examples/customers/get.rb +1 -1
  16. data/examples/customers/list-payments.rb +1 -1
  17. data/examples/customers/update.rb +2 -2
  18. data/examples/invoices/get.rb +1 -1
  19. data/examples/mandates/create.rb +7 -7
  20. data/examples/mandates/delete.rb +1 -1
  21. data/examples/mandates/get.rb +1 -1
  22. data/examples/mandates/list.rb +1 -1
  23. data/examples/methods/get.rb +2 -2
  24. data/examples/organisations/get.rb +1 -1
  25. data/examples/payments/delete.rb +1 -1
  26. data/examples/payments/get-customer.rb +1 -1
  27. data/examples/payments/get-mandate.rb +1 -1
  28. data/examples/payments/get-settlement.rb +1 -1
  29. data/examples/payments/get-subscription.rb +1 -1
  30. data/examples/payments/get.rb +1 -1
  31. data/examples/payments/webhook.rb +1 -1
  32. data/examples/permissions/get.rb +1 -1
  33. data/examples/profiles/create.rb +6 -6
  34. data/examples/profiles/delete.rb +1 -1
  35. data/examples/profiles/get.rb +1 -1
  36. data/examples/profiles/list-chargebacks.rb +1 -1
  37. data/examples/profiles/list-methods.rb +1 -1
  38. data/examples/profiles/list-payments.rb +1 -1
  39. data/examples/profiles/list-refunds.rb +1 -1
  40. data/examples/profiles/update.rb +3 -3
  41. data/examples/refunds/create.rb +3 -3
  42. data/examples/refunds/delete.rb +2 -2
  43. data/examples/refunds/get.rb +2 -2
  44. data/examples/settlements/get.rb +1 -1
  45. data/examples/settlements/list-chargebacks.rb +1 -1
  46. data/examples/settlements/list-payments.rb +1 -1
  47. data/examples/settlements/list-refunds.rb +1 -1
  48. data/examples/subscriptions/create.rb +5 -5
  49. data/examples/subscriptions/delete.rb +2 -2
  50. data/examples/subscriptions/get.rb +2 -2
  51. data/examples/subscriptions/list.rb +1 -1
  52. data/examples/subscriptions/update.rb +1 -1
  53. data/lib/cacert.pem +2 -26
  54. data/lib/mollie.rb +0 -1
  55. data/lib/mollie/amount.rb +1 -1
  56. data/lib/mollie/base.rb +8 -8
  57. data/lib/mollie/chargeback.rb +12 -6
  58. data/lib/mollie/client.rb +17 -17
  59. data/lib/mollie/customer/mandate.rb +10 -6
  60. data/lib/mollie/customer/subscription.rb +15 -7
  61. data/lib/mollie/exception.rb +1 -1
  62. data/lib/mollie/invoice.rb +14 -6
  63. data/lib/mollie/list.rb +9 -13
  64. data/lib/mollie/method.rb +15 -15
  65. data/lib/mollie/organization.rb +1 -1
  66. data/lib/mollie/payment.rb +36 -16
  67. data/lib/mollie/permission.rb +18 -17
  68. data/lib/mollie/profile.rb +11 -7
  69. data/lib/mollie/refund.rb +12 -8
  70. data/lib/mollie/settlement.rb +17 -9
  71. data/lib/mollie/util.rb +8 -8
  72. data/lib/mollie/version.rb +1 -1
  73. data/mollie-api-ruby.gemspec +5 -4
  74. data/test/helper.rb +1 -1
  75. data/test/mollie/amount_test.rb +1 -1
  76. data/test/mollie/base_test.rb +72 -72
  77. data/test/mollie/chargeback_test.rb +36 -37
  78. data/test/mollie/client_test.rb +49 -49
  79. data/test/mollie/customer/mandate_test.rb +40 -40
  80. data/test/mollie/customer/payment_test.rb +5 -6
  81. data/test/mollie/customer/subscription_test.rb +45 -45
  82. data/test/mollie/customer_test.rb +12 -12
  83. data/test/mollie/invoice_test.rb +29 -29
  84. data/test/mollie/list_test.rb +23 -23
  85. data/test/mollie/method_test.rb +8 -8
  86. data/test/mollie/organization_test.rb +9 -9
  87. data/test/mollie/payment/chargeback_test.rb +4 -4
  88. data/test/mollie/payment/refund_test.rb +4 -4
  89. data/test/mollie/payment_test.rb +111 -111
  90. data/test/mollie/profile_test.rb +41 -42
  91. data/test/mollie/refund_test.rb +39 -39
  92. data/test/mollie/settlement/chargeback_test.rb +4 -4
  93. data/test/mollie/settlement/payment_test.rb +5 -5
  94. data/test/mollie/settlement/refund_test.rb +4 -4
  95. data/test/mollie/settlement_test.rb +53 -53
  96. data/test/mollie/util_test.rb +9 -11
  97. data/test/run-test.rb +4 -4
  98. metadata +46 -30
@@ -27,30 +27,30 @@ module Mollie
27
27
  end
28
28
 
29
29
  def test_list_mandates
30
- stub_request(:get, "https://api.mollie.com/v2/customers/cus-id/mandates")
31
- .to_return(:status => 200, :body => %{{"_embedded" : { "mandates" : [{"id":"man-id", "customer_id":"cus-id"}]}} }, :headers => {})
30
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cus-id/mandates')
31
+ .to_return(status: 200, body: %({"_embedded" : { "mandates" : [{"id":"man-id", "customer_id":"cus-id"}]}} ), headers: {})
32
32
 
33
- mandates = Customer.new(id: "cus-id").mandates
33
+ mandates = Customer.new(id: 'cus-id').mandates
34
34
 
35
- assert_equal "man-id", mandates.first.id
35
+ assert_equal 'man-id', mandates.first.id
36
36
  end
37
37
 
38
38
  def test_list_subscriptions
39
- stub_request(:get, "https://api.mollie.com/v2/customers/cus-id/subscriptions")
40
- .to_return(:status => 200, :body => %{{"_embedded" : {"subscriptions" : [{"id":"sub-id", "customer_id":"cus-id"}]}} }, :headers => {})
39
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cus-id/subscriptions')
40
+ .to_return(status: 200, body: %({"_embedded" : {"subscriptions" : [{"id":"sub-id", "customer_id":"cus-id"}]}} ), headers: {})
41
41
 
42
- subscriptions = Customer.new(id: "cus-id").subscriptions
42
+ subscriptions = Customer.new(id: 'cus-id').subscriptions
43
43
 
44
- assert_equal "sub-id", subscriptions.first.id
44
+ assert_equal 'sub-id', subscriptions.first.id
45
45
  end
46
46
 
47
47
  def test_list_payments
48
- stub_request(:get, "https://api.mollie.com/v2/customers/cus-id/payments")
49
- .to_return(:status => 200, :body => %{{"_embedded" : { "payments" : [{"id":"sub-id", "customer_id":"cus-id"}]}}}, :headers => {})
48
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cus-id/payments')
49
+ .to_return(status: 200, body: %({"_embedded" : { "payments" : [{"id":"sub-id", "customer_id":"cus-id"}]}}), headers: {})
50
50
 
51
- payments = Customer.new(id: "cus-id").payments
51
+ payments = Customer.new(id: 'cus-id').payments
52
52
 
53
- assert_equal "sub-id", payments.first.id
53
+ assert_equal 'sub-id', payments.first.id
54
54
  end
55
55
  end
56
56
  end
@@ -4,68 +4,68 @@ module Mollie
4
4
  class InvoiceTest < Test::Unit::TestCase
5
5
  def test_setting_attributes
6
6
  attributes = {
7
- id: "inv_xBEbP9rvAq",
8
- reference: "2016.10000",
9
- vat_number: "NL001234567B01",
10
- status: "open",
11
- issued_at: "2016-08-31",
12
- due_at: "2016-09-14",
7
+ id: 'inv_xBEbP9rvAq',
8
+ reference: '2016.10000',
9
+ vat_number: 'NL001234567B01',
10
+ status: 'open',
11
+ issued_at: '2016-08-31',
12
+ due_at: '2016-09-14',
13
13
  net_amount: {
14
- value: "45.00",
15
- currency: "EUR"
14
+ value: '45.00',
15
+ currency: 'EUR'
16
16
  },
17
17
  vat_amount: {
18
- value: "9.45",
19
- currency: "EUR"
18
+ value: '9.45',
19
+ currency: 'EUR'
20
20
  },
21
21
  gross_amount: {
22
- value: "54.45",
23
- currency: "EUR"
22
+ value: '54.45',
23
+ currency: 'EUR'
24
24
  },
25
25
  lines: [
26
26
  {
27
- period: "2016-09",
28
- description: "iDEAL transactiekosten",
27
+ period: '2016-09',
28
+ description: 'iDEAL transactiekosten',
29
29
  count: 100,
30
30
  vat_percentage: 21,
31
31
  amount: {
32
- value: "45.00",
33
- currency: "EUR"
32
+ value: '45.00',
33
+ currency: 'EUR'
34
34
  }
35
35
  }
36
36
  ],
37
37
  _links: {
38
- "pdf" => {
39
- "href" => "https://www.mollie.com/beheer/facturen/2016.10000/52981a39788e5e0acaf71bbf570e941f/",
40
- "type" => "application/pdf"
38
+ 'pdf' => {
39
+ 'href' => 'https://www.mollie.com/beheer/facturen/2016.10000/52981a39788e5e0acaf71bbf570e941f/',
40
+ 'type' => 'application/pdf'
41
41
  }
42
42
  }
43
43
  }
44
44
 
45
45
  invoice = Invoice.new(attributes)
46
46
 
47
- assert_equal "inv_xBEbP9rvAq", invoice.id
48
- assert_equal "2016.10000", invoice.reference
49
- assert_equal "NL001234567B01", invoice.vat_number
50
- assert_equal "open", invoice.status
51
- assert_equal Time.parse("2016-08-31"), invoice.issued_at
52
- assert_equal Time.parse("2016-09-14"), invoice.due_at
47
+ assert_equal 'inv_xBEbP9rvAq', invoice.id
48
+ assert_equal '2016.10000', invoice.reference
49
+ assert_equal 'NL001234567B01', invoice.vat_number
50
+ assert_equal 'open', invoice.status
51
+ assert_equal Time.parse('2016-08-31'), invoice.issued_at
52
+ assert_equal Time.parse('2016-09-14'), invoice.due_at
53
53
  assert_equal 45.0, invoice.net_amount.value
54
54
  assert_equal 'EUR', invoice.net_amount.currency
55
- assert_equal BigDecimal.new(9.45, 3), invoice.vat_amount.value
55
+ assert_equal BigDecimal(9.45, 3), invoice.vat_amount.value
56
56
  assert_equal 'EUR', invoice.vat_amount.currency
57
57
  assert_equal 54.45, invoice.gross_amount.value
58
58
  assert_equal 'EUR', invoice.gross_amount.currency
59
59
 
60
60
  line = invoice.lines.first
61
- assert_equal "2016-09", line.period
62
- assert_equal "iDEAL transactiekosten", line.description
61
+ assert_equal '2016-09', line.period
62
+ assert_equal 'iDEAL transactiekosten', line.description
63
63
  assert_equal 100, line.count
64
64
  assert_equal 21, line.vat_percentage
65
65
  assert_equal 45.0, line.amount.value
66
66
  assert_equal 'EUR', line.amount.currency
67
67
 
68
- assert_equal "https://www.mollie.com/beheer/facturen/2016.10000/52981a39788e5e0acaf71bbf570e941f/", invoice.pdf
68
+ assert_equal 'https://www.mollie.com/beheer/facturen/2016.10000/52981a39788e5e0acaf71bbf570e941f/', invoice.pdf
69
69
  end
70
70
  end
71
71
  end
@@ -4,27 +4,27 @@ module Mollie
4
4
  class ListTest < Test::Unit::TestCase
5
5
  def test_setting_attributes
6
6
  attributes = {
7
- '_embedded' => { "payments" => [
8
- { 'id' => "tr_1" },
9
- { 'id' => "tr_2" },
7
+ '_embedded' => { 'payments' => [
8
+ { 'id' => 'tr_1' },
9
+ { 'id' => 'tr_2' }
10
10
  ] },
11
11
  'count' => 2,
12
12
  '_links' => {
13
- "self" => {
14
- "href" => "https://api.mollie.com/v2/payments?limit=5",
15
- "type" => "application/hal+json"
13
+ 'self' => {
14
+ 'href' => 'https://api.mollie.com/v2/payments?limit=5',
15
+ 'type' => 'application/hal+json'
16
16
  },
17
- "previous" => {
18
- "href" => "https://api.mollie.com/v2/payments?from=tr_1&limit=1",
19
- "type" => "application/hal+json"
17
+ 'previous' => {
18
+ 'href' => 'https://api.mollie.com/v2/payments?from=tr_1&limit=1',
19
+ 'type' => 'application/hal+json'
20
20
  },
21
- "next" => {
22
- "href" => "https://api.mollie.com/v2/payments?from=tr_2&limit=1",
23
- "type" => "application/hal+json"
21
+ 'next' => {
22
+ 'href' => 'https://api.mollie.com/v2/payments?from=tr_2&limit=1',
23
+ 'type' => 'application/hal+json'
24
24
  },
25
- "documentation" => {
26
- "href" => "https://docs.mollie.com/reference/payments/list",
27
- "type" => "text/html"
25
+ 'documentation' => {
26
+ 'href' => 'https://docs.mollie.com/reference/payments/list',
27
+ 'type' => 'text/html'
28
28
  }
29
29
  }
30
30
  }
@@ -33,17 +33,17 @@ module Mollie
33
33
 
34
34
  assert_equal 2, list.count
35
35
  assert_kind_of Payment, list.to_a[0]
36
- assert_equal "tr_1", list.to_a[0].id
36
+ assert_equal 'tr_1', list.to_a[0].id
37
37
 
38
38
  assert_kind_of Payment, list.to_a[1]
39
- assert_equal "tr_2", list.to_a[1].id
39
+ assert_equal 'tr_2', list.to_a[1].id
40
40
  end
41
41
 
42
42
  def test_next_page
43
- stub_request(:get, "https://api.mollie.com/v2/payments?from=tr_WDqYK6vllg&limit=10").
44
- to_return(
43
+ stub_request(:get, 'https://api.mollie.com/v2/payments?from=tr_WDqYK6vllg&limit=10')
44
+ .to_return(
45
45
  status: 200,
46
- body: %{{"_embedded":{"payments":[{"id":"tr_1"},{"id":"tr_2"}]},"count":2}},
46
+ body: %({"_embedded":{"payments":[{"id":"tr_1"},{"id":"tr_2"}]},"count":2}),
47
47
  headers: {}
48
48
  )
49
49
 
@@ -61,10 +61,10 @@ module Mollie
61
61
  end
62
62
 
63
63
  def test_previous_page
64
- stub_request(:get, "https://api.mollie.com/v2/payments?from=tr_SDkzMggpvx&limit=10").
65
- to_return(
64
+ stub_request(:get, 'https://api.mollie.com/v2/payments?from=tr_SDkzMggpvx&limit=10')
65
+ .to_return(
66
66
  status: 200,
67
- body: %{{"_embedded":{"payments":[{"id":"tr_1"},{"id":"tr_2"}]},"count":2}},
67
+ body: %({"_embedded":{"payments":[{"id":"tr_1"},{"id":"tr_2"}]},"count":2}),
68
68
  headers: {}
69
69
  )
70
70
 
@@ -4,20 +4,20 @@ module Mollie
4
4
  class MethodTest < Test::Unit::TestCase
5
5
  def test_setting_attributes
6
6
  attributes = {
7
- id: "creditcard",
8
- description: "Credit card",
7
+ id: 'creditcard',
8
+ description: 'Credit card',
9
9
  image: {
10
- 'size1x' => "https://www.mollie.com/images/payscreen/methods/creditcard.png",
11
- 'size2x' => "https://www.mollie.com/images/payscreen/methods/creditcard@2x.png"
10
+ 'size1x' => 'https://www.mollie.com/images/payscreen/methods/creditcard.png',
11
+ 'size2x' => 'https://www.mollie.com/images/payscreen/methods/creditcard@2x.png'
12
12
  }
13
13
  }
14
14
 
15
15
  method = Method.new(attributes)
16
16
 
17
- assert_equal "creditcard", method.id
18
- assert_equal "Credit card", method.description
19
- assert_equal "https://www.mollie.com/images/payscreen/methods/creditcard.png", method.normal_image
20
- assert_equal "https://www.mollie.com/images/payscreen/methods/creditcard@2x.png", method.bigger_image
17
+ assert_equal 'creditcard', method.id
18
+ assert_equal 'Credit card', method.description
19
+ assert_equal 'https://www.mollie.com/images/payscreen/methods/creditcard.png', method.normal_image
20
+ assert_equal 'https://www.mollie.com/images/payscreen/methods/creditcard@2x.png', method.bigger_image
21
21
  end
22
22
  end
23
23
  end
@@ -8,13 +8,13 @@ module Mollie
8
8
  name: 'Mollie B.V.',
9
9
  email: 'info@mollie.com',
10
10
  address: {
11
- street_and_number: "Keizersgracht 313",
12
- postal_code: "1016 EE",
13
- city: "Amsterdam",
14
- country: "NL"
11
+ street_and_number: 'Keizersgracht 313',
12
+ postal_code: '1016 EE',
13
+ city: 'Amsterdam',
14
+ country: 'NL'
15
15
  },
16
16
  registration_number: '30204462',
17
- vat_number: 'NL815839091B01',
17
+ vat_number: 'NL815839091B01'
18
18
  }
19
19
 
20
20
  organization = Organization.new(attributes)
@@ -31,16 +31,16 @@ module Mollie
31
31
  end
32
32
 
33
33
  def test_current_organization
34
- stub_request(:get, "https://api.mollie.com/v2/organizations/me")
35
- .to_return(:status => 200, :body => %{
34
+ stub_request(:get, 'https://api.mollie.com/v2/organizations/me')
35
+ .to_return(status: 200, body: %(
36
36
  {
37
37
  "resource": "organization",
38
38
  "id": "org_12345678"
39
39
  }
40
- }, :headers => {})
40
+ ), headers: {})
41
41
 
42
42
  organization = Organization.current
43
- assert_equal "org_12345678", organization.id
43
+ assert_equal 'org_12345678', organization.id
44
44
  end
45
45
  end
46
46
  end
@@ -9,12 +9,12 @@ module Mollie
9
9
  end
10
10
 
11
11
  def test_list_chargebacks
12
- stub_request(:get, "https://api.mollie.com/v2/payments/pay-id/chargebacks")
13
- .to_return(:status => 200, :body => %{{"_embedded" : {"chargebacks" : [{"id":"re-id"}]}}}, :headers => {})
12
+ stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/chargebacks')
13
+ .to_return(status: 200, body: %({"_embedded" : {"chargebacks" : [{"id":"re-id"}]}}), headers: {})
14
14
 
15
- chargebacks = Mollie::Payment::Chargeback.all(payment_id: "pay-id")
15
+ chargebacks = Mollie::Payment::Chargeback.all(payment_id: 'pay-id')
16
16
 
17
- assert_equal "re-id", chargebacks.first.id
17
+ assert_equal 're-id', chargebacks.first.id
18
18
  end
19
19
  end
20
20
  end
@@ -9,12 +9,12 @@ module Mollie
9
9
  end
10
10
 
11
11
  def test_list_refunds
12
- stub_request(:get, "https://api.mollie.com/v2/payments/pay-id/refunds")
13
- .to_return(:status => 200, :body => %{{"_embedded" : { "refunds" : [{"id":"re-id"}]}}}, :headers => {})
12
+ stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/refunds')
13
+ .to_return(status: 200, body: %({"_embedded" : { "refunds" : [{"id":"re-id"}]}}), headers: {})
14
14
 
15
- refunds = Mollie::Payment::Refund.all(payment_id: "pay-id")
15
+ refunds = Mollie::Payment::Refund.all(payment_id: 'pay-id')
16
16
 
17
- assert_equal "re-id", refunds.first.id
17
+ assert_equal 're-id', refunds.first.id
18
18
  end
19
19
  end
20
20
  end
@@ -4,49 +4,49 @@ module Mollie
4
4
  class PaymentTest < Test::Unit::TestCase
5
5
  def test_setting_attributes
6
6
  attributes = {
7
- resource: "payment",
8
- id: "tr_7UhSN1zuXS",
9
- mode: "test",
10
- created_at: "2018-03-20T09:13:37+00:00",
7
+ resource: 'payment',
8
+ id: 'tr_7UhSN1zuXS',
9
+ mode: 'test',
10
+ created_at: '2018-03-20T09:13:37+00:00',
11
11
  amount: {
12
- "value" => "10.00",
13
- "currency" => "EUR"
12
+ 'value' => '10.00',
13
+ 'currency' => 'EUR'
14
14
  },
15
- description: "My first payment",
16
- method: "ideal",
17
- country_code: "NL",
15
+ description: 'My first payment',
16
+ method: 'ideal',
17
+ country_code: 'NL',
18
18
  metadata: {
19
- order_id: "12345"
19
+ order_id: '12345'
20
20
  },
21
21
  details: {
22
22
  consumer_name: "Hr E G H K\u00fcppers en\/of MW M.J. K\u00fcppers-Veeneman",
23
- consumer_account: "NL53INGB0618365937",
24
- consumer_bic: "INGBNL2A"
23
+ consumer_account: 'NL53INGB0618365937',
24
+ consumer_bic: 'INGBNL2A'
25
25
  },
26
- status: "paid",
27
- paid_at: "2018-03-20T09:14:37+00:00",
26
+ status: 'paid',
27
+ paid_at: '2018-03-20T09:14:37+00:00',
28
28
  is_cancelable: false,
29
- expires_at: "2018-03-20T09:28:37+00:00",
30
- locale: "nl_NL",
31
- profile_id: "pfl_QkEhN94Ba",
32
- sequence_type: "oneoff",
33
- redirect_url: "https://webshop.example.org/order/12345",
34
- webhook_url: "https://webshop.example.org/payments/webhook",
29
+ expires_at: '2018-03-20T09:28:37+00:00',
30
+ locale: 'nl_NL',
31
+ profile_id: 'pfl_QkEhN94Ba',
32
+ sequence_type: 'oneoff',
33
+ redirect_url: 'https://webshop.example.org/order/12345',
34
+ webhook_url: 'https://webshop.example.org/payments/webhook',
35
35
  _links: {
36
- "self" => {
37
- "href" => "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS",
38
- "type" => "application/json"
36
+ 'self' => {
37
+ 'href' => 'https://api.mollie.com/v2/payments/tr_7UhSN1zuXS',
38
+ 'type' => 'application/json'
39
39
  },
40
- "checkout" => {
41
- "href" => "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS",
42
- "type" => "text/html"
40
+ 'checkout' => {
41
+ 'href' => 'https://www.mollie.com/payscreen/select-method/7UhSN1zuXS',
42
+ 'type' => 'text/html'
43
43
  },
44
- "settlement" => {
45
- "href" => "https://webshop.example.org/payment/tr_WDqYK6vllg/settlement",
44
+ 'settlement' => {
45
+ 'href' => 'https://webshop.example.org/payment/tr_WDqYK6vllg/settlement'
46
46
  },
47
- "refunds" => {
48
- "href" => "https://webshop.example.org/payment/tr_WDqYK6vllg/refunds",
49
- "type" => "text/html"
47
+ 'refunds' => {
48
+ 'href' => 'https://webshop.example.org/payment/tr_WDqYK6vllg/refunds',
49
+ 'type' => 'text/html'
50
50
  }
51
51
  }
52
52
  }
@@ -106,35 +106,35 @@ module Mollie
106
106
  end
107
107
 
108
108
  def test_create_payment
109
- stub_request(:post, "https://api.mollie.com/v2/payments")
110
- .with(body: %{{"amount":{"value":1.95,"currency":"EUR"}}})
111
- .to_return(:status => 201, :body => %{{"id":"my-id", "amount":{ "value" : 1.95, "currency" : "EUR"}}}, :headers => {})
109
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
110
+ .with(body: %({"amount":{"value":1.95,"currency":"EUR"}}))
111
+ .to_return(status: 201, body: %({"id":"my-id", "amount":{ "value" : 1.95, "currency" : "EUR"}}), headers: {})
112
112
 
113
- payment = Payment.create(amount: { value: 1.95, currency: "EUR" })
113
+ payment = Payment.create(amount: { value: 1.95, currency: 'EUR' })
114
114
 
115
115
  assert_kind_of Mollie::Payment, payment
116
- assert_equal "my-id", payment.id
117
- assert_equal BigDecimal.new("1.95"), payment.amount.value
116
+ assert_equal 'my-id', payment.id
117
+ assert_equal BigDecimal('1.95'), payment.amount.value
118
118
  assert_equal 'EUR', payment.amount.currency
119
119
  end
120
120
 
121
121
  def test_create_payment_for_customer
122
- stub_request(:post, "https://api.mollie.com/v2/payments")
123
- .with(body: %{{"customerId":"cst_8wmqcHMN4U","amount":{"value":1.95,"currency":"EUR"}}})
124
- .to_return(:status => 201, :body => %{{"id":"my-id", "amount":{ "value" : 1.95, "currency" : "EUR"}, "customerId":"cst_8wmqcHMN4U"}}, :headers => {})
122
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
123
+ .with(body: %({"customerId":"cst_8wmqcHMN4U","amount":{"value":1.95,"currency":"EUR"}}))
124
+ .to_return(status: 201, body: %({"id":"my-id", "amount":{ "value" : 1.95, "currency" : "EUR"}, "customerId":"cst_8wmqcHMN4U"}), headers: {})
125
125
 
126
126
  payment = Payment.create(
127
127
  customer_id: 'cst_8wmqcHMN4U',
128
- amount: { value: 1.95, currency: "EUR" }
128
+ amount: { value: 1.95, currency: 'EUR' }
129
129
  )
130
130
 
131
131
  assert_kind_of Mollie::Payment, payment
132
- assert_equal "cst_8wmqcHMN4U", payment.customer_id
132
+ assert_equal 'cst_8wmqcHMN4U', payment.customer_id
133
133
  end
134
134
 
135
135
  def test_refund!
136
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
137
- .to_return(:status => 200, :body => %{
136
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
137
+ .to_return(status: 200, body: %(
138
138
  {
139
139
  "resource": "payment",
140
140
  "id": "tr_WDqYK6vllg",
@@ -143,24 +143,24 @@ module Mollie
143
143
  "currency": "EUR"
144
144
  }
145
145
  }
146
- }, :headers => {})
146
+ ), headers: {})
147
147
 
148
- stub_request(:post, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds")
149
- .to_return(:status => 200, :body => %{
148
+ stub_request(:post, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds')
149
+ .to_return(status: 200, body: %(
150
150
  {
151
151
  "resource": "refund",
152
152
  "id": "re_4qqhO89gsT"
153
153
  }
154
- }, :headers => {})
154
+ ), headers: {})
155
155
 
156
- payment = Payment.get("tr_WDqYK6vllg")
156
+ payment = Payment.get('tr_WDqYK6vllg')
157
157
  refund = payment.refund!
158
- assert_equal "re_4qqhO89gsT", refund.id
158
+ assert_equal 're_4qqhO89gsT', refund.id
159
159
  end
160
160
 
161
161
  def test_refund_with_custom_amount_and_description
162
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
163
- .to_return(:status => 200, :body => %{
162
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
163
+ .to_return(status: 200, body: %(
164
164
  {
165
165
  "resource": "payment",
166
166
  "id": "tr_WDqYK6vllg",
@@ -169,29 +169,29 @@ module Mollie
169
169
  "currency": "EUR"
170
170
  }
171
171
  }
172
- }, :headers => {})
172
+ ), headers: {})
173
173
 
174
- stub_request(:post, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds")
175
- .with(body: %{{"amount":{"value":"9.95","currency":"EUR"},"description":"Test refund"}})
176
- .to_return(:status => 200, :body => %{
174
+ stub_request(:post, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds')
175
+ .with(body: %({"amount":{"value":"9.95","currency":"EUR"},"description":"Test refund"}))
176
+ .to_return(status: 200, body: %(
177
177
  {
178
178
  "resource": "refund",
179
179
  "id": "re_4qqhO89gsT"
180
180
  }
181
- }, :headers => {})
181
+ ), headers: {})
182
182
 
183
- payment = Payment.get("tr_WDqYK6vllg")
183
+ payment = Payment.get('tr_WDqYK6vllg')
184
184
  refund = payment.refund!(
185
- amount: { value: "9.95", currency: "EUR" },
185
+ amount: { value: '9.95', currency: 'EUR' },
186
186
  description: 'Test refund'
187
187
  )
188
188
 
189
- assert_equal "re_4qqhO89gsT", refund.id
189
+ assert_equal 're_4qqhO89gsT', refund.id
190
190
  end
191
191
 
192
192
  def test_application_fee
193
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
194
- .to_return(:status => 200, :body => %{
193
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
194
+ .to_return(status: 200, body: %(
195
195
  {
196
196
  "application_fee": {
197
197
  "amount": {
@@ -201,146 +201,146 @@ module Mollie
201
201
  "description": "Example application fee"
202
202
  }
203
203
  }
204
- }, :headers => {})
204
+ ), headers: {})
205
205
 
206
- payment = Payment.get("tr_WDqYK6vllg")
206
+ payment = Payment.get('tr_WDqYK6vllg')
207
207
  assert_equal 42.10, payment.application_fee.amount.value
208
- assert_equal "EUR", payment.application_fee.amount.currency
208
+ assert_equal 'EUR', payment.application_fee.amount.currency
209
209
  end
210
210
 
211
211
  def test_list_refunds
212
- stub_request(:get, "https://api.mollie.com/v2/payments/pay-id/refunds")
213
- .to_return(:status => 200, :body => %{{"_embedded" : {"refunds" : [{"id":"ref-id", "payment_id":"pay-id"}]}}}, :headers => {})
212
+ stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/refunds')
213
+ .to_return(status: 200, body: %({"_embedded" : {"refunds" : [{"id":"ref-id", "payment_id":"pay-id"}]}}), headers: {})
214
214
 
215
- refunds = Payment.new(id: "pay-id").refunds
215
+ refunds = Payment.new(id: 'pay-id').refunds
216
216
 
217
- assert_equal "ref-id", refunds.first.id
217
+ assert_equal 'ref-id', refunds.first.id
218
218
  end
219
219
 
220
220
  def test_list_chargebacks
221
- stub_request(:get, "https://api.mollie.com/v2/payments/pay-id/chargebacks")
222
- .to_return(:status => 200, :body => %{{"_embedded" : {"chargebacks" :[{"id":"chb-id", "payment_id":"pay-id"}]}}}, :headers => {})
221
+ stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/chargebacks')
222
+ .to_return(status: 200, body: %({"_embedded" : {"chargebacks" :[{"id":"chb-id", "payment_id":"pay-id"}]}}), headers: {})
223
223
 
224
- chargebacks = Payment.new(id: "pay-id").chargebacks
225
- assert_equal "chb-id", chargebacks.first.id
224
+ chargebacks = Payment.new(id: 'pay-id').chargebacks
225
+ assert_equal 'chb-id', chargebacks.first.id
226
226
  end
227
227
 
228
228
  def test_get_settlement
229
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
230
- .to_return(:status => 200, :body => %{
229
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
230
+ .to_return(status: 200, body: %(
231
231
  {
232
232
  "resource": "payment",
233
233
  "id": "tr_WDqYK6vllg",
234
234
  "settlement_id": "stl_jDk30akdN"
235
235
  }
236
- }, :headers => {})
236
+ ), headers: {})
237
237
 
238
- stub_request(:get, "https://api.mollie.com/v2/settlements/stl_jDk30akdN")
239
- .to_return(:status => 200, :body => %{
238
+ stub_request(:get, 'https://api.mollie.com/v2/settlements/stl_jDk30akdN')
239
+ .to_return(status: 200, body: %(
240
240
  {
241
241
  "resource": "settlement",
242
242
  "id": "stl_jDk30akdN"
243
243
  }
244
- }, :headers => {})
244
+ ), headers: {})
245
245
 
246
- payment = Payment.get("tr_WDqYK6vllg")
246
+ payment = Payment.get('tr_WDqYK6vllg')
247
247
  settlement = payment.settlement
248
- assert_equal "stl_jDk30akdN", settlement.id
248
+ assert_equal 'stl_jDk30akdN', settlement.id
249
249
  end
250
250
 
251
251
  def test_nil_settlement
252
- payment = Payment.new(id: "tr_WDqYK6vllg")
252
+ payment = Payment.new(id: 'tr_WDqYK6vllg')
253
253
  assert payment.settlement.nil?
254
254
  end
255
255
 
256
256
  def test_get_mandate
257
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
258
- .to_return(:status => 200, :body => %{
257
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
258
+ .to_return(status: 200, body: %(
259
259
  {
260
260
  "resource": "payment",
261
261
  "id": "tr_WDqYK6vllg",
262
262
  "mandate_id": "mdt_h3gAaD5zP"
263
263
  }
264
- }, :headers => {})
264
+ ), headers: {})
265
265
 
266
- stub_request(:get, "https://api.mollie.com/v2/mandates/mdt_h3gAaD5zP")
267
- .to_return(:status => 200, :body => %{
266
+ stub_request(:get, 'https://api.mollie.com/v2/mandates/mdt_h3gAaD5zP')
267
+ .to_return(status: 200, body: %(
268
268
  {
269
269
  "resource": "mandate",
270
270
  "id": "mdt_h3gAaD5zP"
271
271
  }
272
- }, :headers => {})
272
+ ), headers: {})
273
273
 
274
- payment = Payment.get("tr_WDqYK6vllg")
274
+ payment = Payment.get('tr_WDqYK6vllg')
275
275
  mandate = payment.mandate
276
- assert_equal "mdt_h3gAaD5zP", mandate.id
276
+ assert_equal 'mdt_h3gAaD5zP', mandate.id
277
277
  end
278
278
 
279
279
  def test_nil_mandate
280
- payment = Payment.new(id: "tr_WDqYK6vllg")
280
+ payment = Payment.new(id: 'tr_WDqYK6vllg')
281
281
  assert payment.mandate.nil?
282
282
  end
283
283
 
284
284
  def test_get_subscription
285
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
286
- .to_return(:status => 200, :body => %{
285
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
286
+ .to_return(status: 200, body: %(
287
287
  {
288
288
  "resource": "payment",
289
289
  "id": "tr_WDqYK6vllg",
290
290
  "subscription_id": "sub_rVKGtNd6s3",
291
291
  "customer_id": "cst_8wmqcHMN4U"
292
292
  }
293
- }, :headers => {})
293
+ ), headers: {})
294
294
 
295
- stub_request(:get, "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_rVKGtNd6s3")
296
- .to_return(:status => 200, :body => %{
295
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_rVKGtNd6s3')
296
+ .to_return(status: 200, body: %(
297
297
  {
298
298
  "resource": "subscription",
299
299
  "id": "sub_rVKGtNd6s3"
300
300
  }
301
- }, :headers => {})
301
+ ), headers: {})
302
302
 
303
- payment = Payment.get("tr_WDqYK6vllg")
303
+ payment = Payment.get('tr_WDqYK6vllg')
304
304
  subscription = payment.subscription
305
- assert_equal "sub_rVKGtNd6s3", subscription.id
305
+ assert_equal 'sub_rVKGtNd6s3', subscription.id
306
306
  end
307
307
 
308
308
  def test_nil_subscription
309
- payment = Payment.new(id: "tr_WDqYK6vllg")
309
+ payment = Payment.new(id: 'tr_WDqYK6vllg')
310
310
  assert payment.subscription.nil?
311
311
 
312
- payment = Payment.new(id: "tr_WDqYK6vllg", customer_id: "cst_8wmqcHMN4U")
312
+ payment = Payment.new(id: 'tr_WDqYK6vllg', customer_id: 'cst_8wmqcHMN4U')
313
313
  assert payment.subscription.nil?
314
314
 
315
- payment = Payment.new(id: "tr_WDqYK6vllg", subscription_id: "sub_rVKGtNd6s3")
315
+ payment = Payment.new(id: 'tr_WDqYK6vllg', subscription_id: 'sub_rVKGtNd6s3')
316
316
  assert payment.subscription.nil?
317
317
  end
318
318
 
319
319
  def test_get_customer
320
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
321
- .to_return(:status => 200, :body => %{
320
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
321
+ .to_return(status: 200, body: %(
322
322
  {
323
323
  "resource": "payment",
324
324
  "id": "tr_WDqYK6vllg",
325
325
  "customer_id": "cst_8wmqcHMN4U"
326
326
  }
327
- }, :headers => {})
327
+ ), headers: {})
328
328
 
329
- stub_request(:get, "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U")
330
- .to_return(:status => 200, :body => %{
329
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U')
330
+ .to_return(status: 200, body: %(
331
331
  {
332
332
  "resource": "customer",
333
333
  "id": "cst_8wmqcHMN4U"
334
334
  }
335
- }, :headers => {})
335
+ ), headers: {})
336
336
 
337
- payment = Payment.get("tr_WDqYK6vllg")
337
+ payment = Payment.get('tr_WDqYK6vllg')
338
338
  customer = payment.customer
339
- assert_equal "cst_8wmqcHMN4U", customer.id
339
+ assert_equal 'cst_8wmqcHMN4U', customer.id
340
340
  end
341
341
 
342
342
  def test_nil_customer
343
- payment = Payment.new(id: "tr_WDqYK6vllg")
343
+ payment = Payment.new(id: 'tr_WDqYK6vllg')
344
344
  assert payment.customer.nil?
345
345
  end
346
346
  end