mollie-api-ruby 4.0.0 → 4.0.1

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 (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
@@ -4,64 +4,64 @@ module Mollie
4
4
  class ChargebackTest < Test::Unit::TestCase
5
5
  def test_setting_attributes
6
6
  attributes = {
7
- id: "re_4qqhO89gsT",
8
- amount: { "value" => "5.95", "currency" => "EUR" },
9
- created_at: "2016-10-08T07:59:53.0Z",
10
- reversed_at: "2016-10-08T07:59:53.0Z",
11
- payment_id: "tr_WDqYK6vllg",
12
- settlement_amount: { "value" => "-5.95", "currency" => "EUR" }
7
+ id: 're_4qqhO89gsT',
8
+ amount: { 'value' => '5.95', 'currency' => 'EUR' },
9
+ created_at: '2016-10-08T07:59:53.0Z',
10
+ reversed_at: '2016-10-08T07:59:53.0Z',
11
+ payment_id: 'tr_WDqYK6vllg',
12
+ settlement_amount: { 'value' => '-5.95', 'currency' => 'EUR' }
13
13
  }
14
14
 
15
15
  chargeback = Chargeback.new(attributes)
16
16
 
17
- assert_equal "re_4qqhO89gsT", chargeback.id
18
- assert_equal BigDecimal.new("5.95"), chargeback.amount.value
19
- assert_equal "EUR", chargeback.amount.currency
20
- assert_equal Time.parse("2016-10-08T07:59:53.0Z"), chargeback.created_at
21
- assert_equal Time.parse("2016-10-08T07:59:53.0Z"), chargeback.reversed_at
22
- assert_equal "tr_WDqYK6vllg", chargeback.payment_id
23
- assert_equal BigDecimal.new("-5.95"), chargeback.settlement_amount.value
24
- assert_equal "EUR", chargeback.settlement_amount.currency
17
+ assert_equal 're_4qqhO89gsT', chargeback.id
18
+ assert_equal BigDecimal('5.95'), chargeback.amount.value
19
+ assert_equal 'EUR', chargeback.amount.currency
20
+ assert_equal Time.parse('2016-10-08T07:59:53.0Z'), chargeback.created_at
21
+ assert_equal Time.parse('2016-10-08T07:59:53.0Z'), chargeback.reversed_at
22
+ assert_equal 'tr_WDqYK6vllg', chargeback.payment_id
23
+ assert_equal BigDecimal('-5.95'), chargeback.settlement_amount.value
24
+ assert_equal 'EUR', chargeback.settlement_amount.currency
25
25
  end
26
26
 
27
27
  def test_reversed?
28
- assert Chargeback.new(reversed_at: "2016-10-08T07:59:53.0Z").reversed?
28
+ assert Chargeback.new(reversed_at: '2016-10-08T07:59:53.0Z').reversed?
29
29
  assert !Chargeback.new(reversed_at: nil).reversed?
30
30
  end
31
31
 
32
32
  def test_get_chargeback
33
- stub_request(:get, "https://api.mollie.com/v2/payments/pay-id/chargebacks/chb-id")
34
- .to_return(:status => 200, :body => %{{"id":"chb-id"}}, :headers => {})
33
+ stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/chargebacks/chb-id')
34
+ .to_return(status: 200, body: %({"id":"chb-id"}), headers: {})
35
35
 
36
- chargeback = Payment::Chargeback.get("chb-id", payment_id: "pay-id")
37
- assert_equal "chb-id", chargeback.id
36
+ chargeback = Payment::Chargeback.get('chb-id', payment_id: 'pay-id')
37
+ assert_equal 'chb-id', chargeback.id
38
38
  end
39
39
 
40
40
  def test_get_payment
41
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/chargebacks/chb_n9z0tp")
42
- .to_return(:status => 200, :body => %{
41
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/chargebacks/chb_n9z0tp')
42
+ .to_return(status: 200, body: %(
43
43
  {
44
44
  "resource": "chargeback",
45
45
  "id": "chb_n9z0tp",
46
46
  "paymentId": "tr_WDqYK6vllg"
47
47
  }
48
- }, :headers => {})
48
+ ), headers: {})
49
49
 
50
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg")
51
- .to_return(:status => 200, :body => %{
50
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
51
+ .to_return(status: 200, body: %(
52
52
  {
53
53
  "resource": "payment",
54
54
  "id": "tr_WDqYK6vllg"
55
55
  }
56
- }, :headers => {})
56
+ ), headers: {})
57
57
 
58
- chargeback = Payment::Chargeback.get("chb_n9z0tp", payment_id: "tr_WDqYK6vllg")
59
- assert_equal "tr_WDqYK6vllg", chargeback.payment.id
58
+ chargeback = Payment::Chargeback.get('chb_n9z0tp', payment_id: 'tr_WDqYK6vllg')
59
+ assert_equal 'tr_WDqYK6vllg', chargeback.payment.id
60
60
  end
61
61
 
62
62
  def test_get_settlement
63
- stub_request(:get, "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/chargebacks/chb_n9z0tp")
64
- .to_return(:status => 200, :body => %{
63
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/chargebacks/chb_n9z0tp')
64
+ .to_return(status: 200, body: %(
65
65
  {
66
66
  "resource": "chargeback",
67
67
  "id": "chb_n9z0tp",
@@ -73,24 +73,23 @@ module Mollie
73
73
  }
74
74
  }
75
75
  }
76
- }, :headers => {})
76
+ ), headers: {})
77
77
 
