mollie-api-ruby 4.14.0 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/examples/balances/get-primary.rb +1 -0
- data/examples/balances/get-report.rb +2 -0
- data/examples/balances/get.rb +1 -0
- data/examples/balances/list-transactions.rb +2 -0
- data/examples/balances/list.rb +1 -0
- data/lib/mollie/balance/report.rb +25 -0
- data/lib/mollie/balance/transaction.rb +41 -0
- data/lib/mollie/balance.rb +53 -0
- data/lib/mollie/version.rb +1 -1
- data/lib/mollie.rb +3 -0
- data/test/fixtures/balances/get.json +38 -0
- data/test/fixtures/balances/list.json +34 -0
- data/test/fixtures/balances/list_transactions.json +65 -0
- data/test/fixtures/balances/report.json +149 -0
- data/test/mollie/balance/transaction_test.rb +36 -0
- data/test/mollie/balance_test.rb +108 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06f14768975850db4a88530cf6cfbe4d4b80f274c2616736ba6af908e83a044c
|
4
|
+
data.tar.gz: d7eae71e95f7d0b06646fcc39b069658dc0d808874654fdfd9b2353f1af70d3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d450cb135d44a6b17b51cdb5921aa03fa9a3796c540b427fb8796251177c776f5d3541f4bccf10739f1bf17fdc65611a318ae6ed17938718d915d487000ac435
|
7
|
+
data.tar.gz: 9a8fad769b51f90ecf0a4d464661b5e22cda7304b32388091019bb754d66eed1abe731f598547778e8357e302500f32a33a2c740a60b725625e03ed261ec29a2
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
primary_balance = Mollie::Balance.primary
|
@@ -0,0 +1 @@
|
|
1
|
+
balance = Mollie::Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH")
|
@@ -0,0 +1 @@
|
|
1
|
+
balances = Mollie::Balance.all
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Balance
|
3
|
+
class Report < Base
|
4
|
+
attr_accessor :balance_id,
|
5
|
+
:time_zone,
|
6
|
+
:grouping,
|
7
|
+
:totals,
|
8
|
+
:_links
|
9
|
+
|
10
|
+
attr_reader :from,
|
11
|
+
:until
|
12
|
+
|
13
|
+
alias links _links
|
14
|
+
|
15
|
+
def from=(from)
|
16
|
+
@from = Date.parse(from)
|
17
|
+
end
|
18
|
+
|
19
|
+
def until=(until_date)
|
20
|
+
# `until` is a reserved keyword
|
21
|
+
@until = Date.parse(until_date)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Balance
|
3
|
+
class Transaction < Base
|
4
|
+
attr_accessor :id,
|
5
|
+
:type,
|
6
|
+
:_links
|
7
|
+
|
8
|
+
attr_reader :result_amount,
|
9
|
+
:initial_amount,
|
10
|
+
:deductions,
|
11
|
+
:context,
|
12
|
+
:created_at
|
13
|
+
|
14
|
+
alias links _links
|
15
|
+
|
16
|
+
def self.embedded_resource_name
|
17
|
+
"balance_transactions"
|
18
|
+
end
|
19
|
+
|
20
|
+
def result_amount=(amount)
|
21
|
+
@result_amount = Mollie::Amount.new(amount)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initial_amount=(amount)
|
25
|
+
@initial_amount = Mollie::Amount.new(amount)
|
26
|
+
end
|
27
|
+
|
28
|
+
def deductions=(amount)
|
29
|
+
@deductions = Mollie::Amount.new(amount)
|
30
|
+
end
|
31
|
+
|
32
|
+
def context=(context)
|
33
|
+
@context = OpenStruct.new(context) if context.is_a?(Hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
def created_at=(created_at)
|
37
|
+
@created_at = Time.parse(created_at.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Balance < Base
|
3
|
+
attr_accessor :id,
|
4
|
+
:mode,
|
5
|
+
:currency,
|
6
|
+
:description,
|
7
|
+
:status,
|
8
|
+
:transfer_frequency,
|
9
|
+
:transfer_reference,
|
10
|
+
:_links
|
11
|
+
|
12
|
+
attr_reader :transfer_threshold,
|
13
|
+
:transfer_destination,
|
14
|
+
:available_amount,
|
15
|
+
:pending_amount,
|
16
|
+
:created_at
|
17
|
+
|
18
|
+
alias links _links
|
19
|
+
|
20
|
+
def self.primary(options = {})
|
21
|
+
get('primary', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def transfer_threshold=(amount)
|
25
|
+
@transfer_threshold = Mollie::Amount.new(amount)
|
26
|
+
end
|
27
|
+
|
28
|
+
def transfer_destination=(transfer_destination)
|
29
|
+
@transfer_destination = OpenStruct.new(transfer_destination) if transfer_destination.is_a?(Hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
def available_amount=(amount)
|
33
|
+
@available_amount = Mollie::Amount.new(amount)
|
34
|
+
end
|
35
|
+
|
36
|
+
def pending_amount=(amount)
|
37
|
+
@pending_amount = Mollie::Amount.new(amount)
|
38
|
+
end
|
39
|
+
|
40
|
+
def created_at=(created_at)
|
41
|
+
@created_at = Time.parse(created_at.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def report(options = {})
|
45
|
+
response = Client.instance.perform_http_call("GET", "balances/#{id}", "report", {}, options)
|
46
|
+
Balance::Report.new(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
def transactions(options = {})
|
50
|
+
Balance::Transaction.all(options.merge(balance_id: id))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/mollie/version.rb
CHANGED
data/lib/mollie.rb
CHANGED
@@ -13,6 +13,7 @@ require 'mollie/version'
|
|
13
13
|
|
14
14
|
require 'mollie/base'
|
15
15
|
require 'mollie/amount'
|
16
|
+
require 'mollie/balance'
|
16
17
|
require 'mollie/chargeback'
|
17
18
|
require 'mollie/client'
|
18
19
|
require 'mollie/customer'
|
@@ -31,6 +32,8 @@ require 'mollie/settlement'
|
|
31
32
|
require 'mollie/subscription'
|
32
33
|
require 'mollie/terminal'
|
33
34
|
|
35
|
+
require 'mollie/balance/report'
|
36
|
+
require 'mollie/balance/transaction'
|
34
37
|
require 'mollie/customer/mandate'
|
35
38
|
require 'mollie/customer/payment'
|
36
39
|
require 'mollie/customer/subscription'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"resource": "balance",
|
3
|
+
"id": "bal_gVMhHKqSSRYJyPsuoPNFH",
|
4
|
+
"mode": "live",
|
5
|
+
"currency": "EUR",
|
6
|
+
"description": "Primary balance",
|
7
|
+
"availableAmount": {
|
8
|
+
"currency": "EUR",
|
9
|
+
"value": "905.25"
|
10
|
+
},
|
11
|
+
"pendingAmount": {
|
12
|
+
"currency": "EUR",
|
13
|
+
"value": "0.00"
|
14
|
+
},
|
15
|
+
"transferFrequency": "twice-a-month",
|
16
|
+
"transferThreshold": {
|
17
|
+
"currency": "EUR",
|
18
|
+
"value": "5.00"
|
19
|
+
},
|
20
|
+
"transferReference": "Mollie settlement",
|
21
|
+
"transferDestination": {
|
22
|
+
"type": "bank-account",
|
23
|
+
"beneficiaryName": "John Doe",
|
24
|
+
"bankAccount": "NL55INGB0000000000"
|
25
|
+
},
|
26
|
+
"status": "active",
|
27
|
+
"createdAt": "2019-01-10T12:06:28+00:00",
|
28
|
+
"_links": {
|
29
|
+
"self": {
|
30
|
+
"href": "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH",
|
31
|
+
"type": "application/hal+json"
|
32
|
+
},
|
33
|
+
"documentation": {
|
34
|
+
"href": "https://docs.mollie.com/reference/get-balance",
|
35
|
+
"type": "text/html"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"count": 1,
|
3
|
+
"_embedded": {
|
4
|
+
"balances": [
|
5
|
+
{
|
6
|
+
"resource": "balance",
|
7
|
+
"id": "bal_one"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"resource": "balance",
|
11
|
+
"id": "bal_two"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"resource": "balance",
|
15
|
+
"id": "bal_three"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
},
|
19
|
+
"_links": {
|
20
|
+
"documentation": {
|
21
|
+
"href": "https://docs.mollie.com/reference/v2/balances-api/list-balances",
|
22
|
+
"type": "text/html"
|
23
|
+
},
|
24
|
+
"self": {
|
25
|
+
"href": "https://api.mollie.com/v2/balances?limit=5",
|
26
|
+
"type": "application/hal+json"
|
27
|
+
},
|
28
|
+
"previous": null,
|
29
|
+
"next": {
|
30
|
+
"href": "https://api.mollie.com/v2/balances?from=bal_gVMhHKqSSRYJyPsuoPABC&limit=5",
|
31
|
+
"type": "application/hal+json"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
{
|
2
|
+
"count": 2,
|
3
|
+
"_embedded": {
|
4
|
+
"balance_transactions": [
|
5
|
+
{
|
6
|
+
"resource": "balance_transaction",
|
7
|
+
"id": "baltr_QM24QwzUWR4ev4Xfgyt29A",
|
8
|
+
"type": "refund",
|
9
|
+
"resultAmount": {
|
10
|
+
"currency": "EUR",
|
11
|
+
"value": "-10.25"
|
12
|
+
},
|
13
|
+
"initialAmount": {
|
14
|
+
"currency": "EUR",
|
15
|
+
"value": "-10.00"
|
16
|
+
},
|
17
|
+
"deductions": {
|
18
|
+
"currency": "EUR",
|
19
|
+
"value": "-0.25"
|
20
|
+
},
|
21
|
+
"context": {
|
22
|
+
"paymentId": "tr_7UhSN1zuXS",
|
23
|
+
"refundId": "re_4qqhO89gsT"
|
24
|
+
},
|
25
|
+
"createdAt": "2021-01-10T12:06:28+00:00"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"resource": "balance_transaction",
|
29
|
+
"id": "baltr_WhmDwNYR87FPDbiwBhUXCh",
|
30
|
+
"type": "payment",
|
31
|
+
"resultAmount": {
|
32
|
+
"currency": "EUR",
|
33
|
+
"value": "9.71"
|
34
|
+
},
|
35
|
+
"initialAmount": {
|
36
|
+
"currency": "EUR",
|
37
|
+
"value": "10.00"
|
38
|
+
},
|
39
|
+
"deductions": {
|
40
|
+
"currency": "EUR",
|
41
|
+
"value": "-0.29"
|
42
|
+
},
|
43
|
+
"context": {
|
44
|
+
"paymentId": "tr_7UhSN1zuXS"
|
45
|
+
},
|
46
|
+
"createdAt": "2021-01-10T12:06:28+00:00"
|
47
|
+
}
|
48
|
+
]
|
49
|
+
},
|
50
|
+
"_links": {
|
51
|
+
"self": {
|
52
|
+
"href": "...",
|
53
|
+
"type": "application/hal+json"
|
54
|
+
},
|
55
|
+
"previous": null,
|
56
|
+
"next": {
|
57
|
+
"href": "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/transactions?from=baltr_rXeW2yPqqDUyfAqq8fS5Bg&limit=5",
|
58
|
+
"type": "application/hal+json"
|
59
|
+
},
|
60
|
+
"documentation": {
|
61
|
+
"href": "...",
|
62
|
+
"type": "text/html"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
@@ -0,0 +1,149 @@
|
|
1
|
+
{
|
2
|
+
"resource": "balance-report",
|
3
|
+
"balanceId": "bal_gVMhHKqSSRYJyPsuoPNFH",
|
4
|
+
"timeZone": "Europe/Amsterdam",
|
5
|
+
"from": "2024-01-01",
|
6
|
+
"until": "2024-01-31",
|
7
|
+
"grouping": "transaction-categories",
|
8
|
+
"totals": {
|
9
|
+
"open": {
|
10
|
+
"available": {
|
11
|
+
"amount": {
|
12
|
+
"currency": "EUR",
|
13
|
+
"value": "0.00"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"pending": {
|
17
|
+
"amount": {
|
18
|
+
"currency": "EUR",
|
19
|
+
"value": "0.00"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"payments": {
|
24
|
+
"immediatelyAvailable": {
|
25
|
+
"amount": {
|
26
|
+
"currency": "EUR",
|
27
|
+
"value": "0.00"
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"pending": {
|
31
|
+
"amount": {
|
32
|
+
"currency": "EUR",
|
33
|
+
"value": "4.98"
|
34
|
+
},
|
35
|
+
"subtotals": [
|
36
|
+
{
|
37
|
+
"transactionType": "payment",
|
38
|
+
"count": 1,
|
39
|
+
"amount": {
|
40
|
+
"currency": "EUR",
|
41
|
+
"value": "4.98"
|
42
|
+
},
|
43
|
+
"subtotals": [
|
44
|
+
{
|
45
|
+
"method": "ideal",
|
46
|
+
"count": 1,
|
47
|
+
"amount": {
|
48
|
+
"currency": "EUR",
|
49
|
+
"value": "4.98"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
]
|
55
|
+
},
|
56
|
+
"movedToAvailable": {
|
57
|
+
"amount": {
|
58
|
+
"currency": "EUR",
|
59
|
+
"value": "0.00"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
},
|
63
|
+
"refunds": {},
|
64
|
+
"capital": {},
|
65
|
+
"chargebacks": {},
|
66
|
+
"transfers": {},
|
67
|
+
"fee-prepayments": {
|
68
|
+
"immediatelyAvailable": {
|
69
|
+
"amount": {
|
70
|
+
"currency": "EUR",
|
71
|
+
"value": "0.00"
|
72
|
+
}
|
73
|
+
},
|
74
|
+
"movedToAvailable": {
|
75
|
+
"amount": {
|
76
|
+
"currency": "EUR",
|
77
|
+
"value": "-0.36"
|
78
|
+
},
|
79
|
+
"subtotals": [
|
80
|
+
{
|
81
|
+
"prepaymentPartType": "fee",
|
82
|
+
"count": 1,
|
83
|
+
"amount": {
|
84
|
+
"currency": "EUR",
|
85
|
+
"value": "-0.29"
|
86
|
+
},
|
87
|
+
"subtotals": [
|
88
|
+
{
|
89
|
+
"feeType": "payment-fee",
|
90
|
+
"method": "ideal",
|
91
|
+
"count": 1,
|
92
|
+
"amount": {
|
93
|
+
"currency": "EUR",
|
94
|
+
"value": "-0.29"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
]
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"prepaymentPartType": "fee-vat",
|
101
|
+
"amount": {
|
102
|
+
"currency": "EUR",
|
103
|
+
"value": "-0.0609"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"prepaymentPartType": "fee-rounding-compensation",
|
108
|
+
"amount": {
|
109
|
+
"currency": "EUR",
|
110
|
+
"value": "-0.0091"
|
111
|
+
}
|
112
|
+
}
|
113
|
+
]
|
114
|
+
},
|
115
|
+
"pending": {
|
116
|
+
"amount": {
|
117
|
+
"currency": "EUR",
|
118
|
+
"value": "-0.36"
|
119
|
+
},
|
120
|
+
"subtotals": []
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"corrections": {},
|
124
|
+
"close": {
|
125
|
+
"available": {
|
126
|
+
"amount": {
|
127
|
+
"currency": "EUR",
|
128
|
+
"value": "0.00"
|
129
|
+
}
|
130
|
+
},
|
131
|
+
"pending": {
|
132
|
+
"amount": {
|
133
|
+
"currency": "EUR",
|
134
|
+
"value": "4.32"
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
},
|
139
|
+
"_links": {
|
140
|
+
"self": {
|
141
|
+
"href": "...",
|
142
|
+
"type": "application/hal+json"
|
143
|
+
},
|
144
|
+
"documentation": {
|
145
|
+
"href": "...",
|
146
|
+
"type": "text/html"
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class Balance
|
5
|
+
class TransactionTest < Test::Unit::TestCase
|
6
|
+
def test_setting_attributes
|
7
|
+
attributes = {
|
8
|
+
id: "baltr_QM24QwzUWR4ev4Xfgyt29A",
|
9
|
+
type: "refund",
|
10
|
+
result_amount: { "value" => "-10.25", "currency" => "EUR" },
|
11
|
+
initial_amount: { "value" => "-10.00", "currency" => "EUR" },
|
12
|
+
deductions: { "value" => "0.25", "currency" => "EUR" },
|
13
|
+
context: {
|
14
|
+
"paymentId" => "tr_7UhSN1zuXS",
|
15
|
+
"refundId" => "re_4qqhO89gsT"
|
16
|
+
},
|
17
|
+
created_at: "2021-01-10T12:06:28+00:00"
|
18
|
+
}
|
19
|
+
|
20
|
+
balance = Balance::Transaction.new(attributes)
|
21
|
+
|
22
|
+
assert_equal "baltr_QM24QwzUWR4ev4Xfgyt29A", balance.id
|
23
|
+
assert_equal "refund", balance.type
|
24
|
+
assert_equal BigDecimal("-10.25"), balance.result_amount.value
|
25
|
+
assert_equal "EUR", balance.result_amount.currency
|
26
|
+
assert_equal BigDecimal("-10.00"), balance.initial_amount.value
|
27
|
+
assert_equal "EUR", balance.initial_amount.currency
|
28
|
+
assert_equal BigDecimal("0.25"), balance.deductions.value
|
29
|
+
assert_equal "EUR", balance.deductions.currency
|
30
|
+
assert_equal "tr_7UhSN1zuXS", balance.context.paymentId
|
31
|
+
assert_equal "re_4qqhO89gsT", balance.context.refundId
|
32
|
+
assert_equal Time.parse("2021-01-10T12:06:28+00:00"), balance.created_at
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class BalanceTest < Test::Unit::TestCase
|
5
|
+
GET_BALANCE = read_fixture('balances/get.json')
|
6
|
+
GET_BALANCE_REPORT = read_fixture('balances/report.json')
|
7
|
+
LIST_BALANCES = read_fixture('balances/list.json')
|
8
|
+
LIST_BALANCE_TRANSACTIONS = read_fixture('balances/list_transactions.json')
|
9
|
+
|
10
|
+
def test_setting_attributes
|
11
|
+
attributes = {
|
12
|
+
id: "bal_gVMhHKqSSRYJyPsuoPNFH",
|
13
|
+
mode: "live",
|
14
|
+
currency: "EUR",
|
15
|
+
description: "Primary balance",
|
16
|
+
available_amount: { "value" => "0.00", "currency" => "EUR" },
|
17
|
+
pending_amount: { "value" => "0.00", "currency" => "EUR" },
|
18
|
+
transfer_frequency: "twice-a-month",
|
19
|
+
transfer_threshold: { "value" => "5.00", "currency" => "EUR" },
|
20
|
+
transfer_reference: "Mollie settlement",
|
21
|
+
transfer_destination: {
|
22
|
+
type: "bank-account",
|
23
|
+
beneficiary_name: "John Doe",
|
24
|
+
bank_account: "NL55INGB0000000000"
|
25
|
+
},
|
26
|
+
status: "active",
|
27
|
+
created_at: "2018-03-20T09:13:37+00:00",
|
28
|
+
}
|
29
|
+
|
30
|
+
balance = Mollie::Balance.new(attributes)
|
31
|
+
|
32
|
+
assert_equal "bal_gVMhHKqSSRYJyPsuoPNFH", balance.id
|
33
|
+
assert_equal "live", balance.mode
|
34
|
+
assert_equal "EUR", balance.currency
|
35
|
+
assert_equal "Primary balance", balance.description
|
36
|
+
assert_equal BigDecimal("0.00"), balance.available_amount.value
|
37
|
+
assert_equal "EUR", balance.available_amount.currency
|
38
|
+
assert_equal BigDecimal("0.00"), balance.pending_amount.value
|
39
|
+
assert_equal "EUR", balance.pending_amount.currency
|
40
|
+
assert_equal "twice-a-month", balance.transfer_frequency
|
41
|
+
assert_equal BigDecimal("5.00"), balance.transfer_threshold.value
|
42
|
+
assert_equal "EUR", balance.transfer_threshold.currency
|
43
|
+
assert_equal "Mollie settlement", balance.transfer_reference
|
44
|
+
assert_equal "bank-account", balance.transfer_destination.type
|
45
|
+
assert_equal "John Doe", balance.transfer_destination.beneficiary_name
|
46
|
+
assert_equal "NL55INGB0000000000", balance.transfer_destination.bank_account
|
47
|
+
assert_equal "active", balance.status
|
48
|
+
assert_equal Time.parse('2018-03-20T09:13:37+00:00'), balance.created_at
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_get_balance
|
52
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH")
|
53
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
54
|
+
|
55
|
+
balance = Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH")
|
56
|
+
assert_equal "bal_gVMhHKqSSRYJyPsuoPNFH", balance.id
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_list_balances
|
60
|
+
stub_request(:get, 'https://api.mollie.com/v2/balances')
|
61
|
+
.to_return(status: 200, body: LIST_BALANCES, headers: {})
|
62
|
+
|
63
|
+
balances = Balance.all
|
64
|
+
assert_equal 3, balances.size
|
65
|
+
assert_equal 'bal_one', balances[0].id
|
66
|
+
assert_equal 'bal_two', balances[1].id
|
67
|
+
assert_equal 'bal_three', balances[2].id
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_primary
|
71
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/primary")
|
72
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
73
|
+
|
74
|
+
balance = Balance.primary
|
75
|
+
assert_equal "bal_gVMhHKqSSRYJyPsuoPNFH", balance.id
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_report
|
79
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH")
|
80
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
81
|
+
|
82
|
+
stub_request(:get, 'https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/report')
|
83
|
+
.to_return(status: 200, body: GET_BALANCE_REPORT, headers: {})
|
84
|
+
|
85
|
+
report = Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH").report
|
86
|
+
|
87
|
+
assert_equal Date.parse("2024-01-01"), report.from
|
88
|
+
assert_equal Date.parse("2024-01-31"), report.until
|
89
|
+
assert_equal "transaction-categories", report.grouping
|
90
|
+
assert_equal "4.98", report.totals.dig("payments", "pending", "amount", "value")
|
91
|
+
assert_equal "-0.36", report.totals.dig("fee_prepayments", "moved_to_available", "amount", "value")
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_list_transactions
|
95
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH")
|
96
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
97
|
+
|
98
|
+
stub_request(:get, 'https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/transactions')
|
99
|
+
.to_return(status: 200, body: LIST_BALANCE_TRANSACTIONS, headers: {})
|
100
|
+
|
101
|
+
transactions = Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH").transactions
|
102
|
+
assert_equal 2, transactions.size
|
103
|
+
|
104
|
+
assert_equal "baltr_QM24QwzUWR4ev4Xfgyt29A", transactions[0].id
|
105
|
+
assert_equal "baltr_WhmDwNYR87FPDbiwBhUXCh", transactions[1].id
|
106
|
+
end
|
107
|
+
end
|
108
|
+
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.
|
4
|
+
version: 4.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mollie B.V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ostruct
|
@@ -129,6 +129,11 @@ files:
|
|
129
129
|
- bin/setup
|
130
130
|
- docs/migration_v2_2_x.md
|
131
131
|
- docs/migration_v3_x.md
|
132
|
+
- examples/balances/get-primary.rb
|
133
|
+
- examples/balances/get-report.rb
|
134
|
+
- examples/balances/get.rb
|
135
|
+
- examples/balances/list-transactions.rb
|
136
|
+
- examples/balances/list.rb
|
132
137
|
- examples/captures/get-payment.rb
|
133
138
|
- examples/captures/get-settlement.rb
|
134
139
|
- examples/captures/get-shipment.rb
|
@@ -226,6 +231,9 @@ files:
|
|
226
231
|
- lib/mollie-api-ruby.rb
|
227
232
|
- lib/mollie.rb
|
228
233
|
- lib/mollie/amount.rb
|
234
|
+
- lib/mollie/balance.rb
|
235
|
+
- lib/mollie/balance/report.rb
|
236
|
+
- lib/mollie/balance/transaction.rb
|
229
237
|
- lib/mollie/base.rb
|
230
238
|
- lib/mollie/chargeback.rb
|
231
239
|
- lib/mollie/client.rb
|
@@ -263,6 +271,10 @@ files:
|
|
263
271
|
- lib/mollie/util.rb
|
264
272
|
- lib/mollie/version.rb
|
265
273
|
- mollie-api-ruby.gemspec
|
274
|
+
- test/fixtures/balances/get.json
|
275
|
+
- test/fixtures/balances/list.json
|
276
|
+
- test/fixtures/balances/list_transactions.json
|
277
|
+
- test/fixtures/balances/report.json
|
266
278
|
- test/fixtures/captures/get.json
|
267
279
|
- test/fixtures/captures/list.json
|
268
280
|
- test/fixtures/customer/get.json
|
@@ -303,6 +315,8 @@ files:
|
|
303
315
|
- test/fixtures/terminals/list.json
|
304
316
|
- test/helper.rb
|
305
317
|
- test/mollie/amount_test.rb
|
318
|
+
- test/mollie/balance/transaction_test.rb
|
319
|
+
- test/mollie/balance_test.rb
|
306
320
|
- test/mollie/base_test.rb
|
307
321
|
- test/mollie/chargeback_test.rb
|
308
322
|
- test/mollie/client_test.rb
|
@@ -356,11 +370,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
370
|
- !ruby/object:Gem::Version
|
357
371
|
version: '0'
|
358
372
|
requirements: []
|
359
|
-
rubygems_version: 3.5.
|
373
|
+
rubygems_version: 3.5.22
|
360
374
|
signing_key:
|
361
375
|
specification_version: 4
|
362
376
|
summary: Official Mollie API Client for Ruby
|
363
377
|
test_files:
|
378
|
+
- test/fixtures/balances/get.json
|
379
|
+
- test/fixtures/balances/list.json
|
380
|
+
- test/fixtures/balances/list_transactions.json
|
381
|
+
- test/fixtures/balances/report.json
|
364
382
|
- test/fixtures/captures/get.json
|
365
383
|
- test/fixtures/captures/list.json
|
366
384
|
- test/fixtures/customer/get.json
|
@@ -401,6 +419,8 @@ test_files:
|
|
401
419
|
- test/fixtures/terminals/list.json
|
402
420
|
- test/helper.rb
|
403
421
|
- test/mollie/amount_test.rb
|
422
|
+
- test/mollie/balance/transaction_test.rb
|
423
|
+
- test/mollie/balance_test.rb
|
404
424
|
- test/mollie/base_test.rb
|
405
425
|
- test/mollie/chargeback_test.rb
|
406
426
|
- test/mollie/client_test.rb
|