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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 719ea9fd2cb5e56072dc35c2f66efdd2c87e278b
4
- data.tar.gz: 3c460d1338c55e3fb80449da019ad5702e65b0a7
3
+ metadata.gz: 7d6b6f21eeda06bcb33555aa029fe76466497263
4
+ data.tar.gz: 64aadca75fd234e1df340843b1f92627ffa75a05
5
5
  SHA512:
6
- metadata.gz: 6035c6b84b160788f7f9ea14259bcc8ac1fe64e71e676e5227b8bf45f7dd0cad717b1fc7ed04a2a98b7655977e1c8d32863bcdf579beaeb312f0c5dc991b4665
7
- data.tar.gz: d69710e8d191ed705a3b391f3d08bb29868d38d30e67f7e77741d1f329546605772b8da1de98c944e11404d1d3182e6ca49cbac6e2b1b95de015c3f6bd140621
6
+ metadata.gz: dac9bb4f03cd09e80eeab7fd0af5ed5f13cc3a3bdabbc71176ab125e829f6b7634512f4afd849dc75f482125687d80db9dbe481e87835ddccc74f7e7460783e6
7
+ data.tar.gz: 29dca80e86f9876f1512c76b3a3f872c27e55c5eef8a369b0e08f2edbe97b700a5ca7ce95852a101c4a50906fdfff3fa2ee02b53c80d42054e978541031eabbb
@@ -4,6 +4,12 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ #### 2.2.1 - 2017-09-13
8
+ - Added support for gift card method.
9
+ - Added support for `invoice` endpoint.
10
+ - Improved support for `refunds` endpoint.
11
+ - Added and updated examples.
12
+
7
13
  #### 2.2.0 - 2017-04-21
