mollie-api-ruby 4.11.0 → 4.13.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: 3771f281c214f0e44afd28c576b79c25aaddb41e8cbb0bb660a17a5ce0381e7e
4
- data.tar.gz: 958f0d36aae881909578c746b936f16dbf67a94ae3a7f8d79113f2e9d026b8cc
3
+ metadata.gz: 58916be713b9cf5128476188f1b0e61dc51f04d9e41b48b09c053b923e9daf39
4
+ data.tar.gz: 2f514f685d55211565be7197d5b9b36e587894582bdc515f4eb75ce19c481f10
5
5
  SHA512:
6
- metadata.gz: 223833841d3d5c122a81df8985f456a447d5ed1bee91e8daea7b1ffda1ba4c50ec73254dbead5c6efd444e091b9e18038985fb3a3559d1ab33bb8ee665025901
7
- data.tar.gz: e57c84fb83b53b0c6ac59dfecc7fbb407f4c33fd84c9c5110e68ac8e381c42eb346f027123554a85d5d8f927178976a872efc0b9005a02b7a808811da687dc54
6
+ metadata.gz: f3dd1ed54bf737169dbd652f3314ce258c03a87d3b73ed0f8e2473ff2acfef1c08cd5b06349d370f564ee318964a78757978fc948d975f6e0733b1d60a69ff52
7
+ data.tar.gz: cad4e544c9cb525bbc94d1a4caf5585590456345ec1bd74fe08f4fe73a5292d4c721b7df2226f6721311487f3ef319bc69d8664863ca864792399cd48f067669
@@ -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
@@ -0,0 +1,27 @@
1
+ name: Publish gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v[0-9]+.[0-9]+.[0-9]+*
7
+
8
+ jobs:
9
+ publish:
10
+ name: Push gem to RubyGems.org
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
16
+
17
+ steps:
18
+ # Set up
19
+ - uses: actions/checkout@v4
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ bundler-cache: true
24
+ ruby-version: ruby
25
+
26
+ # Release
27
+ - uses: rubygems/release-gem@v1
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,18 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ ## 4.13.0 - 2023-05-22
8
+
9
+ - (09489be) Add HTTP response details to RequestError
10
+ - (fe5d114) Add Terminals API
11
+
12
+ ## 4.12.0 - 2023-01-29
13
+
14
+ - (f180b47) Add support for idempotency keys
15
+ - (f0a47d1) Payment: add support for cancel_url
16
+ - (9db60b3) Order: add support for cancel_url
17
+ - (2f88990) Require non-empty ID when fetching a resource
18
+
7
19
  ## 4.11.0 - 2022-03-01
8
20
 
