diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index e6028d5..512eb60 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -3,6 +3,7 @@ Monei/api/__init__.py Monei/api/apple_pay_certificate_api.py Monei/api/apple_pay_domain_api.py Monei/api/bizum_api.py +Monei/api/customers_api.py Monei/api/payment_methods_api.py Monei/api/payments_api.py Monei/api/pos_auth_token_api.py @@ -27,9 +28,15 @@ Monei/model/capture_payment_request.py Monei/model/confirm_payment_request.py Monei/model/confirm_payment_request_payment_method.py Monei/model/confirm_payment_request_payment_method_card.py +Monei/model/conflict_error.py +Monei/model/conflict_error_all_of.py +Monei/model/create_customer_request.py Monei/model/create_payment_request.py Monei/model/create_pos_auth_token_request.py Monei/model/create_subscription_request.py +Monei/model/customer.py +Monei/model/customer_payment_method.py +Monei/model/deleted_resource.py Monei/model/internal_server_error.py Monei/model/internal_server_error_all_of.py Monei/model/not_found_error.py @@ -116,9 +123,18 @@ Monei/model/unauthorized_error_all_of.py Monei/model/unprocessable_entity_error.py Monei/model/unprocessable_entity_error_all_of.py Monei/model/update_apple_pay_certificate_request.py +Monei/model/update_customer_request.py Monei/model/update_subscription_request.py Monei/model/validate_bizum_phone_request.py Monei/model_utils.py Monei/models/__init__.py Monei/rest.py test/__init__.py +test/test_conflict_error.py +test/test_conflict_error_all_of.py +test/test_create_customer_request.py +test/test_customer.py +test/test_customer_payment_method.py +test/test_customers_api.py +test/test_deleted_resource.py +test/test_update_customer_request.py diff --git a/Monei/api/customers_api.py b/Monei/api/customers_api.py new file mode 100644 index 0000000..6758afb --- /dev/null +++ b/Monei/api/customers_api.py @@ -0,0 +1,676 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.api_client import ApiClient, Endpoint as _Endpoint +from Monei.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types, +) +from Monei.model.bad_request_error import BadRequestError +from Monei.model.conflict_error import ConflictError +from Monei.model.create_customer_request import CreateCustomerRequest +from Monei.model.customer import Customer +from Monei.model.customer_payment_method import CustomerPaymentMethod +from Monei.model.deleted_resource import DeletedResource +from Monei.model.internal_server_error import InternalServerError +from Monei.model.not_found_error import NotFoundError +from Monei.model.service_unavailable_error import ServiceUnavailableError +from Monei.model.unauthorized_error import UnauthorizedError +from Monei.model.unprocessable_entity_error import UnprocessableEntityError +from Monei.model.update_customer_request import UpdateCustomerRequest + + +class CustomersApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + self.create_endpoint = _Endpoint( + settings={ + "response_type": (Customer,), + "auth": ["APIKey"], + "endpoint_path": "/customers", + "operation_id": "create", + "http_method": "POST", + "servers": None, + }, + params_map={ + "all": [ + "create_customer_request", + ], + "required": [ + "create_customer_request", + ], + "nullable": [], + "enum": [], + "validation": [], + }, + root_map={ + "validations": {}, + "allowed_values": {}, + "openapi_types": { + "create_customer_request": (CreateCustomerRequest,), + }, + "attribute_map": {}, + "location_map": { + "create_customer_request": "body", + }, + "collection_format_map": {}, + }, + headers_map={ + "accept": ["application/json"], + "content_type": ["application/json"], + }, + api_client=api_client, + ) + self.delete_endpoint = _Endpoint( + settings={ + "response_type": (DeletedResource,), + "auth": ["APIKey"], + "endpoint_path": "/customers/{id}", + "operation_id": "delete", + "http_method": "DELETE", + "servers": None, + }, + params_map={ + "all": [ + "id", + ], + "required": [ + "id", + ], + "nullable": [], + "enum": [], + "validation": [], + }, + root_map={ + "validations": {}, + "allowed_values": {}, + "openapi_types": { + "id": (str,), + }, + "attribute_map": { + "id": "id", + }, + "location_map": { + "id": "path", + }, + "collection_format_map": {}, + }, + headers_map={ + "accept": ["application/json"], + "content_type": [], + }, + api_client=api_client, + ) + self.delete_payment_method_endpoint = _Endpoint( + settings={ + "response_type": (DeletedResource,), + "auth": ["APIKey"], + "endpoint_path": "/customers/{id}/payment-methods/{tokenId}", + "operation_id": "delete_payment_method", + "http_method": "DELETE", + "servers": None, + }, + params_map={ + "all": [ + "id", + "token_id", + ], + "required": [ + "id", + "token_id", + ], + "nullable": [], + "enum": [], + "validation": [], + }, + root_map={ + "validations": {}, + "allowed_values": {}, + "openapi_types": { + "id": (str,), + "token_id": (str,), + }, + "attribute_map": { + "id": "id", + "token_id": "tokenId", + }, + "location_map": { + "id": "path", + "token_id": "path", + }, + "collection_format_map": {}, + }, + headers_map={ + "accept": ["application/json"], + "content_type": [], + }, + api_client=api_client, + ) + self.get_endpoint = _Endpoint( + settings={ + "response_type": (Customer,), + "auth": ["APIKey"], + "endpoint_path": "/customers/{id}", + "operation_id": "get", + "http_method": "GET", + "servers": None, + }, + params_map={ + "all": [ + "id", + ], + "required": [ + "id", + ], + "nullable": [], + "enum": [], + "validation": [], + }, + root_map={ + "validations": {}, + "allowed_values": {}, + "openapi_types": { + "id": (str,), + }, + "attribute_map": { + "id": "id", + }, + "location_map": { + "id": "path", + }, + "collection_format_map": {}, + }, + headers_map={ + "accept": ["application/json"], + "content_type": [], + }, + api_client=api_client, + ) + self.list_payment_methods_endpoint = _Endpoint( + settings={ + "response_type": ([CustomerPaymentMethod],), + "auth": ["APIKey"], + "endpoint_path": "/customers/{id}/payment-methods", + "operation_id": "list_payment_methods", + "http_method": "GET", + "servers": None, + }, + params_map={ + "all": [ + "id", + ], + "required": [ + "id", + ], + "nullable": [], + "enum": [], + "validation": [], + }, + root_map={ + "validations": {}, + "allowed_values": {}, + "openapi_types": { + "id": (str,), + }, + "attribute_map": { + "id": "id", + }, + "location_map": { + "id": "path", + }, + "collection_format_map": {}, + }, + headers_map={ + "accept": ["application/json"], + "content_type": [], + }, + api_client=api_client, + ) + self.update_endpoint = _Endpoint( + settings={ + "response_type": (Customer,), + "auth": ["APIKey"], + "endpoint_path": "/customers/{id}", + "operation_id": "update", + "http_method": "PUT", + "servers": None, + }, + params_map={ + "all": [ + "id", + "update_customer_request", + ], + "required": [ + "id", + "update_customer_request", + ], + "nullable": [], + "enum": [], + "validation": [], + }, + root_map={ + "validations": {}, + "allowed_values": {}, + "openapi_types": { + "id": (str,), + "update_customer_request": (UpdateCustomerRequest,), + }, + "attribute_map": { + "id": "id", + }, + "location_map": { + "id": "path", + "update_customer_request": "body", + }, + "collection_format_map": {}, + }, + headers_map={ + "accept": ["application/json"], + "content_type": ["application/json"], + }, + api_client=api_client, + ) + + def create(self, create_customer_request, **kwargs): + """Create Customer # noqa: E501 + + Creates a customer. Every field is optional — a customer with no details at all is valid, and useful if you only want somewhere to attach saved payment methods. Pass the returned `id` as `customerId` when you [create a payment](https://docs.monei.com/apis/rest/payments-create/) or a [subscription](https://docs.monei.com/apis/rest/subscriptions-create/) to link it to this buyer. **What linking does**: - A payment saved with `generatePaymentToken` stores its payment method under this customer - The customer's details are copied onto the payment at the time it is made. Editing the customer later never rewrites a payment that already happened - A subscription gains renewal failover across the customer's other saved payment methods **Best practices**: - Create the customer once, when the buyer first registers with you, and reuse the `id` - Use `metadata` to store your own user identifier, so you can match your records to MONEI's # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create(create_customer_request, async_req=True) + >>> result = thread.get() + + Args: + create_customer_request (CreateCustomerRequest): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + + Returns: + Customer + If the method is called asynchronously, returns the request + thread. + """ + kwargs["async_req"] = kwargs.get("async_req", False) + kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) + kwargs["_preload_content"] = kwargs.get("_preload_content", True) + kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) + kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) + kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) + kwargs["_spec_property_naming"] = kwargs.get("_spec_property_naming", False) + kwargs["_content_type"] = kwargs.get("_content_type") + kwargs["_host_index"] = kwargs.get("_host_index") + kwargs["_request_auths"] = kwargs.get("_request_auths", None) + kwargs["create_customer_request"] = create_customer_request + return self.create_endpoint.call_with_http_info(**kwargs) + + def delete(self, id, **kwargs): + """Delete Customer # noqa: E501 + + Deletes a customer and every payment method it owns. This is the operation to use for a data-erasure request: the buyer's saved payment methods go with the customer, in one call. **Refused while the customer is still billing**: The request fails with `409` when a subscription that is `ACTIVE`, `TRIALING`, `PAUSED` or `PAST_DUE` still names this customer. Cancel those subscriptions first. **What is kept**: Payments and charges already made are not deleted. They keep the copy of the customer's details taken at the time, because they are a financial record. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete(id, async_req=True) + >>> result = thread.get() + + Args: + id (str): The customer ID + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + + Returns: + DeletedResource + If the method is called asynchronously, returns the request + thread. + """ + kwargs["async_req"] = kwargs.get("async_req", False) + kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) + kwargs["_preload_content"] = kwargs.get("_preload_content", True) + kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) + kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) + kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) + kwargs["_spec_property_naming"] = kwargs.get("_spec_property_naming", False) + kwargs["_content_type"] = kwargs.get("_content_type") + kwargs["_host_index"] = kwargs.get("_host_index") + kwargs["_request_auths"] = kwargs.get("_request_auths", None) + kwargs["id"] = id + return self.delete_endpoint.call_with_http_info(**kwargs) + + def delete_payment_method(self, id, token_id, **kwargs): + """Delete Payment Method # noqa: E501 + + Deletes one of a customer's saved payment methods. **Refused while it is still billing**: The request fails with `409` when a subscription that is `ACTIVE`, `TRIALING`, `PAUSED` or `PAST_DUE` is charging this payment method. Cancel or move that subscription first. **If it was the default**: Deleting the customer's `defaultTokenId` clears it, rather than silently moving the default to another card. While the customer has no default, a payment sending `useDefaultPaymentMethod` is rejected. The field does not stay empty for good: MONEI fills an empty default with the next reusable payment method the customer saves, the same rule that set the first one. Set `defaultTokenId` yourself if you need to choose which. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_payment_method(id, token_id, async_req=True) + >>> result = thread.get() + + Args: + id (str): The customer ID + token_id (str): The payment method ID + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + + Returns: + DeletedResource + If the method is called asynchronously, returns the request + thread. + """ + kwargs["async_req"] = kwargs.get("async_req", False) + kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) + kwargs["_preload_content"] = kwargs.get("_preload_content", True) + kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) + kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) + kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) + kwargs["_spec_property_naming"] = kwargs.get("_spec_property_naming", False) + kwargs["_content_type"] = kwargs.get("_content_type") + kwargs["_host_index"] = kwargs.get("_host_index") + kwargs["_request_auths"] = kwargs.get("_request_auths", None) + kwargs["id"] = id + kwargs["token_id"] = token_id + return self.delete_payment_method_endpoint.call_with_http_info(**kwargs) + + def get(self, id, **kwargs): + """Get Customer # noqa: E501 + + Retrieves a customer by its unique ID. Returns the customer's contact details, billing and shipping addresses, metadata, and the `defaultTokenId` of the payment method charged when a payment sets `useDefaultPaymentMethod`. The customer's saved payment methods are **not** included. Use [List Payment Methods](https://docs.monei.com/apis/rest/customers-list-payment-methods/) for those. A customer belonging to another merchant account is reported as not found. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get(id, async_req=True) + >>> result = thread.get() + + Args: + id (str): The customer ID + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + + Returns: + Customer + If the method is called asynchronously, returns the request + thread. + """ + kwargs["async_req"] = kwargs.get("async_req", False) + kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) + kwargs["_preload_content"] = kwargs.get("_preload_content", True) + kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) + kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) + kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) + kwargs["_spec_property_naming"] = kwargs.get("_spec_property_naming", False) + kwargs["_content_type"] = kwargs.get("_content_type") + kwargs["_host_index"] = kwargs.get("_host_index") + kwargs["_request_auths"] = kwargs.get("_request_auths", None) + kwargs["id"] = id + return self.get_endpoint.call_with_http_info(**kwargs) + + def list_payment_methods(self, id, **kwargs): + """List Payment Methods # noqa: E501 + + Lists the payment methods a customer has saved. Card and account numbers are never returned. Each entry carries only the display details — brand, last four digits, expiry — along with an `id` you can pass as `paymentToken` on a payment. Expired payment methods are left out. **`sequence`**: `sequence: true` marks a payment method saved for merchant-initiated charges, such as subscription renewals. These are the candidates a declined renewal fails over to. `sequence: false` marks one the buyer chose at checkout, which you can charge again with `paymentToken` or set as the customer's `defaultTokenId`. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.list_payment_methods(id, async_req=True) + >>> result = thread.get() + + Args: + id (str): The customer ID + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + + Returns: + [CustomerPaymentMethod] + If the method is called asynchronously, returns the request + thread. + """ + kwargs["async_req"] = kwargs.get("async_req", False) + kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) + kwargs["_preload_content"] = kwargs.get("_preload_content", True) + kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) + kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) + kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) + kwargs["_spec_property_naming"] = kwargs.get("_spec_property_naming", False) + kwargs["_content_type"] = kwargs.get("_content_type") + kwargs["_host_index"] = kwargs.get("_host_index") + kwargs["_request_auths"] = kwargs.get("_request_auths", None) + kwargs["id"] = id + return self.list_payment_methods_endpoint.call_with_http_info(**kwargs) + + def update(self, id, update_customer_request, **kwargs): + """Update Customer # noqa: E501 + + Updates a customer. Only the fields you send are changed. **Changing the default payment method**: Set `defaultTokenId` to the ID of a payment method this customer already owns. It must be one that can be reused for future payments — a payment method saved for a single use is rejected. MONEI only ever fills a default that is empty, so a value you set here is kept. Deleting that payment method clears the field, and the next reusable one the customer saves becomes the new default. **What updating does not do**: Updating a customer never changes a payment or a subscription that already exists. Their copies of the customer's details were taken when they were created, so a corrected email here does not rewrite last month's receipt. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update(id, update_customer_request, async_req=True) + >>> result = thread.get() + + Args: + id (str): The customer ID + update_customer_request (UpdateCustomerRequest): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + + Returns: + Customer + If the method is called asynchronously, returns the request + thread. + """ + kwargs["async_req"] = kwargs.get("async_req", False) + kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) + kwargs["_preload_content"] = kwargs.get("_preload_content", True) + kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) + kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) + kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) + kwargs["_spec_property_naming"] = kwargs.get("_spec_property_naming", False) + kwargs["_content_type"] = kwargs.get("_content_type") + kwargs["_host_index"] = kwargs.get("_host_index") + kwargs["_request_auths"] = kwargs.get("_request_auths", None) + kwargs["id"] = id + kwargs["update_customer_request"] = update_customer_request + return self.update_endpoint.call_with_http_info(**kwargs) diff --git a/Monei/apis/__init__.py b/Monei/apis/__init__.py index 391e412..dd83d28 100644 --- a/Monei/apis/__init__.py +++ b/Monei/apis/__init__.py @@ -16,6 +16,7 @@ from Monei.api.apple_pay_certificate_api import ApplePayCertificateApi from Monei.api.apple_pay_domain_api import ApplePayDomainApi from Monei.api.bizum_api import BizumApi +from Monei.api.customers_api import CustomersApi from Monei.api.pos_auth_token_api import POSAuthTokenApi from Monei.api.payment_methods_api import PaymentMethodsApi from Monei.api.payments_api import PaymentsApi diff --git a/Monei/model/conflict_error.py b/Monei/model/conflict_error.py new file mode 100644 index 0000000..a1ac282 --- /dev/null +++ b/Monei/model/conflict_error.py @@ -0,0 +1,350 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +def lazy_import(): + from Monei.model.api_exception import ApiException + from Monei.model.conflict_error_all_of import ConflictErrorAllOf + + globals()["ApiException"] = ApiException + globals()["ConflictErrorAllOf"] = ConflictErrorAllOf + + +class ConflictError(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + "status": (str,), # noqa: E501 + "status_code": (int,), # noqa: E501 + "message": (str,), # noqa: E501 + "request_id": (str,), # noqa: E501 + "request_time": (datetime,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "status": "status", # noqa: E501 + "status_code": "statusCode", # noqa: E501 + "message": "message", # noqa: E501 + "request_id": "requestId", # noqa: E501 + "request_time": "requestTime", # noqa: E501 + } + + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ConflictError - a model defined in OpenAPI + + Keyword Args: + status (str): Error type identifier + status_code (int): HTTP status code + message (str): Human-readable error message + request_id (str): Unique identifier for the request + request_time (datetime): Timestamp when the request was processed + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if ( + var_name in discarded_args + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self._additional_properties_model_instances + ): + # discard variable. + continue + setattr(self, var_name, var_value) + + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + "_composed_instances", + "_var_name_to_model_instances", + "_additional_properties_model_instances", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ConflictError - a model defined in OpenAPI + + Keyword Args: + status (str): Error type identifier + status_code (int): HTTP status code + message (str): Human-readable error message + request_id (str): Unique identifier for the request + request_time (datetime): Timestamp when the request was processed + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if ( + var_name in discarded_args + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self._additional_properties_model_instances + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + "anyOf": [], + "allOf": [ + ApiException, + ConflictErrorAllOf, + ], + "oneOf": [], + } diff --git a/Monei/model/conflict_error_all_of.py b/Monei/model/conflict_error_all_of.py new file mode 100644 index 0000000..e87847e --- /dev/null +++ b/Monei/model/conflict_error_all_of.py @@ -0,0 +1,285 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +class ConflictErrorAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + "status": (str,), # noqa: E501 + "status_code": (int,), # noqa: E501 + "message": (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "status": "status", # noqa: E501 + "status_code": "statusCode", # noqa: E501 + "message": "message", # noqa: E501 + } + + read_only_vars = {} + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ConflictErrorAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (str): Error type identifier. [optional] # noqa: E501 + status_code (int): HTTP status code. [optional] # noqa: E501 + message (str): Human-readable error message. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", True) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ConflictErrorAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (str): Error type identifier. [optional] # noqa: E501 + status_code (int): HTTP status code. [optional] # noqa: E501 + message (str): Human-readable error message. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/Monei/model/create_customer_request.py b/Monei/model/create_customer_request.py new file mode 100644 index 0000000..088c4ff --- /dev/null +++ b/Monei/model/create_customer_request.py @@ -0,0 +1,309 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +def lazy_import(): + from Monei.model.payment_billing_details import PaymentBillingDetails + from Monei.model.payment_shipping_details import PaymentShippingDetails + + globals()["PaymentBillingDetails"] = PaymentBillingDetails + globals()["PaymentShippingDetails"] = PaymentShippingDetails + + +class CreateCustomerRequest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + "email": (str,), # noqa: E501 + "name": (str,), # noqa: E501 + "phone": (str,), # noqa: E501 + "billing_details": (PaymentBillingDetails,), # noqa: E501 + "shipping_details": (PaymentShippingDetails,), # noqa: E501 + "metadata": ( + {str: (bool, date, datetime, dict, float, int, list, str, none_type)}, + ), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "email": "email", # noqa: E501 + "name": "name", # noqa: E501 + "phone": "phone", # noqa: E501 + "billing_details": "billingDetails", # noqa: E501 + "shipping_details": "shippingDetails", # noqa: E501 + "metadata": "metadata", # noqa: E501 + } + + read_only_vars = {} + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """CreateCustomerRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): The customer's email address.. [optional] # noqa: E501 + name (str): The customer's full name or business name.. [optional] # noqa: E501 + phone (str): The customer's phone number in E.164 format.. [optional] # noqa: E501 + billing_details (PaymentBillingDetails): [optional] # noqa: E501 + shipping_details (PaymentShippingDetails): [optional] # noqa: E501 + metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A set of key-value pairs that you can attach to a resource. This can be useful for storing additional information about the resource in a structured format.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", True) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """CreateCustomerRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): The customer's email address.. [optional] # noqa: E501 + name (str): The customer's full name or business name.. [optional] # noqa: E501 + phone (str): The customer's phone number in E.164 format.. [optional] # noqa: E501 + billing_details (PaymentBillingDetails): [optional] # noqa: E501 + shipping_details (PaymentShippingDetails): [optional] # noqa: E501 + metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A set of key-value pairs that you can attach to a resource. This can be useful for storing additional information about the resource in a structured format.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/Monei/model/create_payment_request.py b/Monei/model/create_payment_request.py index aaf8e08..f9ec18d 100644 --- a/Monei/model/create_payment_request.py +++ b/Monei/model/create_payment_request.py @@ -138,6 +138,8 @@ def openapi_types(): "subscription_id": (str,), # noqa: E501 "auto_recover": (bool,), # noqa: E501 "description": (str,), # noqa: E501 + "use_default_payment_method": (bool,), # noqa: E501 + "customer_id": (str,), # noqa: E501 "customer": (PaymentCustomer,), # noqa: E501 "billing_details": (PaymentBillingDetails,), # noqa: E501 "shipping_details": (PaymentShippingDetails,), # noqa: E501 @@ -172,6 +174,8 @@ def discriminator(): "subscription_id": "subscriptionId", # noqa: E501 "auto_recover": "autoRecover", # noqa: E501 "description": "description", # noqa: E501 + "use_default_payment_method": "useDefaultPaymentMethod", # noqa: E501 + "customer_id": "customerId", # noqa: E501 "customer": "customer", # noqa: E501 "billing_details": "billingDetails", # noqa: E501 "shipping_details": "shippingDetails", # noqa: E501 @@ -243,6 +247,8 @@ def _from_openapi_data( subscription_id (str): A unique identifier of the Subscription. If specified the payment is attached to this Subscription. . [optional] # noqa: E501 auto_recover (bool): If set to `true`, the new payment will be automatically created when customer visits the payment link of the previously failed payment. Is automatically set to `true` if `completeUrl` is not provided.(set this value to `true` to create \"Pay By Link\" payments).. [optional] # noqa: E501 description (str): An arbitrary string attached to the payment. Often useful for displaying to users. . [optional] # noqa: E501 + use_default_payment_method (bool): Charge the customer's default payment method, so you do not have to look its token up first. Requires `customerId`, and cannot be combined with `paymentToken` or `paymentMethod` — naming a payment method as well leaves no way to tell which one you meant. The payment is rejected when the customer has no default. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this payment belongs to. Linking a payment to a customer saves its payment method under that customer and groups the buyer's payments together. Not to be confused with `paymentMethod.trustly.customerId`, which is an identifier Trustly returns for its own account holder and is unrelated. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 @@ -363,6 +369,8 @@ def __init__(self, amount, currency, order_id, *args, **kwargs): # noqa: E501 subscription_id (str): A unique identifier of the Subscription. If specified the payment is attached to this Subscription. . [optional] # noqa: E501 auto_recover (bool): If set to `true`, the new payment will be automatically created when customer visits the payment link of the previously failed payment. Is automatically set to `true` if `completeUrl` is not provided.(set this value to `true` to create \"Pay By Link\" payments).. [optional] # noqa: E501 description (str): An arbitrary string attached to the payment. Often useful for displaying to users. . [optional] # noqa: E501 + use_default_payment_method (bool): Charge the customer's default payment method, so you do not have to look its token up first. Requires `customerId`, and cannot be combined with `paymentToken` or `paymentMethod` — naming a payment method as well leaves no way to tell which one you meant. The payment is rejected when the customer has no default. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this payment belongs to. Linking a payment to a customer saves its payment method under that customer and groups the buyer's payments together. Not to be confused with `paymentMethod.trustly.customerId`, which is an identifier Trustly returns for its own account holder and is unrelated. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 diff --git a/Monei/model/create_subscription_request.py b/Monei/model/create_subscription_request.py index c2a55c2..fb44ac7 100644 --- a/Monei/model/create_subscription_request.py +++ b/Monei/model/create_subscription_request.py @@ -117,6 +117,7 @@ def openapi_types(): "interval_count": (int,), # noqa: E501 "allowed_payment_methods": (SubscriptionPaymentMethods,), # noqa: E501 "description": (str,), # noqa: E501 + "customer_id": (str,), # noqa: E501 "customer": (PaymentCustomer,), # noqa: E501 "billing_details": (PaymentBillingDetails,), # noqa: E501 "shipping_details": (PaymentShippingDetails,), # noqa: E501 @@ -143,6 +144,7 @@ def discriminator(): "interval_count": "intervalCount", # noqa: E501 "allowed_payment_methods": "allowedPaymentMethods", # noqa: E501 "description": "description", # noqa: E501 + "customer_id": "customerId", # noqa: E501 "customer": "customer", # noqa: E501 "billing_details": "billingDetails", # noqa: E501 "shipping_details": "shippingDetails", # noqa: E501 @@ -206,6 +208,7 @@ def _from_openapi_data( interval_count (int): Number of intervals between subscription payments.. [optional] # noqa: E501 allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501 description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this subscription belongs to. Linking a subscription to a customer turns on **renewal failover**: when a renewal is declined by the issuing bank, MONEI retries it against up to two of the customer's other saved payment methods within the same attempt, before the subscription goes `PAST_DUE`. One declined renewal can therefore produce up to three charge attempts on different cards. If one succeeds the subscription continues and moves to that payment method. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 @@ -318,6 +321,7 @@ def __init__(self, amount, currency, interval, *args, **kwargs): # noqa: E501 interval_count (int): Number of intervals between subscription payments.. [optional] # noqa: E501 allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501 description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this subscription belongs to. Linking a subscription to a customer turns on **renewal failover**: when a renewal is declined by the issuing bank, MONEI retries it against up to two of the customer's other saved payment methods within the same attempt, before the subscription goes `PAST_DUE`. One declined renewal can therefore produce up to three charge attempts on different cards. If one succeeds the subscription continues and moves to that payment method. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 diff --git a/Monei/model/customer.py b/Monei/model/customer.py new file mode 100644 index 0000000..62f8168 --- /dev/null +++ b/Monei/model/customer.py @@ -0,0 +1,331 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +def lazy_import(): + from Monei.model.payment_billing_details import PaymentBillingDetails + from Monei.model.payment_shipping_details import PaymentShippingDetails + + globals()["PaymentBillingDetails"] = PaymentBillingDetails + globals()["PaymentShippingDetails"] = PaymentShippingDetails + + +class Customer(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + "id": (str,), # noqa: E501 + "email": (str,), # noqa: E501 + "name": (str,), # noqa: E501 + "phone": (str,), # noqa: E501 + "billing_details": (PaymentBillingDetails,), # noqa: E501 + "shipping_details": (PaymentShippingDetails,), # noqa: E501 + "metadata": ( + {str: (bool, date, datetime, dict, float, int, list, str, none_type)}, + ), # noqa: E501 + "default_token_id": (str,), # noqa: E501 + "created_at": (datetime,), # noqa: E501 + "updated_at": (datetime,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "id": "id", # noqa: E501 + "email": "email", # noqa: E501 + "name": "name", # noqa: E501 + "phone": "phone", # noqa: E501 + "billing_details": "billingDetails", # noqa: E501 + "shipping_details": "shippingDetails", # noqa: E501 + "metadata": "metadata", # noqa: E501 + "default_token_id": "defaultTokenId", # noqa: E501 + "created_at": "createdAt", # noqa: E501 + "updated_at": "updatedAt", # noqa: E501 + } + + read_only_vars = {} + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 + """Customer - a model defined in OpenAPI + + Args: + id (str): Unique identifier for the customer. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): The customer's email address.. [optional] # noqa: E501 + name (str): The customer's full name or business name.. [optional] # noqa: E501 + phone (str): The customer's phone number in E.164 format.. [optional] # noqa: E501 + billing_details (PaymentBillingDetails): [optional] # noqa: E501 + shipping_details (PaymentShippingDetails): [optional] # noqa: E501 + metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A set of key-value pairs that you can attach to a resource. This can be useful for storing additional information about the resource in a structured format.. [optional] # noqa: E501 + default_token_id (str): The payment method charged when a payment sets `useDefaultPaymentMethod`. MONEI fills this only while it is empty: the first reusable payment method the customer saves becomes the default, and a value you set here is kept. Deleting that payment method clears the field, so the next reusable one the customer saves becomes the new default. It must be the ID of a payment method this customer already owns, and one that can be reused for future payments. . [optional] # noqa: E501 + created_at (datetime): Time at which the resource was created.. [optional] # noqa: E501 + updated_at (datetime): Time at which the resource was last updated.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", True) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, id, *args, **kwargs): # noqa: E501 + """Customer - a model defined in OpenAPI + + Args: + id (str): Unique identifier for the customer. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): The customer's email address.. [optional] # noqa: E501 + name (str): The customer's full name or business name.. [optional] # noqa: E501 + phone (str): The customer's phone number in E.164 format.. [optional] # noqa: E501 + billing_details (PaymentBillingDetails): [optional] # noqa: E501 + shipping_details (PaymentShippingDetails): [optional] # noqa: E501 + metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A set of key-value pairs that you can attach to a resource. This can be useful for storing additional information about the resource in a structured format.. [optional] # noqa: E501 + default_token_id (str): The payment method charged when a payment sets `useDefaultPaymentMethod`. MONEI fills this only while it is empty: the first reusable payment method the customer saves becomes the default, and a value you set here is kept. Deleting that payment method clears the field, so the next reusable one the customer saves becomes the new default. It must be the ID of a payment method this customer already owns, and one that can be reused for future payments. . [optional] # noqa: E501 + created_at (datetime): Time at which the resource was created.. [optional] # noqa: E501 + updated_at (datetime): Time at which the resource was last updated.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/Monei/model/customer_payment_method.py b/Monei/model/customer_payment_method.py new file mode 100644 index 0000000..983b256 --- /dev/null +++ b/Monei/model/customer_payment_method.py @@ -0,0 +1,315 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +def lazy_import(): + from Monei.model.payment_payment_method import PaymentPaymentMethod + + globals()["PaymentPaymentMethod"] = PaymentPaymentMethod + + +class CustomerPaymentMethod(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + "id": (str,), # noqa: E501 + "type": (str,), # noqa: E501 + "sequence": (bool,), # noqa: E501 + "payment_method": (PaymentPaymentMethod,), # noqa: E501 + "expire_at": (int,), # noqa: E501 + "created_at": (datetime,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "id": "id", # noqa: E501 + "type": "type", # noqa: E501 + "sequence": "sequence", # noqa: E501 + "payment_method": "paymentMethod", # noqa: E501 + "expire_at": "expireAt", # noqa: E501 + "created_at": "createdAt", # noqa: E501 + } + + read_only_vars = {} + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, sequence, *args, **kwargs): # noqa: E501 + """CustomerPaymentMethod - a model defined in OpenAPI + + Args: + id (str): Identifier of the saved payment method. Pass it as `paymentToken` on a payment, as `defaultTokenId` when updating the customer, or to delete the payment method. + type (str): How the payment method is stored. One of `STICKY` or `ENCRYPTED_STICKY`. + sequence (bool): Whether this payment method was saved for merchant-initiated charges, such as subscription renewals, rather than being one the buyer chooses at checkout. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + payment_method (PaymentPaymentMethod): [optional] # noqa: E501 + expire_at (int): Time at which the payment method expires, in seconds since the Unix epoch. For a card this is one month after the card's own expiry. Absent when the payment method does not expire. . [optional] # noqa: E501 + created_at (datetime): Time at which the resource was created.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", True) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + self.sequence = sequence + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, id, type, sequence, *args, **kwargs): # noqa: E501 + """CustomerPaymentMethod - a model defined in OpenAPI + + Args: + id (str): Identifier of the saved payment method. Pass it as `paymentToken` on a payment, as `defaultTokenId` when updating the customer, or to delete the payment method. + type (str): How the payment method is stored. One of `STICKY` or `ENCRYPTED_STICKY`. + sequence (bool): Whether this payment method was saved for merchant-initiated charges, such as subscription renewals, rather than being one the buyer chooses at checkout. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + payment_method (PaymentPaymentMethod): [optional] # noqa: E501 + expire_at (int): Time at which the payment method expires, in seconds since the Unix epoch. For a card this is one month after the card's own expiry. Absent when the payment method does not expire. . [optional] # noqa: E501 + created_at (datetime): Time at which the resource was created.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + self.sequence = sequence + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/Monei/model/deleted_resource.py b/Monei/model/deleted_resource.py new file mode 100644 index 0000000..5834539 --- /dev/null +++ b/Monei/model/deleted_resource.py @@ -0,0 +1,283 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +class DeletedResource(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + "success": (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "success": "success", # noqa: E501 + } + + read_only_vars = {} + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, success, *args, **kwargs): # noqa: E501 + """DeletedResource - a model defined in OpenAPI + + Args: + success (bool): Always `true`. The request failed otherwise. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", True) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.success = success + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, success, *args, **kwargs): # noqa: E501 + """DeletedResource - a model defined in OpenAPI + + Args: + success (bool): Always `true`. The request failed otherwise. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.success = success + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/Monei/model/payment.py b/Monei/model/payment.py index b033cfa..8c2d847 100644 --- a/Monei/model/payment.py +++ b/Monei/model/payment.py @@ -128,6 +128,7 @@ def openapi_types(): "authorization_code": (str,), # noqa: E501 "status_code": (str,), # noqa: E501 "status_message": (str,), # noqa: E501 + "customer_id": (str,), # noqa: E501 "customer": (PaymentCustomer,), # noqa: E501 "shop": (PaymentShop,), # noqa: E501 "billing_details": (PaymentBillingDetails,), # noqa: E501 @@ -168,6 +169,7 @@ def discriminator(): "authorization_code": "authorizationCode", # noqa: E501 "status_code": "statusCode", # noqa: E501 "status_message": "statusMessage", # noqa: E501 + "customer_id": "customerId", # noqa: E501 "customer": "customer", # noqa: E501 "shop": "shop", # noqa: E501 "billing_details": "billingDetails", # noqa: E501 @@ -245,6 +247,7 @@ def _from_openapi_data( authorization_code (str): Unique identifier provided by the bank performing transaction. . [optional] # noqa: E501 status_code (str): Payment status code. . [optional] # noqa: E501 status_message (str): Human readable status message, can be displayed to a user. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this payment belongs to. Linking a payment to a customer saves its payment method under that customer and groups the buyer's payments together. Not to be confused with `paymentMethod.trustly.customerId`, which is an identifier Trustly returns for its own account holder and is unrelated. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 shop (PaymentShop): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 @@ -376,6 +379,7 @@ def __init__( authorization_code (str): Unique identifier provided by the bank performing transaction. . [optional] # noqa: E501 status_code (str): Payment status code. . [optional] # noqa: E501 status_message (str): Human readable status message, can be displayed to a user. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this payment belongs to. Linking a payment to a customer saves its payment method under that customer and groups the buyer's payments together. Not to be confused with `paymentMethod.trustly.customerId`, which is an identifier Trustly returns for its own account holder and is unrelated. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 shop (PaymentShop): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 diff --git a/Monei/model/subscription.py b/Monei/model/subscription.py index 270f2e1..c3dbc43 100644 --- a/Monei/model/subscription.py +++ b/Monei/model/subscription.py @@ -131,6 +131,7 @@ def openapi_types(): "currency": (str,), # noqa: E501 "allowed_payment_methods": (SubscriptionPaymentMethods,), # noqa: E501 "description": (str,), # noqa: E501 + "customer_id": (str,), # noqa: E501 "customer": (PaymentCustomer,), # noqa: E501 "billing_details": (PaymentBillingDetails,), # noqa: E501 "shipping_details": (PaymentShippingDetails,), # noqa: E501 @@ -177,6 +178,7 @@ def discriminator(): "currency": "currency", # noqa: E501 "allowed_payment_methods": "allowedPaymentMethods", # noqa: E501 "description": "description", # noqa: E501 + "customer_id": "customerId", # noqa: E501 "customer": "customer", # noqa: E501 "billing_details": "billingDetails", # noqa: E501 "shipping_details": "shippingDetails", # noqa: E501 @@ -269,6 +271,7 @@ def _from_openapi_data( currency (str): Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217), in uppercase. Must be a supported currency. . [optional] # noqa: E501 allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501 description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this subscription belongs to. Linking a subscription to a customer turns on **renewal failover**: when a renewal is declined by the issuing bank, MONEI retries it against up to two of the customer's other saved payment methods within the same attempt, before the subscription goes `PAST_DUE`. One declined renewal can therefore produce up to three charge attempts on different cards. If one succeeds the subscription continues and moves to that payment method. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 @@ -416,6 +419,7 @@ def __init__( currency (str): Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217), in uppercase. Must be a supported currency. . [optional] # noqa: E501 allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501 description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this subscription belongs to. Linking a subscription to a customer turns on **renewal failover**: when a renewal is declined by the issuing bank, MONEI retries it against up to two of the customer's other saved payment methods within the same attempt, before the subscription goes `PAST_DUE`. One declined renewal can therefore produce up to three charge attempts on different cards. If one succeeds the subscription continues and moves to that payment method. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 diff --git a/Monei/model/update_customer_request.py b/Monei/model/update_customer_request.py new file mode 100644 index 0000000..3921183 --- /dev/null +++ b/Monei/model/update_customer_request.py @@ -0,0 +1,313 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 + +from Monei.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel, +) +from Monei.exceptions import ApiAttributeError + + +def lazy_import(): + from Monei.model.payment_billing_details import PaymentBillingDetails + from Monei.model.payment_shipping_details import PaymentShippingDetails + + globals()["PaymentBillingDetails"] = PaymentBillingDetails + globals()["PaymentShippingDetails"] = PaymentShippingDetails + + +class UpdateCustomerRequest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = {} + + validations = {} + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + none_type, + ) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + "email": (str,), # noqa: E501 + "name": (str,), # noqa: E501 + "phone": (str,), # noqa: E501 + "billing_details": (PaymentBillingDetails,), # noqa: E501 + "shipping_details": (PaymentShippingDetails,), # noqa: E501 + "metadata": ( + {str: (bool, date, datetime, dict, float, int, list, str, none_type)}, + ), # noqa: E501 + "default_token_id": (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + "email": "email", # noqa: E501 + "name": "name", # noqa: E501 + "phone": "phone", # noqa: E501 + "billing_details": "billingDetails", # noqa: E501 + "shipping_details": "shippingDetails", # noqa: E501 + "metadata": "metadata", # noqa: E501 + "default_token_id": "defaultTokenId", # noqa: E501 + } + + read_only_vars = {} + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UpdateCustomerRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): The customer's email address.. [optional] # noqa: E501 + name (str): The customer's full name or business name.. [optional] # noqa: E501 + phone (str): The customer's phone number in E.164 format.. [optional] # noqa: E501 + billing_details (PaymentBillingDetails): [optional] # noqa: E501 + shipping_details (PaymentShippingDetails): [optional] # noqa: E501 + metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A set of key-value pairs that you can attach to a resource. This can be useful for storing additional information about the resource in a structured format.. [optional] # noqa: E501 + default_token_id (str): The payment method charged when a payment sets `useDefaultPaymentMethod`. MONEI fills this only while it is empty: the first reusable payment method the customer saves becomes the default, and a value you set here is kept. Deleting that payment method clears the field, so the next reusable one the customer saves becomes the new default. It must be the ID of a payment method this customer already owns, and one that can be reused for future payments. . [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", True) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set( + [ + "_data_store", + "_check_type", + "_spec_property_naming", + "_path_to_item", + "_configuration", + "_visited_composed_classes", + ] + ) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """UpdateCustomerRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): The customer's email address.. [optional] # noqa: E501 + name (str): The customer's full name or business name.. [optional] # noqa: E501 + phone (str): The customer's phone number in E.164 format.. [optional] # noqa: E501 + billing_details (PaymentBillingDetails): [optional] # noqa: E501 + shipping_details (PaymentShippingDetails): [optional] # noqa: E501 + metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A set of key-value pairs that you can attach to a resource. This can be useful for storing additional information about the resource in a structured format.. [optional] # noqa: E501 + default_token_id (str): The payment method charged when a payment sets `useDefaultPaymentMethod`. MONEI fills this only while it is empty: the first reusable payment method the customer saves becomes the default, and a value you set here is kept. Deleting that payment method clears the field, so the next reusable one the customer saves becomes the new default. It must be the ID of a payment method this customer already owns, and one that can be reused for future payments. . [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/Monei/model/update_subscription_request.py b/Monei/model/update_subscription_request.py index 6e2db92..75a80e9 100644 --- a/Monei/model/update_subscription_request.py +++ b/Monei/model/update_subscription_request.py @@ -110,6 +110,7 @@ def openapi_types(): "interval_count": (int,), # noqa: E501 "allowed_payment_methods": (SubscriptionPaymentMethods,), # noqa: E501 "description": (str,), # noqa: E501 + "customer_id": (str,), # noqa: E501 "customer": (PaymentCustomer,), # noqa: E501 "billing_details": (PaymentBillingDetails,), # noqa: E501 "shipping_details": (PaymentShippingDetails,), # noqa: E501 @@ -138,6 +139,7 @@ def discriminator(): "interval_count": "intervalCount", # noqa: E501 "allowed_payment_methods": "allowedPaymentMethods", # noqa: E501 "description": "description", # noqa: E501 + "customer_id": "customerId", # noqa: E501 "customer": "customer", # noqa: E501 "billing_details": "billingDetails", # noqa: E501 "shipping_details": "shippingDetails", # noqa: E501 @@ -199,6 +201,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 interval_count (int): Number of intervals between subscription payments.. [optional] # noqa: E501 allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501 description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this subscription belongs to. Linking a subscription to a customer turns on **renewal failover**: when a renewal is declined by the issuing bank, MONEI retries it against up to two of the customer's other saved payment methods within the same attempt, before the subscription goes `PAST_DUE`. One declined renewal can therefore produce up to three charge attempts on different cards. If one succeeds the subscription continues and moves to that payment method. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 @@ -308,6 +311,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 interval_count (int): Number of intervals between subscription payments.. [optional] # noqa: E501 allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501 description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501 + customer_id (str): The [customer](https://docs.monei.com/apis/rest/customers-create/) this subscription belongs to. Linking a subscription to a customer turns on **renewal failover**: when a renewal is declined by the issuing bank, MONEI retries it against up to two of the customer's other saved payment methods within the same attempt, before the subscription goes `PAST_DUE`. One declined renewal can therefore produce up to three charge attempts on different cards. If one succeeds the subscription continues and moves to that payment method. . [optional] # noqa: E501 customer (PaymentCustomer): [optional] # noqa: E501 billing_details (PaymentBillingDetails): [optional] # noqa: E501 shipping_details (PaymentShippingDetails): [optional] # noqa: E501 diff --git a/Monei/models/__init__.py b/Monei/models/__init__.py index 75249f6..07adeb0 100644 --- a/Monei/models/__init__.py +++ b/Monei/models/__init__.py @@ -32,9 +32,15 @@ from Monei.model.confirm_payment_request_payment_method_card import ( ConfirmPaymentRequestPaymentMethodCard, ) +from Monei.model.conflict_error import ConflictError +from Monei.model.conflict_error_all_of import ConflictErrorAllOf +from Monei.model.create_customer_request import CreateCustomerRequest from Monei.model.create_payment_request import CreatePaymentRequest from Monei.model.create_pos_auth_token_request import CreatePosAuthTokenRequest from Monei.model.create_subscription_request import CreateSubscriptionRequest +from Monei.model.customer import Customer +from Monei.model.customer_payment_method import CustomerPaymentMethod +from Monei.model.deleted_resource import DeletedResource from Monei.model.internal_server_error import InternalServerError from Monei.model.internal_server_error_all_of import InternalServerErrorAllOf from Monei.model.not_found_error import NotFoundError @@ -141,5 +147,6 @@ from Monei.model.update_apple_pay_certificate_request import ( UpdateApplePayCertificateRequest, ) +from Monei.model.update_customer_request import UpdateCustomerRequest from Monei.model.update_subscription_request import UpdateSubscriptionRequest from Monei.model.validate_bizum_phone_request import ValidateBizumPhoneRequest diff --git a/Monei/monei_client.py b/Monei/monei_client.py index a7547d4..0be0e8e 100644 --- a/Monei/monei_client.py +++ b/Monei/monei_client.py @@ -9,6 +9,7 @@ PaymentsApi, PaymentMethodsApi, SubscriptionsApi, + CustomersApi, ApplePayDomainApi, ApplePayCertificateApi, BizumApi, @@ -86,6 +87,7 @@ def call_api_with_validation(*args, **kwargs): self.Payments = PaymentsApi(api_client) self.PaymentMethods = PaymentMethodsApi(api_client) self.Subscriptions = SubscriptionsApi(api_client) + self.Customers = CustomersApi(api_client) self.ApplePayDomain = ApplePayDomainApi(api_client) self.Bizum = BizumApi(api_client) self.ApplePayCertificate = ApplePayCertificateApi(api_client) @@ -97,6 +99,7 @@ def call_api_with_validation(*args, **kwargs): self.payments = self.Payments self.payment_methods = self.PaymentMethods self.subscriptions = self.Subscriptions + self.customers = self.Customers self.apple_pay_domain = self.ApplePayDomain self.apple_pay_certificate = self.ApplePayCertificate self.bizum = self.Bizum diff --git a/README.md b/README.md index 390b4bc..3d65993 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ For collecting customer and payment information in the browser, use [monei.js](h - [Creating a Payment](#creating-a-payment) - [Retrieving a Payment](#retrieving-a-payment) - [Refunding a Payment](#refunding-a-payment) + - [Customer Operations](#customer-operations) + - [Creating a Customer](#creating-a-customer) + - [Charging a Saved Payment Method](#charging-a-saved-payment-method) + - [Managing Payment Methods](#managing-payment-methods) - [Integration Methods](#integration-methods) - [Using the Prebuilt Payment Page](#using-the-prebuilt-payment-page) - [Features](#features) @@ -228,6 +232,53 @@ except ApiException as e: print(f"Error refunding payment: {e}") ``` +## Customer Operations + +### Creating a Customer + +```python +from Monei import CreateCustomerRequest + +customer = monei.customers.create( + CreateCustomerRequest(email='john.doe@example.com', name='John Doe') +) +``` + +Pass `customer_id` to `CreatePaymentRequest` or `CreateSubscriptionRequest` to link the payment or subscription to the customer. Its payment method is then saved under the customer. + +### Charging a Saved Payment Method + +Set `use_default_payment_method` to charge the customer's default payment method: + +```python +payment = monei.payments.create( + CreatePaymentRequest( + amount=1250, + currency='EUR', + order_id='123457', + customer_id=customer.id, + use_default_payment_method=True, + ) +) +``` + +### Managing Payment Methods + +```python +from Monei import UpdateCustomerRequest + +payment_methods = monei.customers.list_payment_methods(customer.id) + +# Change the default payment method +monei.customers.update( + customer.id, + UpdateCustomerRequest(default_token_id=payment_methods[0].id), +) + +# Remove a saved payment method +monei.customers.delete_payment_method(customer.id, payment_methods[0].id) +``` + ## Integration Methods ### Using the Prebuilt Payment Page diff --git a/test/test_conflict_error.py b/test/test_conflict_error.py new file mode 100644 index 0000000..335a74c --- /dev/null +++ b/test/test_conflict_error.py @@ -0,0 +1,39 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.api_exception import ApiException +from Monei.model.conflict_error_all_of import ConflictErrorAllOf + +globals()["ApiException"] = ApiException +globals()["ConflictErrorAllOf"] = ConflictErrorAllOf +from Monei.model.conflict_error import ConflictError + + +class TestConflictError(unittest.TestCase): + """ConflictError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testConflictError(self): + """Test ConflictError""" + # FIXME: construct object with mandatory attributes with example values + # model = ConflictError() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_conflict_error_all_of.py b/test/test_conflict_error_all_of.py new file mode 100644 index 0000000..2917b13 --- /dev/null +++ b/test/test_conflict_error_all_of.py @@ -0,0 +1,34 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.conflict_error_all_of import ConflictErrorAllOf + + +class TestConflictErrorAllOf(unittest.TestCase): + """ConflictErrorAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testConflictErrorAllOf(self): + """Test ConflictErrorAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = ConflictErrorAllOf() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_create_customer_request.py b/test/test_create_customer_request.py new file mode 100644 index 0000000..f977a4b --- /dev/null +++ b/test/test_create_customer_request.py @@ -0,0 +1,39 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.payment_billing_details import PaymentBillingDetails +from Monei.model.payment_shipping_details import PaymentShippingDetails + +globals()["PaymentBillingDetails"] = PaymentBillingDetails +globals()["PaymentShippingDetails"] = PaymentShippingDetails +from Monei.model.create_customer_request import CreateCustomerRequest + + +class TestCreateCustomerRequest(unittest.TestCase): + """CreateCustomerRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCreateCustomerRequest(self): + """Test CreateCustomerRequest""" + # FIXME: construct object with mandatory attributes with example values + # model = CreateCustomerRequest() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_customer.py b/test/test_customer.py new file mode 100644 index 0000000..2d20835 --- /dev/null +++ b/test/test_customer.py @@ -0,0 +1,39 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.payment_billing_details import PaymentBillingDetails +from Monei.model.payment_shipping_details import PaymentShippingDetails + +globals()["PaymentBillingDetails"] = PaymentBillingDetails +globals()["PaymentShippingDetails"] = PaymentShippingDetails +from Monei.model.customer import Customer + + +class TestCustomer(unittest.TestCase): + """Customer unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCustomer(self): + """Test Customer""" + # FIXME: construct object with mandatory attributes with example values + # model = Customer() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_customer_payment_method.py b/test/test_customer_payment_method.py new file mode 100644 index 0000000..0a4fa63 --- /dev/null +++ b/test/test_customer_payment_method.py @@ -0,0 +1,37 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.payment_payment_method import PaymentPaymentMethod + +globals()["PaymentPaymentMethod"] = PaymentPaymentMethod +from Monei.model.customer_payment_method import CustomerPaymentMethod + + +class TestCustomerPaymentMethod(unittest.TestCase): + """CustomerPaymentMethod unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCustomerPaymentMethod(self): + """Test CustomerPaymentMethod""" + # FIXME: construct object with mandatory attributes with example values + # model = CustomerPaymentMethod() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_customers.py b/test/test_customers.py new file mode 100644 index 0000000..f633775 --- /dev/null +++ b/test/test_customers.py @@ -0,0 +1,72 @@ +import unittest +from unittest.mock import patch + +from Monei import CreatePaymentRequest, MoneiClient, UpdateCustomerRequest +from Monei.api_client import ApiClient +from test.test_subscriptions_preview import _response + + +class TestCustomers(unittest.TestCase): + """The generated tests patch nothing below the API method, so they would not + catch a wrong method, path or body key.""" + + @patch.object(ApiClient, "request") + def test_update_puts_the_default_token_to_the_customer(self, request): + request.return_value = _response({"id": "cus_123", "defaultTokenId": "tok_456"}) + monei = MoneiClient(api_key="test_api_key") + + customer = monei.customers.update( + "cus_123", UpdateCustomerRequest(default_token_id="tok_456") + ) + + method, url = request.call_args.args[:2] + self.assertEqual(method, "PUT") + self.assertTrue(url.endswith("/customers/cus_123")) + self.assertEqual( + request.call_args.kwargs["body"], {"defaultTokenId": "tok_456"} + ) + self.assertEqual(customer.default_token_id, "tok_456") + + @patch.object(ApiClient, "request") + def test_delete_payment_method_puts_both_ids_in_the_path(self, request): + request.return_value = _response({"success": True}) + monei = MoneiClient(api_key="test_api_key") + + monei.customers.delete_payment_method("cus_123", "tok_456") + + method, url = request.call_args.args[:2] + self.assertEqual(method, "DELETE") + self.assertTrue(url.endswith("/customers/cus_123/payment-methods/tok_456")) + + @patch.object(ApiClient, "request") + def test_payment_can_charge_the_customer_default_method(self, request): + request.return_value = _response( + { + "id": "pay_123", + "accountId": "acc_1", + "livemode": False, + "status": "PENDING", + "amount": 100, + "currency": "EUR", + "customerId": "cus_123", + } + ) + monei = MoneiClient(api_key="test_api_key") + + monei.payments.create( + CreatePaymentRequest( + amount=100, + currency="EUR", + order_id="1", + customer_id="cus_123", + use_default_payment_method=True, + ) + ) + + body = request.call_args.kwargs["body"] + self.assertEqual(body["customerId"], "cus_123") + self.assertIs(body["useDefaultPaymentMethod"], True) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_customers_api.py b/test/test_customers_api.py new file mode 100644 index 0000000..48ac75f --- /dev/null +++ b/test/test_customers_api.py @@ -0,0 +1,69 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import unittest + +import Monei +from Monei.api.customers_api import CustomersApi # noqa: E501 + + +class TestCustomersApi(unittest.TestCase): + """CustomersApi unit test stubs""" + + def setUp(self): + self.api = CustomersApi() # noqa: E501 + + def tearDown(self): + pass + + def test_create(self): + """Test case for create + + Create Customer # noqa: E501 + """ + pass + + def test_delete(self): + """Test case for delete + + Delete Customer # noqa: E501 + """ + pass + + def test_delete_payment_method(self): + """Test case for delete_payment_method + + Delete Payment Method # noqa: E501 + """ + pass + + def test_get(self): + """Test case for get + + Get Customer # noqa: E501 + """ + pass + + def test_list_payment_methods(self): + """Test case for list_payment_methods + + List Payment Methods # noqa: E501 + """ + pass + + def test_update(self): + """Test case for update + + Update Customer # noqa: E501 + """ + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_deleted_resource.py b/test/test_deleted_resource.py new file mode 100644 index 0000000..83a19b5 --- /dev/null +++ b/test/test_deleted_resource.py @@ -0,0 +1,34 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.deleted_resource import DeletedResource + + +class TestDeletedResource(unittest.TestCase): + """DeletedResource unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testDeletedResource(self): + """Test DeletedResource""" + # FIXME: construct object with mandatory attributes with example values + # model = DeletedResource() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_update_customer_request.py b/test/test_update_customer_request.py new file mode 100644 index 0000000..c8e22e3 --- /dev/null +++ b/test/test_update_customer_request.py @@ -0,0 +1,39 @@ +""" +MONEI API v1 + +The MONEI API is organized around REST principles. Our API is designed to be intuitive and developer-friendly. ### Base URL All API requests should be made to: ``` https://api.monei.com/v1 ``` ### Environment MONEI provides two environments: - **Test Environment**: For development and testing without processing real payments - **Live Environment**: For processing real transactions in production ### Client Libraries We provide official SDKs to simplify integration: - [PHP SDK](https://github.com/MONEI/monei-php-sdk) - [Python SDK](https://github.com/MONEI/monei-python-sdk) - [Node.js SDK](https://github.com/MONEI/monei-node-sdk) - [Postman Collection](https://postman.monei.com/) Our SDKs handle authentication, error handling, and request formatting automatically. You can download the OpenAPI specification from the https://js.monei.com/api/v1/openapi.json and generate your own client library using the [OpenAPI Generator](https://openapi-generator.tech/). ### Important Requirements - All API requests must be made over HTTPS - If you are not using our official SDKs, you **must provide a valid `User-Agent` header** with each request - Requests without proper authentication will return a `401 Unauthorized` error ### Error Handling The API returns consistent error codes and messages to help you troubleshoot issues. Each response includes a `statusCode` attribute indicating the outcome of your request. ### Rate Limits The API implements rate limiting to ensure stability. If you exceed the limits, requests will return a `429 Too Many Requests` status code. # noqa: E501 + +The version of the OpenAPI document: 1.12.3 +Generated by: https://openapi-generator.tech +""" + +import sys +import unittest + +import Monei +from Monei.model.payment_billing_details import PaymentBillingDetails +from Monei.model.payment_shipping_details import PaymentShippingDetails + +globals()["PaymentBillingDetails"] = PaymentBillingDetails +globals()["PaymentShippingDetails"] = PaymentShippingDetails +from Monei.model.update_customer_request import UpdateCustomerRequest + + +class TestUpdateCustomerRequest(unittest.TestCase): + """UpdateCustomerRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testUpdateCustomerRequest(self): + """Test UpdateCustomerRequest""" + # FIXME: construct object with mandatory attributes with example values + # model = UpdateCustomerRequest() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main()