mollie-api-ruby 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +15 -2
  4. data/examples/apis/api_docs.rb +37 -0
  5. data/examples/apis/connect.rb +58 -0
  6. data/examples/apis/customers.rb +115 -0
  7. data/examples/apis/invoices.rb +38 -0
  8. data/examples/apis/issuers.rb +35 -0
  9. data/examples/apis/mandates.rb +83 -0
  10. data/examples/apis/methods.rb +50 -0
  11. data/examples/apis/organizations.rb +16 -0
  12. data/examples/apis/payments.rb +140 -0
  13. data/examples/apis/permissions.rb +32 -0
  14. data/examples/apis/profiles.rb +126 -0
  15. data/examples/apis/refunds.rb +17 -0
  16. data/examples/apis/settlements.rb +84 -0
  17. data/examples/apis/subscriptions.rb +165 -0
  18. data/examples/config.ru +58 -0
  19. data/examples/public/images/collapse.gif +0 -0
  20. data/examples/public/images/expand.gif +0 -0
  21. data/examples/public/images/explorer_icons.png +0 -0
  22. data/examples/public/images/favicon-16x16.png +0 -0
  23. data/examples/public/images/favicon-32x32.png +0 -0
  24. data/examples/public/images/favicon.ico +0 -0
  25. data/examples/public/images/logo_small.png +0 -0
  26. data/examples/public/images/pet_store_api.png +0 -0
  27. data/examples/public/images/throbber.gif +0 -0
  28. data/examples/public/images/wordnik_api.png +0 -0
  29. data/examples/public/index.html +101 -0
  30. data/examples/public/javascripts/lib/backbone-min.js +1 -0
  31. data/examples/public/javascripts/lib/es5-shim.js +1 -0
  32. data/examples/public/javascripts/lib/handlebars-4.0.5.js +3 -0
  33. data/examples/public/javascripts/lib/highlight.9.1.0.pack.js +1 -0
  34. data/examples/public/javascripts/lib/highlight.9.1.0.pack_extended.js +1 -0
  35. data/examples/public/javascripts/lib/jquery-1.8.0.min.js +3 -0
  36. data/examples/public/javascripts/lib/jquery.ba-bbq.min.js +1 -0
  37. data/examples/public/javascripts/lib/jquery.slideto.min.js +1 -0
  38. data/examples/public/javascripts/lib/jquery.wiggle.min.js +1 -0
  39. data/examples/public/javascripts/lib/js-yaml.min.js +2 -0
  40. data/examples/public/javascripts/lib/jsoneditor.min.js +5 -0
  41. data/examples/public/javascripts/lib/lodash.min.js +2 -0
  42. data/examples/public/javascripts/lib/marked.js +1 -0
  43. data/examples/public/javascripts/lib/object-assign-pollyfill.js +1 -0
  44. data/examples/public/javascripts/lib/sanitize-html.min.js +4 -0
  45. data/examples/public/javascripts/lib/swagger-oauth.js +1 -0
  46. data/examples/public/javascripts/swagger-ui.js +25378 -0
  47. data/examples/public/javascripts/swagger-ui.min.js +15 -0
  48. data/examples/public/javascripts/swagger_docs.js +14 -0
  49. data/examples/public/o2c.html +20 -0
  50. data/examples/public/stylesheets/reset.css +1 -0
  51. data/examples/public/stylesheets/screen.css +1545 -0
  52. data/examples/public/stylesheets/swagger_docs.css +4 -0
  53. data/examples/public/stylesheets/typography.css +0 -0
  54. data/lib/mollie/api/client.rb +42 -22
  55. data/lib/mollie/api/client/version.rb +1 -1
  56. data/lib/mollie/api/object/invoice.rb +70 -0
  57. data/lib/mollie/api/object/method.rb +1 -0
  58. data/lib/mollie/api/object/organization.rb +1 -1
  59. data/lib/mollie/api/object/payment.rb +21 -7
  60. data/lib/mollie/api/object/payment/refund.rb +5 -1
  61. data/lib/mollie/api/resource/base.rb +6 -6
  62. data/lib/mollie/api/resource/invoices.rb +11 -0
  63. data/lib/mollie/api/resource/permissions.rb +20 -0
  64. data/lib/mollie/api/resource/profiles/apikeys.rb +6 -0
  65. data/lib/mollie/api/resource/refunds.rb +11 -0
  66. data/lib/mollie/api/resource/settlements.rb +8 -0
  67. data/lib/mollie/api/resource/settlements/payments.rb +27 -0
  68. data/mollie.gemspec +7 -0
  69. data/test/mollie/api/client_test.rb +12 -5
  70. data/test/mollie/api/object/invoice_test.rb +59 -0
  71. data/test/mollie/api/object/organization_test.rb +0 -6
  72. data/test/mollie/api/object/payment_test.rb +15 -0
  73. data/test/mollie/api/resource/invoices_test.rb +13 -0
  74. metadata +159 -12
  75. data/examples/1-new-payment.rb +0 -56
  76. data/examples/2-webhook-verification.rb +0 -41
  77. data/examples/3-return-page.rb +0 -21
  78. data/examples/4-ideal-payment.rb +0 -79
  79. data/examples/5-payments-history.rb +0 -27
  80. data/examples/6-list-activated-methods.rb +0 -30
  81. data/examples/7-refund-payment.rb +0 -40
  82. data/examples/app.rb +0 -58
  83. data/examples/orders/.gitignore +0 -1
