Skip to content

Commit d8ac6c4

Browse files
mitchenallmvantellingen
authored andcommitted
remove ml client and updated API and tests
1 parent 3bd9fd1 commit d8ac6c4

485 files changed

Lines changed: 32083 additions & 12936 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# This file is automatically generated by the rmf-codegen project.
2+
#
3+
# The Python code generator is maintained by Lab Digital. If you want to
4+
# contribute to this project then please do not edit this file directly
5+
# but send a pull request to the Lab Digital fork of rmf-codegen at
6+
# https://github.com/labd/rmf-codegen
7+
8+
import datetime
9+
import enum
10+
import typing
11+
12+
from ._abstract import _BaseType
13+
14+
__all__ = ["Amount", "PaymentAction", "PaymentOperation", "Region"]
15+
16+
17+
class Region(enum.Enum):
18+
"""The Region in which the Checkout application is [hosted](/../checkout/installing-checkout#regions-and-hosts)."""
19+
20+
EUROPE_WEST1.GCP = "europe-west1.gcp"
21+
US_CENTRAL1.GCP = "us-central1.gcp"
22+
AUSTRALIA_SOUTHEAST1.GCP = "australia-southeast1.gcp"
23+
24+
25+
class Amount(_BaseType):
26+
"""The amount related to a [payment action](ctp:checkout:type:PaymentAction)."""
27+
28+
#: Amount in the smallest indivisible unit of a currency, such as:
29+
#:
30+
#: * Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as `500`).
31+
#: * The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as `5`).
32+
cent_amount: int
33+
#: Currency code compliant to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).
34+
currency_code: str
35+
36+
def __init__(self, *, cent_amount: int, currency_code: str):
37+
self.cent_amount = cent_amount
38+
self.currency_code = currency_code
39+
40+
super().__init__()
41+
42+
@classmethod
43+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "Amount":
44+
from ._schemas.common import AmountSchema
45+
46+
return AmountSchema().load(data)
47+
48+
def serialize(self) -> typing.Dict[str, typing.Any]:
49+
from ._schemas.common import AmountSchema
50+
51+
return AmountSchema().dump(self)
52+
53+
54+
class PaymentOperation(enum.Enum):
55+
"""The possible values for a [payment action](ctp:checkout:type:PaymentAction)."""
56+
57+
CAPTURE_PAYMENT = "capturePayment"
58+
REFUND_PAYMENT = "refundPayment"
59+
CANCEL_PAYMENT = "cancelPayment"
60+
61+
62+
class PaymentAction(_BaseType):
63+
"""Depending on the action specified, Checkout requests the [payment service provider](/../checkout/configuring-checkout#supported-psps) (PSP) to capture, refund, or cancel the authorization for the given Payment."""
64+
65+
#: Action to execute for the given Payment.
66+
action: "PaymentOperation"
67+
#: Amount to be captured or refunded.
68+
amount: typing.Optional["Amount"]
69+
70+
def __init__(
71+
self, *, action: "PaymentOperation", amount: typing.Optional["Amount"] = None
72+
):
73+
self.action = action
74+
self.amount = amount
75+
76+
super().__init__()
77+
78+
@classmethod
79+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "PaymentAction":
80+
from ._schemas.common import PaymentActionSchema
81+
82+
return PaymentActionSchema().load(data)
83+
84+
def serialize(self) -> typing.Dict[str, typing.Any]:
85+
from ._schemas.common import PaymentActionSchema
86+
87+
return PaymentActionSchema().dump(self)
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# This file is automatically generated by the rmf-codegen project.
2+
#
3+
# The Python code generator is maintained by Lab Digital. If you want to
4+
# contribute to this project then please do not edit this file directly
5+
# but send a pull request to the Lab Digital fork of rmf-codegen at
6+
# https://github.com/labd/rmf-codegen
7+
8+
import datetime
9+
import enum
10+
import typing
11+
12+
from ._abstract import _BaseType
13+
14+
__all__ = [
15+
"ErrorObject",
16+
"GeneralError",
17+
"MultipleActionsNotAllowedError",
18+
"RequiredFieldError",
19+
"ResourceNotFoundError",
20+
]
21+
22+
23+
class ErrorObject(_BaseType):
24+
"""This is the representation of a single error."""
25+
26+
#: Error identifier.
27+
code: str
28+
#: Plain text description of the cause of the error.
29+
message: str
30+
31+
def __init__(self, *, code: str, message: str):
32+
self.code = code
33+
self.message = message
34+
35+
super().__init__()
36+
37+
@classmethod
38+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "ErrorObject":
39+
if data["code"] == "General":
40+
from ._schemas.error import GeneralErrorSchema
41+
42+
return GeneralErrorSchema().load(data)
43+
if data["code"] == "MultipleActionsNotAllowed":
44+
from ._schemas.error import MultipleActionsNotAllowedErrorSchema
45+
46+
return MultipleActionsNotAllowedErrorSchema().load(data)
47+
if data["code"] == "RequiredField":
48+
from ._schemas.error import RequiredFieldErrorSchema
49+
50+
return RequiredFieldErrorSchema().load(data)
51+
if data["code"] == "ResourceNotFound":
52+
from ._schemas.error import ResourceNotFoundErrorSchema
53+
54+
return ResourceNotFoundErrorSchema().load(data)
55+
56+
def serialize(self) -> typing.Dict[str, typing.Any]:
57+
from ._schemas.error import ErrorObjectSchema
58+
59+
return ErrorObjectSchema().dump(self)
60+
61+
62+
class GeneralError(ErrorObject):
63+
"""Returned when a server-side problem occurs. In some cases, the requested action may successfully complete after the error is returned. Therefore, it is recommended to verify the status of the requested resource after receiving a 500 error.
64+
65+
If you encounter this error, report it using the [Support Portal](https://commercetools.atlassian.net/servicedesk/customer/portal/30).
66+
67+
"""
68+
69+
def __init__(self, *, message: str):
70+
71+
super().__init__(message=message, code="General")
72+
73+
@classmethod
74+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "GeneralError":
75+
from ._schemas.error import GeneralErrorSchema
76+
77+
return GeneralErrorSchema().load(data)
78+
79+
def serialize(self) -> typing.Dict[str, typing.Any]:
80+
from ._schemas.error import GeneralErrorSchema
81+
82+
return GeneralErrorSchema().dump(self)
83+
84+
85+
class MultipleActionsNotAllowedError(ErrorObject):
86+
"""Returned when `actions` in the request body contains more than one object."""
87+
88+
def __init__(self, *, message: str):
89+
90+
super().__init__(message=message, code="MultipleActionsNotAllowed")
91+
92+
@classmethod
93+
def deserialize(
94+
cls, data: typing.Dict[str, typing.Any]
95+
) -> "MultipleActionsNotAllowedError":
96+
from ._schemas.error import MultipleActionsNotAllowedErrorSchema
97+
98+
return MultipleActionsNotAllowedErrorSchema().load(data)
99+
100+
def serialize(self) -> typing.Dict[str, typing.Any]:
101+
from ._schemas.error import MultipleActionsNotAllowedErrorSchema
102+
103+
return MultipleActionsNotAllowedErrorSchema().dump(self)
104+
105+
106+
class RequiredFieldError(ErrorObject):
107+
"""Returned when a value is not defined for a required field."""
108+
109+
#: Name of the field missing the value.
110+
field: str
111+
112+
def __init__(self, *, message: str, field: str):
113+
self.field = field
114+
115+
super().__init__(message=message, code="RequiredField")
116+
117+
@classmethod
118+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "RequiredFieldError":
119+
from ._schemas.error import RequiredFieldErrorSchema
120+
121+
return RequiredFieldErrorSchema().load(data)
122+
123+
def serialize(self) -> typing.Dict[str, typing.Any]:
124+
from ._schemas.error import RequiredFieldErrorSchema
125+
126+
return RequiredFieldErrorSchema().dump(self)
127+
128+
129+
class ResourceNotFoundError(ErrorObject):
130+
"""Returned when the resource addressed by the request URL does not exist."""
131+
132+
def __init__(self, *, message: str):
133+
134+
super().__init__(message=message, code="ResourceNotFound")
135+
136+
@classmethod
137+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "ResourceNotFoundError":
138+
from ._schemas.error import ResourceNotFoundErrorSchema
139+
140+
return ResourceNotFoundErrorSchema().load(data)
141+
142+
def serialize(self) -> typing.Dict[str, typing.Any]:
143+
from ._schemas.error import ResourceNotFoundErrorSchema
144+
145+
return ResourceNotFoundErrorSchema().dump(self)
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# This file is automatically generated by the rmf-codegen project.
2+
#
3+
# The Python code generator is maintained by Lab Digital. If you want to
4+
# contribute to this project then please do not edit this file directly
5+
# but send a pull request to the Lab Digital fork of rmf-codegen at
6+
# https://github.com/labd/rmf-codegen
7+
8+
import datetime
9+
import enum
10+
import typing
11+
12+
from ._abstract import _BaseType
13+
14+
if typing.TYPE_CHECKING:
15+
from . import Amount
16+
from .common import PaymentAction
17+
18+
__all__ = [
19+
"CancelPaymentAction",
20+
"CapturePaymentAction",
21+
"Payment",
22+
"RefundPaymentAction",
23+
]
24+
25+
26+
class CapturePaymentAction(_BaseType):
27+
"""Requests to [capture](/payments-lifecycle#payment-capture) the given amount from the customer. Checkout will request the PSP to proceed with the financial process to capture the amount."""
28+
29+
#: Amount to be captured. It must be less than or equal to the [authorized](/payments-lifecycle#authorization) amount.
30+
amount: "Amount"
31+
32+
def __init__(self, *, amount: "Amount"):
33+
self.amount = amount
34+
35+
super().__init__(action="capturePayment")
36+
37+
@classmethod
38+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "CapturePaymentAction":
39+
from ._schemas.payments import CapturePaymentActionSchema
40+
41+
return CapturePaymentActionSchema().load(data)
42+
43+
def serialize(self) -> typing.Dict[str, typing.Any]:
44+
from ._schemas.payments import CapturePaymentActionSchema
45+
46+
return CapturePaymentActionSchema().dump(self)
47+
48+
49+
class RefundPaymentAction(_BaseType):
50+
"""Requests to [refund](/payments-lifecycle#refund) the given amount to the customer. Checkout will request the PSP to proceed with the financial process to refund the amount."""
51+
52+
#: Amount to be refunded. It must be less than or equal to the [captured](/payments-lifecycle#payment-capture) amount.
53+
amount: typing.Optional["Amount"]
54+
55+
def __init__(self, *, amount: typing.Optional["Amount"] = None):
56+
self.amount = amount
57+
58+
super().__init__(action="refundPayment")
59+
60+
@classmethod
61+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "RefundPaymentAction":
62+
from ._schemas.payments import RefundPaymentActionSchema
63+
64+
return RefundPaymentActionSchema().load(data)
65+
66+
def serialize(self) -> typing.Dict[str, typing.Any]:
67+
from ._schemas.payments import RefundPaymentActionSchema
68+
69+
return RefundPaymentActionSchema().dump(self)
70+
71+
72+
class CancelPaymentAction(_BaseType):
73+
"""Requests to [cancel the authorization](/payments-lifecycle#authorization-cancellation) for a Payment. Checkout will cancel the [Payment](/../api/projects/payments#payment) and will request the PSP to proceed with the financial process to cancel the authorization.
74+
75+
You cannot request to cancel the authorization for a Payment that has already been [captured](/payments-lifecycle#payment-capture).
76+
77+
"""
78+
79+
def __init__(self):
80+
81+
super().__init__(action="cancelPayment")
82+
83+
@classmethod
84+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "CancelPaymentAction":
85+
from ._schemas.payments import CancelPaymentActionSchema
86+
87+
return CancelPaymentActionSchema().load(data)
88+
89+
def serialize(self) -> typing.Dict[str, typing.Any]:
90+
from ._schemas.payments import CancelPaymentActionSchema
91+
92+
return CancelPaymentActionSchema().dump(self)
93+
94+
95+
class Payment(_BaseType):
96+
#: Action to execute for the given Payment.
97+
actions: typing.List["PaymentAction"]
98+
99+
def __init__(self, *, actions: typing.List["PaymentAction"]):
100+
self.actions = actions
101+
102+
super().__init__()
103+
104+
@classmethod
105+
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "Payment":
106+
from ._schemas.payments import PaymentSchema
107+
108+
return PaymentSchema().load(data)
109+
110+
def serialize(self) -> typing.Dict[str, typing.Any]:
111+
from ._schemas.payments import PaymentSchema
112+
113+
return PaymentSchema().dump(self)

0 commit comments

Comments
 (0)