mollie-api-ruby 4.10.0 → 4.12.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d80bc70f4fab363a9546ef3d08b7ce81d0d67a0bc9bfc4f5ae81f2e55fdb853
4
- data.tar.gz: e10228e454d164a725c0d977cff690f17f4cdf8d2ad4f85c28c81059ae12bb6d
3
+ metadata.gz: 74f551510fa882249e3224bd53e50334ccce5d9f4538b0c9fdf94cd86eb25bd1
4
+ data.tar.gz: 2208eac855cb783b5183c4b64f604ce9981b2196eeaa92cdfd71061b0e98a56a
5
5
  SHA512:
6
- metadata.gz: 313a6f14d2fd5f0ea96f3234a27eb8bbdd334ef7053fb290f416b5f13ceb29b8a9cf15809e37ec103db6d1721f334c39f1962eab3029814f3e404cc812a5b20a
7
- data.tar.gz: 5fb49b6d256cc78d63c7ed41eaf9e1478c1a6ac8c413fb92e66cf2c3d2a58417b2c55435f228f0e600bcadaecd71f71a45c29d592f6d39e9659fa3ea21405ef0
6
+ metadata.gz: 50eb679501ae91cdf624127d13d5e45be32624864c166c3ff75fff563e0accc9e24874142b279c019b48f848f061e87c18f3c8092a34120588ca869de7e01498
7
+ data.tar.gz: 54cd23ca6361f723a622d00b05724373632f2ab395dcb51d8343e37467c0a14d7da23b758cd127fc7340c0e7bdd57fea837a1cfaa0b18eb0fb0a8889d1fd3c7c
@@ -0,0 +1,72 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "master" ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "master" ]
20
+ schedule:
21
+ - cron: '30 20 * * 4'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+
52
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53
+ # queries: security-extended,security-and-quality
54
+
55
+
56
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57
+ # If this step fails, then you should remove it and run the build manually (see below)
58
+ - name: Autobuild
59
+ uses: github/codeql-action/autobuild@v2
60
+
61
+ # ℹ️ Command-line programs to run using the OS shell.
62
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63
+
64
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
65
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66
+
67
+ # - run: |
68
+ # echo "Run, Build Application using script"
69
+ # ./location_of_script_within_repo/buildscript.sh
70
+
71
+ - name: Perform CodeQL Analysis
72
+ uses: github/codeql-action/analyze@v2
data/.travis.yml CHANGED
@@ -8,7 +8,7 @@ deploy:
8
8
  gem: mollie-api-ruby
9
9
  provider: rubygems
10
10
  api_key:
11
- secure: "JdYKjK+AZNNviyAW92ta16Kk/u1gLTyvUVjoiSrGchsMmx8pN107MERpn5klFzOTKcnmMn+h3eA0RzhsuA+eFBfd5X58kNlXzXzKzKvOKmjrH69jiUWAJ5PmepacvsKMCAovOOtkskFzifKUUkrkPv87KO1J97wsZ4ASX6q3MRs="
11
+ secure: "OQobSXpfwELzuh5prnwADPGwt3LHyD/EMuKlJ7aJ6CNveGQzvgGOtK52Cn3X9X8yAkX/PNJVXnPeFaKSQopcAJB30ySJMnPYGjQvIoiUOglMB8lJDFxcLtZ/21NXDf2f3cxYPmZkBGtFQeb/EEYBg4/vwjgWlJ/mcwnesLpwj5A="
12
12
  on:
13
13
  tags: true
14
14
  repo: mollie/mollie-api-ruby
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ ## 4.12.0 - 2023-01-29
8
+
9
+ - (f180b47) Add support for idempotency keys
10
+ - (f0a47d1) Payment: add support for cancel_url
11
+ - (9db60b3) Order: add support for cancel_url
12
+ - (2f88990) Require non-empty ID when fetching a resource
13
+
14
+ ## 4.11.0 - 2022-03-01
15
+
16
+ - (1ef339e) Add Partner API
17
+
7
18
  ## 4.10.0 - 2021-11-20
8
19
 
9
20
  :warning: The `Profile#category_code` attribute is deprecated and will be removed in 2022. Please use the `business_category` parameter instead.
data/README.md CHANGED
@@ -24,11 +24,11 @@ To use the Mollie API client, the following things are required:
24
24
 
25
25
  ## Installation
26
26
 