9
21
  - (1ef339e) Add Partner API
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
  ```
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+
1
3
  task default: %w[test]
2
4
 
3
5
  task :test do
@@ -0,0 +1 @@
1
+ terminal = Mollie::Terminal.get("term_7MgL4wea46qkRcoTZjWEH")
@@ -0,0 +1 @@
1
+ terminals = Mollie::Terminal.all
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,
@@ -125,11 +130,11 @@ module Mollie
125
130
  {} # No Content
126
131
  when 404
127
132
  json = JSON.parse(response.body)
128
- exception = ResourceNotFoundError.new(json)
133
+ exception = ResourceNotFoundError.new(json, response)
129
134
  raise exception
130
135
  else
131
136
  json = JSON.parse(response.body)
132
- exception = Mollie::RequestError.new(json)
137
+ exception = Mollie::RequestError.new(json, response)
133
138
  raise exception
134
139
  end
135
140
  end
@@ -5,17 +5,30 @@ module Mollie
5
5
  class RequestError < Mollie::Exception
6
6
  attr_accessor :status, :title, :detail, :field, :links
7
7
 
8
- def initialize(error)
8
+ def initialize(error, response = nil)
9
9
  exception.status = error['status']
10
10
  exception.title = error['title']
11
11
  exception.detail = error['detail']
12
12
  exception.field = error['field']
13
13
  exception.links = error['_links']
14
+ self.response = response
14
15
  end
15
16
 
16
17
  def to_s
17
18
  "#{status} #{title}: #{detail}"
18
19
  end
20
+
21
+ def http_headers
22
+ response.to_hash if response
23
+ end
24
+
25
+ def http_body
26
+ response.body if response
27
+ end
28
+
29
+ private
30
+
31
+ attr_accessor :response
19
32
  end
20
33
 
21
34
  class ResourceNotFoundError < RequestError
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,
@@ -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
@@ -0,0 +1,59 @@
1
+ module Mollie
2
+ class Terminal < Base
3
+
4
+ STATUS_PENDING = "pending".freeze
5
+ STATUS_ACTIVE = "active".freeze
6
+ STATUS_INACTIVE = "inactive".freeze
7
+
8
+ attr_accessor :id,
9
+ :profile_id,
10
+ :status,
11
+ :brand,
12
+ :model,
13
+ :serial_number,
14
+ :currency,
15
+ :description,
16
+ :created_at,
17
+ :updated_at,
18
+ :deactivated_at,
19
+ :_links
20
+
21
+ alias links _links
22
+
23
+ def pending?
24
+ status == STATUS_PENDING
25
+ end
26
+
27
+ def active?
28
+ status == STATUS_ACTIVE
29
+ end
30
+
31
+ def inactive?
32
+ status == STATUS_INACTIVE
33
+ end
34
+
35
+ def created_at=(created_at)
36
+ @created_at = begin
37
+ Time.parse(created_at.to_s)
38
+ rescue StandardError
39
+ nil
40
+ end
41
+ end
42
+
43
+ def updated_at=(updated_at)
44
+ @updated_at = begin
45
+ Time.parse(updated_at.to_s)
46
+ rescue StandardError
47
+ nil
48
+ end
49
+ end
50
+
51
+ def deactivated_at=(deactivated_at)
52
+ @deactivated_at = begin
53
+ Time.parse(deactivated_at.to_s)
54
+ rescue StandardError
55
+ nil
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.11.0'.freeze
2
+ VERSION = '4.13.0'.freeze
3
3
  end
data/lib/mollie.rb CHANGED
@@ -28,6 +28,7 @@ require 'mollie/profile'
28
28
  require 'mollie/refund'
29
29
  require 'mollie/settlement'
30
30
  require 'mollie/subscription'
31
+ require 'mollie/terminal'
31
32
 
32
33
  require 'mollie/customer/mandate'
33
34
  require 'mollie/customer/payment'
@@ -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,23 @@
1
+ {
2
+ "id": "term_7MgL4wea46qkRcoTZjWEH",
3
+ "profileId": "pfl_QkEhN94Ba",
4
+ "status": "active",
5
+ "brand": "PAX",
6
+ "model": "A920",
7
+ "serialNumber": "1234567890",
8
+ "currency": "EUR",
9
+ "description": "Terminal #12345",
10
+ "createdAt": "2022-02-12T11:58:35.0Z",
11
+ "updatedAt": "2022-11-15T13:32:11+00:00",
12
+ "deactivatedAt": "2022-02-12T12:13:35.0Z",
13
+ "_links": {
14
+ "self": {
15
+ "href": "https://api.mollie.com/v2/terminals/term_7MgL4wea46qkRcoTZjWEH",
16
+ "type": "application/hal+json"
17
+ },
18
+ "documentation": {
19
+ "href": "https://docs.mollie.com/reference/v2/terminals-api/get-terminal",
20
+ "type": "text/html"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "count": 3,
3
+ "_embedded": {
4
+ "terminals": [
5
+ {
6
+ "resource": "terminal",
7
+ "id": "terminal_one"
8
+ },
9
+ {
10
+ "resource": "terminal",
11
+ "id": "terminal_two"
12
+ },
13
+ {
14
+ "resource": "terminal",
15
+ "id": "terminal_three"
16
+ }
17
+ ]
18
+ },
19
+ "_links": {
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/terminals",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": null,
25
+ "next": {
26
+ "href": "https://api.mollie.com/v2/terminals?from=term_7MgL4wea46qkRcoTZjWEH",
27
+ "type": "application/hal+json"
28
+ },
29
+ "documentation": {
30
+ "href": "https://docs.mollie.com/reference/v2/terminals-api/list-terminals",
31
+ "type": "text/html"
32
+ }
33
+ }
34
+ }
@@ -45,6 +45,14 @@ module Mollie
45
45
  assert_equal 'object-id', resource.testobject_id
46
46
  end
47
47
 
48
+ def test_get_with_invalid_identifiers
49
+ assert_raises(Mollie::Exception) { TestObject.get(nil) }
50
+ assert_raises(Mollie::Exception) { TestObject.get(" ") }
51
+ assert_raises(Mollie::Exception) { TestObject.get(" ") }
52
+ assert_raises(Mollie::Exception) { TestObject.get("\t") }
53
+ assert_raises(Mollie::Exception) { TestObject.get("\n") }
54
+ end
55
+
48
56
  def test_create
49
57
  stub_request(:post, 'https://api.mollie.com/v2/testobjects')
50
58
  .with(body: %({"foo":1.95}))
@@ -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: {})
@@ -0,0 +1,87 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class ExceptionTest < Test::Unit::TestCase
5
+ def test_attributes
6
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
7
+ .to_return(status: 422, headers: { "Content-Type" => "application/hal+json}" }, body: %(
8
+ {
9
+ "status": 422,
10
+ "title": "Unprocessable Entity",
11
+ "detail": "The amount is higher than the maximum",
12
+ "field": "amount",
13
+ "_links": {
14
+ "documentation": {
15
+ "href": "https://docs.mollie.com/errors",
16
+ "type": "text/html"
17
+ }
18
+ }
19
+ }
20
+ ))
21
+
22
+ exception = assert_raise(Mollie::RequestError) do
23
+ Mollie::Payment.create(
24
+ amount: { value: "1000000000.00", currency: "EUR" },
25
+ description: "Order #66",
26
+ redirect_url: "https://www.example.org/payment/completed",
27
+ )
28
+ end
29
+
30
+ assert_equal 422, exception.status
31
+ assert_equal "Unprocessable Entity", exception.title
32
+ assert_equal "The amount is higher than the maximum", exception.detail
33
+ assert_equal "amount", exception.field
34
+ assert_equal "https://docs.mollie.com/errors", exception.links["documentation"]["href"]
35
+ assert_equal "text/html", exception.links["documentation"]["type"]
36
+ end
37
+
38
+ def test_exception_message
39
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
40
+ .to_return(status: 401, headers: { "Content-Type" => "application/hal+json}" }, body: %(
41
+ {
42
+ "status": 401,
43
+ "title": "Unauthorized Request",
44
+ "detail": "Missing authentication, or failed to authenticate",
45
+ "_links": {
46
+ "documentation": {
47
+ "href": "https://docs.mollie.com/overview/authentication",
48
+ "type": "text/html"
49
+ }
50
+ }
51
+ }
52
+ ))
53
+
54
+ exception = assert_raise(Mollie::RequestError) { Payment.get('tr_WDqYK6vllg') }
55
+ assert_equal '401 Unauthorized Request: Missing authentication, or failed to authenticate', exception.message
56
+ end
57
+
58
+ def test_http_attributes
59
+ body = %({
60
+ "status": 422,
61
+ "title": "Unprocessable Entity",
62
+ "detail": "The amount is higher than the maximum",
63
+ "field": "amount",
64
+ "_links": {
65
+ "documentation": {
66
+ "href": "https://docs.mollie.com/errors",
67
+ "type": "text/html"
68
+ }
69
+ }
70
+ })
71
+
72
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
73
+ .to_return(status: 422, headers: { "Content-Type" => "application/hal+json" }, body: body)
74
+
75
+ exception = assert_raise(Mollie::RequestError) do
76
+ Mollie::Payment.create(
77
+ amount: { value: "1000000000.00", currency: "EUR" },
78
+ description: "Order #66",
79
+ redirect_url: "https://www.example.org/payment/completed",
80
+ )
81
+ end
82
+
83
+ assert_equal({ "content-type" => ["application/hal+json"] }, exception.http_headers)
84
+ assert_equal(body, exception.http_body)
85
+ end
86
+ end
87
+ end
@@ -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
@@ -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
@@ -0,0 +1,54 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class TerminalTest < Test::Unit::TestCase
5
+ GET_TERMINAL = read_fixture('terminals/get.json')
6
+ LIST_TERMINALS = read_fixture('terminals/list.json')
7
+
8
+ def test_get_terminal
9
+ stub_request(:get, "https://api.mollie.com/v2/terminals/term_7MgL4wea46qkRcoTZjWEH")
10
+ .to_return(status: 200, body: GET_TERMINAL, headers: {})
11
+
12
+ terminal = Terminal.get("term_7MgL4wea46qkRcoTZjWEH")
13
+
14
+ assert_equal "term_7MgL4wea46qkRcoTZjWEH", terminal.id
15
+ assert_equal "pfl_QkEhN94Ba", terminal.profile_id
16
+ assert_equal "active", terminal.status
17
+ assert_equal "PAX", terminal.brand
18
+ assert_equal "A920", terminal.model
19
+ assert_equal "1234567890", terminal.serial_number
20
+ assert_equal "EUR", terminal.currency
21
+ assert_equal "Terminal #12345", terminal.description
22
+ assert_equal Time.parse("2022-02-12T11:58:35.0Z"), terminal.created_at
23
+ assert_equal Time.parse("2022-11-15T13:32:11+00:00"), terminal.updated_at
24
+ assert_equal Time.parse("2022-02-12T12:13:35.0Z"), terminal.deactivated_at
25
+ end
26
+
27
+ def test_status_pending
28
+ assert Terminal.new(status: Terminal::STATUS_PENDING).pending?
29
+ assert !Terminal.new(status: "not-pending").pending?
30
+ end
31
+
32
+ def test_status_active
33
+ assert Terminal.new(status: Terminal::STATUS_ACTIVE).active?
34
+ assert !Terminal.new(status: "not-active").active?
35
+ end
36
+
37
+ def test_status_inactive
38
+ assert Terminal.new(status: Terminal::STATUS_INACTIVE).inactive?
39
+ assert !Terminal.new(status: "not-inactive").inactive?
40
+ end
41
+
42
+ def test_list_terminals
43
+ stub_request(:get, "https://api.mollie.com/v2/terminals")
44
+ .to_return(status: 200, body: LIST_TERMINALS, headers: {})
45
+
46
+ terminals = Terminal.all
47
+
48
+ assert_equal 3, terminals.size
49
+ assert_equal "terminal_one", terminals[0].id
50
+ assert_equal "terminal_two", terminals[1].id
51
+ assert_equal "terminal_three", terminals[2].id
52
+ end
53
+ end
54
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mollie-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mollie B.V.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-25 00:00:00.000000000 Z
11
+ date: 2024-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -80,6 +80,8 @@ extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
82
  - ".github/workflows/build.yml"
83
+ - ".github/workflows/codeql.yml"
84
+ - ".github/workflows/push.yml"
83
85
  - ".gitignore"
84
86
  - ".rubocop.yml"
85
87
  - ".rubocop_todo.yml"
@@ -179,6 +181,8 @@ files:
179
181
  - examples/subscriptions/get.rb
180
182
  - examples/subscriptions/list.rb
181
183
  - examples/subscriptions/update.rb
184
+ - examples/terminals/get.rb
185
+ - examples/terminals/list.rb
182
186
  - lib/cacert.pem
183
187
  - lib/mollie-api-ruby.rb
184
188
  - lib/mollie.rb
@@ -215,6 +219,7 @@ files:
215
219
  - lib/mollie/settlement/payment.rb
216
220
  - lib/mollie/settlement/refund.rb
217
221
  - lib/mollie/subscription.rb
222
+ - lib/mollie/terminal.rb
218
223
  - lib/mollie/util.rb
219
224
  - lib/mollie/version.rb
220
225
  - mollie-api-ruby.gemspec
@@ -249,6 +254,8 @@ files:
249
254
  - test/fixtures/shipments/update.json
250
255
  - test/fixtures/subscriptions/get.json
251
256
  - test/fixtures/subscriptions/get_payments.json
257
+ - test/fixtures/terminals/get.json
258
+ - test/fixtures/terminals/list.json
252
259
  - test/helper.rb
253
260
  - test/mollie/amount_test.rb
254
261
  - test/mollie/base_test.rb
@@ -258,6 +265,7 @@ files:
258
265
  - test/mollie/customer/payment_test.rb
259
266
  - test/mollie/customer/subscription_test.rb
260
267
  - test/mollie/customer_test.rb
268
+ - test/mollie/exception_test.rb
261
269
  - test/mollie/invoice_test.rb
262
270
  - test/mollie/list_test.rb
263
271
  - test/mollie/method_test.rb
@@ -279,13 +287,14 @@ files:
279
287
  - test/mollie/settlement/payment_test.rb
280
288
  - test/mollie/settlement/refund_test.rb
281
289
  - test/mollie/settlement_test.rb
290
+ - test/mollie/terminal_test.rb
282
291
  - test/mollie/util_test.rb
283
292
  - test/run-test.rb
284
293
  homepage: https://github.com/mollie/mollie-api-ruby
285
294
  licenses:
286
295
  - BSD
287
296
  metadata: {}
288
- post_install_message:
297
+ post_install_message:
289
298
  rdoc_options: []
290
299
  require_paths:
291
300
  - lib
@@ -300,8 +309,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
309
  - !ruby/object:Gem::Version
301
310
  version: '0'
302
311
  requirements: []
303
- rubygems_version: 3.5.10
304
- signing_key:
312
+ rubygems_version: 3.5.9
313
+ signing_key:
305
314
  specification_version: 4
306
315
  summary: Official Mollie API Client for Ruby
307
316
  test_files:
@@ -336,6 +345,8 @@ test_files:
336
345
  - test/fixtures/shipments/update.json
337
346
  - test/fixtures/subscriptions/get.json
338
347
  - test/fixtures/subscriptions/get_payments.json
348
+ - test/fixtures/terminals/get.json
349
+ - test/fixtures/terminals/list.json
339
350
  - test/helper.rb
340
351
  - test/mollie/amount_test.rb
341
352
  - test/mollie/base_test.rb
@@ -345,6 +356,7 @@ test_files:
345
356
  - test/mollie/customer/payment_test.rb
346
357
  - test/mollie/customer/subscription_test.rb
347
358
  - test/mollie/customer_test.rb
359
+ - test/mollie/exception_test.rb
348
360
  - test/mollie/invoice_test.rb
349
361
  - test/mollie/list_test.rb
350
362
  - test/mollie/method_test.rb
@@ -366,5 +378,6 @@ test_files:
366
378
  - test/mollie/settlement/payment_test.rb
367
379
  - test/mollie/settlement/refund_test.rb
368
380
  - test/mollie/settlement_test.rb
381
+ - test/mollie/terminal_test.rb
369
382
  - test/mollie/util_test.rb
370
383
  - test/run-test.rb