@@ -0,0 +1,16 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/organizations/{id}' do
3
+ operation :get, description: 'Get organization https://www.mollie.com/en/docs/reference/organizations/get', tags: ['Organizations'] do
4
+ parameter name: :id, in: 'path', description: 'Organization id', type: :string
5
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
6
+ security api_key: []
7
+ response 200, description: 'Successful response'
8
+ response 500, description: 'Unexpected error'
9
+ end
10
+ end
11
+
12
+ get '/v1/organizations/:id' do
13
+ organization = client.organizations.get(params[:id], testmode: params[:testmode])
14
+ JSON.pretty_generate(organization.attributes)
15
+ end
16
+ end
@@ -0,0 +1,140 @@
1
+ class Application < Sinatra::Application
2
+ swagger_schema :PaymentRequest do
3
+ property :amount, type: :decimal, description: 'Amount of money', example: 10.0
4
+ property :description, type: :string, description: 'Description', example: "My first payment"
5
+ property :redirect_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/order/12345/"
6
+ property :webhook_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/payments/webhook/"
7
+ property :metadata, type: :object, description: 'Extra info', example: { "order_id" => "12345" }
8
+ property :profileId, type: :object, description: 'ProfileId (Connect api only)', example: "pfl_FxPFwdxxJf"
9
+ property :testmode, type: :boolean, description: '(Connect api only)', example: true
10
+ end
11
+
12
+ swagger_schema :RefundRequest do
13
+ property :amount, type: :decimal, description: 'Amount of money', example: 10.0
14
+ property :description, type: :string, description: 'Description', example: "My first payment"
15
+ property :testmode, type: :boolean, description: 'Testmode', example: true
16
+ end
17
+
18
+ swagger_path '/v1/payments' do
19
+ operation :post, description: 'Create payment https://www.mollie.com/en/docs/reference/payments/create', tags: ['Payments'] do
20
+ security api_key: []
21
+ parameter name: :payment, in: 'body', description: 'PaymentRequest params', schema: { '$ref' => '#/definitions/PaymentRequest' }
22
+ response 200, description: 'Successful response'
23
+ response 500, description: 'Unexpected error'
24
+ end
25
+ end
26
+
27
+ swagger_path '/v1/payments/{id}' do
28
+ operation :get, description: 'Get payment https://www.mollie.com/en/docs/reference/payments/get', tags: ['Payments'] do
29
+ parameter name: :id, in: 'path', description: 'Payment id', type: :string
30
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
31
+ security api_key: []
32
+ response 200, description: 'Successful response'
33
+ response 500, description: 'Unexpected error'
34
+ end
35
+ end
36
+
37
+ swagger_path '/v1/payments' do
38
+ operation :get, description: 'List payments https://www.mollie.com/en/docs/reference/payments/list', tags: ['Payments'] do
39
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
40
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
41
+ parameter name: :profile_id, in: 'query', description: 'Profile ID', type: :string
42
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
43
+ security api_key: []
44
+ response 200, description: 'Successful response'
45
+ response 500, description: 'Unexpected error'
46
+ end
47
+ end
48
+
49
+ swagger_path '/v1/payments/{payment_id}/refunds' do
50
+ operation :post, description: 'Create payment https://www.mollie.com/nl/docs/reference/refunds/create', tags: ['Payments'] do
51
+ parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
52
+ security api_key: []
53
+ parameter name: :refund, in: 'body', description: 'RefundRequest params', schema: { '$ref' => '#/definitions/RefundRequest' }
54
+ response 200, description: 'Successful response'
55
+ response 500, description: 'Unexpected error'
56
+ end
57
+
58
+ operation :get, description: 'List payment refunds https://www.mollie.com/en/docs/reference/refunds/list', tags: ['Payments'] do
59
+ parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
60
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
61
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
62
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
63
+ security api_key: []
64
+ response 200, description: 'Successful response'
65
+ response 500, description: 'Unexpected error'
66
+ end
67
+ end
68
+
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
71
+ parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
72
+ parameter name: :id, in: 'path', description: 'Refund id', type: :string
73
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
74
+ security api_key: []
75
+ response 200, description: 'Successful response'
76
+ response 500, description: 'Unexpected error'
77
+ end
78
+
79
+ operation :delete, description: 'Delete payment https://www.mollie.com/nl/docs/reference/refunds/delete', tags: ['Payments'] do
80
+ parameter name: :payment_id, in: 'path', description: 'Payment id', type: :string
81
+ parameter name: :id, in: 'path', description: 'Refund id', type: :string
82
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
83
+ security api_key: []
84
+ response 204, description: 'Successful response'
85
+ response 500, description: 'Unexpected error'
86
+ end
87
+ end
88
+
89
+ get '/v1/payments' do
90
+ payments = client.payments.all(params[:offset], params[:count],
91
+ profile_id: params[:profile_id],
92
+ testmode: params[:testmode]
93
+ )
94
+
95
+ JSON.pretty_generate(payments.attributes)
96
+ end
97
+
98
+ get '/v1/payments/:id' do
99
+ payment = client.payments.get(params[:id], testmode: params[:testmode])
100
+ JSON.pretty_generate(payment.attributes)
101
+ end
102
+
103
+ post '/v1/payments' do
104
+ payment = client.payments.create(
105
+ amount: json_params['amount'],
106
+ description: json_params['description'],
107
+ redirect_url: json_params['redirect_url'],
108
+ webhook_url: json_params['webhook_url'],
109
+ metadata: json_params['metadata'],
110
+ profileId: json_params['profileId'],
111
+ testmode: json_params['testmode'],
112
+ )
113
+ JSON.pretty_generate(payment.attributes)
114
+ end
115
+
116
+ post '/v1/payments/:payment_id/refunds' do
117
+ refund = client.payments_refunds.with(params[:payment_id]).create(
118
+ amount: json_params['amount'],
119
+ description: json_params['description'],
120
+ testmode: json_params['testmode']
121
+ )
122
+ JSON.pretty_generate(refund.attributes)
123
+ end
124
+
125
+ get '/v1/payments/:payment_id/refunds/:id' do
126
+ refund = client.payments_refunds.with(params[:payment_id]).get(params[:id], testmode: params[:testmode])
127
+ JSON.pretty_generate(refund.attributes)
128
+ end
129
+
130
+ delete '/v1/payments/:payment_id/refunds/:id' do
131
+ client.payments_refunds.with(params[:payment_id]).delete(params[:id], testmode: params[:testmode])
132
+ "deleted"
133
+ end
134
+
135
+ get '/v1/payments/:payment_id/refunds' do
136
+ refunds = client.payments_refunds.with(params[:payment_id]).all(params[:offset], params[:count], testmode: params[:testmode])
137
+ JSON.pretty_generate(refunds.attributes)
138
+ end
139
+
140
+ end
@@ -0,0 +1,32 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/permissions' do
3
+ operation :get, description: 'List permissions https://www.mollie.com/en/docs/reference/permissions/list', tags: ['Permissions'] 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
+ swagger_path '/v1/permissions/{id}' do
14
+ operation :get, description: 'Get permission https://www.mollie.com/en/docs/reference/permissions/get', tags: ['Permissions'] do
15
+ parameter name: :id, in: 'path', description: 'Permission id', type: :string
16
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
17
+ security api_key: []
18
+ response 200, description: 'Successful response'
19
+ response 500, description: 'Unexpected error'
20
+ end
21
+ end
22
+
23
+ get '/v1/permissions' do
24
+ permissions = client.permissions.all(params[:offset], params[:count], testmode: params[:testmode])
25
+ JSON.pretty_generate(permissions.attributes)
26
+ end
27
+
28
+ get '/v1/permissions/:id' do
29
+ permission = client.permissions.get(params[:id], testmode: params[:testmode])
30
+ JSON.pretty_generate(permission.attributes)
31
+ end
32
+ end
@@ -0,0 +1,126 @@
1
+ class Application < Sinatra::Application
2
+ swagger_schema :ProfileRequest do
3
+ property :name, type: :string, description: 'Name', example: "My website name"
4
+ property :website, type: :string, description: 'Website', example: "#{Ngrok::Tunnel.ngrok_url_https}"
5
+ property :email, type: :string, description: 'Email', example: "info@mywebsite.com"
6
+ property :phone, type: :string, description: 'Phone', example: "31123456789"
7
+ property :categoryCode, type: :integer, description: 'Category code', example: "5399"
8
+ property :mode, type: :string, description: 'Mode (live or test)', example: "test"
9
+ end
10
+
11
+ swagger_path '/v1/profiles' do
12
+ operation :post, description: 'https://www.mollie.com/en/docs/reference/profiles/create', tags: ['Profiles'] do
13
+ security api_key: []
14
+ parameter name: :profile, in: 'body', description: 'ProfileRequest params', schema: { '$ref' => '#/definitions/ProfileRequest' }
15
+ response 200, description: 'Successful response'
16
+ response 500, description: 'Unexpected error'
17
+ end
18
+ end
19
+
20
+ swagger_path '/v1/profiles' do
21
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/profiles/list', tags: ['Profiles'] do
22
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
23
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
24
+ security api_key: []
25
+ response 200, description: 'Successful response'
26
+ response 500, description: 'Unexpected error'
27
+ end
28
+ end
29
+
30
+ swagger_path '/v1/profiles/{id}' do
31
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/profiles/get', tags: ['Profiles'] do
32
+ parameter name: :id, in: 'path', description: 'Profile id', type: :string, default: 'pfl_v9hTwCvYqw'
33
+ security api_key: []
34
+ response 200, description: 'Successful response'
35
+ response 500, description: 'Unexpected error'
36
+ end
37
+ operation :patch, description: 'https://www.mollie.com/en/docs/reference/profiles/create', tags: ['Profiles'] do
38
+ parameter name: :id, in: 'path', description: 'Profile id', type: :string, default: 'pfl_v9hTwCvYqw'
39
+ security api_key: []
40
+ parameter name: :profile, in: 'body', description: 'ProfileRequest params', schema: { '$ref' => '#/definitions/ProfileRequest' }
41
+ response 200, description: 'Successful response'
42
+ response 500, description: 'Unexpected error'
43
+ end
44
+ operation :delete, description: 'https://www.mollie.com/en/docs/reference/profiles/delete', tags: ['Profiles'] do
45
+ parameter name: :id, in: 'path', description: 'Profile id', type: :string, default: 'pfl_v9hTwCvYqw'
46
+ security api_key: []
47
+ response 200, description: 'Successful response'
48
+ response 500, description: 'Unexpected error'
49
+ end
50
+ end
51
+
52
+ swagger_path '/v1/profiles/{profile_id}/apikeys' do
53
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/profiles/api-keys/list', tags: ['Profiles'] do
54
+ parameter name: :profile_id, in: 'path', description: 'Profile id', type: :string, default: 'pfl_v9hTwCvYqw'
55
+ security api_key: []
56
+ response 200, description: 'Successful response'
57
+ response 500, description: 'Unexpected error'
58
+ end
59
+ end
60
+
61
+ swagger_path '/v1/profiles/{profile_id}/apikeys/{mode}' do
62
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/profiles/api-keys/list', tags: ['Profiles'] do
63
+ parameter name: :profile_id, in: 'path', description: 'Profile id', type: :string, default: 'pfl_v9hTwCvYqw'
64
+ parameter name: :mode, in: 'path', description: 'Mode (live or test)', type: :string, default: 'test'
65
+ security api_key: []
66
+ response 200, description: 'Successful response'
67
+ response 500, description: 'Unexpected error'
68
+ end
69
+ operation :post, description: 'https://www.mollie.com/en/docs/reference/profiles/api-keys/reset', tags: ['Profiles'] do
70
+ parameter name: :profile_id, in: 'path', description: 'Profile id', type: :string, default: 'pfl_v9hTwCvYqw'
71
+ parameter name: :mode, in: 'path', description: 'Mode (live or test)', type: :string, default: 'test'
72
+ security api_key: []
73
+ response 200, description: 'Successful response'
74
+ response 500, description: 'Unexpected error'
75
+ end
76
+ end
77
+
78
+ get '/v1/profiles' do
79
+ profiles = client.profiles.all(params[:offset], params[:count])
80
+ JSON.pretty_generate(profiles.attributes)
81
+ end
82
+
83
+ get '/v1/profiles/:id' do
84
+ profile = client.profiles.get(params[:id])
85
+ JSON.pretty_generate(profile.attributes)
86
+ end
87
+
88
+ post '/v1/profiles' do
89
+ profile = client.profiles.create(
90
+ name: json_params['name'],
91
+ website: json_params['website'],
92
+ email: json_params['email'],
93
+ phone: json_params['phone'],
94
+ categoryCode: json_params['categoryCode'],
95
+ mode: json_params['mode'],
96
+ )
97
+ JSON.pretty_generate(profile.attributes)
98
+ end
99
+
100
+ patch '/v1/profiles/:id' do
101
+ profile = client.profiles.update(params[:id],
102
+ name: json_params['name'],
103
+ website: json_params['website'],
104
+ email: json_params['email'],
105
+ phone: json_params['phone'],
106
+ categoryCode: json_params['categoryCode'],
107
+ mode: json_params['mode'],
108
+ )
109
+ JSON.pretty_generate(profile.attributes)
110
+ end
111
+
112
+ get '/v1/profiles/:profile_id/apikeys' do
113
+ api_keys = client.profiles_api_keys.with(params[:profile_id]).all
114
+ JSON.pretty_generate(api_keys.attributes)
115
+ end
116
+
117
+ get '/v1/profiles/:profile_id/apikeys/:mode' do
118
+ api_key = client.profiles_api_keys.with(params[:profile_id]).get(params[:mode])
119
+ JSON.pretty_generate(api_key.attributes)
120
+ end
121
+
122
+ post '/v1/profiles/:profile_id/apikeys/:mode' do
123
+ payment = client.profiles_api_keys.with(params[:profile_id]).create(params[:mode])
124
+ JSON.pretty_generate(payment.attributes)
125
+ end
126
+ end
@@ -0,0 +1,17 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/refunds' do
3
+ operation :get, description: 'List refunds https://www.mollie.com/en/docs/reference/refunds/list', tags: ['Refunds'] 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/refunds' do
14
+ refunds = client.refunds.all(params[:offset], params[:limit], testmode: params[:test_mode])
15
+ JSON.pretty_generate(refunds.attributes)
16
+ end
17
+ end
@@ -0,0 +1,84 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/settlements' do
3
+ operation :get, description: 'List settlements https://www.mollie.com/en/docs/reference/settlements/list', tags: ['Settlements'] do
4
+ parameter name: :reference, in: 'query', description: 'Issuer id', type: :string, example: "1182161.1506.02"
5
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
6
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
7
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
8
+ security api_key: []
9
+ response 200, description: 'Successful response'
10
+ response 500, description: 'Unexpected error'
11
+ end
12
+ end
13
+
14
+ swagger_path '/v1/settlements/{id}' do
15
+ operation :get, description: 'Get settlement https://www.mollie.com/en/docs/reference/settlements/get', tags: ['Settlements'] do
16
+ parameter name: :id, in: 'path', description: 'Issuer id', type: :string, example: "stl_jDk30akdN"
17
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
18
+ security api_key: []
19
+ response 200, description: 'Successful response'
20
+ response 500, description: 'Unexpected error'
21
+ end
22
+ end
23
+
24
+ swagger_path '/v1/settlements/next' do
25
+ operation :get, description: 'Next settlement https://www.mollie.com/en/docs/reference/settlements/next', tags: ['Settlements'] do
26
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
27
+ security api_key: []
28
+ response 200, description: 'Successful response'
29
+ response 500, description: 'Unexpected error'
30
+ end
31
+ end
32
+
33
+ swagger_path '/v1/settlements/open' do
34
+ operation :get, description: 'Open settlement https://www.mollie.com/en/docs/reference/settlements/open', tags: ['Settlements'] do
35
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
36
+ security api_key: []
37
+ response 200, description: 'Successful response'
38
+ response 500, description: 'Unexpected error'
39
+ end
40
+ end
41
+
42
+ swagger_path '/v1/settlements/{settlement_id}/payments' do
43
+ operation :get, description: 'List settlement payments https://www.mollie.com/nl/docs/reference/settlements/list-payments', tags: ['Settlements'] do
44
+ parameter name: :settlement_id, in: 'path', description: 'Settlement id', type: :string, example: "stl_jDk30akdN"
45
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
46
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
47
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
48
+ security api_key: []
49
+ response 200, description: 'Successful response'
50
+ response 500, description: 'Unexpected error'
51
+ end
52
+ end
53
+
54
+ get '/v1/settlements' do
55
+ settlements = client.settlements.all(params[:offset], params[:count],
56
+ reference: params[:reference],
57
+ testmode: params[:testmode]
58
+ )
59
+ JSON.pretty_generate(settlements.attributes)
60
+ end
61
+
62
+ get '/v1/settlements/:id' do
63
+ settlement = client.settlements.get(params[:id], testmode: params[:testmode])
64
+ JSON.pretty_generate(settlement.attributes)
65
+ end
66
+
67
+ get '/v1/settlements/next' do
68
+ settlement = client.settlements.next(testmode: params[:testmode])
69
+ JSON.pretty_generate(settlement.attributes)
70
+ end
71
+
72
+ get '/v1/settlements/open' do
73
+ settlement = client.settlements.open(testmode: params[:testmode])
74
+ JSON.pretty_generate(settlement.attributes)
75
+ end
76
+
77
+
78
+ get '/v1/settlements/:settlement_id/payments' do
79
+ payments = client.settlements_payments.with(params[:settlement_id]).all(params[:offset], params[:count], testmode: params[:testmode])
80
+ JSON.pretty_generate(payments.attributes)
81
+ end
82
+
83
+
84
+ end
@@ -0,0 +1,165 @@
1
+ class Application < Sinatra::Application
2
+ swagger_schema :FirstPaymentRequest do
3
+ property :amount, type: :decimal, description: 'Amount of money', example: 0.01
4
+ property :customer_id, type: :string, description: 'Customer id', example: "cst_GUvJFqwVCD"
5
+ property :description, type: :string, description: 'Description', example: "My first payment"
6
+ property :recurring_type, type: :string, description: 'Recurring type', example: "first"
7
+ property :redirect_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/order/12345/"
8
+ property :webhook_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/payments/webhook/"
9
+ property :metadata, type: :object, description: 'Extra info', example: { "order_id" => "12345" }
10
+ property :testmode, type: :boolean, description: '(Connect api only)', example: true
11
+ end
12
+
13
+ swagger_schema :OnDemandPaymentRequest do
14
+ property :amount, type: :decimal, description: 'Amount of money', example: 25.0
15
+ property :customer_id, type: :string, description: 'Customer id', example: "cst_GUvJFqwVCD"
16
+ property :description, type: :string, description: 'Description', example: "Monthly payment"
17
+ property :recurring_type, type: :string, description: 'Recurring type', example: "recurring"
18
+ property :redirect_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/order/12345/"
19
+ property :webhook_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/payments/webhook/"
20
+ property :metadata, type: :object, description: 'Extra info', example: { "order_id" => "12345" }
21
+ property :testmode, type: :boolean, description: '(Connect api only)', example: true
22
+ end
23
+
24
+ swagger_schema :SubscriptionRequest do
25
+ property :amount, type: :decimal, description: 'Amount of money', example: 25.0
26
+ property :times, type: :integer, description: 'Times', example: "10"
27
+ property :interval, type: :string, description: 'Interval', example: "1 month"
28
+ property :start_date, type: :string, description: 'Start date', example: Time.now.strftime("%Y-%m-%d")
29
+ property :description, type: :string, description: 'Description', example: "Monthly subscription"
30
+ property :method, type: :object, description: 'Method', example: "directdebit"
31
+ property :webhook_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/payments/webhook/"
32
+ property :testmode, type: :boolean, description: '(Connect api only)', example: true
33
+ end
34
+
35
+ swagger_path '/v1/subscriptions/first_payment' do
36
+ operation :post, description: 'https://www.mollie.com/en/docs/recurring#first-payment', tags: ['Subscriptions'] do
37
+ security api_key: []
38
+ parameter name: :payment, in: 'body', description: 'PaymentRequest params', schema: { '$ref' => '#/definitions/OnDemandPaymentRequest' }
39
+ response 200, description: 'Successful response'
40
+ response 500, description: 'Unexpected error'
41
+ end
42
+ end
43
+
44
+ swagger_path '/v1/subscriptions/mandates/{customer_id}' do
45
+ operation :get, description: 'List mandates', tags: ['Subscriptions'] do
46
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
47
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
48
+ security api_key: []
49
+ response 200, description: 'Successful response'
50
+ response 500, description: 'Unexpected error'
51
+ end
52
+ end
53
+
54
+ swagger_path '/v1/subscriptions/on_demand' do
55
+ operation :post, description: 'https://www.mollie.com/en/docs/recurring#on-demand', tags: ['Subscriptions'] do
56
+ parameter name: :payment, in: 'body', description: 'PaymentRequest params', schema: { '$ref' => '#/definitions/OnDemandPaymentRequest' }
57
+ security api_key: []
58
+ response 200, description: 'Successful response'
59
+ response 500, description: 'Unexpected error'
60
+ end
61
+ end
62
+
63
+ swagger_path '/v1/customers/{customer_id}/subscriptions' do
64
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/subscriptions/get', tags: ['Subscriptions'] do
65
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
66
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
67
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
68
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
69
+ security api_key: []
70
+ response 200, description: 'Successful response'
71
+ response 500, description: 'Unexpected error'
72
+ end
73
+
74
+ operation :post, description: 'https://www.mollie.com/en/docs/recurring#subscriptions', tags: ['Subscriptions'] do
75
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
76
+ parameter name: :payment, in: 'body', description: 'PaymentRequest params', schema: { '$ref' => '#/definitions/SubscriptionRequest' }
77
+ security api_key: []
78
+ response 200, description: 'Successful response'
79
+ response 500, description: 'Unexpected error'
80
+ end
81
+ end
82
+
83
+ swagger_path '/v1/customers/{customer_id}/subscriptions/{id}' do
84
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/subscriptions/get', tags: ['Subscriptions'] do
85
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
86
+ parameter name: :id, in: 'path', description: 'Subscription id', type: :string, default: 'sub_qte7Jyfc5B'
87
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
88
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
89
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
90
+ security api_key: []
91
+ response 200, description: 'Successful response'
92
+ response 500, description: 'Unexpected error'
93
+ end
94
+ operation :delete, description: 'https://www.mollie.com/en/docs/reference/subscriptions/delete', tags: ['Subscriptions'] do
95
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
96
+ parameter name: :id, in: 'path', description: 'Subscription id', type: :string, default: 'sub_qte7Jyfc5B'
97
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
98
+ security api_key: []
99
+ response 200, description: 'Successful response'
100
+ response 500, description: 'Unexpected error'
101
+ end
102
+ end
103
+
104
+ post '/v1/subscriptions/first_payment' do
105
+ payment = client.payments.create(
106
+ amount: json_params['amount'],
107
+ customer_id: json_params['customer_id'],
108
+ description: json_params['description'],
109
+ redirect_url: json_params['redirect_url'],
110
+ recurring_type: "first",
111
+ webhook_url: json_params['webhook_url'],
112
+ metadata: json_params['metadata'],
113
+ testmode: json_params['testmode'],
114
+ )
115
+ JSON.pretty_generate(payment.attributes)
116
+ end
117
+
118
+ get '/v1/subscriptions/mandates/:customer_id' do
119
+ mandates = client.customers_mandates.with(params[:customer_id]).all
120
+ JSON.pretty_generate(mandates.attributes)
121
+ end
122
+
123
+ post '/v1/subscriptions/on_demand' do
124
+ payment = client.payments.create(
125
+ amount: json_params['amount'],
126
+ customer_id: json_params['customer_id'],
127
+ description: json_params['description'],
128
+ redirect_url: json_params['redirect_url'],
129
+ recurring_type: "recurring",
130
+ webhook_url: json_params['webhook_url'],
131
+ metadata: json_params['metadata'],
132
+ testmode: json_params['testmode'],
133
+ )
134
+ JSON.pretty_generate(payment.attributes)
135
+ end
136
+
137
+ get '/v1/customers/:customer_id/subscriptions' do
138
+ subscriptions = client.customers_subscriptions.with(params[:customer_id]).all(params[:offset], params[:count], testmode: params[:testmode])
139
+ JSON.pretty_generate(subscriptions.attributes)
140
+ end
141
+
142
+ get '/v1/customers/:customer_id/subscriptions/:id' do
143
+ payment = client.customers_subscriptions.with(params[:customer_id]).get(params[:id], testmode: params[:testmode])
144
+ JSON.pretty_generate(payment.attributes)
145
+ end
146
+
147
+ post '/v1/customers/:customer_id/subscriptions' do
148
+ subscription = client.customers_subscriptions.with(params[:customer_id]).create(
149
+ amount: json_params['amount'],
150
+ times: json_params['times'],
151
+ interval: json_params['interval'],
152
+ start_date: json_params['start_date'],
153
+ description: json_params["description"],
154
+ method: json_params['method'],
155
+ webhook_url: json_params['webhook_url'],
156
+ testmode: json_params['testmode'],
157
+ )
158
+ JSON.pretty_generate(subscription.attributes)
159
+ end
160
+
161
+ delete '/v1/customers/:customer_id/subscriptions/:id' do
162
+ client.customers_subscriptions.with(params[:customer_id]).delete(params[:id], testmode: params[:testmode])
163
+ "deleted"
164
+ end
165
+ end