78
- stub_request(:get, "https://api.mollie.com/v2/settlements/stl_jDk30akdN")
79
- .to_return(:status => 200, :body => %{
78
+ stub_request(:get, 'https://api.mollie.com/v2/settlements/stl_jDk30akdN')
79
+ .to_return(status: 200, body: %(
80
80
  {
81
81
  "resource": "settlement",
82
82
  "id": "stl_jDk30akdN"
83
83
  }
84
- }, :headers => {})
84
+ ), headers: {})
85
85
 
86
- chargeback = Payment::Chargeback.get("chb_n9z0tp", payment_id: "tr_WDqYK6vllg")
87
- assert_equal "stl_jDk30akdN", chargeback.settlement.id
86
+ chargeback = Payment::Chargeback.get('chb_n9z0tp', payment_id: 'tr_WDqYK6vllg')
87
+ assert_equal 'stl_jDk30akdN', chargeback.settlement.id
88
88
  end
89
89
 
90
90
  def test_nil_settlement
91
- chargeback = Payment::Chargeback.new(id: "chb_n9z0tp")
91
+ chargeback = Payment::Chargeback.new(id: 'chb_n9z0tp')
92
92
  assert_nil chargeback.settlement
93
93
  end
94
-
95
94
  end
96
95
  end
@@ -3,60 +3,60 @@ require 'helper'
3
3
  module Mollie
4
4
  class ClientTest < Test::Unit::TestCase
5
5
  def client
6
- Mollie::Client.new("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM")
6
+ Mollie::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
7
7
  end
8
8
 
9
9
  def test_initialize
10
- assert_equal "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM", client.api_key
10
+ assert_equal 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM', client.api_key
11
11
  end
12
12
 
13
13
  def test_setting_the_api_endpoint
14
14
  client = self.client
15
- client.api_endpoint = "http://my.endpoint/"
16
- assert_equal "http://my.endpoint", client.api_endpoint
15
+ client.api_endpoint = 'http://my.endpoint/'
16
+ assert_equal 'http://my.endpoint', client.api_endpoint
17
17
  end
18
18
 
19
19
  def test_perform_http_call_defaults
