Skip to content

Commit e602b08

Browse files
author
Tom Hendrikx
committed
Correct SettlementCaptures
1 parent f8569a3 commit e602b08

File tree

9 files changed

+136
-19
lines changed

9 files changed

+136
-19
lines changed

mollie/api/objects/settlement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def captures(self):
9393
"""Return the captures related to this settlement."""
9494
from ..resources import SettlementCaptures
9595

96-
return SettlementCaptures(self.client, self)
96+
return SettlementCaptures(self.client, resource_path=f"settlements/{self.id}/captures")
9797

9898
def get_invoice(self):
9999
"""Return the invoice related to this settlement."""

mollie/api/resources/captures.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
from typing import TYPE_CHECKING, Any
1+
from typing import Any
22

33
from ..objects.capture import Capture
44
from .base import ResourceBase, ResourceGetMixin, ResourceListMixin
55

6-
if TYPE_CHECKING:
7-
from ..client import Client
8-
from ..objects.settlement import Settlement
9-
106
__all__ = [
117
"PaymentCaptures",
128
"SettlementCaptures",
@@ -31,11 +27,4 @@ def get(self, resource_id: str, **params: Any) -> Capture:
3127
class SettlementCaptures(CapturesBase, ResourceListMixin):
3228
"""Resource handler for the `/settlements/:settlement_id:/captures` endpoint."""
3329

34-
_settlement: "Settlement"
35-
36-
def __init__(self, client: "Client", settlement: "Settlement") -> None:
37-
self._settlement = settlement
38-
super().__init__(client)
39-
40-
def get_resource_path(self) -> str:
41-
return f"settlements/{self._settlement.id}/captures"
30+
pass
File renamed without changes.
File renamed without changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"_embedded": {
3+
"captures": [
4+
{
5+
"resource": "capture",
6+
"id": "cpt_4qqhO89gsT",
7+
"mode": "live",
8+
"amount": {
9+
"value": "1027.99",
10+
"currency": "EUR"
11+
},
12+
"settlementAmount": {
13+
"value": "399.00",
14+
"currency": "EUR"
15+
},
16+
"paymentId": "tr_7UhSN1zuXS",
17+
"shipmentId": "shp_3wmsgCJN4U",
18+
"settlementId": "stl_jDk30akdN",
19+
"createdAt": "2018-08-02T09:29:56+00:00",
20+
"_links": {
21+
"self": {
22+
"href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS/captures/cpt_4qqhO89gsT",
23+
"type": "application/hal+json"
24+
},
25+
"payment": {
26+
"href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS",
27+
"type": "application/hal+json"
28+
},
29+
"shipment": {
30+
"href": "https://api.mollie.com/v2/orders/ord_8wmqcHMN4U/shipments/shp_3wmsgCJN4U",
31+
"type": "application/hal+json"
32+
},
33+
"settlement": {
34+
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN",
35+
"type": "application/hal+json"
36+
},
37+
"documentation": {
38+
"href": "https://docs.mollie.com/reference/v2/captures-api/get-capture",
39+
"type": "text/html"
40+
}
41+
}
42+
}
43+
]
44+
},
45+
"count": 1,
46+
"_links": {
47+
"documentation": {
48+
"href": "https://docs.mollie.com/reference/v2/captures-api/list-captures",
49+
"type": "text/html"
50+
},
51+
"self": {
52+
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN/captures?limit=1",
53+
"type": "application/hal+json"
54+
},
55+
"previous": null,
56+
"next": {
57+
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN/captures?limit=1&from=cpt_4qqhO89gsU",
58+
"type": "application/hal+json"
59+
}
60+
}
61+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"_embedded": {
3+
"captures": [
4+
{
5+
"resource": "capture",
6+
"id": "cpt_4qqhO89gsU",
7+
"mode": "live",
8+
"amount": {
9+
"value": "1027.99",
10+
"currency": "EUR"
11+
},
12+
"settlementAmount": {
13+
"value": "399.00",
14+
"currency": "EUR"
15+
},
16+
"paymentId": "tr_7UhSN1zuXS",
17+
"shipmentId": "shp_3wmsgCJN4U",
18+
"settlementId": "stl_jDk30akdN",
19+
"createdAt": "2018-08-02T09:29:56+00:00",
20+
"_links": {
21+
"self": {
22+
"href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS/captures/cpt_4qqhO89gsT",
23+
"type": "application/hal+json"
24+
},
25+
"payment": {
26+
"href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS",
27+
"type": "application/hal+json"
28+
},
29+
"shipment": {
30+
"href": "https://api.mollie.com/v2/orders/ord_8wmqcHMN4U/shipments/shp_3wmsgCJN4U",
31+
"type": "application/hal+json"
32+
},
33+
"settlement": {
34+
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN",
35+
"type": "application/hal+json"
36+
},
37+
"documentation": {
38+
"href": "https://docs.mollie.com/reference/v2/captures-api/get-capture",
39+
"type": "text/html"
40+
}
41+
}
42+
}
43+
]
44+
},
45+
"count": 1,
46+
"_links": {
47+
"documentation": {
48+
"href": "https://docs.mollie.com/reference/v2/captures-api/list-captures",
49+
"type": "text/html"
50+
},
51+
"self": {
52+
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN/captures?limit=1&from=cpt_4qqhO89gsU",
53+
"type": "application/hal+json"
54+
},
55+
"previous": null,
56+
"next": null
57+
}
58+
}

