mollie-api-ruby 4.10.0 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d80bc70f4fab363a9546ef3d08b7ce81d0d67a0bc9bfc4f5ae81f2e55fdb853
4
- data.tar.gz: e10228e454d164a725c0d977cff690f17f4cdf8d2ad4f85c28c81059ae12bb6d
3
+ metadata.gz: 3771f281c214f0e44afd28c576b79c25aaddb41e8cbb0bb660a17a5ce0381e7e
4
+ data.tar.gz: 958f0d36aae881909578c746b936f16dbf67a94ae3a7f8d79113f2e9d026b8cc
5
5
  SHA512:
6
- metadata.gz: 313a6f14d2fd5f0ea96f3234a27eb8bbdd334ef7053fb290f416b5f13ceb29b8a9cf15809e37ec103db6d1721f334c39f1962eab3029814f3e404cc812a5b20a
7
- data.tar.gz: 5fb49b6d256cc78d63c7ed41eaf9e1478c1a6ac8c413fb92e66cf2c3d2a58417b2c55435f228f0e600bcadaecd71f71a45c29d592f6d39e9659fa3ea21405ef0
6
+ metadata.gz: 223833841d3d5c122a81df8985f456a447d5ed1bee91e8daea7b1ffda1ba4c50ec73254dbead5c6efd444e091b9e18038985fb3a3559d1ab33bb8ee665025901
7
+ data.tar.gz: e57c84fb83b53b0c6ac59dfecc7fbb407f4c33fd84c9c5110e68ac8e381c42eb346f027123554a85d5d8f927178976a872efc0b9005a02b7a808811da687dc54
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ ## 4.11.0 - 2022-03-01
8
+
9
+ - (1ef339e) Add Partner API
10
+
7
11
  ## 4.10.0 - 2021-11-20
8
12
 
9
13
  :warning: The `Profile#category_code` attribute is deprecated and will be removed in 2022. Please use the `business_category` parameter instead.
@@ -0,0 +1 @@
1
+ partner = Mollie::Partner.current
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.10.0'.freeze
2
+ VERSION = '4.11.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'
@@ -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
+ }
@@ -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
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.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mollie B.V.
@@ -131,6 +131,7 @@ files:
131
131
  - examples/orders/update-orderline.rb
132
132
  - examples/orders/update.rb
133
133
  - examples/organisations/get-current.rb
134
+ - examples/organisations/get-partner.rb
134
135
  - examples/organisations/get.rb
135
136
  - examples/payments/create.rb
136
137
  - examples/payments/delete.rb
@@ -200,6 +201,7 @@ files:
200
201
  - lib/mollie/order/refund.rb
201
202
  - lib/mollie/order/shipment.rb
202
203
  - lib/mollie/organization.rb
204
+ - lib/mollie/partner.rb
203
205
  - lib/mollie/payment.rb
204
206
  - lib/mollie/payment/capture.rb
205
207
  - lib/mollie/payment/chargeback.rb
@@ -238,6 +240,7 @@ files:
238
240
  - test/fixtures/orders/refund_all.json
239
241
  - test/fixtures/orders/update.json
240
242
  - test/fixtures/orders/update_line.json
243
+ - test/fixtures/organizations/partner.json
241
244
  - test/fixtures/payments/get.json
242
245
  - test/fixtures/refunds/get.json
243
246
  - test/fixtures/shipments/create.json
@@ -264,6 +267,7 @@ files:
264
267
  - test/mollie/order/shipment_test.rb
265
268
  - test/mollie/order_test.rb
266
269
  - test/mollie/organization_test.rb
270
+ - test/mollie/partner_test.rb
267
271
  - test/mollie/payment/capture_test.rb
268
272
  - test/mollie/payment/chargeback_test.rb
269
273
  - test/mollie/payment/refund_test.rb
@@ -323,6 +327,7 @@ test_files:
323
327
  - test/fixtures/orders/refund_all.json
324
328
  - test/fixtures/orders/update.json
325
329
  - test/fixtures/orders/update_line.json
330
+ - test/fixtures/organizations/partner.json
326
331
  - test/fixtures/payments/get.json
327
332
  - test/fixtures/refunds/get.json
328
333
  - test/fixtures/shipments/create.json
@@ -349,6 +354,7 @@ test_files:
349
354
  - test/mollie/order/shipment_test.rb
350
355
  - test/mollie/order_test.rb
351
356
  - test/mollie/organization_test.rb
357
+ - test/mollie/partner_test.rb
352
358
  - test/mollie/payment/capture_test.rb
353
359
  - test/mollie/payment/chargeback_test.rb
354
360
  - test/mollie/payment/refund_test.rb