20
- stub_request(:any, "https://api.mollie.com/v2/my-method")
21
- .with(:headers => { 'Accept' => 'application/json',
22
- 'Content-type' => 'application/json',
23
- 'Authorization' => 'Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM',
24
- 'User-Agent' => /^Mollie\/#{Mollie::VERSION} Ruby\/#{RUBY_VERSION} OpenSSL\/.*$/ })
25
- .to_return(:status => 200, :body => "{}", :headers => {})
26
- client.perform_http_call("GET", "my-method", nil, {})
20
+ stub_request(:any, 'https://api.mollie.com/v2/my-method')
21
+ .with(headers: { 'Accept' => 'application/json',
22
+ 'Content-type' => 'application/json',
23
+ 'Authorization' => 'Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM',
24
+ 'User-Agent' => /^Mollie\/#{Mollie::VERSION} Ruby\/#{RUBY_VERSION} OpenSSL\/.*$/ })
25
+ .to_return(status: 200, body: '{}', headers: {})
26
+ client.perform_http_call('GET', 'my-method', nil, {})
27
27
  end
28
28
 
29
29
  def test_perform_http_call_key_override
30
- stub_request(:any, "https://localhost/v2/my-method")
31
- .with(:headers => { 'Accept' => 'application/json',
32
- 'Content-type' => 'application/json',
33
- 'Authorization' => 'Bearer my_key',
34
- 'User-Agent' => /^Mollie\/#{Mollie::VERSION} Ruby\/#{RUBY_VERSION} OpenSSL\/.*$/ })
35
- .to_return(:status => 200, :body => "{}", :headers => {})
36
- client.perform_http_call("GET", "my-method", nil, {api_key: 'my_key', api_endpoint: 'https://localhost'})
37
- client.perform_http_call("GET", "my-method", nil, {}, {api_key: 'my_key', api_endpoint: 'https://localhost'})
30
+ stub_request(:any, 'https://localhost/v2/my-method')
31
+ .with(headers: { 'Accept' => 'application/json',
32
+ 'Content-type' => 'application/json',
33
+ 'Authorization' => 'Bearer my_key',
34
+ 'User-Agent' => /^Mollie\/#{Mollie::VERSION} Ruby\/#{RUBY_VERSION} OpenSSL\/.*$/ })
35
+ .to_return(status: 200, body: '{}', headers: {})
36
+ client.perform_http_call('GET', 'my-method', nil, { api_key: 'my_key', api_endpoint: 'https://localhost' })
37
+ client.perform_http_call('GET', 'my-method', nil, {}, { api_key: 'my_key', api_endpoint: 'https://localhost' })
38
38
  end
39
39
 
40
40
  def test_perform_http_call_with_api_key_block
41
- stub_request(:any, "https://api.mollie.com/v2/my-method")
42
- .with(:headers => { 'Accept' => 'application/json',
43
- 'Content-type' => 'application/json',
44
- 'Authorization' => 'Bearer my_key',
45
- 'User-Agent' => /^Mollie\/#{Mollie::VERSION} Ruby\/#{RUBY_VERSION} OpenSSL\/.*$/ })
46
- .to_return(:status => 200, :body => "{}", :headers => {})
47
-
48
- Mollie::Client.instance.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
49
- Mollie::Client.with_api_key("my_key") do
50
- assert_equal "my_key", Mollie::Client.instance.api_key
51
- Mollie::Client.instance.perform_http_call("GET", "my-method", nil, {})
41
+ stub_request(:any, 'https://api.mollie.com/v2/my-method')
42
+ .with(headers: { 'Accept' => 'application/json',
43
+ 'Content-type' => 'application/json',
44
+ 'Authorization' => 'Bearer my_key',
45
+ 'User-Agent' => /^Mollie\/#{Mollie::VERSION} Ruby\/#{RUBY_VERSION} OpenSSL\/.*$/ })
46
+ .to_return(status: 200, body: '{}', headers: {})
47
+
48
+ Mollie::Client.instance.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
49
+ Mollie::Client.with_api_key('my_key') do
50
+ assert_equal 'my_key', Mollie::Client.instance.api_key
51
+ Mollie::Client.instance.perform_http_call('GET', 'my-method', nil, {})
52
52
  end
53
- assert_equal "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM", Mollie::Client.instance.api_key
53
+ assert_equal 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM', Mollie::Client.instance.api_key
54
54
  end
55
55
 
56
56
  def test_get_request_convert_to_camel_case
57
- stub_request(:get, "https://api.mollie.com/v2/my-method?myParam=ok")
58
- .to_return(:status => 200, :body => "{}", :headers => {})
59
- client.perform_http_call("GET", "my-method", nil, {}, { my_param: "ok" })
57
+ stub_request(:get, 'https://api.mollie.com/v2/my-method?myParam=ok')
58
+ .to_return(status: 200, body: '{}', headers: {})
59
+ client.perform_http_call('GET', 'my-method', nil, {}, { my_param: 'ok' })
60
60
  end
61
61
 
62
62
  def test_get_response_convert_to_snake_case
@@ -75,34 +75,34 @@ module Mollie
75
75
 
76
76
  expected_response = {
77
77
  'some_camel_cased' =>
78
- { 'also_nested' => "camelCaseValue" },
78
+ { 'also_nested' => 'camelCaseValue' },
79
79
  'even_lists' => [
80
- { 'with_camel_case' => "camelCaseValue" }
80
+ { 'with_camel_case' => 'camelCaseValue' }
81
81
  ]
82
82
  }
83
83
 
84
- stub_request(:get, "https://api.mollie.com/v2/my-method")
85
- .to_return(:status => 200, :body => response_body, :headers => {})
86
- response = client.perform_http_call("GET", "my-method", nil, {})
84
+ stub_request(:get, 'https://api.mollie.com/v2/my-method')
85
+ .to_return(status: 200, body: response_body, headers: {})
86
+ response = client.perform_http_call('GET', 'my-method', nil, {})
87
87
 
88
88
  assert_equal expected_response, response
89
89
  end
90
90
 
91
91
  def test_post_requests_convert_to_camel_case
92
- expected_body = %{{"redirectUrl":"my-url"}}
92
+ expected_body = %({"redirectUrl":"my-url"})
93
93
 
94
- stub_request(:post, "https://api.mollie.com/v2/my-method")
94
+ stub_request(:post, 'https://api.mollie.com/v2/my-method')
95
95
  .with(body: expected_body)
96
- .to_return(:status => 200, :body => "{}", :headers => {})
96
+ .to_return(status: 200, body: '{}', headers: {})
97
97
 
98
- client.perform_http_call("POST", "my-method", nil, redirect_url: "my-url")
98
+ client.perform_http_call('POST', 'my-method', nil, redirect_url: 'my-url')
99
99
  end
100
100
 
101
101
  def test_delete_requests_with_no_content_responses
102
- stub_request(:delete, "https://api.mollie.com/v2/my-method/1")
103
- .to_return(:status => 204, :body => "", :headers => {})
102
+ stub_request(:delete, 'https://api.mollie.com/v2/my-method/1')
103
+ .to_return(status: 204, body: '', headers: {})
104
104
 
105
- client.perform_http_call("DELETE", "my-method", "1")
105
+ client.perform_http_call('DELETE', 'my-method', '1')
106
106
  end
107
107
 
108
108
  def test_error_response
@@ -122,11 +122,11 @@ module Mollie
122
122
  JSON
123
123
 
124
124
  json = JSON.parse(response)
125
- stub_request(:post, "https://api.mollie.com/v2/my-method")
126
- .to_return(:status => 401, :body => response, :headers => {})
125
+ stub_request(:post, 'https://api.mollie.com/v2/my-method')
126
+ .to_return(status: 401, body: response, headers: {})
127
127
 
128
128
  e = assert_raise Mollie::RequestError.new(JSON.parse(response)) do
129
- client.perform_http_call("POST", "my-method", nil, {})
129
+ client.perform_http_call('POST', 'my-method', nil, {})
130
130
  end
131
131
 
132
132
  assert_equal(json['status'], e.status)
@@ -5,28 +5,28 @@ module Mollie
5
5
  class MandateTest < Test::Unit::TestCase
6
6
  def test_setting_attributes
7
7
  attributes = {
8
- id: "mdt_h3gAaD5zP",
9
- status: "valid",
10
- method: "creditcard",
8
+ id: 'mdt_h3gAaD5zP',
9
+ status: 'valid',
10
+ method: 'creditcard',
11
11
  details: {
12
- card_holder: "John Doe",
13
- card_expiry_date: "2016-03-31"
12
+ card_holder: 'John Doe',
13
+ card_expiry_date: '2016-03-31'
14
14
  },
15
- mandate_reference: "YOUR-COMPANY-MD1380",
16
- signature_date: "2018-05-07",
17
- created_at: "2016-04-13T11:32:38.0Z",
15
+ mandate_reference: 'YOUR-COMPANY-MD1380',
16
+ signature_date: '2018-05-07',
17
+ created_at: '2016-04-13T11:32:38.0Z',
18
18
  _links: {
19
- "self" => {
20
- "href" => "https://api.mollie.com/v2/customers/cst_4qqhO89gsT/mandates/mdt_h3gAaD5zP",
21
- "type" => "application/hal+json"
19
+ 'self' => {
20
+ 'href' => 'https://api.mollie.com/v2/customers/cst_4qqhO89gsT/mandates/mdt_h3gAaD5zP',
21
+ 'type' => 'application/hal+json'
22
22
  },
23
- "customer" => {
24
- "href" => "https://api.mollie.com/v2/customers/cst_4qqhO89gsT",
25
- "type" => "application/hal+json"
23
+ 'customer' => {
24
+ 'href' => 'https://api.mollie.com/v2/customers/cst_4qqhO89gsT',
25
+ 'type' => 'application/hal+json'
26
26
  },
27
- "documentation" => {
28
- "href" => "https://docs.mollie.com/reference/v2/mandates-api/get-mandate",
29
- "type" => "text/html"
27
+ 'documentation' => {
28
+ 'href' => 'https://docs.mollie.com/reference/v2/mandates-api/get-mandate',
29
+ 'type' => 'text/html'
30
30
  }
31
31
  }
32
32
  }
@@ -57,40 +57,40 @@ module Mollie
57
57
  end
58
58
 
59
59
  def test_get_mandate
60
- stub_request(:get, "https://api.mollie.com/v2/customers/cus-id/mandates/man-id")
61
- .to_return(:status => 200, :body => %{{"id":"man-id", "method":"directdebit"}}, :headers => {})
60
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cus-id/mandates/man-id')
61
+ .to_return(status: 200, body: %({"id":"man-id", "method":"directdebit"}), headers: {})
62
62
 
63
- mandate = Customer::Mandate.get("man-id", customer_id: "cus-id")
63
+ mandate = Customer::Mandate.get('man-id', customer_id: 'cus-id')
64
64
 
65
- assert_equal "man-id", mandate.id
66
- assert_equal "directdebit", mandate.method
65
+ assert_equal 'man-id', mandate.id
66
+ assert_equal 'directdebit', mandate.method
67
67
  end
68
68
 
69
69
  def test_create_mandate
70
- stub_request(:post, "https://api.mollie.com/v2/customers/cus-id/mandates")
71
- .with(body: %{{"method":"directdebit"}})
72
- .to_return(:status => 201, :body => %{{"id":"my-id", "method":"directdebit"}}, :headers => {})
70
+ stub_request(:post, 'https://api.mollie.com/v2/customers/cus-id/mandates')
71
+ .with(body: %({"method":"directdebit"}))
72
+ .to_return(status: 201, body: %({"id":"my-id", "method":"directdebit"}), headers: {})
73
73
 
74
74
  mandate = Customer::Mandate.create(
75
- method: "directdebit",
76
- customer_id: "cus-id"
75
+ method: 'directdebit',
76
+ customer_id: 'cus-id'
77
77
  )
78
78
 
79
- assert_equal "my-id", mandate.id
80
- assert_equal "directdebit", mandate.method
79
+ assert_equal 'my-id', mandate.id
80
+ assert_equal 'directdebit', mandate.method
81
81
  end
82
82
 
83
83
  def test_delete_mandate
84
- stub_request(:delete, "https://api.mollie.com/v2/customers/cus-id/mandates/man-id")
85
- .to_return(:status => 204, :headers => {})
84
+ stub_request(:delete, 'https://api.mollie.com/v2/customers/cus-id/mandates/man-id')
85
+ .to_return(status: 204, headers: {})
86
86
 
87
- mandate = Customer::Mandate.delete("man-id", customer_id: "cus-id")
87
+ mandate = Customer::Mandate.delete('man-id', customer_id: 'cus-id')
88
88
  assert_equal nil, mandate
89
89
  end
90
90
 
91
91
  def test_get_customer
92
- stub_request(:get, "https://api.mollie.com/v2/customers/cst_4qqhO89gsT/mandates/mdt_h3gAaD5zP")
93
- .to_return(:status => 200, :body => %{
92
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_4qqhO89gsT/mandates/mdt_h3gAaD5zP')
93
+ .to_return(status: 200, body: %(
94
94
  {
95
95
  "resource": "mandate",
96
96
  "id": "mdt_h3gAaD5zP",
@@ -101,18 +101,18 @@ module Mollie
101
101
  }
102
102
  }
103
103
  }
104
- }, :headers => {})
104
+ ), headers: {})
105
105
 
106
- stub_request(:get, "https://api.mollie.com/v2/customers/cst_4qqhO89gsT")
107
- .to_return(:status => 200, :body => %{
106
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_4qqhO89gsT')
107
+ .to_return(status: 200, body: %(
108
108
  {
109
109
  "resource": "customer",
110
110
  "id": "cst_4qqhO89gsT"
111
111
  }
112
- }, :headers => {})
112
+ ), headers: {})
113
113
 
114
- mandate = Customer::Mandate.get("mdt_h3gAaD5zP", customer_id: 'cst_4qqhO89gsT')
115
- assert_equal "cst_4qqhO89gsT", mandate.customer.id
114
+ mandate = Customer::Mandate.get('mdt_h3gAaD5zP', customer_id: 'cst_4qqhO89gsT')
115
+ assert_equal 'cst_4qqhO89gsT', mandate.customer.id
116
116
  end
117
117
  end
118
118
  end
@@ -8,15 +8,14 @@ module Mollie
8
8
  assert_kind_of Mollie::Payment, payment
9
9
  end
10
10
 
11
-
12
11
  def test_list_payments
13
- stub_request(:get, "https://api.mollie.com/v2/customers/cus-id/payments")
14
- .to_return(:status => 200, :body => %{{"_embedded" : { "payments" : [{"id":"pay-id", "customer_id":"cus-id"}]}}}, :headers => {})
12
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cus-id/payments')
13
+ .to_return(status: 200, body: %({"_embedded" : { "payments" : [{"id":"pay-id", "customer_id":"cus-id"}]}}), headers: {})
15
14
 
16
- payments = Payment.all(customer_id: "cus-id")
15
+ payments = Payment.all(customer_id: 'cus-id')
17
16
 
18
- assert_equal "pay-id", payments.first.id
19
- assert_equal "cus-id", payments.first.customer_id
17
+ assert_equal 'pay-id', payments.first.id
18
+ assert_equal 'cus-id', payments.first.customer_id
20
19
  end
21
20
  end
22
21
  end
@@ -5,35 +5,35 @@ module Mollie
5
5
  class SubscriptionTest < Test::Unit::TestCase
6
6
  def test_setting_attributes
7
7
  attributes = {
8
- id: "sub_rVKGtNd6s3",
9
- customer_id: "cst_stTC2WHAuS",
10
- mode: "live",
11
- created_at: "2016-06-01T12:23:34.0Z",
12
- status: "active",
13
- amount: { "value" => "25.00", "currency" => "EUR" },
8
+ id: 'sub_rVKGtNd6s3',
9
+ customer_id: 'cst_stTC2WHAuS',
10
+ mode: 'live',
11
+ created_at: '2016-06-01T12:23:34.0Z',
12
+ status: 'active',
13
+ amount: { 'value' => '25.00', 'currency' => 'EUR' },
14
14
  times: 4,
15
- interval: "3 months",
16
- description: "Quarterly payment",
17
- method: "creditcard",
18
- canceled_at: "2016-06-01T12:23:34.0Z",
19
- webhook_url: "https://example.org/payments/webhook"
15
+ interval: '3 months',
16
+ description: 'Quarterly payment',
17
+ method: 'creditcard',
18
+ canceled_at: '2016-06-01T12:23:34.0Z',
19
+ webhook_url: 'https://example.org/payments/webhook'
20
20
  }
21
21
 
22
22
  subscription = Subscription.new(attributes)
23
23
 
24
- assert_equal "sub_rVKGtNd6s3", subscription.id
25
- assert_equal "cst_stTC2WHAuS", subscription.customer_id
26
- assert_equal "live", subscription.mode
27
- assert_equal Time.parse("2016-06-01T12:23:34.0Z"), subscription.created_at
28
- assert_equal "active", subscription.status
29
- assert_equal BigDecimal.new("25.00"), subscription.amount.value
30
- assert_equal "EUR", subscription.amount.currency
24
+ assert_equal 'sub_rVKGtNd6s3', subscription.id
25
+ assert_equal 'cst_stTC2WHAuS', subscription.customer_id
26
+ assert_equal 'live', subscription.mode
27
+ assert_equal Time.parse('2016-06-01T12:23:34.0Z'), subscription.created_at
28
+ assert_equal 'active', subscription.status
29
+ assert_equal BigDecimal('25.00'), subscription.amount.value
30
+ assert_equal 'EUR', subscription.amount.currency
31
31
  assert_equal 4, subscription.times
32
- assert_equal "3 months", subscription.interval
33
- assert_equal "Quarterly payment", subscription.description
34
- assert_equal "creditcard", subscription.method
35
- assert_equal Time.parse("2016-06-01T12:23:34.0Z"), subscription.canceled_at
36
- assert_equal "https://example.org/payments/webhook", subscription.webhook_url
32
+ assert_equal '3 months', subscription.interval
33
+ assert_equal 'Quarterly payment', subscription.description
34
+ assert_equal 'creditcard', subscription.method
35
+ assert_equal Time.parse('2016-06-01T12:23:34.0Z'), subscription.canceled_at
36
+ assert_equal 'https://example.org/payments/webhook', subscription.webhook_url
37
37
  end
38
38
 
39
39
  def test_status_active
@@ -62,55 +62,55 @@ module Mollie
62
62
  end
63
63
 
64
64
  def test_get_subscription
65
- stub_request(:get, "https://api.mollie.com/v2/customers/cus-id/subscriptions/sub-id")
66
- .to_return(:status => 200, :body => %{{"id":"sub-id", "customer_id":"cus-id"}}, :headers => {})
65
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cus-id/subscriptions/sub-id')
66
+ .to_return(status: 200, body: %({"id":"sub-id", "customer_id":"cus-id"}), headers: {})
67
67
 
68
- subscription = Customer::Subscription.get("sub-id", customer_id: "cus-id")
68
+ subscription = Customer::Subscription.get('sub-id', customer_id: 'cus-id')
69
69
 
70
- assert_equal "sub-id", subscription.id
71
- assert_equal "cus-id", subscription.customer_id
70
+ assert_equal 'sub-id', subscription.id
71
+ assert_equal 'cus-id', subscription.customer_id
72
72
  end
73
73
 
74
74
  def test_create_subscription
75
- stub_request(:post, "https://api.mollie.com/v2/customers/cus-id/subscriptions")
76
- .with(body: %{{"amount":{"value":1.95,"currency":"EUR"}}})
77
- .to_return(:status => 201, :body => %{{"id":"my-id", "amount": { "value" : 1.95, "currency": "EUR"}}}, :headers => {})
75
+ stub_request(:post, 'https://api.mollie.com/v2/customers/cus-id/subscriptions')
76
+ .with(body: %({"amount":{"value":1.95,"currency":"EUR"}}))
77
+ .to_return(status: 201, body: %({"id":"my-id", "amount": { "value" : 1.95, "currency": "EUR"}}), headers: {})
78
78
 
79
- subscription = Customer::Subscription.create(customer_id: 'cus-id', amount: { value: 1.95, currency: "EUR" })
79
+ subscription = Customer::Subscription.create(customer_id: 'cus-id', amount: { value: 1.95, currency: 'EUR' })
80
80
 
81
- assert_equal "my-id", subscription.id
82
- assert_equal BigDecimal.new("1.95"), subscription.amount.value
81
+ assert_equal 'my-id', subscription.id
82
+ assert_equal BigDecimal('1.95'), subscription.amount.value
83
83
  end
84
84
 
85
85
  def test_delete_subscription
86
- stub_request(:delete, "https://api.mollie.com/v2/customers/cus-id/subscriptions/sub-id")
87
- .to_return(:status => 204, :headers => {})
86
+ stub_request(:delete, 'https://api.mollie.com/v2/customers/cus-id/subscriptions/sub-id')
87
+ .to_return(status: 204, headers: {})
88
88
 
89
- subscription = Customer::Subscription.delete("sub-id", customer_id: "cus-id")
89
+ subscription = Customer::Subscription.delete('sub-id', customer_id: 'cus-id')
90
90
  assert_equal nil, subscription
91
91
  end
92
92
 
93
93
  def test_get_customer
94
- stub_request(:get, "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_rVKGtNd6s3")
95
- .to_return(:status => 200, :body => %{
94
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_rVKGtNd6s3')
95
+ .to_return(status: 200, body: %(
96
96
  {
97
97
  "resource": "subscription",
98
98
  "id": "sub_rVKGtNd6s3",
99
99
  "customer_id": "cst_8wmqcHMN4U"
100
100
  }
101
- }, :headers => {})
101
+ ), headers: {})
102
102
 
103
- stub_request(:get, "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U")
104
- .to_return(:status => 200, :body => %{
103
+ stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U')
104
+ .to_return(status: 200, body: %(
105
105
  {
106
106
  "resource": "customer",
107
107
  "id": "cst_8wmqcHMN4U"
108
108
  }
109
- }, :headers => {})
109
+ ), headers: {})
110
110
 
111
- payment = Customer::Subscription.get("sub_rVKGtNd6s3", customer_id: "cst_8wmqcHMN4U")
111
+ payment = Customer::Subscription.get('sub_rVKGtNd6s3', customer_id: 'cst_8wmqcHMN4U')
112
112
  customer = payment.customer
113
- assert_equal "cst_8wmqcHMN4U", customer.id
113
+ assert_equal 'cst_8wmqcHMN4U', customer.id
114
114
  end
115
115
  end
116
116
  end