tests/test_payment_captures.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
def test_list_payment_captures(client, response):
1818
"""Get capture relevant to payment by payment id."""
1919
response.get(f"https://api.mollie.com/v2/payments/{PAYMENT_ID}", "payment_single")
20-
response.get(f"https://api.mollie.com/v2/payments/{PAYMENT_ID}/captures", "captures_list")
20+
response.get(f"https://api.mollie.com/v2/payments/{PAYMENT_ID}/captures", "payment_captures_list")
2121
response.get(
22-
f"https://api.mollie.com/v2/payments/{PAYMENT_ID}/captures?limit=1&from=cpt_4qqhO89gsU", "captures_list_more"
22+
f"https://api.mollie.com/v2/payments/{PAYMENT_ID}/captures?limit=1&from=cpt_4qqhO89gsU",
23+
"payment_captures_list_more",
2324
)
2425

2526
payment = client.payments.get(PAYMENT_ID)

tests/test_payments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_payment_get_related_chargebacks(client, response):
161161
def test_payment_get_related_captures(client, response):
162162
"""Get captures related to payment."""
163163
response.get(f"https://api.mollie.com/v2/payments/{PAYMENT_ID}", "payment_single")
164-
response.get(f"https://api.mollie.com/v2/payments/{PAYMENT_ID}/captures", "captures_list")
164+
response.get(f"https://api.mollie.com/v2/payments/{PAYMENT_ID}/captures", "payment_captures_list")
165165

166166
payment = client.payments.get(PAYMENT_ID)
167167
captures = payment.captures.list()

tests/test_settlement_captures.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@
99
def test_list_settlement_captures(oauth_client, response):
1010
"""Get a list of captures relevant to settlement object."""
1111
response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}", "settlement_single")
12-
response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures", "captures_list")
12+
response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures", "settlement_captures_list")
13+
response.get(
14+
f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures?limit=1&from=cpt_4qqhO89gsU",
15+
"settlement_captures_list_more",
16+
)
1317

1418
settlement = oauth_client.settlements.get(SETTLEMENT_ID)
1519
captures = settlement.captures.list()
16-
assert_list_object(captures, Capture)
20+
assert_list_object(captures, Capture, 1)
21+
22+
assert captures.has_next() is True
23+
more_captures = captures.get_next()
24+
assert_list_object(more_captures, Capture)

0 commit comments

Comments
 (0)