27
- By far the easiest way to install the Mollie API client is to install it with [gem](http://rubygems.org/).
27
+ By far the easiest way to install the Mollie API client is to install it with [gem](http://rubygems.org/). Note: v4.8.0 and higher are not published on rubygems.org, see [GH-140](https://github.com/mollie/mollie-api-ruby/issues/140) for details.
28
28
 
29
29
  ```
30
30
  # Gemfile
31
- gem 'mollie-api-ruby'
31
+ gem "mollie-api-ruby", github: "mollie/mollie-api-ruby", tag: "v4.11.0"
32
32
 
33
33
  $ gem install mollie-api-ruby
34
34
  ```
@@ -0,0 +1 @@
1
+ partner = Mollie::Partner.current
data/lib/mollie/base.rb CHANGED
@@ -30,6 +30,8 @@ module Mollie
30
30
  end
31
31
 
32
32
  def get(id, options = {})
33
+ raise Mollie::Exception, "Invalid resource ID: #{id.inspect}" if id.nil? || id.strip.empty?
34
+
33
35
  request('GET', id, {}, options) do |response|
34
36
  new(response)
35
37
  end
data/lib/mollie/client.rb CHANGED
@@ -72,6 +72,7 @@ module Mollie
72
72
 
73
73
  api_key = http_body.delete(:api_key) || query.delete(:api_key) || @api_key
74
74
  api_endpoint = http_body.delete(:api_endpoint) || query.delete(:api_endpoint) || @api_endpoint
75
+ idempotency_key = http_body.delete(:idempotency_key) || query.delete(:idempotency_key)
75
76
 
76
77
  unless query.empty?
77
78
  camelized_query = Util.camelize_keys(query)
@@ -110,6 +111,10 @@ module Mollie
110
111
  request['Authorization'] = "Bearer #{api_key}"
111
112
  request['User-Agent'] = @version_strings.join(' ')
112
113
 
114
+ if http_method == 'POST' && idempotency_key
115
+ request['Idempotency-Key'] = idempotency_key
116
+ end
117
+
113
118
  begin
114
119
  response = client.request(request)
115
120
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
data/lib/mollie/order.rb CHANGED
@@ -25,6 +25,7 @@ module Mollie
25
25
  :locale,
26
26
  :metadata,
27
27
  :redirect_url,
28
+ :cancel_url,
28
29
  :webhook_url,
29
30
  :created_at,
30
31
  :expires_at,
@@ -0,0 +1,52 @@
1
+ module Mollie
2
+ class Partner < Base
3
+ attr_accessor :partner_type,
4
+ :is_commission_partner,
5
+ :partner_contract_signed_at,
6
+ :partner_contract_update_available,
7
+ :_links
8
+
9
+ attr_reader :user_agent_tokens
10
+
11
+ alias links _links
12
+
13
+ def self.current(options = {})
14
+ response = Client.instance.perform_http_call('GET', 'organizations/me/partner', nil, {}, options)
15
+ new(response)
16
+ end
17
+
18
+ def type
19
+ partner_type
20
+ end
21
+
22
+ def commission_partner?
23
+ is_commission_partner
24
+ end
25
+
26
+ def contract_signed_at
27
+ @contract_signed_at = begin
28
+ Time.parse(partner_contract_signed_at)
29
+ rescue StandardError
30
+ nil
31
+ end
32
+ end
33
+
34
+ def contract_update_available?
35
+ partner_contract_update_available
36
+ end
37
+
38
+ def user_agent_tokens=(tokens)
39
+ @user_agent_tokens = tokens.map do |token|
40
+ OpenStruct.new(
41
+ token: token['token'],
42
+ starts_at: Time.parse(token['starts_at']),
43
+ ends_at: (Time.parse(token['ends_at']) unless token['ends_at'].nil?)
44
+ )
45
+ end
46
+ end
47
+
48
+ def signuplink
49
+ Util.extract_url(links, 'signuplink')
50
+ end
51
+ end
52
+ end
@@ -46,6 +46,7 @@ module Mollie
46
46
  :_links,
47
47
  :details,
48
48
  :redirect_url,
49
+ :cancel_url,
49
50
  :webhook_url
50
51
 
51
52
  alias links _links
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.10.0'.freeze
2
+ VERSION = '4.12.0'.freeze
3
3
  end
data/lib/mollie.rb CHANGED
@@ -21,6 +21,7 @@ require 'mollie/list'
21
21
  require 'mollie/method'
22
22
  require 'mollie/order'
23
23
  require 'mollie/organization'
24
+ require 'mollie/partner'
24
25
  require 'mollie/payment'
25
26
  require 'mollie/permission'
26
27
  require 'mollie/profile'
@@ -49,6 +49,7 @@
49
49
  "email": "luke@skywalker.com"
50
50
  },
51
51
  "redirectUrl": "https://example.org/redirect",
52
+ "cancelUrl": "https://example.org/cancel",
52
53
  "webhookUrl": "https://example.org/webhook",
53
54
  "expiredAt": "2018-08-30T09:29:56+00:02",
54
55
  "paidAt": "2018-08-26T09:29:56+00:00",
@@ -0,0 +1,26 @@
1
+ {
2
+ "resource": "partner",
3
+ "partnerType": "signuplink",
4
+ "isCommissionPartner": true,
5
+ "userAgentTokens": [{
6
+ "token": "unique-token",
7
+ "startsAt": "2018-03-20T13:13:37+00:00",
8
+ "endsAt": null
9
+ }],
10
+ "partnerContractSignedAt": "2018-03-20T13:13:37+00:00",
11
+ "partnerContractUpdateAvailable": true,
12
+ "_links": {
13
+ "self": {
14
+ "href": "https://api.mollie.com/v2/organizations/me/partner",
15
+ "type": "application/hal+json"
16
+ },
17
+ "documentation": {
18
+ "href": "https://docs.mollie.com/reference/v2/organizations-api/get-partner",
19
+ "type": "text/html"
20
+ },
21
+ "signuplink": {
22
+ "href": "https://www.mollie.com/dashboard/signup/myCode?lang=en",
23
+ "type": "text/html"
24
+ }
25
+ }
26
+ }
@@ -44,6 +44,13 @@ module Mollie
44
44
  assert_equal 'my-id', resource.id
45
45
  assert_equal 'object-id', resource.testobject_id
46
46
  end
47
+ def test_get_with_invalid_identifiers
48
+ assert_raises(Mollie::Exception) { TestObject.get(nil) }
49
+ assert_raises(Mollie::Exception) { TestObject.get(" ") }
50
+ assert_raises(Mollie::Exception) { TestObject.get(" ") }
51
+ assert_raises(Mollie::Exception) { TestObject.get("\t") }
52
+ assert_raises(Mollie::Exception) { TestObject.get("\n") }
53
+ end
47
54
 
48
55
  def test_create
49
56
  stub_request(:post, 'https://api.mollie.com/v2/testobjects')
@@ -53,6 +53,18 @@ module Mollie
53
53
  assert_equal 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM', Mollie::Client.instance.api_key
54
54
  end
55
55
 
56
+ def test_post_with_idempotency_key
57
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
58
+ .with(headers: { "Idempotency-Key" => '91d42bd5-e47f-4f4a-b38e-99333b264e78' })
59
+ .to_return(status: 200, body: '{}', headers: {})
60
+
61
+ payment = Mollie::Payment.create(
62
+ amount: { value: '10.00', currency: 'EUR' },
63
+ redirect_url: 'https://webshop.example.org/order/12345/',
64
+ idempotency_key: '91d42bd5-e47f-4f4a-b38e-99333b264e78'
65
+ )
66
+ end
67
+
56
68
  def test_get_request_convert_to_camel_case
57
69
  stub_request(:get, 'https://api.mollie.com/v2/my-method?myParam=ok')
58
70
  .to_return(status: 200, body: '{}', headers: {})
@@ -75,6 +75,7 @@ module Mollie
75
75
  assert_equal '1337', order.metadata.order_id
76
76
  assert_equal 'Lego cars', order.metadata.description
77
77
  assert_equal 'https://example.org/redirect', order.redirect_url
78
+ assert_equal 'https://example.org/cancel', order.cancel_url
78
79
  assert_equal 'https://example.org/webhook', order.webhook_url
79
80
  assert_equal Time.parse('2018-08-02T09:29:56+00:00'), order.created_at
80
81
  assert_equal Time.parse('2018-08-30T09:29:56+00:00'), order.expires_at
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class PartnerTest < Test::Unit::TestCase
5
+ def setup
6
+ stub_request(:get, 'https://api.mollie.com/v2/organizations/me/partner')
7
+ .to_return(status: 200, body: read_fixture('organizations/partner.json'), headers: {})
8
+ end
9
+
10
+ def test_class_type
11
+ partner = Partner.current
12
+ assert_equal Mollie::Partner, partner.class
13
+ end
14
+
15
+ def test_partner_type
16
+ partner = Partner.current
17
+ assert_equal 'signuplink', partner.type
18
+ end
19
+
20
+ def test_commision_partner
21
+ partner = Partner.current
22
+ assert partner.commission_partner?
23
+ end
24
+
25
+ def test_contract_signed_at
26
+ partner = Partner.current
27
+ assert_equal Time.parse('2018-03-20T13:13:37+00:00'), partner.contract_signed_at
28
+ end
29
+
30
+ def test_contract_update_available?
31
+ partner = Partner.current
32
+ assert partner.contract_update_available?
33
+ end
34
+
35
+ def test_signuplink
36
+ partner = Partner.current
37
+ assert_equal 'https://www.mollie.com/dashboard/signup/myCode?lang=en', partner.signuplink
38
+ end
39
+
40
+ def test_user_agent_tokens
41
+ token = Partner.current.user_agent_tokens.first
42
+ assert_equal 'unique-token', token.token
43
+ assert_equal Time.parse('2018-03-20T13:13:37+00:00'), token.starts_at
44
+ assert_nil nil, token.ends_at
45
+ end
46
+ end
47
+ end
@@ -32,6 +32,7 @@ module Mollie
32
32
  profile_id: 'pfl_QkEhN94Ba',
33
33
  sequence_type: 'oneoff',
34
34
  redirect_url: 'https://webshop.example.org/order/12345',
35
+ cancel_url: 'https://webshop.example.org/payments/cancel',
35
36
  webhook_url: 'https://webshop.example.org/payments/webhook',
36
37
  _links: {
37
38
  'self' => {
@@ -72,8 +73,9 @@ module Mollie
72
73
  assert_equal 'nl_NL', payment.locale
73
74
  assert_equal 'NL', payment.country_code
74
75
  assert_equal 'pfl_QkEhN94Ba', payment.profile_id
75
- assert_equal 'https://webshop.example.org/payments/webhook', payment.webhook_url
76
76
  assert_equal 'https://webshop.example.org/order/12345', payment.redirect_url
77
+ assert_equal 'https://webshop.example.org/payments/cancel', payment.cancel_url
78
+ assert_equal 'https://webshop.example.org/payments/webhook', payment.webhook_url
77
79
  assert_equal 'https://www.mollie.com/payscreen/select-method/7UhSN1zuXS', payment.checkout_url
78
80
  assert_equal false, payment.cancelable?
79
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mollie-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.0
4
+ version: 4.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mollie B.V.
@@ -80,6 +80,7 @@ extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
82
  - ".github/workflows/build.yml"
83
+ - ".github/workflows/codeql.yml"
83
84
  - ".gitignore"
84
85
  - ".rubocop.yml"
85
86
  - ".rubocop_todo.yml"
@@ -131,6 +132,7 @@ files:
131
132
  - examples/orders/update-orderline.rb
132
133
  - examples/orders/update.rb
133
134
  - examples/organisations/get-current.rb
135
+ - examples/organisations/get-partner.rb
134
136
  - examples/organisations/get.rb
135
137
  - examples/payments/create.rb
136
138
  - examples/payments/delete.rb
@@ -200,6 +202,7 @@ files:
200
202
  - lib/mollie/order/refund.rb
201
203
  - lib/mollie/order/shipment.rb
202
204
  - lib/mollie/organization.rb
205
+ - lib/mollie/partner.rb
203
206
  - lib/mollie/payment.rb
204
207
  - lib/mollie/payment/capture.rb
205
208
  - lib/mollie/payment/chargeback.rb
@@ -238,6 +241,7 @@ files:
238
241
  - test/fixtures/orders/refund_all.json
239
242
  - test/fixtures/orders/update.json
240
243
  - test/fixtures/orders/update_line.json
244
+ - test/fixtures/organizations/partner.json
241
245
  - test/fixtures/payments/get.json
242
246
  - test/fixtures/refunds/get.json
243
247
  - test/fixtures/shipments/create.json
@@ -264,6 +268,7 @@ files:
264
268
  - test/mollie/order/shipment_test.rb
265
269
  - test/mollie/order_test.rb
266
270
  - test/mollie/organization_test.rb
271
+ - test/mollie/partner_test.rb
267
272
  - test/mollie/payment/capture_test.rb
268
273
  - test/mollie/payment/chargeback_test.rb
269
274
  - test/mollie/payment/refund_test.rb
@@ -323,6 +328,7 @@ test_files:
323
328
  - test/fixtures/orders/refund_all.json
324
329
  - test/fixtures/orders/update.json
325
330
  - test/fixtures/orders/update_line.json
331
+ - test/fixtures/organizations/partner.json
326
332
  - test/fixtures/payments/get.json
327
333
  - test/fixtures/refunds/get.json
328
334
  - test/fixtures/shipments/create.json
@@ -349,6 +355,7 @@ test_files:
349
355
  - test/mollie/order/shipment_test.rb
350
356
  - test/mollie/order_test.rb
351
357
  - test/mollie/organization_test.rb
358
+ - test/mollie/partner_test.rb
352
359
  - test/mollie/payment/capture_test.rb
353
360
  - test/mollie/payment/chargeback_test.rb
354
361
  - test/mollie/payment/refund_test.rb