mollie-api-ruby 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/CHANGELOG.md +4 -0
- data/{README.mdown → README.md} +8 -8
- data/examples/1-new-payment.rb +4 -2
- data/examples/4-ideal-payment.rb +4 -2
- data/lib/mollie/api/client.rb +32 -13
- data/lib/mollie/api/client/version.rb +1 -1
- data/lib/mollie/api/object/customer/mandate.rb +37 -0
- data/lib/mollie/api/object/customer/subscription.rb +69 -0
- data/lib/mollie/api/object/organization.rb +28 -0
- data/lib/mollie/api/object/permission.rb +12 -0
- data/lib/mollie/api/object/profile.rb +78 -0
- data/lib/mollie/api/object/profile/apikey.rb +23 -0
- data/lib/mollie/api/object/settlement.rb +32 -0
- data/lib/mollie/api/resource/customers/mandates.rb +1 -1
- data/lib/mollie/api/resource/customers/subscriptions.rb +1 -1
- data/lib/mollie/api/resource/organizations.rb +11 -0
- data/lib/mollie/api/resource/permissions.rb +11 -0
- data/lib/mollie/api/resource/profiles.rb +11 -0
- data/lib/mollie/api/resource/profiles/apikeys.rb +27 -0
- data/lib/mollie/api/resource/settlements.rb +11 -0
- data/lib/mollie/api/util.rb +46 -30
- data/test/mollie/api/client_test.rb +9 -4
- data/test/mollie/api/object/customer/mandate_test.rb +47 -0
- data/test/mollie/api/object/customer/subscription_test.rb +70 -0
- data/test/mollie/api/object/organization_test.rb +51 -0
- data/test/mollie/api/object/permission_test.rb +25 -0
- data/test/mollie/api/object/profile/apikey_test.rb +35 -0
- data/test/mollie/api/object/profile_test.rb +72 -0
- data/test/mollie/api/object/settlement_test.rb +140 -0
- data/test/mollie/api/resource/customers/mandates_test.rb +1 -1
- data/test/mollie/api/resource/customers/subscriptions_test.rb +1 -1
- data/test/mollie/api/resource/organizations_test.rb +13 -0
- data/test/mollie/api/resource/permissions_test.rb +13 -0
- data/test/mollie/api/resource/profiles/apikeys_test.rb +23 -0
- data/test/mollie/api/resource/profiles_test.rb +13 -0
- data/test/mollie/api/resource/settlements_test.rb +13 -0
- data/test/mollie/api/util_test.rb +47 -0
- metadata +42 -10
- data/lib/mollie/api/object/mandate.rb +0 -35
- data/lib/mollie/api/object/subscription.rb +0 -67
- data/test/mollie/api/object/mandate_test.rb +0 -45
- data/test/mollie/api/object/subscription_test.rb +0 -68
@@ -1,35 +0,0 @@
|
|
1
|
-
module Mollie
|
2
|
-
module API
|
3
|
-
module Object
|
4
|
-
class Mandate < Base
|
5
|
-
STATUS_VALID = "valid"
|
6
|
-
STATUS_INVALID = "invalid"
|
7
|
-
|
8
|
-
attr_accessor :id,
|
9
|
-
:status,
|
10
|
-
:method,
|
11
|
-
:customer_id,
|
12
|
-
:details,
|
13
|
-
:created_datetime,
|
14
|
-
:mandate_reference
|
15
|
-
|
16
|
-
|
17
|
-
def details=(details)
|
18
|
-
@details = OpenStruct.new(details) if details.is_a?(Hash)
|
19
|
-
end
|
20
|
-
|
21
|
-
def created_datetime=(created_datetime)
|
22
|
-
@created_datetime = Time.parse(created_datetime.to_s) rescue nil
|
23
|
-
end
|
24
|
-
|
25
|
-
def valid?
|
26
|
-
status == STATUS_VALID
|
27
|
-
end
|
28
|
-
|
29
|
-
def invalid?
|
30
|
-
status == STATUS_INVALID
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module Mollie
|
2
|
-
module API
|
3
|
-
module Object
|
4
|
-
class Subscription < Base
|
5
|
-
STATUS_ACTIVE = "active"
|
6
|
-
STATUS_PENDING = "pending" # Waiting for a valid mandate.
|
7
|
-
STATUS_CANCELLED = "cancelled"
|
8
|
-
STATUS_SUSPENDED = "suspended" # Active, but mandate became invalid.
|
9
|
-
STATUS_COMPLETED = "completed"
|
10
|
-
|
11
|
-
attr_accessor :resource,
|
12
|
-
:id,
|
13
|
-
:customer_id,
|
14
|
-
:mode,
|
15
|
-
:created_datetime,
|
16
|
-
:status,
|
17
|
-
:amount,
|
18
|
-
:times,
|
19
|
-
:interval,
|
20
|
-
:description,
|
21
|
-
:method,
|
22
|
-
:cancelled_datetime,
|
23
|
-
:links
|
24
|
-
|
25
|
-
def active?
|
26
|
-
status == STATUS_ACTIVE
|
27
|
-
end
|
28
|
-
|
29
|
-
def pending?
|
30
|
-
status == STATUS_PENDING
|
31
|
-
end
|
32
|
-
|
33
|
-
def suspended?
|
34
|
-
status == STATUS_SUSPENDED
|
35
|
-
end
|
36
|
-
|
37
|
-
def cancelled?
|
38
|
-
status == STATUS_CANCELLED
|
39
|
-
end
|
40
|
-
|
41
|
-
def completed?
|
42
|
-
status == STATUS_COMPLETED
|
43
|
-
end
|
44
|
-
|
45
|
-
def created_datetime=(created_datetime)
|
46
|
-
@created_datetime = Time.parse(created_datetime.to_s) rescue nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def cancelled_datetime=(cancelled_datetime)
|
50
|
-
@cancelled_datetime = Time.parse(cancelled_datetime.to_s) rescue nil
|
51
|
-
end
|
52
|
-
|
53
|
-
def amount=(amount)
|
54
|
-
@amount = BigDecimal.new(amount.to_s)
|
55
|
-
end
|
56
|
-
|
57
|
-
def times=(times)
|
58
|
-
@times = times.to_i
|
59
|
-
end
|
60
|
-
|
61
|
-
def webhook_url
|
62
|
-
links && links['webhook_url']
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module Mollie
|
4
|
-
module API
|
5
|
-
module Object
|
6
|
-
class MandateTest < Test::Unit::TestCase
|
7
|
-
def test_setting_attributes
|
8
|
-
attributes = {
|
9
|
-
id: "mdt_qtUgejVgMN",
|
10
|
-
status: "valid",
|
11
|
-
method: "creditcard",
|
12
|
-
customer_id: "cst_R6JLAuqEgm",
|
13
|
-
details: {
|
14
|
-
card_holder: "John Doe",
|
15
|
-
card_expiry_date: "2016-03-31"
|
16
|
-
},
|
17
|
-
created_datetime: "2016-04-13T11:32:38.0Z"
|
18
|
-
}
|
19
|
-
|
20
|
-
mandate = Mandate.new(attributes)
|
21
|
-
|
22
|
-
assert_equal 'mdt_qtUgejVgMN', mandate.id
|
23
|
-
assert_equal 'valid', mandate.status
|
24
|
-
assert_equal 'creditcard', mandate.method
|
25
|
-
assert_equal 'cst_R6JLAuqEgm', mandate.customer_id
|
26
|
-
assert_equal Time.parse('2016-04-13T11:32:38.0Z'), mandate.created_datetime
|
27
|
-
|
28
|
-
assert_equal 'John Doe', mandate.details.card_holder
|
29
|
-
assert_equal '2016-03-31', mandate.details.card_expiry_date
|
30
|
-
assert_equal nil, mandate.details.non_existing
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_valid_invalid
|
34
|
-
mandate = Mandate.new(status: Mandate::STATUS_VALID)
|
35
|
-
assert mandate.valid?
|
36
|
-
assert !mandate.invalid?
|
37
|
-
|
38
|
-
mandate = Mandate.new(status: Mandate::STATUS_INVALID)
|
39
|
-
assert !mandate.valid?
|
40
|
-
assert mandate.invalid?
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module Mollie
|
4
|
-
module API
|
5
|
-
module Object
|
6
|
-
class SubscriptionTest < Test::Unit::TestCase
|
7
|
-
def test_setting_attributes
|
8
|
-
attributes = {
|
9
|
-
id: "sub_rVKGtNd6s3",
|
10
|
-
customer_id: "cst_stTC2WHAuS",
|
11
|
-
mode: "live",
|
12
|
-
created_datetime: "2016-06-01T12:23:34.0Z",
|
13
|
-
status: "active",
|
14
|
-
amount: "25.00",
|
15
|
-
times: 4,
|
16
|
-
interval: "3 months",
|
17
|
-
description: "Quarterly payment",
|
18
|
-
method: "creditcard",
|
19
|
-
cancelled_datetime: "2016-06-01T12:23:34.0Z",
|
20
|
-
links: {
|
21
|
-
'webhook_url' => "https://example.org/payments/webhook"
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
subscription = Subscription.new(attributes)
|
26
|
-
|
27
|
-
assert_equal "sub_rVKGtNd6s3", subscription.id
|
28
|
-
assert_equal "cst_stTC2WHAuS", subscription.customer_id
|
29
|
-
assert_equal "live", subscription.mode
|
30
|
-
assert_equal Time.parse("2016-06-01T12:23:34.0Z"), subscription.created_datetime
|
31
|
-
assert_equal "active", subscription.status
|
32
|
-
assert_equal BigDecimal.new(25, 2), subscription.amount
|
33
|
-
assert_equal 4, subscription.times
|
34
|
-
assert_equal "3 months", subscription.interval
|
35
|
-
assert_equal "Quarterly payment", subscription.description
|
36
|
-
assert_equal "creditcard", subscription.method
|
37
|
-
assert_equal Time.parse("2016-06-01T12:23:34.0Z"), subscription.cancelled_datetime
|
38
|
-
assert_equal "https://example.org/payments/webhook", subscription.webhook_url
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_status_active
|
42
|
-
assert Subscription.new(status: Subscription::STATUS_ACTIVE).active?
|
43
|
-
assert !Subscription.new(status: 'not-active').active?
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_status_pending
|
47
|
-
assert Subscription.new(status: Subscription::STATUS_PENDING).pending?
|
48
|
-
assert !Subscription.new(status: 'not-pending').pending?
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_status_suspended
|
52
|
-
assert Subscription.new(status: Subscription::STATUS_SUSPENDED).suspended?
|
53
|
-
assert !Subscription.new(status: 'not-suspended').suspended?
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_status_cancelled
|
57
|
-
assert Subscription.new(status: Subscription::STATUS_CANCELLED).cancelled?
|
58
|
-
assert !Subscription.new(status: 'not-cancelled').cancelled?
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_status_completed
|
62
|
-
assert Subscription.new(status: Subscription::STATUS_COMPLETED).completed?
|
63
|
-
assert !Subscription.new(status: 'not-completed').completed?
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|