mollie-api-ruby 2.2.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +37 -8
  4. data/examples/apis/api_docs.rb +1 -1
  5. data/examples/apis/chargebacks.rb +17 -0
  6. data/examples/apis/connect.rb +1 -1
  7. data/examples/apis/customers.rb +7 -6
  8. data/examples/apis/invoices.rb +2 -2
  9. data/examples/apis/issuers.rb +2 -2
  10. data/examples/apis/mandates.rb +5 -5
  11. data/examples/apis/methods.rb +2 -2
  12. data/examples/apis/organizations.rb +1 -1
  13. data/examples/apis/payments.rb +43 -9
  14. data/examples/apis/permissions.rb +2 -2
  15. data/examples/apis/profiles.rb +7 -7
  16. data/examples/apis/refunds.rb +1 -1
  17. data/examples/apis/settlements.rb +5 -5
  18. data/examples/apis/subscriptions.rb +7 -7
  19. data/examples/config.ru +6 -7
  20. data/lib/{mollie/api/cacert.pem → cacert.pem} +0 -0
  21. data/lib/mollie-api-ruby.rb +1 -0
  22. data/lib/mollie.rb +39 -0
  23. data/lib/mollie/base.rb +91 -0
  24. data/lib/mollie/chargeback.rb +36 -0
  25. data/lib/mollie/client.rb +125 -0
  26. data/lib/mollie/customer.rb +36 -0
  27. data/lib/mollie/customer/mandate.rb +33 -0
  28. data/lib/mollie/customer/payment.rb +6 -0
  29. data/lib/mollie/customer/subscription.rb +65 -0
  30. data/lib/mollie/exception.rb +8 -0
  31. data/lib/mollie/invoice.rb +66 -0
  32. data/lib/mollie/issuer.rb +5 -0
  33. data/lib/mollie/list.rb +40 -0
  34. data/lib/mollie/method.rb +38 -0
  35. data/lib/mollie/organization.rb +24 -0
  36. data/lib/mollie/payment.rb +142 -0
  37. data/lib/mollie/payment/chargeback.rb +6 -0
  38. data/lib/mollie/payment/refund.rb +6 -0
  39. data/lib/mollie/permission.rb +26 -0
  40. data/lib/mollie/profile.rb +78 -0
  41. data/lib/mollie/profile/api_key.rb +19 -0
  42. data/lib/mollie/refund.rb +42 -0
  43. data/lib/mollie/relation.rb +36 -0
  44. data/lib/mollie/settlement.rb +36 -0
  45. data/lib/mollie/settlement/chargeback.rb +6 -0
  46. data/lib/mollie/settlement/payment.rb +6 -0
  47. data/lib/mollie/settlement/refund.rb +6 -0
  48. data/lib/mollie/util.rb +57 -0
  49. data/lib/mollie/version.rb +3 -0
  50. data/mollie.gemspec +2 -2
  51. data/test/helper.rb +5 -1
  52. data/test/mollie/base_test.rb +182 -0
  53. data/test/mollie/chargeback_test.rb +35 -0
  54. data/test/mollie/client_test.rb +122 -0
  55. data/test/mollie/customer/mandate_test.rb +43 -0
  56. data/test/mollie/customer/payment_test.rb +23 -0
  57. data/test/mollie/customer/subscription_test.rb +66 -0
  58. data/test/mollie/customer_test.rb +128 -0
  59. data/test/mollie/invoice_test.rb +55 -0
  60. data/test/mollie/issuer_test.rb +19 -0
  61. data/test/mollie/list_test.rb +40 -0
  62. data/test/mollie/method_test.rb +29 -0
  63. data/test/mollie/organization_test.rb +41 -0
  64. data/test/mollie/payment/chargeback_test.rb +22 -0
  65. data/test/mollie/payment/refund_test.rb +22 -0
  66. data/test/mollie/payment_test.rb +161 -0
  67. data/test/mollie/permission_test.rb +21 -0
  68. data/test/mollie/profile/apikey_test.rb +31 -0
  69. data/test/mollie/profile_test.rb +98 -0
  70. data/test/mollie/refund_test.rb +40 -0
  71. data/test/mollie/settlement/chargeback_test.rb +22 -0
  72. data/test/mollie/settlement/payment_test.rb +22 -0
  73. data/test/mollie/settlement/refund_test.rb +22 -0
  74. data/test/mollie/settlement_test.rb +156 -0
  75. data/website-docs/chargebacks/list-all.rb +12 -0
  76. data/website-docs/connect/authorize.rb +15 -0
  77. data/website-docs/connect/tokens.rb +14 -0
  78. data/website-docs/customers/create-payment.rb +13 -0
  79. data/website-docs/customers/create.rb +12 -0
  80. data/website-docs/customers/delete.rb +10 -0
  81. data/website-docs/customers/get.rb +10 -0
  82. data/website-docs/customers/list-payments.rb +10 -0
  83. data/website-docs/customers/list.rb +12 -0
  84. data/website-docs/customers/update.rb +11 -0
  85. data/website-docs/invoices/get.rb +10 -0
  86. data/website-docs/invoices/list.rb +12 -0
  87. data/website-docs/issuers/get.rb +10 -0
  88. data/website-docs/issuers/list.rb +12 -0
  89. data/website-docs/mandates/create.rb +16 -0
  90. data/website-docs/mandates/delete.rb +10 -0
  91. data/website-docs/mandates/get.rb +10 -0
  92. data/website-docs/mandates/list.rb +12 -0
  93. data/website-docs/methods/get.rb +10 -0
  94. data/website-docs/methods/list.rb +12 -0
  95. data/website-docs/organisations/get.rb +10 -0
  96. data/website-docs/payments/create-refund.rb +14 -0
  97. data/website-docs/payments/create.rb +16 -0
  98. data/website-docs/payments/delete-refund.rb +13 -0
  99. data/website-docs/payments/delete.rb +12 -0
  100. data/website-docs/payments/get-chargeback.rb +11 -0
  101. data/website-docs/payments/get-refund.rb +11 -0
  102. data/website-docs/payments/get.rb +10 -0
  103. data/website-docs/payments/list-chargeback.rb +13 -0
  104. data/website-docs/payments/list-refunds.rb +13 -0
  105. data/website-docs/payments/list.rb +12 -0
  106. data/website-docs/payments/payment-webhook.rb +21 -0
  107. data/website-docs/permissions/get.rb +10 -0
  108. data/website-docs/permissions/list.rb +12 -0
  109. data/website-docs/profiles/create.rb +15 -0
  110. data/website-docs/profiles/delete.rb +10 -0
  111. data/website-docs/profiles/get-key.rb +11 -0
  112. data/website-docs/profiles/get.rb +10 -0
  113. data/website-docs/profiles/list-keys.rb +13 -0
  114. data/website-docs/profiles/list.rb +12 -0
  115. data/website-docs/profiles/reset-key.rb +13 -0
  116. data/website-docs/profiles/update.rb +12 -0
  117. data/website-docs/refunds/list.rb +12 -0
  118. data/website-docs/settlements/get.rb +10 -0
  119. data/website-docs/settlements/list-chargebacks.rb +13 -0
  120. data/website-docs/settlements/list-payments.rb +13 -0
  121. data/website-docs/settlements/list-refunds.rb +13 -0
  122. data/website-docs/settlements/list.rb +12 -0
  123. data/website-docs/settlements/next.rb +9 -0
  124. data/website-docs/settlements/open.rb +9 -0
  125. data/website-docs/subscriptions/create.rb +14 -0
  126. data/website-docs/subscriptions/delete.rb +10 -0
  127. data/website-docs/subscriptions/get.rb +10 -0
  128. data/website-docs/subscriptions/list.rb +12 -0
  129. metadata +134 -104
  130. data/lib/mollie/api/client.rb +0 -161
  131. data/lib/mollie/api/client/version.rb +0 -7
  132. data/lib/mollie/api/exception.rb +0 -10
  133. data/lib/mollie/api/object/base.rb +0 -18
  134. data/lib/mollie/api/object/customer.rb +0 -28
  135. data/lib/mollie/api/object/customer/mandate.rb +0 -37
  136. data/lib/mollie/api/object/customer/subscription.rb +0 -69
  137. data/lib/mollie/api/object/invoice.rb +0 -70
  138. data/lib/mollie/api/object/issuer.rb +0 -9
  139. data/lib/mollie/api/object/list.rb +0 -44
  140. data/lib/mollie/api/object/method.rb +0 -42
  141. data/lib/mollie/api/object/organization.rb +0 -28
  142. data/lib/mollie/api/object/payment.rb +0 -137
  143. data/lib/mollie/api/object/payment/refund.rb +0 -47
  144. data/lib/mollie/api/object/permission.rb +0 -12
  145. data/lib/mollie/api/object/profile.rb +0 -78
  146. data/lib/mollie/api/object/profile/apikey.rb +0 -23
  147. data/lib/mollie/api/object/settlement.rb +0 -32
  148. data/lib/mollie/api/resource/base.rb +0 -53
  149. data/lib/mollie/api/resource/customers.rb +0 -11
  150. data/lib/mollie/api/resource/customers/mandates.rb +0 -27
  151. data/lib/mollie/api/resource/customers/payments.rb +0 -27
  152. data/lib/mollie/api/resource/customers/subscriptions.rb +0 -27
  153. data/lib/mollie/api/resource/invoices.rb +0 -11
  154. data/lib/mollie/api/resource/issuers.rb +0 -11
  155. data/lib/mollie/api/resource/methods.rb +0 -11
  156. data/lib/mollie/api/resource/organizations.rb +0 -11
  157. data/lib/mollie/api/resource/payments.rb +0 -11
  158. data/lib/mollie/api/resource/payments/refunds.rb +0 -27
  159. data/lib/mollie/api/resource/permissions.rb +0 -31
  160. data/lib/mollie/api/resource/profiles.rb +0 -11
  161. data/lib/mollie/api/resource/profiles/apikeys.rb +0 -33
  162. data/lib/mollie/api/resource/refunds.rb +0 -11
  163. data/lib/mollie/api/resource/settlements.rb +0 -19
  164. data/lib/mollie/api/resource/settlements/payments.rb +0 -27
  165. data/lib/mollie/api/util.rb +0 -53
  166. data/test/mollie/api/client_test.rb +0 -111
  167. data/test/mollie/api/object/base_test.rb +0 -21
  168. data/test/mollie/api/object/customer/mandate_test.rb +0 -47
  169. data/test/mollie/api/object/customer/subscription_test.rb +0 -70
  170. data/test/mollie/api/object/customer_test.rb +0 -35
  171. data/test/mollie/api/object/invoice_test.rb +0 -59
  172. data/test/mollie/api/object/issuer_test.rb +0 -23
  173. data/test/mollie/api/object/list_test.rb +0 -44
  174. data/test/mollie/api/object/method_test.rb +0 -33
  175. data/test/mollie/api/object/organization_test.rb +0 -45
  176. data/test/mollie/api/object/payment/refund_test.rb +0 -46
  177. data/test/mollie/api/object/payment_test.rb +0 -106
  178. data/test/mollie/api/object/permission_test.rb +0 -25
  179. data/test/mollie/api/object/profile/apikey_test.rb +0 -35
  180. data/test/mollie/api/object/profile_test.rb +0 -72
  181. data/test/mollie/api/object/settlement_test.rb +0 -140
  182. data/test/mollie/api/resource/base_test.rb +0 -83
  183. data/test/mollie/api/resource/customers/mandates_test.rb +0 -23
  184. data/test/mollie/api/resource/customers/payments_test.rb +0 -23
  185. data/test/mollie/api/resource/customers/subscriptions_test.rb +0 -23
  186. data/test/mollie/api/resource/customers_test.rb +0 -13
  187. data/test/mollie/api/resource/invoices_test.rb +0 -13
  188. data/test/mollie/api/resource/issuers_test.rb +0 -13
  189. data/test/mollie/api/resource/methods_test.rb +0 -13
  190. data/test/mollie/api/resource/organizations_test.rb +0 -13
  191. data/test/mollie/api/resource/payments/refunds_test.rb +0 -23
  192. data/test/mollie/api/resource/payments_test.rb +0 -13
  193. data/test/mollie/api/resource/permissions_test.rb +0 -13
  194. data/test/mollie/api/resource/profiles/apikeys_test.rb +0 -23
  195. data/test/mollie/api/resource/profiles_test.rb +0 -13
  196. data/test/mollie/api/resource/settlements_test.rb +0 -13
  197. data/test/mollie/api/util_test.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7d6b6f21eeda06bcb33555aa029fe76466497263