8
14
  - Add support for organizations, permissions, profiles, settlement and profiles/apikeys resources ([#54](https://github.com/mollie/mollie-api-ruby/issues/54)).
9
15
  - Remove `jruby` from the build.
data/README.md CHANGED
@@ -83,14 +83,27 @@ refund = mollie.payments_refunds.with(payment).create
83
83
 
84
84
  ## Examples ##
85
85
 
86
- The examples require [Sinatra](http://rubygems.org/gems/sinatra) so you will need to install that gem first. Afterwards simply run:
86
+ In order to run the examples first run `bundle install`
87
87
 
88
88
  ```
89
89
  $ cd mollie-api-ruby
90
- $ ruby examples/app.rb
90
+ $ bundle install
91
+ $ cd examples
92
+ $ rackup
91
93
  ```
92
94
 
93
95
  ## API documentation ##
96
+ If you wish to learn more about the Ruby API, download the source code and run the Example app as follows:
97
+
98
+ ```
99
+ $ git clone git@github.com:mollie/mollie-api-ruby.git
100
+ $ cd mollie-api-ruby
101
+ $ bundle
102
+ $ cd examples
103
+ $ API_KEY=test_xxxxxx rackup
104
+ ```
105
+ You can then browse the swagger documentation on [http://localhost:9292](http://localhost:9292)
106
+
94
107
  If you wish to learn more about our API, please visit the [Mollie Developer Portal](https://www.mollie.com/developer/). API Documentation is available in both Dutch and English.
95
108
 
96
109
  ## License ##
@@ -0,0 +1,37 @@
1
+ class Application < Sinatra::Application
2
+ ::Application
3
+ swagger_root do
4
+ key :swagger, '2.0'
5
+ info version: Mollie::API::Client::VERSION,
6
+ title: 'Mollie',
7
+ description: 'Examples for the mollie api',
8
+ termsOfService: 'https://github.com/mollie/mollie-api-ruby',
9
+ contact: { name: 'Mollie B.V.' },
10
+ license: { name: 'BSD' }
11
+ key :basePath, '/'
12
+ key :consumes, %w(application/json multipart/form-data)
13
+ key :produces, ['application/json', "text/plain"]
14
+
15
+ security_definition :api_key do
16
+ key :type, :apiKey
17
+ key :name, :"X-Mollie-Api-Key"
18
+ key :in, :header
19
+ end
20
+ end
21
+
22
+ swagger_schema :ErrorModel do
23
+ property :message do
24
+ key :type, :string
25
+ end
26
+ end
27
+
28
+ get '/' do
29
+ # redirect "http://petstore.swagger.io/?url=#{Ngrok::Tunnel.ngrok_url_https}/api-docs"
30
+ redirect "#{Ngrok::Tunnel.ngrok_url_https}/index.html"
31
+ end
32
+
33
+ get '/api-docs' do
34
+ content_type :json
35
+ Swagger::Blocks.build_root_json([Application ]).to_json
36
+ end
37
+ end
@@ -0,0 +1,58 @@
1
+ require 'rack/oauth2'
2
+ class Application < Sinatra::Application
3
+ swagger_path '/oauth2/authorize' do
4
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/oauth/authorize', tags: ['Connect'] do
5
+ parameter name: :client_id, in: 'query', description: 'Client Id', type: :string
6
+ parameter name: :secret, in: 'query', description: 'oAuth Secret', type: :string
7
+ parameter name: :redirect_uri, in: 'query', description: 'Redirect URI', type: :string, default: "#{Ngrok::Tunnel.ngrok_url_https}/token"
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(' ')
10
+ parameter name: :response_type, in: 'query', description: 'Response Type', type: :string
11
+ parameter name: :approval_prompt, in: 'query', description: 'Approval prompt', type: :boolean
12
+ security api_key: []
13
+ response 301, description: 'Successful response'
14
+ response 500, description: 'Unexpected error'
15
+ end
16
+ end
17
+
18
+ swagger_path '/oauth2/token' do
19
+ operation :get, description: 'Get access token', tags: ['Connect'] do
20
+ parameter name: :client_id, in: 'query', description: 'Client Id', type: :string
21
+ parameter name: :secret, in: 'query', description: 'oAuth Secret', type: :string
22
+ parameter name: :redirect_uri, in: 'query', description: 'Redirect URI', type: :string, default: "#{Ngrok::Tunnel.ngrok_url_https}/token"
23
+ parameter name: :code, in: 'query', description: 'Authorization code', type: :string
24
+ security api_key: []
25
+ response 200, description: 'Successful response'
26
+ response 500, description: 'Unexpected error'
27
+ end
28
+ end
29
+
30
+ get '/oauth2/authorize' do
31
+ client = Rack::OAuth2::Client.new(
32
+ identifier: params[:client_id],
33
+ secret: params[:secret],
34
+ state: params[:state],
35
+ redirect_uri: params[:redirect_uri],
36
+ authorization_endpoint: 'https://www.mollie.com/oauth2/authorize',
37
+ token_endpoint: 'https://api.mollie.nl/oauth2/tokens'
38
+ )
39
+ client.authorization_uri(state: params[:state], scope: params[:scope], approval_prompt: params[:approval_prompt])
40
+ end
41
+
42
+ get '/token' do
43
+ params[:code]
44
+ end
45
+
46
+ get '/oauth2/token' do
47
+ client = Rack::OAuth2::Client.new(
48
+ identifier: params[:client_id],
49
+ secret: params[:secret],
50
+ redirect_uri: params[:redirect_uri],
51
+ authorization_endpoint: 'https://www.mollie.com/oauth2/authorize',
52
+ token_endpoint: 'https://api.mollie.nl/oauth2/tokens'
53
+ )
54
+
55
+ client.authorization_code = params['code']
56
+ client.access_token!.access_token
57
+ end
58
+ end
@@ -0,0 +1,115 @@
1
+ class Application < Sinatra::Application
2
+ swagger_schema :CustomerRequest do
3
+ property :name, type: :string, description: 'Name', example: "John doe"
4
+ property :email, type: :string, description: 'Email', example: "john@example.com"
5
+ property :locale, type: :string, description: 'locale', example: "en_US"
6
+ property :metadata, type: :object, description: 'Metadata', example: { "user_id" => "12345" }
7
+ property :profileId, type: :object, description: 'ProfileId (Connect api only)', example: "pfl_FxPFwdxxJf"
8
+ property :testmode, type: :boolean, description: '(Connect api only)', example: true
9
+ end
10
+
11
+ swagger_path '/v1/customers' do
12
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/customers/list', tags: ['Customers'] do
13
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
14
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
15
+ parameter name: :testmode, in: 'query', type: :boolean, description: '(Connect api only)', example: true
16
+ security api_key: []
17
+ response 200, description: 'Successful response'
18
+ response 500, description: 'Unexpected error'
19
+ end
20
+ end
21
+
22
+ swagger_path '/v1/customers' do
23
+ operation :post, description: 'https://www.mollie.com/en/docs/reference/customers/create', tags: ['Customers'] do
24
+ security api_key: []
25
+ parameter name: :customer, in: 'body', description: 'CustomerRequest params', schema: { '$ref' => '#/definitions/CustomerRequest' }
26
+ response 200, description: 'Successful response'
27
+ response 500, description: 'Unexpected error'
28
+ end
29
+ end
30
+
31
+ swagger_path '/v1/customers/{id}' do
32
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/customers/get', tags: ['Customers'] do
33
+ parameter name: :id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
34
+ parameter name: :testmode, in: 'query', type: :boolean, description: '(Connect api only)', example: true
35
+ security api_key: []
36
+ response 200, description: 'Successful response'
37
+ response 500, description: 'Unexpected error'
38
+ end
39
+ operation :patch, description: 'https://www.mollie.com/en/docs/reference/customers/create', tags: ['Customers'] do
40
+ parameter name: :id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
41
+ security api_key: []
42
+ parameter name: :customer, in: 'body', description: 'CustomerRequest params', schema: { '$ref' => '#/definitions/CustomerRequest' }
43
+ response 200, description: 'Successful response'
44
+ response 500, description: 'Unexpected error'
45
+ end
46
+ end
47
+
48
+ swagger_path '/v1/customers/{customer_id}/payments' do
49
+ operation :get, description: 'https://www.mollie.com/en/docs/reference/customers/list-payments', tags: ['Customers'] do
50
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
51
+ parameter name: :testmode, in: 'query', type: :boolean, description: '(Connect api only)', example: true
52
+ security api_key: []
53
+ response 200, description: 'Successful response'
54
+ response 500, description: 'Unexpected error'
55
+ end
56
+
57
+ operation :post, description: 'https://www.mollie.com/en/docs/reference/customers/create-payment', tags: ['Customers'] do
58
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: 'cst_GUvJFqwVCD'
59
+ parameter name: :payment, in: 'body', description: 'PaymentRequest params', schema: { '$ref' => '#/definitions/PaymentRequest' }
60
+ security api_key: []
61
+ response 200, description: 'Successful response'
62
+ response 500, description: 'Unexpected error'
63
+ end
64
+ end
65
+
66
+ get '/v1/customers' do
67
+ customers = client.customers.all(params[:offset], params[:count], testmode: params[:testmode])
68
+ JSON.pretty_generate(customers.attributes)
69
+ end
70
+
71
+ get '/v1/customers/:id' do
72
+ customer = client.customers.get(params[:id], testmode: params[:testmode])
73
+ JSON.pretty_generate(customer.attributes)
74
+ end
75
+
76
+ post '/v1/customers' do
77
+ customer = client.customers.create(
78
+ name: json_params['name'],
79
+ email: json_params['email'],
80
+ locale: json_params['locale'],
81
+ metadata: json_params['metadata'],
82
+ profileId: json_params['profileId'],
83
+ testmode: json_params['testmode']
84
+ )
85
+ JSON.pretty_generate(customer.attributes)
86
+ end
87
+
88
+ patch '/v1/customers/:id' do
89
+ customer = client.customers.update(params[:id],
90
+ name: json_params['name'],
91
+ email: json_params['email'],
92
+ locale: json_params['locale'],
93
+ metadata: json_params['metadata'],
94
+ )
95
+ JSON.pretty_generate(customer.attributes)
96
+ end
97
+
98
+ get '/v1/customers/:customer_id/payments' do
99
+ payments = client.customers_payments.with(params[:customer_id]).all(testmode: params[:testmode])
100
+ JSON.pretty_generate(payments.attributes)
101
+ end
102
+
103
+ post '/v1/customers/:customer_id/payments' do
104
+ payment = client.customers_payments.with(params[:customer_id]).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
+ end
@@ -0,0 +1,38 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/invoices' do
3
+ operation :get, description: 'List invoices https://www.mollie.com/en/docs/reference/invoices/list', tags: ['Invoices'] do
4
+ parameter name: :include, in: 'query', description: 'Include', type: :string, example: "lines,settlements"
5
+ parameter name: :reference, in: 'query', description: 'Issuer id', type: :string, example: "inv_FrvewDA3Pr"
6
+ parameter name: :year, in: 'query', description: 'Issuer id', type: :integer, example: Time.now.year
7
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
8
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
9
+ security api_key: []
10
+ response 200, description: 'Successful response'
11
+ response 500, description: 'Unexpected error'
12
+ end
13
+ end
14
+
15
+ swagger_path '/v1/invoices/{id}' do
16
+ operation :get, description: 'Get invoice', tags: ['Invoices'] do
17
+ parameter name: :id, in: 'path', description: 'Issuer id', type: :string, example: "inv_FrvewDA3Pr"
18
+ parameter name: :include, in: 'query', description: 'Includes', type: :string, example: "lines,settlements"
19
+ security api_key: []
20
+ response 200, description: 'Successful response'
21
+ response 500, description: 'Unexpected error'
22
+ end
23
+ end
24
+
25
+ get '/v1/invoices' do
26
+ invoices = client.invoices.all(params[:offset], params[:count],
27
+ include: params[:include],
28
+ reference: params[:reference],
29
+ year: params[:year]
30
+ )
31
+ JSON.pretty_generate(invoices.attributes)
32
+ end
33
+
34
+ get '/v1/invoices/:id' do
35
+ invoice = client.invoices.get(params[:id], include: params[:include])
36
+ JSON.pretty_generate(invoice.attributes)
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/issuers' do
3
+ operation :get, description: 'List issuers https://www.mollie.com/en/docs/reference/issuers/list', tags: ['Issuers'] 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/issuers/{id}' do
14
+ operation :get, description: 'Get issuer', tags: ['Issuers'] do
15
+ parameter name: :id, in: 'path', description: 'Issuer 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/issuers' do
24
+ issuers = client.issuers.all(params[:offset], params[:count],
25
+ testmode: params[:testmode])
26
+ JSON.pretty_generate(issuers.attributes)
27
+ end
28
+
29
+ get '/v1/issuers/:id' do
30
+ issuer = client.issuers.get(params[:id],
31
+ testmode: params[:testmode]
32
+ )
33
+ JSON.pretty_generate(issuer.attributes)
34
+ end
35
+ end
@@ -0,0 +1,83 @@
1
+ class Application < Sinatra::Application
2
+ swagger_schema :MandateRequest do
3
+ property :method, type: :decimal, description: 'Method', example: "directdebit"
4
+ property :consumer_name, type: :string, description: 'Consumer name', example: "Customer A"
5
+ property :consumer_account, type: :string, description: 'Account number', example: "NL17RABO0213698412"
6
+ property :consumer_bic, type: :string, description: 'BIC', example: "RABONL2U"
7
+ property :signature_date, type: :string, description: 'Date mandate was signed', example: "2016-05-01"
8
+ property :mandate_reference, type: :string, description: 'A custom reference', example: "YOUR-COMPANY-MD13804"
9
+ property :webhook_url, type: :string, description: 'URL for redirection', example: "https://webshop.example.org/payments/webhook/"
10
+ property :testmode, type: :boolean, description: '(Connect api only)', example: true
11
+ end
12
+
13
+ swagger_path '/v1/customers/{customer_id}/mandates' do
14
+ operation :post, description: 'Create mandates', tags: ['Mandates'] do
15
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: "cst_GUvJFqwVCD"
16
+ security api_key: []
17
+ parameter name: :mandate, in: 'body', description: 'MandateRequest params', schema: { '$ref' => '#/definitions/MandateRequest' }
18
+ response 200, description: 'Successful response'
19
+ response 500, description: 'Unexpected error'
20
+ end
21
+
22
+ operation :get, description: 'List mandates', tags: ['Mandates'] do
23
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: "cst_GUvJFqwVCD"
24
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
25
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
26
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
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/customers/{customer_id}/mandates/{id}' do
34
+ operation :get, description: 'Get mandate', tags: ['Mandates'] do
35
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: "cst_GUvJFqwVCD"
36
+ parameter name: :id, in: 'path', description: 'Mandate id', type: :string, default: "mdt_qP7Qk6mgaz"
37
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
38
+ security api_key: []
39
+ response 200, description: 'Successful response'
40
+ response 500, description: 'Unexpected error'
41
+ end
42
+
43
+ operation :delete, description: 'Remove mandate', tags: ['Mandates'] do
44
+ parameter name: :customer_id, in: 'path', description: 'Customer id', type: :string, default: "cst_GUvJFqwVCD"
45
+ parameter name: :id, in: 'path', description: 'Mandate id', type: :string, default: "mdt_qP7Qk6mgaz"
46
+ parameter name: :testmode, in: 'query', description: 'Testmode', type: :boolean, default: true
47
+ security api_key: []
48
+ response 200, description: 'Successful response'
49
+ response 500, description: 'Unexpected error'
50
+ end
51
+ end
52
+
53
+ post '/v1/customers/:customer_id/mandates' do
54
+ mandate = client.customers_mandates.with(params[:customer_id]).create(
55
+ method: json_params['method'],
56
+ consumer_name: json_params['consumer_name'],
57
+ consumer_account: json_params['consumer_account'],
58
+ consumer_bic: json_params['consumer_bic'],
59
+ signature_date: json_params['signature_date'],
60
+ mandate_reference: json_params['mandate_reference'],
61
+ webhook_url: json_params['webhook_url'],
62
+ testmode: json_params['testmode']
63
+ )
64
+ JSON.pretty_generate(mandate.attributes)
65
+ end
66
+
67
+ 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
+ )
70
+ JSON.pretty_generate(mandates.attributes)
71
+ end
72
+
73
+
74
+ get '/v1/customers/:customer_id/mandates/:id' do
75
+ mandate = client.customers_mandates.with(params[:customer_id]).get(params[:id], testmode: params[:testmode])
76
+ JSON.pretty_generate(mandate.attributes)
77
+ end
78
+
79
+ delete '/v1/customers/:customer_id/mandates/:id' do
80
+ client.customers_mandates.with(params[:customer_id]).delete(params[:id], testmode: params[:testmode])
81
+ "deleted"
82
+ end
83
+ end
@@ -0,0 +1,50 @@
1
+ class Application < Sinatra::Application
2
+ swagger_path '/v1/methods' do
3
+ operation :get, description: 'List methods https://www.mollie.com/en/docs/reference/methods/list', tags: ['Methods'] do
4
+ parameter name: :include, in: 'query', description: 'Include additional data, e.g. issuers', type: :string
5
+ parameter name: :recurring_type, in: 'query', description: 'Recurring type', type: :string, default: 'first'
6
+ parameter name: :locale, in: 'query', description: 'Locale', type: :integer
7
+ parameter name: :offset, in: 'query', description: 'Offset', type: :integer
8
+ parameter name: :count, in: 'query', description: 'Count', type: :integer
9
+ parameter name: :profile_id, in: 'query', description: 'Profile ID', type: :string
10
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
11
+ security api_key: []
12
+ response 200, description: 'Successful response'
13
+ response 500, description: 'Unexpected error'
14
+ end
15
+ end
16
+
17
+ swagger_path '/v1/methods/{id}' do
18
+ operation :get, description: 'Get method', tags: ['Methods'] do
19
+ parameter name: :id, in: 'path', description: 'Method id', type: :string
20
+ parameter name: :include, in: 'query', description: 'Include additional data, e.g. issuers', type: :string
21
+ parameter name: :locale, in: 'query', description: 'Locale', type: :integer
22
+ parameter name: :profile_id, in: 'query', description: 'Profile ID', type: :string
23
+ parameter name: :testmode, in: 'query', description: 'Test mode', type: :boolean
24
+ security api_key: []
25
+ response 200, description: 'Successful response'
26
+ response 500, description: 'Unexpected error'
27
+ end
28
+ end
29
+
30
+ get '/v1/methods' do
31
+ methods = client.methods.all(params[:offset], params[:count],
32
+ include: params[:include],
33
+ recurring_type: params[:recurring_type],
34
+ locale: params[:locale],
35
+ profile_id: params[:profile_id],
36
+ testmode: params[:testmode]
37
+ )
38
+ JSON.pretty_generate(methods.attributes)
39
+ end
40
+
41
+ get '/v1/methods/:id' do
42
+ method = client.methods.get(params[:id],
43
+ include: params[:include],
44
+ locale: params[:locale],
45
+ profile_id: params[:profile_id],
46
+ testmode: params[:testmode]
47
+ )
48
+ JSON.pretty_generate(method.attributes)
49
+ end
50
+ end