4
- data.tar.gz: 64aadca75fd234e1df340843b1f92627ffa75a05
2
+ SHA256:
3
+ metadata.gz: 1c2e6be24fa39ccf69510523b4b5a40cb6751db4ea6f819cde67fa3ef395586c
4
+ data.tar.gz: 33c5f94a0ccfe001a1c4762af6bd6e5e1f3759fea8b80ffc845eb2d704ceb778
5
5
  SHA512:
6
- metadata.gz: dac9bb4f03cd09e80eeab7fd0af5ed5f13cc3a3bdabbc71176ab125e829f6b7634512f4afd849dc75f482125687d80db9dbe481e87835ddccc74f7e7460783e6
7
- data.tar.gz: 29dca80e86f9876f1512c76b3a3f872c27e55c5eef8a369b0e08f2edbe97b700a5ca7ce95852a101c4a50906fdfff3fa2ee02b53c80d42054e978541031eabbb
6
+ metadata.gz: 5d0e2c5c93a303db70129236a2ffd11a9b2008683d02c22a5577971b7b9a894a1d3609caa07b05af3c6231683dec75e7ae4142fc66bd12849b5d15bcd179ee7b
7
+ data.tar.gz: 76fc4df609c87e70abde982aa12d8190c10e02a3a5c82a1b0ee28c7a3a17eef57f4d4c1b2d0eed24c26776c99ac8300fc8ecdd84a753b799a9898ad582cb112a
@@ -4,6 +4,13 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ #### 3.1.0 - ....
8
+ - Removed old api
9
+
10
+ #### 3.0.0 - ....
11
+ - Introduced new api
12
+ - Deprecated old api
13
+
7
14
  #### 2.2.1 - 2017-09-13
8
15
  - Added support for gift card method.
9
16
  - Added support for `invoice` endpoint.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png)
2
2
 
3
+ # LOOKING FOR VERSION v2.2.X README [CLICK HERE](https://github.com/mollie/mollie-api-ruby/tree/2.2.x) #
4
+
3
5
  # Mollie API client for Ruby #
4
6
 
5
7
  [![Gem Version](https://badge.fury.io/rb/mollie-api-ruby.svg)](https://badge.fury.io/rb/mollie-api-ruby)
@@ -20,6 +22,9 @@ To use the Mollie API client, the following things are required:
20
22
  By far the easiest way to install the Mollie API client is to install it with [gem](http://rubygems.org/).
21
23
 
22
24
  ```
25
+ # Gemfile
26
+ gem 'mollie-api-ruby'
27
+
23
28
  $ gem install mollie-api-ruby
24
29
  ```
25
30
 
@@ -37,22 +42,46 @@ To successfully receive a payment, these steps should be implemented:
37
42
 
38
43
  ## Getting started ##
39
44
 
40
- Requiring the Mollie API Client.
45
+ Requiring the Mollie API Client. *Not required when used with a Gemfile*
46
+
47
+ ```ruby
48
+ require 'mollie-api-ruby'
49
+ ```
50
+
51
+ Create an initializer and add the following line:
41
52
 
42
53
  ```ruby
43
- require 'mollie/api/client'
54
+ Mollie::Client.configure do |config|
55
+ config.api_key = '<your-api-key>'
56
+ end
57
+ ```
58
+
59
+ You can also include the API Key in each request you make, for instance if you are using the Connect API
60
+
61
+ ```ruby
62
+ Mollie::Payment.get("pay-id", api_key: '<your-api-key>')
44
63
  ```
45
64
 
46
- Initializing the Mollie API client, and setting your API key.
65
+ If you need to do multiple calls with the same API Key, use the following helper
47
66
 
48
67
  ```ruby
49
- mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
68
+ Mollie::Client.with_api_key('<your-api-key>') do
69
+ mandates = Mollie::Customer::Mandate.all(customer_id: params[:customer_id])
70
+ if mandates.any?
71
+ payment = Mollie::Payment.create(
72
+ amount: 10.00,
73
+ description: 'My first API payment',
74
+ redirect_url: 'https://webshop.example.org/order/12345/',
75
+ webhook_url: 'https://webshop.example.org/mollie-webhook/'
76
+ )
77
+ end
78
+ end
50
79
  ```
51
80
 
52
81
  Creating a new payment.
53
82
 
54
83
  ```ruby
55
- payment = mollie.payments.create(
84
+ payment = Mollie::Payment.create(
56
85
  amount: 10.00,
57
86
  description: 'My first API payment',
58
87
  redirect_url: 'https://webshop.example.org/order/12345/',
@@ -63,7 +92,7 @@ payment = mollie.payments.create(
63
92
  Retrieving a payment.
64
93
 
65
94
  ```ruby
66
- payment = mollie.payments.get(payment.id)
95
+ payment = Mollie::Payment.get(payment.id)
67
96
 
68
97
  if payment.paid?
69
98
  puts 'Payment received.'
@@ -77,8 +106,8 @@ definitive. Refunds are only supported for iDEAL, credit card and Bank Transfer
77
106
  be refunded through our API at the moment.
78
107
 
79
108
  ```ruby
80
- payment = mollie.payments.get(payment.id)
81
- refund = mollie.payments_refunds.with(payment).create
109
+ payment = Mollie::Payment.get(payment.id)
110
+ refund = payment.refunds.create
82
111
  ```
83
112
 
84
113
  ## Examples ##
@@ -2,7 +2,7 @@ class Application < Sinatra::Application
2
2
  ::Application
3
3
  swagger_root do
4
4
  key :swagger, '2.0'
5
- info version: Mollie::API::Client::VERSION,
5
+ info version: Mollie::Client::VERSION,
6
6
  title: 'Mollie',
7
7
  description: 'Examples for the mollie api',
8
8
  termsOfService: 'https://github.com/mollie/mollie-api-ruby',
@@ -0,0 +1,17 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/chargebacks' do
3
+ operation :get, description: 'List chargebacks https://www.mollie.com/en/docs/reference/chargebacks/list', tags: ['Chargebacks'] do
4
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
5
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
6
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
7
+ security api_key: []
8
+ response 200, description: 'Successful response'
9
+ response 500, description: 'Unexpected error'
10
+ end
11
+ end
12
+
13
+ get '/v1/chargebacks' do
14
+ chargebacks = Mollie::Chargeback.all(params[:offset], params[:limit], testmode: params[:test_mode])
15
+ JSON.pretty_generate(chargebacks.attributes)
16
+ end
17
+ end
@@ -6,7 +6,7 @@ class Application < Sinatra::Application
6
6
  parameter name: :secret, in: 'query', description: 'oAuth Secret', type: :string
7
7
  parameter name: :redirect_uri, in: 'query', description: 'Redirect URI', type: :string, default: "#{Ngrok::Tunnel.ngrok_url_https}/token"
8
8
  parameter name: :state, in: 'query', description: 'State', type: :string, default: SecureRandom.uuid
9
- parameter name: :scope, in: 'query', description: 'Scope', type: :string, default: Mollie::API::Resource::Permissions.available.join(' ')
9
+ parameter name: :scope, in: 'query', description: 'Scope', type: :string, default: Mollie::Permission::AVAILABLE.join(' ')
10
10
  parameter name: :response_type, in: 'query', description: 'Response Type', type: :string
11
11
  parameter name: :approval_prompt, in: 'query', description: 'Approval prompt', type: :boolean
12
12
  security api_key: []
@@ -64,17 +64,17 @@ class Application < Sinatra::Application
64
64
  end
65
65
 
66
66
  get '/v1/customers' do
67
- customers = client.customers.all(params[:offset], params[:count], testmode: params[:testmode])
67
+ customers = Mollie::Customer.all(params[:offset], params[:count], testmode: params[:testmode])
68
68
  JSON.pretty_generate(customers.attributes)
69
69
  end
70
70
 
71
71
  get '/v1/customers/:id' do
72
- customer = client.customers.get(params[:id], testmode: params[:testmode])
72
+ customer = Mollie::Customer.get(params[:id], testmode: params[:testmode])
73
73
  JSON.pretty_generate(customer.attributes)
74
74
  end
75
75
 
76
76
  post '/v1/customers' do
77
- customer = client.customers.create(
77
+ customer = Mollie::Customer.create(
78
78
  name: json_params['name'],
79
79
  email: json_params['email'],
80
80
  locale: json_params['locale'],
@@ -86,7 +86,7 @@ class Application < Sinatra::Application
86
86
  end
87
87
 
88
88
  patch '/v1/customers/:id' do
89
- customer = client.customers.update(params[:id],
89
+ customer = Mollie::Customer.update(params[:id],
90
90
  name: json_params['name'],
91
91
  email: json_params['email'],
92
92
  locale: json_params['locale'],
@@ -96,12 +96,13 @@ class Application < Sinatra::Application
96
96
  end
97
97
 
98
98
  get '/v1/customers/:customer_id/payments' do
99
- payments = client.customers_payments.with(params[:customer_id]).all(testmode: params[:testmode])
99
+ payments = Mollie::Customer::Payment.all(customer_id: params[:customer_id], testmode: params[:testmode])
100
100
  JSON.pretty_generate(payments.attributes)
101
101
  end
102
102
 
103
103
  post '/v1/customers/:customer_id/payments' do
104
- payment = client.customers_payments.with(params[:customer_id]).create(
104
+ payment = Mollie::Customer::Payment.create(
105
+ customer_id: params[:customer_id],
105
106
  amount: json_params['amount'],
106
107
  description: json_params['description'],
107
108
  redirect_url: json_params['redirect_url'],
@@ -23,7 +23,7 @@ class Application < Sinatra::Application
23
23
  end
24
24
 
25
25
  get '/v1/invoices' do
26
- invoices = client.invoices.all(params[:offset], params[:count],
26
+ invoices = Mollie::Invoice.all(params[:offset], params[:count],
27
27
  include: params[:include],
28
28
  reference: params[:reference],
29
29
  year: params[:year]
@@ -32,7 +32,7 @@ class Application < Sinatra::Application
32
32
  end
33
33
 
34
34
  get '/v1/invoices/:id' do
35
- invoice = client.invoices.get(params[:id], include: params[:include])
35
+ invoice = Mollie::Invoice.get(params[:id], include: params[:include])
36
36
  JSON.pretty_generate(invoice.attributes)
37
37
  end
38
38
  end
@@ -21,13 +21,13 @@ class Application < Sinatra::Application
21
21
  end
22
22
 
23
23
  get '/v1/issuers' do
24
- issuers = client.issuers.all(params[:offset], params[:count],
24
+ issuers = Mollie::Issuer.all(params[:offset], params[:count],
25
25
  testmode: params[:testmode])
26
26
  JSON.pretty_generate(issuers.attributes)
27
27
  end
28
28
 
29
29
  get '/v1/issuers/:id' do
30
- issuer = client.issuers.get(params[:id],
30
+ issuer = Mollie::Issuer.get(params[:id],
31
31
  testmode: params[:testmode]
32
32
  )
33
33
  JSON.pretty_generate(issuer.attributes)
@@ -51,7 +51,8 @@ class Application < Sinatra::Application
51
51
  end
52
52
 
53
53
  post '/v1/customers/:customer_id/mandates' do
54
- mandate = client.customers_mandates.with(params[:customer_id]).create(
54
+ mandate = Mollie::Customer::Mandate.create(
55
+ customer_id: params[:customer_id],
55
56
  method: json_params['method'],
56
57
  consumer_name: json_params['consumer_name'],
57
58
  consumer_account: json_params['consumer_account'],
@@ -65,19 +66,18 @@ class Application < Sinatra::Application
65
66
  end
66
67
 
67
68
  get '/v1/customers/:customer_id/mandates' do
68
- mandates = client.customers_mandates.with(params[:customer_id]).all(params[:offset], params[:count], testmode: params[:testmode]
69
- )
69
+ mandates = Mollie::Customer::Mandate.all(params[:offset], params[:count], testmode: params[:testmode], customer_id: params[:customer_id])
70
70
  JSON.pretty_generate(mandates.attributes)
71
71
  end
72
72
 
73
73
 
74
74
  get '/v1/customers/:customer_id/mandates/:id' do
75
- mandate = client.customers_mandates.with(params[:customer_id]).get(params[:id], testmode: params[:testmode])
75
+ mandate = Mollie::Customer::Mandate.get(params[:id], testmode: params[:testmode], customer_id: params[:customer_id])
76
76
  JSON.pretty_generate(mandate.attributes)
77
77
  end
78
78
 
79
79
  delete '/v1/customers/:customer_id/mandates/:id' do
80
- client.customers_mandates.with(params[:customer_id]).delete(params[:id], testmode: params[:testmode])
80
+ Mollie::Customer::Mandate.delete(params[:id], testmode: params[:testmode], customer_id: params[:customer_id])
81
81
  "deleted"
82
82
  end
83
83
  end
@@ -28,7 +28,7 @@ class Application < Sinatra::Application
28
28
  end
29
29
 
30
30
  get '/v1/methods' do
31
- methods = client.methods.all(params[:offset], params[:count],
31
+ methods = Mollie::Method.all(params[:offset], params[:count],
32
32
  include: params[:include],
33
33
  recurring_type: params[:recurring_type],
34
34
  locale: params[:locale],
@@ -39,7 +39,7 @@ class Application < Sinatra::Application
39
39
  end
40
40
 
41
41
  get '/v1/methods/:id' do
42
- method = client.methods.get(params[:id],
42
+ method = Mollie::Method.get(params[:id],
43
43
  include: params[:include],
44
44
  locale: params[:locale],
45
45
  profile_id: params[:profile_id],
@@ -10,7 +10,7 @@ class Application < Sinatra::Application
10
10
  end
11
11
 
12
12
  get '/v1/organizations/:id' do
13
- organization = client.organizations.get(params[:id], testmode: params[:testmode])
13
+ organization = Mollie::Organization.get(params[:id], testmode: params[:testmode])
14
14
  JSON.pretty_generate(organization.attributes)
15
15
  end
16
16
  end
@@ -67,7 +67,7 @@ class Application < Sinatra::Application
67
67
  end
68
68
 
69
69
  swagger_path '/v1/payments/{payment_id}/refunds/{id}' do
70
- operation :get, description: 'Create payment https://www.mollie.com/nl/docs/reference/refunds/get', tags: ['Payments'] do
70
+ operation :get, description: 'Get refund https://www.mollie.com/nl/docs/reference/refunds/get', tags: ['Payments'] do
71
71
  parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
72
72
  parameter name: :id, in: 'path', description: 'Refund id', type: :string
73
73
  parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
@@ -76,7 +76,7 @@ class Application < Sinatra::Application
76
76
  response 500, description: 'Unexpected error'
77
77
  end
78
78
 
79
- operation :delete, description: 'Delete payment https://www.mollie.com/nl/docs/reference/refunds/delete', tags: ['Payments'] do
79
+ operation :delete, description: 'Delete refund https://www.mollie.com/nl/docs/reference/refunds/delete', tags: ['Payments'] do
80
80
  parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
81
81
  parameter name: :id, in: 'path', description: 'Refund id', type: :string
82
82
  parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
@@ -86,8 +86,31 @@ class Application < Sinatra::Application
86
86
  end
87
87
  end
88
88
 
89
+ swagger_path '/v1/payments/{payment_id}/chargebacks' do
90
+ operation :get, description: 'List payment chargebacks https://www.mollie.com/en/docs/reference/chargebacks/list', tags: ['Payments'] do
91
+ parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
92
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
93
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
94
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
95
+ security api_key: []
96
+ response 200, description: 'Successful response'
97
+ response 500, description: 'Unexpected error'
98
+ end
99
+ end
100
+
101
+ swagger_path '/v1/payments/{payment_id}/chargebacks/{id}' do
102
+ operation :get, description: 'Get chargeback https://www.mollie.com/nl/docs/reference/chargebacks/get', tags: ['Payments'] do
103
+ parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
104
+ parameter name: :id, in: 'path', description: 'Refund id', type: :string
105
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
106
+ security api_key: []
107
+ response 200, description: 'Successful response'
108
+ response 500, description: 'Unexpected error'
109
+ end
110
+ end
111
+
89
112
  get '/v1/payments' do
90
- payments = client.payments.all(params[:offset], params[:count],
113
+ payments = Mollie::Payment.all(params[:offset], params[:count],
91
114
  profile_id: params[:profile_id],
92
115
  testmode: params[:testmode]
93
116
  )
@@ -96,12 +119,12 @@ class Application < Sinatra::Application
96
119
  end
97
120
 
98
121
  get '/v1/payments/:id' do
99
- payment = client.payments.get(params[:id], testmode: params[:testmode])
122
+ payment = Mollie::Payment.get(params[:id], testmode: params[:testmode])
100
123
  JSON.pretty_generate(payment.attributes)
101
124
  end
102
125
 
103
126
  post '/v1/payments' do
104
- payment = client.payments.create(
127
+ payment = Mollie::Payment.create(
105
128
  amount: json_params['amount'],
106
129
  description: json_params['description'],
107
130
  redirect_url: json_params['redirect_url'],
@@ -114,7 +137,8 @@ class Application < Sinatra::Application
114
137
  end
115
138
 
116
139
  post '/v1/payments/:payment_id/refunds' do
117
- refund = client.payments_refunds.with(params[:payment_id]).create(
140
+ refund = Mollie::Payment::Refund.create(
141
+ payment_id: params[:payment_id],
118
142
  amount: json_params['amount'],
119
143
  description: json_params['description'],
120
144
  testmode: json_params['testmode']
@@ -123,18 +147,28 @@ class Application < Sinatra::Application
123
147
  end
124
148
 
125
149
  get '/v1/payments/:payment_id/refunds/:id' do
126
- refund = client.payments_refunds.with(params[:payment_id]).get(params[:id], testmode: params[:testmode])
150
+ refund = Mollie::Payment::Refund.get(params[:id], testmode: params[:testmode], payment_id: params[:payment_id])
127
151
  JSON.pretty_generate(refund.attributes)
128
152
  end
129
153
 
130
154
  delete '/v1/payments/:payment_id/refunds/:id' do
131
- client.payments_refunds.with(params[:payment_id]).delete(params[:id], testmode: params[:testmode])
155
+ Mollie::Payment::Refund.delete(params[:id], testmode: params[:testmode], payment_id: params[:payment_id])
132
156
  "deleted"
133
157
  end
134
158
 
135
159
  get '/v1/payments/:payment_id/refunds' do
136
- refunds = client.payments_refunds.with(params[:payment_id]).all(params[:offset], params[:count], testmode: params[:testmode])
160
+ refunds = Mollie::Payment::Refund.all(params[:offset], params[:count], testmode: params[:testmode], payment_id: params[:payment_id])
137
161
  JSON.pretty_generate(refunds.attributes)
138
162
  end
139
163
 
164
+ get '/v1/payments/:payment_id/chargebacks/:id' do
165
+ chargeback = Mollie::Payment::Chargeback.get(params[:id], testmode: params[:testmode], payment_id: params[:payment_id])
166
+ JSON.pretty_generate(chargeback.attributes)
167
+ end
168
+
169
+ get '/v1/payments/:payment_id/chargebacks' do
170
+ chargebacks = Mollie::Payment::Chargeback.all(params[:offset], params[:count], testmode: params[:testmode], payment_id: params[:payment_id])
171
+ JSON.pretty_generate(chargebacks.attributes)
172
+ end
173
+
140
174
  end
@@ -21,12 +21,12 @@ class Application < Sinatra::Application
21
21
  end
22
22
 
23
23
  get '/v1/permissions' do
24
- permissions = client.permissions.all(params[:offset], params[:count], testmode: params[:testmode])
24
+ permissions = Mollie::Permission.all(params[:offset], params[:count], testmode: params[:testmode])
25
25
  JSON.pretty_generate(permissions.attributes)
26
26
  end
27
27
 
28
28
  get '/v1/permissions/:id' do
29
- permission = client.permissions.get(params[:id], testmode: params[:testmode])
29
+ permission = Mollie::Permission.get(params[:id], testmode: params[:testmode])
30
30
  JSON.pretty_generate(permission.attributes)
31
31
  end
32
32
  end
@@ -76,17 +76,17 @@ class Application < Sinatra::Application
76
76
  end
77
77
 
78
78
  get '/v1/profiles' do
79
- profiles = client.profiles.all(params[:offset], params[:count])
79
+ profiles = Mollie::Profile.all(params[:offset], params[:count])
80
80
  JSON.pretty_generate(profiles.attributes)
81
81
  end
82
82
 
83
83
  get '/v1/profiles/:id' do
84
- profile = client.profiles.get(params[:id])
84
+ profile = Mollie::Profile.get(params[:id])
85
85
  JSON.pretty_generate(profile.attributes)
86
86
  end
87
87
 
88
88
  post '/v1/profiles' do
89
- profile = client.profiles.create(
89
+ profile = Mollie::Profile.create(
90
90
  name: json_params['name'],
91
91
  website: json_params['website'],
92
92
  email: json_params['email'],
@@ -98,7 +98,7 @@ class Application < Sinatra::Application
98
98
  end
99
99
 
100
100
  patch '/v1/profiles/:id' do
101
- profile = client.profiles.update(params[:id],
101
+ profile = Mollie::Profile.update(params[:id],
102
102
  name: json_params['name'],
103
103
  website: json_params['website'],
104
104
  email: json_params['email'],
@@ -110,17 +110,17 @@ class Application < Sinatra::Application
110
110
  end
111
111
 
112
112
  get '/v1/profiles/:profile_id/apikeys' do
113
- api_keys = client.profiles_api_keys.with(params[:profile_id]).all
113
+ api_keys = Mollie::Profile::ApiKey.all(profile_id: params[:profile_id])
114
114
  JSON.pretty_generate(api_keys.attributes)
115
115
  end
116
116
 
117
117
  get '/v1/profiles/:profile_id/apikeys/:mode' do
118
- api_key = client.profiles_api_keys.with(params[:profile_id]).get(params[:mode])
118
+ api_key = Mollie::Profile::ApiKey.get(params[:mode], profile_id: params[:profile_id])
119
119
  JSON.pretty_generate(api_key.attributes)
120
120
  end
121
121
 
122
122
  post '/v1/profiles/:profile_id/apikeys/:mode' do
123
- payment = client.profiles_api_keys.with(params[:profile_id]).create(params[:mode])
123
+ payment = Mollie::Profile::ApiKey.create(params[:mode], profile_id: params[:profile_id])
124
124
  JSON.pretty_generate(payment.attributes)
125
125
  end
126
126
  end