From 9fbb658e2e874968962f06d507cd1c7db47cf047 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:35:45 +0000 Subject: [PATCH] SDK regeneration --- poetry.lock | 6 +- pyproject.toml | 2 +- reference.md | 2961 ++++++++++++++--- src/monite/__init__.py | 112 +- src/monite/access_tokens/client.py | 28 +- src/monite/access_tokens/raw_client.py | 69 +- .../accounting/connections/raw_client.py | 153 +- .../accounting/ledger_accounts/raw_client.py | 63 +- src/monite/accounting/payables/raw_client.py | 63 +- .../accounting/receivables/raw_client.py | 63 +- .../accounting/synced_records/raw_client.py | 93 +- src/monite/accounting/tax_rates/raw_client.py | 63 +- src/monite/analytics/raw_client.py | 26 +- src/monite/approval_policies/client.py | 20 + .../approval_policies/processes/raw_client.py | 34 +- src/monite/approval_policies/raw_client.py | 62 +- src/monite/approval_requests/client.py | 20 +- src/monite/approval_requests/raw_client.py | 70 +- src/monite/client.py | 6 + src/monite/comments/client.py | 20 +- src/monite/comments/raw_client.py | 173 +- src/monite/core/client_wrapper.py | 4 +- .../client.py | 4 +- .../raw_client.py | 153 +- src/monite/counterparts/addresses/client.py | 4 +- .../counterparts/addresses/raw_client.py | 157 +- .../counterparts/bank_accounts/raw_client.py | 183 +- .../counterparts/contacts/raw_client.py | 183 +- src/monite/counterparts/raw_client.py | 213 +- src/monite/counterparts/vat_ids/raw_client.py | 153 +- src/monite/credit_notes/raw_client.py | 170 +- src/monite/custom_vat_rates/raw_client.py | 42 +- src/monite/data_exports/client.py | 20 +- src/monite/data_exports/extra_data/client.py | 20 +- .../data_exports/extra_data/raw_client.py | 62 +- src/monite/data_exports/raw_client.py | 76 +- src/monite/delivery_notes/client.py | 54 +- src/monite/delivery_notes/raw_client.py | 62 +- .../e_invoicing_connections/raw_client.py | 50 +- .../__init__.py} | 3 +- src/monite/e_invoicing_search/client.py | 157 + src/monite/e_invoicing_search/raw_client.py | 209 ++ src/monite/entities/bank_accounts/client.py | 20 +- .../entities/bank_accounts/raw_client.py | 183 +- src/monite/entities/client.py | 635 ++-- src/monite/entities/onboarding_data/client.py | 10 + .../entities/onboarding_data/raw_client.py | 77 +- src/monite/entities/payment_methods/client.py | 28 +- .../entities/payment_methods/raw_client.py | 87 +- src/monite/entities/persons/raw_client.py | 183 +- src/monite/entities/raw_client.py | 1257 +++++-- src/monite/entities/vat_ids/raw_client.py | 153 +- src/monite/entity_users/client.py | 212 +- src/monite/entity_users/raw_client.py | 504 ++- src/monite/errors/__init__.py | 4 +- ...er_error.py => too_many_requests_error.py} | 4 +- src/monite/events/raw_client.py | 63 +- src/monite/files/client.py | 120 +- src/monite/files/raw_client.py | 286 +- src/monite/financing/raw_client.py | 123 +- src/monite/mail_templates/client.py | 8 +- src/monite/mail_templates/raw_client.py | 251 +- src/monite/mailbox_domains/raw_client.py | 34 +- src/monite/mailboxes/client.py | 33 +- src/monite/mailboxes/raw_client.py | 59 +- src/monite/measure_units/raw_client.py | 42 +- src/monite/ocr/raw_client.py | 123 +- src/monite/overdue_reminders/raw_client.py | 42 +- src/monite/partner_settings/client.py | 140 +- src/monite/partner_settings/raw_client.py | 309 +- src/monite/payables/client.py | 195 +- src/monite/payables/line_items/raw_client.py | 72 +- src/monite/payables/raw_client.py | 685 +++- src/monite/payment_intents/raw_client.py | 123 +- src/monite/payment_links/client.py | 78 +- src/monite/payment_links/raw_client.py | 149 +- src/monite/payment_records/client.py | 30 +- src/monite/payment_records/raw_client.py | 237 +- src/monite/payment_reminders/raw_client.py | 42 +- src/monite/payment_terms/client.py | 10 +- src/monite/payment_terms/raw_client.py | 42 +- src/monite/pdf_templates/raw_client.py | 153 +- src/monite/products/raw_client.py | 42 +- src/monite/projects/client.py | 56 +- src/monite/projects/raw_client.py | 98 +- src/monite/purchase_orders/raw_client.py | 198 +- src/monite/receipts/__init__.py | 4 + src/monite/receipts/client.py | 1494 +++++++++ src/monite/receipts/raw_client.py | 2802 ++++++++++++++++ src/monite/receivables/client.py | 490 ++- src/monite/receivables/raw_client.py | 736 +++- src/monite/recurrences/raw_client.py | 58 +- src/monite/roles/client.py | 8 +- src/monite/roles/raw_client.py | 138 +- src/monite/tags/raw_client.py | 64 +- src/monite/text_templates/raw_client.py | 183 +- src/monite/types/__init__.py | 104 +- src/monite/types/access_token_response.py | 17 +- src/monite/types/airwallex_mandate.py | 32 - src/monite/types/airwallex_mandate_type.py | 5 - ..._plaid_bank_account_verification_status.py | 7 - src/monite/types/allowed_file_types.py | 1 + src/monite/types/approval_policy_resource.py | 5 + .../types/approval_process_step_resource.py | 1 + ..._verification.py => attachment_request.py} | 12 +- src/monite/types/attachment_response.py | 47 + .../types/bank_account_verification_type.py | 5 - src/monite/types/button_theme.py | 17 +- .../complete_refresh_verification_request.py | 20 - .../complete_refresh_verification_response.py | 20 - ...te_verification_airwallex_plaid_request.py | 36 - .../types/complete_verification_request.py | 22 - .../types/complete_verification_response.py | 72 - src/monite/types/counterpart_address.py | 2 +- ...nvoicing_credential_existence_response.py} | 11 +- .../counterpart_individual_root_response.py | 10 +- .../counterpart_organization_root_response.py | 10 +- .../types/counterpart_raw_bank_account.py | 5 + ...terpart_raw_bank_account_update_request.py | 5 + .../types/create_onboarding_link_request.py | 22 - .../types/credit_note_response_payload.py | 23 +- .../types/delivery_note_create_request.py | 2 +- src/monite/types/delivery_note_resource.py | 2 +- .../types/document_rendering_settings.py | 26 +- .../document_rendering_settings_input.py | 57 + .../document_rendering_settings_output.py | 57 + .../types/entity_individual_response.py | 2 +- .../types/entity_onboarding_data_response.py | 5 + .../types/entity_organization_response.py | 2 +- src/monite/types/entity_user_response.py | 27 +- src/monite/types/exchange_rate.py | 2 +- src/monite/types/file_response.py | 80 +- src/monite/types/file_schema.py | 32 +- src/monite/types/financing_invoice.py | 62 +- .../types/financing_invoice_list_response.py | 8 +- src/monite/types/financing_offer.py | 20 +- src/monite/types/financing_offers_response.py | 8 +- src/monite/types/invoice.py | 17 +- src/monite/types/invoice_response_payload.py | 20 +- ...ations.py => line_item_column_settings.py} | 8 +- ...y => line_item_numeric_column_settings.py} | 14 +- .../types/line_items_rendering_settings.py | 69 + src/monite/types/mail_settings.py | 27 +- src/monite/types/mailbox_object_type_enum.py | 2 +- src/monite/types/next_document_numbers.py | 42 + src/monite/types/ocr_address_details.py | 4 +- src/monite/types/ocr_counterpart_details.py | 8 +- src/monite/types/ocr_credit_note.py | 12 +- src/monite/types/ocr_invoice.py | 12 +- src/monite/types/ocr_line_item.py | 8 +- src/monite/types/ocr_receipt.py | 12 +- src/monite/types/ocr_receipt_line_item.py | 10 +- src/monite/types/ocr_recognition_response.py | 8 +- .../ocr_response_invoice_receipt_data.py | 92 +- ..._response_invoice_receipt_line_item_raw.py | 32 +- src/monite/types/ocr_task_response_schema.py | 2 +- ...cr_task_response_schema_recognized_data.py | 36 +- .../types/ocr_tasks_pagination_response.py | 8 +- .../types/onboarding_link_public_response.py | 25 - src/monite/types/onboarding_link_request.py | 22 - src/monite/types/onboarding_link_response.py | 27 - src/monite/types/page_schema2.py | 8 +- ...partner_project_settings_payload_output.py | 43 +- src/monite/types/payable_settings.py | 39 +- src/monite/types/payment_account_object.py | 7 +- .../types/payment_intent_payout_method.py | 5 - src/monite/types/payment_intents_recipient.py | 23 - .../types/payment_received_event_data.py | 2 +- src/monite/types/payment_record_response.py | 2 +- .../types/payments_batch_payment_request.py | 22 - .../types/payments_batch_payment_response.py | 29 - .../types/payments_batch_payment_status.py | 7 - src/monite/types/payments_settings_input.py | 8 +- src/monite/types/payments_settings_output.py | 8 +- src/monite/types/preview_schema2.py | 10 +- src/monite/types/pricing_plan.py | 8 +- src/monite/types/project_resource.py | 22 +- ...er_counterpart_individual_root_response.py | 10 +- ..._counterpart_organization_root_response.py | 10 +- src/monite/types/quote_response_payload.py | 26 +- src/monite/types/receipt_cursor_fields.py | 5 + .../types/receipt_line_item_cursor_fields.py | 5 + .../receipt_line_item_response_schema.py | 63 + ...receipt_line_items_pagination_response.py} | 16 +- ...ount.py => receipt_pagination_response.py} | 17 +- src/monite/types/receipt_response_schema.py | 110 + ...eceivable_facade_create_invoice_payload.py | 22 +- .../receivable_facade_create_quote_payload.py | 22 +- src/monite/types/receivable_response.py | 9 + src/monite/types/receivable_settings.py | 11 +- src/monite/types/recipient_type.py | 5 - src/monite/types/related_documents.py | 11 +- src/monite/types/repayment_schedule.py | 8 +- src/monite/types/role_pagination_response.py | 8 +- src/monite/types/role_response.py | 20 +- src/monite/types/root_schema_input.py | 15 + src/monite/types/root_schema_output.py | 15 + src/monite/types/settings_response.py | 64 +- src/monite/types/signature.py | 6 +- .../types/single_payment_intent_response.py | 31 - .../types/source_of_receipt_data_enum.py | 5 + ...nt.py => suggested_counterpart_payload.py} | 7 +- ...bject_payable.py => suggested_response.py} | 6 +- src/monite/types/sync_record_resource.py | 8 +- .../types/total_vat_amount_item_component.py | 10 +- src/monite/types/update_credit_note.py | 22 +- src/monite/types/update_entity_request.py | 28 +- src/monite/types/update_invoice.py | 22 +- src/monite/types/update_issued_invoice.py | 22 +- src/monite/types/update_quote.py | 22 +- src/monite/types/vat_rate_response.py | 10 +- .../verification_airwallex_plaid_response.py | 39 - src/monite/types/verification_request.py | 22 - src/monite/types/verification_response.py | 22 - src/monite/types/webhook_object_type.py | 1 + .../types/webhook_subscription_resource.py | 23 +- ...bhook_subscription_resource_with_secret.py | 29 +- src/monite/vat_rates/client.py | 34 + src/monite/vat_rates/raw_client.py | 44 +- src/monite/webhook_deliveries/raw_client.py | 33 +- src/monite/webhook_subscriptions/client.py | 90 +- .../webhook_subscriptions/raw_client.py | 404 ++- 222 files changed, 18157 insertions(+), 4181 deletions(-) rename src/monite/{types/airwallex_mandate_version.py => e_invoicing_search/__init__.py} (51%) create mode 100644 src/monite/e_invoicing_search/client.py create mode 100644 src/monite/e_invoicing_search/raw_client.py rename src/monite/errors/{internal_server_error.py => too_many_requests_error.py} (70%) create mode 100644 src/monite/receipts/__init__.py create mode 100644 src/monite/receipts/client.py create mode 100644 src/monite/receipts/raw_client.py delete mode 100644 src/monite/types/airwallex_mandate.py delete mode 100644 src/monite/types/airwallex_mandate_type.py delete mode 100644 src/monite/types/airwallex_plaid_bank_account_verification_status.py rename src/monite/types/{airwallex_plaid_verification.py => attachment_request.py} (61%) create mode 100644 src/monite/types/attachment_response.py delete mode 100644 src/monite/types/bank_account_verification_type.py delete mode 100644 src/monite/types/complete_refresh_verification_request.py delete mode 100644 src/monite/types/complete_refresh_verification_response.py delete mode 100644 src/monite/types/complete_verification_airwallex_plaid_request.py delete mode 100644 src/monite/types/complete_verification_request.py delete mode 100644 src/monite/types/complete_verification_response.py rename src/monite/types/{airwallex_plaid_institution.py => counterpart_einvoicing_credential_existence_response.py} (68%) delete mode 100644 src/monite/types/create_onboarding_link_request.py create mode 100644 src/monite/types/document_rendering_settings_input.py create mode 100644 src/monite/types/document_rendering_settings_output.py rename src/monite/types/{bank_account_verifications.py => line_item_column_settings.py} (64%) rename src/monite/types/{verification_airwallex_plaid_request.py => line_item_numeric_column_settings.py} (52%) create mode 100644 src/monite/types/line_items_rendering_settings.py create mode 100644 src/monite/types/next_document_numbers.py delete mode 100644 src/monite/types/onboarding_link_public_response.py delete mode 100644 src/monite/types/onboarding_link_request.py delete mode 100644 src/monite/types/onboarding_link_response.py delete mode 100644 src/monite/types/payment_intent_payout_method.py delete mode 100644 src/monite/types/payment_intents_recipient.py delete mode 100644 src/monite/types/payments_batch_payment_request.py delete mode 100644 src/monite/types/payments_batch_payment_response.py delete mode 100644 src/monite/types/payments_batch_payment_status.py create mode 100644 src/monite/types/receipt_cursor_fields.py create mode 100644 src/monite/types/receipt_line_item_cursor_fields.py create mode 100644 src/monite/types/receipt_line_item_response_schema.py rename src/monite/types/{single_payment_intent.py => receipt_line_items_pagination_response.py} (53%) rename src/monite/types/{airwallex_plaid_account.py => receipt_pagination_response.py} (56%) create mode 100644 src/monite/types/receipt_response_schema.py delete mode 100644 src/monite/types/recipient_type.py delete mode 100644 src/monite/types/single_payment_intent_response.py create mode 100644 src/monite/types/source_of_receipt_data_enum.py rename src/monite/types/{recipient.py => suggested_counterpart_payload.py} (71%) rename src/monite/types/{payment_object_payable.py => suggested_response.py} (73%) delete mode 100644 src/monite/types/verification_airwallex_plaid_response.py delete mode 100644 src/monite/types/verification_request.py delete mode 100644 src/monite/types/verification_response.py diff --git a/poetry.lock b/poetry.lock index 3ddef64..c2ddd86 100644 --- a/poetry.lock +++ b/poetry.lock @@ -38,13 +38,13 @@ trio = ["trio (>=0.26.1)"] [[package]] name = "certifi" -version = "2025.6.15" +version = "2025.8.3" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.7" files = [ - {file = "certifi-2025.6.15-py3-none-any.whl", hash = "sha256:2e0c7ce7cb5d8f8634ca55d2ba7e6ec2689a2fd6537d8dec1296a477a4910057"}, - {file = "certifi-2025.6.15.tar.gz", hash = "sha256:d747aa5a8b9bbbb1bb8c22bb13e22bd1f18e9796defa16bab421f7f7a317323b"}, + {file = "certifi-2025.8.3-py3-none-any.whl", hash = "sha256:f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5"}, + {file = "certifi-2025.8.3.tar.gz", hash = "sha256:e564105f78ded564e3ae7c923924435e1daa7463faeab5bb932bc53ffae63407"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 1e6b471..cafc93a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "monite" [tool.poetry] name = "monite" -version = "0.5.3" +version = "0.5.4" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 0d0d6e4..5d3ceac 100644 --- a/reference.md +++ b/reference.md @@ -1758,6 +1758,14 @@ client.approval_policies.create(
+**priority:** `typing.Optional[int]` — The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + +
+
+ +
+
+ **starts_at:** `typing.Optional[dt.datetime]` — The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC.
@@ -2014,6 +2022,14 @@ client.approval_policies.update_by_id(
+**priority:** `typing.Optional[int]` — The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + +
+
+ +
+
+ **script:** `typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]]` — A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object.
@@ -2095,7 +2111,7 @@ client.approval_requests.get()
-**order:** `typing.Optional[OrderEnum]` — Order by +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -2103,7 +2119,7 @@ client.approval_requests.get()
-**limit:** `typing.Optional[int]` — Max is 100 +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page.
@@ -2111,7 +2127,11 @@ client.approval_requests.get()
-**pagination_token:** `typing.Optional[str]` — A token, obtained from previous page. Prior over other filters +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned.
@@ -2119,7 +2139,7 @@ client.approval_requests.get()
-**sort:** `typing.Optional[ApprovalRequestCursorFields]` — Allowed sort fields +**sort:** `typing.Optional[ApprovalRequestCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -2627,7 +2647,7 @@ client.access_tokens.revoke(
-**client_id:** `str` +**client_id:** `str` — Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs.
@@ -2635,7 +2655,7 @@ client.access_tokens.revoke(
-**client_secret:** `str` +**client_secret:** `str` — Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets.
@@ -2643,7 +2663,7 @@ client.access_tokens.revoke(
-**token:** `str` +**token:** `str` — The token to revoke.
@@ -2698,9 +2718,10 @@ client = Monite( token="YOUR_TOKEN", ) client.access_tokens.create( - client_id="client_id", - client_secret="client_secret", - grant_type="client_credentials", + client_id="eb959578-a74d-4ac3-8b25-bf0910027857", + client_secret="14c84a34-282b-4fd8-8af6-86b5b5f2c212", + entity_user_id="7abd8744-507c-40e6-a5ca-34aa480b3991", + grant_type="entity_user", ) ``` @@ -2717,7 +2738,7 @@ client.access_tokens.create(
-**client_id:** `str` +**client_id:** `str` — Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs.
@@ -2725,7 +2746,7 @@ client.access_tokens.create(
-**client_secret:** `str` +**client_secret:** `str` — Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets.
@@ -2734,6 +2755,11 @@ client.access_tokens.create(
**grant_type:** `GrantType` + +The type of the access token to generate: + + * `client_credentials` - partner-level access token, + * `entity_user` - entity user token.
@@ -2741,7 +2767,7 @@ client.access_tokens.create(
-**entity_user_id:** `typing.Optional[str]` +**entity_user_id:** `typing.Optional[str]` — ID of the entity user to generate the access token for. Used only if `grant_type` is `entity_user`.
@@ -2822,7 +2848,7 @@ client.comments.get(
-**order:** `typing.Optional[OrderEnum]` — Order by +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -2830,7 +2856,7 @@ client.comments.get(
-**limit:** `typing.Optional[int]` — Max is 100 +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page.
@@ -2838,7 +2864,11 @@ client.comments.get(
-**pagination_token:** `typing.Optional[str]` — A token, obtained from previous page. Prior over other filters +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned.
@@ -2846,7 +2876,7 @@ client.comments.get(
-**sort:** `typing.Optional[CommentCursorFields]` — Allowed sort fields +**sort:** `typing.Optional[CommentCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -3992,7 +4022,7 @@ client.counterpart_e_invoicing_credentials.get_counterparts_id_einvoicing_creden
```python -from monite import CreateCounterpartEinvoicingCredentialCounterpartVatId, Monite +from monite import CounterpartEinvoicingCredentialSchema, Monite client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -4001,8 +4031,9 @@ client = Monite( ) client.counterpart_e_invoicing_credentials.post_counterparts_id_einvoicing_credentials( counterpart_id="counterpart_id", - request=CreateCounterpartEinvoicingCredentialCounterpartVatId( - counterpart_vat_id_id="counterpart_vat_id_id", + request=CounterpartEinvoicingCredentialSchema( + network_identifier="DE087095777", + network_schema="DE:VAT", ), ) @@ -4613,7 +4644,7 @@ client.data_exports.get()
-**order:** `typing.Optional[OrderEnum]` — Order by +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -4621,7 +4652,7 @@ client.data_exports.get()
-**limit:** `typing.Optional[int]` — Max is 100 +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page.
@@ -4629,7 +4660,11 @@ client.data_exports.get()
-**pagination_token:** `typing.Optional[str]` — A token, obtained from previous page. Prior over other filters +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned.
@@ -4637,7 +4672,7 @@ client.data_exports.get()
-**sort:** `typing.Optional[DataExportCursorFields]` — Allowed sort fields +**sort:** `typing.Optional[DataExportCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -5182,13 +5217,7 @@ If not specified, the first page of results will be returned.
```python -from monite import ( - DeliveryNoteCreateLineItem, - DeliveryNoteCreateRequest, - DeliveryNoteLineItemProduct, - Monite, - UnitRequest, -) +from monite import DeliveryNoteCreateBasedOnRequest, Monite client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -5196,30 +5225,8 @@ client = Monite( token="YOUR_TOKEN", ) client.delivery_notes.post_delivery_notes( - request=DeliveryNoteCreateRequest( - counterpart_address_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - counterpart_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - delivery_date="2025-01-01", - delivery_number="102-2025-0987", - display_signature_placeholder=True, - line_items=[ - DeliveryNoteCreateLineItem( - product_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - quantity=10.0, - ), - DeliveryNoteCreateLineItem( - product=DeliveryNoteLineItemProduct( - description="Description of product 2", - measure_unit=UnitRequest( - description="pieces", - name="pcs", - ), - name="Product 2", - ), - quantity=20.0, - ), - ], - memo="This is a memo", + request=DeliveryNoteCreateBasedOnRequest( + based_on="e78de69c-c789-44ef-80bf-474b9e63b91d", ), ) @@ -5467,7 +5474,7 @@ client.delivery_notes.patch_delivery_notes_id(
-**memo:** `typing.Optional[str]` — Additional information regarding the delivery note +**memo:** `typing.Optional[str]` — An optional note for the customer, displayed above the line items table in the PDF.
@@ -5840,6 +5847,98 @@ client.pdf_templates.make_default_by_id(
+ + + + +## E-invoicing search +
client.e_invoicing_search.get_einvoice_search(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Checks if the specified VAT number or business number is registered on the PEPPOL network as a receiver. For example, you can use this endpoint to check if an entity's counterparts are registered in PEPPOL before creating e-invoices for those counterparts. + +The lookup is powered by PEPPOL SMPs (Service Metadata Publishers) so it also includes registrations that are not visible in the public PEPPOL directory. + +Both partner tokens and entity user tokens can be used for authentication. + +Production and sandbox lookups are separate. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.e_invoicing_search.get_einvoice_search( + network_identifier="DE010101010", + network_schema="DE:VAT", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**network_identifier:** `str` + +VAT number or business number, depending on the `network_schema` used. VAT numbers must include the country prefix, for example, use `DE010101010` not `10101010`. + +**Note:** This endpoint does not validate the format of VAT numbers and business numbers (such as the length or characters used). Invalid values will return `{"exists": false}`. + +
+
+ +
+
+ +**network_schema:** `EinvoiceSchemaTypeEnum` — [PEPPOL scheme](https://docs.monite.com/e-invoicing/peppol-ids#schemes) name. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
@@ -6524,7 +6623,7 @@ client.entities.create(
-**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments. +**individual:** `typing.Optional[IndividualSchema]` — A set of meta data describing the individual
@@ -6532,7 +6631,7 @@ client.entities.create(
-**website:** `typing.Optional[str]` — A website of the entity +**organization:** `typing.Optional[OrganizationSchema]` — A set of meta data describing the organization
@@ -6540,7 +6639,7 @@ client.entities.create(
-**organization:** `typing.Optional[OrganizationSchema]` — A set of meta data describing the organization +**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments.
@@ -6548,7 +6647,7 @@ client.entities.create(
-**individual:** `typing.Optional[IndividualSchema]` — A set of meta data describing the individual +**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided.
@@ -6556,7 +6655,7 @@ client.entities.create(
-**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. +**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available.
@@ -6564,7 +6663,7 @@ client.entities.create(
-**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. +**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered.
@@ -6572,7 +6671,7 @@ client.entities.create(
-**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. +**website:** `typing.Optional[str]` — A website of the entity
@@ -6720,7 +6819,7 @@ client.entities.patch_entities_me()
-**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments. +**individual:** `typing.Optional[OptionalIndividualSchema]` — A set of meta data describing the individual
@@ -6728,7 +6827,7 @@ client.entities.patch_entities_me()
-**website:** `typing.Optional[str]` — A website of the entity +**organization:** `typing.Optional[OptionalOrganizationSchema]` — A set of meta data describing the organization
@@ -6736,7 +6835,7 @@ client.entities.patch_entities_me()
-**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. +**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments.
@@ -6744,7 +6843,7 @@ client.entities.patch_entities_me()
-**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. +**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided.
@@ -6752,7 +6851,7 @@ client.entities.patch_entities_me()
-**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. +**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available.
@@ -6760,7 +6859,7 @@ client.entities.patch_entities_me()
-**organization:** `typing.Optional[OptionalOrganizationSchema]` — A set of meta data describing the organization +**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered.
@@ -6768,7 +6867,7 @@ client.entities.patch_entities_me()
-**individual:** `typing.Optional[OptionalIndividualSchema]` — A set of meta data describing the individual +**website:** `typing.Optional[str]` — A website of the entity
@@ -6800,7 +6899,15 @@ client.entities.patch_entities_me()
-Retrieve an entity by its ID. +Returns entity information for the specified entity ID. + +This endpoint requires a partner access token and can be used to get any of the partner's entities. + +To get entity information by using an entity user token, use [`GET /entity_users/my_entity`](https://docs.monite.com/api/entities/get-entity-users-my-entity) instead. + +Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings)
@@ -6872,7 +6979,16 @@ client.entities.get_by_id(
-Change the specified fields with the provided values. +Update entity information for the specified entity ID. + +This endpoint requires a partner access token and can be used to update any of the partner's entities. + +To update an entity by using an entity user token, use [`PATCH /entity_users/my_entity`](https://docs.monite.com/api/entities/patch-entity-users-my-entity) instead. + +Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo)
@@ -6936,7 +7052,7 @@ client.entities.update_by_id(
-**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments. +**individual:** `typing.Optional[OptionalIndividualSchema]` — A set of meta data describing the individual
@@ -6944,7 +7060,7 @@ client.entities.update_by_id(
-**website:** `typing.Optional[str]` — A website of the entity +**organization:** `typing.Optional[OptionalOrganizationSchema]` — A set of meta data describing the organization
@@ -6952,7 +7068,7 @@ client.entities.update_by_id(
-**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. +**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments.
@@ -6960,7 +7076,7 @@ client.entities.update_by_id(
-**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. +**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided.
@@ -6968,7 +7084,7 @@ client.entities.update_by_id(
-**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. +**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available.
@@ -6976,7 +7092,7 @@ client.entities.update_by_id(
-**organization:** `typing.Optional[OptionalOrganizationSchema]` — A set of meta data describing the organization +**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered.
@@ -6984,7 +7100,7 @@ client.entities.update_by_id(
-**individual:** `typing.Optional[OptionalIndividualSchema]` — A set of meta data describing the individual +**website:** `typing.Optional[str]` — A website of the entity
@@ -7161,6 +7277,8 @@ client.entities.post_entities_id_deactivate(
Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + +Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission.
@@ -7234,6 +7352,20 @@ core.File` — See core.File for more documentation
+#### 📝 Description + +
+
+ +
+
+ +Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. +
+
+
+
+ #### 🔌 Usage
@@ -7453,7 +7585,14 @@ client.entities.update_partner_metadata_by_id(
-Retrieve all settings for this entity. +Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + +Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.read` permission. + +Related endpoints: + + * [Get next document numbers](https://docs.monite.com/api/entities/get-entities-id-settings-next-document-numbers) + * [Get partner settings](https://docs.monite.com/api/partner-settings/get-settings)
@@ -7525,7 +7664,15 @@ client.entities.get_settings_by_id(
-Change the specified fields with the provided values. +Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + +Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + +Related endpoints: + + * [Update an entity](https://docs.monite.com/api/entities/patch-entities-id) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) + * [Update partner settings](https://docs.monite.com/api/partner-settings/patch-settings)
@@ -7573,7 +7720,7 @@ client.entities.update_settings_by_id(
-**language:** `typing.Optional[LanguageCodeEnum]` +**accounting:** `typing.Optional[AccountingSettings]`
@@ -7581,7 +7728,7 @@ client.entities.update_settings_by_id(
-**currency:** `typing.Optional[CurrencySettingsInput]` +**allow_purchase_order_autolinking:** `typing.Optional[bool]` — Automatically attempt to find a corresponding purchase order for all incoming payables.
@@ -7589,7 +7736,7 @@ client.entities.update_settings_by_id(
-**reminder:** `typing.Optional[RemindersSettings]` +**currency:** `typing.Optional[CurrencySettingsInput]`
@@ -7597,7 +7744,7 @@ client.entities.update_settings_by_id(
-**vat_mode:** `typing.Optional[VatModeEnum]` — Defines whether the prices of products in receivables will already include VAT or not. +**document_ids:** `typing.Optional[DocumentIDsSettingsRequest]`
@@ -7605,7 +7752,7 @@ client.entities.update_settings_by_id(
-**vat_inclusive_discount_mode:** `typing.Optional[VatModeEnum]` — Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. +**document_rendering:** `typing.Optional[DocumentRenderingSettingsInput]` — Settings for rendering documents in PDF format.
@@ -7613,7 +7760,15 @@ client.entities.update_settings_by_id(
-**payment_priority:** `typing.Optional[PaymentPriorityEnum]` — Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. +**generate_paid_invoice_pdf:** `typing.Optional[bool]` + +This setting affects how PDF is generated for accounts receivable invoices that are paid, partially paid, or have credit notes applied. +If this setting is `true`: + + * The totals block in the PDF invoice will include a list of all payments made and credit notes issued. + * Once an invoice becomes fully paid, the payment link and QR code are removed. + +The PDF invoice gets regenerated at the moment when an invoice payment is recorded or a credit note is issued. This PDF is not issued as a separate document, and the original PDF invoice is no longer available.
@@ -7621,7 +7776,7 @@ client.entities.update_settings_by_id(
-**allow_purchase_order_autolinking:** `typing.Optional[bool]` — Automatically attempt to find a corresponding purchase order for all incoming payables. +**language:** `typing.Optional[LanguageCodeEnum]`
@@ -7629,7 +7784,7 @@ client.entities.update_settings_by_id(
-**receivable_edit_flow:** `typing.Optional[ReceivableEditFlow]` +**payables_ocr_auto_tagging:** `typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]]` — Auto tagging settings for all incoming OCR payable documents.
@@ -7637,7 +7792,7 @@ client.entities.update_settings_by_id(
-**document_ids:** `typing.Optional[DocumentIDsSettingsRequest]` +**payables_skip_approval_flow:** `typing.Optional[bool]` — If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status.
@@ -7645,7 +7800,7 @@ client.entities.update_settings_by_id(
-**payables_ocr_auto_tagging:** `typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]]` — Auto tagging settings for all incoming OCR payable documents. +**payment_priority:** `typing.Optional[PaymentPriorityEnum]` — Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences.
@@ -7661,13 +7816,13 @@ client.entities.update_settings_by_id(
-**generate_paid_invoice_pdf:** `typing.Optional[bool]` - -This setting affects how PDF is generated for paid accounts receivable invoices. If set to `true`, once an invoice is fully paid its PDF version is updated to display the amount paid and the payment-related features are removed. +**receivable_edit_flow:** `typing.Optional[ReceivableEditFlow]` -The PDF file gets regenerated at the moment when an invoice becomes paid. It is not issued as a separate document, and the original PDF invoice is no longer available. +[Invoice compliance mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance) for accounts receivable. Possible values: -This field is deprecated and will be replaced by `document_rendering.invoice.generate_paid_invoice_pdf`. + * `compliant` - invoices cannot be edited once issued. + * `non_compliant` - issued invoices can still be edited. + * `partially_compliant` - deprecated mode, should not be used.
@@ -7675,7 +7830,7 @@ This field is deprecated and will be replaced by `document_rendering.invoice.gen
-**accounting:** `typing.Optional[AccountingSettings]` +**reminder:** `typing.Optional[RemindersSettings]`
@@ -7683,7 +7838,7 @@ This field is deprecated and will be replaced by `document_rendering.invoice.gen
-**payables_skip_approval_flow:** `typing.Optional[bool]` — If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. +**vat_inclusive_discount_mode:** `typing.Optional[VatModeEnum]` — Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT.
@@ -7691,7 +7846,7 @@ This field is deprecated and will be replaced by `document_rendering.invoice.gen
-**document_rendering:** `typing.Optional[DocumentRenderingSettings]` — Settings for rendering documents in PDF format. +**vat_mode:** `typing.Optional[VatModeEnum]` — Defines whether the prices of products in receivables will already include VAT or not.
@@ -7711,7 +7866,7 @@ This field is deprecated and will be replaced by `document_rendering.invoice.gen
-
client.entities.upload_onboarding_documents(...) +
client.entities.get_entities_id_settings_next_document_numbers(...)
@@ -7723,7 +7878,11 @@ This field is deprecated and will be replaced by `document_rendering.invoice.gen
-Provide files for entity onboarding verification +Returns the next sequence number for various document types - invoices, quotes, credit notes, and others. For example, if the last issued invoice is `INV-00042`, the next invoice number is 43. + +To set the next document numbers, use `PATCH /entities/{entity_id}/settings`. + +For more information, see [Document number customization](https://docs.monite.com/advanced/document-number-customization).
@@ -7745,7 +7904,9 @@ client = Monite( monite_entity_id="YOUR_MONITE_ENTITY_ID", token="YOUR_TOKEN", ) -client.entities.upload_onboarding_documents() +client.entities.get_entities_id_settings_next_document_numbers( + entity_id="entity_id", +) ``` @@ -7761,7 +7922,7 @@ client.entities.upload_onboarding_documents()
-**additional_verification_document_back:** `typing.Optional[str]` +**entity_id:** `str` — Unique ID of the entity
@@ -7769,31 +7930,101 @@ client.entities.upload_onboarding_documents()
-**additional_verification_document_front:** `typing.Optional[str]` +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
-
-
-**bank_account_ownership_verification:** `typing.Optional[typing.Sequence[str]]` -
+
+
client.entities.upload_onboarding_documents(...)
-**company_license:** `typing.Optional[typing.Sequence[str]]` - -
-
+#### 📝 Description
-**company_memorandum_of_association:** `typing.Optional[typing.Sequence[str]]` +
+
+ +Provide files for entity onboarding verification +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.entities.upload_onboarding_documents() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**additional_verification_document_back:** `typing.Optional[str]` + +
+
+ +
+
+ +**additional_verification_document_front:** `typing.Optional[str]` + +
+
+ +
+
+ +**bank_account_ownership_verification:** `typing.Optional[typing.Sequence[str]]` + +
+
+ +
+
+ +**company_license:** `typing.Optional[typing.Sequence[str]]` + +
+
+ +
+
+ +**company_memorandum_of_association:** `typing.Optional[typing.Sequence[str]]`
@@ -8171,7 +8402,7 @@ client.entity_users.create(
-**first_name:** `str` — First name +**first_name:** `str` — The user's first name.
@@ -8180,6 +8411,10 @@ client.entity_users.create(
**login:** `str` + +The username assigned to this user. Usernames must be unique within the entity. + +The `login` value is not used by Monite but may be used by partner applications, for example, to map the users between the partner's platform and Monite.
@@ -8187,7 +8422,7 @@ client.entity_users.create(
-**email:** `typing.Optional[str]` — An entity user business email +**email:** `typing.Optional[str]` — The user's business email address.
@@ -8195,7 +8430,7 @@ client.entity_users.create(
-**last_name:** `typing.Optional[str]` — Last name +**last_name:** `typing.Optional[str]` — The user's last name.
@@ -8203,7 +8438,7 @@ client.entity_users.create(
-**phone:** `typing.Optional[str]` — An entity user phone number in the international format +**phone:** `typing.Optional[str]` — The user's phone number.
@@ -8211,7 +8446,7 @@ client.entity_users.create(
-**role_id:** `typing.Optional[str]` — UUID of the role assigned to this entity user +**role_id:** `typing.Optional[str]` — ID of the role to assign to this user. The role defines the user's [access permissions](https://docs.monite.com/api/concepts/authentication#permissions) within the entity. Each user has just one role.
@@ -8219,7 +8454,7 @@ client.entity_users.create(
-**title:** `typing.Optional[str]` — Title +**title:** `typing.Optional[str]` — The user's job title.
@@ -8251,7 +8486,7 @@ client.entity_users.create(
-Retrieve an entity user by its ID. +The user ID is inferred fron the `Authorization` header, which must contain a user-level access token.
@@ -8313,7 +8548,7 @@ client.entity_users.get_current()
-Change the specified fields with provided values. +The user ID is inferred fron the `Authorization` header, which must contain a user-level access token.
@@ -8351,7 +8586,7 @@ client.entity_users.update_current()
-**email:** `typing.Optional[str]` — An entity user business email +**email:** `typing.Optional[str]` — The user's business email address.
@@ -8359,7 +8594,7 @@ client.entity_users.update_current()
-**first_name:** `typing.Optional[str]` — First name +**first_name:** `typing.Optional[str]` — The user's first name.
@@ -8367,7 +8602,7 @@ client.entity_users.update_current()
-**last_name:** `typing.Optional[str]` — Last name +**last_name:** `typing.Optional[str]` — The user's last name.
@@ -8375,7 +8610,7 @@ client.entity_users.update_current()
-**phone:** `typing.Optional[str]` — An entity user phone number in the international format +**phone:** `typing.Optional[str]` — The user's phone number.
@@ -8383,7 +8618,7 @@ client.entity_users.update_current()
-**title:** `typing.Optional[str]` — Title +**title:** `typing.Optional[str]` — The user's job title.
@@ -8415,7 +8650,13 @@ client.entity_users.update_current()
-Retrieves information of an entity, which this entity user belongs to. +Returns the entity to which the authenticated user belongs. This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.read` permission. + +To get an entity by using a partner access token, use [`GET /entities/{entity_id}`](https://docs.monite.com/api/entities/get-entities-id) instead. + +Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings)
@@ -8477,7 +8718,16 @@ client.entity_users.get_current_entity()
-Update information of an entity, which this entity user belongs to. +Update the entity to which the authenticated user belongs. + +This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.update` permission. + +This endpoint does not use the `X-Monite-Entity-Id` header. The entity ID is inferred from the access token. + +Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo)
@@ -8531,7 +8781,7 @@ client.entity_users.update_current_entity()
-**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments. +**individual:** `typing.Optional[OptionalIndividualSchema]` — A set of meta data describing the individual
@@ -8539,7 +8789,7 @@ client.entity_users.update_current_entity()
-**website:** `typing.Optional[str]` — A website of the entity +**organization:** `typing.Optional[OptionalOrganizationSchema]` — A set of meta data describing the organization
@@ -8547,7 +8797,7 @@ client.entity_users.update_current_entity()
-**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. +**phone:** `typing.Optional[str]` — The contact phone number of the entity. Required for US organizations to use payments.
@@ -8555,7 +8805,7 @@ client.entity_users.update_current_entity()
-**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. +**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided.
@@ -8563,7 +8813,7 @@ client.entity_users.update_current_entity()
-**registration_authority:** `typing.Optional[str]` — (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. +**registration_number:** `typing.Optional[str]` — (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available.
@@ -8571,7 +8821,7 @@ client.entity_users.update_current_entity()
-**organization:** `typing.Optional[OptionalOrganizationSchema]` — A set of meta data describing the organization +**tax_id:** `typing.Optional[str]` — The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered.
@@ -8579,7 +8829,7 @@ client.entity_users.update_current_entity()
-**individual:** `typing.Optional[OptionalIndividualSchema]` — A set of meta data describing the individual +**website:** `typing.Optional[str]` — A website of the entity
@@ -8851,7 +9101,7 @@ client.entity_users.update_by_id(
-**email:** `typing.Optional[str]` — An entity user business email +**email:** `typing.Optional[str]` — The user's business email address.
@@ -8859,7 +9109,7 @@ client.entity_users.update_by_id(
-**first_name:** `typing.Optional[str]` — First name +**first_name:** `typing.Optional[str]` — The user's first name.
@@ -8867,7 +9117,7 @@ client.entity_users.update_by_id(
-**last_name:** `typing.Optional[str]` — Last name +**last_name:** `typing.Optional[str]` — The user's last name.
@@ -8875,7 +9125,7 @@ client.entity_users.update_by_id(
-**login:** `typing.Optional[str]` — Login +**login:** `typing.Optional[str]` — The new username for this user. Must be unique within the entity.
@@ -8883,7 +9133,7 @@ client.entity_users.update_by_id(
-**phone:** `typing.Optional[str]` — An entity user phone number in the international format +**phone:** `typing.Optional[str]` — The user's phone number.
@@ -8891,7 +9141,7 @@ client.entity_users.update_by_id(
-**role_id:** `typing.Optional[str]` — UUID of the role assigned to this entity user +**role_id:** `typing.Optional[str]` — ID of the new role to assign to this user. The new role takes effect immediately, existing access tokens of this user are not invalidated.
@@ -8899,7 +9149,7 @@ client.entity_users.update_by_id(
-**title:** `typing.Optional[str]` — Title +**title:** `typing.Optional[str]` — The user's job title.
@@ -9139,6 +9389,29 @@ client.events.get_by_id(
+#### 📝 Description + +
+
+ +
+
+ +The `/files` endpoint provides access to an entity's files hosted on Monite's servers. This includes both files uploaded by the entity and files that were automatically created by Monite (such as PDF versions of invoices). + +`GET /files` requires at least one query parameter, either `id__in` or `file_type`. You can use this operation to: + + * Bulk fetch multiple files by IDs. + * Get all files with the given purpose (for example, invoice attachments). + +If no files matching the query parameters were found, the response contains an empty `data` array. + +Both partner tokens and entity user tokens can be used for authentication. +
+
+
+
+ #### 🔌 Usage
@@ -9172,6 +9445,31 @@ client.files.get()
**id_in:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +Return only files with specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. + +To specify multiple IDs, repeat this parameter for each value: `id__in=&id__in=` + +
+
+ +
+
+ +**file_type:** `typing.Optional[AllowedFileTypes]` + +Return only files with the given purpose. Possible values: + + * `additional_identity_documents` and `identity_documents` - [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) uploaded for payments onboarding. + * `attachments` - supplementary attachments for accounts receivable invoices, quotes, and credit notes. + * `delivery_notes` - auto-generated PDF versions of delivery notes. + * `einvoices_xml` - e-invoice XML generated when sending e-invoices. + * `payables` - payables (bills) received via email or uploaded via API. + * `receivable_signatures` - images of customer signatures provided during quote acceptance. + * `receivables` - auto-generated PDF versions of invoices, quotes, and credit notes. + * `zip` - data export archives created by `POST /data_exports`. + +Other values are unused.
@@ -9195,6 +9493,27 @@ client.files.get()
+#### 📝 Description + +
+
+ +
+
+ +Upload files for use as: + + * supplementary attachments for invoices, quotes, and credit notes, + * [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) for payments onboarding. + +Maximum file size is 15 MB. Each uploaded file is assigned a unique `id` that you can use to reference this file elsewhere. + +Both partner tokens and entity user tokens can be used for authentication. +
+
+
+
+ #### 🔌 Usage
@@ -9240,6 +9559,14 @@ core.File` — See core.File for more documentation
**file_type:** `AllowedFileTypes` + +The intended purpose of the file. Possible values: + + * `attachments` - supplemental attachments for accounts receivable invoices, quotes, and credit notes. + * `identity_documents` - company registration documents or a person's identity documents for payments onboarding. + * `additional_identity_documents` - documents that verify a person's address. + +Other enum values are not supposed to be used directly.
@@ -9263,6 +9590,22 @@ core.File` — See core.File for more documentation
+#### 📝 Description + +
+
+ +
+
+ +Returns the details of an existing file. To bulk fetch multiple files by their IDs, use `GET /files?id__in=&id__in=`. + +Both partner tokens and entity user tokens can be used for authentication. +
+
+
+
+ #### 🔌 Usage
@@ -9321,6 +9664,26 @@ client.files.get_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Delete a file with the specified ID. + +**Note:** This endpoint does not check if the specified file is in use. Use with caution. + +Both partner tokens and entity user tokens can be used for authentication. +#### Considerations for invoice attachments +Deleting a file does not delete it from the `attachments` list of accounts receivable invoices, quotes, and credit notes because these documents contain an inline copy of all referenced resources. To delete a file from attachments, call `PATCH /receivables/{receivable_id}` and update the `attachments` list to exclude the deleted file. +
+
+
+
+ #### 🔌 Usage
@@ -9355,7 +9718,7 @@ client.files.delete(
-**file_id:** `str` +**file_id:** `str` — ID of the file you want to delete.
@@ -9928,7 +10291,7 @@ client.mail_templates.get()
-**order:** `typing.Optional[OrderEnum]` — Order by +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -9952,7 +10315,7 @@ client.mail_templates.get()
-**sort:** `typing.Optional[CustomTemplatesCursorFields]` — Allowed sort fields +**sort:** `typing.Optional[CustomTemplatesCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -11021,6 +11384,7 @@ client = Monite( client.mailboxes.create( mailbox_domain_id="mailbox_domain_id", mailbox_name="mailbox_name", + related_object_type="payable", ) ``` @@ -11053,6 +11417,14 @@ client.mailboxes.create(
+**related_object_type:** `MailboxObjectTypeEnum` — Related object type: payable and so on + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -16932,7 +17304,7 @@ client.payables.reset_validations()
-Get a list of placeholders allowed to insert into an email template for customization +Returns a list of placeholders that can be used to personalize email templates related to payables. These include payables attributes such as `currency`, `customer_name`, `document_id`, `due_date`, `invoice_id`, `total_amount`, and `uploaded_username`.
@@ -17186,6 +17558,14 @@ client.payables.update_by_id(
+**amount_paid:** `typing.Optional[int]` — How much was paid on the invoice (in minor units). + +
+
+ +
+
+ **counterpart_address_id:** `typing.Optional[str]` — The ID of counterpart address object stored in counterparts service
@@ -17676,6 +18056,20 @@ client.payables.post_payables_id_cancel_ocr(
+#### 📝 Description + +
+
+ +
+
+ +Returns a chronological list of events related to the specified payable. This includes changes in status, updates to data, comments, and actions taken by users or automation rules. +
+
+
+
+ #### 🔌 Usage
@@ -17710,7 +18104,7 @@ client.payables.get_payables_id_history(
-**payable_id:** `str` +**payable_id:** `str` — The unique identifier of the payable whose history you want to retrieve.
@@ -18111,7 +18505,7 @@ client.payables.reject_by_id(
-Reset payable state from rejected to new. +Moves payables in the `rejected` or `waiting_to_be_paid` statuses back to `new`, allowing further actions such as editing, approval, or payment. The
@@ -18151,7 +18545,7 @@ client.payables.reopen_by_id(
-**payable_id:** `str` +**payable_id:** `str` — The unique identifier of the payable you want to reopen.
@@ -18243,7 +18637,7 @@ client.payables.submit_for_approval_by_id(
-
client.payables.validate_by_id(...) +
client.payables.get_payables_id_suggestions(...)
@@ -18255,7 +18649,13 @@ client.payables.submit_for_approval_by_id(
-Check the invoice for compliance with the requirements for movement from draft to new status. +Retrieves the most likely matching counterpart for a given payable, based on an AI-powered analysis of the payable's data. + +When a user uploads a payable, Monite automatically compares key fields—such as `name`, `address`, `VAT ID`, and bank `account`—against existing counterparts. If a sufficiently similar match is found, this endpoint will return a suggested counterpart. + +If no suitable match is identified, the response will be empty. + +**Note:** Suggestions are automatically generated during payable upload. This endpoint simply retrieves the existing suggestion for a specific payable.
@@ -18277,7 +18677,7 @@ client = Monite( monite_entity_id="YOUR_MONITE_ENTITY_ID", token="YOUR_TOKEN", ) -client.payables.validate_by_id( +client.payables.get_payables_id_suggestions( payable_id="payable_id", ) @@ -18295,7 +18695,7 @@ client.payables.validate_by_id(
-**payable_id:** `str` +**payable_id:** `str` — The unique identifier of the payable you want to find matching suggestions for.
@@ -18315,11 +18715,24 @@ client.payables.validate_by_id(
-## Payment intents -
client.payment_intents.get(...) +
client.payables.delete_payables_id_suggestions(...) +
+
+ +#### 📝 Description + +
+
+
+Deletes the automatically generated counterpart suggestion for a specific payable. +
+
+
+
+ #### 🔌 Usage
@@ -18336,7 +18749,9 @@ client = Monite( monite_entity_id="YOUR_MONITE_ENTITY_ID", token="YOUR_TOKEN", ) -client.payment_intents.get() +client.payables.delete_payables_id_suggestions( + payable_id="payable_id", +) ```
@@ -18352,7 +18767,7 @@ client.payment_intents.get()
-**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter. +**payable_id:** `str` — The unique identifier of the payable whose suggestions you want to delete.
@@ -18360,36 +18775,165 @@ client.payment_intents.get()
-**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
-
-
- -**pagination_token:** `typing.Optional[str]` - -A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. -If not specified, the first page of results will be returned. -
+
+
client.payables.validate_by_id(...)
-**sort:** `typing.Optional[PaymentIntentCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter. - -
-
+#### 📝 Description
-**object_id:** `typing.Optional[str]` — ID of a payable or receivable invoice. If provided, returns only payment intents associated with the specified invoice. - +
+
+ +Check the invoice for compliance with the requirements for movement from draft to new status. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.payables.validate_by_id( + payable_id="payable_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payable_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + + + +
+ +## Payment intents +
client.payment_intents.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.payment_intents.get() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + +
+
+ +
+
+ +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned. + +
+
+ +
+
+ +**sort:** `typing.Optional[PaymentIntentCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter. + +
+
+ +
+
+ +**object_id:** `typing.Optional[str]` — ID of a payable or receivable invoice. If provided, returns only payment intents associated with the specified invoice. +
@@ -18604,6 +19148,20 @@ client.payment_intents.get_history_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Create a new [payment link](https://docs.monite.com/payments/payment-links) for an accounts payble invoice (to be paid by the entity) or an accounts receivable invoice (to be sent to the counterpart). +
+
+
+
+ #### 🔌 Usage
@@ -18613,7 +19171,9 @@ client.payment_intents.get_history_by_id(
```python -from monite import Monite, PaymentAccountObject +import datetime + +from monite import Invoice, InvoiceFile, Monite, PaymentAccountObject client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -18621,11 +19181,27 @@ client = Monite( token="YOUR_TOKEN", ) client.payment_links.create( - payment_methods=["sepa_credit"], + amount=12500, + currency="EUR", + expires_at=datetime.datetime.fromisoformat( + "2025-08-30 23:59:59+00:00", + ), + invoice=Invoice( + due_date="2025-07-31", + file=InvoiceFile( + mimetype="application/pdf", + name="invoice.pdf", + url="https://example.com/path/to/invoice.pdf", + ), + issue_date="2025-07-01", + ), + payment_methods=["card", "eps", "ideal", "sepa_credit", "sepa_debit"], + payment_reference="INV/2025/0042", recipient=PaymentAccountObject( - id="id", + id="274b995b-1906-4d8a-b7fe-e8d822d731b0", type="entity", ), + return_url="https://example.com/where-to-redirect-after-payment", ) ``` @@ -18643,6 +19219,10 @@ client.payment_links.create(
**payment_methods:** `typing.Sequence[MoniteAllPaymentMethodsTypes]` + +Payment methods to be displayed on the payment page. These payment methods must already be enabled for the entity. + +**Note:** Available payment methods vary per country, transaction type (B2B or B2C), and the payment link type (entity pays a bill or entity generates an invoice payment link for its counterpart). For more information, see [Payment methods](https://docs.monite.com/payments/payment-methods).
@@ -18650,7 +19230,7 @@ client.payment_links.create(
-**recipient:** `PaymentAccountObject` +**recipient:** `PaymentAccountObject` — Specifies the invoice vendor - entity or counterpart. This is the payee, or the recipient of the payment.
@@ -18658,7 +19238,16 @@ client.payment_links.create(
-**amount:** `typing.Optional[int]` — The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). Required if `object` is not specified. +**amount:** `typing.Optional[int]` + +The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). The usage of the `amount` field depends on the type of the payment link you are creating: + + * If the `invoice` object is specified (that is, when creating a payment link for an external invoice), + `amount` is required. + * If `object` is specified: + * If `object.type` is `payable`, `amount` must not be specified since it's taken from the payable. + * If `object.type` is `receivable`, you can provide a custom `amount` value to create a partial payment link. + In this case, the `amount` value must not exceed the invoice's `amount_to_pay` minus all active payment links.
@@ -18666,7 +19255,7 @@ client.payment_links.create(
-**currency:** `typing.Optional[CurrencyEnum]` — The payment currency. Required if `object` is not specified. +**currency:** `typing.Optional[CurrencyEnum]` — The payment currency. Mutually exclusive with `object`.
@@ -18675,6 +19264,14 @@ client.payment_links.create(
**expires_at:** `typing.Optional[dt.datetime]` + +Date and time (in the ISO 8601 format) when this payment link will expire. Can be up to 70 days from the current date and time. +If omitted: + + * Payment links for payables and receivables expire 30 days after the invoice due date. + * Payment links for external invoices expire 30 days after the link creation time. + +For more information, see [Payment link expiration](https://docs.monite.com/payments/payment-links#expiration).
@@ -18682,7 +19279,7 @@ client.payment_links.create(
-**invoice:** `typing.Optional[Invoice]` — An object containing information about the invoice being paid. Used only if `object` is not specified. +**invoice:** `typing.Optional[Invoice]` — An object containing information about an external invoice to be paid. Mutually exclusive with `object`.
@@ -18698,7 +19295,7 @@ client.payment_links.create(
-**payment_reference:** `typing.Optional[str]` — A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Required if `object` is not specified. +**payment_reference:** `typing.Optional[str]` — A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Mutually exclusive with `object`.
@@ -18879,7 +19476,7 @@ client.payment_records.get()
-**order:** `typing.Optional[OrderEnum]` — Order by +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -18903,7 +19500,7 @@ client.payment_records.get()
-**sort:** `typing.Optional[PaymentRecordCursorFields]` — Allowed sort fields +**sort:** `typing.Optional[PaymentRecordCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -19094,7 +19691,6 @@ client.payment_records.create( id="id", type="receivable", ), - payment_intent_id="payment_intent_id", ) ``` @@ -19135,7 +19731,7 @@ client.payment_records.create(
-**payment_intent_id:** `str` — Identifier for an payment intent. +**entity_user_id:** `typing.Optional[str]` — ID of the user associated with the payment, if applicable.
@@ -19143,7 +19739,7 @@ client.payment_records.create(
-**entity_user_id:** `typing.Optional[str]` — ID of the user associated with the payment, if applicable. +**paid_at:** `typing.Optional[dt.datetime]` — Timestamp marking when the payment was executed. Null if payment hasn't occurred yet.
@@ -19151,7 +19747,7 @@ client.payment_records.create(
-**paid_at:** `typing.Optional[dt.datetime]` — Timestamp marking when the payment was executed. Null if payment hasn't occurred yet. +**payment_intent_id:** `typing.Optional[str]` — Identifier for an payment intent.
@@ -20017,7 +20613,7 @@ client.payment_terms.get()
```python -from monite import Monite, TermFinalDays +from monite import Monite, TermDiscountDays, TermFinalDays client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -20025,9 +20621,18 @@ client = Monite( token="YOUR_TOKEN", ) client.payment_terms.create( - name="name", + description="The invoice must be paid within 30 days. 2% discount if paid within the first 10 days, 1% discount if paid within 20 days.", + name="2/10, 1/20, Net 30", + term1=TermDiscountDays( + discount=200, + number_of_days=10, + ), + term2=TermDiscountDays( + discount=100, + number_of_days=20, + ), term_final=TermFinalDays( - number_of_days=1, + number_of_days=30, ), ) @@ -21203,7 +21808,7 @@ client.projects.create(
-**code:** `typing.Optional[str]` — Project code +**code:** `typing.Optional[str]` — A user-defined identifier of this project.
@@ -21211,7 +21816,7 @@ client.projects.create(
-**color:** `typing.Optional[str]` — Project color +**color:** `typing.Optional[str]` — Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data.
@@ -21219,7 +21824,7 @@ client.projects.create(
-**description:** `typing.Optional[str]` — Description of project +**description:** `typing.Optional[str]` — A user-defined description of the project.
@@ -21227,7 +21832,7 @@ client.projects.create(
-**end_date:** `typing.Optional[str]` — Project end date +**end_date:** `typing.Optional[str]` — Project end date. If specified, must be later than or equal to the start date.
@@ -21235,7 +21840,7 @@ client.projects.create(
-**parent_id:** `typing.Optional[str]` — Parent project ID +**parent_id:** `typing.Optional[str]` — Unused. Reserved for future use.
@@ -21243,7 +21848,7 @@ client.projects.create(
-**partner_metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Project metadata +**partner_metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — [Metadata](https://docs.monite.com/common/metadata) for partner needs.
@@ -21251,7 +21856,7 @@ client.projects.create(
-**start_date:** `typing.Optional[str]` — Project start date +**start_date:** `typing.Optional[str]` — Project start date.
@@ -21483,7 +22088,7 @@ client.projects.update_by_id(
-**code:** `typing.Optional[str]` — Project code +**code:** `typing.Optional[str]` — A user-defined identifier of this project.
@@ -21491,7 +22096,7 @@ client.projects.update_by_id(
-**color:** `typing.Optional[str]` — Project color +**color:** `typing.Optional[str]` — Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data.
@@ -21499,7 +22104,7 @@ client.projects.update_by_id(
-**description:** `typing.Optional[str]` — Description of project +**description:** `typing.Optional[str]` — A user-defined description of the project.
@@ -21507,7 +22112,7 @@ client.projects.update_by_id(
-**end_date:** `typing.Optional[str]` — Project end date +**end_date:** `typing.Optional[str]` — Project end date. If specified, must be later than or equal to the start date.
@@ -21523,7 +22128,7 @@ client.projects.update_by_id(
-**parent_id:** `typing.Optional[str]` — Parent project ID +**parent_id:** `typing.Optional[str]` — Unused. Reserved for future use.
@@ -21531,7 +22136,7 @@ client.projects.update_by_id(
-**partner_metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Project metadata +**partner_metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — [Metadata](https://docs.monite.com/common/metadata) for partner needs.
@@ -21539,7 +22144,7 @@ client.projects.update_by_id(
-**start_date:** `typing.Optional[str]` — Project start date +**start_date:** `typing.Optional[str]` — Project start date.
@@ -21567,90 +22172,11 @@ client.projects.update_by_id(
-## Receivables -
client.receivables.get(...) -
-
- -#### 📝 Description - -
-
- +## Receipts +
client.receipts.get_receipts(...)
-Returns a list of [accounts receivable](https://docs.monite.com/accounts-receivable/index) documents - invoices, quotes, and credit notes - of the specified entity. - -Results can be filtered by amount, counterpart, due date, and other criteria. Multiple filters are combined using logical AND unless specified otherwise. If no documents matching the search criteria are found, the endpoint returns a successful response with an empty `data` array. - -This endpoint supports [pagination](https://docs.monite.com/api/concepts/pagination-sorting-filtering) and sorting. By default, results are sorted by the creation date in ascending order (from oldest to newest). - -#### Examples - -##### Invoices - -* Get all overdue invoices: - ``` - GET /receivables?type=invoice&status=overdue - ``` - -* Get all invoices created for the counterpart named "Solarwind" (case-insensitive): - - ``` - GET /receivables?type=invoice?counterpart_name__icontains=Solarwind - ``` - -* Get invoices whose total amount starts from 500 EUR: - - ``` - GET /receivables?type=invoice&total_amount__gte=50000 - ``` - -* Get invoices that are due for payment in September 2024: - - ``` - GET /receivables?type=invoice&due_date__gte=2024-09-01T00:00:00Z&due_date__lt=2024-10-01T00:00:00Z - ``` - -* Get invoices created on or after September 1, 2024: - - ``` - GET /receivables?type=invoice&created_at__gte=2024-09-01T00:00:00Z - ``` - -* Find an invoice created from a specific quote: - - ``` - GET /receivables?type=invoice?based_on=QUOTE_ID - ``` - -##### Quotes - -* Get the latest created quote: - - ``` - GET /receivables?type=quote&sort=created_at&order=desc&limit=1 - ``` - -* Get the latest issued quote: - - ``` - GET /receivables?type=quote&sort=issue_date&order=desc&limit=1 - ``` - -##### Credit notes - -* Find all credit notes created for a specific invoice: - - ``` - GET /receivables?type=credit_note?based_on=INVOICE_ID - ``` -
-
-
-
- #### 🔌 Usage
@@ -21667,7 +22193,1265 @@ client = Monite( monite_entity_id="YOUR_MONITE_ENTITY_ID", token="YOUR_TOKEN", ) -client.receivables.get() +client.receipts.get_receipts() + +``` +
+
+ + + +#### ⚙️ Parameters + +
+
+ +
+
+ +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + +
+
+ +
+
+ +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned. + +
+
+ +
+
+ +**sort:** `typing.Optional[ReceiptCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter. + +
+
+ +
+
+ +**created_at_gt:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**created_at_lt:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**created_at_gte:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**created_at_lte:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**id_in:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**currency:** `typing.Optional[CurrencyEnum]` + +
+
+ +
+
+ +**document_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**document_id_contains:** `typing.Optional[str]` + +
+
+ +
+
+ +**document_id_icontains:** `typing.Optional[str]` + +
+
+ +
+
+ +**total_amount_gt:** `typing.Optional[int]` + +
+
+ +
+
+ +**total_amount_lt:** `typing.Optional[int]` + +
+
+ +
+
+ +**total_amount_gte:** `typing.Optional[int]` + +
+
+ +
+
+ +**total_amount_lte:** `typing.Optional[int]` + +
+
+ +
+
+ +**has_file:** `typing.Optional[bool]` + +
+
+ +
+
+ +**has_transaction:** `typing.Optional[bool]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + + + +
+ +
client.receipts.post_receipts(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.post_receipts() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**base64encoded_file:** `typing.Optional[str]` — Base64-encoded contents of the original receipt file. + +
+
+ +
+
+ +**currency:** `typing.Optional[CurrencyEnum]` — Currency code used in the receipt. + +
+
+ +
+
+ +**document_id:** `typing.Optional[str]` — Unique receipt number assigned by the issuer. + +
+
+ +
+
+ +**issued_at:** `typing.Optional[dt.datetime]` — Receipt issued date and time. + +
+
+ +
+
+ +**merchant_location:** `typing.Optional[str]` — Location of the merchant. + +
+
+ +
+
+ +**merchant_name:** `typing.Optional[str]` — Name of the merchant. + +
+
+ +
+
+ +**total_amount:** `typing.Optional[int]` — Total amount for the receipt in minor units (e.g. cents). + +
+
+ +
+
+ +**transaction_id:** `typing.Optional[str]` — Transaction ID. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.post_receipts_upload_from_file(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Upload an incoming receipt in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.post_receipts_upload_from_file() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file:** `from __future__ import annotations + +core.File` — See core.File for more documentation + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.get_receipts_id(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.get_receipts_id( + receipt_id="receipt_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.delete_receipts_id(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.delete_receipts_id( + receipt_id="receipt_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.patch_receipts_id(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.patch_receipts_id( + receipt_id="receipt_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**base64encoded_file:** `typing.Optional[str]` — Base64-encoded file contents. + +
+
+ +
+
+ +**currency:** `typing.Optional[CurrencyEnum]` — Currency code. + +
+
+ +
+
+ +**document_id:** `typing.Optional[str]` — Receipt number. + +
+
+ +
+
+ +**issued_at:** `typing.Optional[dt.datetime]` — Date when the receipt was issued. + +
+
+ +
+
+ +**merchant_location:** `typing.Optional[str]` — Merchant location. + +
+
+ +
+
+ +**merchant_name:** `typing.Optional[str]` — Merchant name. + +
+
+ +
+
+ +**total_amount:** `typing.Optional[int]` — Total amount. + +
+
+ +
+
+ +**transaction_id:** `typing.Optional[str]` — Transaction ID. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.post_receipts_id_attach_file(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Attach file to receipt without existing attachment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.post_receipts_id_attach_file( + receipt_id="receipt_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**file:** `from __future__ import annotations + +core.File` — See core.File for more documentation + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.get_receipts_id_line_items(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.get_receipts_id_line_items( + receipt_id="receipt_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + +
+
+ +
+
+ +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned. + +
+
+ +
+
+ +**sort:** `typing.Optional[ReceiptLineItemCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter. + +
+
+ +
+
+ +**created_at_gt:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**created_at_lt:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**created_at_gte:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**created_at_lte:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**name_iexact:** `typing.Optional[str]` + +
+
+ +
+
+ +**name_contains:** `typing.Optional[str]` + +
+
+ +
+
+ +**name_icontains:** `typing.Optional[str]` + +
+
+ +
+
+ +**total_gt:** `typing.Optional[int]` + +
+
+ +
+
+ +**total_lt:** `typing.Optional[int]` + +
+
+ +
+
+ +**total_gte:** `typing.Optional[int]` + +
+
+ +
+
+ +**total_lte:** `typing.Optional[int]` + +
+
+ +
+
+ +**created_by_user_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.post_receipts_id_line_items(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.post_receipts_id_line_items( + receipt_id="receipt_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**accounting_tax_rate_id:** `typing.Optional[str]` — Accounting tax rate ID. + +
+
+ +
+
+ +**cost_center_id:** `typing.Optional[str]` — Cost center ID. + +
+
+ +
+
+ +**general_ledger_id:** `typing.Optional[str]` — General ledger ID. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Line item name/description. + +
+
+ +
+
+ +**total:** `typing.Optional[int]` — Line item total in minor units. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.delete_receipts_id_line_items_id(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.delete_receipts_id_line_items_id( + receipt_id="receipt_id", + line_item_id="line_item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**line_item_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.receipts.patch_receipts_id_line_items_id(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receipts.patch_receipts_id_line_items_id( + receipt_id="receipt_id", + line_item_id="line_item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receipt_id:** `str` + +
+
+ +
+
+ +**line_item_id:** `str` + +
+
+ +
+
+ +**accounting_tax_rate_id:** `typing.Optional[str]` — Accounting tax rate ID. + +
+
+ +
+
+ +**cost_center_id:** `typing.Optional[str]` — Cost center ID. + +
+
+ +
+
+ +**general_ledger_id:** `typing.Optional[str]` — General ledger ID. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Line item name/description. + +
+
+ +
+
+ +**total:** `typing.Optional[int]` — Line item total in minor units. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Receivables +
client.receivables.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of [accounts receivable](https://docs.monite.com/accounts-receivable/index) documents - invoices, quotes, and credit notes - of the specified entity. + +Results can be filtered by amount, counterpart, due date, and other criteria. Multiple filters are combined using logical AND unless specified otherwise. If no documents matching the search criteria are found, the endpoint returns a successful response with an empty `data` array. + +This endpoint supports [pagination](https://docs.monite.com/api/concepts/pagination-sorting-filtering) and sorting. By default, results are sorted by the creation date in ascending order (from oldest to newest). + +#### Examples + +##### Invoices + +* Get all overdue invoices: + ``` + GET /receivables?type=invoice&status=overdue + ``` + +* Get all invoices created for the counterpart named "Solarwind" (case-insensitive): + + ``` + GET /receivables?type=invoice?counterpart_name__icontains=Solarwind + ``` + +* Get invoices whose total amount starts from 500 EUR: + + ``` + GET /receivables?type=invoice&total_amount__gte=50000 + ``` + +* Get invoices that are due for payment in September 2024: + + ``` + GET /receivables?type=invoice&due_date__gte=2024-09-01T00:00:00Z&due_date__lt=2024-10-01T00:00:00Z + ``` + +* Get invoices created on or after September 1, 2024: + + ``` + GET /receivables?type=invoice&created_at__gte=2024-09-01T00:00:00Z + ``` + +* Find an invoice created from a specific quote: + + ``` + GET /receivables?type=invoice?based_on=QUOTE_ID + ``` + +##### Quotes + +* Get the latest created quote: + + ``` + GET /receivables?type=quote&sort=created_at&order=desc&limit=1 + ``` + +* Get the latest issued quote: + + ``` + GET /receivables?type=quote&sort=issue_date&order=desc&limit=1 + ``` + +##### Credit notes + +* Find all credit notes created for a specific invoice: + + ``` + GET /receivables?type=credit_note?based_on=INVOICE_ID + ``` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from monite import Monite + +client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", +) +client.receivables.get() ```
@@ -21865,7 +23649,7 @@ For example, given receivables with the following product IDs:
-**type:** `typing.Optional[ReceivableType]` +**type:** `typing.Optional[ReceivableType]` — Return only receivables of the specified type. Use this parameter to get only invoices, or only quotes, or only credit notes.
@@ -21873,7 +23657,7 @@ For example, given receivables with the following product IDs:
-**document_id:** `typing.Optional[str]` +**document_id:** `typing.Optional[str]` — Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`).
@@ -21881,7 +23665,7 @@ For example, given receivables with the following product IDs:
-**document_id_contains:** `typing.Optional[str]` +**document_id_contains:** `typing.Optional[str]` — Return only receivables whose document number (`document_id`) contains the specified string (case-sensitive).
@@ -21889,7 +23673,7 @@ For example, given receivables with the following product IDs:
-**document_id_icontains:** `typing.Optional[str]` +**document_id_icontains:** `typing.Optional[str]` — Return only receivables whose document number (`document_id`) contains the specified string (case-insensitive).
@@ -21897,7 +23681,7 @@ For example, given receivables with the following product IDs:
-**issue_date_gt:** `typing.Optional[dt.datetime]` +**issue_date_gt:** `typing.Optional[dt.datetime]` — Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`.
@@ -21905,7 +23689,7 @@ For example, given receivables with the following product IDs:
-**issue_date_lt:** `typing.Optional[dt.datetime]` +**issue_date_lt:** `typing.Optional[dt.datetime]` — Return only non-draft receivables that were issued before the specified date and time.
@@ -21913,7 +23697,7 @@ For example, given receivables with the following product IDs:
-**issue_date_gte:** `typing.Optional[dt.datetime]` +**issue_date_gte:** `typing.Optional[dt.datetime]` — Return only non-draft receivables that were issued on or after the specified date and time.
@@ -21921,7 +23705,7 @@ For example, given receivables with the following product IDs:
-**issue_date_lte:** `typing.Optional[dt.datetime]` +**issue_date_lte:** `typing.Optional[dt.datetime]` — Return only non-draft receivables that were issued before or on the specified date and time.
@@ -21929,7 +23713,7 @@ For example, given receivables with the following product IDs:
-**created_at_gt:** `typing.Optional[dt.datetime]` +**created_at_gt:** `typing.Optional[dt.datetime]` — Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`.
@@ -21937,7 +23721,7 @@ For example, given receivables with the following product IDs:
-**created_at_lt:** `typing.Optional[dt.datetime]` +**created_at_lt:** `typing.Optional[dt.datetime]` — Return only receivables created before the specified date and time.
@@ -21945,7 +23729,7 @@ For example, given receivables with the following product IDs:
-**created_at_gte:** `typing.Optional[dt.datetime]` +**created_at_gte:** `typing.Optional[dt.datetime]` — Return only receivables created on or after the specified date and time.
@@ -21953,7 +23737,7 @@ For example, given receivables with the following product IDs:
-**created_at_lte:** `typing.Optional[dt.datetime]` +**created_at_lte:** `typing.Optional[dt.datetime]` — Return only receivables created before or on the specified date and time.
@@ -21962,6 +23746,12 @@ For example, given receivables with the following product IDs:
**counterpart_id:** `typing.Optional[str]` + +Return only receivables created for the counterpart with the specified ID. + +Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + +If the specified counterpart ID does not exist and never existed, no results are returned.
@@ -21969,7 +23759,7 @@ For example, given receivables with the following product IDs:
-**counterpart_name:** `typing.Optional[str]` +**counterpart_name:** `typing.Optional[str]` — Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`.
@@ -21977,7 +23767,7 @@ For example, given receivables with the following product IDs:
-**counterpart_name_contains:** `typing.Optional[str]` +**counterpart_name_contains:** `typing.Optional[str]` — Return only receivables created for counterparts whose name contains the specified string (case-sensitive).
@@ -21985,7 +23775,7 @@ For example, given receivables with the following product IDs:
-**counterpart_name_icontains:** `typing.Optional[str]` +**counterpart_name_icontains:** `typing.Optional[str]` — Return only receivables created for counterparts whose name contains the specified string (case-insensitive).
@@ -21993,7 +23783,7 @@ For example, given receivables with the following product IDs:
-**total_amount:** `typing.Optional[int]` +**total_amount:** `typing.Optional[int]` — Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250."
@@ -22001,7 +23791,7 @@ For example, given receivables with the following product IDs:
-**total_amount_gt:** `typing.Optional[int]` +**total_amount_gt:** `typing.Optional[int]` — Return only receivables whose total amount (in minor units) exceeds the specified value.
@@ -22009,7 +23799,7 @@ For example, given receivables with the following product IDs:
-**total_amount_lt:** `typing.Optional[int]` +**total_amount_lt:** `typing.Optional[int]` — Return only receivables whose total amount (in minor units) is less than the specified value.
@@ -22017,7 +23807,7 @@ For example, given receivables with the following product IDs:
-**total_amount_gte:** `typing.Optional[int]` +**total_amount_gte:** `typing.Optional[int]` — Return only receivables whose total amount (in minor units) is greater than or equal to the specified value.
@@ -22025,7 +23815,7 @@ For example, given receivables with the following product IDs:
-**total_amount_lte:** `typing.Optional[int]` +**total_amount_lte:** `typing.Optional[int]` — Return only receivables whose total amount (in minor units) is less than or equal to the specified value.
@@ -22033,7 +23823,7 @@ For example, given receivables with the following product IDs:
-**discounted_subtotal:** `typing.Optional[int]` +**discounted_subtotal:** `typing.Optional[int]` — Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250.
@@ -22041,7 +23831,7 @@ For example, given receivables with the following product IDs:
-**discounted_subtotal_gt:** `typing.Optional[int]` +**discounted_subtotal_gt:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is greater than the specified value.
@@ -22049,7 +23839,7 @@ For example, given receivables with the following product IDs:
-**discounted_subtotal_lt:** `typing.Optional[int]` +**discounted_subtotal_lt:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is less than the specified value.
@@ -22057,7 +23847,7 @@ For example, given receivables with the following product IDs:
-**discounted_subtotal_gte:** `typing.Optional[int]` +**discounted_subtotal_gte:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value.
@@ -22065,7 +23855,7 @@ For example, given receivables with the following product IDs:
-**discounted_subtotal_lte:** `typing.Optional[int]` +**discounted_subtotal_lte:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value.
@@ -22074,6 +23864,10 @@ For example, given receivables with the following product IDs:
**status:** `typing.Optional[ReceivablesGetRequestStatus]` + +Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + +To query multiple statuses at once, use the `status__in` parameter instead.
@@ -22082,6 +23876,13 @@ For example, given receivables with the following product IDs:
**entity_user_id:** `typing.Optional[str]` + +Return only receivables created by the entity users with the specified IDs. To specify multiple user IDs, repeat this parameter for each ID: +`entity_user_id__in=&entity_user_id__in=` + +If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + +IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results.
@@ -22090,6 +23891,13 @@ For example, given receivables with the following product IDs:
**based_on:** `typing.Optional[str]` + +This parameter accepts a quote ID or an invoice ID. + + * Specify a quote ID to find invoices created from this quote. + * Specify an invoice ID to find credit notes created for this invoice or find recurring invoices created from a base invoice. + +Valid but nonexistent IDs do not raise errors but produce no results.
@@ -22098,6 +23906,10 @@ For example, given receivables with the following product IDs:
**due_date_gt:** `typing.Optional[str]` + +Return invoices that are due after the specified date (exclusive, `YYYY-MM-DD`). + +This filter excludes quotes, credit notes, and draft invoices.
@@ -22106,6 +23918,10 @@ For example, given receivables with the following product IDs:
**due_date_lt:** `typing.Optional[str]` + +Return invoices that are due before the specified date (exclusive, `YYYY-MM-DD`). + +This filter excludes quotes, credit notes, and draft invoices.
@@ -22114,6 +23930,10 @@ For example, given receivables with the following product IDs:
**due_date_gte:** `typing.Optional[str]` + +Return invoices that are due on or after the specified date (`YYYY-MM-DD`). + +This filter excludes quotes, credit notes, and draft invoices.
@@ -22122,6 +23942,10 @@ For example, given receivables with the following product IDs:
**due_date_lte:** `typing.Optional[str]` + +Return invoices that are due before or on the specified date (`YYYY-MM-DD`). + +This filter excludes quotes, credit notes, and draft invoices.
@@ -22129,7 +23953,7 @@ For example, given receivables with the following product IDs:
-**project_id:** `typing.Optional[str]` +**project_id:** `typing.Optional[str]` — Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results.
@@ -22162,7 +23986,7 @@ For example, given receivables with the following product IDs:
```python -from monite import LineItem, Monite, ReceivableFacadeCreateQuotePayload +from monite import Monite, ReceivableCreateBasedOnPayload client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -22170,15 +23994,9 @@ client = Monite( token="YOUR_TOKEN", ) client.receivables.create( - request=ReceivableFacadeCreateQuotePayload( - counterpart_billing_address_id="counterpart_billing_address_id", - counterpart_id="counterpart_id", - currency="AED", - line_items=[ - LineItem( - quantity=1.1, - ) - ], + request=ReceivableCreateBasedOnPayload( + based_on="e977db242-e7d5-4d2e-83cf-a1f5051ed40a", + type="credit_note", ), ) @@ -22360,7 +24178,10 @@ client = Monite( monite_entity_id="YOUR_MONITE_ENTITY_ID", token="YOUR_TOKEN", ) -client.receivables.post_receivables_search() +client.receivables.post_receivables_search( + status="draft", + type="invoice", +) ```
@@ -22376,7 +24197,14 @@ client.receivables.post_receivables_search()
-**discounted_subtotal:** `typing.Optional[int]` — Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. +**based_on:** `typing.Optional[str]` + +This parameter accepts a quote ID or an invoice ID. + +* Specify a quote ID to find invoices created from this quote. +* Specify an invoice ID to find credit notes created for this invoice. + +Valid but nonexistent IDs do not raise errors but produce no results.
@@ -22384,7 +24212,13 @@ client.receivables.post_receivables_search()
-**discounted_subtotal_gt:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. +**counterpart_id:** `typing.Optional[str]` + +Return only receivables created for the counterpart with the specified ID. + +Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + +If the specified counterpart ID does not exist and never existed, no results are returned.
@@ -22392,7 +24226,7 @@ client.receivables.post_receivables_search()
-**discounted_subtotal_gte:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. +**counterpart_name:** `typing.Optional[str]` — Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`.
@@ -22400,7 +24234,7 @@ client.receivables.post_receivables_search()
-**discounted_subtotal_lt:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is less than the specified value. +**counterpart_name_contains:** `typing.Optional[str]` — Return only receivables created for counterparts whose name contains the specified string (case-sensitive).
@@ -22408,7 +24242,7 @@ client.receivables.post_receivables_search()
-**discounted_subtotal_lte:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. +**counterpart_name_icontains:** `typing.Optional[str]` — Return only receivables created for counterparts whose name contains the specified string (case-insensitive).
@@ -22416,14 +24250,7 @@ client.receivables.post_receivables_search()
-**based_on:** `typing.Optional[str]` - -This parameter accepts a quote ID or an invoice ID. - -* Specify a quote ID to find invoices created from this quote. -* Specify an invoice ID to find credit notes created for this invoice. - -Valid but nonexistent IDs do not raise errors but produce no results. +**created_at_gt:** `typing.Optional[dt.datetime]` — Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`.
@@ -22431,13 +24258,7 @@ Valid but nonexistent IDs do not raise errors but produce no results.
-**counterpart_id:** `typing.Optional[str]` - -Return only receivables created for the counterpart with the specified ID. - -Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. - -If the specified counterpart ID does not exist and never existed, no results are returned. +**created_at_gte:** `typing.Optional[dt.datetime]` — Return only receivables created on or after the specified date and time.
@@ -22445,7 +24266,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**counterpart_name:** `typing.Optional[str]` — Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`. +**created_at_lt:** `typing.Optional[dt.datetime]` — Return only receivables created before the specified date and time.
@@ -22453,7 +24274,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**counterpart_name_contains:** `typing.Optional[str]` — Return only receivables created for counterparts whose name contains the specified string (case-sensitive). +**created_at_lte:** `typing.Optional[dt.datetime]` — Return only receivables created before or on the specified date and time.
@@ -22461,7 +24282,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**counterpart_name_icontains:** `typing.Optional[str]` — Return only receivables created for counterparts whose name contains the specified string (case-insensitive). +**discounted_subtotal:** `typing.Optional[int]` — Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250.
@@ -22469,7 +24290,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**created_at_gt:** `typing.Optional[dt.datetime]` — Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. +**discounted_subtotal_gt:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is greater than the specified value.
@@ -22477,7 +24298,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**created_at_gte:** `typing.Optional[dt.datetime]` — Return only receivables created on or after the specified date and time. +**discounted_subtotal_gte:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value.
@@ -22485,7 +24306,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**created_at_lt:** `typing.Optional[dt.datetime]` — Return only receivables created before the specified date and time. +**discounted_subtotal_lt:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is less than the specified value.
@@ -22493,7 +24314,7 @@ If the specified counterpart ID does not exist and never existed, no results are
-**created_at_lte:** `typing.Optional[dt.datetime]` — Return only receivables created before or on the specified date and time. +**discounted_subtotal_lte:** `typing.Optional[int]` — Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value.
@@ -22588,6 +24409,12 @@ IDs of deleted users will still produce results here if those users had associat
**entity_user_id_in:** `typing.Optional[typing.Sequence[str]]` + +Return only receivables created by the entity users with the specified IDs. + +If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + +IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results.
@@ -22595,7 +24422,7 @@ IDs of deleted users will still produce results here if those users had associat
-**id_in:** `typing.Optional[typing.Sequence[str]]` +**id_in:** `typing.Optional[typing.Sequence[str]]` — Return only receivables with the specified IDs. Valid but nonexistent IDs do not raise errors but produce no results.
@@ -22636,6 +24463,10 @@ IDs of deleted users will still produce results here if those users had associat
**limit:** `typing.Optional[int]` + +The number of items (0 .. 250) to return in a single page of the response. Default is 100. The response may contain fewer items if it is the last or only page. + +When using pagination with a non-default limit, you must provide the `limit` value alongside `pagination_token` in all subsequent pagination requests. Unlike other pagination parameters, `limit` is not inferred from `pagination_token`.
@@ -22643,7 +24474,7 @@ IDs of deleted users will still produce results here if those users had associat
-**order:** `typing.Optional[OrderEnum]` +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -22652,6 +24483,10 @@ IDs of deleted users will still produce results here if those users had associat
**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to `GET /receivables` or `POST /receivables/search`. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other parameters except `limit` are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned.
@@ -22660,6 +24495,20 @@ IDs of deleted users will still produce results here if those users had associat
**product_ids:** `typing.Optional[typing.Sequence[str]]` + +Return only receivables with line items containing all of the products with the specified IDs and optionally other products that are not specified. + +For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productA, productB, productC + +`product_ids` = `[productA, productB]` will return receivables 3 and 5. + +Valid but nonexistent product IDs do not raise errors but produce no results.
@@ -22668,6 +24517,20 @@ IDs of deleted users will still produce results here if those users had associat
**product_ids_in:** `typing.Optional[typing.Sequence[str]]` + +Return only receivables with line items containing at least one of the products with the specified IDs. + +For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productB, productC + +`product_ids__in` = `[productA, productB]` will return receivables 1, 2, 3, and 5. + +Valid but nonexistent product IDs do not raise errors but produce no results.
@@ -22683,7 +24546,7 @@ IDs of deleted users will still produce results here if those users had associat
-**project_id_in:** `typing.Optional[typing.Sequence[str]]` +**project_id_in:** `typing.Optional[typing.Sequence[str]]` — Return only receivables that belong to one of the projects with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results.
@@ -22691,7 +24554,7 @@ IDs of deleted users will still produce results here if those users had associat
-**sort:** `typing.Optional[ReceivableCursorFields2]` +**sort:** `typing.Optional[ReceivableCursorFields2]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -22711,7 +24574,7 @@ To query multiple statuses at once, use the `status__in` parameter instead.
-**status_in:** `typing.Optional[typing.Sequence[str]]` +**status_in:** `typing.Optional[typing.Sequence[str]]` — Return only receivables that have the specified statuses. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle).
@@ -22720,6 +24583,18 @@ To query multiple statuses at once, use the `status__in` parameter instead.
**tag_ids:** `typing.Optional[typing.Sequence[str]]` + +Return only receivables whose [tags](https://docs.monite.com/common/tags) include all of the tags with the specified IDs and optionally other tags that are not specified. + +For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagA, tagB, tagC + +`tag_ids` = `[tagA, tagB]` will return receivables 3 and 5.
@@ -22728,6 +24603,20 @@ To query multiple statuses at once, use the `status__in` parameter instead.
**tag_ids_in:** `typing.Optional[typing.Sequence[str]]` + +Return only receivables whose [tags](https://docs.monite.com/common/tags) include at least one of the tags with the specified IDs. + +For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagB, tagC + +`tag_ids__in` = `[tagA, tagB]` will return receivables 1, 2, 3, and 5. + +Valid but nonexistent tag IDs do not raise errors but produce no results.
@@ -22861,6 +24750,24 @@ client.receivables.get_variables()
+#### 📝 Description + +
+
+ +
+
+ +Returns the details of an existing accounts receivable invoice, quote, or credit note with the specified ID. + +The response fields vary depending on the document type. Use the `type` field to distinguish between different document types. + +Entity users with the `receivable.read.allowed_for_own` permission (rather than `allowed`) can access only documents that they created themselves. +
+
+
+
+ #### 🔌 Usage
@@ -22895,7 +24802,7 @@ client.receivables.get_by_id(
-**receivable_id:** `str` +**receivable_id:** `str` — ID of an existing invoice, quote, or credit note that you want to retrieve.
@@ -23046,6 +24953,22 @@ client.receivables.update_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Only quotes in the `issued` status can be accepted. + +When a quote is accepted, Monite automatically creates a draft invoice based on this quote. To find the newly created invoice, use `GET /receivables?based_on=QUOTE_ID`. +
+
+
+
+ #### 🔌 Usage
@@ -23088,7 +25011,7 @@ client.receivables.accept_by_id(
-**signature:** `typing.Optional[Signature]` — A digital signature, if required for quote acceptance +**signature:** `typing.Optional[Signature]` — The counterpart's signature. Required if the quote field `signature_required` is `true`.
@@ -23170,6 +25093,29 @@ client.receivables.cancel_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Creates a copy of an existing accounts receivable invoice or quote. The original document can be in any status. The cloned document will have the `draft` status. + +Cloning a document requires that all of the referenced resource IDs (counterpart ID, product IDs, and others) still exist. + +Most of the original document's data is copied as is, with a few exceptions: + + * Some fields are not copied: `attachments`, `document_id`, `issue_date`, quote `expiry_date`. + * Counterpart details, entity bank account details, and entity VAT number are fetched anew from their corresponding IDs. + This means, for example, that if the counterpart details have been changed since the original invoice or quote was created, + the cloned document will use the current counterpart details rather than the old details from the original document. +
+
+
+
+ #### 🔌 Usage
@@ -23204,7 +25150,7 @@ client.receivables.clone_by_id(
-**receivable_id:** `str` +**receivable_id:** `str` — ID of an existing invoice or quote that you want to clone.
@@ -23228,6 +25174,20 @@ client.receivables.clone_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Only quotes in the `issued` status can be declined. +
+
+
+
+ #### 🔌 Usage
@@ -24187,6 +26147,25 @@ client.receivables.get_pdf_link_by_id(
+#### 📝 Description + +
+
+ +
+
+ +You can preview emails only for documents in the following statuses: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. +
+
+
+
+ #### 🔌 Usage
@@ -24279,6 +26258,29 @@ client.receivables.preview_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Only documents in the following statuses can be sent via email: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + +Draft documents are automatically moved to the `issued` status before sending. + +For more information, see [Send an invoice via email](https://docs.monite.com/accounts-receivable/invoices/create#send-via-email). +
+
+
+
+ #### 🔌 Usage
@@ -25323,7 +27325,7 @@ client.roles.create(
-**name:** `str` — Role name +**name:** `str` — The role name is case-sensitive and must be unique.
@@ -25541,7 +27543,7 @@ client.roles.update_by_id(
-**name:** `typing.Optional[str]` — Role name +**name:** `typing.Optional[str]` — The new name for this role. Case-sensitive and must be unique.
@@ -25582,7 +27584,11 @@ client.roles.update_by_id(
-Retrieve all settings for this partner. +Partner-level settings apply to all entities of that partner. + +See also: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings)
@@ -25644,7 +27650,11 @@ client.partner_settings.get()
-Change the specified fields with the provided values. +Partner-level settings apply to all entities of that partner. + +See also: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings)
@@ -25682,7 +27692,7 @@ client.partner_settings.update()
-**currency:** `typing.Optional[CurrencySettingsInput]` — Custom currency exchange rates. +**api_version:** `typing.Optional[ApiVersion]` — Default API version for partner.
@@ -25690,7 +27700,7 @@ client.partner_settings.update()
-**payable:** `typing.Optional[PayableSettings]` — Settings for the payables module. +**commercial_conditions:** `typing.Optional[typing.Sequence[str]]` — Unused. To specify commercial conditions for invoices and quotes, use the `commercial_condition_description` field in those documents.
@@ -25698,7 +27708,7 @@ client.partner_settings.update()
-**receivable:** `typing.Optional[ReceivableSettings]` — Settings for the receivables module. +**currency:** `typing.Optional[CurrencySettingsInput]` — Custom currency exchange rates.
@@ -25706,7 +27716,7 @@ client.partner_settings.update()
-**mail:** `typing.Optional[MailSettings]` — Settings for email and mailboxes. +**default_role:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — A default role to provision upon new entity creation.
@@ -25714,7 +27724,12 @@ client.partner_settings.update()
-**commercial_conditions:** `typing.Optional[typing.Sequence[str]]` — Commercial conditions for receivables. +**mail:** `typing.Optional[MailSettings]` + +Settings for outgoing email. Used by: + + * accounts receivable emails, for example, emails sent by `POST /recevables/{receivable_id}/send`, + * accounts payable approval notifications.
@@ -25722,7 +27737,7 @@ client.partner_settings.update()
-**units:** `typing.Optional[typing.Sequence[Unit]]` — Measurement units. +**payable:** `typing.Optional[PayableSettings]` — Settings for accounts payable.
@@ -25730,7 +27745,7 @@ client.partner_settings.update()
-**website:** `typing.Optional[str]` +**payments:** `typing.Optional[PaymentsSettingsInput]` — Settings for the payments module.
@@ -25738,7 +27753,7 @@ client.partner_settings.update()
-**default_role:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — A default role to provision upon new entity creation. +**receivable:** `typing.Optional[ReceivableSettings]` — Settings for accounts receivable.
@@ -25746,7 +27761,7 @@ client.partner_settings.update()
-**payments:** `typing.Optional[PaymentsSettingsInput]` — Settings for the payments module. +**units:** `typing.Optional[typing.Sequence[Unit]]` — Unused. To manage the [measure units](https://docs.monite.com/accounts-receivable/products#manage-measure-units) for your entities, use the `/measure_units` endpoints.
@@ -25754,7 +27769,7 @@ client.partner_settings.update()
-**api_version:** `typing.Optional[ApiVersion]` — Default API version for partner. +**website:** `typing.Optional[str]` — The URL of the partner's website. Must be an HTTPS URL. Required if the partner's entities use [payment links](https://docs.monite.com/payments/payment-links). The "Powered by" badge in the payment page footer will link to this website.
@@ -26727,6 +28742,30 @@ client.text_templates.make_default_by_id(
+#### 📝 Description + +
+
+ +
+
+ +Monite maintains a catalog of VAT and sales tax rates for [select countries](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries). + +To query the applicable VAT/tax rates for an invoice or quote, use: + +`GET /vat_rates?counterpart_id=<...>&entity_vat_id_id=<...>` + +Or if the entity does not have a VAT ID: + +`GET /vat_rates?counterpart_id=<...>` + +**Note:** Entities from countries [not on the list](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries) should not use this endpoint. Instead, those entities can either create custom VAT/tax rates or use the invoice field `line_items[].tax_rate_value` to specify the VAT/tax rates directly. +
+
+
+
+ #### 🔌 Usage
@@ -26759,7 +28798,7 @@ client.vat_rates.get()
-**counterpart_address_id:** `typing.Optional[str]` +**counterpart_address_id:** `typing.Optional[str]` — Unused. Reserved for future use.
@@ -26767,7 +28806,7 @@ client.vat_rates.get()
-**counterpart_id:** `typing.Optional[str]` +**counterpart_id:** `typing.Optional[str]` — ID of the counterpart that will be invoiced.
@@ -26775,7 +28814,7 @@ client.vat_rates.get()
-**counterpart_vat_id_id:** `typing.Optional[str]` +**counterpart_vat_id_id:** `typing.Optional[str]` — Unused. Reserved for future use.
@@ -26783,7 +28822,7 @@ client.vat_rates.get()
-**entity_vat_id_id:** `typing.Optional[str]` +**entity_vat_id_id:** `typing.Optional[str]` — ID of the entity's VAT number (if any) used for the sales transaction.
@@ -26791,7 +28830,7 @@ client.vat_rates.get()
-**product_type:** `typing.Optional[ProductServiceTypeEnum]` +**product_type:** `typing.Optional[ProductServiceTypeEnum]` — Unused. Reserved for future use.
@@ -26975,6 +29014,20 @@ If not specified, the first page of results will be returned.
+#### 📝 Description + +
+
+ +
+
+ +Returns a list of all [webhook](https://docs.monite.com/references/webhooks/index) subscriptions (both active and disabled). +
+
+
+
+ #### 🔌 Usage
@@ -27051,7 +29104,7 @@ If not specified, the first page of results will be returned.
-**created_at_gt:** `typing.Optional[dt.datetime]` +**created_at_gt:** `typing.Optional[dt.datetime]` — Return only subscriptions created after the specified date and time.
@@ -27059,7 +29112,7 @@ If not specified, the first page of results will be returned.
-**created_at_lt:** `typing.Optional[dt.datetime]` +**created_at_lt:** `typing.Optional[dt.datetime]` — Return only subscriptions created before the specified date and time.
@@ -27067,7 +29120,7 @@ If not specified, the first page of results will be returned.
-**created_at_gte:** `typing.Optional[dt.datetime]` +**created_at_gte:** `typing.Optional[dt.datetime]` — Return only subscriptions created on or after the specified date and time.
@@ -27075,7 +29128,7 @@ If not specified, the first page of results will be returned.
-**created_at_lte:** `typing.Optional[dt.datetime]` +**created_at_lte:** `typing.Optional[dt.datetime]` — Return only subscriptions created before or on the specified date and time.
@@ -27099,6 +29152,20 @@ If not specified, the first page of results will be returned.
+#### 📝 Description + +
+
+ +
+
+ +Related guide: [Webhooks](https://docs.monite.com/references/webhooks/index). +
+
+
+
+ #### 🔌 Usage
@@ -27116,8 +29183,13 @@ client = Monite( token="YOUR_TOKEN", ) client.webhook_subscriptions.create( - object_type="account", - url="url", + event_types=[ + "created", + "onboarding_requirements.updated", + "onboarding_requirements.status_updated", + ], + object_type="entity", + url="https://example.com/your-webhook-listener", ) ``` @@ -27135,6 +29207,10 @@ client.webhook_subscriptions.create(
**object_type:** `WebhookObjectType` + +The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + +To subscribe to events from multiple object types, create a separate subscription for each object type.
@@ -27143,6 +29219,10 @@ client.webhook_subscriptions.create(
**url:** `str` + +An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + +The same URL can be used by multiple webhook subscriptions.
@@ -27150,7 +29230,7 @@ client.webhook_subscriptions.create(
-**event_types:** `typing.Optional[typing.Sequence[str]]` +**event_types:** `typing.Optional[typing.Sequence[str]]` — A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`.
@@ -27174,6 +29254,22 @@ client.webhook_subscriptions.create(
+#### 📝 Description + +
+
+ +
+
+ +Returns the details of the webhook subscription with the specified ID. + +The response does not include the [webhook signing secret](https://docs.monite.com/references/webhooks/signatures). If you lost the secret, you can [regenerate it](https://docs.monite.com/api/webhook-subscriptions/post-webhook-subscriptions-id-regenerate-secret). +
+
+
+
+ #### 🔌 Usage
@@ -27208,7 +29304,7 @@ client.webhook_subscriptions.get_by_id(
-**webhook_subscription_id:** `str` +**webhook_subscription_id:** `str` — ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks.
@@ -27266,7 +29362,7 @@ client.webhook_subscriptions.delete_by_id(
-**webhook_subscription_id:** `str` +**webhook_subscription_id:** `str` — ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks.
@@ -27290,6 +29386,20 @@ client.webhook_subscriptions.delete_by_id(
+#### 📝 Description + +
+
+ +
+
+ +You can update the webhook listener URL or the event list. +
+
+
+
+ #### 🔌 Usage
@@ -27324,7 +29434,7 @@ client.webhook_subscriptions.update_by_id(
-**webhook_subscription_id:** `str` +**webhook_subscription_id:** `str` — ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks.
@@ -27332,7 +29442,7 @@ client.webhook_subscriptions.update_by_id(
-**event_types:** `typing.Optional[typing.Sequence[str]]` +**event_types:** `typing.Optional[typing.Sequence[str]]` — A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`.
@@ -27341,6 +29451,10 @@ client.webhook_subscriptions.update_by_id(
**object_type:** `typing.Optional[WebhookObjectType]` + +The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + +To subscribe to events from multiple object types, create a separate subscription for each object type.
@@ -27349,6 +29463,10 @@ client.webhook_subscriptions.update_by_id(
**url:** `typing.Optional[str]` + +An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + +The same URL can be used by multiple webhook subscriptions.
@@ -27406,7 +29524,7 @@ client.webhook_subscriptions.disable_by_id(
-**webhook_subscription_id:** `str` +**webhook_subscription_id:** `str` — ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks.
@@ -27464,7 +29582,7 @@ client.webhook_subscriptions.enable_by_id(
-**webhook_subscription_id:** `str` +**webhook_subscription_id:** `str` — ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks.
@@ -27488,6 +29606,20 @@ client.webhook_subscriptions.enable_by_id(
+#### 📝 Description + +
+
+ +
+
+ +The webhook signing secret lets you [verify webhook signatures](https://docs.monite.com/references/webhooks/signatures). If you lost the original secret generated for any of your webhook subscriptions, you can regenerate it. +
+
+
+
+ #### 🔌 Usage
@@ -27522,7 +29654,7 @@ client.webhook_subscriptions.regenerate_secret_by_id(
-**webhook_subscription_id:** `str` +**webhook_subscription_id:** `str` — ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks.
@@ -29331,7 +31463,7 @@ client.counterparts.addresses.create(
-**state:** `typing.Optional[str]` — State, region, province, or county. +**state:** `typing.Optional[str]` — State, county, province, prefecture, region, or similar component of the counterpart's address. For US counterparts, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA.
@@ -31048,7 +33180,7 @@ client.data_exports.extra_data.get()
-**order:** `typing.Optional[OrderEnum]` — Order by +**order:** `typing.Optional[OrderEnum]` — Sort order (ascending by default). Typically used together with the `sort` parameter.
@@ -31056,7 +33188,7 @@ client.data_exports.extra_data.get()
-**limit:** `typing.Optional[int]` — Max is 100 +**limit:** `typing.Optional[int]` — The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page.
@@ -31064,7 +33196,11 @@ client.data_exports.extra_data.get()
-**pagination_token:** `typing.Optional[str]` — A token, obtained from previous page. Prior over other filters +**pagination_token:** `typing.Optional[str]` + +A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + +If not specified, the first page of results will be returned.
@@ -31072,7 +33208,7 @@ client.data_exports.extra_data.get()
-**sort:** `typing.Optional[ExportSettingCursorFields]` — Allowed sort fields +**sort:** `typing.Optional[ExportSettingCursorFields]` — The field to sort the results by. Typically used together with the `order` parameter.
@@ -31573,8 +33709,14 @@ client = Monite( token="YOUR_TOKEN", ) client.entities.bank_accounts.create( - country="AF", - currency="AED", + account_holder_name="Bob Jones", + account_number="2571714302", + bank_name="WELLS FARGO", + country="US", + currency="USD", + display_name="Primary account", + is_default_for_currency=True, + routing_number="061000227", ) ``` @@ -32132,6 +34274,14 @@ client.entities.onboarding_data.update(
+**treasury_tos_acceptance:** `typing.Optional[TermsOfServiceAcceptanceInput]` — Details on the entity's acceptance of the Stripe Treasury service agreement. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -32253,6 +34403,7 @@ client = Monite( ) client.entities.payment_methods.set( entity_id="entity_id", + payment_methods_receive=["card", "us_ach", "affirm", "klarna"], ) ``` @@ -32277,7 +34428,7 @@ client.entities.payment_methods.set(
-**payment_methods:** `typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]]` — Deprecated. Use payment_methods_receive instead. +**payment_methods:** `typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]]` — Deprecated. Replaced by `payment_methods_receive`.
@@ -32285,7 +34436,13 @@ client.entities.payment_methods.set(
-**payment_methods_receive:** `typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]]` — Enable payment methods to receive money. +**payment_methods_receive:** `typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]]` + +Payment methods to receive money from customers. Supported payment methods [vary per country](https://docs.monite.com/payments/payment-methods). + +`card` includes card payments, Apple Pay, and Google Pay. The values `applepay` and `googlepay` are deprecated and unused. + +`sofort` is deprecated and replaced by `klarna`.
@@ -32293,7 +34450,11 @@ client.entities.payment_methods.set(
-**payment_methods_send:** `typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]]` — Enable payment methods to send money. +**payment_methods_send:** `typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]]` + +Only for entities in the EU and UK. Payment methods used to make payments to vendors. + +Currently only `sepa_credit` is supported for making payments.
diff --git a/src/monite/__init__.py b/src/monite/__init__.py index 28e4d8b..d3582f1 100644 --- a/src/monite/__init__.py +++ b/src/monite/__init__.py @@ -25,13 +25,6 @@ ActionEnum, ActionSchema, AggregationFunctionEnum, - AirwallexMandate, - AirwallexMandateType, - AirwallexMandateVersion, - AirwallexPlaidAccount, - AirwallexPlaidBankAccountVerificationStatus, - AirwallexPlaidInstitution, - AirwallexPlaidVerification, AllDocumentExportResponseSchema, AllOverdueRemindersResponse, AllowedCountries, @@ -57,10 +50,10 @@ ApprovalRequestResourceList, ApprovalRequestResourceWithMetadata, ApprovalRequestStatus, + AttachmentRequest, + AttachmentResponse, AutomationLevel, BankAccount, - BankAccountVerificationType, - BankAccountVerifications, BasedOnReceivableCreatedEventData, BasedOnTransitionType, BizObjectsSchemaInput, @@ -75,11 +68,6 @@ CommentResourceList, CommonSchemaInput, CommonSchemaOutput, - CompleteRefreshVerificationRequest, - CompleteRefreshVerificationResponse, - CompleteVerificationAirwallexPlaidRequest, - CompleteVerificationRequest, - CompleteVerificationResponse, ConnectionStatus, CounterpartAddress, CounterpartAddressResourceList, @@ -92,6 +80,7 @@ CounterpartCreatePayload_Individual, CounterpartCreatePayload_Organization, CounterpartCursorFields, + CounterpartEinvoicingCredentialExistenceResponse, CounterpartEinvoicingCredentialResponse, CounterpartEinvoicingCredentialResponseList, CounterpartEinvoicingCredentialSchema, @@ -126,7 +115,6 @@ CreateCounterpartEinvoicingCredentialCounterpartVatId, CreateCounterpartEinvoicingCredentialPayload, CreateExportTaskResponseSchema, - CreateOnboardingLinkRequest, CreditNoteCursorFields, CreditNoteDimensionEnum, CreditNoteFieldsAllowedForValidate, @@ -188,6 +176,8 @@ DocumentIdSeparators, DocumentObjectTypeRequestEnum, DocumentRenderingSettings, + DocumentRenderingSettingsInput, + DocumentRenderingSettingsOutput, DocumentTypeEnum, DocumentTypePrefix, DomainListResponse, @@ -280,9 +270,11 @@ LedgerAccountListResponse, LedgerAccountResponse, LineItem, + LineItemColumnSettings, LineItemCursorFields, LineItemFields, LineItemInternalRequest, + LineItemNumericColumnSettings, LineItemPaginationResponse, LineItemProduct, LineItemProductCreate, @@ -291,6 +283,7 @@ LineItemRequest, LineItemResponse, LineItemUpdate, + LineItemsRenderingSettings, LineItemsReplaceResponse, LineItemsResponse, MailSentEventData, @@ -303,6 +296,7 @@ MissingLineItemFields, MoniteAllPaymentMethods, MoniteAllPaymentMethodsTypes, + NextDocumentNumbers, ObjectMatchTypes, ObjectType, ObjectTypeAvailableComment, @@ -329,9 +323,6 @@ OcrTaskResponseSchemaRecognizedData_Receipt, OcrTaskStatus, OcrTasksPaginationResponse, - OnboardingLinkPublicResponse, - OnboardingLinkRequest, - OnboardingLinkResponse, OnboardingPaymentMethodsResponse, OnboardingRequirementsError, OnboardingRequirementsResponse, @@ -405,16 +396,13 @@ PaymentIntentCursorFields, PaymentIntentHistory, PaymentIntentHistoryResponse, - PaymentIntentPayoutMethod, PaymentIntentResponse, PaymentIntentsListResponse, - PaymentIntentsRecipient, PaymentMethod, PaymentMethodDirection, PaymentMethodRequirements, PaymentMethodStatus, PaymentObject, - PaymentObjectPayable, PaymentObjectType, PaymentPageTheme, PaymentPriorityEnum, @@ -432,9 +420,6 @@ PaymentTerms, PaymentTermsListResponse, PaymentTermsResponse, - PaymentsBatchPaymentRequest, - PaymentsBatchPaymentResponse, - PaymentsBatchPaymentStatus, PaymentsSettingsInput, PaymentsSettingsOutput, PermissionEnum, @@ -484,6 +469,12 @@ QuoteResponsePayloadEntity_Individual, QuoteResponsePayloadEntity_Organization, QuoteStateEnum, + ReceiptCursorFields, + ReceiptLineItemCursorFields, + ReceiptLineItemResponseSchema, + ReceiptLineItemsPaginationResponse, + ReceiptPaginationResponse, + ReceiptResponseSchema, ReceivableCounterpartContact, ReceivableCounterpartVatIdResponse, ReceivableCreateBasedOnPayload, @@ -540,9 +531,7 @@ ReceivablesSendResponse, ReceivablesStatusEnum, ReceivablesVerifyResponse, - Recipient, RecipientAccountResponse, - RecipientType, Recipients, RecurrenceFrequency, RecurrenceIteration, @@ -583,6 +572,7 @@ RootSchemaInput_Person, RootSchemaInput_Product, RootSchemaInput_Project, + RootSchemaInput_Receipt, RootSchemaInput_Receivable, RootSchemaInput_Reconciliation, RootSchemaInput_Role, @@ -614,6 +604,7 @@ RootSchemaOutput_Person, RootSchemaOutput_Product, RootSchemaOutput_Project, + RootSchemaOutput_Receipt, RootSchemaOutput_Receivable, RootSchemaOutput_Reconciliation, RootSchemaOutput_Role, @@ -626,13 +617,14 @@ SettingsResponse, Signature, SingleOnboardingRequirementsResponse, - SinglePaymentIntent, - SinglePaymentIntentResponse, SourceOfPayableDataEnum, + SourceOfReceiptDataEnum, StatusChangedEventData, StatusEnum, SuccessResult, + SuggestedCounterpartPayload, SuggestedPaymentTerm, + SuggestedResponse, SupportedFieldNames, SupportedFormatSchema, SupportedFormatSchemaObjectType, @@ -695,11 +687,7 @@ VatRateListResponse, VatRateResponse, VatRateStatusEnum, - VerificationAirwallexPlaidRequest, - VerificationAirwallexPlaidResponse, VerificationError, - VerificationRequest, - VerificationResponse, VerificationStatusEnum, VerifyResponse, WcBusinessStatus, @@ -722,10 +710,10 @@ ContentTooLargeError, FailedDependencyError, ForbiddenError, - InternalServerError, MisdirectedRequestError, NotAcceptableError, NotFoundError, + TooManyRequestsError, UnauthorizedError, UnprocessableEntityError, UnsupportedMediaTypeError, @@ -744,6 +732,7 @@ data_exports, delivery_notes, e_invoicing_connections, + e_invoicing_search, entities, entity_users, events, @@ -766,6 +755,7 @@ products, projects, purchase_orders, + receipts, receivables, recurrences, roles, @@ -814,13 +804,6 @@ "ActionEnum", "ActionSchema", "AggregationFunctionEnum", - "AirwallexMandate", - "AirwallexMandateType", - "AirwallexMandateVersion", - "AirwallexPlaidAccount", - "AirwallexPlaidBankAccountVerificationStatus", - "AirwallexPlaidInstitution", - "AirwallexPlaidVerification", "AllDocumentExportResponseSchema", "AllOverdueRemindersResponse", "AllowedCountries", @@ -853,11 +836,11 @@ "ApprovalRequestResourceWithMetadata", "ApprovalRequestStatus", "AsyncMonite", + "AttachmentRequest", + "AttachmentResponse", "AutomationLevel", "BadRequestError", "BankAccount", - "BankAccountVerificationType", - "BankAccountVerifications", "BasedOnReceivableCreatedEventData", "BasedOnTransitionType", "BizObjectsSchemaInput", @@ -872,11 +855,6 @@ "CommentResourceList", "CommonSchemaInput", "CommonSchemaOutput", - "CompleteRefreshVerificationRequest", - "CompleteRefreshVerificationResponse", - "CompleteVerificationAirwallexPlaidRequest", - "CompleteVerificationRequest", - "CompleteVerificationResponse", "ConflictError", "ConnectionStatus", "ContentTooLargeError", @@ -891,6 +869,7 @@ "CounterpartCreatePayload_Individual", "CounterpartCreatePayload_Organization", "CounterpartCursorFields", + "CounterpartEinvoicingCredentialExistenceResponse", "CounterpartEinvoicingCredentialResponse", "CounterpartEinvoicingCredentialResponseList", "CounterpartEinvoicingCredentialSchema", @@ -925,7 +904,6 @@ "CreateCounterpartEinvoicingCredentialCounterpartVatId", "CreateCounterpartEinvoicingCredentialPayload", "CreateExportTaskResponseSchema", - "CreateOnboardingLinkRequest", "CreditNoteCursorFields", "CreditNoteDimensionEnum", "CreditNoteFieldsAllowedForValidate", @@ -987,6 +965,8 @@ "DocumentIdSeparators", "DocumentObjectTypeRequestEnum", "DocumentRenderingSettings", + "DocumentRenderingSettingsInput", + "DocumentRenderingSettingsOutput", "DocumentTypeEnum", "DocumentTypePrefix", "DomainListResponse", @@ -1068,7 +1048,6 @@ "InlinePaymentTermsRequestPayload", "InlineTermDiscount", "InlineTermFinal", - "InternalServerError", "Invoice", "InvoiceFile", "InvoiceRenderingSettings", @@ -1084,9 +1063,11 @@ "LedgerAccountListResponse", "LedgerAccountResponse", "LineItem", + "LineItemColumnSettings", "LineItemCursorFields", "LineItemFields", "LineItemInternalRequest", + "LineItemNumericColumnSettings", "LineItemPaginationResponse", "LineItemProduct", "LineItemProductCreate", @@ -1095,6 +1076,7 @@ "LineItemRequest", "LineItemResponse", "LineItemUpdate", + "LineItemsRenderingSettings", "LineItemsReplaceResponse", "LineItemsResponse", "MailSentEventData", @@ -1110,6 +1092,7 @@ "MoniteAllPaymentMethods", "MoniteAllPaymentMethodsTypes", "MoniteEnvironment", + "NextDocumentNumbers", "NotAcceptableError", "NotFoundError", "ObjectMatchTypes", @@ -1138,9 +1121,6 @@ "OcrTaskResponseSchemaRecognizedData_Receipt", "OcrTaskStatus", "OcrTasksPaginationResponse", - "OnboardingLinkPublicResponse", - "OnboardingLinkRequest", - "OnboardingLinkResponse", "OnboardingPaymentMethodsResponse", "OnboardingRequirementsError", "OnboardingRequirementsResponse", @@ -1215,16 +1195,13 @@ "PaymentIntentCursorFields", "PaymentIntentHistory", "PaymentIntentHistoryResponse", - "PaymentIntentPayoutMethod", "PaymentIntentResponse", "PaymentIntentsListResponse", - "PaymentIntentsRecipient", "PaymentMethod", "PaymentMethodDirection", "PaymentMethodRequirements", "PaymentMethodStatus", "PaymentObject", - "PaymentObjectPayable", "PaymentObjectType", "PaymentPageTheme", "PaymentPriorityEnum", @@ -1243,9 +1220,6 @@ "PaymentTerms", "PaymentTermsListResponse", "PaymentTermsResponse", - "PaymentsBatchPaymentRequest", - "PaymentsBatchPaymentResponse", - "PaymentsBatchPaymentStatus", "PaymentsSettingsInput", "PaymentsSettingsOutput", "PermissionEnum", @@ -1295,6 +1269,12 @@ "QuoteResponsePayloadEntity_Individual", "QuoteResponsePayloadEntity_Organization", "QuoteStateEnum", + "ReceiptCursorFields", + "ReceiptLineItemCursorFields", + "ReceiptLineItemResponseSchema", + "ReceiptLineItemsPaginationResponse", + "ReceiptPaginationResponse", + "ReceiptResponseSchema", "ReceivableCounterpartContact", "ReceivableCounterpartVatIdResponse", "ReceivableCreateBasedOnPayload", @@ -1354,9 +1334,7 @@ "ReceivablesSendResponse", "ReceivablesStatusEnum", "ReceivablesVerifyResponse", - "Recipient", "RecipientAccountResponse", - "RecipientType", "Recipients", "RecurrenceFrequency", "RecurrenceIteration", @@ -1397,6 +1375,7 @@ "RootSchemaInput_Person", "RootSchemaInput_Product", "RootSchemaInput_Project", + "RootSchemaInput_Receipt", "RootSchemaInput_Receivable", "RootSchemaInput_Reconciliation", "RootSchemaInput_Role", @@ -1428,6 +1407,7 @@ "RootSchemaOutput_Person", "RootSchemaOutput_Product", "RootSchemaOutput_Project", + "RootSchemaOutput_Receipt", "RootSchemaOutput_Receivable", "RootSchemaOutput_Reconciliation", "RootSchemaOutput_Role", @@ -1440,13 +1420,14 @@ "SettingsResponse", "Signature", "SingleOnboardingRequirementsResponse", - "SinglePaymentIntent", - "SinglePaymentIntentResponse", "SourceOfPayableDataEnum", + "SourceOfReceiptDataEnum", "StatusChangedEventData", "StatusEnum", "SuccessResult", + "SuggestedCounterpartPayload", "SuggestedPaymentTerm", + "SuggestedResponse", "SupportedFieldNames", "SupportedFormatSchema", "SupportedFormatSchemaObjectType", @@ -1474,6 +1455,7 @@ "TextTemplateResponse", "TextTemplateResponseList", "TextTemplateType", + "TooManyRequestsError", "TotalVatAmountItem", "TotalVatAmountItemComponent", "UnauthorizedError", @@ -1512,11 +1494,7 @@ "VatRateListResponse", "VatRateResponse", "VatRateStatusEnum", - "VerificationAirwallexPlaidRequest", - "VerificationAirwallexPlaidResponse", "VerificationError", - "VerificationRequest", - "VerificationResponse", "VerificationStatusEnum", "VerifyResponse", "WcBusinessStatus", @@ -1546,6 +1524,7 @@ "data_exports", "delivery_notes", "e_invoicing_connections", + "e_invoicing_search", "entities", "entity_users", "events", @@ -1568,6 +1547,7 @@ "products", "projects", "purchase_orders", + "receipts", "receivables", "recurrences", "roles", diff --git a/src/monite/access_tokens/client.py b/src/monite/access_tokens/client.py index fb796a6..63cfb78 100644 --- a/src/monite/access_tokens/client.py +++ b/src/monite/access_tokens/client.py @@ -37,10 +37,13 @@ def revoke( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. token : str + The token to revoke. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -85,12 +88,19 @@ def create( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. grant_type : GrantType + The type of the access token to generate: + + * `client_credentials` - partner-level access token, + * `entity_user` - entity user token. entity_user_id : typing.Optional[str] + ID of the entity user to generate the access token for. Used only if `grant_type` is `entity_user`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -110,8 +120,8 @@ def create( token="YOUR_TOKEN", ) client.access_tokens.create( - client_id="client_id", - client_secret="client_secret", + client_id="eb959578-a74d-4ac3-8b25-bf0910027857", + client_secret="14c84a34-282b-4fd8-8af6-86b5b5f2c212", grant_type="client_credentials", ) """ @@ -149,10 +159,13 @@ async def revoke( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. token : str + The token to revoke. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -205,12 +218,19 @@ async def create( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. grant_type : GrantType + The type of the access token to generate: + + * `client_credentials` - partner-level access token, + * `entity_user` - entity user token. entity_user_id : typing.Optional[str] + ID of the entity user to generate the access token for. Used only if `grant_type` is `entity_user`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -235,8 +255,8 @@ async def create( async def main() -> None: await client.access_tokens.create( - client_id="client_id", - client_secret="client_secret", + client_id="eb959578-a74d-4ac3-8b25-bf0910027857", + client_secret="14c84a34-282b-4fd8-8af6-86b5b5f2c212", grant_type="client_credentials", ) diff --git a/src/monite/access_tokens/raw_client.py b/src/monite/access_tokens/raw_client.py index 76e0a85..d6ca850 100644 --- a/src/monite/access_tokens/raw_client.py +++ b/src/monite/access_tokens/raw_client.py @@ -8,7 +8,8 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.bad_request_error import BadRequestError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.access_token_response import AccessTokenResponse @@ -32,10 +33,13 @@ def revoke( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. token : str + The token to revoke. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -69,6 +73,17 @@ def revoke( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -80,8 +95,8 @@ def revoke( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -111,12 +126,19 @@ def create( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. grant_type : GrantType + The type of the access token to generate: + + * `client_credentials` - partner-level access token, + * `entity_user` - entity user token. entity_user_id : typing.Optional[str] + ID of the entity user to generate the access token for. Used only if `grant_type` is `entity_user`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -151,8 +173,8 @@ def create( ), ) return HttpResponse(response=_response, data=_data) - if _response.status_code == 401: - raise UnauthorizedError( + if _response.status_code == 400: + raise BadRequestError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -173,8 +195,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -203,10 +225,13 @@ async def revoke( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. token : str + The token to revoke. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -240,6 +265,17 @@ async def revoke( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -251,8 +287,8 @@ async def revoke( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -282,12 +318,19 @@ async def create( Parameters ---------- client_id : str + Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs. client_secret : str + Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets. grant_type : GrantType + The type of the access token to generate: + + * `client_credentials` - partner-level access token, + * `entity_user` - entity user token. entity_user_id : typing.Optional[str] + ID of the entity user to generate the access token for. Used only if `grant_type` is `entity_user`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -322,8 +365,8 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 401: - raise UnauthorizedError( + if _response.status_code == 400: + raise BadRequestError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -344,8 +387,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/accounting/connections/raw_client.py b/src/monite/accounting/connections/raw_client.py index 5dde54b..776689e 100644 --- a/src/monite/accounting/connections/raw_client.py +++ b/src/monite/accounting/connections/raw_client.py @@ -9,7 +9,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.accounting_connection_list import AccountingConnectionList from ...types.accounting_connection_response import AccountingConnectionResponse @@ -49,6 +50,17 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -60,8 +72,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -107,6 +119,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -118,8 +141,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -167,6 +190,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -178,8 +212,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -227,6 +261,17 @@ def disconnect_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -238,8 +283,8 @@ def disconnect_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -285,6 +330,17 @@ def sync_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -296,8 +352,8 @@ def sync_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -348,6 +404,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -359,8 +426,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -406,6 +473,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -417,8 +495,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -466,6 +544,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -477,8 +566,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -526,6 +615,17 @@ async def disconnect_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -537,8 +637,8 @@ async def disconnect_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -584,6 +684,17 @@ async def sync_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -595,8 +706,8 @@ async def sync_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/accounting/ledger_accounts/raw_client.py b/src/monite/accounting/ledger_accounts/raw_client.py index fe446f3..12138c2 100644 --- a/src/monite/accounting/ledger_accounts/raw_client.py +++ b/src/monite/accounting/ledger_accounts/raw_client.py @@ -9,7 +9,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.ledger_account_cursor_fields import LedgerAccountCursorFields from ...types.ledger_account_list_response import LedgerAccountListResponse @@ -80,6 +81,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -91,8 +103,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -140,6 +152,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -151,8 +174,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -231,6 +254,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -242,8 +276,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -291,6 +325,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -302,8 +347,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/accounting/payables/raw_client.py b/src/monite/accounting/payables/raw_client.py index 6be5a60..780dde3 100644 --- a/src/monite/accounting/payables/raw_client.py +++ b/src/monite/accounting/payables/raw_client.py @@ -9,7 +9,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.accounting_payable import AccountingPayable from ...types.accounting_payable_list import AccountingPayableList @@ -68,6 +69,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -79,8 +91,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -129,6 +141,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -140,8 +163,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -210,6 +233,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -221,8 +255,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -271,6 +305,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -282,8 +327,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/accounting/receivables/raw_client.py b/src/monite/accounting/receivables/raw_client.py index ad495f1..d58b92d 100644 --- a/src/monite/accounting/receivables/raw_client.py +++ b/src/monite/accounting/receivables/raw_client.py @@ -9,7 +9,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.accounting_receivable import AccountingReceivable from ...types.accounting_receivable_list import AccountingReceivableList @@ -68,6 +69,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -79,8 +91,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -129,6 +141,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -140,8 +163,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -210,6 +233,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -221,8 +255,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -271,6 +305,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -282,8 +327,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/accounting/synced_records/raw_client.py b/src/monite/accounting/synced_records/raw_client.py index 6ace964..ba12d8e 100644 --- a/src/monite/accounting/synced_records/raw_client.py +++ b/src/monite/accounting/synced_records/raw_client.py @@ -11,7 +11,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.object_match_types import ObjectMatchTypes from ...types.order_enum import OrderEnum @@ -127,6 +128,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -138,8 +150,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -187,6 +199,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -198,8 +221,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -247,6 +270,17 @@ def push_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -258,8 +292,8 @@ def push_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -382,6 +416,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -393,8 +438,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -442,6 +487,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -453,8 +509,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -502,6 +558,17 @@ async def push_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -513,8 +580,8 @@ async def push_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/accounting/tax_rates/raw_client.py b/src/monite/accounting/tax_rates/raw_client.py index 15f38fc..d11f72b 100644 --- a/src/monite/accounting/tax_rates/raw_client.py +++ b/src/monite/accounting/tax_rates/raw_client.py @@ -9,7 +9,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.accounting_tax_rate_list_response import AccountingTaxRateListResponse from ...types.accounting_tax_rate_response import AccountingTaxRateResponse @@ -80,6 +81,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -91,8 +103,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -140,6 +152,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -151,8 +174,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -231,6 +254,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -242,8 +276,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -291,6 +325,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -302,8 +347,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/analytics/raw_client.py b/src/monite/analytics/raw_client.py index 5082b2d..562ea45 100644 --- a/src/monite/analytics/raw_client.py +++ b/src/monite/analytics/raw_client.py @@ -12,7 +12,7 @@ from ..core.request_options import RequestOptions from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.aggregation_function_enum import AggregationFunctionEnum @@ -264,8 +264,8 @@ def get_analytics_credit_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -625,8 +625,8 @@ def get_analytics_payables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -999,8 +999,8 @@ def get_analytics_receivables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1241,8 +1241,8 @@ async def get_analytics_credit_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1602,8 +1602,8 @@ async def get_analytics_payables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1976,8 +1976,8 @@ async def get_analytics_receivables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/approval_policies/client.py b/src/monite/approval_policies/client.py index 8de4974..c1802b3 100644 --- a/src/monite/approval_policies/client.py +++ b/src/monite/approval_policies/client.py @@ -170,6 +170,7 @@ def create( script: typing.Sequence[ApprovalPolicyCreateScriptItem], description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, + priority: typing.Optional[int] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, trigger: typing.Optional[ApprovalPolicyCreateTrigger] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -191,6 +192,9 @@ def create( ends_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy stops being active and stops triggering approval workflows.If `ends_at` is provided in the request, then `starts_at` must also be provided and `ends_at` must be later than `starts_at`. The value will be converted to UTC. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + starts_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. @@ -224,6 +228,7 @@ def create( script=script, description=description, ends_at=ends_at, + priority=priority, starts_at=starts_at, trigger=trigger, request_options=request_options, @@ -302,6 +307,7 @@ def update_by_id( description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, + priority: typing.Optional[int] = OMIT, script: typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, status: typing.Optional[ApprovalPolicyStatus] = OMIT, @@ -324,6 +330,9 @@ def update_by_id( name : typing.Optional[str] The name of the approval policy. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + script : typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. @@ -362,6 +371,7 @@ def update_by_id( description=description, ends_at=ends_at, name=name, + priority=priority, script=script, starts_at=starts_at, status=status, @@ -526,6 +536,7 @@ async def create( script: typing.Sequence[ApprovalPolicyCreateScriptItem], description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, + priority: typing.Optional[int] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, trigger: typing.Optional[ApprovalPolicyCreateTrigger] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -547,6 +558,9 @@ async def create( ends_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy stops being active and stops triggering approval workflows.If `ends_at` is provided in the request, then `starts_at` must also be provided and `ends_at` must be later than `starts_at`. The value will be converted to UTC. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + starts_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. @@ -588,6 +602,7 @@ async def main() -> None: script=script, description=description, ends_at=ends_at, + priority=priority, starts_at=starts_at, trigger=trigger, request_options=request_options, @@ -684,6 +699,7 @@ async def update_by_id( description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, + priority: typing.Optional[int] = OMIT, script: typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, status: typing.Optional[ApprovalPolicyStatus] = OMIT, @@ -706,6 +722,9 @@ async def update_by_id( name : typing.Optional[str] The name of the approval policy. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + script : typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. @@ -752,6 +771,7 @@ async def main() -> None: description=description, ends_at=ends_at, name=name, + priority=priority, script=script, starts_at=starts_at, status=status, diff --git a/src/monite/approval_policies/processes/raw_client.py b/src/monite/approval_policies/processes/raw_client.py index 066ea06..04b2224 100644 --- a/src/monite/approval_policies/processes/raw_client.py +++ b/src/monite/approval_policies/processes/raw_client.py @@ -10,8 +10,8 @@ from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions from ...errors.conflict_error import ConflictError -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.approval_process_resource_list import ApprovalProcessResourceList @@ -100,8 +100,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -195,8 +195,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -290,8 +290,8 @@ def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -385,8 +385,8 @@ def get_steps( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -483,8 +483,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -578,8 +578,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -673,8 +673,8 @@ async def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -768,8 +768,8 @@ async def get_steps( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/approval_policies/raw_client.py b/src/monite/approval_policies/raw_client.py index da4fdf7..44e7e4e 100644 --- a/src/monite/approval_policies/raw_client.py +++ b/src/monite/approval_policies/raw_client.py @@ -14,8 +14,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.approval_policy_cursor_fields import ApprovalPolicyCursorFields @@ -196,8 +196,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -219,6 +219,7 @@ def create( script: typing.Sequence[ApprovalPolicyCreateScriptItem], description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, + priority: typing.Optional[int] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, trigger: typing.Optional[ApprovalPolicyCreateTrigger] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -240,6 +241,9 @@ def create( ends_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy stops being active and stops triggering approval workflows.If `ends_at` is provided in the request, then `starts_at` must also be provided and `ends_at` must be later than `starts_at`. The value will be converted to UTC. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + starts_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. @@ -261,6 +265,7 @@ def create( "description": description, "ends_at": ends_at, "name": name, + "priority": priority, "script": convert_and_respect_annotation_metadata( object_=script, annotation=typing.Sequence[ApprovalPolicyCreateScriptItem], direction="write" ), @@ -329,8 +334,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -422,8 +427,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -507,8 +512,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -530,6 +535,7 @@ def update_by_id( description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, + priority: typing.Optional[int] = OMIT, script: typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, status: typing.Optional[ApprovalPolicyStatus] = OMIT, @@ -552,6 +558,9 @@ def update_by_id( name : typing.Optional[str] The name of the approval policy. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + script : typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. @@ -579,6 +588,7 @@ def update_by_id( "description": description, "ends_at": ends_at, "name": name, + "priority": priority, "script": convert_and_respect_annotation_metadata( object_=script, annotation=typing.Sequence[ApprovalPolicyUpdateScriptItem], direction="write" ), @@ -659,8 +669,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -838,8 +848,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -861,6 +871,7 @@ async def create( script: typing.Sequence[ApprovalPolicyCreateScriptItem], description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, + priority: typing.Optional[int] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, trigger: typing.Optional[ApprovalPolicyCreateTrigger] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -882,6 +893,9 @@ async def create( ends_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy stops being active and stops triggering approval workflows.If `ends_at` is provided in the request, then `starts_at` must also be provided and `ends_at` must be later than `starts_at`. The value will be converted to UTC. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + starts_at : typing.Optional[dt.datetime] The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. @@ -903,6 +917,7 @@ async def create( "description": description, "ends_at": ends_at, "name": name, + "priority": priority, "script": convert_and_respect_annotation_metadata( object_=script, annotation=typing.Sequence[ApprovalPolicyCreateScriptItem], direction="write" ), @@ -971,8 +986,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1064,8 +1079,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1149,8 +1164,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1172,6 +1187,7 @@ async def update_by_id( description: typing.Optional[str] = OMIT, ends_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, + priority: typing.Optional[int] = OMIT, script: typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] = OMIT, starts_at: typing.Optional[dt.datetime] = OMIT, status: typing.Optional[ApprovalPolicyStatus] = OMIT, @@ -1194,6 +1210,9 @@ async def update_by_id( name : typing.Optional[str] The name of the approval policy. + priority : typing.Optional[int] + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + script : typing.Optional[typing.Sequence[ApprovalPolicyUpdateScriptItem]] A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. @@ -1221,6 +1240,7 @@ async def update_by_id( "description": description, "ends_at": ends_at, "name": name, + "priority": priority, "script": convert_and_respect_annotation_metadata( object_=script, annotation=typing.Sequence[ApprovalPolicyUpdateScriptItem], direction="write" ), @@ -1301,8 +1321,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/approval_requests/client.py b/src/monite/approval_requests/client.py index 8c964bb..0e6f7a4 100644 --- a/src/monite/approval_requests/client.py +++ b/src/monite/approval_requests/client.py @@ -63,16 +63,18 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ApprovalRequestCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -364,16 +366,18 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ApprovalRequestCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] diff --git a/src/monite/approval_requests/raw_client.py b/src/monite/approval_requests/raw_client.py index 29c7b62..fb573b6 100644 --- a/src/monite/approval_requests/raw_client.py +++ b/src/monite/approval_requests/raw_client.py @@ -15,9 +15,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.approval_request_create_request import ApprovalRequestCreateRequest @@ -66,16 +66,18 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ApprovalRequestCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -212,8 +214,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -332,8 +334,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -445,8 +447,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -558,8 +560,8 @@ def approve_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -671,8 +673,8 @@ def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -784,8 +786,8 @@ def reject_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -835,16 +837,18 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ApprovalRequestCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -981,8 +985,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1101,8 +1105,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1214,8 +1218,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1327,8 +1331,8 @@ async def approve_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1440,8 +1444,8 @@ async def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1553,8 +1557,8 @@ async def reject_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/client.py b/src/monite/client.py index 7edd723..6515934 100644 --- a/src/monite/client.py +++ b/src/monite/client.py @@ -20,6 +20,7 @@ from .data_exports.client import AsyncDataExportsClient, DataExportsClient from .delivery_notes.client import AsyncDeliveryNotesClient, DeliveryNotesClient from .e_invoicing_connections.client import AsyncEInvoicingConnectionsClient, EInvoicingConnectionsClient +from .e_invoicing_search.client import AsyncEInvoicingSearchClient, EInvoicingSearchClient from .entities.client import AsyncEntitiesClient, EntitiesClient from .entity_users.client import AsyncEntityUsersClient, EntityUsersClient from .environment import MoniteEnvironment @@ -43,6 +44,7 @@ from .products.client import AsyncProductsClient, ProductsClient from .projects.client import AsyncProjectsClient, ProjectsClient from .purchase_orders.client import AsyncPurchaseOrdersClient, PurchaseOrdersClient +from .receipts.client import AsyncReceiptsClient, ReceiptsClient from .receivables.client import AsyncReceivablesClient, ReceivablesClient from .recurrences.client import AsyncRecurrencesClient, RecurrencesClient from .roles.client import AsyncRolesClient, RolesClient @@ -139,6 +141,7 @@ def __init__( self.data_exports = DataExportsClient(client_wrapper=self._client_wrapper) self.delivery_notes = DeliveryNotesClient(client_wrapper=self._client_wrapper) self.pdf_templates = PdfTemplatesClient(client_wrapper=self._client_wrapper) + self.e_invoicing_search = EInvoicingSearchClient(client_wrapper=self._client_wrapper) self.e_invoicing_connections = EInvoicingConnectionsClient(client_wrapper=self._client_wrapper) self.entities = EntitiesClient(client_wrapper=self._client_wrapper) self.entity_users = EntityUsersClient(client_wrapper=self._client_wrapper) @@ -161,6 +164,7 @@ def __init__( self.payment_terms = PaymentTermsClient(client_wrapper=self._client_wrapper) self.products = ProductsClient(client_wrapper=self._client_wrapper) self.projects = ProjectsClient(client_wrapper=self._client_wrapper) + self.receipts = ReceiptsClient(client_wrapper=self._client_wrapper) self.receivables = ReceivablesClient(client_wrapper=self._client_wrapper) self.recurrences = RecurrencesClient(client_wrapper=self._client_wrapper) self.roles = RolesClient(client_wrapper=self._client_wrapper) @@ -259,6 +263,7 @@ def __init__( self.data_exports = AsyncDataExportsClient(client_wrapper=self._client_wrapper) self.delivery_notes = AsyncDeliveryNotesClient(client_wrapper=self._client_wrapper) self.pdf_templates = AsyncPdfTemplatesClient(client_wrapper=self._client_wrapper) + self.e_invoicing_search = AsyncEInvoicingSearchClient(client_wrapper=self._client_wrapper) self.e_invoicing_connections = AsyncEInvoicingConnectionsClient(client_wrapper=self._client_wrapper) self.entities = AsyncEntitiesClient(client_wrapper=self._client_wrapper) self.entity_users = AsyncEntityUsersClient(client_wrapper=self._client_wrapper) @@ -281,6 +286,7 @@ def __init__( self.payment_terms = AsyncPaymentTermsClient(client_wrapper=self._client_wrapper) self.products = AsyncProductsClient(client_wrapper=self._client_wrapper) self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper) + self.receipts = AsyncReceiptsClient(client_wrapper=self._client_wrapper) self.receivables = AsyncReceivablesClient(client_wrapper=self._client_wrapper) self.recurrences = AsyncRecurrencesClient(client_wrapper=self._client_wrapper) self.roles = AsyncRolesClient(client_wrapper=self._client_wrapper) diff --git a/src/monite/comments/client.py b/src/monite/comments/client.py index 10390da..14eff9a 100644 --- a/src/monite/comments/client.py +++ b/src/monite/comments/client.py @@ -52,16 +52,18 @@ def get( object_id : str order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[CommentCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -306,16 +308,18 @@ async def get( object_id : str order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[CommentCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] diff --git a/src/monite/comments/raw_client.py b/src/monite/comments/raw_client.py index 3ad2d01..ab3b4cb 100644 --- a/src/monite/comments/raw_client.py +++ b/src/monite/comments/raw_client.py @@ -14,8 +14,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.comment_cursor_fields import CommentCursorFields from ..types.comment_resource import CommentResource @@ -52,16 +53,18 @@ def get( object_id : str order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[CommentCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -117,6 +120,17 @@ def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -150,8 +164,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -232,6 +246,17 @@ def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -276,8 +301,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -336,6 +361,17 @@ def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -380,8 +416,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -432,6 +468,17 @@ def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -476,8 +523,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -553,6 +600,17 @@ def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -597,8 +655,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -640,16 +698,18 @@ async def get( object_id : str order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[CommentCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -705,6 +765,17 @@ async def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -738,8 +809,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -820,6 +891,17 @@ async def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -864,8 +946,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -924,6 +1006,17 @@ async def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -968,8 +1061,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1020,6 +1113,17 @@ async def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1064,8 +1168,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1141,6 +1245,17 @@ async def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1185,8 +1300,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/core/client_wrapper.py b/src/monite/core/client_wrapper.py index bf8e2ed..160f9e1 100644 --- a/src/monite/core/client_wrapper.py +++ b/src/monite/core/client_wrapper.py @@ -26,10 +26,10 @@ def __init__( def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { - "User-Agent": "monite/0.5.3", + "User-Agent": "monite/0.5.4", "X-Fern-Language": "Python", "X-Fern-SDK-Name": "monite", - "X-Fern-SDK-Version": "0.5.3", + "X-Fern-SDK-Version": "0.5.4", **(self.get_custom_headers() or {}), } headers["x-monite-version"] = self._monite_version diff --git a/src/monite/counterpart_e_invoicing_credentials/client.py b/src/monite/counterpart_e_invoicing_credentials/client.py index 7ae498c..75e6737 100644 --- a/src/monite/counterpart_e_invoicing_credentials/client.py +++ b/src/monite/counterpart_e_invoicing_credentials/client.py @@ -97,7 +97,7 @@ def post_counterparts_id_einvoicing_credentials( client.counterpart_e_invoicing_credentials.post_counterparts_id_einvoicing_credentials( counterpart_id="counterpart_id", request=CreateCounterpartEinvoicingCredentialCounterpartVatId( - counterpart_vat_id_id="counterpart_vat_id_id", + counterpart_vat_id_id="14c84a34-282b-4fd8-8af6-86b5b5f2c212", ), ) """ @@ -330,7 +330,7 @@ async def main() -> None: await client.counterpart_e_invoicing_credentials.post_counterparts_id_einvoicing_credentials( counterpart_id="counterpart_id", request=CreateCounterpartEinvoicingCredentialCounterpartVatId( - counterpart_vat_id_id="counterpart_vat_id_id", + counterpart_vat_id_id="14c84a34-282b-4fd8-8af6-86b5b5f2c212", ), ) diff --git a/src/monite/counterpart_e_invoicing_credentials/raw_client.py b/src/monite/counterpart_e_invoicing_credentials/raw_client.py index d339d92..ec35371 100644 --- a/src/monite/counterpart_e_invoicing_credentials/raw_client.py +++ b/src/monite/counterpart_e_invoicing_credentials/raw_client.py @@ -11,8 +11,9 @@ from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.conflict_error import ConflictError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.counterpart_einvoicing_credential_response import CounterpartEinvoicingCredentialResponse from ..types.counterpart_einvoicing_credential_response_list import CounterpartEinvoicingCredentialResponseList @@ -58,6 +59,17 @@ def get_counterparts_id_einvoicing_credentials( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -80,8 +92,8 @@ def get_counterparts_id_einvoicing_credentials( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -140,6 +152,17 @@ def post_counterparts_id_einvoicing_credentials( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -162,8 +185,8 @@ def post_counterparts_id_einvoicing_credentials( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -211,6 +234,17 @@ def get_counterparts_id_einvoicing_credentials_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -233,8 +267,8 @@ def get_counterparts_id_einvoicing_credentials_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -274,6 +308,17 @@ def delete_counterparts_id_einvoicing_credentials_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -296,8 +341,8 @@ def delete_counterparts_id_einvoicing_credentials_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -363,6 +408,17 @@ def patch_counterparts_id_einvoicing_credentials_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -385,8 +441,8 @@ def patch_counterparts_id_einvoicing_credentials_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -437,6 +493,17 @@ async def get_counterparts_id_einvoicing_credentials( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -459,8 +526,8 @@ async def get_counterparts_id_einvoicing_credentials( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -519,6 +586,17 @@ async def post_counterparts_id_einvoicing_credentials( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -541,8 +619,8 @@ async def post_counterparts_id_einvoicing_credentials( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -590,6 +668,17 @@ async def get_counterparts_id_einvoicing_credentials_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -612,8 +701,8 @@ async def get_counterparts_id_einvoicing_credentials_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -653,6 +742,17 @@ async def delete_counterparts_id_einvoicing_credentials_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -675,8 +775,8 @@ async def delete_counterparts_id_einvoicing_credentials_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -742,6 +842,17 @@ async def patch_counterparts_id_einvoicing_credentials_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -764,8 +875,8 @@ async def patch_counterparts_id_einvoicing_credentials_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/counterparts/addresses/client.py b/src/monite/counterparts/addresses/client.py index fb0ab97..04b0624 100644 --- a/src/monite/counterparts/addresses/client.py +++ b/src/monite/counterparts/addresses/client.py @@ -93,7 +93,7 @@ def create( Additional address information (if any). state : typing.Optional[str] - State, region, province, or county. + State, county, province, prefecture, region, or similar component of the counterpart's address. For US counterparts, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -363,7 +363,7 @@ async def create( Additional address information (if any). state : typing.Optional[str] - State, region, province, or county. + State, county, province, prefecture, region, or similar component of the counterpart's address. For US counterparts, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA. request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/monite/counterparts/addresses/raw_client.py b/src/monite/counterparts/addresses/raw_client.py index 79a6462..1dacc2a 100644 --- a/src/monite/counterparts/addresses/raw_client.py +++ b/src/monite/counterparts/addresses/raw_client.py @@ -9,8 +9,9 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.allowed_countries import AllowedCountries from ...types.counterpart_address_resource_list import CounterpartAddressResourceList @@ -55,6 +56,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -77,8 +89,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -126,7 +138,7 @@ def create( Additional address information (if any). state : typing.Optional[str] - State, region, province, or county. + State, county, province, prefecture, region, or similar component of the counterpart's address. For US counterparts, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -163,6 +175,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -185,8 +208,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -234,6 +257,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -256,8 +290,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -297,6 +331,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -319,8 +364,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -408,6 +453,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -430,8 +486,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -482,6 +538,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -504,8 +571,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -553,7 +620,7 @@ async def create( Additional address information (if any). state : typing.Optional[str] - State, region, province, or county. + State, county, province, prefecture, region, or similar component of the counterpart's address. For US counterparts, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -590,6 +657,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -612,8 +690,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -661,6 +739,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -683,8 +772,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -724,6 +813,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -746,8 +846,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -835,6 +935,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -857,8 +968,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/counterparts/bank_accounts/raw_client.py b/src/monite/counterparts/bank_accounts/raw_client.py index 2a6a9fa..61aac89 100644 --- a/src/monite/counterparts/bank_accounts/raw_client.py +++ b/src/monite/counterparts/bank_accounts/raw_client.py @@ -9,8 +9,9 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.allowed_countries import AllowedCountries from ...types.counterpart_bank_account_resource_list import CounterpartBankAccountResourceList @@ -56,6 +57,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -67,8 +79,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -174,6 +186,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -196,8 +219,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -245,6 +268,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -267,8 +301,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -308,6 +342,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -330,8 +375,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -436,6 +481,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -458,8 +514,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -509,6 +565,17 @@ def make_default_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -520,8 +587,8 @@ def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -572,6 +639,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -583,8 +661,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -690,6 +768,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -712,8 +801,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -761,6 +850,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -783,8 +883,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -824,6 +924,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -846,8 +957,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -952,6 +1063,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -974,8 +1096,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1025,6 +1147,17 @@ async def make_default_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1036,8 +1169,8 @@ async def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/counterparts/contacts/raw_client.py b/src/monite/counterparts/contacts/raw_client.py index b5567c0..e7750fe 100644 --- a/src/monite/counterparts/contacts/raw_client.py +++ b/src/monite/counterparts/contacts/raw_client.py @@ -10,8 +10,9 @@ from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions from ...core.serialization import convert_and_respect_annotation_metadata -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.counterpart_address import CounterpartAddress from ...types.counterpart_contact_response import CounterpartContactResponse @@ -56,6 +57,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -67,8 +79,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -155,6 +167,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -177,8 +200,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -226,6 +249,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -248,8 +282,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -289,6 +323,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -311,8 +356,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -402,6 +447,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -424,8 +480,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -473,6 +529,17 @@ def make_default_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -495,8 +562,8 @@ def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -547,6 +614,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -558,8 +636,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -646,6 +724,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -668,8 +757,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -717,6 +806,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -739,8 +839,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -780,6 +880,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -802,8 +913,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -893,6 +1004,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -915,8 +1037,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -964,6 +1086,17 @@ async def make_default_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -986,8 +1119,8 @@ async def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/counterparts/raw_client.py b/src/monite/counterparts/raw_client.py index f666f9e..44e519c 100644 --- a/src/monite/counterparts/raw_client.py +++ b/src/monite/counterparts/raw_client.py @@ -12,8 +12,9 @@ from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.counterpart_create_payload import CounterpartCreatePayload from ..types.counterpart_cursor_fields import CounterpartCursorFields @@ -201,6 +202,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -223,8 +235,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -277,6 +289,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -288,8 +311,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -335,6 +358,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -357,8 +391,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -396,6 +430,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -418,8 +463,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -478,6 +523,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -500,8 +556,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -547,6 +603,17 @@ def get_partner_metadata_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -558,8 +625,8 @@ def get_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -619,6 +686,17 @@ def update_partner_metadata_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -630,8 +708,8 @@ def update_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -820,6 +898,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -842,8 +931,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -896,6 +985,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -907,8 +1007,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -954,6 +1054,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -976,8 +1087,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1015,6 +1126,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1037,8 +1159,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1097,6 +1219,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1119,8 +1252,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1166,6 +1299,17 @@ async def get_partner_metadata_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1177,8 +1321,8 @@ async def get_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1238,6 +1382,17 @@ async def update_partner_metadata_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1249,8 +1404,8 @@ async def update_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/counterparts/vat_ids/raw_client.py b/src/monite/counterparts/vat_ids/raw_client.py index 6fa1fe4..110035f 100644 --- a/src/monite/counterparts/vat_ids/raw_client.py +++ b/src/monite/counterparts/vat_ids/raw_client.py @@ -9,8 +9,9 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.allowed_countries import AllowedCountries from ...types.counterpart_vat_id_resource_list import CounterpartVatIdResourceList @@ -56,6 +57,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -67,8 +79,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -135,6 +147,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -157,8 +180,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -206,6 +229,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -228,8 +262,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -269,6 +303,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -291,8 +336,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -362,6 +407,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -384,8 +440,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -436,6 +492,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -447,8 +514,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -515,6 +582,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -537,8 +615,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -586,6 +664,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -608,8 +697,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -649,6 +738,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -671,8 +771,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -742,6 +842,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -764,8 +875,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/credit_notes/raw_client.py b/src/monite/credit_notes/raw_client.py index 8efcd4f..ff67a18 100644 --- a/src/monite/credit_notes/raw_client.py +++ b/src/monite/credit_notes/raw_client.py @@ -16,9 +16,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.credit_note_cursor_fields import CreditNoteCursorFields @@ -286,8 +286,8 @@ def get_payable_credit_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -468,8 +468,8 @@ def post_payable_credit_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -579,8 +579,8 @@ def post_payable_credit_notes_upload_from_file( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -670,8 +670,8 @@ def get_payable_credit_notes_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -773,8 +773,8 @@ def put_payable_credit_notes_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -864,8 +864,8 @@ def post_payable_credit_notes_validations_reset( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -955,8 +955,8 @@ def get_payable_credit_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1049,8 +1049,8 @@ def delete_payable_credit_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1234,8 +1234,8 @@ def patch_payable_credit_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1338,8 +1338,8 @@ def post_payable_credit_notes_id_approve( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1442,8 +1442,8 @@ def post_payable_credit_notes_id_cancel( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1557,8 +1557,8 @@ def post_payable_credit_notes_id_cancel_ocr( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1835,8 +1835,8 @@ def get_payable_credit_notes_id_line_items( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1965,8 +1965,8 @@ def post_payable_credit_notes_id_line_items( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2072,8 +2072,8 @@ def put_payable_credit_notes_id_line_items( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2165,8 +2165,8 @@ def get_payable_credit_notes_id_line_items_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2258,8 +2258,8 @@ def delete_payable_credit_notes_id_line_items_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2391,8 +2391,8 @@ def patch_payable_credit_notes_id_line_items_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2495,8 +2495,8 @@ def post_payable_credit_notes_id_reject( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2599,8 +2599,8 @@ def post_payable_credit_notes_id_submit_for_approval( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2690,8 +2690,8 @@ def get_payable_credit_notes_id_validate( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2953,8 +2953,8 @@ async def get_payable_credit_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3135,8 +3135,8 @@ async def post_payable_credit_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3246,8 +3246,8 @@ async def post_payable_credit_notes_upload_from_file( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3337,8 +3337,8 @@ async def get_payable_credit_notes_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3440,8 +3440,8 @@ async def put_payable_credit_notes_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3531,8 +3531,8 @@ async def post_payable_credit_notes_validations_reset( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3622,8 +3622,8 @@ async def get_payable_credit_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3716,8 +3716,8 @@ async def delete_payable_credit_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3901,8 +3901,8 @@ async def patch_payable_credit_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4005,8 +4005,8 @@ async def post_payable_credit_notes_id_approve( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4109,8 +4109,8 @@ async def post_payable_credit_notes_id_cancel( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4224,8 +4224,8 @@ async def post_payable_credit_notes_id_cancel_ocr( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4502,8 +4502,8 @@ async def get_payable_credit_notes_id_line_items( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4632,8 +4632,8 @@ async def post_payable_credit_notes_id_line_items( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4739,8 +4739,8 @@ async def put_payable_credit_notes_id_line_items( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4832,8 +4832,8 @@ async def get_payable_credit_notes_id_line_items_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4925,8 +4925,8 @@ async def delete_payable_credit_notes_id_line_items_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5058,8 +5058,8 @@ async def patch_payable_credit_notes_id_line_items_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5162,8 +5162,8 @@ async def post_payable_credit_notes_id_reject( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5266,8 +5266,8 @@ async def post_payable_credit_notes_id_submit_for_approval( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5357,8 +5357,8 @@ async def get_payable_credit_notes_id_validate( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/custom_vat_rates/raw_client.py b/src/monite/custom_vat_rates/raw_client.py index 3fdfeb5..eb6e067 100644 --- a/src/monite/custom_vat_rates/raw_client.py +++ b/src/monite/custom_vat_rates/raw_client.py @@ -12,8 +12,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.custom_vat_rate_response import CustomVatRateResponse @@ -101,8 +101,8 @@ def get_custom_vat_rates( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -210,8 +210,8 @@ def post_custom_vat_rates( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -312,8 +312,8 @@ def get_custom_vat_rates_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -406,8 +406,8 @@ def delete_custom_vat_rates_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -529,8 +529,8 @@ def patch_custom_vat_rates_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -623,8 +623,8 @@ async def get_custom_vat_rates( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -732,8 +732,8 @@ async def post_custom_vat_rates( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -834,8 +834,8 @@ async def get_custom_vat_rates_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -928,8 +928,8 @@ async def delete_custom_vat_rates_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1051,8 +1051,8 @@ async def patch_custom_vat_rates_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/data_exports/client.py b/src/monite/data_exports/client.py index 17e8452..a7d04c3 100644 --- a/src/monite/data_exports/client.py +++ b/src/monite/data_exports/client.py @@ -54,16 +54,18 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[DataExportCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -258,16 +260,18 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[DataExportCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] diff --git a/src/monite/data_exports/extra_data/client.py b/src/monite/data_exports/extra_data/client.py index 2888270..2f083dc 100644 --- a/src/monite/data_exports/extra_data/client.py +++ b/src/monite/data_exports/extra_data/client.py @@ -55,16 +55,18 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ExportSettingCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -330,16 +332,18 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ExportSettingCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] diff --git a/src/monite/data_exports/extra_data/raw_client.py b/src/monite/data_exports/extra_data/raw_client.py index af1a5d1..b9983f7 100644 --- a/src/monite/data_exports/extra_data/raw_client.py +++ b/src/monite/data_exports/extra_data/raw_client.py @@ -13,8 +13,8 @@ from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.forbidden_error import ForbiddenError -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.export_setting_cursor_fields import ExportSettingCursorFields @@ -55,16 +55,18 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ExportSettingCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -161,8 +163,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -271,8 +273,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -362,8 +364,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -453,8 +455,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -580,8 +582,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -625,16 +627,18 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[ExportSettingCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -731,8 +735,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -841,8 +845,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -932,8 +936,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1023,8 +1027,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1150,8 +1154,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/data_exports/raw_client.py b/src/monite/data_exports/raw_client.py index 00523a3..2523188 100644 --- a/src/monite/data_exports/raw_client.py +++ b/src/monite/data_exports/raw_client.py @@ -15,9 +15,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.all_document_export_response_schema import AllDocumentExportResponseSchema @@ -55,16 +55,18 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[DataExportCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -165,8 +167,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -304,8 +306,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -349,6 +351,17 @@ def get_supported_formats( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -360,8 +373,8 @@ def get_supported_formats( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -462,8 +475,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -501,16 +514,18 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] - Max is 100 + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. pagination_token : typing.Optional[str] - A token, obtained from previous page. Prior over other filters + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. sort : typing.Optional[DataExportCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. created_at_gt : typing.Optional[dt.datetime] @@ -611,8 +626,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -750,8 +765,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -795,6 +810,17 @@ async def get_supported_formats( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -806,8 +832,8 @@ async def get_supported_formats( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -908,8 +934,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/delivery_notes/client.py b/src/monite/delivery_notes/client.py index cecb696..3d52e11 100644 --- a/src/monite/delivery_notes/client.py +++ b/src/monite/delivery_notes/client.py @@ -194,7 +194,6 @@ def post_delivery_notes( DeliveryNoteCreateRequest, DeliveryNoteLineItemProduct, Monite, - UnitRequest, ) client = Monite( @@ -204,29 +203,23 @@ def post_delivery_notes( ) client.delivery_notes.post_delivery_notes( request=DeliveryNoteCreateRequest( - counterpart_address_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - counterpart_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - delivery_date="2025-01-01", - delivery_number="102-2025-0987", + counterpart_address_id="9a0282e1-bae7-49c9-a6f3-152dbe6fe6b8", + counterpart_id="18a45457-377e-4b7c-b9a1-7b2e7f264d46", + delivery_date="2025-07-01", + delivery_number="INV-042", display_signature_placeholder=True, line_items=[ DeliveryNoteCreateLineItem( - product_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + product=DeliveryNoteLineItemProduct( + name="LG WH1000XM Monitor", + ), quantity=10.0, ), DeliveryNoteCreateLineItem( - product=DeliveryNoteLineItemProduct( - description="Description of product 2", - measure_unit=UnitRequest( - description="pieces", - name="pcs", - ), - name="Product 2", - ), - quantity=20.0, + product_id="e0c21d00-6556-4536-8390-830c4d3cf4ca", + quantity=5.0, ), ], - memo="This is a memo", ), ) """ @@ -333,7 +326,7 @@ def patch_delivery_notes_id( List of line items in the delivery note memo : typing.Optional[str] - Additional information regarding the delivery note + An optional note for the customer, displayed above the line items table in the PDF. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -622,7 +615,6 @@ async def post_delivery_notes( DeliveryNoteCreateLineItem, DeliveryNoteCreateRequest, DeliveryNoteLineItemProduct, - UnitRequest, ) client = AsyncMonite( @@ -635,29 +627,23 @@ async def post_delivery_notes( async def main() -> None: await client.delivery_notes.post_delivery_notes( request=DeliveryNoteCreateRequest( - counterpart_address_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - counterpart_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", - delivery_date="2025-01-01", - delivery_number="102-2025-0987", + counterpart_address_id="9a0282e1-bae7-49c9-a6f3-152dbe6fe6b8", + counterpart_id="18a45457-377e-4b7c-b9a1-7b2e7f264d46", + delivery_date="2025-07-01", + delivery_number="INV-042", display_signature_placeholder=True, line_items=[ DeliveryNoteCreateLineItem( - product_id="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + product=DeliveryNoteLineItemProduct( + name="LG WH1000XM Monitor", + ), quantity=10.0, ), DeliveryNoteCreateLineItem( - product=DeliveryNoteLineItemProduct( - description="Description of product 2", - measure_unit=UnitRequest( - description="pieces", - name="pcs", - ), - name="Product 2", - ), - quantity=20.0, + product_id="e0c21d00-6556-4536-8390-830c4d3cf4ca", + quantity=5.0, ), ], - memo="This is a memo", ), ) @@ -783,7 +769,7 @@ async def patch_delivery_notes_id( List of line items in the delivery note memo : typing.Optional[str] - Additional information regarding the delivery note + An optional note for the customer, displayed above the line items table in the PDF. request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/monite/delivery_notes/raw_client.py b/src/monite/delivery_notes/raw_client.py index 96fb2ac..dad23c6 100644 --- a/src/monite/delivery_notes/raw_client.py +++ b/src/monite/delivery_notes/raw_client.py @@ -15,8 +15,8 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.delivery_note_create_line_item import DeliveryNoteCreateLineItem @@ -218,8 +218,8 @@ def get_delivery_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -336,8 +336,8 @@ def post_delivery_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -438,8 +438,8 @@ def get_delivery_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -532,8 +532,8 @@ def delete_delivery_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -585,7 +585,7 @@ def patch_delivery_notes_id( List of line items in the delivery note memo : typing.Optional[str] - Additional information regarding the delivery note + An optional note for the customer, displayed above the line items table in the PDF. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -691,8 +691,8 @@ def patch_delivery_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -804,8 +804,8 @@ def post_delivery_notes_id_cancel( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -917,8 +917,8 @@ def post_delivery_notes_id_mark_as_delivered( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1121,8 +1121,8 @@ async def get_delivery_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1239,8 +1239,8 @@ async def post_delivery_notes( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1341,8 +1341,8 @@ async def get_delivery_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1435,8 +1435,8 @@ async def delete_delivery_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1488,7 +1488,7 @@ async def patch_delivery_notes_id( List of line items in the delivery note memo : typing.Optional[str] - Additional information regarding the delivery note + An optional note for the customer, displayed above the line items table in the PDF. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1594,8 +1594,8 @@ async def patch_delivery_notes_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1707,8 +1707,8 @@ async def post_delivery_notes_id_cancel( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1820,8 +1820,8 @@ async def post_delivery_notes_id_mark_as_delivered( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/e_invoicing_connections/raw_client.py b/src/monite/e_invoicing_connections/raw_client.py index 69e7a19..291fa79 100644 --- a/src/monite/e_invoicing_connections/raw_client.py +++ b/src/monite/e_invoicing_connections/raw_client.py @@ -13,8 +13,8 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.e_invoicing_retrieve_list_data import EInvoicingRetrieveListData @@ -105,8 +105,8 @@ def get_einvoicing_connections( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -235,8 +235,8 @@ def post_einvoicing_connections( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -337,8 +337,8 @@ def get_einvoicing_connections_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -431,8 +431,8 @@ def delete_einvoicing_connections_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -570,8 +570,8 @@ def patch_einvoicing_connections_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -702,8 +702,8 @@ def post_einvoicing_connections_id_network_credentials( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -796,8 +796,8 @@ async def get_einvoicing_connections( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -926,8 +926,8 @@ async def post_einvoicing_connections( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1028,8 +1028,8 @@ async def get_einvoicing_connections_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1122,8 +1122,8 @@ async def delete_einvoicing_connections_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1261,8 +1261,8 @@ async def patch_einvoicing_connections_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1393,8 +1393,8 @@ async def post_einvoicing_connections_id_network_credentials( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/types/airwallex_mandate_version.py b/src/monite/e_invoicing_search/__init__.py similarity index 51% rename from src/monite/types/airwallex_mandate_version.py rename to src/monite/e_invoicing_search/__init__.py index 0a63ecf..5cde020 100644 --- a/src/monite/types/airwallex_mandate_version.py +++ b/src/monite/e_invoicing_search/__init__.py @@ -1,5 +1,4 @@ # This file was auto-generated by Fern from our API Definition. -import typing +# isort: skip_file -AirwallexMandateVersion = typing.Literal["1.0"] diff --git a/src/monite/e_invoicing_search/client.py b/src/monite/e_invoicing_search/client.py new file mode 100644 index 0000000..19d516b --- /dev/null +++ b/src/monite/e_invoicing_search/client.py @@ -0,0 +1,157 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from ..types.counterpart_einvoicing_credential_existence_response import ( + CounterpartEinvoicingCredentialExistenceResponse, +) +from ..types.einvoice_schema_type_enum import EinvoiceSchemaTypeEnum +from .raw_client import AsyncRawEInvoicingSearchClient, RawEInvoicingSearchClient + + +class EInvoicingSearchClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawEInvoicingSearchClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawEInvoicingSearchClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawEInvoicingSearchClient + """ + return self._raw_client + + def get_einvoice_search( + self, + *, + network_identifier: str, + network_schema: EinvoiceSchemaTypeEnum, + request_options: typing.Optional[RequestOptions] = None, + ) -> CounterpartEinvoicingCredentialExistenceResponse: + """ + Checks if the specified VAT number or business number is registered on the PEPPOL network as a receiver. For example, you can use this endpoint to check if an entity's counterparts are registered in PEPPOL before creating e-invoices for those counterparts. + + The lookup is powered by PEPPOL SMPs (Service Metadata Publishers) so it also includes registrations that are not visible in the public PEPPOL directory. + + Both partner tokens and entity user tokens can be used for authentication. + + Production and sandbox lookups are separate. + + Parameters + ---------- + network_identifier : str + VAT number or business number, depending on the `network_schema` used. VAT numbers must include the country prefix, for example, use `DE010101010` not `10101010`. + + **Note:** This endpoint does not validate the format of VAT numbers and business numbers (such as the length or characters used). Invalid values will return `{"exists": false}`. + + network_schema : EinvoiceSchemaTypeEnum + [PEPPOL scheme](https://docs.monite.com/e-invoicing/peppol-ids#schemes) name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CounterpartEinvoicingCredentialExistenceResponse + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.e_invoicing_search.get_einvoice_search( + network_identifier="DE010101010", + network_schema="DE:VAT", + ) + """ + _response = self._raw_client.get_einvoice_search( + network_identifier=network_identifier, network_schema=network_schema, request_options=request_options + ) + return _response.data + + +class AsyncEInvoicingSearchClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawEInvoicingSearchClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawEInvoicingSearchClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawEInvoicingSearchClient + """ + return self._raw_client + + async def get_einvoice_search( + self, + *, + network_identifier: str, + network_schema: EinvoiceSchemaTypeEnum, + request_options: typing.Optional[RequestOptions] = None, + ) -> CounterpartEinvoicingCredentialExistenceResponse: + """ + Checks if the specified VAT number or business number is registered on the PEPPOL network as a receiver. For example, you can use this endpoint to check if an entity's counterparts are registered in PEPPOL before creating e-invoices for those counterparts. + + The lookup is powered by PEPPOL SMPs (Service Metadata Publishers) so it also includes registrations that are not visible in the public PEPPOL directory. + + Both partner tokens and entity user tokens can be used for authentication. + + Production and sandbox lookups are separate. + + Parameters + ---------- + network_identifier : str + VAT number or business number, depending on the `network_schema` used. VAT numbers must include the country prefix, for example, use `DE010101010` not `10101010`. + + **Note:** This endpoint does not validate the format of VAT numbers and business numbers (such as the length or characters used). Invalid values will return `{"exists": false}`. + + network_schema : EinvoiceSchemaTypeEnum + [PEPPOL scheme](https://docs.monite.com/e-invoicing/peppol-ids#schemes) name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CounterpartEinvoicingCredentialExistenceResponse + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.e_invoicing_search.get_einvoice_search( + network_identifier="DE010101010", + network_schema="DE:VAT", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_einvoice_search( + network_identifier=network_identifier, network_schema=network_schema, request_options=request_options + ) + return _response.data diff --git a/src/monite/e_invoicing_search/raw_client.py b/src/monite/e_invoicing_search/raw_client.py new file mode 100644 index 0000000..d42421f --- /dev/null +++ b/src/monite/e_invoicing_search/raw_client.py @@ -0,0 +1,209 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.counterpart_einvoicing_credential_existence_response import ( + CounterpartEinvoicingCredentialExistenceResponse, +) +from ..types.einvoice_schema_type_enum import EinvoiceSchemaTypeEnum + + +class RawEInvoicingSearchClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_einvoice_search( + self, + *, + network_identifier: str, + network_schema: EinvoiceSchemaTypeEnum, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CounterpartEinvoicingCredentialExistenceResponse]: + """ + Checks if the specified VAT number or business number is registered on the PEPPOL network as a receiver. For example, you can use this endpoint to check if an entity's counterparts are registered in PEPPOL before creating e-invoices for those counterparts. + + The lookup is powered by PEPPOL SMPs (Service Metadata Publishers) so it also includes registrations that are not visible in the public PEPPOL directory. + + Both partner tokens and entity user tokens can be used for authentication. + + Production and sandbox lookups are separate. + + Parameters + ---------- + network_identifier : str + VAT number or business number, depending on the `network_schema` used. VAT numbers must include the country prefix, for example, use `DE010101010` not `10101010`. + + **Note:** This endpoint does not validate the format of VAT numbers and business numbers (such as the length or characters used). Invalid values will return `{"exists": false}`. + + network_schema : EinvoiceSchemaTypeEnum + [PEPPOL scheme](https://docs.monite.com/e-invoicing/peppol-ids#schemes) name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CounterpartEinvoicingCredentialExistenceResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "einvoice_search", + method="GET", + params={ + "network_identifier": network_identifier, + "network_schema": network_schema, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CounterpartEinvoicingCredentialExistenceResponse, + parse_obj_as( + type_=CounterpartEinvoicingCredentialExistenceResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawEInvoicingSearchClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_einvoice_search( + self, + *, + network_identifier: str, + network_schema: EinvoiceSchemaTypeEnum, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CounterpartEinvoicingCredentialExistenceResponse]: + """ + Checks if the specified VAT number or business number is registered on the PEPPOL network as a receiver. For example, you can use this endpoint to check if an entity's counterparts are registered in PEPPOL before creating e-invoices for those counterparts. + + The lookup is powered by PEPPOL SMPs (Service Metadata Publishers) so it also includes registrations that are not visible in the public PEPPOL directory. + + Both partner tokens and entity user tokens can be used for authentication. + + Production and sandbox lookups are separate. + + Parameters + ---------- + network_identifier : str + VAT number or business number, depending on the `network_schema` used. VAT numbers must include the country prefix, for example, use `DE010101010` not `10101010`. + + **Note:** This endpoint does not validate the format of VAT numbers and business numbers (such as the length or characters used). Invalid values will return `{"exists": false}`. + + network_schema : EinvoiceSchemaTypeEnum + [PEPPOL scheme](https://docs.monite.com/e-invoicing/peppol-ids#schemes) name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CounterpartEinvoicingCredentialExistenceResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "einvoice_search", + method="GET", + params={ + "network_identifier": network_identifier, + "network_schema": network_schema, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CounterpartEinvoicingCredentialExistenceResponse, + parse_obj_as( + type_=CounterpartEinvoicingCredentialExistenceResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/monite/entities/bank_accounts/client.py b/src/monite/entities/bank_accounts/client.py index 497199f..2b47401 100644 --- a/src/monite/entities/bank_accounts/client.py +++ b/src/monite/entities/bank_accounts/client.py @@ -146,8 +146,14 @@ def create( token="YOUR_TOKEN", ) client.entities.bank_accounts.create( - country="AF", - currency="AED", + account_holder_name="Tobias Weingart", + bank_name="DEUTSCHE BANK AG", + bic="DEUTDEFFXXX", + country="DE", + currency="EUR", + display_name="Primary account", + iban="DE74500700100100000900", + is_default_for_currency=True, ) """ _response = self._raw_client.create( @@ -463,8 +469,14 @@ async def create( async def main() -> None: await client.entities.bank_accounts.create( - country="AF", - currency="AED", + account_holder_name="Tobias Weingart", + bank_name="DEUTSCHE BANK AG", + bic="DEUTDEFFXXX", + country="DE", + currency="EUR", + display_name="Primary account", + iban="DE74500700100100000900", + is_default_for_currency=True, ) diff --git a/src/monite/entities/bank_accounts/raw_client.py b/src/monite/entities/bank_accounts/raw_client.py index 0cf5c92..9d6b166 100644 --- a/src/monite/entities/bank_accounts/raw_client.py +++ b/src/monite/entities/bank_accounts/raw_client.py @@ -10,8 +10,9 @@ from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions from ...errors.conflict_error import ConflictError -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.allowed_countries import AllowedCountries from ...types.currency_enum import CurrencyEnum @@ -57,6 +58,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -79,8 +91,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -206,6 +218,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -228,8 +251,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -277,6 +300,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -310,8 +344,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -351,6 +385,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -384,8 +429,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -452,6 +497,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -485,8 +541,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -534,6 +590,17 @@ def make_default_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -567,8 +634,8 @@ def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -619,6 +686,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -641,8 +719,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -768,6 +846,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -790,8 +879,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -839,6 +928,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -872,8 +972,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -913,6 +1013,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -946,8 +1057,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1014,6 +1125,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1047,8 +1169,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1096,6 +1218,17 @@ async def make_default_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1129,8 +1262,8 @@ async def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/entities/client.py b/src/monite/entities/client.py index 102d318..818cff1 100644 --- a/src/monite/entities/client.py +++ b/src/monite/entities/client.py @@ -9,7 +9,7 @@ from ..types.accounting_settings import AccountingSettings from ..types.currency_settings_input import CurrencySettingsInput from ..types.document_i_ds_settings_request import DocumentIDsSettingsRequest -from ..types.document_rendering_settings import DocumentRenderingSettings +from ..types.document_rendering_settings_input import DocumentRenderingSettingsInput from ..types.entity_address_schema import EntityAddressSchema from ..types.entity_cursor_fields import EntityCursorFields from ..types.entity_pagination_response import EntityPaginationResponse @@ -20,6 +20,7 @@ from ..types.get_onboarding_requirements_response import GetOnboardingRequirementsResponse from ..types.individual_schema import IndividualSchema from ..types.language_code_enum import LanguageCodeEnum +from ..types.next_document_numbers import NextDocumentNumbers from ..types.ocr_auto_tagging_settings_request import OcrAutoTaggingSettingsRequest from ..types.optional_individual_schema import OptionalIndividualSchema from ..types.optional_organization_schema import OptionalOrganizationSchema @@ -173,13 +174,13 @@ def create( address: EntityAddressSchema, email: str, type: EntityTypeEnum, - phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - organization: typing.Optional[OrganizationSchema] = OMIT, individual: typing.Optional[IndividualSchema] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, + organization: typing.Optional[OrganizationSchema] = OMIT, + phone: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -196,26 +197,26 @@ def create( type : EntityTypeEnum A type for an entity - phone : typing.Optional[str] - The contact phone number of the entity. Required for US organizations to use payments. - - website : typing.Optional[str] - A website of the entity + individual : typing.Optional[IndividualSchema] + A set of meta data describing the individual organization : typing.Optional[OrganizationSchema] A set of meta data describing the organization - individual : typing.Optional[IndividualSchema] - A set of meta data describing the individual + phone : typing.Optional[str] + The contact phone number of the entity. Required for US organizations to use payments. - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -249,13 +250,13 @@ def create( address=address, email=email, type=type, - phone=phone, - website=website, - organization=organization, individual=individual, - tax_id=tax_id, - registration_number=registration_number, + organization=organization, + phone=phone, registration_authority=registration_authority, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -293,13 +294,13 @@ def patch_entities_me( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -313,26 +314,26 @@ def patch_entities_me( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -356,20 +357,28 @@ def patch_entities_me( _response = self._raw_client.patch_entities_me( address=address, email=email, + individual=individual, + organization=organization, phone=phone, - website=website, - tax_id=tax_id, - registration_number=registration_number, registration_authority=registration_authority, - organization=organization, - individual=individual, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data def get_by_id(self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> EntityResponse: """ - Retrieve an entity by its ID. + Returns entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to get any of the partner's entities. + + To get entity information by using an entity user token, use [`GET /entity_users/my_entity`](https://docs.monite.com/api/entities/get-entity-users-my-entity) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -406,17 +415,26 @@ def update_by_id( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ - Change the specified fields with the provided values. + Update entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to update any of the partner's entities. + + To update an entity by using an entity user token, use [`PATCH /entity_users/my_entity`](https://docs.monite.com/api/entities/patch-entity-users-my-entity) instead. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -429,26 +447,26 @@ def update_by_id( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -475,13 +493,13 @@ def update_by_id( entity_id, address=address, email=email, + individual=individual, + organization=organization, phone=phone, - website=website, - tax_id=tax_id, - registration_number=registration_number, registration_authority=registration_authority, - organization=organization, - individual=individual, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -562,6 +580,8 @@ def upload_logo_by_id( """ Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -596,6 +616,8 @@ def upload_logo_by_id( def delete_logo_by_id(self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -706,7 +728,14 @@ def get_settings_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SettingsResponse: """ - Retrieve all settings for this entity. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.read` permission. + + Related endpoints: + + * [Get next document numbers](https://docs.monite.com/api/entities/get-entities-id-settings-next-document-numbers) + * [Get partner settings](https://docs.monite.com/api/partner-settings/get-settings) Parameters ---------- @@ -741,73 +770,88 @@ def update_settings_by_id( self, entity_id: str, *, - language: typing.Optional[LanguageCodeEnum] = OMIT, - currency: typing.Optional[CurrencySettingsInput] = OMIT, - reminder: typing.Optional[RemindersSettings] = OMIT, - vat_mode: typing.Optional[VatModeEnum] = OMIT, - vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, - payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + accounting: typing.Optional[AccountingSettings] = OMIT, allow_purchase_order_autolinking: typing.Optional[bool] = OMIT, - receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + currency: typing.Optional[CurrencySettingsInput] = OMIT, document_ids: typing.Optional[DocumentIDsSettingsRequest] = OMIT, - payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, - quote_signature_required: typing.Optional[bool] = OMIT, + document_rendering: typing.Optional[DocumentRenderingSettingsInput] = OMIT, generate_paid_invoice_pdf: typing.Optional[bool] = OMIT, - accounting: typing.Optional[AccountingSettings] = OMIT, + language: typing.Optional[LanguageCodeEnum] = OMIT, + payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, payables_skip_approval_flow: typing.Optional[bool] = OMIT, - document_rendering: typing.Optional[DocumentRenderingSettings] = OMIT, + payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + quote_signature_required: typing.Optional[bool] = OMIT, + receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + reminder: typing.Optional[RemindersSettings] = OMIT, + vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, + vat_mode: typing.Optional[VatModeEnum] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> SettingsResponse: """ - Change the specified fields with the provided values. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + + Related endpoints: + + * [Update an entity](https://docs.monite.com/api/entities/patch-entities-id) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) + * [Update partner settings](https://docs.monite.com/api/partner-settings/patch-settings) Parameters ---------- entity_id : str A unique ID to specify the entity. - language : typing.Optional[LanguageCodeEnum] + accounting : typing.Optional[AccountingSettings] - currency : typing.Optional[CurrencySettingsInput] + allow_purchase_order_autolinking : typing.Optional[bool] + Automatically attempt to find a corresponding purchase order for all incoming payables. - reminder : typing.Optional[RemindersSettings] + currency : typing.Optional[CurrencySettingsInput] - vat_mode : typing.Optional[VatModeEnum] - Defines whether the prices of products in receivables will already include VAT or not. + document_ids : typing.Optional[DocumentIDsSettingsRequest] - vat_inclusive_discount_mode : typing.Optional[VatModeEnum] - Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. + document_rendering : typing.Optional[DocumentRenderingSettingsInput] + Settings for rendering documents in PDF format. - payment_priority : typing.Optional[PaymentPriorityEnum] - Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + generate_paid_invoice_pdf : typing.Optional[bool] + This setting affects how PDF is generated for accounts receivable invoices that are paid, partially paid, or have credit notes applied. + If this setting is `true`: - allow_purchase_order_autolinking : typing.Optional[bool] - Automatically attempt to find a corresponding purchase order for all incoming payables. + * The totals block in the PDF invoice will include a list of all payments made and credit notes issued. + * Once an invoice becomes fully paid, the payment link and QR code are removed. - receivable_edit_flow : typing.Optional[ReceivableEditFlow] + The PDF invoice gets regenerated at the moment when an invoice payment is recorded or a credit note is issued. This PDF is not issued as a separate document, and the original PDF invoice is no longer available. - document_ids : typing.Optional[DocumentIDsSettingsRequest] + language : typing.Optional[LanguageCodeEnum] payables_ocr_auto_tagging : typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] Auto tagging settings for all incoming OCR payable documents. + payables_skip_approval_flow : typing.Optional[bool] + If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + + payment_priority : typing.Optional[PaymentPriorityEnum] + Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + quote_signature_required : typing.Optional[bool] Sets the default behavior of whether a signature is required to accept quotes. - generate_paid_invoice_pdf : typing.Optional[bool] - This setting affects how PDF is generated for paid accounts receivable invoices. If set to `true`, once an invoice is fully paid its PDF version is updated to display the amount paid and the payment-related features are removed. - - The PDF file gets regenerated at the moment when an invoice becomes paid. It is not issued as a separate document, and the original PDF invoice is no longer available. + receivable_edit_flow : typing.Optional[ReceivableEditFlow] + [Invoice compliance mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance) for accounts receivable. Possible values: - This field is deprecated and will be replaced by `document_rendering.invoice.generate_paid_invoice_pdf`. + * `compliant` - invoices cannot be edited once issued. + * `non_compliant` - issued invoices can still be edited. + * `partially_compliant` - deprecated mode, should not be used. - accounting : typing.Optional[AccountingSettings] + reminder : typing.Optional[RemindersSettings] - payables_skip_approval_flow : typing.Optional[bool] - If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + vat_inclusive_discount_mode : typing.Optional[VatModeEnum] + Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. - document_rendering : typing.Optional[DocumentRenderingSettings] - Settings for rendering documents in PDF format. + vat_mode : typing.Optional[VatModeEnum] + Defines whether the prices of products in receivables will already include VAT or not. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -832,25 +876,66 @@ def update_settings_by_id( """ _response = self._raw_client.update_settings_by_id( entity_id, - language=language, - currency=currency, - reminder=reminder, - vat_mode=vat_mode, - vat_inclusive_discount_mode=vat_inclusive_discount_mode, - payment_priority=payment_priority, + accounting=accounting, allow_purchase_order_autolinking=allow_purchase_order_autolinking, - receivable_edit_flow=receivable_edit_flow, + currency=currency, document_ids=document_ids, - payables_ocr_auto_tagging=payables_ocr_auto_tagging, - quote_signature_required=quote_signature_required, + document_rendering=document_rendering, generate_paid_invoice_pdf=generate_paid_invoice_pdf, - accounting=accounting, + language=language, + payables_ocr_auto_tagging=payables_ocr_auto_tagging, payables_skip_approval_flow=payables_skip_approval_flow, - document_rendering=document_rendering, + payment_priority=payment_priority, + quote_signature_required=quote_signature_required, + receivable_edit_flow=receivable_edit_flow, + reminder=reminder, + vat_inclusive_discount_mode=vat_inclusive_discount_mode, + vat_mode=vat_mode, request_options=request_options, ) return _response.data + def get_entities_id_settings_next_document_numbers( + self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> NextDocumentNumbers: + """ + Returns the next sequence number for various document types - invoices, quotes, credit notes, and others. For example, if the last issued invoice is `INV-00042`, the next invoice number is 43. + + To set the next document numbers, use `PATCH /entities/{entity_id}/settings`. + + For more information, see [Document number customization](https://docs.monite.com/advanced/document-number-customization). + + Parameters + ---------- + entity_id : str + Unique ID of the entity + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NextDocumentNumbers + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.entities.get_entities_id_settings_next_document_numbers( + entity_id="entity_id", + ) + """ + _response = self._raw_client.get_entities_id_settings_next_document_numbers( + entity_id, request_options=request_options + ) + return _response.data + def upload_onboarding_documents( self, *, @@ -1097,13 +1182,13 @@ async def create( address: EntityAddressSchema, email: str, type: EntityTypeEnum, - phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - organization: typing.Optional[OrganizationSchema] = OMIT, individual: typing.Optional[IndividualSchema] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, + organization: typing.Optional[OrganizationSchema] = OMIT, + phone: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -1120,26 +1205,26 @@ async def create( type : EntityTypeEnum A type for an entity - phone : typing.Optional[str] - The contact phone number of the entity. Required for US organizations to use payments. - - website : typing.Optional[str] - A website of the entity + individual : typing.Optional[IndividualSchema] + A set of meta data describing the individual organization : typing.Optional[OrganizationSchema] A set of meta data describing the organization - individual : typing.Optional[IndividualSchema] - A set of meta data describing the individual + phone : typing.Optional[str] + The contact phone number of the entity. Required for US organizations to use payments. - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1181,13 +1266,13 @@ async def main() -> None: address=address, email=email, type=type, - phone=phone, - website=website, - organization=organization, individual=individual, - tax_id=tax_id, - registration_number=registration_number, + organization=organization, + phone=phone, registration_authority=registration_authority, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -1233,13 +1318,13 @@ async def patch_entities_me( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -1253,26 +1338,26 @@ async def patch_entities_me( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1304,13 +1389,13 @@ async def main() -> None: _response = await self._raw_client.patch_entities_me( address=address, email=email, + individual=individual, + organization=organization, phone=phone, - website=website, - tax_id=tax_id, - registration_number=registration_number, registration_authority=registration_authority, - organization=organization, - individual=individual, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -1319,7 +1404,15 @@ async def get_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> EntityResponse: """ - Retrieve an entity by its ID. + Returns entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to get any of the partner's entities. + + To get entity information by using an entity user token, use [`GET /entity_users/my_entity`](https://docs.monite.com/api/entities/get-entity-users-my-entity) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -1364,17 +1457,26 @@ async def update_by_id( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ - Change the specified fields with the provided values. + Update entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to update any of the partner's entities. + + To update an entity by using an entity user token, use [`PATCH /entity_users/my_entity`](https://docs.monite.com/api/entities/patch-entity-users-my-entity) instead. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -1387,26 +1489,26 @@ async def update_by_id( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1441,13 +1543,13 @@ async def main() -> None: entity_id, address=address, email=email, + individual=individual, + organization=organization, phone=phone, - website=website, - tax_id=tax_id, - registration_number=registration_number, registration_authority=registration_authority, - organization=organization, - individual=individual, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -1544,6 +1646,8 @@ async def upload_logo_by_id( """ Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -1588,6 +1692,8 @@ async def delete_logo_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> None: """ + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -1722,7 +1828,14 @@ async def get_settings_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SettingsResponse: """ - Retrieve all settings for this entity. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.read` permission. + + Related endpoints: + + * [Get next document numbers](https://docs.monite.com/api/entities/get-entities-id-settings-next-document-numbers) + * [Get partner settings](https://docs.monite.com/api/partner-settings/get-settings) Parameters ---------- @@ -1765,73 +1878,88 @@ async def update_settings_by_id( self, entity_id: str, *, - language: typing.Optional[LanguageCodeEnum] = OMIT, - currency: typing.Optional[CurrencySettingsInput] = OMIT, - reminder: typing.Optional[RemindersSettings] = OMIT, - vat_mode: typing.Optional[VatModeEnum] = OMIT, - vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, - payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + accounting: typing.Optional[AccountingSettings] = OMIT, allow_purchase_order_autolinking: typing.Optional[bool] = OMIT, - receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + currency: typing.Optional[CurrencySettingsInput] = OMIT, document_ids: typing.Optional[DocumentIDsSettingsRequest] = OMIT, - payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, - quote_signature_required: typing.Optional[bool] = OMIT, + document_rendering: typing.Optional[DocumentRenderingSettingsInput] = OMIT, generate_paid_invoice_pdf: typing.Optional[bool] = OMIT, - accounting: typing.Optional[AccountingSettings] = OMIT, + language: typing.Optional[LanguageCodeEnum] = OMIT, + payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, payables_skip_approval_flow: typing.Optional[bool] = OMIT, - document_rendering: typing.Optional[DocumentRenderingSettings] = OMIT, + payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + quote_signature_required: typing.Optional[bool] = OMIT, + receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + reminder: typing.Optional[RemindersSettings] = OMIT, + vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, + vat_mode: typing.Optional[VatModeEnum] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> SettingsResponse: """ - Change the specified fields with the provided values. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + + Related endpoints: + + * [Update an entity](https://docs.monite.com/api/entities/patch-entities-id) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) + * [Update partner settings](https://docs.monite.com/api/partner-settings/patch-settings) Parameters ---------- entity_id : str A unique ID to specify the entity. - language : typing.Optional[LanguageCodeEnum] + accounting : typing.Optional[AccountingSettings] - currency : typing.Optional[CurrencySettingsInput] + allow_purchase_order_autolinking : typing.Optional[bool] + Automatically attempt to find a corresponding purchase order for all incoming payables. - reminder : typing.Optional[RemindersSettings] + currency : typing.Optional[CurrencySettingsInput] - vat_mode : typing.Optional[VatModeEnum] - Defines whether the prices of products in receivables will already include VAT or not. + document_ids : typing.Optional[DocumentIDsSettingsRequest] - vat_inclusive_discount_mode : typing.Optional[VatModeEnum] - Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. + document_rendering : typing.Optional[DocumentRenderingSettingsInput] + Settings for rendering documents in PDF format. - payment_priority : typing.Optional[PaymentPriorityEnum] - Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + generate_paid_invoice_pdf : typing.Optional[bool] + This setting affects how PDF is generated for accounts receivable invoices that are paid, partially paid, or have credit notes applied. + If this setting is `true`: - allow_purchase_order_autolinking : typing.Optional[bool] - Automatically attempt to find a corresponding purchase order for all incoming payables. + * The totals block in the PDF invoice will include a list of all payments made and credit notes issued. + * Once an invoice becomes fully paid, the payment link and QR code are removed. - receivable_edit_flow : typing.Optional[ReceivableEditFlow] + The PDF invoice gets regenerated at the moment when an invoice payment is recorded or a credit note is issued. This PDF is not issued as a separate document, and the original PDF invoice is no longer available. - document_ids : typing.Optional[DocumentIDsSettingsRequest] + language : typing.Optional[LanguageCodeEnum] payables_ocr_auto_tagging : typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] Auto tagging settings for all incoming OCR payable documents. + payables_skip_approval_flow : typing.Optional[bool] + If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + + payment_priority : typing.Optional[PaymentPriorityEnum] + Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + quote_signature_required : typing.Optional[bool] Sets the default behavior of whether a signature is required to accept quotes. - generate_paid_invoice_pdf : typing.Optional[bool] - This setting affects how PDF is generated for paid accounts receivable invoices. If set to `true`, once an invoice is fully paid its PDF version is updated to display the amount paid and the payment-related features are removed. - - The PDF file gets regenerated at the moment when an invoice becomes paid. It is not issued as a separate document, and the original PDF invoice is no longer available. + receivable_edit_flow : typing.Optional[ReceivableEditFlow] + [Invoice compliance mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance) for accounts receivable. Possible values: - This field is deprecated and will be replaced by `document_rendering.invoice.generate_paid_invoice_pdf`. + * `compliant` - invoices cannot be edited once issued. + * `non_compliant` - issued invoices can still be edited. + * `partially_compliant` - deprecated mode, should not be used. - accounting : typing.Optional[AccountingSettings] + reminder : typing.Optional[RemindersSettings] - payables_skip_approval_flow : typing.Optional[bool] - If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + vat_inclusive_discount_mode : typing.Optional[VatModeEnum] + Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. - document_rendering : typing.Optional[DocumentRenderingSettings] - Settings for rendering documents in PDF format. + vat_mode : typing.Optional[VatModeEnum] + Defines whether the prices of products in receivables will already include VAT or not. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1864,25 +1992,74 @@ async def main() -> None: """ _response = await self._raw_client.update_settings_by_id( entity_id, - language=language, - currency=currency, - reminder=reminder, - vat_mode=vat_mode, - vat_inclusive_discount_mode=vat_inclusive_discount_mode, - payment_priority=payment_priority, + accounting=accounting, allow_purchase_order_autolinking=allow_purchase_order_autolinking, - receivable_edit_flow=receivable_edit_flow, + currency=currency, document_ids=document_ids, - payables_ocr_auto_tagging=payables_ocr_auto_tagging, - quote_signature_required=quote_signature_required, + document_rendering=document_rendering, generate_paid_invoice_pdf=generate_paid_invoice_pdf, - accounting=accounting, + language=language, + payables_ocr_auto_tagging=payables_ocr_auto_tagging, payables_skip_approval_flow=payables_skip_approval_flow, - document_rendering=document_rendering, + payment_priority=payment_priority, + quote_signature_required=quote_signature_required, + receivable_edit_flow=receivable_edit_flow, + reminder=reminder, + vat_inclusive_discount_mode=vat_inclusive_discount_mode, + vat_mode=vat_mode, request_options=request_options, ) return _response.data + async def get_entities_id_settings_next_document_numbers( + self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> NextDocumentNumbers: + """ + Returns the next sequence number for various document types - invoices, quotes, credit notes, and others. For example, if the last issued invoice is `INV-00042`, the next invoice number is 43. + + To set the next document numbers, use `PATCH /entities/{entity_id}/settings`. + + For more information, see [Document number customization](https://docs.monite.com/advanced/document-number-customization). + + Parameters + ---------- + entity_id : str + Unique ID of the entity + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NextDocumentNumbers + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entities.get_entities_id_settings_next_document_numbers( + entity_id="entity_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_entities_id_settings_next_document_numbers( + entity_id, request_options=request_options + ) + return _response.data + async def upload_onboarding_documents( self, *, diff --git a/src/monite/entities/onboarding_data/client.py b/src/monite/entities/onboarding_data/client.py index c4f61c8..405b4d5 100644 --- a/src/monite/entities/onboarding_data/client.py +++ b/src/monite/entities/onboarding_data/client.py @@ -68,6 +68,7 @@ def update( business_profile: typing.Optional[BusinessProfileInput] = OMIT, ownership_declaration: typing.Optional[OwnershipDeclarationInput] = OMIT, tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, + treasury_tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityOnboardingDataResponse: """ @@ -84,6 +85,9 @@ def update( tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] Details on the entity's acceptance of the service agreement. + treasury_tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] + Details on the entity's acceptance of the Stripe Treasury service agreement. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -110,6 +114,7 @@ def update( business_profile=business_profile, ownership_declaration=ownership_declaration, tos_acceptance=tos_acceptance, + treasury_tos_acceptance=treasury_tos_acceptance, request_options=request_options, ) return _response.data @@ -177,6 +182,7 @@ async def update( business_profile: typing.Optional[BusinessProfileInput] = OMIT, ownership_declaration: typing.Optional[OwnershipDeclarationInput] = OMIT, tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, + treasury_tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityOnboardingDataResponse: """ @@ -193,6 +199,9 @@ async def update( tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] Details on the entity's acceptance of the service agreement. + treasury_tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] + Details on the entity's acceptance of the Stripe Treasury service agreement. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -227,6 +236,7 @@ async def main() -> None: business_profile=business_profile, ownership_declaration=ownership_declaration, tos_acceptance=tos_acceptance, + treasury_tos_acceptance=treasury_tos_acceptance, request_options=request_options, ) return _response.data diff --git a/src/monite/entities/onboarding_data/raw_client.py b/src/monite/entities/onboarding_data/raw_client.py index 0c927a7..4fcf37b 100644 --- a/src/monite/entities/onboarding_data/raw_client.py +++ b/src/monite/entities/onboarding_data/raw_client.py @@ -11,8 +11,9 @@ from ...core.request_options import RequestOptions from ...core.serialization import convert_and_respect_annotation_metadata from ...errors.conflict_error import ConflictError -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.business_profile_input import BusinessProfileInput from ...types.entity_onboarding_data_response import EntityOnboardingDataResponse @@ -58,6 +59,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -91,8 +103,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -114,6 +126,7 @@ def update( business_profile: typing.Optional[BusinessProfileInput] = OMIT, ownership_declaration: typing.Optional[OwnershipDeclarationInput] = OMIT, tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, + treasury_tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[EntityOnboardingDataResponse]: """ @@ -130,6 +143,9 @@ def update( tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] Details on the entity's acceptance of the service agreement. + treasury_tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] + Details on the entity's acceptance of the Stripe Treasury service agreement. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -151,6 +167,9 @@ def update( "tos_acceptance": convert_and_respect_annotation_metadata( object_=tos_acceptance, annotation=TermsOfServiceAcceptanceInput, direction="write" ), + "treasury_tos_acceptance": convert_and_respect_annotation_metadata( + object_=treasury_tos_acceptance, annotation=TermsOfServiceAcceptanceInput, direction="write" + ), }, headers={ "content-type": "application/json", @@ -168,6 +187,17 @@ def update( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -201,8 +231,8 @@ def update( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -253,6 +283,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -286,8 +327,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -309,6 +350,7 @@ async def update( business_profile: typing.Optional[BusinessProfileInput] = OMIT, ownership_declaration: typing.Optional[OwnershipDeclarationInput] = OMIT, tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, + treasury_tos_acceptance: typing.Optional[TermsOfServiceAcceptanceInput] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[EntityOnboardingDataResponse]: """ @@ -325,6 +367,9 @@ async def update( tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] Details on the entity's acceptance of the service agreement. + treasury_tos_acceptance : typing.Optional[TermsOfServiceAcceptanceInput] + Details on the entity's acceptance of the Stripe Treasury service agreement. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -346,6 +391,9 @@ async def update( "tos_acceptance": convert_and_respect_annotation_metadata( object_=tos_acceptance, annotation=TermsOfServiceAcceptanceInput, direction="write" ), + "treasury_tos_acceptance": convert_and_respect_annotation_metadata( + object_=treasury_tos_acceptance, annotation=TermsOfServiceAcceptanceInput, direction="write" + ), }, headers={ "content-type": "application/json", @@ -363,6 +411,17 @@ async def update( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -396,8 +455,8 @@ async def update( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/entities/payment_methods/client.py b/src/monite/entities/payment_methods/client.py index 5ae0a11..c245d6c 100644 --- a/src/monite/entities/payment_methods/client.py +++ b/src/monite/entities/payment_methods/client.py @@ -78,13 +78,19 @@ def set( entity_id : str payment_methods : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Deprecated. Use payment_methods_receive instead. + Deprecated. Replaced by `payment_methods_receive`. payment_methods_receive : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to receive money. + Payment methods to receive money from customers. Supported payment methods [vary per country](https://docs.monite.com/payments/payment-methods). + + `card` includes card payments, Apple Pay, and Google Pay. The values `applepay` and `googlepay` are deprecated and unused. + + `sofort` is deprecated and replaced by `klarna`. payment_methods_send : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to send money. + Only for entities in the EU and UK. Payment methods used to make payments to vendors. + + Currently only `sepa_credit` is supported for making payments. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -105,6 +111,8 @@ def set( ) client.entities.payment_methods.set( entity_id="entity_id", + payment_methods_receive=["card", "sepa_credit", "sepa_debit"], + payment_methods_send=["sepa_credit"], ) """ _response = self._raw_client.set( @@ -191,13 +199,19 @@ async def set( entity_id : str payment_methods : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Deprecated. Use payment_methods_receive instead. + Deprecated. Replaced by `payment_methods_receive`. payment_methods_receive : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to receive money. + Payment methods to receive money from customers. Supported payment methods [vary per country](https://docs.monite.com/payments/payment-methods). + + `card` includes card payments, Apple Pay, and Google Pay. The values `applepay` and `googlepay` are deprecated and unused. + + `sofort` is deprecated and replaced by `klarna`. payment_methods_send : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to send money. + Only for entities in the EU and UK. Payment methods used to make payments to vendors. + + Currently only `sepa_credit` is supported for making payments. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -223,6 +237,8 @@ async def set( async def main() -> None: await client.entities.payment_methods.set( entity_id="entity_id", + payment_methods_receive=["card", "sepa_credit", "sepa_debit"], + payment_methods_send=["sepa_credit"], ) diff --git a/src/monite/entities/payment_methods/raw_client.py b/src/monite/entities/payment_methods/raw_client.py index 9e4859e..c75db00 100644 --- a/src/monite/entities/payment_methods/raw_client.py +++ b/src/monite/entities/payment_methods/raw_client.py @@ -9,7 +9,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.monite_all_payment_methods_types import MoniteAllPaymentMethodsTypes from ...types.onboarding_payment_methods_response import OnboardingPaymentMethodsResponse @@ -55,6 +56,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -66,8 +78,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -99,13 +111,19 @@ def set( entity_id : str payment_methods : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Deprecated. Use payment_methods_receive instead. + Deprecated. Replaced by `payment_methods_receive`. payment_methods_receive : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to receive money. + Payment methods to receive money from customers. Supported payment methods [vary per country](https://docs.monite.com/payments/payment-methods). + + `card` includes card payments, Apple Pay, and Google Pay. The values `applepay` and `googlepay` are deprecated and unused. + + `sofort` is deprecated and replaced by `klarna`. payment_methods_send : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to send money. + Only for entities in the EU and UK. Payment methods used to make payments to vendors. + + Currently only `sepa_credit` is supported for making payments. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -139,6 +157,17 @@ def set( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -150,8 +179,8 @@ def set( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -204,6 +233,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -215,8 +255,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -248,13 +288,19 @@ async def set( entity_id : str payment_methods : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Deprecated. Use payment_methods_receive instead. + Deprecated. Replaced by `payment_methods_receive`. payment_methods_receive : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to receive money. + Payment methods to receive money from customers. Supported payment methods [vary per country](https://docs.monite.com/payments/payment-methods). + + `card` includes card payments, Apple Pay, and Google Pay. The values `applepay` and `googlepay` are deprecated and unused. + + `sofort` is deprecated and replaced by `klarna`. payment_methods_send : typing.Optional[typing.Sequence[MoniteAllPaymentMethodsTypes]] - Enable payment methods to send money. + Only for entities in the EU and UK. Payment methods used to make payments to vendors. + + Currently only `sepa_credit` is supported for making payments. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -288,6 +334,17 @@ async def set( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -299,8 +356,8 @@ async def set( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/entities/persons/raw_client.py b/src/monite/entities/persons/raw_client.py index 3739f67..48cfe09 100644 --- a/src/monite/entities/persons/raw_client.py +++ b/src/monite/entities/persons/raw_client.py @@ -11,8 +11,9 @@ from ...core.request_options import RequestOptions from ...core.serialization import convert_and_respect_annotation_metadata from ...errors.conflict_error import ConflictError -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.allowed_countries import AllowedCountries from ...types.optional_person_address_request import OptionalPersonAddressRequest @@ -57,6 +58,17 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -68,8 +80,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -175,6 +187,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -197,8 +220,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -244,6 +267,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -266,8 +300,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -305,6 +339,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -338,8 +383,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -448,6 +493,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -481,8 +537,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -547,6 +603,17 @@ def upload_onboarding_documents( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -558,8 +625,8 @@ def upload_onboarding_documents( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -608,6 +675,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -619,8 +697,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -726,6 +804,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), @@ -748,8 +837,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -795,6 +884,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -817,8 +917,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -856,6 +956,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -889,8 +1000,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -999,6 +1110,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1032,8 +1154,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1098,6 +1220,17 @@ async def upload_onboarding_documents( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1109,8 +1242,8 @@ async def upload_onboarding_documents( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/entities/raw_client.py b/src/monite/entities/raw_client.py index d26b71f..570882d 100644 --- a/src/monite/entities/raw_client.py +++ b/src/monite/entities/raw_client.py @@ -15,15 +15,15 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.accounting_settings import AccountingSettings from ..types.currency_settings_input import CurrencySettingsInput from ..types.document_i_ds_settings_request import DocumentIDsSettingsRequest -from ..types.document_rendering_settings import DocumentRenderingSettings +from ..types.document_rendering_settings_input import DocumentRenderingSettingsInput from ..types.entity_address_schema import EntityAddressSchema from ..types.entity_cursor_fields import EntityCursorFields from ..types.entity_pagination_response import EntityPaginationResponse @@ -34,6 +34,7 @@ from ..types.get_onboarding_requirements_response import GetOnboardingRequirementsResponse from ..types.individual_schema import IndividualSchema from ..types.language_code_enum import LanguageCodeEnum +from ..types.next_document_numbers import NextDocumentNumbers from ..types.ocr_auto_tagging_settings_request import OcrAutoTaggingSettingsRequest from ..types.optional_individual_schema import OptionalIndividualSchema from ..types.optional_organization_schema import OptionalOrganizationSchema @@ -211,8 +212,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -233,13 +234,13 @@ def create( address: EntityAddressSchema, email: str, type: EntityTypeEnum, - phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - organization: typing.Optional[OrganizationSchema] = OMIT, individual: typing.Optional[IndividualSchema] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, + organization: typing.Optional[OrganizationSchema] = OMIT, + phone: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[EntityResponse]: """ @@ -256,26 +257,26 @@ def create( type : EntityTypeEnum A type for an entity - phone : typing.Optional[str] - The contact phone number of the entity. Required for US organizations to use payments. - - website : typing.Optional[str] - A website of the entity + individual : typing.Optional[IndividualSchema] + A set of meta data describing the individual organization : typing.Optional[OrganizationSchema] A set of meta data describing the organization - individual : typing.Optional[IndividualSchema] - A set of meta data describing the individual + phone : typing.Optional[str] + The contact phone number of the entity. Required for US organizations to use payments. - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -293,18 +294,18 @@ def create( object_=address, annotation=EntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=IndividualSchema, direction="write" ), - "tax_id": tax_id, - "registration_number": registration_number, + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OrganizationSchema, direction="write" + ), + "phone": phone, "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, "type": type, + "website": website, }, headers={ "content-type": "application/json", @@ -333,6 +334,17 @@ def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -355,8 +367,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -413,6 +425,17 @@ def get_entities_me( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -424,8 +447,8 @@ def get_entities_me( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -445,13 +468,13 @@ def patch_entities_me( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[EntityResponse]: """ @@ -465,26 +488,26 @@ def patch_entities_me( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -502,17 +525,17 @@ def patch_entities_me( object_=address, annotation=UpdateEntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "tax_id": tax_id, - "registration_number": registration_number, - "registration_authority": registration_authority, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OptionalOrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=OptionalIndividualSchema, direction="write" ), + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OptionalOrganizationSchema, direction="write" + ), + "phone": phone, + "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, + "website": website, }, headers={ "content-type": "application/json", @@ -541,6 +564,17 @@ def patch_entities_me( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -552,8 +586,8 @@ def patch_entities_me( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -572,7 +606,15 @@ def get_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[EntityResponse]: """ - Retrieve an entity by its ID. + Returns entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to get any of the partner's entities. + + To get entity information by using an entity user token, use [`GET /entity_users/my_entity`](https://docs.monite.com/api/entities/get-entity-users-my-entity) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -613,6 +655,17 @@ def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -624,8 +677,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -646,17 +699,26 @@ def update_by_id( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[EntityResponse]: """ - Change the specified fields with the provided values. + Update entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to update any of the partner's entities. + + To update an entity by using an entity user token, use [`PATCH /entity_users/my_entity`](https://docs.monite.com/api/entities/patch-entity-users-my-entity) instead. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -669,26 +731,26 @@ def update_by_id( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -706,17 +768,17 @@ def update_by_id( object_=address, annotation=UpdateEntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "tax_id": tax_id, - "registration_number": registration_number, - "registration_authority": registration_authority, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OptionalOrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=OptionalIndividualSchema, direction="write" ), + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OptionalOrganizationSchema, direction="write" + ), + "phone": phone, + "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, + "website": website, }, headers={ "content-type": "application/json", @@ -745,6 +807,17 @@ def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -767,8 +840,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -828,6 +901,17 @@ def post_entities_id_activate( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -850,8 +934,8 @@ def post_entities_id_activate( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -911,6 +995,17 @@ def post_entities_id_deactivate( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -933,8 +1028,8 @@ def post_entities_id_deactivate( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -955,6 +1050,8 @@ def upload_logo_by_id( """ Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -1003,6 +1100,17 @@ def upload_logo_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1014,8 +1122,8 @@ def upload_logo_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1034,6 +1142,8 @@ def delete_logo_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[None]: """ + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -1054,6 +1164,17 @@ def delete_logo_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1076,8 +1197,8 @@ def delete_logo_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1125,7 +1246,18 @@ def get_partner_metadata_by_id( ), ) return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( @@ -1136,8 +1268,8 @@ def get_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1199,6 +1331,17 @@ def update_partner_metadata_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1210,8 +1353,8 @@ def update_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1230,7 +1373,14 @@ def get_settings_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[SettingsResponse]: """ - Retrieve all settings for this entity. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.read` permission. + + Related endpoints: + + * [Get next document numbers](https://docs.monite.com/api/entities/get-entities-id-settings-next-document-numbers) + * [Get partner settings](https://docs.monite.com/api/partner-settings/get-settings) Parameters ---------- @@ -1271,6 +1421,17 @@ def get_settings_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1282,8 +1443,8 @@ def get_settings_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1302,73 +1463,88 @@ def update_settings_by_id( self, entity_id: str, *, - language: typing.Optional[LanguageCodeEnum] = OMIT, - currency: typing.Optional[CurrencySettingsInput] = OMIT, - reminder: typing.Optional[RemindersSettings] = OMIT, - vat_mode: typing.Optional[VatModeEnum] = OMIT, - vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, - payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + accounting: typing.Optional[AccountingSettings] = OMIT, allow_purchase_order_autolinking: typing.Optional[bool] = OMIT, - receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + currency: typing.Optional[CurrencySettingsInput] = OMIT, document_ids: typing.Optional[DocumentIDsSettingsRequest] = OMIT, - payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, - quote_signature_required: typing.Optional[bool] = OMIT, + document_rendering: typing.Optional[DocumentRenderingSettingsInput] = OMIT, generate_paid_invoice_pdf: typing.Optional[bool] = OMIT, - accounting: typing.Optional[AccountingSettings] = OMIT, + language: typing.Optional[LanguageCodeEnum] = OMIT, + payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, payables_skip_approval_flow: typing.Optional[bool] = OMIT, - document_rendering: typing.Optional[DocumentRenderingSettings] = OMIT, + payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + quote_signature_required: typing.Optional[bool] = OMIT, + receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + reminder: typing.Optional[RemindersSettings] = OMIT, + vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, + vat_mode: typing.Optional[VatModeEnum] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[SettingsResponse]: """ - Change the specified fields with the provided values. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + + Related endpoints: + + * [Update an entity](https://docs.monite.com/api/entities/patch-entities-id) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) + * [Update partner settings](https://docs.monite.com/api/partner-settings/patch-settings) Parameters ---------- entity_id : str A unique ID to specify the entity. - language : typing.Optional[LanguageCodeEnum] + accounting : typing.Optional[AccountingSettings] - currency : typing.Optional[CurrencySettingsInput] + allow_purchase_order_autolinking : typing.Optional[bool] + Automatically attempt to find a corresponding purchase order for all incoming payables. - reminder : typing.Optional[RemindersSettings] + currency : typing.Optional[CurrencySettingsInput] - vat_mode : typing.Optional[VatModeEnum] - Defines whether the prices of products in receivables will already include VAT or not. + document_ids : typing.Optional[DocumentIDsSettingsRequest] - vat_inclusive_discount_mode : typing.Optional[VatModeEnum] - Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. + document_rendering : typing.Optional[DocumentRenderingSettingsInput] + Settings for rendering documents in PDF format. - payment_priority : typing.Optional[PaymentPriorityEnum] - Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + generate_paid_invoice_pdf : typing.Optional[bool] + This setting affects how PDF is generated for accounts receivable invoices that are paid, partially paid, or have credit notes applied. + If this setting is `true`: - allow_purchase_order_autolinking : typing.Optional[bool] - Automatically attempt to find a corresponding purchase order for all incoming payables. + * The totals block in the PDF invoice will include a list of all payments made and credit notes issued. + * Once an invoice becomes fully paid, the payment link and QR code are removed. - receivable_edit_flow : typing.Optional[ReceivableEditFlow] + The PDF invoice gets regenerated at the moment when an invoice payment is recorded or a credit note is issued. This PDF is not issued as a separate document, and the original PDF invoice is no longer available. - document_ids : typing.Optional[DocumentIDsSettingsRequest] + language : typing.Optional[LanguageCodeEnum] payables_ocr_auto_tagging : typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] Auto tagging settings for all incoming OCR payable documents. + payables_skip_approval_flow : typing.Optional[bool] + If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + + payment_priority : typing.Optional[PaymentPriorityEnum] + Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + quote_signature_required : typing.Optional[bool] Sets the default behavior of whether a signature is required to accept quotes. - generate_paid_invoice_pdf : typing.Optional[bool] - This setting affects how PDF is generated for paid accounts receivable invoices. If set to `true`, once an invoice is fully paid its PDF version is updated to display the amount paid and the payment-related features are removed. - - The PDF file gets regenerated at the moment when an invoice becomes paid. It is not issued as a separate document, and the original PDF invoice is no longer available. + receivable_edit_flow : typing.Optional[ReceivableEditFlow] + [Invoice compliance mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance) for accounts receivable. Possible values: - This field is deprecated and will be replaced by `document_rendering.invoice.generate_paid_invoice_pdf`. + * `compliant` - invoices cannot be edited once issued. + * `non_compliant` - issued invoices can still be edited. + * `partially_compliant` - deprecated mode, should not be used. - accounting : typing.Optional[AccountingSettings] + reminder : typing.Optional[RemindersSettings] - payables_skip_approval_flow : typing.Optional[bool] - If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + vat_inclusive_discount_mode : typing.Optional[VatModeEnum] + Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. - document_rendering : typing.Optional[DocumentRenderingSettings] - Settings for rendering documents in PDF format. + vat_mode : typing.Optional[VatModeEnum] + Defines whether the prices of products in receivables will already include VAT or not. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1382,35 +1558,35 @@ def update_settings_by_id( f"entities/{jsonable_encoder(entity_id)}/settings", method="PATCH", json={ - "language": language, + "accounting": convert_and_respect_annotation_metadata( + object_=accounting, annotation=AccountingSettings, direction="write" + ), + "allow_purchase_order_autolinking": allow_purchase_order_autolinking, "currency": convert_and_respect_annotation_metadata( object_=currency, annotation=CurrencySettingsInput, direction="write" ), - "reminder": convert_and_respect_annotation_metadata( - object_=reminder, annotation=RemindersSettings, direction="write" - ), - "vat_mode": vat_mode, - "vat_inclusive_discount_mode": vat_inclusive_discount_mode, - "payment_priority": payment_priority, - "allow_purchase_order_autolinking": allow_purchase_order_autolinking, - "receivable_edit_flow": receivable_edit_flow, "document_ids": convert_and_respect_annotation_metadata( object_=document_ids, annotation=DocumentIDsSettingsRequest, direction="write" ), + "document_rendering": convert_and_respect_annotation_metadata( + object_=document_rendering, annotation=DocumentRenderingSettingsInput, direction="write" + ), + "generate_paid_invoice_pdf": generate_paid_invoice_pdf, + "language": language, "payables_ocr_auto_tagging": convert_and_respect_annotation_metadata( object_=payables_ocr_auto_tagging, annotation=typing.Sequence[OcrAutoTaggingSettingsRequest], direction="write", ), - "quote_signature_required": quote_signature_required, - "generate_paid_invoice_pdf": generate_paid_invoice_pdf, - "accounting": convert_and_respect_annotation_metadata( - object_=accounting, annotation=AccountingSettings, direction="write" - ), "payables_skip_approval_flow": payables_skip_approval_flow, - "document_rendering": convert_and_respect_annotation_metadata( - object_=document_rendering, annotation=DocumentRenderingSettings, direction="write" + "payment_priority": payment_priority, + "quote_signature_required": quote_signature_required, + "receivable_edit_flow": receivable_edit_flow, + "reminder": convert_and_respect_annotation_metadata( + object_=reminder, annotation=RemindersSettings, direction="write" ), + "vat_inclusive_discount_mode": vat_inclusive_discount_mode, + "vat_mode": vat_mode, }, headers={ "content-type": "application/json", @@ -1439,6 +1615,115 @@ def update_settings_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_entities_id_settings_next_document_numbers( + self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[NextDocumentNumbers]: + """ + Returns the next sequence number for various document types - invoices, quotes, credit notes, and others. For example, if the last issued invoice is `INV-00042`, the next invoice number is 43. + + To set the next document numbers, use `PATCH /entities/{entity_id}/settings`. + + For more information, see [Document number customization](https://docs.monite.com/advanced/document-number-customization). + + Parameters + ---------- + entity_id : str + Unique ID of the entity + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[NextDocumentNumbers] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"entities/{jsonable_encoder(entity_id)}/settings/next_document_numbers", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + NextDocumentNumbers, + parse_obj_as( + type_=NextDocumentNumbers, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1450,8 +1735,8 @@ def update_settings_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1541,6 +1826,17 @@ def upload_onboarding_documents( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1552,8 +1848,8 @@ def upload_onboarding_documents( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1599,6 +1895,17 @@ def get_onboarding_requirements( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1610,8 +1917,8 @@ def get_onboarding_requirements( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1787,8 +2094,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1809,14 +2116,14 @@ async def create( address: EntityAddressSchema, email: str, type: EntityTypeEnum, - phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - organization: typing.Optional[OrganizationSchema] = OMIT, individual: typing.Optional[IndividualSchema] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, + organization: typing.Optional[OrganizationSchema] = OMIT, + phone: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[EntityResponse]: """ Create a new entity from the specified values. @@ -1832,26 +2139,26 @@ async def create( type : EntityTypeEnum A type for an entity - phone : typing.Optional[str] - The contact phone number of the entity. Required for US organizations to use payments. - - website : typing.Optional[str] - A website of the entity + individual : typing.Optional[IndividualSchema] + A set of meta data describing the individual organization : typing.Optional[OrganizationSchema] A set of meta data describing the organization - individual : typing.Optional[IndividualSchema] - A set of meta data describing the individual + phone : typing.Optional[str] + The contact phone number of the entity. Required for US organizations to use payments. - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1869,18 +2176,18 @@ async def create( object_=address, annotation=EntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=IndividualSchema, direction="write" ), - "tax_id": tax_id, - "registration_number": registration_number, + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OrganizationSchema, direction="write" + ), + "phone": phone, "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, "type": type, + "website": website, }, headers={ "content-type": "application/json", @@ -1909,6 +2216,17 @@ async def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1931,8 +2249,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1989,6 +2307,17 @@ async def get_entities_me( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2000,8 +2329,8 @@ async def get_entities_me( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2021,13 +2350,13 @@ async def patch_entities_me( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[EntityResponse]: """ @@ -2041,26 +2370,26 @@ async def patch_entities_me( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2078,17 +2407,17 @@ async def patch_entities_me( object_=address, annotation=UpdateEntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "tax_id": tax_id, - "registration_number": registration_number, - "registration_authority": registration_authority, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OptionalOrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=OptionalIndividualSchema, direction="write" ), + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OptionalOrganizationSchema, direction="write" + ), + "phone": phone, + "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, + "website": website, }, headers={ "content-type": "application/json", @@ -2117,6 +2446,17 @@ async def patch_entities_me( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2128,8 +2468,8 @@ async def patch_entities_me( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2148,7 +2488,15 @@ async def get_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[EntityResponse]: """ - Retrieve an entity by its ID. + Returns entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to get any of the partner's entities. + + To get entity information by using an entity user token, use [`GET /entity_users/my_entity`](https://docs.monite.com/api/entities/get-entity-users-my-entity) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -2189,6 +2537,17 @@ async def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2200,8 +2559,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2222,17 +2581,26 @@ async def update_by_id( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[EntityResponse]: """ - Change the specified fields with the provided values. + Update entity information for the specified entity ID. + + This endpoint requires a partner access token and can be used to update any of the partner's entities. + + To update an entity by using an entity user token, use [`PATCH /entity_users/my_entity`](https://docs.monite.com/api/entities/patch-entity-users-my-entity) instead. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -2245,26 +2613,26 @@ async def update_by_id( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2282,17 +2650,17 @@ async def update_by_id( object_=address, annotation=UpdateEntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "tax_id": tax_id, - "registration_number": registration_number, - "registration_authority": registration_authority, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OptionalOrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=OptionalIndividualSchema, direction="write" ), + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OptionalOrganizationSchema, direction="write" + ), + "phone": phone, + "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, + "website": website, }, headers={ "content-type": "application/json", @@ -2321,6 +2689,17 @@ async def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -2343,8 +2722,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2404,6 +2783,17 @@ async def post_entities_id_activate( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -2426,8 +2816,8 @@ async def post_entities_id_activate( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2487,6 +2877,17 @@ async def post_entities_id_deactivate( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -2509,8 +2910,8 @@ async def post_entities_id_deactivate( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2531,6 +2932,8 @@ async def upload_logo_by_id( """ Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -2579,6 +2982,17 @@ async def upload_logo_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2590,8 +3004,8 @@ async def upload_logo_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2610,6 +3024,8 @@ async def delete_logo_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + Parameters ---------- entity_id : str @@ -2630,6 +3046,17 @@ async def delete_logo_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -2652,8 +3079,8 @@ async def delete_logo_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2701,6 +3128,17 @@ async def get_partner_metadata_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2712,8 +3150,8 @@ async def get_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2775,6 +3213,17 @@ async def update_partner_metadata_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2786,8 +3235,8 @@ async def update_partner_metadata_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2806,7 +3255,14 @@ async def get_settings_by_id( self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[SettingsResponse]: """ - Retrieve all settings for this entity. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.read` permission. + + Related endpoints: + + * [Get next document numbers](https://docs.monite.com/api/entities/get-entities-id-settings-next-document-numbers) + * [Get partner settings](https://docs.monite.com/api/partner-settings/get-settings) Parameters ---------- @@ -2847,6 +3303,17 @@ async def get_settings_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -2858,8 +3325,8 @@ async def get_settings_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2878,73 +3345,88 @@ async def update_settings_by_id( self, entity_id: str, *, - language: typing.Optional[LanguageCodeEnum] = OMIT, - currency: typing.Optional[CurrencySettingsInput] = OMIT, - reminder: typing.Optional[RemindersSettings] = OMIT, - vat_mode: typing.Optional[VatModeEnum] = OMIT, - vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, - payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + accounting: typing.Optional[AccountingSettings] = OMIT, allow_purchase_order_autolinking: typing.Optional[bool] = OMIT, - receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + currency: typing.Optional[CurrencySettingsInput] = OMIT, document_ids: typing.Optional[DocumentIDsSettingsRequest] = OMIT, - payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, - quote_signature_required: typing.Optional[bool] = OMIT, + document_rendering: typing.Optional[DocumentRenderingSettingsInput] = OMIT, generate_paid_invoice_pdf: typing.Optional[bool] = OMIT, - accounting: typing.Optional[AccountingSettings] = OMIT, + language: typing.Optional[LanguageCodeEnum] = OMIT, + payables_ocr_auto_tagging: typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] = OMIT, payables_skip_approval_flow: typing.Optional[bool] = OMIT, - document_rendering: typing.Optional[DocumentRenderingSettings] = OMIT, + payment_priority: typing.Optional[PaymentPriorityEnum] = OMIT, + quote_signature_required: typing.Optional[bool] = OMIT, + receivable_edit_flow: typing.Optional[ReceivableEditFlow] = OMIT, + reminder: typing.Optional[RemindersSettings] = OMIT, + vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = OMIT, + vat_mode: typing.Optional[VatModeEnum] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[SettingsResponse]: """ - Change the specified fields with the provided values. + Entity settings include configuration options for accounts payable, accounts receivable, accounting integration, and other functionality. + + Both partner tokens and entity user tokens can be used for authentication. Entity users must have a role with the `entity.update` permission. + + Related endpoints: + + * [Update an entity](https://docs.monite.com/api/entities/patch-entities-id) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) + * [Update partner settings](https://docs.monite.com/api/partner-settings/patch-settings) Parameters ---------- entity_id : str A unique ID to specify the entity. - language : typing.Optional[LanguageCodeEnum] + accounting : typing.Optional[AccountingSettings] + + allow_purchase_order_autolinking : typing.Optional[bool] + Automatically attempt to find a corresponding purchase order for all incoming payables. currency : typing.Optional[CurrencySettingsInput] - reminder : typing.Optional[RemindersSettings] + document_ids : typing.Optional[DocumentIDsSettingsRequest] - vat_mode : typing.Optional[VatModeEnum] - Defines whether the prices of products in receivables will already include VAT or not. + document_rendering : typing.Optional[DocumentRenderingSettingsInput] + Settings for rendering documents in PDF format. - vat_inclusive_discount_mode : typing.Optional[VatModeEnum] - Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. + generate_paid_invoice_pdf : typing.Optional[bool] + This setting affects how PDF is generated for accounts receivable invoices that are paid, partially paid, or have credit notes applied. + If this setting is `true`: - payment_priority : typing.Optional[PaymentPriorityEnum] - Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + * The totals block in the PDF invoice will include a list of all payments made and credit notes issued. + * Once an invoice becomes fully paid, the payment link and QR code are removed. - allow_purchase_order_autolinking : typing.Optional[bool] - Automatically attempt to find a corresponding purchase order for all incoming payables. + The PDF invoice gets regenerated at the moment when an invoice payment is recorded or a credit note is issued. This PDF is not issued as a separate document, and the original PDF invoice is no longer available. - receivable_edit_flow : typing.Optional[ReceivableEditFlow] - - document_ids : typing.Optional[DocumentIDsSettingsRequest] + language : typing.Optional[LanguageCodeEnum] payables_ocr_auto_tagging : typing.Optional[typing.Sequence[OcrAutoTaggingSettingsRequest]] Auto tagging settings for all incoming OCR payable documents. + payables_skip_approval_flow : typing.Optional[bool] + If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + + payment_priority : typing.Optional[PaymentPriorityEnum] + Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + quote_signature_required : typing.Optional[bool] Sets the default behavior of whether a signature is required to accept quotes. - generate_paid_invoice_pdf : typing.Optional[bool] - This setting affects how PDF is generated for paid accounts receivable invoices. If set to `true`, once an invoice is fully paid its PDF version is updated to display the amount paid and the payment-related features are removed. - - The PDF file gets regenerated at the moment when an invoice becomes paid. It is not issued as a separate document, and the original PDF invoice is no longer available. + receivable_edit_flow : typing.Optional[ReceivableEditFlow] + [Invoice compliance mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance) for accounts receivable. Possible values: - This field is deprecated and will be replaced by `document_rendering.invoice.generate_paid_invoice_pdf`. + * `compliant` - invoices cannot be edited once issued. + * `non_compliant` - issued invoices can still be edited. + * `partially_compliant` - deprecated mode, should not be used. - accounting : typing.Optional[AccountingSettings] + reminder : typing.Optional[RemindersSettings] - payables_skip_approval_flow : typing.Optional[bool] - If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + vat_inclusive_discount_mode : typing.Optional[VatModeEnum] + Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. - document_rendering : typing.Optional[DocumentRenderingSettings] - Settings for rendering documents in PDF format. + vat_mode : typing.Optional[VatModeEnum] + Defines whether the prices of products in receivables will already include VAT or not. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2958,35 +3440,35 @@ async def update_settings_by_id( f"entities/{jsonable_encoder(entity_id)}/settings", method="PATCH", json={ - "language": language, + "accounting": convert_and_respect_annotation_metadata( + object_=accounting, annotation=AccountingSettings, direction="write" + ), + "allow_purchase_order_autolinking": allow_purchase_order_autolinking, "currency": convert_and_respect_annotation_metadata( object_=currency, annotation=CurrencySettingsInput, direction="write" ), - "reminder": convert_and_respect_annotation_metadata( - object_=reminder, annotation=RemindersSettings, direction="write" - ), - "vat_mode": vat_mode, - "vat_inclusive_discount_mode": vat_inclusive_discount_mode, - "payment_priority": payment_priority, - "allow_purchase_order_autolinking": allow_purchase_order_autolinking, - "receivable_edit_flow": receivable_edit_flow, "document_ids": convert_and_respect_annotation_metadata( object_=document_ids, annotation=DocumentIDsSettingsRequest, direction="write" ), + "document_rendering": convert_and_respect_annotation_metadata( + object_=document_rendering, annotation=DocumentRenderingSettingsInput, direction="write" + ), + "generate_paid_invoice_pdf": generate_paid_invoice_pdf, + "language": language, "payables_ocr_auto_tagging": convert_and_respect_annotation_metadata( object_=payables_ocr_auto_tagging, annotation=typing.Sequence[OcrAutoTaggingSettingsRequest], direction="write", ), - "quote_signature_required": quote_signature_required, - "generate_paid_invoice_pdf": generate_paid_invoice_pdf, - "accounting": convert_and_respect_annotation_metadata( - object_=accounting, annotation=AccountingSettings, direction="write" - ), "payables_skip_approval_flow": payables_skip_approval_flow, - "document_rendering": convert_and_respect_annotation_metadata( - object_=document_rendering, annotation=DocumentRenderingSettings, direction="write" + "payment_priority": payment_priority, + "quote_signature_required": quote_signature_required, + "receivable_edit_flow": receivable_edit_flow, + "reminder": convert_and_respect_annotation_metadata( + object_=reminder, annotation=RemindersSettings, direction="write" ), + "vat_inclusive_discount_mode": vat_inclusive_discount_mode, + "vat_mode": vat_mode, }, headers={ "content-type": "application/json", @@ -3015,6 +3497,115 @@ async def update_settings_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_entities_id_settings_next_document_numbers( + self, entity_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[NextDocumentNumbers]: + """ + Returns the next sequence number for various document types - invoices, quotes, credit notes, and others. For example, if the last issued invoice is `INV-00042`, the next invoice number is 43. + + To set the next document numbers, use `PATCH /entities/{entity_id}/settings`. + + For more information, see [Document number customization](https://docs.monite.com/advanced/document-number-customization). + + Parameters + ---------- + entity_id : str + Unique ID of the entity + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[NextDocumentNumbers] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"entities/{jsonable_encoder(entity_id)}/settings/next_document_numbers", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + NextDocumentNumbers, + parse_obj_as( + type_=NextDocumentNumbers, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -3026,8 +3617,8 @@ async def update_settings_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3117,6 +3708,17 @@ async def upload_onboarding_documents( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -3128,8 +3730,8 @@ async def upload_onboarding_documents( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3175,6 +3777,17 @@ async def get_onboarding_requirements( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -3186,8 +3799,8 @@ async def get_onboarding_requirements( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/entities/vat_ids/raw_client.py b/src/monite/entities/vat_ids/raw_client.py index 3a9d855..a2c76d8 100644 --- a/src/monite/entities/vat_ids/raw_client.py +++ b/src/monite/entities/vat_ids/raw_client.py @@ -9,8 +9,9 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions -from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.allowed_countries import AllowedCountries from ...types.entity_vat_id_resource_list import EntityVatIdResourceList @@ -56,6 +57,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -67,8 +79,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -135,6 +147,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -157,8 +180,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -206,6 +229,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -228,8 +262,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -269,6 +303,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -291,8 +336,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -362,6 +407,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -384,8 +440,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -436,6 +492,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -447,8 +514,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -515,6 +582,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -537,8 +615,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -586,6 +664,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -608,8 +697,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -649,6 +738,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -671,8 +771,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -742,6 +842,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -764,8 +875,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/entity_users/client.py b/src/monite/entity_users/client.py index 8a92244..413afe3 100644 --- a/src/monite/entity_users/client.py +++ b/src/monite/entity_users/client.py @@ -157,24 +157,27 @@ def create( Parameters ---------- first_name : str - First name + The user's first name. login : str + The username assigned to this user. Usernames must be unique within the entity. + + The `login` value is not used by Monite but may be used by partner applications, for example, to map the users between the partner's platform and Monite. email : typing.Optional[str] - An entity user business email + The user's business email address. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the role to assign to this user. The role defines the user's [access permissions](https://docs.monite.com/api/concepts/authentication#permissions) within the entity. Each user has just one role. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -212,7 +215,7 @@ def create( def get_current(self, *, request_options: typing.Optional[RequestOptions] = None) -> EntityUserResponse: """ - Retrieve an entity user by its ID. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- @@ -249,24 +252,24 @@ def update_current( request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ - Change the specified fields with provided values. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -299,7 +302,13 @@ def update_current( def get_current_entity(self, *, request_options: typing.Optional[RequestOptions] = None) -> EntityResponse: """ - Retrieves information of an entity, which this entity user belongs to. + Returns the entity to which the authenticated user belongs. This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.read` permission. + + To get an entity by using a partner access token, use [`GET /entities/{entity_id}`](https://docs.monite.com/api/entities/get-entities-id) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -330,17 +339,26 @@ def update_current_entity( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ - Update information of an entity, which this entity user belongs to. + Update the entity to which the authenticated user belongs. + + This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.update` permission. + + This endpoint does not use the `X-Monite-Entity-Id` header. The entity ID is inferred from the access token. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -350,26 +368,26 @@ def update_current_entity( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -393,13 +411,13 @@ def update_current_entity( _response = self._raw_client.update_current_entity( address=address, email=email, + individual=individual, + organization=organization, phone=phone, - website=website, - tax_id=tax_id, - registration_number=registration_number, registration_authority=registration_authority, - organization=organization, - individual=individual, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -516,25 +534,25 @@ def update_by_id( entity_user_id : str email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. login : typing.Optional[str] - Login + The new username for this user. Must be unique within the entity. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the new role to assign to this user. The new role takes effect immediately, existing access tokens of this user are not invalidated. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -716,24 +734,27 @@ async def create( Parameters ---------- first_name : str - First name + The user's first name. login : str + The username assigned to this user. Usernames must be unique within the entity. + + The `login` value is not used by Monite but may be used by partner applications, for example, to map the users between the partner's platform and Monite. email : typing.Optional[str] - An entity user business email + The user's business email address. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the role to assign to this user. The role defines the user's [access permissions](https://docs.monite.com/api/concepts/authentication#permissions) within the entity. Each user has just one role. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -779,7 +800,7 @@ async def main() -> None: async def get_current(self, *, request_options: typing.Optional[RequestOptions] = None) -> EntityUserResponse: """ - Retrieve an entity user by its ID. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- @@ -824,24 +845,24 @@ async def update_current( request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ - Change the specified fields with provided values. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -882,7 +903,13 @@ async def main() -> None: async def get_current_entity(self, *, request_options: typing.Optional[RequestOptions] = None) -> EntityResponse: """ - Retrieves information of an entity, which this entity user belongs to. + Returns the entity to which the authenticated user belongs. This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.read` permission. + + To get an entity by using a partner access token, use [`GET /entities/{entity_id}`](https://docs.monite.com/api/entities/get-entities-id) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -921,17 +948,26 @@ async def update_current_entity( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ - Update information of an entity, which this entity user belongs to. + Update the entity to which the authenticated user belongs. + + This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.update` permission. + + This endpoint does not use the `X-Monite-Entity-Id` header. The entity ID is inferred from the access token. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -941,26 +977,26 @@ async def update_current_entity( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -992,13 +1028,13 @@ async def main() -> None: _response = await self._raw_client.update_current_entity( address=address, email=email, + individual=individual, + organization=organization, phone=phone, - website=website, - tax_id=tax_id, - registration_number=registration_number, registration_authority=registration_authority, - organization=organization, - individual=individual, + registration_number=registration_number, + tax_id=tax_id, + website=website, request_options=request_options, ) return _response.data @@ -1141,25 +1177,25 @@ async def update_by_id( entity_user_id : str email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. login : typing.Optional[str] - Login + The new username for this user. Must be unique within the entity. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the new role to assign to this user. The new role takes effect immediately, existing access tokens of this user are not invalidated. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/monite/entity_users/raw_client.py b/src/monite/entity_users/raw_client.py index 4a91e95..c72616c 100644 --- a/src/monite/entity_users/raw_client.py +++ b/src/monite/entity_users/raw_client.py @@ -14,8 +14,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.entity_response import EntityResponse @@ -196,8 +196,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -230,24 +230,27 @@ def create( Parameters ---------- first_name : str - First name + The user's first name. login : str + The username assigned to this user. Usernames must be unique within the entity. + + The `login` value is not used by Monite but may be used by partner applications, for example, to map the users between the partner's platform and Monite. email : typing.Optional[str] - An entity user business email + The user's business email address. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the role to assign to this user. The role defines the user's [access permissions](https://docs.monite.com/api/concepts/authentication#permissions) within the entity. Each user has just one role. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -296,6 +299,17 @@ def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -307,8 +321,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -327,7 +341,7 @@ def get_current( self, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[EntityUserResponse]: """ - Retrieve an entity user by its ID. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- @@ -365,6 +379,17 @@ def get_current( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -376,8 +401,8 @@ def get_current( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -403,24 +428,24 @@ def update_current( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[EntityUserResponse]: """ - Change the specified fields with provided values. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -467,6 +492,17 @@ def update_current( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -478,8 +514,8 @@ def update_current( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -498,7 +534,13 @@ def get_current_entity( self, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[EntityResponse]: """ - Retrieves information of an entity, which this entity user belongs to. + Returns the entity to which the authenticated user belongs. This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.read` permission. + + To get an entity by using a partner access token, use [`GET /entities/{entity_id}`](https://docs.monite.com/api/entities/get-entities-id) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -536,6 +578,17 @@ def get_current_entity( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -547,8 +600,8 @@ def get_current_entity( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -568,17 +621,26 @@ def update_current_entity( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[EntityResponse]: """ - Update information of an entity, which this entity user belongs to. + Update the entity to which the authenticated user belongs. + + This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.update` permission. + + This endpoint does not use the `X-Monite-Entity-Id` header. The entity ID is inferred from the access token. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -588,26 +650,26 @@ def update_current_entity( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -625,17 +687,17 @@ def update_current_entity( object_=address, annotation=UpdateEntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "tax_id": tax_id, - "registration_number": registration_number, - "registration_authority": registration_authority, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OptionalOrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=OptionalIndividualSchema, direction="write" ), + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OptionalOrganizationSchema, direction="write" + ), + "phone": phone, + "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, + "website": website, }, headers={ "content-type": "application/json", @@ -664,6 +726,17 @@ def update_current_entity( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -675,8 +748,8 @@ def update_current_entity( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -722,6 +795,17 @@ def get_current_role( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -733,8 +817,8 @@ def get_current_role( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -793,6 +877,17 @@ def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -804,8 +899,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -854,6 +949,17 @@ def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -865,8 +971,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -902,25 +1008,25 @@ def update_by_id( entity_user_id : str email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. login : typing.Optional[str] - Login + The new username for this user. Must be unique within the entity. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the new role to assign to this user. The new role takes effect immediately, existing access tokens of this user are not invalidated. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -969,6 +1075,17 @@ def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -980,8 +1097,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1161,8 +1278,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1195,24 +1312,27 @@ async def create( Parameters ---------- first_name : str - First name + The user's first name. login : str + The username assigned to this user. Usernames must be unique within the entity. + + The `login` value is not used by Monite but may be used by partner applications, for example, to map the users between the partner's platform and Monite. email : typing.Optional[str] - An entity user business email + The user's business email address. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the role to assign to this user. The role defines the user's [access permissions](https://docs.monite.com/api/concepts/authentication#permissions) within the entity. Each user has just one role. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1261,6 +1381,17 @@ async def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1272,8 +1403,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1292,7 +1423,7 @@ async def get_current( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[EntityUserResponse]: """ - Retrieve an entity user by its ID. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- @@ -1330,6 +1461,17 @@ async def get_current( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1341,8 +1483,8 @@ async def get_current( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1368,24 +1510,24 @@ async def update_current( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[EntityUserResponse]: """ - Change the specified fields with provided values. + The user ID is inferred fron the `Authorization` header, which must contain a user-level access token. Parameters ---------- email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1432,6 +1574,17 @@ async def update_current( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1443,8 +1596,8 @@ async def update_current( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1463,7 +1616,13 @@ async def get_current_entity( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[EntityResponse]: """ - Retrieves information of an entity, which this entity user belongs to. + Returns the entity to which the authenticated user belongs. This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.read` permission. + + To get an entity by using a partner access token, use [`GET /entities/{entity_id}`](https://docs.monite.com/api/entities/get-entities-id) instead. + + Related endpoints: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -1501,6 +1660,17 @@ async def get_current_entity( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1512,8 +1682,8 @@ async def get_current_entity( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1533,17 +1703,26 @@ async def update_current_entity( *, address: typing.Optional[UpdateEntityAddressSchema] = OMIT, email: typing.Optional[str] = OMIT, + individual: typing.Optional[OptionalIndividualSchema] = OMIT, + organization: typing.Optional[OptionalOrganizationSchema] = OMIT, phone: typing.Optional[str] = OMIT, - website: typing.Optional[str] = OMIT, - tax_id: typing.Optional[str] = OMIT, - registration_number: typing.Optional[str] = OMIT, registration_authority: typing.Optional[str] = OMIT, - organization: typing.Optional[OptionalOrganizationSchema] = OMIT, - individual: typing.Optional[OptionalIndividualSchema] = OMIT, + registration_number: typing.Optional[str] = OMIT, + tax_id: typing.Optional[str] = OMIT, + website: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[EntityResponse]: """ - Update information of an entity, which this entity user belongs to. + Update the entity to which the authenticated user belongs. + + This endpoint requires an [entity user access token](https://docs.monite.com/api/concepts/authentication#entity-user-token). The user must have a role with the `entity.update` permission. + + This endpoint does not use the `X-Monite-Entity-Id` header. The entity ID is inferred from the access token. + + Related endpoints: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) + * [Update entity logo](https://docs.monite.com/api/entities/put-entities-id-logo) Parameters ---------- @@ -1553,26 +1732,26 @@ async def update_current_entity( email : typing.Optional[str] An official email address of the entity + individual : typing.Optional[OptionalIndividualSchema] + A set of meta data describing the individual + + organization : typing.Optional[OptionalOrganizationSchema] + A set of meta data describing the organization + phone : typing.Optional[str] The contact phone number of the entity. Required for US organizations to use payments. - website : typing.Optional[str] - A website of the entity - - tax_id : typing.Optional[str] - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + registration_authority : typing.Optional[str] + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. registration_number : typing.Optional[str] (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. - registration_authority : typing.Optional[str] - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. - - organization : typing.Optional[OptionalOrganizationSchema] - A set of meta data describing the organization + tax_id : typing.Optional[str] + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. - individual : typing.Optional[OptionalIndividualSchema] - A set of meta data describing the individual + website : typing.Optional[str] + A website of the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1590,17 +1769,17 @@ async def update_current_entity( object_=address, annotation=UpdateEntityAddressSchema, direction="write" ), "email": email, - "phone": phone, - "website": website, - "tax_id": tax_id, - "registration_number": registration_number, - "registration_authority": registration_authority, - "organization": convert_and_respect_annotation_metadata( - object_=organization, annotation=OptionalOrganizationSchema, direction="write" - ), "individual": convert_and_respect_annotation_metadata( object_=individual, annotation=OptionalIndividualSchema, direction="write" ), + "organization": convert_and_respect_annotation_metadata( + object_=organization, annotation=OptionalOrganizationSchema, direction="write" + ), + "phone": phone, + "registration_authority": registration_authority, + "registration_number": registration_number, + "tax_id": tax_id, + "website": website, }, headers={ "content-type": "application/json", @@ -1629,6 +1808,17 @@ async def update_current_entity( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1640,8 +1830,8 @@ async def update_current_entity( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1687,6 +1877,17 @@ async def get_current_role( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1698,8 +1899,8 @@ async def get_current_role( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1758,6 +1959,17 @@ async def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1769,8 +1981,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1819,6 +2031,17 @@ async def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1830,8 +2053,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1867,25 +2090,25 @@ async def update_by_id( entity_user_id : str email : typing.Optional[str] - An entity user business email + The user's business email address. first_name : typing.Optional[str] - First name + The user's first name. last_name : typing.Optional[str] - Last name + The user's last name. login : typing.Optional[str] - Login + The new username for this user. Must be unique within the entity. phone : typing.Optional[str] - An entity user phone number in the international format + The user's phone number. role_id : typing.Optional[str] - UUID of the role assigned to this entity user + ID of the new role to assign to this user. The new role takes effect immediately, existing access tokens of this user are not invalidated. title : typing.Optional[str] - Title + The user's job title. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1934,6 +2157,17 @@ async def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1945,8 +2179,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/errors/__init__.py b/src/monite/errors/__init__.py index e237df2..75a44ad 100644 --- a/src/monite/errors/__init__.py +++ b/src/monite/errors/__init__.py @@ -7,10 +7,10 @@ from .content_too_large_error import ContentTooLargeError from .failed_dependency_error import FailedDependencyError from .forbidden_error import ForbiddenError -from .internal_server_error import InternalServerError from .misdirected_request_error import MisdirectedRequestError from .not_acceptable_error import NotAcceptableError from .not_found_error import NotFoundError +from .too_many_requests_error import TooManyRequestsError from .unauthorized_error import UnauthorizedError from .unprocessable_entity_error import UnprocessableEntityError from .unsupported_media_type_error import UnsupportedMediaTypeError @@ -21,10 +21,10 @@ "ContentTooLargeError", "FailedDependencyError", "ForbiddenError", - "InternalServerError", "MisdirectedRequestError", "NotAcceptableError", "NotFoundError", + "TooManyRequestsError", "UnauthorizedError", "UnprocessableEntityError", "UnsupportedMediaTypeError", diff --git a/src/monite/errors/internal_server_error.py b/src/monite/errors/too_many_requests_error.py similarity index 70% rename from src/monite/errors/internal_server_error.py rename to src/monite/errors/too_many_requests_error.py index 14313ab..2705399 100644 --- a/src/monite/errors/internal_server_error.py +++ b/src/monite/errors/too_many_requests_error.py @@ -5,6 +5,6 @@ from ..core.api_error import ApiError -class InternalServerError(ApiError): +class TooManyRequestsError(ApiError): def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): - super().__init__(status_code=500, headers=headers, body=body) + super().__init__(status_code=429, headers=headers, body=body) diff --git a/src/monite/events/raw_client.py b/src/monite/events/raw_client.py index 9c89c37..6d3c65f 100644 --- a/src/monite/events/raw_client.py +++ b/src/monite/events/raw_client.py @@ -11,7 +11,8 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.event_cursor_fields import EventCursorFields from ..types.event_pagination_resource import EventPaginationResource @@ -105,6 +106,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -116,8 +128,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -166,6 +178,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -177,8 +200,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -279,6 +302,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -290,8 +324,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -340,6 +374,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -351,8 +396,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/files/client.py b/src/monite/files/client.py index 538c922..511ed28 100644 --- a/src/monite/files/client.py +++ b/src/monite/files/client.py @@ -33,12 +33,41 @@ def get( self, *, id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + file_type: typing.Optional[AllowedFileTypes] = None, request_options: typing.Optional[RequestOptions] = None, ) -> FilesResponse: """ + The `/files` endpoint provides access to an entity's files hosted on Monite's servers. This includes both files uploaded by the entity and files that were automatically created by Monite (such as PDF versions of invoices). + + `GET /files` requires at least one query parameter, either `id__in` or `file_type`. You can use this operation to: + + * Bulk fetch multiple files by IDs. + * Get all files with the given purpose (for example, invoice attachments). + + If no files matching the query parameters were found, the response contains an empty `data` array. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Return only files with specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. + + To specify multiple IDs, repeat this parameter for each value: `id__in=&id__in=` + + file_type : typing.Optional[AllowedFileTypes] + Return only files with the given purpose. Possible values: + + * `additional_identity_documents` and `identity_documents` - [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) uploaded for payments onboarding. + * `attachments` - supplementary attachments for accounts receivable invoices, quotes, and credit notes. + * `delivery_notes` - auto-generated PDF versions of delivery notes. + * `einvoices_xml` - e-invoice XML generated when sending e-invoices. + * `payables` - payables (bills) received via email or uploaded via API. + * `receivable_signatures` - images of customer signatures provided during quote acceptance. + * `receivables` - auto-generated PDF versions of invoices, quotes, and credit notes. + * `zip` - data export archives created by `POST /data_exports`. + + Other values are unused. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -59,19 +88,35 @@ def get( ) client.files.get() """ - _response = self._raw_client.get(id_in=id_in, request_options=request_options) + _response = self._raw_client.get(id_in=id_in, file_type=file_type, request_options=request_options) return _response.data def upload( self, *, file: core.File, file_type: AllowedFileTypes, request_options: typing.Optional[RequestOptions] = None ) -> FileResponse: """ + Upload files for use as: + + * supplementary attachments for invoices, quotes, and credit notes, + * [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) for payments onboarding. + + Maximum file size is 15 MB. Each uploaded file is assigned a unique `id` that you can use to reference this file elsewhere. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file : core.File See core.File for more documentation file_type : AllowedFileTypes + The intended purpose of the file. Possible values: + + * `attachments` - supplemental attachments for accounts receivable invoices, quotes, and credit notes. + * `identity_documents` - company registration documents or a person's identity documents for payments onboarding. + * `additional_identity_documents` - documents that verify a person's address. + + Other enum values are not supposed to be used directly. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -99,6 +144,10 @@ def upload( def get_by_id(self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> FileResponse: """ + Returns the details of an existing file. To bulk fetch multiple files by their IDs, use `GET /files?id__in=&id__in=`. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file_id : str @@ -129,9 +178,18 @@ def get_by_id(self, file_id: str, *, request_options: typing.Optional[RequestOpt def delete(self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ + Delete a file with the specified ID. + + **Note:** This endpoint does not check if the specified file is in use. Use with caution. + + Both partner tokens and entity user tokens can be used for authentication. + #### Considerations for invoice attachments + Deleting a file does not delete it from the `attachments` list of accounts receivable invoices, quotes, and credit notes because these documents contain an inline copy of all referenced resources. To delete a file from attachments, call `PATCH /receivables/{receivable_id}` and update the `attachments` list to exclude the deleted file. + Parameters ---------- file_id : str + ID of the file you want to delete. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -176,12 +234,41 @@ async def get( self, *, id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + file_type: typing.Optional[AllowedFileTypes] = None, request_options: typing.Optional[RequestOptions] = None, ) -> FilesResponse: """ + The `/files` endpoint provides access to an entity's files hosted on Monite's servers. This includes both files uploaded by the entity and files that were automatically created by Monite (such as PDF versions of invoices). + + `GET /files` requires at least one query parameter, either `id__in` or `file_type`. You can use this operation to: + + * Bulk fetch multiple files by IDs. + * Get all files with the given purpose (for example, invoice attachments). + + If no files matching the query parameters were found, the response contains an empty `data` array. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Return only files with specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. + + To specify multiple IDs, repeat this parameter for each value: `id__in=&id__in=` + + file_type : typing.Optional[AllowedFileTypes] + Return only files with the given purpose. Possible values: + + * `additional_identity_documents` and `identity_documents` - [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) uploaded for payments onboarding. + * `attachments` - supplementary attachments for accounts receivable invoices, quotes, and credit notes. + * `delivery_notes` - auto-generated PDF versions of delivery notes. + * `einvoices_xml` - e-invoice XML generated when sending e-invoices. + * `payables` - payables (bills) received via email or uploaded via API. + * `receivable_signatures` - images of customer signatures provided during quote acceptance. + * `receivables` - auto-generated PDF versions of invoices, quotes, and credit notes. + * `zip` - data export archives created by `POST /data_exports`. + + Other values are unused. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -210,19 +297,35 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.get(id_in=id_in, request_options=request_options) + _response = await self._raw_client.get(id_in=id_in, file_type=file_type, request_options=request_options) return _response.data async def upload( self, *, file: core.File, file_type: AllowedFileTypes, request_options: typing.Optional[RequestOptions] = None ) -> FileResponse: """ + Upload files for use as: + + * supplementary attachments for invoices, quotes, and credit notes, + * [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) for payments onboarding. + + Maximum file size is 15 MB. Each uploaded file is assigned a unique `id` that you can use to reference this file elsewhere. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file : core.File See core.File for more documentation file_type : AllowedFileTypes + The intended purpose of the file. Possible values: + + * `attachments` - supplemental attachments for accounts receivable invoices, quotes, and credit notes. + * `identity_documents` - company registration documents or a person's identity documents for payments onboarding. + * `additional_identity_documents` - documents that verify a person's address. + + Other enum values are not supposed to be used directly. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -258,6 +361,10 @@ async def main() -> None: async def get_by_id(self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> FileResponse: """ + Returns the details of an existing file. To bulk fetch multiple files by their IDs, use `GET /files?id__in=&id__in=`. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file_id : str @@ -296,9 +403,18 @@ async def main() -> None: async def delete(self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ + Delete a file with the specified ID. + + **Note:** This endpoint does not check if the specified file is in use. Use with caution. + + Both partner tokens and entity user tokens can be used for authentication. + #### Considerations for invoice attachments + Deleting a file does not delete it from the `attachments` list of accounts receivable invoices, quotes, and credit notes because these documents contain an inline copy of all referenced resources. To delete a file from attachments, call `PATCH /receivables/{receivable_id}` and update the `attachments` list to exclude the deleted file. + Parameters ---------- file_id : str + ID of the file you want to delete. request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/monite/files/raw_client.py b/src/monite/files/raw_client.py index b1d561d..ae9e53e 100644 --- a/src/monite/files/raw_client.py +++ b/src/monite/files/raw_client.py @@ -10,7 +10,9 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.allowed_file_types import AllowedFileTypes from ..types.file_response import FileResponse @@ -28,12 +30,41 @@ def get( self, *, id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + file_type: typing.Optional[AllowedFileTypes] = None, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[FilesResponse]: """ + The `/files` endpoint provides access to an entity's files hosted on Monite's servers. This includes both files uploaded by the entity and files that were automatically created by Monite (such as PDF versions of invoices). + + `GET /files` requires at least one query parameter, either `id__in` or `file_type`. You can use this operation to: + + * Bulk fetch multiple files by IDs. + * Get all files with the given purpose (for example, invoice attachments). + + If no files matching the query parameters were found, the response contains an empty `data` array. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Return only files with specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. + + To specify multiple IDs, repeat this parameter for each value: `id__in=&id__in=` + + file_type : typing.Optional[AllowedFileTypes] + Return only files with the given purpose. Possible values: + + * `additional_identity_documents` and `identity_documents` - [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) uploaded for payments onboarding. + * `attachments` - supplementary attachments for accounts receivable invoices, quotes, and credit notes. + * `delivery_notes` - auto-generated PDF versions of delivery notes. + * `einvoices_xml` - e-invoice XML generated when sending e-invoices. + * `payables` - payables (bills) received via email or uploaded via API. + * `receivable_signatures` - images of customer signatures provided during quote acceptance. + * `receivables` - auto-generated PDF versions of invoices, quotes, and credit notes. + * `zip` - data export archives created by `POST /data_exports`. + + Other values are unused. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -48,6 +79,7 @@ def get( method="GET", params={ "id__in": id_in, + "file_type": file_type, }, request_options=request_options, ) @@ -61,6 +93,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -72,8 +115,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -92,12 +135,28 @@ def upload( self, *, file: core.File, file_type: AllowedFileTypes, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[FileResponse]: """ + Upload files for use as: + + * supplementary attachments for invoices, quotes, and credit notes, + * [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) for payments onboarding. + + Maximum file size is 15 MB. Each uploaded file is assigned a unique `id` that you can use to reference this file elsewhere. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file : core.File See core.File for more documentation file_type : AllowedFileTypes + The intended purpose of the file. Possible values: + + * `attachments` - supplemental attachments for accounts receivable invoices, quotes, and credit notes. + * `identity_documents` - company registration documents or a person's identity documents for payments onboarding. + * `additional_identity_documents` - documents that verify a person's address. + + Other enum values are not supposed to be used directly. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -130,6 +189,17 @@ def upload( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -141,8 +211,8 @@ def upload( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -161,6 +231,10 @@ def get_by_id( self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[FileResponse]: """ + Returns the details of an existing file. To bulk fetch multiple files by their IDs, use `GET /files?id__in=&id__in=`. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file_id : str @@ -188,6 +262,28 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -199,8 +295,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -217,9 +313,18 @@ def get_by_id( def delete(self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: """ + Delete a file with the specified ID. + + **Note:** This endpoint does not check if the specified file is in use. Use with caution. + + Both partner tokens and entity user tokens can be used for authentication. + #### Considerations for invoice attachments + Deleting a file does not delete it from the `attachments` list of accounts receivable invoices, quotes, and credit notes because these documents contain an inline copy of all referenced resources. To delete a file from attachments, call `PATCH /receivables/{receivable_id}` and update the `attachments` list to exclude the deleted file. + Parameters ---------- file_id : str + ID of the file you want to delete. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -236,6 +341,28 @@ def delete(self, file_id: str, *, request_options: typing.Optional[RequestOption try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -247,8 +374,8 @@ def delete(self, file_id: str, *, request_options: typing.Optional[RequestOption ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -272,12 +399,41 @@ async def get( self, *, id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + file_type: typing.Optional[AllowedFileTypes] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[FilesResponse]: """ + The `/files` endpoint provides access to an entity's files hosted on Monite's servers. This includes both files uploaded by the entity and files that were automatically created by Monite (such as PDF versions of invoices). + + `GET /files` requires at least one query parameter, either `id__in` or `file_type`. You can use this operation to: + + * Bulk fetch multiple files by IDs. + * Get all files with the given purpose (for example, invoice attachments). + + If no files matching the query parameters were found, the response contains an empty `data` array. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Return only files with specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. + + To specify multiple IDs, repeat this parameter for each value: `id__in=&id__in=` + + file_type : typing.Optional[AllowedFileTypes] + Return only files with the given purpose. Possible values: + + * `additional_identity_documents` and `identity_documents` - [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) uploaded for payments onboarding. + * `attachments` - supplementary attachments for accounts receivable invoices, quotes, and credit notes. + * `delivery_notes` - auto-generated PDF versions of delivery notes. + * `einvoices_xml` - e-invoice XML generated when sending e-invoices. + * `payables` - payables (bills) received via email or uploaded via API. + * `receivable_signatures` - images of customer signatures provided during quote acceptance. + * `receivables` - auto-generated PDF versions of invoices, quotes, and credit notes. + * `zip` - data export archives created by `POST /data_exports`. + + Other values are unused. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -292,6 +448,7 @@ async def get( method="GET", params={ "id__in": id_in, + "file_type": file_type, }, request_options=request_options, ) @@ -305,6 +462,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -316,8 +484,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -336,12 +504,28 @@ async def upload( self, *, file: core.File, file_type: AllowedFileTypes, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[FileResponse]: """ + Upload files for use as: + + * supplementary attachments for invoices, quotes, and credit notes, + * [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) for payments onboarding. + + Maximum file size is 15 MB. Each uploaded file is assigned a unique `id` that you can use to reference this file elsewhere. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file : core.File See core.File for more documentation file_type : AllowedFileTypes + The intended purpose of the file. Possible values: + + * `attachments` - supplemental attachments for accounts receivable invoices, quotes, and credit notes. + * `identity_documents` - company registration documents or a person's identity documents for payments onboarding. + * `additional_identity_documents` - documents that verify a person's address. + + Other enum values are not supposed to be used directly. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -374,6 +558,17 @@ async def upload( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -385,8 +580,8 @@ async def upload( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -405,6 +600,10 @@ async def get_by_id( self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[FileResponse]: """ + Returns the details of an existing file. To bulk fetch multiple files by their IDs, use `GET /files?id__in=&id__in=`. + + Both partner tokens and entity user tokens can be used for authentication. + Parameters ---------- file_id : str @@ -432,6 +631,28 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -443,8 +664,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -463,9 +684,18 @@ async def delete( self, file_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ + Delete a file with the specified ID. + + **Note:** This endpoint does not check if the specified file is in use. Use with caution. + + Both partner tokens and entity user tokens can be used for authentication. + #### Considerations for invoice attachments + Deleting a file does not delete it from the `attachments` list of accounts receivable invoices, quotes, and credit notes because these documents contain an inline copy of all referenced resources. To delete a file from attachments, call `PATCH /receivables/{receivable_id}` and update the `attachments` list to exclude the deleted file. + Parameters ---------- file_id : str + ID of the file you want to delete. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -482,6 +712,28 @@ async def delete( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -493,8 +745,8 @@ async def delete( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/financing/raw_client.py b/src/monite/financing/raw_client.py index 019f3ed..93c2faf 100644 --- a/src/monite/financing/raw_client.py +++ b/src/monite/financing/raw_client.py @@ -11,7 +11,8 @@ from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.financing_invoice_cursor_fields import FinancingInvoiceCursorFields from ..types.financing_invoice_list_response import FinancingInvoiceListResponse @@ -213,6 +214,17 @@ def get_financing_invoices( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -224,8 +236,8 @@ def get_financing_invoices( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -286,6 +298,17 @@ def post_financing_invoices( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -297,8 +320,8 @@ def post_financing_invoices( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -344,6 +367,17 @@ def get_financing_offers( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -355,8 +389,8 @@ def get_financing_offers( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -402,6 +436,17 @@ def post_financing_tokens( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -413,8 +458,8 @@ def post_financing_tokens( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -616,6 +661,17 @@ async def get_financing_invoices( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -627,8 +683,8 @@ async def get_financing_invoices( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -689,6 +745,17 @@ async def post_financing_invoices( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -700,8 +767,8 @@ async def post_financing_invoices( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -747,6 +814,17 @@ async def get_financing_offers( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -758,8 +836,8 @@ async def get_financing_offers( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -805,6 +883,17 @@ async def post_financing_tokens( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -816,8 +905,8 @@ async def post_financing_tokens( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/mail_templates/client.py b/src/monite/mail_templates/client.py index 88baa9b..1bf9512 100644 --- a/src/monite/mail_templates/client.py +++ b/src/monite/mail_templates/client.py @@ -60,7 +60,7 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -69,7 +69,7 @@ def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[CustomTemplatesCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. type : typing.Optional[DocumentObjectTypeRequestEnum] @@ -481,7 +481,7 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -490,7 +490,7 @@ async def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[CustomTemplatesCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. type : typing.Optional[DocumentObjectTypeRequestEnum] diff --git a/src/monite/mail_templates/raw_client.py b/src/monite/mail_templates/raw_client.py index 5a1f5b1..6cd7d68 100644 --- a/src/monite/mail_templates/raw_client.py +++ b/src/monite/mail_templates/raw_client.py @@ -9,7 +9,8 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.custom_template_data_schema import CustomTemplateDataSchema from ..types.custom_templates_cursor_fields import CustomTemplatesCursorFields @@ -55,7 +56,7 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -64,7 +65,7 @@ def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[CustomTemplatesCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. type : typing.Optional[DocumentObjectTypeRequestEnum] @@ -119,6 +120,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -130,8 +142,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -215,6 +227,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -226,8 +249,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -301,6 +324,17 @@ def preview( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -312,8 +346,8 @@ def preview( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -357,6 +391,17 @@ def get_system(self, *, request_options: typing.Optional[RequestOptions] = None) ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -368,8 +413,8 @@ def get_system(self, *, request_options: typing.Optional[RequestOptions] = None) ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -417,6 +462,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -428,8 +484,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -469,6 +525,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -480,8 +547,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -558,6 +625,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -569,8 +647,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -618,6 +696,17 @@ def make_default_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -629,8 +718,8 @@ def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -677,7 +766,7 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -686,7 +775,7 @@ async def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[CustomTemplatesCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. type : typing.Optional[DocumentObjectTypeRequestEnum] @@ -741,6 +830,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -752,8 +852,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -837,6 +937,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -848,8 +959,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -923,6 +1034,17 @@ async def preview( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -934,8 +1056,8 @@ async def preview( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -981,6 +1103,17 @@ async def get_system( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -992,8 +1125,8 @@ async def get_system( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1041,6 +1174,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1052,8 +1196,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1093,6 +1237,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1104,8 +1259,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1182,6 +1337,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1193,8 +1359,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1242,6 +1408,17 @@ async def make_default_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1253,8 +1430,8 @@ async def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/mailbox_domains/raw_client.py b/src/monite/mailbox_domains/raw_client.py index 3d5f6b1..acabfaa 100644 --- a/src/monite/mailbox_domains/raw_client.py +++ b/src/monite/mailbox_domains/raw_client.py @@ -12,8 +12,8 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.domain_list_response import DomainListResponse @@ -90,8 +90,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -202,8 +202,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -287,8 +287,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -402,8 +402,8 @@ def verify_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -487,8 +487,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -599,8 +599,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -684,8 +684,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -799,8 +799,8 @@ async def verify_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/mailboxes/client.py b/src/monite/mailboxes/client.py index 62dc066..30ac340 100644 --- a/src/monite/mailboxes/client.py +++ b/src/monite/mailboxes/client.py @@ -5,6 +5,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.mailbox_data_response import MailboxDataResponse +from ..types.mailbox_object_type_enum import MailboxObjectTypeEnum from ..types.mailbox_response import MailboxResponse from .raw_client import AsyncRawMailboxesClient, RawMailboxesClient @@ -56,7 +57,12 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Mai return _response.data def create( - self, *, mailbox_domain_id: str, mailbox_name: str, request_options: typing.Optional[RequestOptions] = None + self, + *, + mailbox_domain_id: str, + mailbox_name: str, + related_object_type: MailboxObjectTypeEnum, + request_options: typing.Optional[RequestOptions] = None, ) -> MailboxResponse: """ Create a new mailbox @@ -67,6 +73,9 @@ def create( mailbox_name : str + related_object_type : MailboxObjectTypeEnum + Related object type: payable and so on + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -87,10 +96,14 @@ def create( client.mailboxes.create( mailbox_domain_id="mailbox_domain_id", mailbox_name="mailbox_name", + related_object_type="payable", ) """ _response = self._raw_client.create( - mailbox_domain_id=mailbox_domain_id, mailbox_name=mailbox_name, request_options=request_options + mailbox_domain_id=mailbox_domain_id, + mailbox_name=mailbox_name, + related_object_type=related_object_type, + request_options=request_options, ) return _response.data @@ -212,7 +225,12 @@ async def main() -> None: return _response.data async def create( - self, *, mailbox_domain_id: str, mailbox_name: str, request_options: typing.Optional[RequestOptions] = None + self, + *, + mailbox_domain_id: str, + mailbox_name: str, + related_object_type: MailboxObjectTypeEnum, + request_options: typing.Optional[RequestOptions] = None, ) -> MailboxResponse: """ Create a new mailbox @@ -223,6 +241,9 @@ async def create( mailbox_name : str + related_object_type : MailboxObjectTypeEnum + Related object type: payable and so on + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -248,13 +269,17 @@ async def main() -> None: await client.mailboxes.create( mailbox_domain_id="mailbox_domain_id", mailbox_name="mailbox_name", + related_object_type="payable", ) asyncio.run(main()) """ _response = await self._raw_client.create( - mailbox_domain_id=mailbox_domain_id, mailbox_name=mailbox_name, request_options=request_options + mailbox_domain_id=mailbox_domain_id, + mailbox_name=mailbox_name, + related_object_type=related_object_type, + request_options=request_options, ) return _response.data diff --git a/src/monite/mailboxes/raw_client.py b/src/monite/mailboxes/raw_client.py index bb9912e..0de18df 100644 --- a/src/monite/mailboxes/raw_client.py +++ b/src/monite/mailboxes/raw_client.py @@ -11,11 +11,12 @@ from ..core.request_options import RequestOptions from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.mailbox_data_response import MailboxDataResponse +from ..types.mailbox_object_type_enum import MailboxObjectTypeEnum from ..types.mailbox_response import MailboxResponse # this is used as the default value for optional parameters @@ -88,8 +89,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -105,7 +106,12 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create( - self, *, mailbox_domain_id: str, mailbox_name: str, request_options: typing.Optional[RequestOptions] = None + self, + *, + mailbox_domain_id: str, + mailbox_name: str, + related_object_type: MailboxObjectTypeEnum, + request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[MailboxResponse]: """ Create a new mailbox @@ -116,6 +122,9 @@ def create( mailbox_name : str + related_object_type : MailboxObjectTypeEnum + Related object type: payable and so on + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -130,7 +139,7 @@ def create( json={ "mailbox_domain_id": mailbox_domain_id, "mailbox_name": mailbox_name, - "related_object_type": "payable", + "related_object_type": related_object_type, }, headers={ "content-type": "application/json", @@ -192,8 +201,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -281,8 +290,8 @@ def search( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -366,8 +375,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -451,8 +460,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -468,7 +477,12 @@ async def get( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create( - self, *, mailbox_domain_id: str, mailbox_name: str, request_options: typing.Optional[RequestOptions] = None + self, + *, + mailbox_domain_id: str, + mailbox_name: str, + related_object_type: MailboxObjectTypeEnum, + request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[MailboxResponse]: """ Create a new mailbox @@ -479,6 +493,9 @@ async def create( mailbox_name : str + related_object_type : MailboxObjectTypeEnum + Related object type: payable and so on + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -493,7 +510,7 @@ async def create( json={ "mailbox_domain_id": mailbox_domain_id, "mailbox_name": mailbox_name, - "related_object_type": "payable", + "related_object_type": related_object_type, }, headers={ "content-type": "application/json", @@ -555,8 +572,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -644,8 +661,8 @@ async def search( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -729,8 +746,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/measure_units/raw_client.py b/src/monite/measure_units/raw_client.py index d351405..75b16b0 100644 --- a/src/monite/measure_units/raw_client.py +++ b/src/monite/measure_units/raw_client.py @@ -11,8 +11,8 @@ from ..core.request_options import RequestOptions from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.unit_list_response import UnitListResponse @@ -97,8 +97,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -202,8 +202,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -304,8 +304,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -398,8 +398,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -517,8 +517,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -611,8 +611,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -716,8 +716,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -818,8 +818,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -912,8 +912,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1031,8 +1031,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/ocr/raw_client.py b/src/monite/ocr/raw_client.py index f8797ca..1a815a5 100644 --- a/src/monite/ocr/raw_client.py +++ b/src/monite/ocr/raw_client.py @@ -15,9 +15,10 @@ from ..errors.bad_request_error import BadRequestError from ..errors.content_too_large_error import ContentTooLargeError from ..errors.failed_dependency_error import FailedDependencyError -from ..errors.internal_server_error import InternalServerError from ..errors.misdirected_request_error import MisdirectedRequestError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError from ..types.cursor_fields import CursorFields @@ -127,6 +128,17 @@ def get_ocr_tasks( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -149,8 +161,8 @@ def get_ocr_tasks( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -221,6 +233,17 @@ def post_ocr_tasks( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 413: raise ContentTooLargeError( headers=dict(_response.headers), @@ -276,8 +299,8 @@ def post_ocr_tasks( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -350,6 +373,17 @@ def post_ocr_tasks_upload_from_file( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 413: raise ContentTooLargeError( headers=dict(_response.headers), @@ -383,8 +417,8 @@ def post_ocr_tasks_upload_from_file( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -430,6 +464,17 @@ def get_ocr_tasks_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -452,8 +497,8 @@ def get_ocr_tasks_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -565,6 +610,17 @@ async def get_ocr_tasks( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -587,8 +643,8 @@ async def get_ocr_tasks( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -659,6 +715,17 @@ async def post_ocr_tasks( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 413: raise ContentTooLargeError( headers=dict(_response.headers), @@ -714,8 +781,8 @@ async def post_ocr_tasks( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -788,6 +855,17 @@ async def post_ocr_tasks_upload_from_file( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 413: raise ContentTooLargeError( headers=dict(_response.headers), @@ -821,8 +899,8 @@ async def post_ocr_tasks_upload_from_file( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -868,6 +946,17 @@ async def get_ocr_tasks_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -890,8 +979,8 @@ async def get_ocr_tasks_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/overdue_reminders/raw_client.py b/src/monite/overdue_reminders/raw_client.py index 2d3167e..7faa4a0 100644 --- a/src/monite/overdue_reminders/raw_client.py +++ b/src/monite/overdue_reminders/raw_client.py @@ -12,8 +12,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.all_overdue_reminders_response import AllOverdueRemindersResponse @@ -91,8 +91,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -205,8 +205,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -296,8 +296,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -390,8 +390,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -518,8 +518,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -601,8 +601,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -715,8 +715,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -806,8 +806,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -900,8 +900,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1028,8 +1028,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/partner_settings/client.py b/src/monite/partner_settings/client.py index 5fa970a..b721625 100644 --- a/src/monite/partner_settings/client.py +++ b/src/monite/partner_settings/client.py @@ -35,7 +35,11 @@ def with_raw_response(self) -> RawPartnerSettingsClient: def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> PartnerProjectSettingsPayloadOutput: """ - Retrieve all settings for this partner. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -64,51 +68,59 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Par def update( self, *, + api_version: typing.Optional[ApiVersion] = OMIT, + commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, currency: typing.Optional[CurrencySettingsInput] = OMIT, + default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + mail: typing.Optional[MailSettings] = OMIT, payable: typing.Optional[PayableSettings] = OMIT, + payments: typing.Optional[PaymentsSettingsInput] = OMIT, receivable: typing.Optional[ReceivableSettings] = OMIT, - mail: typing.Optional[MailSettings] = OMIT, - commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, units: typing.Optional[typing.Sequence[Unit]] = OMIT, website: typing.Optional[str] = OMIT, - default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, - payments: typing.Optional[PaymentsSettingsInput] = OMIT, - api_version: typing.Optional[ApiVersion] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> PartnerProjectSettingsPayloadOutput: """ - Change the specified fields with the provided values. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) Parameters ---------- + api_version : typing.Optional[ApiVersion] + Default API version for partner. + + commercial_conditions : typing.Optional[typing.Sequence[str]] + Unused. To specify commercial conditions for invoices and quotes, use the `commercial_condition_description` field in those documents. + currency : typing.Optional[CurrencySettingsInput] Custom currency exchange rates. - payable : typing.Optional[PayableSettings] - Settings for the payables module. - - receivable : typing.Optional[ReceivableSettings] - Settings for the receivables module. + default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + A default role to provision upon new entity creation. mail : typing.Optional[MailSettings] - Settings for email and mailboxes. + Settings for outgoing email. Used by: - commercial_conditions : typing.Optional[typing.Sequence[str]] - Commercial conditions for receivables. + * accounts receivable emails, for example, emails sent by `POST /recevables/{receivable_id}/send`, + * accounts payable approval notifications. - units : typing.Optional[typing.Sequence[Unit]] - Measurement units. - - website : typing.Optional[str] - - default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - A default role to provision upon new entity creation. + payable : typing.Optional[PayableSettings] + Settings for accounts payable. payments : typing.Optional[PaymentsSettingsInput] Settings for the payments module. - api_version : typing.Optional[ApiVersion] - Default API version for partner. + receivable : typing.Optional[ReceivableSettings] + Settings for accounts receivable. + + units : typing.Optional[typing.Sequence[Unit]] + Unused. To manage the [measure units](https://docs.monite.com/accounts-receivable/products#manage-measure-units) for your entities, use the `/measure_units` endpoints. + + website : typing.Optional[str] + The URL of the partner's website. Must be an HTTPS URL. Required if the partner's entities use [payment links](https://docs.monite.com/payments/payment-links). The "Powered by" badge in the payment page footer will link to this website. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -130,16 +142,16 @@ def update( client.partner_settings.update() """ _response = self._raw_client.update( + api_version=api_version, + commercial_conditions=commercial_conditions, currency=currency, + default_role=default_role, + mail=mail, payable=payable, + payments=payments, receivable=receivable, - mail=mail, - commercial_conditions=commercial_conditions, units=units, website=website, - default_role=default_role, - payments=payments, - api_version=api_version, request_options=request_options, ) return _response.data @@ -164,7 +176,11 @@ async def get( self, *, request_options: typing.Optional[RequestOptions] = None ) -> PartnerProjectSettingsPayloadOutput: """ - Retrieve all settings for this partner. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -201,51 +217,59 @@ async def main() -> None: async def update( self, *, + api_version: typing.Optional[ApiVersion] = OMIT, + commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, currency: typing.Optional[CurrencySettingsInput] = OMIT, + default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + mail: typing.Optional[MailSettings] = OMIT, payable: typing.Optional[PayableSettings] = OMIT, + payments: typing.Optional[PaymentsSettingsInput] = OMIT, receivable: typing.Optional[ReceivableSettings] = OMIT, - mail: typing.Optional[MailSettings] = OMIT, - commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, units: typing.Optional[typing.Sequence[Unit]] = OMIT, website: typing.Optional[str] = OMIT, - default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, - payments: typing.Optional[PaymentsSettingsInput] = OMIT, - api_version: typing.Optional[ApiVersion] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> PartnerProjectSettingsPayloadOutput: """ - Change the specified fields with the provided values. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) Parameters ---------- + api_version : typing.Optional[ApiVersion] + Default API version for partner. + + commercial_conditions : typing.Optional[typing.Sequence[str]] + Unused. To specify commercial conditions for invoices and quotes, use the `commercial_condition_description` field in those documents. + currency : typing.Optional[CurrencySettingsInput] Custom currency exchange rates. - payable : typing.Optional[PayableSettings] - Settings for the payables module. - - receivable : typing.Optional[ReceivableSettings] - Settings for the receivables module. + default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + A default role to provision upon new entity creation. mail : typing.Optional[MailSettings] - Settings for email and mailboxes. + Settings for outgoing email. Used by: - commercial_conditions : typing.Optional[typing.Sequence[str]] - Commercial conditions for receivables. + * accounts receivable emails, for example, emails sent by `POST /recevables/{receivable_id}/send`, + * accounts payable approval notifications. - units : typing.Optional[typing.Sequence[Unit]] - Measurement units. - - website : typing.Optional[str] - - default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - A default role to provision upon new entity creation. + payable : typing.Optional[PayableSettings] + Settings for accounts payable. payments : typing.Optional[PaymentsSettingsInput] Settings for the payments module. - api_version : typing.Optional[ApiVersion] - Default API version for partner. + receivable : typing.Optional[ReceivableSettings] + Settings for accounts receivable. + + units : typing.Optional[typing.Sequence[Unit]] + Unused. To manage the [measure units](https://docs.monite.com/accounts-receivable/products#manage-measure-units) for your entities, use the `/measure_units` endpoints. + + website : typing.Optional[str] + The URL of the partner's website. Must be an HTTPS URL. Required if the partner's entities use [payment links](https://docs.monite.com/payments/payment-links). The "Powered by" badge in the payment page footer will link to this website. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -275,16 +299,16 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._raw_client.update( + api_version=api_version, + commercial_conditions=commercial_conditions, currency=currency, + default_role=default_role, + mail=mail, payable=payable, + payments=payments, receivable=receivable, - mail=mail, - commercial_conditions=commercial_conditions, units=units, website=website, - default_role=default_role, - payments=payments, - api_version=api_version, request_options=request_options, ) return _response.data diff --git a/src/monite/partner_settings/raw_client.py b/src/monite/partner_settings/raw_client.py index 02ca885..abe29c1 100644 --- a/src/monite/partner_settings/raw_client.py +++ b/src/monite/partner_settings/raw_client.py @@ -10,7 +10,10 @@ from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError -from ..errors.internal_server_error import InternalServerError +from ..errors.forbidden_error import ForbiddenError +from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.api_version import ApiVersion from ..types.currency_settings_input import CurrencySettingsInput @@ -33,7 +36,11 @@ def get( self, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[PartnerProjectSettingsPayloadOutput]: """ - Retrieve all settings for this partner. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -71,6 +78,39 @@ def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -82,8 +122,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -101,51 +141,59 @@ def get( def update( self, *, + api_version: typing.Optional[ApiVersion] = OMIT, + commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, currency: typing.Optional[CurrencySettingsInput] = OMIT, + default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + mail: typing.Optional[MailSettings] = OMIT, payable: typing.Optional[PayableSettings] = OMIT, + payments: typing.Optional[PaymentsSettingsInput] = OMIT, receivable: typing.Optional[ReceivableSettings] = OMIT, - mail: typing.Optional[MailSettings] = OMIT, - commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, units: typing.Optional[typing.Sequence[Unit]] = OMIT, website: typing.Optional[str] = OMIT, - default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, - payments: typing.Optional[PaymentsSettingsInput] = OMIT, - api_version: typing.Optional[ApiVersion] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[PartnerProjectSettingsPayloadOutput]: """ - Change the specified fields with the provided values. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) Parameters ---------- + api_version : typing.Optional[ApiVersion] + Default API version for partner. + + commercial_conditions : typing.Optional[typing.Sequence[str]] + Unused. To specify commercial conditions for invoices and quotes, use the `commercial_condition_description` field in those documents. + currency : typing.Optional[CurrencySettingsInput] Custom currency exchange rates. - payable : typing.Optional[PayableSettings] - Settings for the payables module. - - receivable : typing.Optional[ReceivableSettings] - Settings for the receivables module. + default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + A default role to provision upon new entity creation. mail : typing.Optional[MailSettings] - Settings for email and mailboxes. - - commercial_conditions : typing.Optional[typing.Sequence[str]] - Commercial conditions for receivables. + Settings for outgoing email. Used by: - units : typing.Optional[typing.Sequence[Unit]] - Measurement units. - - website : typing.Optional[str] + * accounts receivable emails, for example, emails sent by `POST /recevables/{receivable_id}/send`, + * accounts payable approval notifications. - default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - A default role to provision upon new entity creation. + payable : typing.Optional[PayableSettings] + Settings for accounts payable. payments : typing.Optional[PaymentsSettingsInput] Settings for the payments module. - api_version : typing.Optional[ApiVersion] - Default API version for partner. + receivable : typing.Optional[ReceivableSettings] + Settings for accounts receivable. + + units : typing.Optional[typing.Sequence[Unit]] + Unused. To manage the [measure units](https://docs.monite.com/accounts-receivable/products#manage-measure-units) for your entities, use the `/measure_units` endpoints. + + website : typing.Optional[str] + The URL of the partner's website. Must be an HTTPS URL. Required if the partner's entities use [payment links](https://docs.monite.com/payments/payment-links). The "Powered by" badge in the payment page footer will link to this website. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -159,28 +207,28 @@ def update( "settings", method="PATCH", json={ + "api_version": api_version, + "commercial_conditions": commercial_conditions, "currency": convert_and_respect_annotation_metadata( object_=currency, annotation=CurrencySettingsInput, direction="write" ), + "default_role": default_role, + "mail": convert_and_respect_annotation_metadata( + object_=mail, annotation=MailSettings, direction="write" + ), "payable": convert_and_respect_annotation_metadata( object_=payable, annotation=PayableSettings, direction="write" ), + "payments": convert_and_respect_annotation_metadata( + object_=payments, annotation=PaymentsSettingsInput, direction="write" + ), "receivable": convert_and_respect_annotation_metadata( object_=receivable, annotation=ReceivableSettings, direction="write" ), - "mail": convert_and_respect_annotation_metadata( - object_=mail, annotation=MailSettings, direction="write" - ), - "commercial_conditions": commercial_conditions, "units": convert_and_respect_annotation_metadata( object_=units, annotation=typing.Sequence[Unit], direction="write" ), "website": website, - "default_role": default_role, - "payments": convert_and_respect_annotation_metadata( - object_=payments, annotation=PaymentsSettingsInput, direction="write" - ), - "api_version": api_version, }, headers={ "content-type": "application/json", @@ -209,6 +257,39 @@ def update( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -220,8 +301,8 @@ def update( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -245,7 +326,11 @@ async def get( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[PartnerProjectSettingsPayloadOutput]: """ - Retrieve all settings for this partner. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Get entity settings](https://docs.monite.com/api/entities/get-entities-id-settings) Parameters ---------- @@ -283,6 +368,39 @@ async def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -294,8 +412,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -313,51 +431,59 @@ async def get( async def update( self, *, + api_version: typing.Optional[ApiVersion] = OMIT, + commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, currency: typing.Optional[CurrencySettingsInput] = OMIT, + default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + mail: typing.Optional[MailSettings] = OMIT, payable: typing.Optional[PayableSettings] = OMIT, + payments: typing.Optional[PaymentsSettingsInput] = OMIT, receivable: typing.Optional[ReceivableSettings] = OMIT, - mail: typing.Optional[MailSettings] = OMIT, - commercial_conditions: typing.Optional[typing.Sequence[str]] = OMIT, units: typing.Optional[typing.Sequence[Unit]] = OMIT, website: typing.Optional[str] = OMIT, - default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, - payments: typing.Optional[PaymentsSettingsInput] = OMIT, - api_version: typing.Optional[ApiVersion] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[PartnerProjectSettingsPayloadOutput]: """ - Change the specified fields with the provided values. + Partner-level settings apply to all entities of that partner. + + See also: + + * [Update entity settings](https://docs.monite.com/api/entities/patch-entities-id-settings) Parameters ---------- + api_version : typing.Optional[ApiVersion] + Default API version for partner. + + commercial_conditions : typing.Optional[typing.Sequence[str]] + Unused. To specify commercial conditions for invoices and quotes, use the `commercial_condition_description` field in those documents. + currency : typing.Optional[CurrencySettingsInput] Custom currency exchange rates. - payable : typing.Optional[PayableSettings] - Settings for the payables module. - - receivable : typing.Optional[ReceivableSettings] - Settings for the receivables module. + default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + A default role to provision upon new entity creation. mail : typing.Optional[MailSettings] - Settings for email and mailboxes. - - commercial_conditions : typing.Optional[typing.Sequence[str]] - Commercial conditions for receivables. + Settings for outgoing email. Used by: - units : typing.Optional[typing.Sequence[Unit]] - Measurement units. - - website : typing.Optional[str] + * accounts receivable emails, for example, emails sent by `POST /recevables/{receivable_id}/send`, + * accounts payable approval notifications. - default_role : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - A default role to provision upon new entity creation. + payable : typing.Optional[PayableSettings] + Settings for accounts payable. payments : typing.Optional[PaymentsSettingsInput] Settings for the payments module. - api_version : typing.Optional[ApiVersion] - Default API version for partner. + receivable : typing.Optional[ReceivableSettings] + Settings for accounts receivable. + + units : typing.Optional[typing.Sequence[Unit]] + Unused. To manage the [measure units](https://docs.monite.com/accounts-receivable/products#manage-measure-units) for your entities, use the `/measure_units` endpoints. + + website : typing.Optional[str] + The URL of the partner's website. Must be an HTTPS URL. Required if the partner's entities use [payment links](https://docs.monite.com/payments/payment-links). The "Powered by" badge in the payment page footer will link to this website. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -371,28 +497,28 @@ async def update( "settings", method="PATCH", json={ + "api_version": api_version, + "commercial_conditions": commercial_conditions, "currency": convert_and_respect_annotation_metadata( object_=currency, annotation=CurrencySettingsInput, direction="write" ), + "default_role": default_role, + "mail": convert_and_respect_annotation_metadata( + object_=mail, annotation=MailSettings, direction="write" + ), "payable": convert_and_respect_annotation_metadata( object_=payable, annotation=PayableSettings, direction="write" ), + "payments": convert_and_respect_annotation_metadata( + object_=payments, annotation=PaymentsSettingsInput, direction="write" + ), "receivable": convert_and_respect_annotation_metadata( object_=receivable, annotation=ReceivableSettings, direction="write" ), - "mail": convert_and_respect_annotation_metadata( - object_=mail, annotation=MailSettings, direction="write" - ), - "commercial_conditions": commercial_conditions, "units": convert_and_respect_annotation_metadata( object_=units, annotation=typing.Sequence[Unit], direction="write" ), "website": website, - "default_role": default_role, - "payments": convert_and_respect_annotation_metadata( - object_=payments, annotation=PaymentsSettingsInput, direction="write" - ), - "api_version": api_version, }, headers={ "content-type": "application/json", @@ -421,6 +547,39 @@ async def update( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -432,8 +591,8 @@ async def update( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payables/client.py b/src/monite/payables/client.py index 75e2670..2adb785 100644 --- a/src/monite/payables/client.py +++ b/src/monite/payables/client.py @@ -26,6 +26,7 @@ from ..types.payables_fields_allowed_for_validate import PayablesFieldsAllowedForValidate from ..types.source_of_payable_data_enum import SourceOfPayableDataEnum from ..types.suggested_payment_term import SuggestedPaymentTerm +from ..types.suggested_response import SuggestedResponse from .line_items.client import AsyncLineItemsClient, LineItemsClient from .raw_client import AsyncRawPayablesClient, RawPayablesClient @@ -975,7 +976,7 @@ def get_variables( self, *, request_options: typing.Optional[RequestOptions] = None ) -> PayableTemplatesVariablesObjectList: """ - Get a list of placeholders allowed to insert into an email template for customization + Returns a list of placeholders that can be used to personalize email templates related to payables. These include payables attributes such as `currency`, `customer_name`, `document_id`, `due_date`, `invoice_id`, `total_amount`, and `uploaded_username`. Parameters ---------- @@ -1070,6 +1071,7 @@ def update_by_id( self, payable_id: str, *, + amount_paid: typing.Optional[int] = OMIT, counterpart_address_id: typing.Optional[str] = OMIT, counterpart_bank_account_id: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, @@ -1101,6 +1103,9 @@ def update_by_id( ---------- payable_id : str + amount_paid : typing.Optional[int] + How much was paid on the invoice (in minor units). + counterpart_address_id : typing.Optional[str] The ID of counterpart address object stored in counterparts service @@ -1190,6 +1195,7 @@ def update_by_id( """ _response = self._raw_client.update_by_id( payable_id, + amount_paid=amount_paid, counterpart_address_id=counterpart_address_id, counterpart_bank_account_id=counterpart_bank_account_id, counterpart_id=counterpart_id, @@ -1374,9 +1380,12 @@ def get_payables_id_history( request_options: typing.Optional[RequestOptions] = None, ) -> PayableHistoryPaginationResponse: """ + Returns a chronological list of events related to the specified payable. This includes changes in status, updates to data, comments, and actions taken by users or automation rules. + Parameters ---------- payable_id : str + The unique identifier of the payable whose history you want to retrieve. order : typing.Optional[OrderEnum] Sort order (ascending by default). Typically used together with the `sort` parameter. @@ -1611,11 +1620,12 @@ def reopen_by_id( self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> PayableResponseSchema: """ - Reset payable state from rejected to new. + Moves payables in the `rejected` or `waiting_to_be_paid` statuses back to `new`, allowing further actions such as editing, approval, or payment. The Parameters ---------- payable_id : str + The unique identifier of the payable you want to reopen. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1675,6 +1685,82 @@ def submit_for_approval_by_id( _response = self._raw_client.submit_for_approval_by_id(payable_id, request_options=request_options) return _response.data + def get_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> SuggestedResponse: + """ + Retrieves the most likely matching counterpart for a given payable, based on an AI-powered analysis of the payable's data. + + When a user uploads a payable, Monite automatically compares key fields—such as `name`, `address`, `VAT ID`, and bank `account`—against existing counterparts. If a sufficiently similar match is found, this endpoint will return a suggested counterpart. + + If no suitable match is identified, the response will be empty. + + **Note:** Suggestions are automatically generated during payable upload. This endpoint simply retrieves the existing suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable you want to find matching suggestions for. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SuggestedResponse + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.payables.get_payables_id_suggestions( + payable_id="payable_id", + ) + """ + _response = self._raw_client.get_payables_id_suggestions(payable_id, request_options=request_options) + return _response.data + + def delete_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Deletes the automatically generated counterpart suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable whose suggestions you want to delete. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.payables.delete_payables_id_suggestions( + payable_id="payable_id", + ) + """ + _response = self._raw_client.delete_payables_id_suggestions(payable_id, request_options=request_options) + return _response.data + def validate_by_id( self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> PayableValidationResponse: @@ -2710,7 +2796,7 @@ async def get_variables( self, *, request_options: typing.Optional[RequestOptions] = None ) -> PayableTemplatesVariablesObjectList: """ - Get a list of placeholders allowed to insert into an email template for customization + Returns a list of placeholders that can be used to personalize email templates related to payables. These include payables attributes such as `currency`, `customer_name`, `document_id`, `due_date`, `invoice_id`, `total_amount`, and `uploaded_username`. Parameters ---------- @@ -2829,6 +2915,7 @@ async def update_by_id( self, payable_id: str, *, + amount_paid: typing.Optional[int] = OMIT, counterpart_address_id: typing.Optional[str] = OMIT, counterpart_bank_account_id: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, @@ -2860,6 +2947,9 @@ async def update_by_id( ---------- payable_id : str + amount_paid : typing.Optional[int] + How much was paid on the invoice (in minor units). + counterpart_address_id : typing.Optional[str] The ID of counterpart address object stored in counterparts service @@ -2957,6 +3047,7 @@ async def main() -> None: """ _response = await self._raw_client.update_by_id( payable_id, + amount_paid=amount_paid, counterpart_address_id=counterpart_address_id, counterpart_bank_account_id=counterpart_bank_account_id, counterpart_id=counterpart_id, @@ -3173,9 +3264,12 @@ async def get_payables_id_history( request_options: typing.Optional[RequestOptions] = None, ) -> PayableHistoryPaginationResponse: """ + Returns a chronological list of events related to the specified payable. This includes changes in status, updates to data, comments, and actions taken by users or automation rules. + Parameters ---------- payable_id : str + The unique identifier of the payable whose history you want to retrieve. order : typing.Optional[OrderEnum] Sort order (ascending by default). Typically used together with the `sort` parameter. @@ -3444,11 +3538,12 @@ async def reopen_by_id( self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> PayableResponseSchema: """ - Reset payable state from rejected to new. + Moves payables in the `rejected` or `waiting_to_be_paid` statuses back to `new`, allowing further actions such as editing, approval, or payment. The Parameters ---------- payable_id : str + The unique identifier of the payable you want to reopen. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -3524,6 +3619,98 @@ async def main() -> None: _response = await self._raw_client.submit_for_approval_by_id(payable_id, request_options=request_options) return _response.data + async def get_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> SuggestedResponse: + """ + Retrieves the most likely matching counterpart for a given payable, based on an AI-powered analysis of the payable's data. + + When a user uploads a payable, Monite automatically compares key fields—such as `name`, `address`, `VAT ID`, and bank `account`—against existing counterparts. If a sufficiently similar match is found, this endpoint will return a suggested counterpart. + + If no suitable match is identified, the response will be empty. + + **Note:** Suggestions are automatically generated during payable upload. This endpoint simply retrieves the existing suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable you want to find matching suggestions for. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SuggestedResponse + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.payables.get_payables_id_suggestions( + payable_id="payable_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_payables_id_suggestions(payable_id, request_options=request_options) + return _response.data + + async def delete_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Deletes the automatically generated counterpart suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable whose suggestions you want to delete. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.payables.delete_payables_id_suggestions( + payable_id="payable_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete_payables_id_suggestions(payable_id, request_options=request_options) + return _response.data + async def validate_by_id( self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> PayableValidationResponse: diff --git a/src/monite/payables/line_items/raw_client.py b/src/monite/payables/line_items/raw_client.py index 16f2110..d98f0ec 100644 --- a/src/monite/payables/line_items/raw_client.py +++ b/src/monite/payables/line_items/raw_client.py @@ -13,9 +13,9 @@ from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError from ...errors.forbidden_error import ForbiddenError -from ...errors.internal_server_error import InternalServerError from ...errors.not_acceptable_error import NotAcceptableError from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError from ...errors.unauthorized_error import UnauthorizedError from ...errors.unprocessable_entity_error import UnprocessableEntityError from ...types.line_item_cursor_fields import LineItemCursorFields @@ -159,8 +159,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -335,8 +335,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -484,8 +484,8 @@ def replace( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -609,8 +609,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -671,6 +671,17 @@ def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -715,8 +726,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -890,8 +901,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1037,8 +1048,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1213,8 +1224,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1362,8 +1373,8 @@ async def replace( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1487,8 +1498,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1549,6 +1560,17 @@ async def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1593,8 +1615,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1768,8 +1790,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payables/raw_client.py b/src/monite/payables/raw_client.py index 51aca2e..d6c849e 100644 --- a/src/monite/payables/raw_client.py +++ b/src/monite/payables/raw_client.py @@ -16,9 +16,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.counterpart_raw_data_update_request import CounterpartRawDataUpdateRequest @@ -41,6 +41,7 @@ from ..types.payables_fields_allowed_for_validate import PayablesFieldsAllowedForValidate from ..types.source_of_payable_data_enum import SourceOfPayableDataEnum from ..types.suggested_payment_term import SuggestedPaymentTerm +from ..types.suggested_response import SuggestedResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -449,8 +450,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -675,8 +676,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1017,8 +1018,8 @@ def get_analytics( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1128,8 +1129,8 @@ def upload_from_file( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1219,8 +1220,8 @@ def get_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1322,8 +1323,8 @@ def update_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1413,8 +1414,8 @@ def reset_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1433,7 +1434,7 @@ def get_variables( self, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[PayableTemplatesVariablesObjectList]: """ - Get a list of placeholders allowed to insert into an email template for customization + Returns a list of placeholders that can be used to personalize email templates related to payables. These include payables attributes such as `currency`, `customer_name`, `document_id`, `due_date`, `invoice_id`, `total_amount`, and `uploaded_username`. Parameters ---------- @@ -1460,6 +1461,17 @@ def get_variables( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1482,8 +1494,8 @@ def get_variables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1586,8 +1598,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1682,8 +1694,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1702,6 +1714,7 @@ def update_by_id( self, payable_id: str, *, + amount_paid: typing.Optional[int] = OMIT, counterpart_address_id: typing.Optional[str] = OMIT, counterpart_bank_account_id: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, @@ -1733,6 +1746,9 @@ def update_by_id( ---------- payable_id : str + amount_paid : typing.Optional[int] + How much was paid on the invoice (in minor units). + counterpart_address_id : typing.Optional[str] The ID of counterpart address object stored in counterparts service @@ -1811,6 +1827,7 @@ def update_by_id( f"payables/{jsonable_encoder(payable_id)}", method="PATCH", json={ + "amount_paid": amount_paid, "counterpart_address_id": counterpart_address_id, "counterpart_bank_account_id": counterpart_bank_account_id, "counterpart_id": counterpart_id, @@ -1867,6 +1884,17 @@ def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1911,8 +1939,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2026,8 +2054,8 @@ def approve_payment_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2095,6 +2123,17 @@ def attach_file_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -2139,8 +2178,8 @@ def attach_file_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2254,8 +2293,8 @@ def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2369,8 +2408,8 @@ def post_payables_id_cancel_ocr( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2404,9 +2443,12 @@ def get_payables_id_history( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[PayableHistoryPaginationResponse]: """ + Returns a chronological list of events related to the specified payable. This includes changes in status, updates to data, comments, and actions taken by users or automation rules. + Parameters ---------- payable_id : str + The unique identifier of the payable whose history you want to retrieve. order : typing.Optional[OrderEnum] Sort order (ascending by default). Typically used together with the `sort` parameter. @@ -2531,8 +2573,8 @@ def get_payables_id_history( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2681,8 +2723,8 @@ def mark_as_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2829,8 +2871,8 @@ def mark_as_partially_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2944,8 +2986,8 @@ def reject_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2964,11 +3006,12 @@ def reopen_by_id( self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[PayableResponseSchema]: """ - Reset payable state from rejected to new. + Moves payables in the `rejected` or `waiting_to_be_paid` statuses back to `new`, allowing further actions such as editing, approval, or payment. The Parameters ---------- payable_id : str + The unique identifier of the payable you want to reopen. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -3059,8 +3102,8 @@ def reopen_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3174,8 +3217,204 @@ def submit_for_approval_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SuggestedResponse]: + """ + Retrieves the most likely matching counterpart for a given payable, based on an AI-powered analysis of the payable's data. + + When a user uploads a payable, Monite automatically compares key fields—such as `name`, `address`, `VAT ID`, and bank `account`—against existing counterparts. If a sufficiently similar match is found, this endpoint will return a suggested counterpart. + + If no suitable match is identified, the response will be empty. + + **Note:** Suggestions are automatically generated during payable upload. This endpoint simply retrieves the existing suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable you want to find matching suggestions for. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SuggestedResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"payables/{jsonable_encoder(payable_id)}/suggestions", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SuggestedResponse, + parse_obj_as( + type_=SuggestedResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Deletes the automatically generated counterpart suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable whose suggestions you want to delete. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"payables/{jsonable_encoder(payable_id)}/suggestions", + method="DELETE", + request_options=request_options, + ) + try: + if _response is None or not _response.text.strip(): + return HttpResponse(response=_response, data=None) + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3234,6 +3473,17 @@ def validate_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -3278,8 +3528,8 @@ def validate_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3698,8 +3948,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3924,8 +4174,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4266,8 +4516,8 @@ async def get_analytics( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4377,8 +4627,8 @@ async def upload_from_file( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4468,8 +4718,8 @@ async def get_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4571,8 +4821,8 @@ async def update_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4662,8 +4912,8 @@ async def reset_validations( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4682,7 +4932,7 @@ async def get_variables( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[PayableTemplatesVariablesObjectList]: """ - Get a list of placeholders allowed to insert into an email template for customization + Returns a list of placeholders that can be used to personalize email templates related to payables. These include payables attributes such as `currency`, `customer_name`, `document_id`, `due_date`, `invoice_id`, `total_amount`, and `uploaded_username`. Parameters ---------- @@ -4709,6 +4959,17 @@ async def get_variables( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -4731,8 +4992,8 @@ async def get_variables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4835,8 +5096,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4931,8 +5192,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4951,6 +5212,7 @@ async def update_by_id( self, payable_id: str, *, + amount_paid: typing.Optional[int] = OMIT, counterpart_address_id: typing.Optional[str] = OMIT, counterpart_bank_account_id: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, @@ -4982,6 +5244,9 @@ async def update_by_id( ---------- payable_id : str + amount_paid : typing.Optional[int] + How much was paid on the invoice (in minor units). + counterpart_address_id : typing.Optional[str] The ID of counterpart address object stored in counterparts service @@ -5060,6 +5325,7 @@ async def update_by_id( f"payables/{jsonable_encoder(payable_id)}", method="PATCH", json={ + "amount_paid": amount_paid, "counterpart_address_id": counterpart_address_id, "counterpart_bank_account_id": counterpart_bank_account_id, "counterpart_id": counterpart_id, @@ -5116,6 +5382,17 @@ async def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -5160,8 +5437,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5275,8 +5552,8 @@ async def approve_payment_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5344,6 +5621,17 @@ async def attach_file_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -5388,8 +5676,8 @@ async def attach_file_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5503,8 +5791,8 @@ async def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5618,8 +5906,8 @@ async def post_payables_id_cancel_ocr( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5653,9 +5941,12 @@ async def get_payables_id_history( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[PayableHistoryPaginationResponse]: """ + Returns a chronological list of events related to the specified payable. This includes changes in status, updates to data, comments, and actions taken by users or automation rules. + Parameters ---------- payable_id : str + The unique identifier of the payable whose history you want to retrieve. order : typing.Optional[OrderEnum] Sort order (ascending by default). Typically used together with the `sort` parameter. @@ -5780,8 +6071,8 @@ async def get_payables_id_history( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5930,8 +6221,8 @@ async def mark_as_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6078,8 +6369,8 @@ async def mark_as_partially_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6193,8 +6484,8 @@ async def reject_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6213,11 +6504,12 @@ async def reopen_by_id( self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[PayableResponseSchema]: """ - Reset payable state from rejected to new. + Moves payables in the `rejected` or `waiting_to_be_paid` statuses back to `new`, allowing further actions such as editing, approval, or payment. The Parameters ---------- payable_id : str + The unique identifier of the payable you want to reopen. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -6308,8 +6600,8 @@ async def reopen_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6423,8 +6715,204 @@ async def submit_for_approval_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SuggestedResponse]: + """ + Retrieves the most likely matching counterpart for a given payable, based on an AI-powered analysis of the payable's data. + + When a user uploads a payable, Monite automatically compares key fields—such as `name`, `address`, `VAT ID`, and bank `account`—against existing counterparts. If a sufficiently similar match is found, this endpoint will return a suggested counterpart. + + If no suitable match is identified, the response will be empty. + + **Note:** Suggestions are automatically generated during payable upload. This endpoint simply retrieves the existing suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable you want to find matching suggestions for. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SuggestedResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"payables/{jsonable_encoder(payable_id)}/suggestions", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SuggestedResponse, + parse_obj_as( + type_=SuggestedResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete_payables_id_suggestions( + self, payable_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Deletes the automatically generated counterpart suggestion for a specific payable. + + Parameters + ---------- + payable_id : str + The unique identifier of the payable whose suggestions you want to delete. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"payables/{jsonable_encoder(payable_id)}/suggestions", + method="DELETE", + request_options=request_options, + ) + try: + if _response is None or not _response.text.strip(): + return AsyncHttpResponse(response=_response, data=None) + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6483,6 +6971,17 @@ async def validate_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -6527,8 +7026,8 @@ async def validate_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payment_intents/raw_client.py b/src/monite/payment_intents/raw_client.py index 96b51d3..7c149d3 100644 --- a/src/monite/payment_intents/raw_client.py +++ b/src/monite/payment_intents/raw_client.py @@ -9,7 +9,8 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.order_enum import OrderEnum from ..types.payment_intent_cursor_fields import PaymentIntentCursorFields @@ -90,6 +91,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -101,8 +113,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -148,6 +160,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -159,8 +182,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -215,6 +238,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -226,8 +260,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -273,6 +307,17 @@ def get_history_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -284,8 +329,8 @@ def get_history_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -370,6 +415,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -381,8 +437,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -428,6 +484,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -439,8 +506,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -495,6 +562,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -506,8 +584,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -553,6 +631,17 @@ async def get_history_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -564,8 +653,8 @@ async def get_history_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payment_links/client.py b/src/monite/payment_links/client.py index 057877d..bd259dc 100644 --- a/src/monite/payment_links/client.py +++ b/src/monite/payment_links/client.py @@ -47,28 +47,48 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> PublicPaymentLinkResponse: """ + Create a new [payment link](https://docs.monite.com/payments/payment-links) for an accounts payble invoice (to be paid by the entity) or an accounts receivable invoice (to be sent to the counterpart). + Parameters ---------- payment_methods : typing.Sequence[MoniteAllPaymentMethodsTypes] + Payment methods to be displayed on the payment page. These payment methods must already be enabled for the entity. + + **Note:** Available payment methods vary per country, transaction type (B2B or B2C), and the payment link type (entity pays a bill or entity generates an invoice payment link for its counterpart). For more information, see [Payment methods](https://docs.monite.com/payments/payment-methods). recipient : PaymentAccountObject + Specifies the invoice vendor - entity or counterpart. This is the payee, or the recipient of the payment. amount : typing.Optional[int] - The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). Required if `object` is not specified. + The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). The usage of the `amount` field depends on the type of the payment link you are creating: + + * If the `invoice` object is specified (that is, when creating a payment link for an external invoice), + `amount` is required. + * If `object` is specified: + * If `object.type` is `payable`, `amount` must not be specified since it's taken from the payable. + * If `object.type` is `receivable`, you can provide a custom `amount` value to create a partial payment link. + In this case, the `amount` value must not exceed the invoice's `amount_to_pay` minus all active payment links. currency : typing.Optional[CurrencyEnum] - The payment currency. Required if `object` is not specified. + The payment currency. Mutually exclusive with `object`. expires_at : typing.Optional[dt.datetime] + Date and time (in the ISO 8601 format) when this payment link will expire. Can be up to 70 days from the current date and time. + If omitted: + + * Payment links for payables and receivables expire 30 days after the invoice due date. + * Payment links for external invoices expire 30 days after the link creation time. + + For more information, see [Payment link expiration](https://docs.monite.com/payments/payment-links#expiration). invoice : typing.Optional[Invoice] - An object containing information about the invoice being paid. Used only if `object` is not specified. + An object containing information about an external invoice to be paid. Mutually exclusive with `object`. object : typing.Optional[PaymentObject] If the invoice being paid is a payable or receivable stored in Monite, provide the `object` object containing the invoice type and ID. Otherwise, use the `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to specify the invoice-related data. payment_reference : typing.Optional[str] - A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Required if `object` is not specified. + A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Mutually exclusive with `object`. return_url : typing.Optional[str] The URL where to redirect the payer after the payment. If `return_url` is specified, then after the payment is completed the payment page will display the "Return to platform" link that navigates to this URL. @@ -83,7 +103,7 @@ def create( Examples -------- - from monite import Monite, PaymentAccountObject + from monite import Monite, PaymentAccountObject, PaymentObject client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -91,11 +111,16 @@ def create( token="YOUR_TOKEN", ) client.payment_links.create( + object=PaymentObject( + id="5940eb3a-de95-4e7e-b5e7-8a4ad0ea341b", + type="payable", + ), payment_methods=["sepa_credit"], recipient=PaymentAccountObject( - id="id", - type="entity", + id="6296af34-6feb-43c1-b567-83e3bf45050c", + type="counterpart", ), + return_url="https://example.com/where-to-redirect-after-payment", ) """ _response = self._raw_client.create( @@ -207,28 +232,48 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> PublicPaymentLinkResponse: """ + Create a new [payment link](https://docs.monite.com/payments/payment-links) for an accounts payble invoice (to be paid by the entity) or an accounts receivable invoice (to be sent to the counterpart). + Parameters ---------- payment_methods : typing.Sequence[MoniteAllPaymentMethodsTypes] + Payment methods to be displayed on the payment page. These payment methods must already be enabled for the entity. + + **Note:** Available payment methods vary per country, transaction type (B2B or B2C), and the payment link type (entity pays a bill or entity generates an invoice payment link for its counterpart). For more information, see [Payment methods](https://docs.monite.com/payments/payment-methods). recipient : PaymentAccountObject + Specifies the invoice vendor - entity or counterpart. This is the payee, or the recipient of the payment. amount : typing.Optional[int] - The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). Required if `object` is not specified. + The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). The usage of the `amount` field depends on the type of the payment link you are creating: + + * If the `invoice` object is specified (that is, when creating a payment link for an external invoice), + `amount` is required. + * If `object` is specified: + * If `object.type` is `payable`, `amount` must not be specified since it's taken from the payable. + * If `object.type` is `receivable`, you can provide a custom `amount` value to create a partial payment link. + In this case, the `amount` value must not exceed the invoice's `amount_to_pay` minus all active payment links. currency : typing.Optional[CurrencyEnum] - The payment currency. Required if `object` is not specified. + The payment currency. Mutually exclusive with `object`. expires_at : typing.Optional[dt.datetime] + Date and time (in the ISO 8601 format) when this payment link will expire. Can be up to 70 days from the current date and time. + If omitted: + + * Payment links for payables and receivables expire 30 days after the invoice due date. + * Payment links for external invoices expire 30 days after the link creation time. + + For more information, see [Payment link expiration](https://docs.monite.com/payments/payment-links#expiration). invoice : typing.Optional[Invoice] - An object containing information about the invoice being paid. Used only if `object` is not specified. + An object containing information about an external invoice to be paid. Mutually exclusive with `object`. object : typing.Optional[PaymentObject] If the invoice being paid is a payable or receivable stored in Monite, provide the `object` object containing the invoice type and ID. Otherwise, use the `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to specify the invoice-related data. payment_reference : typing.Optional[str] - A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Required if `object` is not specified. + A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Mutually exclusive with `object`. return_url : typing.Optional[str] The URL where to redirect the payer after the payment. If `return_url` is specified, then after the payment is completed the payment page will display the "Return to platform" link that navigates to this URL. @@ -245,7 +290,7 @@ async def create( -------- import asyncio - from monite import AsyncMonite, PaymentAccountObject + from monite import AsyncMonite, PaymentAccountObject, PaymentObject client = AsyncMonite( monite_version="YOUR_MONITE_VERSION", @@ -256,11 +301,16 @@ async def create( async def main() -> None: await client.payment_links.create( + object=PaymentObject( + id="5940eb3a-de95-4e7e-b5e7-8a4ad0ea341b", + type="payable", + ), payment_methods=["sepa_credit"], recipient=PaymentAccountObject( - id="id", - type="entity", + id="6296af34-6feb-43c1-b567-83e3bf45050c", + type="counterpart", ), + return_url="https://example.com/where-to-redirect-after-payment", ) diff --git a/src/monite/payment_links/raw_client.py b/src/monite/payment_links/raw_client.py index fdf9422..b395720 100644 --- a/src/monite/payment_links/raw_client.py +++ b/src/monite/payment_links/raw_client.py @@ -11,7 +11,8 @@ from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.currency_enum import CurrencyEnum from ..types.invoice import Invoice @@ -43,28 +44,48 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[PublicPaymentLinkResponse]: """ + Create a new [payment link](https://docs.monite.com/payments/payment-links) for an accounts payble invoice (to be paid by the entity) or an accounts receivable invoice (to be sent to the counterpart). + Parameters ---------- payment_methods : typing.Sequence[MoniteAllPaymentMethodsTypes] + Payment methods to be displayed on the payment page. These payment methods must already be enabled for the entity. + + **Note:** Available payment methods vary per country, transaction type (B2B or B2C), and the payment link type (entity pays a bill or entity generates an invoice payment link for its counterpart). For more information, see [Payment methods](https://docs.monite.com/payments/payment-methods). recipient : PaymentAccountObject + Specifies the invoice vendor - entity or counterpart. This is the payee, or the recipient of the payment. amount : typing.Optional[int] - The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). Required if `object` is not specified. + The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). The usage of the `amount` field depends on the type of the payment link you are creating: + + * If the `invoice` object is specified (that is, when creating a payment link for an external invoice), + `amount` is required. + * If `object` is specified: + * If `object.type` is `payable`, `amount` must not be specified since it's taken from the payable. + * If `object.type` is `receivable`, you can provide a custom `amount` value to create a partial payment link. + In this case, the `amount` value must not exceed the invoice's `amount_to_pay` minus all active payment links. currency : typing.Optional[CurrencyEnum] - The payment currency. Required if `object` is not specified. + The payment currency. Mutually exclusive with `object`. expires_at : typing.Optional[dt.datetime] + Date and time (in the ISO 8601 format) when this payment link will expire. Can be up to 70 days from the current date and time. + If omitted: + + * Payment links for payables and receivables expire 30 days after the invoice due date. + * Payment links for external invoices expire 30 days after the link creation time. + + For more information, see [Payment link expiration](https://docs.monite.com/payments/payment-links#expiration). invoice : typing.Optional[Invoice] - An object containing information about the invoice being paid. Used only if `object` is not specified. + An object containing information about an external invoice to be paid. Mutually exclusive with `object`. object : typing.Optional[PaymentObject] If the invoice being paid is a payable or receivable stored in Monite, provide the `object` object containing the invoice type and ID. Otherwise, use the `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to specify the invoice-related data. payment_reference : typing.Optional[str] - A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Required if `object` is not specified. + A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Mutually exclusive with `object`. return_url : typing.Optional[str] The URL where to redirect the payer after the payment. If `return_url` is specified, then after the payment is completed the payment page will display the "Return to platform" link that navigates to this URL. @@ -113,6 +134,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -124,8 +156,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -171,6 +203,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -182,8 +225,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -229,6 +272,17 @@ def expire_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -240,8 +294,8 @@ def expire_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -276,28 +330,48 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[PublicPaymentLinkResponse]: """ + Create a new [payment link](https://docs.monite.com/payments/payment-links) for an accounts payble invoice (to be paid by the entity) or an accounts receivable invoice (to be sent to the counterpart). + Parameters ---------- payment_methods : typing.Sequence[MoniteAllPaymentMethodsTypes] + Payment methods to be displayed on the payment page. These payment methods must already be enabled for the entity. + + **Note:** Available payment methods vary per country, transaction type (B2B or B2C), and the payment link type (entity pays a bill or entity generates an invoice payment link for its counterpart). For more information, see [Payment methods](https://docs.monite.com/payments/payment-methods). recipient : PaymentAccountObject + Specifies the invoice vendor - entity or counterpart. This is the payee, or the recipient of the payment. amount : typing.Optional[int] - The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). Required if `object` is not specified. + The payment amount in [minor units](https://docs.monite.com/references/currencies#minor-units). The usage of the `amount` field depends on the type of the payment link you are creating: + + * If the `invoice` object is specified (that is, when creating a payment link for an external invoice), + `amount` is required. + * If `object` is specified: + * If `object.type` is `payable`, `amount` must not be specified since it's taken from the payable. + * If `object.type` is `receivable`, you can provide a custom `amount` value to create a partial payment link. + In this case, the `amount` value must not exceed the invoice's `amount_to_pay` minus all active payment links. currency : typing.Optional[CurrencyEnum] - The payment currency. Required if `object` is not specified. + The payment currency. Mutually exclusive with `object`. expires_at : typing.Optional[dt.datetime] + Date and time (in the ISO 8601 format) when this payment link will expire. Can be up to 70 days from the current date and time. + If omitted: + + * Payment links for payables and receivables expire 30 days after the invoice due date. + * Payment links for external invoices expire 30 days after the link creation time. + + For more information, see [Payment link expiration](https://docs.monite.com/payments/payment-links#expiration). invoice : typing.Optional[Invoice] - An object containing information about the invoice being paid. Used only if `object` is not specified. + An object containing information about an external invoice to be paid. Mutually exclusive with `object`. object : typing.Optional[PaymentObject] If the invoice being paid is a payable or receivable stored in Monite, provide the `object` object containing the invoice type and ID. Otherwise, use the `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to specify the invoice-related data. payment_reference : typing.Optional[str] - A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Required if `object` is not specified. + A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Mutually exclusive with `object`. return_url : typing.Optional[str] The URL where to redirect the payer after the payment. If `return_url` is specified, then after the payment is completed the payment page will display the "Return to platform" link that navigates to this URL. @@ -346,6 +420,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -357,8 +442,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -404,6 +489,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -415,8 +511,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -462,6 +558,17 @@ async def expire_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -473,8 +580,8 @@ async def expire_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payment_records/client.py b/src/monite/payment_records/client.py index e65e644..04b3934 100644 --- a/src/monite/payment_records/client.py +++ b/src/monite/payment_records/client.py @@ -66,7 +66,7 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -75,7 +75,7 @@ def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[PaymentRecordCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. is_external : typing.Optional[bool] Identifies whether payment is from our rails or external system @@ -183,9 +183,9 @@ def create( amount: int, currency: CurrencyEnum, object: PaymentRecordObjectRequest, - payment_intent_id: str, entity_user_id: typing.Optional[str] = OMIT, paid_at: typing.Optional[dt.datetime] = OMIT, + payment_intent_id: typing.Optional[str] = OMIT, payment_intent_status: typing.Optional[str] = OMIT, payment_method: typing.Optional[str] = OMIT, planned_payment_date: typing.Optional[str] = OMIT, @@ -204,15 +204,15 @@ def create( object : PaymentRecordObjectRequest Reference object linked to this payment record, indicating the type (receivable or payable) and its identifier. - payment_intent_id : str - Identifier for an payment intent. - entity_user_id : typing.Optional[str] ID of the user associated with the payment, if applicable. paid_at : typing.Optional[dt.datetime] Timestamp marking when the payment was executed. Null if payment hasn't occurred yet. + payment_intent_id : typing.Optional[str] + Identifier for an payment intent. + payment_intent_status : typing.Optional[str] Raw status string of the external payment intent. @@ -249,16 +249,15 @@ def create( id="id", type="receivable", ), - payment_intent_id="payment_intent_id", ) """ _response = self._raw_client.create( amount=amount, currency=currency, object=object, - payment_intent_id=payment_intent_id, entity_user_id=entity_user_id, paid_at=paid_at, + payment_intent_id=payment_intent_id, payment_intent_status=payment_intent_status, payment_method=payment_method, planned_payment_date=planned_payment_date, @@ -564,7 +563,7 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -573,7 +572,7 @@ async def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[PaymentRecordCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. is_external : typing.Optional[bool] Identifies whether payment is from our rails or external system @@ -689,9 +688,9 @@ async def create( amount: int, currency: CurrencyEnum, object: PaymentRecordObjectRequest, - payment_intent_id: str, entity_user_id: typing.Optional[str] = OMIT, paid_at: typing.Optional[dt.datetime] = OMIT, + payment_intent_id: typing.Optional[str] = OMIT, payment_intent_status: typing.Optional[str] = OMIT, payment_method: typing.Optional[str] = OMIT, planned_payment_date: typing.Optional[str] = OMIT, @@ -710,15 +709,15 @@ async def create( object : PaymentRecordObjectRequest Reference object linked to this payment record, indicating the type (receivable or payable) and its identifier. - payment_intent_id : str - Identifier for an payment intent. - entity_user_id : typing.Optional[str] ID of the user associated with the payment, if applicable. paid_at : typing.Optional[dt.datetime] Timestamp marking when the payment was executed. Null if payment hasn't occurred yet. + payment_intent_id : typing.Optional[str] + Identifier for an payment intent. + payment_intent_status : typing.Optional[str] Raw status string of the external payment intent. @@ -760,7 +759,6 @@ async def main() -> None: id="id", type="receivable", ), - payment_intent_id="payment_intent_id", ) @@ -770,9 +768,9 @@ async def main() -> None: amount=amount, currency=currency, object=object, - payment_intent_id=payment_intent_id, entity_user_id=entity_user_id, paid_at=paid_at, + payment_intent_id=payment_intent_id, payment_intent_status=payment_intent_status, payment_method=payment_method, planned_payment_date=planned_payment_date, diff --git a/src/monite/payment_records/raw_client.py b/src/monite/payment_records/raw_client.py index 7995509..4de48a4 100644 --- a/src/monite/payment_records/raw_client.py +++ b/src/monite/payment_records/raw_client.py @@ -12,7 +12,8 @@ from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.currency_enum import CurrencyEnum from ..types.object_type_enum import ObjectTypeEnum @@ -63,7 +64,7 @@ def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -72,7 +73,7 @@ def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[PaymentRecordCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. is_external : typing.Optional[bool] Identifies whether payment is from our rails or external system @@ -175,6 +176,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -186,8 +198,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -208,9 +220,9 @@ def create( amount: int, currency: CurrencyEnum, object: PaymentRecordObjectRequest, - payment_intent_id: str, entity_user_id: typing.Optional[str] = OMIT, paid_at: typing.Optional[dt.datetime] = OMIT, + payment_intent_id: typing.Optional[str] = OMIT, payment_intent_status: typing.Optional[str] = OMIT, payment_method: typing.Optional[str] = OMIT, planned_payment_date: typing.Optional[str] = OMIT, @@ -229,15 +241,15 @@ def create( object : PaymentRecordObjectRequest Reference object linked to this payment record, indicating the type (receivable or payable) and its identifier. - payment_intent_id : str - Identifier for an payment intent. - entity_user_id : typing.Optional[str] ID of the user associated with the payment, if applicable. paid_at : typing.Optional[dt.datetime] Timestamp marking when the payment was executed. Null if payment hasn't occurred yet. + payment_intent_id : typing.Optional[str] + Identifier for an payment intent. + payment_intent_status : typing.Optional[str] Raw status string of the external payment intent. @@ -291,6 +303,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -302,8 +325,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -349,6 +372,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -360,8 +394,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -463,6 +497,17 @@ def patch_payment_records_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -474,8 +519,8 @@ def patch_payment_records_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -535,6 +580,17 @@ def post_payment_records_id_cancel( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -546,8 +602,8 @@ def post_payment_records_id_cancel( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -612,6 +668,17 @@ def post_payment_records_id_mark_as_succeeded( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -623,8 +690,8 @@ def post_payment_records_id_mark_as_succeeded( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -684,6 +751,17 @@ def post_payment_records_id_start_processing( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -695,8 +773,8 @@ def post_payment_records_id_start_processing( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -747,7 +825,7 @@ async def get( Parameters ---------- order : typing.Optional[OrderEnum] - Order by + Sort order (ascending by default). Typically used together with the `sort` parameter. limit : typing.Optional[int] Max is 100 @@ -756,7 +834,7 @@ async def get( A token, obtained from previous page. Prior over other filters sort : typing.Optional[PaymentRecordCursorFields] - Allowed sort fields + The field to sort the results by. Typically used together with the `order` parameter. is_external : typing.Optional[bool] Identifies whether payment is from our rails or external system @@ -859,6 +937,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -870,8 +959,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -892,9 +981,9 @@ async def create( amount: int, currency: CurrencyEnum, object: PaymentRecordObjectRequest, - payment_intent_id: str, entity_user_id: typing.Optional[str] = OMIT, paid_at: typing.Optional[dt.datetime] = OMIT, + payment_intent_id: typing.Optional[str] = OMIT, payment_intent_status: typing.Optional[str] = OMIT, payment_method: typing.Optional[str] = OMIT, planned_payment_date: typing.Optional[str] = OMIT, @@ -913,15 +1002,15 @@ async def create( object : PaymentRecordObjectRequest Reference object linked to this payment record, indicating the type (receivable or payable) and its identifier. - payment_intent_id : str - Identifier for an payment intent. - entity_user_id : typing.Optional[str] ID of the user associated with the payment, if applicable. paid_at : typing.Optional[dt.datetime] Timestamp marking when the payment was executed. Null if payment hasn't occurred yet. + payment_intent_id : typing.Optional[str] + Identifier for an payment intent. + payment_intent_status : typing.Optional[str] Raw status string of the external payment intent. @@ -975,6 +1064,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -986,8 +1086,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1033,6 +1133,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1044,8 +1155,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1147,6 +1258,17 @@ async def patch_payment_records_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1158,8 +1280,8 @@ async def patch_payment_records_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1219,6 +1341,17 @@ async def post_payment_records_id_cancel( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1230,8 +1363,8 @@ async def post_payment_records_id_cancel( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1296,6 +1429,17 @@ async def post_payment_records_id_mark_as_succeeded( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1307,8 +1451,8 @@ async def post_payment_records_id_mark_as_succeeded( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1368,6 +1512,17 @@ async def post_payment_records_id_start_processing( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1379,8 +1534,8 @@ async def post_payment_records_id_start_processing( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payment_reminders/raw_client.py b/src/monite/payment_reminders/raw_client.py index b3b05fa..24c7471 100644 --- a/src/monite/payment_reminders/raw_client.py +++ b/src/monite/payment_reminders/raw_client.py @@ -12,8 +12,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.get_all_payment_reminders import GetAllPaymentReminders @@ -89,8 +89,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -217,8 +217,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -308,8 +308,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -402,8 +402,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -544,8 +544,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -627,8 +627,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -755,8 +755,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -846,8 +846,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -940,8 +940,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1082,8 +1082,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/payment_terms/client.py b/src/monite/payment_terms/client.py index a0fcfe7..b1cae01 100644 --- a/src/monite/payment_terms/client.py +++ b/src/monite/payment_terms/client.py @@ -99,9 +99,10 @@ def create( token="YOUR_TOKEN", ) client.payment_terms.create( - name="name", + description="Payment is due within 30 days after the invoice issue date", + name="Net 30", term_final=TermFinalDays( - number_of_days=1, + number_of_days=30, ), ) """ @@ -336,9 +337,10 @@ async def create( async def main() -> None: await client.payment_terms.create( - name="name", + description="Payment is due within 30 days after the invoice issue date", + name="Net 30", term_final=TermFinalDays( - number_of_days=1, + number_of_days=30, ), ) diff --git a/src/monite/payment_terms/raw_client.py b/src/monite/payment_terms/raw_client.py index 3085cab..c9e59b8 100644 --- a/src/monite/payment_terms/raw_client.py +++ b/src/monite/payment_terms/raw_client.py @@ -12,8 +12,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.payment_terms_list_response import PaymentTermsListResponse @@ -89,8 +89,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -215,8 +215,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -306,8 +306,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -400,8 +400,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -540,8 +540,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -623,8 +623,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -749,8 +749,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -840,8 +840,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -934,8 +934,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1074,8 +1074,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/pdf_templates/raw_client.py b/src/monite/pdf_templates/raw_client.py index 000858c..43f1d40 100644 --- a/src/monite/pdf_templates/raw_client.py +++ b/src/monite/pdf_templates/raw_client.py @@ -10,7 +10,8 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.template_list_response import TemplateListResponse from ..types.template_receivable_response import TemplateReceivableResponse @@ -49,6 +50,17 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -60,8 +72,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -107,6 +119,17 @@ def get_system( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -118,8 +141,8 @@ def get_system( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -165,6 +188,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -176,8 +210,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -223,6 +257,17 @@ def make_default_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -234,8 +279,8 @@ def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -283,6 +328,17 @@ def _stream() -> HttpResponse[typing.Iterator[bytes]]: response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) ) _response.read() + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -294,8 +350,8 @@ def _stream() -> HttpResponse[typing.Iterator[bytes]]: ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -350,6 +406,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -361,8 +428,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -408,6 +475,17 @@ async def get_system( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -419,8 +497,8 @@ async def get_system( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -466,6 +544,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -477,8 +566,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -524,6 +613,17 @@ async def make_default_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -535,8 +635,8 @@ async def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -585,6 +685,17 @@ async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), ) await _response.aread() + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -596,8 +707,8 @@ async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/products/raw_client.py b/src/monite/products/raw_client.py index 7b594f5..5cc8801 100644 --- a/src/monite/products/raw_client.py +++ b/src/monite/products/raw_client.py @@ -14,8 +14,8 @@ from ..core.serialization import convert_and_respect_annotation_metadata from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.currency_enum import CurrencyEnum @@ -201,8 +201,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -336,8 +336,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -438,8 +438,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -532,8 +532,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -681,8 +681,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -869,8 +869,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1004,8 +1004,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1106,8 +1106,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1200,8 +1200,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1349,8 +1349,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/projects/client.py b/src/monite/projects/client.py index 7fd7bd8..da11b99 100644 --- a/src/monite/projects/client.py +++ b/src/monite/projects/client.py @@ -189,25 +189,25 @@ def create( The project name. code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -333,28 +333,28 @@ def update_by_id( project_id : str code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. name : typing.Optional[str] The project name. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -578,25 +578,25 @@ async def create( The project name. code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -748,28 +748,28 @@ async def update_by_id( project_id : str code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. name : typing.Optional[str] The project name. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. diff --git a/src/monite/projects/raw_client.py b/src/monite/projects/raw_client.py index 2c8355a..3f95bc7 100644 --- a/src/monite/projects/raw_client.py +++ b/src/monite/projects/raw_client.py @@ -13,9 +13,9 @@ from ..core.request_options import RequestOptions from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.order_enum import OrderEnum @@ -234,8 +234,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -273,25 +273,25 @@ def create( The project name. code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -378,8 +378,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -482,8 +482,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -578,8 +578,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -617,28 +617,28 @@ def update_by_id( project_id : str code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. name : typing.Optional[str] The project name. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -736,8 +736,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -960,8 +960,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -999,25 +999,25 @@ async def create( The project name. code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -1104,8 +1104,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1208,8 +1208,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1304,8 +1304,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1343,28 +1343,28 @@ async def update_by_id( project_id : str code : typing.Optional[str] - Project code + A user-defined identifier of this project. color : typing.Optional[str] - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. description : typing.Optional[str] - Description of project + A user-defined description of the project. end_date : typing.Optional[str] - Project end date + Project end date. If specified, must be later than or equal to the start date. name : typing.Optional[str] The project name. parent_id : typing.Optional[str] - Parent project ID + Unused. Reserved for future use. partner_metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. start_date : typing.Optional[str] - Project start date + Project start date. tag_ids : typing.Optional[typing.Sequence[str]] A list of IDs of user-defined tags (labels) assigned to this project. @@ -1462,8 +1462,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/purchase_orders/raw_client.py b/src/monite/purchase_orders/raw_client.py index 658968c..b0ccec9 100644 --- a/src/monite/purchase_orders/raw_client.py +++ b/src/monite/purchase_orders/raw_client.py @@ -15,8 +15,8 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.currency_enum import CurrencyEnum @@ -192,6 +192,17 @@ def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -214,8 +225,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -320,6 +331,17 @@ def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -342,8 +364,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -389,6 +411,17 @@ def get_variables( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -411,8 +444,8 @@ def get_variables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -469,6 +502,17 @@ def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -491,8 +535,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -541,6 +585,17 @@ def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -563,8 +618,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -667,6 +722,17 @@ def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -689,8 +755,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -808,8 +874,8 @@ def preview_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -938,8 +1004,8 @@ def send_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1113,6 +1179,17 @@ async def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1135,8 +1212,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1241,6 +1318,17 @@ async def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1263,8 +1351,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1310,6 +1398,17 @@ async def get_variables( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1332,8 +1431,8 @@ async def get_variables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1390,6 +1489,17 @@ async def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1412,8 +1522,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1462,6 +1572,17 @@ async def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1484,8 +1605,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1588,6 +1709,17 @@ async def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1610,8 +1742,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1729,8 +1861,8 @@ async def preview_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1859,8 +1991,8 @@ async def send_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/receipts/__init__.py b/src/monite/receipts/__init__.py new file mode 100644 index 0000000..5cde020 --- /dev/null +++ b/src/monite/receipts/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/monite/receipts/client.py b/src/monite/receipts/client.py new file mode 100644 index 0000000..b01d85f --- /dev/null +++ b/src/monite/receipts/client.py @@ -0,0 +1,1494 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from .. import core +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from ..types.currency_enum import CurrencyEnum +from ..types.order_enum import OrderEnum +from ..types.receipt_cursor_fields import ReceiptCursorFields +from ..types.receipt_line_item_cursor_fields import ReceiptLineItemCursorFields +from ..types.receipt_line_item_response_schema import ReceiptLineItemResponseSchema +from ..types.receipt_line_items_pagination_response import ReceiptLineItemsPaginationResponse +from ..types.receipt_pagination_response import ReceiptPaginationResponse +from ..types.receipt_response_schema import ReceiptResponseSchema +from .raw_client import AsyncRawReceiptsClient, RawReceiptsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ReceiptsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawReceiptsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawReceiptsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawReceiptsClient + """ + return self._raw_client + + def get_receipts( + self, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + currency: typing.Optional[CurrencyEnum] = None, + document_id: typing.Optional[str] = None, + document_id_contains: typing.Optional[str] = None, + document_id_icontains: typing.Optional[str] = None, + total_amount_gt: typing.Optional[int] = None, + total_amount_lt: typing.Optional[int] = None, + total_amount_gte: typing.Optional[int] = None, + total_amount_lte: typing.Optional[int] = None, + has_file: typing.Optional[bool] = None, + has_transaction: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptPaginationResponse: + """ + Parameters + ---------- + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + currency : typing.Optional[CurrencyEnum] + + document_id : typing.Optional[str] + + document_id_contains : typing.Optional[str] + + document_id_icontains : typing.Optional[str] + + total_amount_gt : typing.Optional[int] + + total_amount_lt : typing.Optional[int] + + total_amount_gte : typing.Optional[int] + + total_amount_lte : typing.Optional[int] + + has_file : typing.Optional[bool] + + has_transaction : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptPaginationResponse + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.get_receipts() + """ + _response = self._raw_client.get_receipts( + order=order, + limit=limit, + pagination_token=pagination_token, + sort=sort, + created_at_gt=created_at_gt, + created_at_lt=created_at_lt, + created_at_gte=created_at_gte, + created_at_lte=created_at_lte, + id_in=id_in, + currency=currency, + document_id=document_id, + document_id_contains=document_id_contains, + document_id_icontains=document_id_icontains, + total_amount_gt=total_amount_gt, + total_amount_lt=total_amount_lt, + total_amount_gte=total_amount_gte, + total_amount_lte=total_amount_lte, + has_file=has_file, + has_transaction=has_transaction, + request_options=request_options, + ) + return _response.data + + def post_receipts( + self, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptResponseSchema: + """ + Parameters + ---------- + base64encoded_file : typing.Optional[str] + Base64-encoded contents of the original receipt file. + + currency : typing.Optional[CurrencyEnum] + Currency code used in the receipt. + + document_id : typing.Optional[str] + Unique receipt number assigned by the issuer. + + issued_at : typing.Optional[dt.datetime] + Receipt issued date and time. + + merchant_location : typing.Optional[str] + Location of the merchant. + + merchant_name : typing.Optional[str] + Name of the merchant. + + total_amount : typing.Optional[int] + Total amount for the receipt in minor units (e.g. cents). + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.post_receipts() + """ + _response = self._raw_client.post_receipts( + base64encoded_file=base64encoded_file, + currency=currency, + document_id=document_id, + issued_at=issued_at, + merchant_location=merchant_location, + merchant_name=merchant_name, + total_amount=total_amount, + transaction_id=transaction_id, + request_options=request_options, + ) + return _response.data + + def post_receipts_upload_from_file( + self, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> ReceiptResponseSchema: + """ + Upload an incoming receipt in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.post_receipts_upload_from_file() + """ + _response = self._raw_client.post_receipts_upload_from_file(file=file, request_options=request_options) + return _response.data + + def get_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ReceiptResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.get_receipts_id( + receipt_id="receipt_id", + ) + """ + _response = self._raw_client.get_receipts_id(receipt_id, request_options=request_options) + return _response.data + + def delete_receipts_id(self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.delete_receipts_id( + receipt_id="receipt_id", + ) + """ + _response = self._raw_client.delete_receipts_id(receipt_id, request_options=request_options) + return _response.data + + def patch_receipts_id( + self, + receipt_id: str, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + base64encoded_file : typing.Optional[str] + Base64-encoded file contents. + + currency : typing.Optional[CurrencyEnum] + Currency code. + + document_id : typing.Optional[str] + Receipt number. + + issued_at : typing.Optional[dt.datetime] + Date when the receipt was issued. + + merchant_location : typing.Optional[str] + Merchant location. + + merchant_name : typing.Optional[str] + Merchant name. + + total_amount : typing.Optional[int] + Total amount. + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.patch_receipts_id( + receipt_id="receipt_id", + ) + """ + _response = self._raw_client.patch_receipts_id( + receipt_id, + base64encoded_file=base64encoded_file, + currency=currency, + document_id=document_id, + issued_at=issued_at, + merchant_location=merchant_location, + merchant_name=merchant_name, + total_amount=total_amount, + transaction_id=transaction_id, + request_options=request_options, + ) + return _response.data + + def post_receipts_id_attach_file( + self, receipt_id: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> ReceiptResponseSchema: + """ + Attach file to receipt without existing attachment. + + Parameters + ---------- + receipt_id : str + + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.post_receipts_id_attach_file( + receipt_id="receipt_id", + ) + """ + _response = self._raw_client.post_receipts_id_attach_file( + receipt_id, file=file, request_options=request_options + ) + return _response.data + + def get_receipts_id_line_items( + self, + receipt_id: str, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptLineItemCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + name: typing.Optional[str] = None, + name_iexact: typing.Optional[str] = None, + name_contains: typing.Optional[str] = None, + name_icontains: typing.Optional[str] = None, + total_gt: typing.Optional[int] = None, + total_lt: typing.Optional[int] = None, + total_gte: typing.Optional[int] = None, + total_lte: typing.Optional[int] = None, + created_by_user_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptLineItemsPaginationResponse: + """ + Parameters + ---------- + receipt_id : str + + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptLineItemCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + name : typing.Optional[str] + + name_iexact : typing.Optional[str] + + name_contains : typing.Optional[str] + + name_icontains : typing.Optional[str] + + total_gt : typing.Optional[int] + + total_lt : typing.Optional[int] + + total_gte : typing.Optional[int] + + total_lte : typing.Optional[int] + + created_by_user_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptLineItemsPaginationResponse + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.get_receipts_id_line_items( + receipt_id="receipt_id", + ) + """ + _response = self._raw_client.get_receipts_id_line_items( + receipt_id, + order=order, + limit=limit, + pagination_token=pagination_token, + sort=sort, + created_at_gt=created_at_gt, + created_at_lt=created_at_lt, + created_at_gte=created_at_gte, + created_at_lte=created_at_lte, + name=name, + name_iexact=name_iexact, + name_contains=name_contains, + name_icontains=name_icontains, + total_gt=total_gt, + total_lt=total_lt, + total_gte=total_gte, + total_lte=total_lte, + created_by_user_id=created_by_user_id, + request_options=request_options, + ) + return _response.data + + def post_receipts_id_line_items( + self, + receipt_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptLineItemResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptLineItemResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.post_receipts_id_line_items( + receipt_id="receipt_id", + ) + """ + _response = self._raw_client.post_receipts_id_line_items( + receipt_id, + accounting_tax_rate_id=accounting_tax_rate_id, + cost_center_id=cost_center_id, + general_ledger_id=general_ledger_id, + name=name, + total=total, + request_options=request_options, + ) + return _response.data + + def delete_receipts_id_line_items_id( + self, receipt_id: str, line_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.delete_receipts_id_line_items_id( + receipt_id="receipt_id", + line_item_id="line_item_id", + ) + """ + _response = self._raw_client.delete_receipts_id_line_items_id( + receipt_id, line_item_id, request_options=request_options + ) + return _response.data + + def patch_receipts_id_line_items_id( + self, + receipt_id: str, + line_item_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptLineItemResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptLineItemResponseSchema + Successful Response + + Examples + -------- + from monite import Monite + + client = Monite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + client.receipts.patch_receipts_id_line_items_id( + receipt_id="receipt_id", + line_item_id="line_item_id", + ) + """ + _response = self._raw_client.patch_receipts_id_line_items_id( + receipt_id, + line_item_id, + accounting_tax_rate_id=accounting_tax_rate_id, + cost_center_id=cost_center_id, + general_ledger_id=general_ledger_id, + name=name, + total=total, + request_options=request_options, + ) + return _response.data + + +class AsyncReceiptsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawReceiptsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawReceiptsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawReceiptsClient + """ + return self._raw_client + + async def get_receipts( + self, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + currency: typing.Optional[CurrencyEnum] = None, + document_id: typing.Optional[str] = None, + document_id_contains: typing.Optional[str] = None, + document_id_icontains: typing.Optional[str] = None, + total_amount_gt: typing.Optional[int] = None, + total_amount_lt: typing.Optional[int] = None, + total_amount_gte: typing.Optional[int] = None, + total_amount_lte: typing.Optional[int] = None, + has_file: typing.Optional[bool] = None, + has_transaction: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptPaginationResponse: + """ + Parameters + ---------- + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + currency : typing.Optional[CurrencyEnum] + + document_id : typing.Optional[str] + + document_id_contains : typing.Optional[str] + + document_id_icontains : typing.Optional[str] + + total_amount_gt : typing.Optional[int] + + total_amount_lt : typing.Optional[int] + + total_amount_gte : typing.Optional[int] + + total_amount_lte : typing.Optional[int] + + has_file : typing.Optional[bool] + + has_transaction : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptPaginationResponse + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.get_receipts() + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_receipts( + order=order, + limit=limit, + pagination_token=pagination_token, + sort=sort, + created_at_gt=created_at_gt, + created_at_lt=created_at_lt, + created_at_gte=created_at_gte, + created_at_lte=created_at_lte, + id_in=id_in, + currency=currency, + document_id=document_id, + document_id_contains=document_id_contains, + document_id_icontains=document_id_icontains, + total_amount_gt=total_amount_gt, + total_amount_lt=total_amount_lt, + total_amount_gte=total_amount_gte, + total_amount_lte=total_amount_lte, + has_file=has_file, + has_transaction=has_transaction, + request_options=request_options, + ) + return _response.data + + async def post_receipts( + self, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptResponseSchema: + """ + Parameters + ---------- + base64encoded_file : typing.Optional[str] + Base64-encoded contents of the original receipt file. + + currency : typing.Optional[CurrencyEnum] + Currency code used in the receipt. + + document_id : typing.Optional[str] + Unique receipt number assigned by the issuer. + + issued_at : typing.Optional[dt.datetime] + Receipt issued date and time. + + merchant_location : typing.Optional[str] + Location of the merchant. + + merchant_name : typing.Optional[str] + Name of the merchant. + + total_amount : typing.Optional[int] + Total amount for the receipt in minor units (e.g. cents). + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.post_receipts() + + + asyncio.run(main()) + """ + _response = await self._raw_client.post_receipts( + base64encoded_file=base64encoded_file, + currency=currency, + document_id=document_id, + issued_at=issued_at, + merchant_location=merchant_location, + merchant_name=merchant_name, + total_amount=total_amount, + transaction_id=transaction_id, + request_options=request_options, + ) + return _response.data + + async def post_receipts_upload_from_file( + self, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> ReceiptResponseSchema: + """ + Upload an incoming receipt in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.post_receipts_upload_from_file() + + + asyncio.run(main()) + """ + _response = await self._raw_client.post_receipts_upload_from_file(file=file, request_options=request_options) + return _response.data + + async def get_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ReceiptResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.get_receipts_id( + receipt_id="receipt_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_receipts_id(receipt_id, request_options=request_options) + return _response.data + + async def delete_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.delete_receipts_id( + receipt_id="receipt_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete_receipts_id(receipt_id, request_options=request_options) + return _response.data + + async def patch_receipts_id( + self, + receipt_id: str, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + base64encoded_file : typing.Optional[str] + Base64-encoded file contents. + + currency : typing.Optional[CurrencyEnum] + Currency code. + + document_id : typing.Optional[str] + Receipt number. + + issued_at : typing.Optional[dt.datetime] + Date when the receipt was issued. + + merchant_location : typing.Optional[str] + Merchant location. + + merchant_name : typing.Optional[str] + Merchant name. + + total_amount : typing.Optional[int] + Total amount. + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.patch_receipts_id( + receipt_id="receipt_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.patch_receipts_id( + receipt_id, + base64encoded_file=base64encoded_file, + currency=currency, + document_id=document_id, + issued_at=issued_at, + merchant_location=merchant_location, + merchant_name=merchant_name, + total_amount=total_amount, + transaction_id=transaction_id, + request_options=request_options, + ) + return _response.data + + async def post_receipts_id_attach_file( + self, receipt_id: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> ReceiptResponseSchema: + """ + Attach file to receipt without existing attachment. + + Parameters + ---------- + receipt_id : str + + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.post_receipts_id_attach_file( + receipt_id="receipt_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.post_receipts_id_attach_file( + receipt_id, file=file, request_options=request_options + ) + return _response.data + + async def get_receipts_id_line_items( + self, + receipt_id: str, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptLineItemCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + name: typing.Optional[str] = None, + name_iexact: typing.Optional[str] = None, + name_contains: typing.Optional[str] = None, + name_icontains: typing.Optional[str] = None, + total_gt: typing.Optional[int] = None, + total_lt: typing.Optional[int] = None, + total_gte: typing.Optional[int] = None, + total_lte: typing.Optional[int] = None, + created_by_user_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptLineItemsPaginationResponse: + """ + Parameters + ---------- + receipt_id : str + + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptLineItemCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + name : typing.Optional[str] + + name_iexact : typing.Optional[str] + + name_contains : typing.Optional[str] + + name_icontains : typing.Optional[str] + + total_gt : typing.Optional[int] + + total_lt : typing.Optional[int] + + total_gte : typing.Optional[int] + + total_lte : typing.Optional[int] + + created_by_user_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptLineItemsPaginationResponse + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.get_receipts_id_line_items( + receipt_id="receipt_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_receipts_id_line_items( + receipt_id, + order=order, + limit=limit, + pagination_token=pagination_token, + sort=sort, + created_at_gt=created_at_gt, + created_at_lt=created_at_lt, + created_at_gte=created_at_gte, + created_at_lte=created_at_lte, + name=name, + name_iexact=name_iexact, + name_contains=name_contains, + name_icontains=name_icontains, + total_gt=total_gt, + total_lt=total_lt, + total_gte=total_gte, + total_lte=total_lte, + created_by_user_id=created_by_user_id, + request_options=request_options, + ) + return _response.data + + async def post_receipts_id_line_items( + self, + receipt_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptLineItemResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptLineItemResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.post_receipts_id_line_items( + receipt_id="receipt_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.post_receipts_id_line_items( + receipt_id, + accounting_tax_rate_id=accounting_tax_rate_id, + cost_center_id=cost_center_id, + general_ledger_id=general_ledger_id, + name=name, + total=total, + request_options=request_options, + ) + return _response.data + + async def delete_receipts_id_line_items_id( + self, receipt_id: str, line_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.delete_receipts_id_line_items_id( + receipt_id="receipt_id", + line_item_id="line_item_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete_receipts_id_line_items_id( + receipt_id, line_item_id, request_options=request_options + ) + return _response.data + + async def patch_receipts_id_line_items_id( + self, + receipt_id: str, + line_item_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiptLineItemResponseSchema: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiptLineItemResponseSchema + Successful Response + + Examples + -------- + import asyncio + + from monite import AsyncMonite + + client = AsyncMonite( + monite_version="YOUR_MONITE_VERSION", + monite_entity_id="YOUR_MONITE_ENTITY_ID", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.receipts.patch_receipts_id_line_items_id( + receipt_id="receipt_id", + line_item_id="line_item_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.patch_receipts_id_line_items_id( + receipt_id, + line_item_id, + accounting_tax_rate_id=accounting_tax_rate_id, + cost_center_id=cost_center_id, + general_ledger_id=general_ledger_id, + name=name, + total=total, + request_options=request_options, + ) + return _response.data diff --git a/src/monite/receipts/raw_client.py b/src/monite/receipts/raw_client.py new file mode 100644 index 0000000..7f87572 --- /dev/null +++ b/src/monite/receipts/raw_client.py @@ -0,0 +1,2802 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.datetime_utils import serialize_datetime +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.bad_request_error import BadRequestError +from ..errors.conflict_error import ConflictError +from ..errors.forbidden_error import ForbiddenError +from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.currency_enum import CurrencyEnum +from ..types.order_enum import OrderEnum +from ..types.receipt_cursor_fields import ReceiptCursorFields +from ..types.receipt_line_item_cursor_fields import ReceiptLineItemCursorFields +from ..types.receipt_line_item_response_schema import ReceiptLineItemResponseSchema +from ..types.receipt_line_items_pagination_response import ReceiptLineItemsPaginationResponse +from ..types.receipt_pagination_response import ReceiptPaginationResponse +from ..types.receipt_response_schema import ReceiptResponseSchema + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawReceiptsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_receipts( + self, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + currency: typing.Optional[CurrencyEnum] = None, + document_id: typing.Optional[str] = None, + document_id_contains: typing.Optional[str] = None, + document_id_icontains: typing.Optional[str] = None, + total_amount_gt: typing.Optional[int] = None, + total_amount_lt: typing.Optional[int] = None, + total_amount_gte: typing.Optional[int] = None, + total_amount_lte: typing.Optional[int] = None, + has_file: typing.Optional[bool] = None, + has_transaction: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiptPaginationResponse]: + """ + Parameters + ---------- + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + currency : typing.Optional[CurrencyEnum] + + document_id : typing.Optional[str] + + document_id_contains : typing.Optional[str] + + document_id_icontains : typing.Optional[str] + + total_amount_gt : typing.Optional[int] + + total_amount_lt : typing.Optional[int] + + total_amount_gte : typing.Optional[int] + + total_amount_lte : typing.Optional[int] + + has_file : typing.Optional[bool] + + has_transaction : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptPaginationResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "receipts", + method="GET", + params={ + "order": order, + "limit": limit, + "pagination_token": pagination_token, + "sort": sort, + "created_at__gt": serialize_datetime(created_at_gt) if created_at_gt is not None else None, + "created_at__lt": serialize_datetime(created_at_lt) if created_at_lt is not None else None, + "created_at__gte": serialize_datetime(created_at_gte) if created_at_gte is not None else None, + "created_at__lte": serialize_datetime(created_at_lte) if created_at_lte is not None else None, + "id__in": id_in, + "currency": currency, + "document_id": document_id, + "document_id__contains": document_id_contains, + "document_id__icontains": document_id_icontains, + "total_amount__gt": total_amount_gt, + "total_amount__lt": total_amount_lt, + "total_amount__gte": total_amount_gte, + "total_amount__lte": total_amount_lte, + "has_file": has_file, + "has_transaction": has_transaction, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptPaginationResponse, + parse_obj_as( + type_=ReceiptPaginationResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def post_receipts( + self, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiptResponseSchema]: + """ + Parameters + ---------- + base64encoded_file : typing.Optional[str] + Base64-encoded contents of the original receipt file. + + currency : typing.Optional[CurrencyEnum] + Currency code used in the receipt. + + document_id : typing.Optional[str] + Unique receipt number assigned by the issuer. + + issued_at : typing.Optional[dt.datetime] + Receipt issued date and time. + + merchant_location : typing.Optional[str] + Location of the merchant. + + merchant_name : typing.Optional[str] + Name of the merchant. + + total_amount : typing.Optional[int] + Total amount for the receipt in minor units (e.g. cents). + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "receipts", + method="POST", + json={ + "base64_encoded_file": base64encoded_file, + "currency": currency, + "document_id": document_id, + "issued_at": issued_at, + "merchant_location": merchant_location, + "merchant_name": merchant_name, + "total_amount": total_amount, + "transaction_id": transaction_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def post_receipts_upload_from_file( + self, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ReceiptResponseSchema]: + """ + Upload an incoming receipt in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "receipts/upload_from_file", + method="POST", + data={}, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ReceiptResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def patch_receipts_id( + self, + receipt_id: str, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiptResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + base64encoded_file : typing.Optional[str] + Base64-encoded file contents. + + currency : typing.Optional[CurrencyEnum] + Currency code. + + document_id : typing.Optional[str] + Receipt number. + + issued_at : typing.Optional[dt.datetime] + Date when the receipt was issued. + + merchant_location : typing.Optional[str] + Merchant location. + + merchant_name : typing.Optional[str] + Merchant name. + + total_amount : typing.Optional[int] + Total amount. + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}", + method="PATCH", + json={ + "base64_encoded_file": base64encoded_file, + "currency": currency, + "document_id": document_id, + "issued_at": issued_at, + "merchant_location": merchant_location, + "merchant_name": merchant_name, + "total_amount": total_amount, + "transaction_id": transaction_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def post_receipts_id_attach_file( + self, receipt_id: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ReceiptResponseSchema]: + """ + Attach file to receipt without existing attachment. + + Parameters + ---------- + receipt_id : str + + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/attach_file", + method="POST", + data={}, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_receipts_id_line_items( + self, + receipt_id: str, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptLineItemCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + name: typing.Optional[str] = None, + name_iexact: typing.Optional[str] = None, + name_contains: typing.Optional[str] = None, + name_icontains: typing.Optional[str] = None, + total_gt: typing.Optional[int] = None, + total_lt: typing.Optional[int] = None, + total_gte: typing.Optional[int] = None, + total_lte: typing.Optional[int] = None, + created_by_user_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiptLineItemsPaginationResponse]: + """ + Parameters + ---------- + receipt_id : str + + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptLineItemCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + name : typing.Optional[str] + + name_iexact : typing.Optional[str] + + name_contains : typing.Optional[str] + + name_icontains : typing.Optional[str] + + total_gt : typing.Optional[int] + + total_lt : typing.Optional[int] + + total_gte : typing.Optional[int] + + total_lte : typing.Optional[int] + + created_by_user_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptLineItemsPaginationResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items", + method="GET", + params={ + "order": order, + "limit": limit, + "pagination_token": pagination_token, + "sort": sort, + "created_at__gt": serialize_datetime(created_at_gt) if created_at_gt is not None else None, + "created_at__lt": serialize_datetime(created_at_lt) if created_at_lt is not None else None, + "created_at__gte": serialize_datetime(created_at_gte) if created_at_gte is not None else None, + "created_at__lte": serialize_datetime(created_at_lte) if created_at_lte is not None else None, + "name": name, + "name__iexact": name_iexact, + "name__contains": name_contains, + "name__icontains": name_icontains, + "total__gt": total_gt, + "total__lt": total_lt, + "total__gte": total_gte, + "total__lte": total_lte, + "created_by_user_id": created_by_user_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptLineItemsPaginationResponse, + parse_obj_as( + type_=ReceiptLineItemsPaginationResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def post_receipts_id_line_items( + self, + receipt_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiptLineItemResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptLineItemResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items", + method="POST", + json={ + "accounting_tax_rate_id": accounting_tax_rate_id, + "cost_center_id": cost_center_id, + "general_ledger_id": general_ledger_id, + "name": name, + "total": total, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptLineItemResponseSchema, + parse_obj_as( + type_=ReceiptLineItemResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete_receipts_id_line_items_id( + self, receipt_id: str, line_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items/{jsonable_encoder(line_item_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def patch_receipts_id_line_items_id( + self, + receipt_id: str, + line_item_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiptLineItemResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiptLineItemResponseSchema] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items/{jsonable_encoder(line_item_id)}", + method="PATCH", + json={ + "accounting_tax_rate_id": accounting_tax_rate_id, + "cost_center_id": cost_center_id, + "general_ledger_id": general_ledger_id, + "name": name, + "total": total, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptLineItemResponseSchema, + parse_obj_as( + type_=ReceiptLineItemResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawReceiptsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_receipts( + self, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + id_in: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + currency: typing.Optional[CurrencyEnum] = None, + document_id: typing.Optional[str] = None, + document_id_contains: typing.Optional[str] = None, + document_id_icontains: typing.Optional[str] = None, + total_amount_gt: typing.Optional[int] = None, + total_amount_lt: typing.Optional[int] = None, + total_amount_gte: typing.Optional[int] = None, + total_amount_lte: typing.Optional[int] = None, + has_file: typing.Optional[bool] = None, + has_transaction: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiptPaginationResponse]: + """ + Parameters + ---------- + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + id_in : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + currency : typing.Optional[CurrencyEnum] + + document_id : typing.Optional[str] + + document_id_contains : typing.Optional[str] + + document_id_icontains : typing.Optional[str] + + total_amount_gt : typing.Optional[int] + + total_amount_lt : typing.Optional[int] + + total_amount_gte : typing.Optional[int] + + total_amount_lte : typing.Optional[int] + + has_file : typing.Optional[bool] + + has_transaction : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptPaginationResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "receipts", + method="GET", + params={ + "order": order, + "limit": limit, + "pagination_token": pagination_token, + "sort": sort, + "created_at__gt": serialize_datetime(created_at_gt) if created_at_gt is not None else None, + "created_at__lt": serialize_datetime(created_at_lt) if created_at_lt is not None else None, + "created_at__gte": serialize_datetime(created_at_gte) if created_at_gte is not None else None, + "created_at__lte": serialize_datetime(created_at_lte) if created_at_lte is not None else None, + "id__in": id_in, + "currency": currency, + "document_id": document_id, + "document_id__contains": document_id_contains, + "document_id__icontains": document_id_icontains, + "total_amount__gt": total_amount_gt, + "total_amount__lt": total_amount_lt, + "total_amount__gte": total_amount_gte, + "total_amount__lte": total_amount_lte, + "has_file": has_file, + "has_transaction": has_transaction, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptPaginationResponse, + parse_obj_as( + type_=ReceiptPaginationResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def post_receipts( + self, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiptResponseSchema]: + """ + Parameters + ---------- + base64encoded_file : typing.Optional[str] + Base64-encoded contents of the original receipt file. + + currency : typing.Optional[CurrencyEnum] + Currency code used in the receipt. + + document_id : typing.Optional[str] + Unique receipt number assigned by the issuer. + + issued_at : typing.Optional[dt.datetime] + Receipt issued date and time. + + merchant_location : typing.Optional[str] + Location of the merchant. + + merchant_name : typing.Optional[str] + Name of the merchant. + + total_amount : typing.Optional[int] + Total amount for the receipt in minor units (e.g. cents). + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "receipts", + method="POST", + json={ + "base64_encoded_file": base64encoded_file, + "currency": currency, + "document_id": document_id, + "issued_at": issued_at, + "merchant_location": merchant_location, + "merchant_name": merchant_name, + "total_amount": total_amount, + "transaction_id": transaction_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def post_receipts_upload_from_file( + self, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ReceiptResponseSchema]: + """ + Upload an incoming receipt in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "receipts/upload_from_file", + method="POST", + data={}, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ReceiptResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete_receipts_id( + self, receipt_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + receipt_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def patch_receipts_id( + self, + receipt_id: str, + *, + base64encoded_file: typing.Optional[str] = OMIT, + currency: typing.Optional[CurrencyEnum] = OMIT, + document_id: typing.Optional[str] = OMIT, + issued_at: typing.Optional[dt.datetime] = OMIT, + merchant_location: typing.Optional[str] = OMIT, + merchant_name: typing.Optional[str] = OMIT, + total_amount: typing.Optional[int] = OMIT, + transaction_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiptResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + base64encoded_file : typing.Optional[str] + Base64-encoded file contents. + + currency : typing.Optional[CurrencyEnum] + Currency code. + + document_id : typing.Optional[str] + Receipt number. + + issued_at : typing.Optional[dt.datetime] + Date when the receipt was issued. + + merchant_location : typing.Optional[str] + Merchant location. + + merchant_name : typing.Optional[str] + Merchant name. + + total_amount : typing.Optional[int] + Total amount. + + transaction_id : typing.Optional[str] + Transaction ID. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}", + method="PATCH", + json={ + "base64_encoded_file": base64encoded_file, + "currency": currency, + "document_id": document_id, + "issued_at": issued_at, + "merchant_location": merchant_location, + "merchant_name": merchant_name, + "total_amount": total_amount, + "transaction_id": transaction_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def post_receipts_id_attach_file( + self, receipt_id: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ReceiptResponseSchema]: + """ + Attach file to receipt without existing attachment. + + Parameters + ---------- + receipt_id : str + + file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/attach_file", + method="POST", + data={}, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptResponseSchema, + parse_obj_as( + type_=ReceiptResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_receipts_id_line_items( + self, + receipt_id: str, + *, + order: typing.Optional[OrderEnum] = None, + limit: typing.Optional[int] = None, + pagination_token: typing.Optional[str] = None, + sort: typing.Optional[ReceiptLineItemCursorFields] = None, + created_at_gt: typing.Optional[dt.datetime] = None, + created_at_lt: typing.Optional[dt.datetime] = None, + created_at_gte: typing.Optional[dt.datetime] = None, + created_at_lte: typing.Optional[dt.datetime] = None, + name: typing.Optional[str] = None, + name_iexact: typing.Optional[str] = None, + name_contains: typing.Optional[str] = None, + name_icontains: typing.Optional[str] = None, + total_gt: typing.Optional[int] = None, + total_lt: typing.Optional[int] = None, + total_gte: typing.Optional[int] = None, + total_lte: typing.Optional[int] = None, + created_by_user_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiptLineItemsPaginationResponse]: + """ + Parameters + ---------- + receipt_id : str + + order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. + + limit : typing.Optional[int] + The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + + pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. + + sort : typing.Optional[ReceiptLineItemCursorFields] + The field to sort the results by. Typically used together with the `order` parameter. + + created_at_gt : typing.Optional[dt.datetime] + + created_at_lt : typing.Optional[dt.datetime] + + created_at_gte : typing.Optional[dt.datetime] + + created_at_lte : typing.Optional[dt.datetime] + + name : typing.Optional[str] + + name_iexact : typing.Optional[str] + + name_contains : typing.Optional[str] + + name_icontains : typing.Optional[str] + + total_gt : typing.Optional[int] + + total_lt : typing.Optional[int] + + total_gte : typing.Optional[int] + + total_lte : typing.Optional[int] + + created_by_user_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptLineItemsPaginationResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items", + method="GET", + params={ + "order": order, + "limit": limit, + "pagination_token": pagination_token, + "sort": sort, + "created_at__gt": serialize_datetime(created_at_gt) if created_at_gt is not None else None, + "created_at__lt": serialize_datetime(created_at_lt) if created_at_lt is not None else None, + "created_at__gte": serialize_datetime(created_at_gte) if created_at_gte is not None else None, + "created_at__lte": serialize_datetime(created_at_lte) if created_at_lte is not None else None, + "name": name, + "name__iexact": name_iexact, + "name__contains": name_contains, + "name__icontains": name_icontains, + "total__gt": total_gt, + "total__lt": total_lt, + "total__gte": total_gte, + "total__lte": total_lte, + "created_by_user_id": created_by_user_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptLineItemsPaginationResponse, + parse_obj_as( + type_=ReceiptLineItemsPaginationResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def post_receipts_id_line_items( + self, + receipt_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiptLineItemResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptLineItemResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items", + method="POST", + json={ + "accounting_tax_rate_id": accounting_tax_rate_id, + "cost_center_id": cost_center_id, + "general_ledger_id": general_ledger_id, + "name": name, + "total": total, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptLineItemResponseSchema, + parse_obj_as( + type_=ReceiptLineItemResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete_receipts_id_line_items_id( + self, receipt_id: str, line_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items/{jsonable_encoder(line_item_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def patch_receipts_id_line_items_id( + self, + receipt_id: str, + line_item_id: str, + *, + accounting_tax_rate_id: typing.Optional[str] = OMIT, + cost_center_id: typing.Optional[str] = OMIT, + general_ledger_id: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + total: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiptLineItemResponseSchema]: + """ + Parameters + ---------- + receipt_id : str + + line_item_id : str + + accounting_tax_rate_id : typing.Optional[str] + Accounting tax rate ID. + + cost_center_id : typing.Optional[str] + Cost center ID. + + general_ledger_id : typing.Optional[str] + General ledger ID. + + name : typing.Optional[str] + Line item name/description. + + total : typing.Optional[int] + Line item total in minor units. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiptLineItemResponseSchema] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"receipts/{jsonable_encoder(receipt_id)}/line_items/{jsonable_encoder(line_item_id)}", + method="PATCH", + json={ + "accounting_tax_rate_id": accounting_tax_rate_id, + "cost_center_id": cost_center_id, + "general_ledger_id": general_ledger_id, + "name": name, + "total": total, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiptLineItemResponseSchema, + parse_obj_as( + type_=ReceiptLineItemResponseSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/monite/receivables/client.py b/src/monite/receivables/client.py index 1398226..3bb3797 100644 --- a/src/monite/receivables/client.py +++ b/src/monite/receivables/client.py @@ -285,72 +285,130 @@ def get( Return only receivables whose `project_id` include at least one of the project_id with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. type : typing.Optional[ReceivableType] + Return only receivables of the specified type. Use this parameter to get only invoices, or only quotes, or only credit notes. document_id : typing.Optional[str] + Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). document_id_contains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-sensitive). document_id_icontains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-insensitive). issue_date_gt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. issue_date_lt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before the specified date and time. issue_date_gte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued on or after the specified date and time. issue_date_lte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before or on the specified date and time. created_at_gt : typing.Optional[dt.datetime] + Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. created_at_lt : typing.Optional[dt.datetime] + Return only receivables created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only receivables created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only receivables created before or on the specified date and time. counterpart_id : typing.Optional[str] + Return only receivables created for the counterpart with the specified ID. + + Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + + If the specified counterpart ID does not exist and never existed, no results are returned. counterpart_name : typing.Optional[str] + Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`. counterpart_name_contains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-sensitive). counterpart_name_icontains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-insensitive). total_amount : typing.Optional[int] + Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250." total_amount_gt : typing.Optional[int] + Return only receivables whose total amount (in minor units) exceeds the specified value. total_amount_lt : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than the specified value. total_amount_gte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is greater than or equal to the specified value. total_amount_lte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than or equal to the specified value. discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. status : typing.Optional[ReceivablesGetRequestStatus] + Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + + To query multiple statuses at once, use the `status__in` parameter instead. entity_user_id : typing.Optional[str] + Return only receivables created by the entity users with the specified IDs. To specify multiple user IDs, repeat this parameter for each ID: + `entity_user_id__in=&entity_user_id__in=` + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. based_on : typing.Optional[str] + This parameter accepts a quote ID or an invoice ID. + + * Specify a quote ID to find invoices created from this quote. + * Specify an invoice ID to find credit notes created for this invoice or find recurring invoices created from a base invoice. + + Valid but nonexistent IDs do not raise errors but produce no results. due_date_gt : typing.Optional[str] + Return invoices that are due after the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lt : typing.Optional[str] + Return invoices that are due before the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_gte : typing.Optional[str] + Return invoices that are due on or after the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lte : typing.Optional[str] + Return invoices that are due before or on the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. project_id : typing.Optional[str] + Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -440,7 +498,7 @@ def create( Examples -------- - from monite import LineItem, Monite, ReceivableFacadeCreateQuotePayload + from monite import Monite, ReceivableCreateBasedOnPayload client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -448,15 +506,9 @@ def create( token="YOUR_TOKEN", ) client.receivables.create( - request=ReceivableFacadeCreateQuotePayload( - counterpart_billing_address_id="counterpart_billing_address_id", - counterpart_id="counterpart_id", - currency="AED", - line_items=[ - LineItem( - quantity=1.1, - ) - ], + request=ReceivableCreateBasedOnPayload( + based_on="based_on", + type="invoice", ), ) """ @@ -524,11 +576,6 @@ def get_receivables_required_fields( def post_receivables_search( self, *, - discounted_subtotal: typing.Optional[int] = OMIT, - discounted_subtotal_gt: typing.Optional[int] = OMIT, - discounted_subtotal_gte: typing.Optional[int] = OMIT, - discounted_subtotal_lt: typing.Optional[int] = OMIT, - discounted_subtotal_lte: typing.Optional[int] = OMIT, based_on: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, counterpart_name: typing.Optional[str] = OMIT, @@ -538,6 +585,11 @@ def post_receivables_search( created_at_gte: typing.Optional[dt.datetime] = OMIT, created_at_lt: typing.Optional[dt.datetime] = OMIT, created_at_lte: typing.Optional[dt.datetime] = OMIT, + discounted_subtotal: typing.Optional[int] = OMIT, + discounted_subtotal_gt: typing.Optional[int] = OMIT, + discounted_subtotal_gte: typing.Optional[int] = OMIT, + discounted_subtotal_lt: typing.Optional[int] = OMIT, + discounted_subtotal_lte: typing.Optional[int] = OMIT, document_id: typing.Optional[str] = OMIT, document_id_contains: typing.Optional[str] = OMIT, document_id_icontains: typing.Optional[str] = OMIT, @@ -577,21 +629,6 @@ def post_receivables_search( Parameters ---------- - discounted_subtotal : typing.Optional[int] - Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. - - discounted_subtotal_gt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. - - discounted_subtotal_gte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. - - discounted_subtotal_lt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than the specified value. - - discounted_subtotal_lte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. - based_on : typing.Optional[str] This parameter accepts a quote ID or an invoice ID. @@ -628,6 +665,21 @@ def post_receivables_search( created_at_lte : typing.Optional[dt.datetime] Return only receivables created before or on the specified date and time. + discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. + + discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. + + discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. + + discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. + + discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. + document_id : typing.Optional[str] Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). @@ -665,8 +717,14 @@ def post_receivables_search( IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. entity_user_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables created by the entity users with the specified IDs. + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. id_in : typing.Optional[typing.Sequence[str]] + Return only receivables with the specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. issue_date_gt : typing.Optional[dt.datetime] Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. @@ -681,21 +739,56 @@ def post_receivables_search( Return only non-draft receivables that were issued before or on the specified date and time. limit : typing.Optional[int] + The number of items (0 .. 250) to return in a single page of the response. Default is 100. The response may contain fewer items if it is the last or only page. + + When using pagination with a non-default limit, you must provide the `limit` value alongside `pagination_token` in all subsequent pagination requests. Unlike other pagination parameters, `limit` is not inferred from `pagination_token`. order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to `GET /receivables` or `POST /receivables/search`. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other parameters except `limit` are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. product_ids : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing all of the products with the specified IDs and optionally other products that are not specified. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productA, productB, productC + + `product_ids` = `[productA, productB]` will return receivables 3 and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. product_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing at least one of the products with the specified IDs. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productB, productC + + `product_ids__in` = `[productA, productB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. project_id : typing.Optional[str] Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. project_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables that belong to one of the projects with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. sort : typing.Optional[ReceivableCursorFields2] + The field to sort the results by. Typically used together with the `order` parameter. status : typing.Optional[ReceivablesSearchRequestStatus] Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). @@ -703,10 +796,35 @@ def post_receivables_search( To query multiple statuses at once, use the `status__in` parameter instead. status_in : typing.Optional[typing.Sequence[str]] + Return only receivables that have the specified statuses. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). tag_ids : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include all of the tags with the specified IDs and optionally other tags that are not specified. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagA, tagB, tagC + + `tag_ids` = `[tagA, tagB]` will return receivables 3 and 5. tag_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include at least one of the tags with the specified IDs. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagB, tagC + + `tag_ids__in` = `[tagA, tagB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent tag IDs do not raise errors but produce no results. total_amount : typing.Optional[int] Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. @@ -743,14 +861,12 @@ def post_receivables_search( monite_entity_id="YOUR_MONITE_ENTITY_ID", token="YOUR_TOKEN", ) - client.receivables.post_receivables_search() + client.receivables.post_receivables_search( + status="draft", + type="invoice", + ) """ _response = self._raw_client.post_receivables_search( - discounted_subtotal=discounted_subtotal, - discounted_subtotal_gt=discounted_subtotal_gt, - discounted_subtotal_gte=discounted_subtotal_gte, - discounted_subtotal_lt=discounted_subtotal_lt, - discounted_subtotal_lte=discounted_subtotal_lte, based_on=based_on, counterpart_id=counterpart_id, counterpart_name=counterpart_name, @@ -760,6 +876,11 @@ def post_receivables_search( created_at_gte=created_at_gte, created_at_lt=created_at_lt, created_at_lte=created_at_lte, + discounted_subtotal=discounted_subtotal, + discounted_subtotal_gt=discounted_subtotal_gt, + discounted_subtotal_gte=discounted_subtotal_gte, + discounted_subtotal_lt=discounted_subtotal_lt, + discounted_subtotal_lte=discounted_subtotal_lte, document_id=document_id, document_id_contains=document_id_contains, document_id_icontains=document_id_icontains, @@ -830,9 +951,16 @@ def get_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ReceivableResponse: """ + Returns the details of an existing accounts receivable invoice, quote, or credit note with the specified ID. + + The response fields vary depending on the document type. Use the `type` field to distinguish between different document types. + + Entity users with the `receivable.read.allowed_for_own` permission (rather than `allowed`) can access only documents that they created themselves. + Parameters ---------- receivable_id : str + ID of an existing invoice, quote, or credit note that you want to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -936,12 +1064,16 @@ def accept_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> SuccessResult: """ + Only quotes in the `issued` status can be accepted. + + When a quote is accepted, Monite automatically creates a draft invoice based on this quote. To find the newly created invoice, use `GET /receivables?based_on=QUOTE_ID`. + Parameters ---------- receivable_id : str signature : typing.Optional[Signature] - A digital signature, if required for quote acceptance + The counterpart's signature. Required if the quote field `signature_required` is `true`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -953,7 +1085,7 @@ def accept_by_id( Examples -------- - from monite import Monite + from monite import Monite, Signature client = Monite( monite_version="YOUR_MONITE_VERSION", @@ -962,6 +1094,11 @@ def accept_by_id( ) client.receivables.accept_by_id( receivable_id="receivable_id", + signature=Signature( + email="theo@example.com", + full_name="Theo Quinn", + signature_image="iVBORw0KGgoAAAANSUhEUg.....AAABJRU5ErkJggg==", + ), ) """ _response = self._raw_client.accept_by_id(receivable_id, signature=signature, request_options=request_options) @@ -1000,9 +1137,21 @@ def clone_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ReceivableResponse: """ + Creates a copy of an existing accounts receivable invoice or quote. The original document can be in any status. The cloned document will have the `draft` status. + + Cloning a document requires that all of the referenced resource IDs (counterpart ID, product IDs, and others) still exist. + + Most of the original document's data is copied as is, with a few exceptions: + + * Some fields are not copied: `attachments`, `document_id`, `issue_date`, quote `expiry_date`. + * Counterpart details, entity bank account details, and entity VAT number are fetched anew from their corresponding IDs. + This means, for example, that if the counterpart details have been changed since the original invoice or quote was created, + the cloned document will use the current counterpart details rather than the old details from the original document. + Parameters ---------- receivable_id : str + ID of an existing invoice or quote that you want to clone. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1036,6 +1185,8 @@ def decline_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> SuccessResult: """ + Only quotes in the `issued` status can be declined. + Parameters ---------- receivable_id : str @@ -1582,6 +1733,13 @@ def preview_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> ReceivablePreviewResponse: """ + You can preview emails only for documents in the following statuses: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + Parameters ---------- receivable_id : str @@ -1641,6 +1799,17 @@ def send_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> ReceivableSendResponse: """ + Only documents in the following statuses can be sent via email: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + + Draft documents are automatically moved to the `issued` status before sending. + + For more information, see [Send an invoice via email](https://docs.monite.com/accounts-receivable/invoices/create#send-via-email). + Parameters ---------- receivable_id : str @@ -2001,72 +2170,130 @@ async def get( Return only receivables whose `project_id` include at least one of the project_id with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. type : typing.Optional[ReceivableType] + Return only receivables of the specified type. Use this parameter to get only invoices, or only quotes, or only credit notes. document_id : typing.Optional[str] + Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). document_id_contains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-sensitive). document_id_icontains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-insensitive). issue_date_gt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. issue_date_lt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before the specified date and time. issue_date_gte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued on or after the specified date and time. issue_date_lte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before or on the specified date and time. created_at_gt : typing.Optional[dt.datetime] + Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. created_at_lt : typing.Optional[dt.datetime] + Return only receivables created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only receivables created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only receivables created before or on the specified date and time. counterpart_id : typing.Optional[str] + Return only receivables created for the counterpart with the specified ID. + + Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + + If the specified counterpart ID does not exist and never existed, no results are returned. counterpart_name : typing.Optional[str] + Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`. counterpart_name_contains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-sensitive). counterpart_name_icontains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-insensitive). total_amount : typing.Optional[int] + Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250." total_amount_gt : typing.Optional[int] + Return only receivables whose total amount (in minor units) exceeds the specified value. total_amount_lt : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than the specified value. total_amount_gte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is greater than or equal to the specified value. total_amount_lte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than or equal to the specified value. discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. status : typing.Optional[ReceivablesGetRequestStatus] + Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + + To query multiple statuses at once, use the `status__in` parameter instead. entity_user_id : typing.Optional[str] + Return only receivables created by the entity users with the specified IDs. To specify multiple user IDs, repeat this parameter for each ID: + `entity_user_id__in=&entity_user_id__in=` + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. based_on : typing.Optional[str] + This parameter accepts a quote ID or an invoice ID. + + * Specify a quote ID to find invoices created from this quote. + * Specify an invoice ID to find credit notes created for this invoice or find recurring invoices created from a base invoice. + + Valid but nonexistent IDs do not raise errors but produce no results. due_date_gt : typing.Optional[str] + Return invoices that are due after the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lt : typing.Optional[str] + Return invoices that are due before the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_gte : typing.Optional[str] + Return invoices that are due on or after the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lte : typing.Optional[str] + Return invoices that are due before or on the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. project_id : typing.Optional[str] + Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2166,7 +2393,7 @@ async def create( -------- import asyncio - from monite import AsyncMonite, LineItem, ReceivableFacadeCreateQuotePayload + from monite import AsyncMonite, ReceivableCreateBasedOnPayload client = AsyncMonite( monite_version="YOUR_MONITE_VERSION", @@ -2177,15 +2404,9 @@ async def create( async def main() -> None: await client.receivables.create( - request=ReceivableFacadeCreateQuotePayload( - counterpart_billing_address_id="counterpart_billing_address_id", - counterpart_id="counterpart_id", - currency="AED", - line_items=[ - LineItem( - quantity=1.1, - ) - ], + request=ReceivableCreateBasedOnPayload( + based_on="based_on", + type="invoice", ), ) @@ -2264,11 +2485,6 @@ async def main() -> None: async def post_receivables_search( self, *, - discounted_subtotal: typing.Optional[int] = OMIT, - discounted_subtotal_gt: typing.Optional[int] = OMIT, - discounted_subtotal_gte: typing.Optional[int] = OMIT, - discounted_subtotal_lt: typing.Optional[int] = OMIT, - discounted_subtotal_lte: typing.Optional[int] = OMIT, based_on: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, counterpart_name: typing.Optional[str] = OMIT, @@ -2278,6 +2494,11 @@ async def post_receivables_search( created_at_gte: typing.Optional[dt.datetime] = OMIT, created_at_lt: typing.Optional[dt.datetime] = OMIT, created_at_lte: typing.Optional[dt.datetime] = OMIT, + discounted_subtotal: typing.Optional[int] = OMIT, + discounted_subtotal_gt: typing.Optional[int] = OMIT, + discounted_subtotal_gte: typing.Optional[int] = OMIT, + discounted_subtotal_lt: typing.Optional[int] = OMIT, + discounted_subtotal_lte: typing.Optional[int] = OMIT, document_id: typing.Optional[str] = OMIT, document_id_contains: typing.Optional[str] = OMIT, document_id_icontains: typing.Optional[str] = OMIT, @@ -2317,21 +2538,6 @@ async def post_receivables_search( Parameters ---------- - discounted_subtotal : typing.Optional[int] - Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. - - discounted_subtotal_gt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. - - discounted_subtotal_gte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. - - discounted_subtotal_lt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than the specified value. - - discounted_subtotal_lte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. - based_on : typing.Optional[str] This parameter accepts a quote ID or an invoice ID. @@ -2368,6 +2574,21 @@ async def post_receivables_search( created_at_lte : typing.Optional[dt.datetime] Return only receivables created before or on the specified date and time. + discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. + + discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. + + discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. + + discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. + + discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. + document_id : typing.Optional[str] Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). @@ -2405,8 +2626,14 @@ async def post_receivables_search( IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. entity_user_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables created by the entity users with the specified IDs. + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. id_in : typing.Optional[typing.Sequence[str]] + Return only receivables with the specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. issue_date_gt : typing.Optional[dt.datetime] Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. @@ -2421,21 +2648,56 @@ async def post_receivables_search( Return only non-draft receivables that were issued before or on the specified date and time. limit : typing.Optional[int] + The number of items (0 .. 250) to return in a single page of the response. Default is 100. The response may contain fewer items if it is the last or only page. + + When using pagination with a non-default limit, you must provide the `limit` value alongside `pagination_token` in all subsequent pagination requests. Unlike other pagination parameters, `limit` is not inferred from `pagination_token`. order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to `GET /receivables` or `POST /receivables/search`. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other parameters except `limit` are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. product_ids : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing all of the products with the specified IDs and optionally other products that are not specified. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productA, productB, productC + + `product_ids` = `[productA, productB]` will return receivables 3 and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. product_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing at least one of the products with the specified IDs. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productB, productC + + `product_ids__in` = `[productA, productB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. project_id : typing.Optional[str] Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. project_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables that belong to one of the projects with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. sort : typing.Optional[ReceivableCursorFields2] + The field to sort the results by. Typically used together with the `order` parameter. status : typing.Optional[ReceivablesSearchRequestStatus] Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). @@ -2443,10 +2705,35 @@ async def post_receivables_search( To query multiple statuses at once, use the `status__in` parameter instead. status_in : typing.Optional[typing.Sequence[str]] + Return only receivables that have the specified statuses. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). tag_ids : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include all of the tags with the specified IDs and optionally other tags that are not specified. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagA, tagB, tagC + + `tag_ids` = `[tagA, tagB]` will return receivables 3 and 5. tag_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include at least one of the tags with the specified IDs. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagB, tagC + + `tag_ids__in` = `[tagA, tagB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent tag IDs do not raise errors but produce no results. total_amount : typing.Optional[int] Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. @@ -2488,17 +2775,15 @@ async def post_receivables_search( async def main() -> None: - await client.receivables.post_receivables_search() + await client.receivables.post_receivables_search( + status="draft", + type="invoice", + ) asyncio.run(main()) """ _response = await self._raw_client.post_receivables_search( - discounted_subtotal=discounted_subtotal, - discounted_subtotal_gt=discounted_subtotal_gt, - discounted_subtotal_gte=discounted_subtotal_gte, - discounted_subtotal_lt=discounted_subtotal_lt, - discounted_subtotal_lte=discounted_subtotal_lte, based_on=based_on, counterpart_id=counterpart_id, counterpart_name=counterpart_name, @@ -2508,6 +2793,11 @@ async def main() -> None: created_at_gte=created_at_gte, created_at_lt=created_at_lt, created_at_lte=created_at_lte, + discounted_subtotal=discounted_subtotal, + discounted_subtotal_gt=discounted_subtotal_gt, + discounted_subtotal_gte=discounted_subtotal_gte, + discounted_subtotal_lt=discounted_subtotal_lt, + discounted_subtotal_lte=discounted_subtotal_lte, document_id=document_id, document_id_contains=document_id_contains, document_id_icontains=document_id_icontains, @@ -2586,9 +2876,16 @@ async def get_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ReceivableResponse: """ + Returns the details of an existing accounts receivable invoice, quote, or credit note with the specified ID. + + The response fields vary depending on the document type. Use the `type` field to distinguish between different document types. + + Entity users with the `receivable.read.allowed_for_own` permission (rather than `allowed`) can access only documents that they created themselves. + Parameters ---------- receivable_id : str + ID of an existing invoice, quote, or credit note that you want to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2718,12 +3015,16 @@ async def accept_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> SuccessResult: """ + Only quotes in the `issued` status can be accepted. + + When a quote is accepted, Monite automatically creates a draft invoice based on this quote. To find the newly created invoice, use `GET /receivables?based_on=QUOTE_ID`. + Parameters ---------- receivable_id : str signature : typing.Optional[Signature] - A digital signature, if required for quote acceptance + The counterpart's signature. Required if the quote field `signature_required` is `true`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2737,7 +3038,7 @@ async def accept_by_id( -------- import asyncio - from monite import AsyncMonite + from monite import AsyncMonite, Signature client = AsyncMonite( monite_version="YOUR_MONITE_VERSION", @@ -2749,6 +3050,11 @@ async def accept_by_id( async def main() -> None: await client.receivables.accept_by_id( receivable_id="receivable_id", + signature=Signature( + email="theo@example.com", + full_name="Theo Quinn", + signature_image="iVBORw0KGgoAAAANSUhEUg.....AAABJRU5ErkJggg==", + ), ) @@ -2802,9 +3108,21 @@ async def clone_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ReceivableResponse: """ + Creates a copy of an existing accounts receivable invoice or quote. The original document can be in any status. The cloned document will have the `draft` status. + + Cloning a document requires that all of the referenced resource IDs (counterpart ID, product IDs, and others) still exist. + + Most of the original document's data is copied as is, with a few exceptions: + + * Some fields are not copied: `attachments`, `document_id`, `issue_date`, quote `expiry_date`. + * Counterpart details, entity bank account details, and entity VAT number are fetched anew from their corresponding IDs. + This means, for example, that if the counterpart details have been changed since the original invoice or quote was created, + the cloned document will use the current counterpart details rather than the old details from the original document. + Parameters ---------- receivable_id : str + ID of an existing invoice or quote that you want to clone. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2846,6 +3164,8 @@ async def decline_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> SuccessResult: """ + Only quotes in the `issued` status can be declined. + Parameters ---------- receivable_id : str @@ -3484,6 +3804,13 @@ async def preview_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> ReceivablePreviewResponse: """ + You can preview emails only for documents in the following statuses: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + Parameters ---------- receivable_id : str @@ -3551,6 +3878,17 @@ async def send_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> ReceivableSendResponse: """ + Only documents in the following statuses can be sent via email: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + + Draft documents are automatically moved to the `issued` status before sending. + + For more information, see [Send an invoice via email](https://docs.monite.com/accounts-receivable/invoices/create#send-via-email). + Parameters ---------- receivable_id : str diff --git a/src/monite/receivables/raw_client.py b/src/monite/receivables/raw_client.py index add192a..7edc56d 100644 --- a/src/monite/receivables/raw_client.py +++ b/src/monite/receivables/raw_client.py @@ -15,9 +15,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.allowed_countries import AllowedCountries @@ -288,72 +288,130 @@ def get( Return only receivables whose `project_id` include at least one of the project_id with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. type : typing.Optional[ReceivableType] + Return only receivables of the specified type. Use this parameter to get only invoices, or only quotes, or only credit notes. document_id : typing.Optional[str] + Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). document_id_contains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-sensitive). document_id_icontains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-insensitive). issue_date_gt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. issue_date_lt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before the specified date and time. issue_date_gte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued on or after the specified date and time. issue_date_lte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before or on the specified date and time. created_at_gt : typing.Optional[dt.datetime] + Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. created_at_lt : typing.Optional[dt.datetime] + Return only receivables created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only receivables created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only receivables created before or on the specified date and time. counterpart_id : typing.Optional[str] + Return only receivables created for the counterpart with the specified ID. + + Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + + If the specified counterpart ID does not exist and never existed, no results are returned. counterpart_name : typing.Optional[str] + Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`. counterpart_name_contains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-sensitive). counterpart_name_icontains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-insensitive). total_amount : typing.Optional[int] + Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250." total_amount_gt : typing.Optional[int] + Return only receivables whose total amount (in minor units) exceeds the specified value. total_amount_lt : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than the specified value. total_amount_gte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is greater than or equal to the specified value. total_amount_lte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than or equal to the specified value. discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. status : typing.Optional[ReceivablesGetRequestStatus] + Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + + To query multiple statuses at once, use the `status__in` parameter instead. entity_user_id : typing.Optional[str] + Return only receivables created by the entity users with the specified IDs. To specify multiple user IDs, repeat this parameter for each ID: + `entity_user_id__in=&entity_user_id__in=` + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. based_on : typing.Optional[str] + This parameter accepts a quote ID or an invoice ID. + + * Specify a quote ID to find invoices created from this quote. + * Specify an invoice ID to find credit notes created for this invoice or find recurring invoices created from a base invoice. + + Valid but nonexistent IDs do not raise errors but produce no results. due_date_gt : typing.Optional[str] + Return invoices that are due after the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lt : typing.Optional[str] + Return invoices that are due before the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_gte : typing.Optional[str] + Return invoices that are due on or after the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lte : typing.Optional[str] + Return invoices that are due before or on the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. project_id : typing.Optional[str] + Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -437,6 +495,17 @@ def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -481,8 +550,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -601,8 +670,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -676,6 +745,17 @@ def get_receivables_required_fields( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -687,8 +767,8 @@ def get_receivables_required_fields( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -706,11 +786,6 @@ def get_receivables_required_fields( def post_receivables_search( self, *, - discounted_subtotal: typing.Optional[int] = OMIT, - discounted_subtotal_gt: typing.Optional[int] = OMIT, - discounted_subtotal_gte: typing.Optional[int] = OMIT, - discounted_subtotal_lt: typing.Optional[int] = OMIT, - discounted_subtotal_lte: typing.Optional[int] = OMIT, based_on: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, counterpart_name: typing.Optional[str] = OMIT, @@ -720,6 +795,11 @@ def post_receivables_search( created_at_gte: typing.Optional[dt.datetime] = OMIT, created_at_lt: typing.Optional[dt.datetime] = OMIT, created_at_lte: typing.Optional[dt.datetime] = OMIT, + discounted_subtotal: typing.Optional[int] = OMIT, + discounted_subtotal_gt: typing.Optional[int] = OMIT, + discounted_subtotal_gte: typing.Optional[int] = OMIT, + discounted_subtotal_lt: typing.Optional[int] = OMIT, + discounted_subtotal_lte: typing.Optional[int] = OMIT, document_id: typing.Optional[str] = OMIT, document_id_contains: typing.Optional[str] = OMIT, document_id_icontains: typing.Optional[str] = OMIT, @@ -759,21 +839,6 @@ def post_receivables_search( Parameters ---------- - discounted_subtotal : typing.Optional[int] - Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. - - discounted_subtotal_gt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. - - discounted_subtotal_gte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. - - discounted_subtotal_lt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than the specified value. - - discounted_subtotal_lte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. - based_on : typing.Optional[str] This parameter accepts a quote ID or an invoice ID. @@ -810,6 +875,21 @@ def post_receivables_search( created_at_lte : typing.Optional[dt.datetime] Return only receivables created before or on the specified date and time. + discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. + + discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. + + discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. + + discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. + + discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. + document_id : typing.Optional[str] Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). @@ -847,8 +927,14 @@ def post_receivables_search( IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. entity_user_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables created by the entity users with the specified IDs. + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. id_in : typing.Optional[typing.Sequence[str]] + Return only receivables with the specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. issue_date_gt : typing.Optional[dt.datetime] Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. @@ -863,21 +949,56 @@ def post_receivables_search( Return only non-draft receivables that were issued before or on the specified date and time. limit : typing.Optional[int] + The number of items (0 .. 250) to return in a single page of the response. Default is 100. The response may contain fewer items if it is the last or only page. + + When using pagination with a non-default limit, you must provide the `limit` value alongside `pagination_token` in all subsequent pagination requests. Unlike other pagination parameters, `limit` is not inferred from `pagination_token`. order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to `GET /receivables` or `POST /receivables/search`. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other parameters except `limit` are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. product_ids : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing all of the products with the specified IDs and optionally other products that are not specified. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productA, productB, productC + + `product_ids` = `[productA, productB]` will return receivables 3 and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. product_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing at least one of the products with the specified IDs. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productB, productC + + `product_ids__in` = `[productA, productB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. project_id : typing.Optional[str] Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. project_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables that belong to one of the projects with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. sort : typing.Optional[ReceivableCursorFields2] + The field to sort the results by. Typically used together with the `order` parameter. status : typing.Optional[ReceivablesSearchRequestStatus] Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). @@ -885,10 +1006,35 @@ def post_receivables_search( To query multiple statuses at once, use the `status__in` parameter instead. status_in : typing.Optional[typing.Sequence[str]] + Return only receivables that have the specified statuses. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). tag_ids : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include all of the tags with the specified IDs and optionally other tags that are not specified. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagA, tagB, tagC + + `tag_ids` = `[tagA, tagB]` will return receivables 3 and 5. tag_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include at least one of the tags with the specified IDs. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagB, tagC + + `tag_ids__in` = `[tagA, tagB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent tag IDs do not raise errors but produce no results. total_amount : typing.Optional[int] Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. @@ -920,11 +1066,6 @@ def post_receivables_search( "receivables/search", method="POST", json={ - "discounted_subtotal": discounted_subtotal, - "discounted_subtotal__gt": discounted_subtotal_gt, - "discounted_subtotal__gte": discounted_subtotal_gte, - "discounted_subtotal__lt": discounted_subtotal_lt, - "discounted_subtotal__lte": discounted_subtotal_lte, "based_on": based_on, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, @@ -934,6 +1075,11 @@ def post_receivables_search( "created_at__gte": created_at_gte, "created_at__lt": created_at_lt, "created_at__lte": created_at_lte, + "discounted_subtotal": discounted_subtotal, + "discounted_subtotal__gt": discounted_subtotal_gt, + "discounted_subtotal__gte": discounted_subtotal_gte, + "discounted_subtotal__lt": discounted_subtotal_lt, + "discounted_subtotal__lte": discounted_subtotal_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, @@ -994,6 +1140,17 @@ def post_receivables_search( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1038,8 +1195,8 @@ def post_receivables_search( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1085,6 +1242,17 @@ def get_variables( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -1118,8 +1286,8 @@ def get_variables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1138,9 +1306,16 @@ def get_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[ReceivableResponse]: """ + Returns the details of an existing accounts receivable invoice, quote, or credit note with the specified ID. + + The response fields vary depending on the document type. Use the `type` field to distinguish between different document types. + + Entity users with the `receivable.read.allowed_for_own` permission (rather than `allowed`) can access only documents that they created themselves. + Parameters ---------- receivable_id : str + ID of an existing invoice, quote, or credit note that you want to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1220,8 +1395,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1325,8 +1500,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1451,8 +1626,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1475,12 +1650,16 @@ def accept_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[SuccessResult]: """ + Only quotes in the `issued` status can be accepted. + + When a quote is accepted, Monite automatically creates a draft invoice based on this quote. To find the newly created invoice, use `GET /receivables?based_on=QUOTE_ID`. + Parameters ---------- receivable_id : str signature : typing.Optional[Signature] - A digital signature, if required for quote acceptance + The counterpart's signature. Required if the quote field `signature_required` is `true`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1580,8 +1759,8 @@ def accept_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1685,8 +1864,8 @@ def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1705,9 +1884,21 @@ def clone_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[ReceivableResponse]: """ + Creates a copy of an existing accounts receivable invoice or quote. The original document can be in any status. The cloned document will have the `draft` status. + + Cloning a document requires that all of the referenced resource IDs (counterpart ID, product IDs, and others) still exist. + + Most of the original document's data is copied as is, with a few exceptions: + + * Some fields are not copied: `attachments`, `document_id`, `issue_date`, quote `expiry_date`. + * Counterpart details, entity bank account details, and entity VAT number are fetched anew from their corresponding IDs. + This means, for example, that if the counterpart details have been changed since the original invoice or quote was created, + the cloned document will use the current counterpart details rather than the old details from the original document. + Parameters ---------- receivable_id : str + ID of an existing invoice or quote that you want to clone. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1798,8 +1989,8 @@ def clone_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1822,6 +2013,8 @@ def decline_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[SuccessResult]: """ + Only quotes in the `issued` status can be declined. + Parameters ---------- receivable_id : str @@ -1925,8 +2118,8 @@ def decline_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2093,8 +2286,8 @@ def get_history( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2201,8 +2394,8 @@ def get_history_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2314,8 +2507,8 @@ def issue_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2444,8 +2637,8 @@ def update_line_items_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2599,8 +2792,8 @@ def get_mails( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2703,8 +2896,8 @@ def get_mail_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2835,8 +3028,8 @@ def mark_as_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -2969,8 +3162,8 @@ def mark_as_partially_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3096,8 +3289,8 @@ def mark_as_uncollectible_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3198,8 +3391,8 @@ def get_pdf_link_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3225,6 +3418,13 @@ def preview_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[ReceivablePreviewResponse]: """ + You can preview emails only for documents in the following statuses: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + Parameters ---------- receivable_id : str @@ -3329,8 +3529,8 @@ def preview_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3355,6 +3555,17 @@ def send_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[ReceivableSendResponse]: """ + Only documents in the following statuses can be sent via email: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + + Draft documents are automatically moved to the `issued` status before sending. + + For more information, see [Send an invoice via email](https://docs.monite.com/accounts-receivable/invoices/create#send-via-email). + Parameters ---------- receivable_id : str @@ -3467,8 +3678,8 @@ def send_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3600,8 +3811,8 @@ def send_test_reminder_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3702,8 +3913,8 @@ def verify_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -3946,72 +4157,130 @@ async def get( Return only receivables whose `project_id` include at least one of the project_id with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. type : typing.Optional[ReceivableType] + Return only receivables of the specified type. Use this parameter to get only invoices, or only quotes, or only credit notes. document_id : typing.Optional[str] + Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). document_id_contains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-sensitive). document_id_icontains : typing.Optional[str] + Return only receivables whose document number (`document_id`) contains the specified string (case-insensitive). issue_date_gt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. issue_date_lt : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before the specified date and time. issue_date_gte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued on or after the specified date and time. issue_date_lte : typing.Optional[dt.datetime] + Return only non-draft receivables that were issued before or on the specified date and time. created_at_gt : typing.Optional[dt.datetime] + Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. created_at_lt : typing.Optional[dt.datetime] + Return only receivables created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only receivables created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only receivables created before or on the specified date and time. counterpart_id : typing.Optional[str] + Return only receivables created for the counterpart with the specified ID. + + Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + + If the specified counterpart ID does not exist and never existed, no results are returned. counterpart_name : typing.Optional[str] + Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`. counterpart_name_contains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-sensitive). counterpart_name_icontains : typing.Optional[str] + Return only receivables created for counterparts whose name contains the specified string (case-insensitive). total_amount : typing.Optional[int] + Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250." total_amount_gt : typing.Optional[int] + Return only receivables whose total amount (in minor units) exceeds the specified value. total_amount_lt : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than the specified value. total_amount_gte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is greater than or equal to the specified value. total_amount_lte : typing.Optional[int] + Return only receivables whose total amount (in minor units) is less than or equal to the specified value. discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. status : typing.Optional[ReceivablesGetRequestStatus] + Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + + To query multiple statuses at once, use the `status__in` parameter instead. entity_user_id : typing.Optional[str] + Return only receivables created by the entity users with the specified IDs. To specify multiple user IDs, repeat this parameter for each ID: + `entity_user_id__in=&entity_user_id__in=` + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. based_on : typing.Optional[str] + This parameter accepts a quote ID or an invoice ID. + + * Specify a quote ID to find invoices created from this quote. + * Specify an invoice ID to find credit notes created for this invoice or find recurring invoices created from a base invoice. + + Valid but nonexistent IDs do not raise errors but produce no results. due_date_gt : typing.Optional[str] + Return invoices that are due after the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lt : typing.Optional[str] + Return invoices that are due before the specified date (exclusive, `YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_gte : typing.Optional[str] + Return invoices that are due on or after the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. due_date_lte : typing.Optional[str] + Return invoices that are due before or on the specified date (`YYYY-MM-DD`). + + This filter excludes quotes, credit notes, and draft invoices. project_id : typing.Optional[str] + Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -4095,6 +4364,17 @@ async def get( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -4139,8 +4419,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4259,8 +4539,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4334,6 +4614,17 @@ async def get_receivables_required_fields( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -4345,8 +4636,8 @@ async def get_receivables_required_fields( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4364,11 +4655,6 @@ async def get_receivables_required_fields( async def post_receivables_search( self, *, - discounted_subtotal: typing.Optional[int] = OMIT, - discounted_subtotal_gt: typing.Optional[int] = OMIT, - discounted_subtotal_gte: typing.Optional[int] = OMIT, - discounted_subtotal_lt: typing.Optional[int] = OMIT, - discounted_subtotal_lte: typing.Optional[int] = OMIT, based_on: typing.Optional[str] = OMIT, counterpart_id: typing.Optional[str] = OMIT, counterpart_name: typing.Optional[str] = OMIT, @@ -4378,6 +4664,11 @@ async def post_receivables_search( created_at_gte: typing.Optional[dt.datetime] = OMIT, created_at_lt: typing.Optional[dt.datetime] = OMIT, created_at_lte: typing.Optional[dt.datetime] = OMIT, + discounted_subtotal: typing.Optional[int] = OMIT, + discounted_subtotal_gt: typing.Optional[int] = OMIT, + discounted_subtotal_gte: typing.Optional[int] = OMIT, + discounted_subtotal_lt: typing.Optional[int] = OMIT, + discounted_subtotal_lte: typing.Optional[int] = OMIT, document_id: typing.Optional[str] = OMIT, document_id_contains: typing.Optional[str] = OMIT, document_id_icontains: typing.Optional[str] = OMIT, @@ -4417,21 +4708,6 @@ async def post_receivables_search( Parameters ---------- - discounted_subtotal : typing.Optional[int] - Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. - - discounted_subtotal_gt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. - - discounted_subtotal_gte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. - - discounted_subtotal_lt : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than the specified value. - - discounted_subtotal_lte : typing.Optional[int] - Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. - based_on : typing.Optional[str] This parameter accepts a quote ID or an invoice ID. @@ -4468,6 +4744,21 @@ async def post_receivables_search( created_at_lte : typing.Optional[dt.datetime] Return only receivables created before or on the specified date and time. + discounted_subtotal : typing.Optional[int] + Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. + + discounted_subtotal_gt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. + + discounted_subtotal_gte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. + + discounted_subtotal_lt : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than the specified value. + + discounted_subtotal_lte : typing.Optional[int] + Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. + document_id : typing.Optional[str] Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). @@ -4505,8 +4796,14 @@ async def post_receivables_search( IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. entity_user_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables created by the entity users with the specified IDs. + + If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + + IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. id_in : typing.Optional[typing.Sequence[str]] + Return only receivables with the specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. issue_date_gt : typing.Optional[dt.datetime] Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. @@ -4521,21 +4818,56 @@ async def post_receivables_search( Return only non-draft receivables that were issued before or on the specified date and time. limit : typing.Optional[int] + The number of items (0 .. 250) to return in a single page of the response. Default is 100. The response may contain fewer items if it is the last or only page. + + When using pagination with a non-default limit, you must provide the `limit` value alongside `pagination_token` in all subsequent pagination requests. Unlike other pagination parameters, `limit` is not inferred from `pagination_token`. order : typing.Optional[OrderEnum] + Sort order (ascending by default). Typically used together with the `sort` parameter. pagination_token : typing.Optional[str] + A pagination token obtained from a previous call to `GET /receivables` or `POST /receivables/search`. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other parameters except `limit` are ignored and inferred from the initial query. + + If not specified, the first page of results will be returned. product_ids : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing all of the products with the specified IDs and optionally other products that are not specified. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productA, productB, productC + + `product_ids` = `[productA, productB]` will return receivables 3 and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. product_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables with line items containing at least one of the products with the specified IDs. + + For example, given receivables that contain the following products: + + 1. productA + 2. productB + 3. productA, productB + 4. productC + 5. productB, productC + + `product_ids__in` = `[productA, productB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent product IDs do not raise errors but produce no results. project_id : typing.Optional[str] Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. project_id_in : typing.Optional[typing.Sequence[str]] + Return only receivables that belong to one of the projects with the specified IDs. Valid but nonexistent project IDs do not raise errors but produce no results. sort : typing.Optional[ReceivableCursorFields2] + The field to sort the results by. Typically used together with the `order` parameter. status : typing.Optional[ReceivablesSearchRequestStatus] Return only receivables that have the specified status. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). @@ -4543,10 +4875,35 @@ async def post_receivables_search( To query multiple statuses at once, use the `status__in` parameter instead. status_in : typing.Optional[typing.Sequence[str]] + Return only receivables that have the specified statuses. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). tag_ids : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include all of the tags with the specified IDs and optionally other tags that are not specified. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagA, tagB, tagC + + `tag_ids` = `[tagA, tagB]` will return receivables 3 and 5. tag_ids_in : typing.Optional[typing.Sequence[str]] + Return only receivables whose [tags](https://docs.monite.com/common/tags) include at least one of the tags with the specified IDs. + + For example, given receivables with the following tags: + + 1. tagA + 2. tagB + 3. tagA, tagB + 4. tagC + 5. tagB, tagC + + `tag_ids__in` = `[tagA, tagB]` will return receivables 1, 2, 3, and 5. + + Valid but nonexistent tag IDs do not raise errors but produce no results. total_amount : typing.Optional[int] Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. @@ -4578,11 +4935,6 @@ async def post_receivables_search( "receivables/search", method="POST", json={ - "discounted_subtotal": discounted_subtotal, - "discounted_subtotal__gt": discounted_subtotal_gt, - "discounted_subtotal__gte": discounted_subtotal_gte, - "discounted_subtotal__lt": discounted_subtotal_lt, - "discounted_subtotal__lte": discounted_subtotal_lte, "based_on": based_on, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, @@ -4592,6 +4944,11 @@ async def post_receivables_search( "created_at__gte": created_at_gte, "created_at__lt": created_at_lt, "created_at__lte": created_at_lte, + "discounted_subtotal": discounted_subtotal, + "discounted_subtotal__gt": discounted_subtotal_gt, + "discounted_subtotal__gte": discounted_subtotal_gte, + "discounted_subtotal__lt": discounted_subtotal_lt, + "discounted_subtotal__lte": discounted_subtotal_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, @@ -4652,6 +5009,17 @@ async def post_receivables_search( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -4696,8 +5064,8 @@ async def post_receivables_search( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4743,6 +5111,17 @@ async def get_variables( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -4776,8 +5155,8 @@ async def get_variables( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4796,9 +5175,16 @@ async def get_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[ReceivableResponse]: """ + Returns the details of an existing accounts receivable invoice, quote, or credit note with the specified ID. + + The response fields vary depending on the document type. Use the `type` field to distinguish between different document types. + + Entity users with the `receivable.read.allowed_for_own` permission (rather than `allowed`) can access only documents that they created themselves. + Parameters ---------- receivable_id : str + ID of an existing invoice, quote, or credit note that you want to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -4878,8 +5264,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -4983,8 +5369,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5109,8 +5495,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5133,12 +5519,16 @@ async def accept_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[SuccessResult]: """ + Only quotes in the `issued` status can be accepted. + + When a quote is accepted, Monite automatically creates a draft invoice based on this quote. To find the newly created invoice, use `GET /receivables?based_on=QUOTE_ID`. + Parameters ---------- receivable_id : str signature : typing.Optional[Signature] - A digital signature, if required for quote acceptance + The counterpart's signature. Required if the quote field `signature_required` is `true`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -5238,8 +5628,8 @@ async def accept_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5343,8 +5733,8 @@ async def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5363,9 +5753,21 @@ async def clone_by_id( self, receivable_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[ReceivableResponse]: """ + Creates a copy of an existing accounts receivable invoice or quote. The original document can be in any status. The cloned document will have the `draft` status. + + Cloning a document requires that all of the referenced resource IDs (counterpart ID, product IDs, and others) still exist. + + Most of the original document's data is copied as is, with a few exceptions: + + * Some fields are not copied: `attachments`, `document_id`, `issue_date`, quote `expiry_date`. + * Counterpart details, entity bank account details, and entity VAT number are fetched anew from their corresponding IDs. + This means, for example, that if the counterpart details have been changed since the original invoice or quote was created, + the cloned document will use the current counterpart details rather than the old details from the original document. + Parameters ---------- receivable_id : str + ID of an existing invoice or quote that you want to clone. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -5456,8 +5858,8 @@ async def clone_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5480,6 +5882,8 @@ async def decline_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[SuccessResult]: """ + Only quotes in the `issued` status can be declined. + Parameters ---------- receivable_id : str @@ -5583,8 +5987,8 @@ async def decline_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5751,8 +6155,8 @@ async def get_history( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5859,8 +6263,8 @@ async def get_history_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -5972,8 +6376,8 @@ async def issue_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6102,8 +6506,8 @@ async def update_line_items_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6257,8 +6661,8 @@ async def get_mails( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6361,8 +6765,8 @@ async def get_mail_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6493,8 +6897,8 @@ async def mark_as_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6627,8 +7031,8 @@ async def mark_as_partially_paid_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6754,8 +7158,8 @@ async def mark_as_uncollectible_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6856,8 +7260,8 @@ async def get_pdf_link_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -6883,6 +7287,13 @@ async def preview_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[ReceivablePreviewResponse]: """ + You can preview emails only for documents in the following statuses: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + Parameters ---------- receivable_id : str @@ -6987,8 +7398,8 @@ async def preview_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -7013,6 +7424,17 @@ async def send_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[ReceivableSendResponse]: """ + Only documents in the following statuses can be sent via email: + + * Invoices: `draft`, `issued`, `overdue`, `partially_paid`, `paid`. + In the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance): also `canceled`. + * Quotes: `draft`, `issued`. + * Credit notes: `draft`, `issued`. + + Draft documents are automatically moved to the `issued` status before sending. + + For more information, see [Send an invoice via email](https://docs.monite.com/accounts-receivable/invoices/create#send-via-email). + Parameters ---------- receivable_id : str @@ -7125,8 +7547,8 @@ async def send_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -7258,8 +7680,8 @@ async def send_test_reminder_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -7360,8 +7782,8 @@ async def verify_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/recurrences/raw_client.py b/src/monite/recurrences/raw_client.py index a6594cc..11550c7 100644 --- a/src/monite/recurrences/raw_client.py +++ b/src/monite/recurrences/raw_client.py @@ -13,8 +13,8 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.automation_level import AutomationLevel @@ -114,8 +114,8 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Htt ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -306,8 +306,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -408,8 +408,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -588,8 +588,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -693,8 +693,8 @@ def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -808,8 +808,8 @@ def post_recurrences_id_pause( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -923,8 +923,8 @@ def post_recurrences_id_resume( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1028,8 +1028,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1220,8 +1220,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1322,8 +1322,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1502,8 +1502,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1607,8 +1607,8 @@ async def cancel_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1722,8 +1722,8 @@ async def post_recurrences_id_pause( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1837,8 +1837,8 @@ async def post_recurrences_id_resume( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/roles/client.py b/src/monite/roles/client.py index a7c8933..8b167ea 100644 --- a/src/monite/roles/client.py +++ b/src/monite/roles/client.py @@ -124,7 +124,7 @@ def create( Parameters ---------- name : str - Role name + The role name is case-sensitive and must be unique. permissions : BizObjectsSchemaInput Access permissions @@ -231,7 +231,7 @@ def update_by_id( role_id : str name : typing.Optional[str] - Role name + The new name for this role. Case-sensitive and must be unique. permissions : typing.Optional[BizObjectsSchemaInput] Access permissions @@ -379,7 +379,7 @@ async def create( Parameters ---------- name : str - Role name + The role name is case-sensitive and must be unique. permissions : BizObjectsSchemaInput Access permissions @@ -510,7 +510,7 @@ async def update_by_id( role_id : str name : typing.Optional[str] - Role name + The new name for this role. Case-sensitive and must be unique. permissions : typing.Optional[BizObjectsSchemaInput] Access permissions diff --git a/src/monite/roles/raw_client.py b/src/monite/roles/raw_client.py index 43df381..b7f14d2 100644 --- a/src/monite/roles/raw_client.py +++ b/src/monite/roles/raw_client.py @@ -15,9 +15,9 @@ from ..errors.bad_request_error import BadRequestError from ..errors.conflict_error import ConflictError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.biz_objects_schema_input import BizObjectsSchemaInput @@ -174,8 +174,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -199,7 +199,7 @@ def create( Parameters ---------- name : str - Role name + The role name is case-sensitive and must be unique. permissions : BizObjectsSchemaInput Access permissions @@ -248,6 +248,17 @@ def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -259,8 +270,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -317,6 +328,17 @@ def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -328,8 +350,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -380,6 +402,17 @@ def delete_roles_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -413,8 +446,8 @@ def delete_roles_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -445,7 +478,7 @@ def update_by_id( role_id : str name : typing.Optional[str] - Role name + The new name for this role. Case-sensitive and must be unique. permissions : typing.Optional[BizObjectsSchemaInput] Access permissions @@ -494,6 +527,17 @@ def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -505,8 +549,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -666,8 +710,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -691,7 +735,7 @@ async def create( Parameters ---------- name : str - Role name + The role name is case-sensitive and must be unique. permissions : BizObjectsSchemaInput Access permissions @@ -740,6 +784,17 @@ async def create( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -751,8 +806,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -809,6 +864,17 @@ async def get_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -820,8 +886,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -872,6 +938,17 @@ async def delete_roles_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), @@ -905,8 +982,8 @@ async def delete_roles_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -937,7 +1014,7 @@ async def update_by_id( role_id : str name : typing.Optional[str] - Role name + The new name for this role. Case-sensitive and must be unique. permissions : typing.Optional[BizObjectsSchemaInput] Access permissions @@ -986,6 +1063,17 @@ async def update_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -997,8 +1085,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/tags/raw_client.py b/src/monite/tags/raw_client.py index 1e4753b..9b86f00 100644 --- a/src/monite/tags/raw_client.py +++ b/src/monite/tags/raw_client.py @@ -11,9 +11,9 @@ from ..core.request_options import RequestOptions from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_acceptable_error import NotAcceptableError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.order_enum import OrderEnum @@ -155,8 +155,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -296,8 +296,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -411,8 +411,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -463,6 +463,17 @@ def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -507,8 +518,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -647,8 +658,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -793,8 +804,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -934,8 +945,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1049,8 +1060,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1101,6 +1112,17 @@ async def delete_by_id( ), ), ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), @@ -1145,8 +1167,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1285,8 +1307,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/text_templates/raw_client.py b/src/monite/text_templates/raw_client.py index 6a1f6cf..fefee00 100644 --- a/src/monite/text_templates/raw_client.py +++ b/src/monite/text_templates/raw_client.py @@ -9,7 +9,8 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.text_template_document_type_enum import TextTemplateDocumentTypeEnum from ..types.text_template_response import TextTemplateResponse @@ -71,6 +72,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -82,8 +94,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -153,6 +165,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -164,8 +187,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -213,6 +236,17 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -224,8 +258,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -266,6 +300,17 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -277,8 +322,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -344,6 +389,17 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -355,8 +411,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -405,6 +461,17 @@ def make_default_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -416,8 +483,8 @@ def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -484,6 +551,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -495,8 +573,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -566,6 +644,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -577,8 +666,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -626,6 +715,17 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -637,8 +737,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -679,6 +779,17 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -690,8 +801,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -757,6 +868,17 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -768,8 +890,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -818,6 +940,17 @@ async def make_default_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -829,8 +962,8 @@ async def make_default_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/types/__init__.py b/src/monite/types/__init__.py index ce2c72d..0def32a 100644 --- a/src/monite/types/__init__.py +++ b/src/monite/types/__init__.py @@ -24,13 +24,6 @@ from .action_enum import ActionEnum from .action_schema import ActionSchema from .aggregation_function_enum import AggregationFunctionEnum -from .airwallex_mandate import AirwallexMandate -from .airwallex_mandate_type import AirwallexMandateType -from .airwallex_mandate_version import AirwallexMandateVersion -from .airwallex_plaid_account import AirwallexPlaidAccount -from .airwallex_plaid_bank_account_verification_status import AirwallexPlaidBankAccountVerificationStatus -from .airwallex_plaid_institution import AirwallexPlaidInstitution -from .airwallex_plaid_verification import AirwallexPlaidVerification from .all_document_export_response_schema import AllDocumentExportResponseSchema from .all_overdue_reminders_response import AllOverdueRemindersResponse from .allowed_countries import AllowedCountries @@ -56,10 +49,10 @@ from .approval_request_resource_list import ApprovalRequestResourceList from .approval_request_resource_with_metadata import ApprovalRequestResourceWithMetadata from .approval_request_status import ApprovalRequestStatus +from .attachment_request import AttachmentRequest +from .attachment_response import AttachmentResponse from .automation_level import AutomationLevel from .bank_account import BankAccount -from .bank_account_verification_type import BankAccountVerificationType -from .bank_account_verifications import BankAccountVerifications from .based_on_receivable_created_event_data import BasedOnReceivableCreatedEventData from .based_on_transition_type import BasedOnTransitionType from .biz_objects_schema_input import BizObjectsSchemaInput @@ -74,11 +67,6 @@ from .comment_resource_list import CommentResourceList from .common_schema_input import CommonSchemaInput from .common_schema_output import CommonSchemaOutput -from .complete_refresh_verification_request import CompleteRefreshVerificationRequest -from .complete_refresh_verification_response import CompleteRefreshVerificationResponse -from .complete_verification_airwallex_plaid_request import CompleteVerificationAirwallexPlaidRequest -from .complete_verification_request import CompleteVerificationRequest -from .complete_verification_response import CompleteVerificationResponse from .connection_status import ConnectionStatus from .counterpart_address import CounterpartAddress from .counterpart_address_resource_list import CounterpartAddressResourceList @@ -93,6 +81,7 @@ CounterpartCreatePayload_Organization, ) from .counterpart_cursor_fields import CounterpartCursorFields +from .counterpart_einvoicing_credential_existence_response import CounterpartEinvoicingCredentialExistenceResponse from .counterpart_einvoicing_credential_response import CounterpartEinvoicingCredentialResponse from .counterpart_einvoicing_credential_response_list import CounterpartEinvoicingCredentialResponseList from .counterpart_einvoicing_credential_schema import CounterpartEinvoicingCredentialSchema @@ -129,7 +118,6 @@ ) from .create_counterpart_einvoicing_credential_payload import CreateCounterpartEinvoicingCredentialPayload from .create_export_task_response_schema import CreateExportTaskResponseSchema -from .create_onboarding_link_request import CreateOnboardingLinkRequest from .credit_note_cursor_fields import CreditNoteCursorFields from .credit_note_dimension_enum import CreditNoteDimensionEnum from .credit_note_fields_allowed_for_validate import CreditNoteFieldsAllowedForValidate @@ -195,6 +183,8 @@ from .document_id_separators import DocumentIdSeparators from .document_object_type_request_enum import DocumentObjectTypeRequestEnum from .document_rendering_settings import DocumentRenderingSettings +from .document_rendering_settings_input import DocumentRenderingSettingsInput +from .document_rendering_settings_output import DocumentRenderingSettingsOutput from .document_type_enum import DocumentTypeEnum from .document_type_prefix import DocumentTypePrefix from .domain_list_response import DomainListResponse @@ -285,9 +275,11 @@ from .ledger_account_list_response import LedgerAccountListResponse from .ledger_account_response import LedgerAccountResponse from .line_item import LineItem +from .line_item_column_settings import LineItemColumnSettings from .line_item_cursor_fields import LineItemCursorFields from .line_item_fields import LineItemFields from .line_item_internal_request import LineItemInternalRequest +from .line_item_numeric_column_settings import LineItemNumericColumnSettings from .line_item_pagination_response import LineItemPaginationResponse from .line_item_product import LineItemProduct from .line_item_product_create import LineItemProductCreate @@ -296,6 +288,7 @@ from .line_item_request import LineItemRequest from .line_item_response import LineItemResponse from .line_item_update import LineItemUpdate +from .line_items_rendering_settings import LineItemsRenderingSettings from .line_items_replace_response import LineItemsReplaceResponse from .line_items_response import LineItemsResponse from .mail_sent_event_data import MailSentEventData @@ -308,6 +301,7 @@ from .missing_line_item_fields import MissingLineItemFields from .monite_all_payment_methods import MoniteAllPaymentMethods from .monite_all_payment_methods_types import MoniteAllPaymentMethodsTypes +from .next_document_numbers import NextDocumentNumbers from .object_match_types import ObjectMatchTypes from .object_type import ObjectType from .object_type_available_comment import ObjectTypeAvailableComment @@ -336,9 +330,6 @@ ) from .ocr_task_status import OcrTaskStatus from .ocr_tasks_pagination_response import OcrTasksPaginationResponse -from .onboarding_link_public_response import OnboardingLinkPublicResponse -from .onboarding_link_request import OnboardingLinkRequest -from .onboarding_link_response import OnboardingLinkResponse from .onboarding_payment_methods_response import OnboardingPaymentMethodsResponse from .onboarding_requirements_error import OnboardingRequirementsError from .onboarding_requirements_response import OnboardingRequirementsResponse @@ -412,16 +403,13 @@ from .payment_intent_cursor_fields import PaymentIntentCursorFields from .payment_intent_history import PaymentIntentHistory from .payment_intent_history_response import PaymentIntentHistoryResponse -from .payment_intent_payout_method import PaymentIntentPayoutMethod from .payment_intent_response import PaymentIntentResponse from .payment_intents_list_response import PaymentIntentsListResponse -from .payment_intents_recipient import PaymentIntentsRecipient from .payment_method import PaymentMethod from .payment_method_direction import PaymentMethodDirection from .payment_method_requirements import PaymentMethodRequirements from .payment_method_status import PaymentMethodStatus from .payment_object import PaymentObject -from .payment_object_payable import PaymentObjectPayable from .payment_object_type import PaymentObjectType from .payment_page_theme import PaymentPageTheme from .payment_priority_enum import PaymentPriorityEnum @@ -439,9 +427,6 @@ from .payment_terms import PaymentTerms from .payment_terms_list_response import PaymentTermsListResponse from .payment_terms_response import PaymentTermsResponse -from .payments_batch_payment_request import PaymentsBatchPaymentRequest -from .payments_batch_payment_response import PaymentsBatchPaymentResponse -from .payments_batch_payment_status import PaymentsBatchPaymentStatus from .payments_settings_input import PaymentsSettingsInput from .payments_settings_output import PaymentsSettingsOutput from .permission_enum import PermissionEnum @@ -493,6 +478,12 @@ QuoteResponsePayloadEntity_Organization, ) from .quote_state_enum import QuoteStateEnum +from .receipt_cursor_fields import ReceiptCursorFields +from .receipt_line_item_cursor_fields import ReceiptLineItemCursorFields +from .receipt_line_item_response_schema import ReceiptLineItemResponseSchema +from .receipt_line_items_pagination_response import ReceiptLineItemsPaginationResponse +from .receipt_pagination_response import ReceiptPaginationResponse +from .receipt_response_schema import ReceiptResponseSchema from .receivable_counterpart_contact import ReceivableCounterpartContact from .receivable_counterpart_vat_id_response import ReceivableCounterpartVatIdResponse from .receivable_create_based_on_payload import ReceivableCreateBasedOnPayload @@ -551,9 +542,7 @@ from .receivables_send_response import ReceivablesSendResponse from .receivables_status_enum import ReceivablesStatusEnum from .receivables_verify_response import ReceivablesVerifyResponse -from .recipient import Recipient from .recipient_account_response import RecipientAccountResponse -from .recipient_type import RecipientType from .recipients import Recipients from .recurrence_frequency import RecurrenceFrequency from .recurrence_iteration import RecurrenceIteration @@ -595,6 +584,7 @@ RootSchemaInput_Person, RootSchemaInput_Product, RootSchemaInput_Project, + RootSchemaInput_Receipt, RootSchemaInput_Receivable, RootSchemaInput_Reconciliation, RootSchemaInput_Role, @@ -628,6 +618,7 @@ RootSchemaOutput_Person, RootSchemaOutput_Product, RootSchemaOutput_Project, + RootSchemaOutput_Receipt, RootSchemaOutput_Receivable, RootSchemaOutput_Reconciliation, RootSchemaOutput_Role, @@ -641,13 +632,14 @@ from .settings_response import SettingsResponse from .signature import Signature from .single_onboarding_requirements_response import SingleOnboardingRequirementsResponse -from .single_payment_intent import SinglePaymentIntent -from .single_payment_intent_response import SinglePaymentIntentResponse from .source_of_payable_data_enum import SourceOfPayableDataEnum +from .source_of_receipt_data_enum import SourceOfReceiptDataEnum from .status_changed_event_data import StatusChangedEventData from .status_enum import StatusEnum from .success_result import SuccessResult +from .suggested_counterpart_payload import SuggestedCounterpartPayload from .suggested_payment_term import SuggestedPaymentTerm +from .suggested_response import SuggestedResponse from .supported_field_names import SupportedFieldNames from .supported_format_schema import SupportedFormatSchema from .supported_format_schema_object_type import SupportedFormatSchemaObjectType @@ -712,11 +704,7 @@ from .vat_rate_list_response import VatRateListResponse from .vat_rate_response import VatRateResponse from .vat_rate_status_enum import VatRateStatusEnum -from .verification_airwallex_plaid_request import VerificationAirwallexPlaidRequest -from .verification_airwallex_plaid_response import VerificationAirwallexPlaidResponse from .verification_error import VerificationError -from .verification_request import VerificationRequest -from .verification_response import VerificationResponse from .verification_status_enum import VerificationStatusEnum from .verify_response import VerifyResponse from .wc_business_status import WcBusinessStatus @@ -756,13 +744,6 @@ "ActionEnum", "ActionSchema", "AggregationFunctionEnum", - "AirwallexMandate", - "AirwallexMandateType", - "AirwallexMandateVersion", - "AirwallexPlaidAccount", - "AirwallexPlaidBankAccountVerificationStatus", - "AirwallexPlaidInstitution", - "AirwallexPlaidVerification", "AllDocumentExportResponseSchema", "AllOverdueRemindersResponse", "AllowedCountries", @@ -788,10 +769,10 @@ "ApprovalRequestResourceList", "ApprovalRequestResourceWithMetadata", "ApprovalRequestStatus", + "AttachmentRequest", + "AttachmentResponse", "AutomationLevel", "BankAccount", - "BankAccountVerificationType", - "BankAccountVerifications", "BasedOnReceivableCreatedEventData", "BasedOnTransitionType", "BizObjectsSchemaInput", @@ -806,11 +787,6 @@ "CommentResourceList", "CommonSchemaInput", "CommonSchemaOutput", - "CompleteRefreshVerificationRequest", - "CompleteRefreshVerificationResponse", - "CompleteVerificationAirwallexPlaidRequest", - "CompleteVerificationRequest", - "CompleteVerificationResponse", "ConnectionStatus", "CounterpartAddress", "CounterpartAddressResourceList", @@ -823,6 +799,7 @@ "CounterpartCreatePayload_Individual", "CounterpartCreatePayload_Organization", "CounterpartCursorFields", + "CounterpartEinvoicingCredentialExistenceResponse", "CounterpartEinvoicingCredentialResponse", "CounterpartEinvoicingCredentialResponseList", "CounterpartEinvoicingCredentialSchema", @@ -857,7 +834,6 @@ "CreateCounterpartEinvoicingCredentialCounterpartVatId", "CreateCounterpartEinvoicingCredentialPayload", "CreateExportTaskResponseSchema", - "CreateOnboardingLinkRequest", "CreditNoteCursorFields", "CreditNoteDimensionEnum", "CreditNoteFieldsAllowedForValidate", @@ -919,6 +895,8 @@ "DocumentIdSeparators", "DocumentObjectTypeRequestEnum", "DocumentRenderingSettings", + "DocumentRenderingSettingsInput", + "DocumentRenderingSettingsOutput", "DocumentTypeEnum", "DocumentTypePrefix", "DomainListResponse", @@ -1011,9 +989,11 @@ "LedgerAccountListResponse", "LedgerAccountResponse", "LineItem", + "LineItemColumnSettings", "LineItemCursorFields", "LineItemFields", "LineItemInternalRequest", + "LineItemNumericColumnSettings", "LineItemPaginationResponse", "LineItemProduct", "LineItemProductCreate", @@ -1022,6 +1002,7 @@ "LineItemRequest", "LineItemResponse", "LineItemUpdate", + "LineItemsRenderingSettings", "LineItemsReplaceResponse", "LineItemsResponse", "MailSentEventData", @@ -1034,6 +1015,7 @@ "MissingLineItemFields", "MoniteAllPaymentMethods", "MoniteAllPaymentMethodsTypes", + "NextDocumentNumbers", "ObjectMatchTypes", "ObjectType", "ObjectTypeAvailableComment", @@ -1060,9 +1042,6 @@ "OcrTaskResponseSchemaRecognizedData_Receipt", "OcrTaskStatus", "OcrTasksPaginationResponse", - "OnboardingLinkPublicResponse", - "OnboardingLinkRequest", - "OnboardingLinkResponse", "OnboardingPaymentMethodsResponse", "OnboardingRequirementsError", "OnboardingRequirementsResponse", @@ -1136,16 +1115,13 @@ "PaymentIntentCursorFields", "PaymentIntentHistory", "PaymentIntentHistoryResponse", - "PaymentIntentPayoutMethod", "PaymentIntentResponse", "PaymentIntentsListResponse", - "PaymentIntentsRecipient", "PaymentMethod", "PaymentMethodDirection", "PaymentMethodRequirements", "PaymentMethodStatus", "PaymentObject", - "PaymentObjectPayable", "PaymentObjectType", "PaymentPageTheme", "PaymentPriorityEnum", @@ -1163,9 +1139,6 @@ "PaymentTerms", "PaymentTermsListResponse", "PaymentTermsResponse", - "PaymentsBatchPaymentRequest", - "PaymentsBatchPaymentResponse", - "PaymentsBatchPaymentStatus", "PaymentsSettingsInput", "PaymentsSettingsOutput", "PermissionEnum", @@ -1215,6 +1188,12 @@ "QuoteResponsePayloadEntity_Individual", "QuoteResponsePayloadEntity_Organization", "QuoteStateEnum", + "ReceiptCursorFields", + "ReceiptLineItemCursorFields", + "ReceiptLineItemResponseSchema", + "ReceiptLineItemsPaginationResponse", + "ReceiptPaginationResponse", + "ReceiptResponseSchema", "ReceivableCounterpartContact", "ReceivableCounterpartVatIdResponse", "ReceivableCreateBasedOnPayload", @@ -1271,9 +1250,7 @@ "ReceivablesSendResponse", "ReceivablesStatusEnum", "ReceivablesVerifyResponse", - "Recipient", "RecipientAccountResponse", - "RecipientType", "Recipients", "RecurrenceFrequency", "RecurrenceIteration", @@ -1314,6 +1291,7 @@ "RootSchemaInput_Person", "RootSchemaInput_Product", "RootSchemaInput_Project", + "RootSchemaInput_Receipt", "RootSchemaInput_Receivable", "RootSchemaInput_Reconciliation", "RootSchemaInput_Role", @@ -1345,6 +1323,7 @@ "RootSchemaOutput_Person", "RootSchemaOutput_Product", "RootSchemaOutput_Project", + "RootSchemaOutput_Receipt", "RootSchemaOutput_Receivable", "RootSchemaOutput_Reconciliation", "RootSchemaOutput_Role", @@ -1357,13 +1336,14 @@ "SettingsResponse", "Signature", "SingleOnboardingRequirementsResponse", - "SinglePaymentIntent", - "SinglePaymentIntentResponse", "SourceOfPayableDataEnum", + "SourceOfReceiptDataEnum", "StatusChangedEventData", "StatusEnum", "SuccessResult", + "SuggestedCounterpartPayload", "SuggestedPaymentTerm", + "SuggestedResponse", "SupportedFieldNames", "SupportedFormatSchema", "SupportedFormatSchemaObjectType", @@ -1426,11 +1406,7 @@ "VatRateListResponse", "VatRateResponse", "VatRateStatusEnum", - "VerificationAirwallexPlaidRequest", - "VerificationAirwallexPlaidResponse", "VerificationError", - "VerificationRequest", - "VerificationResponse", "VerificationStatusEnum", "VerifyResponse", "WcBusinessStatus", diff --git a/src/monite/types/access_token_response.py b/src/monite/types/access_token_response.py index 7c69b28..6044d8f 100644 --- a/src/monite/types/access_token_response.py +++ b/src/monite/types/access_token_response.py @@ -7,9 +7,20 @@ class AccessTokenResponse(UniversalBaseModel): - access_token: str - expires_in: int - token_type: str + access_token: str = pydantic.Field() + """ + The access token. Send it in the `Authorization: Bearer ACCESS_TOKEN` header in subsequent API calls. + """ + + expires_in: int = pydantic.Field() + """ + The token expiration time, in seconds. + """ + + token_type: str = pydantic.Field() + """ + Always "Bearer". + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/airwallex_mandate.py b/src/monite/types/airwallex_mandate.py deleted file mode 100644 index 0dc3b9c..0000000 --- a/src/monite/types/airwallex_mandate.py +++ /dev/null @@ -1,32 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .airwallex_mandate_type import AirwallexMandateType -from .airwallex_mandate_version import AirwallexMandateVersion - - -class AirwallexMandate(UniversalBaseModel): - email: str = pydantic.Field() - """ - PDF copy of mandate will be sent to the email by Airwallex - """ - - signatory: str = pydantic.Field() - """ - Name of the person signed the mandate, must be a bank account owner - """ - - type: AirwallexMandateType = "us_ach_debit" - version: AirwallexMandateVersion = "1.0" - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/airwallex_mandate_type.py b/src/monite/types/airwallex_mandate_type.py deleted file mode 100644 index 12c4fe2..0000000 --- a/src/monite/types/airwallex_mandate_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -AirwallexMandateType = typing.Literal["us_ach_debit"] diff --git a/src/monite/types/airwallex_plaid_bank_account_verification_status.py b/src/monite/types/airwallex_plaid_bank_account_verification_status.py deleted file mode 100644 index d01a1e1..0000000 --- a/src/monite/types/airwallex_plaid_bank_account_verification_status.py +++ /dev/null @@ -1,7 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -AirwallexPlaidBankAccountVerificationStatus = typing.Union[ - typing.Literal["verified", "expired", "suspended"], typing.Any -] diff --git a/src/monite/types/allowed_file_types.py b/src/monite/types/allowed_file_types.py index 79e6c6d..0951a23 100644 --- a/src/monite/types/allowed_file_types.py +++ b/src/monite/types/allowed_file_types.py @@ -18,6 +18,7 @@ "additional_identity_documents", "receivable_signatures", "einvoices_xml", + "attachments", ], typing.Any, ] diff --git a/src/monite/types/approval_policy_resource.py b/src/monite/types/approval_policy_resource.py index 5c33452..54ccc2b 100644 --- a/src/monite/types/approval_policy_resource.py +++ b/src/monite/types/approval_policy_resource.py @@ -30,6 +30,11 @@ class ApprovalPolicyResource(UniversalBaseModel): The name of the approval policy. """ + priority: typing.Optional[int] = pydantic.Field(default=None) + """ + The priority controls which approval policy takes precedence when a payable matches multiple approval policies. A higher value mean higher priority. + """ + script: typing.List[ApprovalPolicyResourceScriptItem] = pydantic.Field() """ A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. diff --git a/src/monite/types/approval_process_step_resource.py b/src/monite/types/approval_process_step_resource.py index 1d881b9..e7050ab 100644 --- a/src/monite/types/approval_process_step_resource.py +++ b/src/monite/types/approval_process_step_resource.py @@ -8,6 +8,7 @@ class ApprovalProcessStepResource(UniversalBaseModel): + approval_request_id: typing.Optional[str] = None approved_by: typing.List[str] object_id: str rejected_by: typing.Optional[str] = None diff --git a/src/monite/types/airwallex_plaid_verification.py b/src/monite/types/attachment_request.py similarity index 61% rename from src/monite/types/airwallex_plaid_verification.py rename to src/monite/types/attachment_request.py index 7642e0a..550e9db 100644 --- a/src/monite/types/airwallex_plaid_verification.py +++ b/src/monite/types/attachment_request.py @@ -4,13 +4,17 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .airwallex_plaid_bank_account_verification_status import AirwallexPlaidBankAccountVerificationStatus -class AirwallexPlaidVerification(UniversalBaseModel): - status: AirwallexPlaidBankAccountVerificationStatus = pydantic.Field() +class AttachmentRequest(UniversalBaseModel): + id: str = pydantic.Field() """ - Status of the bank account verification + Unique ID of the file with file_type=attachment from /v1/files. + """ + + include_in_email: typing.Optional[bool] = pydantic.Field(default=None) + """ + Indicates whether the file would be included in the email. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/attachment_response.py b/src/monite/types/attachment_response.py new file mode 100644 index 0000000..ade6f98 --- /dev/null +++ b/src/monite/types/attachment_response.py @@ -0,0 +1,47 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class AttachmentResponse(UniversalBaseModel): + id: str = pydantic.Field() + """ + Unique ID of the file with file_type=attachment from /v1/files. + """ + + include_in_email: typing.Optional[bool] = pydantic.Field(default=None) + """ + Indicates whether the file would be included in the email. + """ + + mimetype: str = pydantic.Field() + """ + The file's media type, for example, `application/pdf` or `image/png`. + """ + + name: str = pydantic.Field() + """ + The original file name (if available). + """ + + size: int = pydantic.Field() + """ + The file size in bytes. + """ + + url: str = pydantic.Field() + """ + The URL to download the file. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/bank_account_verification_type.py b/src/monite/types/bank_account_verification_type.py deleted file mode 100644 index 72ce47b..0000000 --- a/src/monite/types/bank_account_verification_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -BankAccountVerificationType = typing.Union[typing.Literal["airwallex_plaid", "micro_deposit"], typing.Any] diff --git a/src/monite/types/button_theme.py b/src/monite/types/button_theme.py index c163a74..47f22c2 100644 --- a/src/monite/types/button_theme.py +++ b/src/monite/types/button_theme.py @@ -8,9 +8,20 @@ class ButtonTheme(UniversalBaseModel): primary_color: typing.Optional[str] = None - primary_hover_color: typing.Optional[str] = None - secondary_color: typing.Optional[str] = None - secondary_hover_color: typing.Optional[str] = None + primary_hover_color: typing.Optional[str] = pydantic.Field(default=None) + """ + Unused. + """ + + secondary_color: typing.Optional[str] = pydantic.Field(default=None) + """ + Unused. + """ + + secondary_hover_color: typing.Optional[str] = pydantic.Field(default=None) + """ + Unused. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/complete_refresh_verification_request.py b/src/monite/types/complete_refresh_verification_request.py deleted file mode 100644 index 25a0d16..0000000 --- a/src/monite/types/complete_refresh_verification_request.py +++ /dev/null @@ -1,20 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .bank_account_verification_type import BankAccountVerificationType - - -class CompleteRefreshVerificationRequest(UniversalBaseModel): - type: BankAccountVerificationType - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/complete_refresh_verification_response.py b/src/monite/types/complete_refresh_verification_response.py deleted file mode 100644 index 9c50cdb..0000000 --- a/src/monite/types/complete_refresh_verification_response.py +++ /dev/null @@ -1,20 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .bank_account_verifications import BankAccountVerifications - - -class CompleteRefreshVerificationResponse(UniversalBaseModel): - verifications: BankAccountVerifications - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/complete_verification_airwallex_plaid_request.py b/src/monite/types/complete_verification_airwallex_plaid_request.py deleted file mode 100644 index e628f08..0000000 --- a/src/monite/types/complete_verification_airwallex_plaid_request.py +++ /dev/null @@ -1,36 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .airwallex_mandate import AirwallexMandate -from .airwallex_plaid_account import AirwallexPlaidAccount -from .airwallex_plaid_institution import AirwallexPlaidInstitution - - -class CompleteVerificationAirwallexPlaidRequest(UniversalBaseModel): - account: AirwallexPlaidAccount = pydantic.Field() - """ - The bank account that was selected in the Plaid Modal - """ - - institution: AirwallexPlaidInstitution = pydantic.Field() - """ - The financial institution that was selected in the Plaid Modal - """ - - mandate: AirwallexMandate - public_token: str = pydantic.Field() - """ - The Plaid Public Token - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/complete_verification_request.py b/src/monite/types/complete_verification_request.py deleted file mode 100644 index 51de03f..0000000 --- a/src/monite/types/complete_verification_request.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .bank_account_verification_type import BankAccountVerificationType -from .complete_verification_airwallex_plaid_request import CompleteVerificationAirwallexPlaidRequest - - -class CompleteVerificationRequest(UniversalBaseModel): - airwallex_plaid: CompleteVerificationAirwallexPlaidRequest - type: BankAccountVerificationType - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/complete_verification_response.py b/src/monite/types/complete_verification_response.py deleted file mode 100644 index ca92b40..0000000 --- a/src/monite/types/complete_verification_response.py +++ /dev/null @@ -1,72 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .allowed_countries import AllowedCountries -from .bank_account_verifications import BankAccountVerifications -from .currency_enum import CurrencyEnum - - -class CompleteVerificationResponse(UniversalBaseModel): - id: str = pydantic.Field() - """ - Deprecated. Use bank_account_id instead. - """ - - account_holder_name: typing.Optional[str] = pydantic.Field(default=None) - """ - Account holder's name - """ - - account_number: typing.Optional[str] = pydantic.Field(default=None) - """ - Account number (required if IBAN is not provided) - """ - - bank_account_id: str - bank_name: typing.Optional[str] = pydantic.Field(default=None) - """ - The name of the entity`s bank account. - """ - - bic: typing.Optional[str] = pydantic.Field(default=None) - """ - The BIC of the entity`s bank account. - """ - - country: typing.Optional[AllowedCountries] = None - currency: typing.Optional[CurrencyEnum] = None - display_name: typing.Optional[str] = None - iban: typing.Optional[str] = pydantic.Field(default=None) - """ - The IBAN of the entity`s bank account. - """ - - is_default: bool = pydantic.Field() - """ - Marks if a bank account should be used by default for the currency. Only 1 can be True for each currency. - """ - - routing_number: typing.Optional[str] = pydantic.Field(default=None) - """ - Routing number (US) - """ - - sort_code: typing.Optional[str] = pydantic.Field(default=None) - """ - Sort code (GB) - """ - - verifications: BankAccountVerifications - was_created_by_user_id: typing.Optional[str] = None - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/counterpart_address.py b/src/monite/types/counterpart_address.py index c65f980..8a5944e 100644 --- a/src/monite/types/counterpart_address.py +++ b/src/monite/types/counterpart_address.py @@ -39,7 +39,7 @@ class CounterpartAddress(UniversalBaseModel): state: typing.Optional[str] = pydantic.Field(default=None) """ - State, region, province, or county. + State, county, province, prefecture, region, or similar component of the counterpart's address. For US counterparts, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/airwallex_plaid_institution.py b/src/monite/types/counterpart_einvoicing_credential_existence_response.py similarity index 68% rename from src/monite/types/airwallex_plaid_institution.py rename to src/monite/types/counterpart_einvoicing_credential_existence_response.py index 60e3468..30f775d 100644 --- a/src/monite/types/airwallex_plaid_institution.py +++ b/src/monite/types/counterpart_einvoicing_credential_existence_response.py @@ -6,15 +6,10 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -class AirwallexPlaidInstitution(UniversalBaseModel): - id: str = pydantic.Field() +class CounterpartEinvoicingCredentialExistenceResponse(UniversalBaseModel): + exists: bool = pydantic.Field() """ - The institution identifier assigned by Plaid - """ - - name: str = pydantic.Field() - """ - The full financial institution name + `true` is the specified identifier is registered as a receiver in PEPPOL, and `false` otherwise. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/counterpart_individual_root_response.py b/src/monite/types/counterpart_individual_root_response.py index bb6db67..43a8143 100644 --- a/src/monite/types/counterpart_individual_root_response.py +++ b/src/monite/types/counterpart_individual_root_response.py @@ -35,6 +35,11 @@ class CounterpartIndividualRootResponse(UniversalBaseModel): `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. """ + created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Entity user ID of counterpart creator. + """ + default_billing_address_id: typing.Optional[str] = pydantic.Field(default=None) """ ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. @@ -45,11 +50,6 @@ class CounterpartIndividualRootResponse(UniversalBaseModel): ID of the shipping address. """ - created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) - """ - Entity user ID of counterpart creator. - """ - external_reference: typing.Optional[str] = pydantic.Field(default=None) """ A user-defined identifier of the counterpart. For example, the customer or vendor reference number in the entity's CRM system. If specified, it will be displayed in PDF invoices and other accounts receivable documents created by the entity. diff --git a/src/monite/types/counterpart_organization_root_response.py b/src/monite/types/counterpart_organization_root_response.py index 722fad1..9fc7d20 100644 --- a/src/monite/types/counterpart_organization_root_response.py +++ b/src/monite/types/counterpart_organization_root_response.py @@ -35,6 +35,11 @@ class CounterpartOrganizationRootResponse(UniversalBaseModel): `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. """ + created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Entity user ID of counterpart creator. + """ + default_billing_address_id: typing.Optional[str] = pydantic.Field(default=None) """ ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. @@ -45,11 +50,6 @@ class CounterpartOrganizationRootResponse(UniversalBaseModel): ID of the shipping address. """ - created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) - """ - Entity user ID of counterpart creator. - """ - external_reference: typing.Optional[str] = pydantic.Field(default=None) """ A user-defined identifier of the counterpart. For example, the customer or vendor reference number in the entity's CRM system. If specified, it will be displayed in PDF invoices and other accounts receivable documents created by the entity. diff --git a/src/monite/types/counterpart_raw_bank_account.py b/src/monite/types/counterpart_raw_bank_account.py index 5af993c..ca50da5 100644 --- a/src/monite/types/counterpart_raw_bank_account.py +++ b/src/monite/types/counterpart_raw_bank_account.py @@ -27,6 +27,11 @@ class CounterpartRawBankAccount(UniversalBaseModel): required for non-GB bank accounts """ + routing_number: typing.Optional[str] = pydantic.Field(default=None) + """ + required for US bank accounts + """ + sort_code: typing.Optional[str] = pydantic.Field(default=None) """ required for GB bank accounts diff --git a/src/monite/types/counterpart_raw_bank_account_update_request.py b/src/monite/types/counterpart_raw_bank_account_update_request.py index c8494f4..b2a3931 100644 --- a/src/monite/types/counterpart_raw_bank_account_update_request.py +++ b/src/monite/types/counterpart_raw_bank_account_update_request.py @@ -27,6 +27,11 @@ class CounterpartRawBankAccountUpdateRequest(UniversalBaseModel): required for non-GB bank accounts """ + routing_number: typing.Optional[str] = pydantic.Field(default=None) + """ + required for US bank accounts + """ + sort_code: typing.Optional[str] = pydantic.Field(default=None) """ required for GB bank accounts diff --git a/src/monite/types/create_onboarding_link_request.py b/src/monite/types/create_onboarding_link_request.py deleted file mode 100644 index 6f7cd84..0000000 --- a/src/monite/types/create_onboarding_link_request.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .recipient import Recipient - - -class CreateOnboardingLinkRequest(UniversalBaseModel): - recipient: Recipient - refresh_url: str - return_url: str - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/credit_note_response_payload.py b/src/monite/types/credit_note_response_payload.py index 047a288..12ba209 100644 --- a/src/monite/types/credit_note_response_payload.py +++ b/src/monite/types/credit_note_response_payload.py @@ -5,11 +5,13 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_response import AttachmentResponse from .counterpart_type import CounterpartType from .credit_note_response_payload_entity import CreditNoteResponsePayloadEntity from .credit_note_state_enum import CreditNoteStateEnum from .currency_enum import CurrencyEnum from .discount_response import DiscountResponse +from .document_rendering_settings import DocumentRenderingSettings from .einvoicing_credentials import EinvoicingCredentials from .language_code_enum import LanguageCodeEnum from .receivable_counterpart_contact import ReceivableCounterpartContact @@ -36,6 +38,11 @@ class CreditNoteResponsePayload(UniversalBaseModel): Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. """ + attachments: typing.Optional[typing.List[AttachmentResponse]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + based_on: typing.Optional[str] = pydantic.Field(default=None) """ The unique ID of a previous document related to the receivable if applicable. @@ -136,6 +143,11 @@ class CreditNoteResponsePayload(UniversalBaseModel): The sequential code systematically assigned to invoices. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + due_date: typing.Optional[str] = pydantic.Field(default=None) """ Optional field representing date until which invoice should be paid @@ -172,7 +184,12 @@ class CreditNoteResponsePayload(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. See also: `memo`, `commercial_condition_description`. + """ + + is_einvoice: typing.Optional[bool] = pydantic.Field(default=None) + """ + If `true`, the credit note will be sent through an e-invoicing network. The value is inherited from the invoice for which the credit note was created, and cannot be changed. """ issue_date: typing.Optional[dt.datetime] = pydantic.Field(default=None) @@ -183,7 +200,7 @@ class CreditNoteResponsePayload(UniversalBaseModel): line_items: typing.List[ResponseItem] memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable. + An optional note for the customer, displayed above the line items table in the PDF. See also: `footer`, `commercial_condition_description`. """ network_credentials: typing.Optional[EinvoicingCredentials] = pydantic.Field(default=None) @@ -208,7 +225,7 @@ class CreditNoteResponsePayload(UniversalBaseModel): project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this credit note. If specified, the project name will be included in the header of the PDF credit note. """ purchase_order: typing.Optional[str] = pydantic.Field(default=None) diff --git a/src/monite/types/delivery_note_create_request.py b/src/monite/types/delivery_note_create_request.py index a2b11b0..d3ef81d 100644 --- a/src/monite/types/delivery_note_create_request.py +++ b/src/monite/types/delivery_note_create_request.py @@ -49,7 +49,7 @@ class DeliveryNoteCreateRequest(UniversalBaseModel): memo: typing.Optional[str] = pydantic.Field(default=None) """ - Additional information regarding the delivery note + An optional note for the customer, displayed above the line items table in the PDF. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/delivery_note_resource.py b/src/monite/types/delivery_note_resource.py index ff06621..ac83063 100644 --- a/src/monite/types/delivery_note_resource.py +++ b/src/monite/types/delivery_note_resource.py @@ -112,7 +112,7 @@ class DeliveryNoteResource(UniversalBaseModel): memo: typing.Optional[str] = pydantic.Field(default=None) """ - Additional information regarding the delivery note + An optional note for the customer, displayed above the line items table in the PDF. """ original_file_language: LanguageCodeEnum = pydantic.Field() diff --git a/src/monite/types/document_rendering_settings.py b/src/monite/types/document_rendering_settings.py index 4b7fc68..b972373 100644 --- a/src/monite/types/document_rendering_settings.py +++ b/src/monite/types/document_rendering_settings.py @@ -6,23 +6,43 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .credit_note_rendering_settings import CreditNoteRenderingSettings from .invoice_rendering_settings import InvoiceRenderingSettings +from .line_items_rendering_settings import LineItemsRenderingSettings from .quote_rendering_settings import QuoteRenderingSettings class DocumentRenderingSettings(UniversalBaseModel): + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + credit_note: typing.Optional[CreditNoteRenderingSettings] = pydantic.Field(default=None) """ - Settings for rendering credit notes in PDF documents. + Credit note-specific rendering settings for PDF documents. + """ + + display_entity_bank_account: typing.Optional[bool] = pydantic.Field(default=None) + """ + If set to `true`, the entity's bank account details will be displayed on the PDF documents. Defaults to `true`. + """ + + display_line_items: typing.Optional[bool] = pydantic.Field(default=None) + """ + If set to `true`, the line items table will be displayed on the quote PDF. Defaults to `true`. """ invoice: typing.Optional[InvoiceRenderingSettings] = pydantic.Field(default=None) """ - Settings for rendering invoices in PDF documents. + Invoice-specific rendering settings for PDF documents. + """ + + line_items: typing.Optional[LineItemsRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering line items in PDF documents. """ quote: typing.Optional[QuoteRenderingSettings] = pydantic.Field(default=None) """ - Settings for rendering quotes in PDF documents. + Quote-specific rendering settings for PDF documents. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/document_rendering_settings_input.py b/src/monite/types/document_rendering_settings_input.py new file mode 100644 index 0000000..1cdf6bb --- /dev/null +++ b/src/monite/types/document_rendering_settings_input.py @@ -0,0 +1,57 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .credit_note_rendering_settings import CreditNoteRenderingSettings +from .invoice_rendering_settings import InvoiceRenderingSettings +from .line_items_rendering_settings import LineItemsRenderingSettings +from .quote_rendering_settings import QuoteRenderingSettings + + +class DocumentRenderingSettingsInput(UniversalBaseModel): + """ + Rendering settings that control how different parts of the PDF documents are displayed. + Includes common settings for all document types such as quotes, invoices, and credit notes and document + type-specific settings that are defined in their respective objects. + """ + + credit_note: typing.Optional[CreditNoteRenderingSettings] = pydantic.Field(default=None) + """ + Credit note-specific rendering settings for PDF documents. + """ + + display_entity_bank_account: typing.Optional[bool] = pydantic.Field(default=None) + """ + If set to `true`, the entity's bank account details will be displayed on the PDF documents. Defaults to `true`. + """ + + display_line_items: typing.Optional[bool] = pydantic.Field(default=None) + """ + If set to `true`, the line items table will be displayed on the quote PDF. Defaults to `true`. + """ + + invoice: typing.Optional[InvoiceRenderingSettings] = pydantic.Field(default=None) + """ + Invoice-specific rendering settings for PDF documents. + """ + + line_items: typing.Optional[LineItemsRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering line items in PDF documents. + """ + + quote: typing.Optional[QuoteRenderingSettings] = pydantic.Field(default=None) + """ + Quote-specific rendering settings for PDF documents. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/document_rendering_settings_output.py b/src/monite/types/document_rendering_settings_output.py new file mode 100644 index 0000000..ad341cc --- /dev/null +++ b/src/monite/types/document_rendering_settings_output.py @@ -0,0 +1,57 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .credit_note_rendering_settings import CreditNoteRenderingSettings +from .invoice_rendering_settings import InvoiceRenderingSettings +from .line_items_rendering_settings import LineItemsRenderingSettings +from .quote_rendering_settings import QuoteRenderingSettings + + +class DocumentRenderingSettingsOutput(UniversalBaseModel): + """ + Rendering settings that control how different parts of the PDF documents are displayed. + Includes common settings for all document types such as quotes, invoices, and credit notes and document + type-specific settings that are defined in their respective objects. + """ + + credit_note: typing.Optional[CreditNoteRenderingSettings] = pydantic.Field(default=None) + """ + Credit note-specific rendering settings for PDF documents. + """ + + display_entity_bank_account: typing.Optional[bool] = pydantic.Field(default=None) + """ + If set to `true`, the entity's bank account details will be displayed on the PDF documents. Defaults to `true`. + """ + + display_line_items: typing.Optional[bool] = pydantic.Field(default=None) + """ + If set to `true`, the line items table will be displayed on the quote PDF. Defaults to `true`. + """ + + invoice: typing.Optional[InvoiceRenderingSettings] = pydantic.Field(default=None) + """ + Invoice-specific rendering settings for PDF documents. + """ + + line_items: typing.Optional[LineItemsRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering line items in PDF documents. + """ + + quote: typing.Optional[QuoteRenderingSettings] = pydantic.Field(default=None) + """ + Quote-specific rendering settings for PDF documents. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/entity_individual_response.py b/src/monite/types/entity_individual_response.py index e5ca870..74cebfa 100644 --- a/src/monite/types/entity_individual_response.py +++ b/src/monite/types/entity_individual_response.py @@ -44,7 +44,7 @@ class EntityIndividualResponse(UniversalBaseModel): logo: typing.Optional[FileSchema2] = pydantic.Field(default=None) """ - A logo image of the entity + An object containing the entity logo URL and other image details, or `null` if the entity does not have a logo. """ phone: typing.Optional[str] = pydantic.Field(default=None) diff --git a/src/monite/types/entity_onboarding_data_response.py b/src/monite/types/entity_onboarding_data_response.py index e5e9e2a..665ca6c 100644 --- a/src/monite/types/entity_onboarding_data_response.py +++ b/src/monite/types/entity_onboarding_data_response.py @@ -25,6 +25,11 @@ class EntityOnboardingDataResponse(UniversalBaseModel): Details on the entity's acceptance of the service agreement. """ + treasury_tos_acceptance: typing.Optional[TermsOfServiceAcceptanceOutput] = pydantic.Field(default=None) + """ + Details on the entity's acceptance of the Stripe Treasury service agreement. + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/monite/types/entity_organization_response.py b/src/monite/types/entity_organization_response.py index b10efb9..02d258f 100644 --- a/src/monite/types/entity_organization_response.py +++ b/src/monite/types/entity_organization_response.py @@ -39,7 +39,7 @@ class EntityOrganizationResponse(UniversalBaseModel): logo: typing.Optional[FileSchema2] = pydantic.Field(default=None) """ - A logo image of the entity + An object containing the entity logo URL and other image details, or `null` if the entity does not have a logo. """ organization: OrganizationResponseSchema = pydantic.Field() diff --git a/src/monite/types/entity_user_response.py b/src/monite/types/entity_user_response.py index 2913c77..8081fea 100644 --- a/src/monite/types/entity_user_response.py +++ b/src/monite/types/entity_user_response.py @@ -11,55 +11,60 @@ class EntityUserResponse(UniversalBaseModel): id: str = pydantic.Field() """ - UUID entity user ID + A unique Monite-assigned ID of this entity user. Can be used with `POST /auth/token` to generate an API access token for this user. """ created_at: dt.datetime = pydantic.Field() """ - UTC datetime + UTC date and time when this user was created in Monite. """ updated_at: dt.datetime = pydantic.Field() """ - UTC datetime + UTC date and time when this user was last updated. """ email: typing.Optional[str] = pydantic.Field(default=None) """ - An entity user business email + The user's business email address. """ first_name: typing.Optional[str] = pydantic.Field(default=None) """ - First name + The user's first name. """ last_name: typing.Optional[str] = pydantic.Field(default=None) """ - Last name + The user's last name. """ login: str = pydantic.Field() """ - Login + The username assigned to this user. Usernames must be unique within the entity. + + The `login` value is not used by Monite but may be used by partner applications, for example, to map the users between the partner's platform and Monite. """ phone: typing.Optional[str] = pydantic.Field(default=None) """ - An entity user phone number in the international format + The user's phone number. """ role_id: str = pydantic.Field() """ - UUID role ID + ID of the role assigned to this user. The role defines the user's [access permissions](https://docs.monite.com/api/concepts/authentication#permissions) within the entity. Each user has just one role. """ status: StatusEnum = pydantic.Field() """ - record status, 'active' by default + The user's status. Always `active`. """ - userpic_file_id: typing.Optional[str] = None + userpic_file_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Unused. Reserved for future use. Currently always returns `null`. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/exchange_rate.py b/src/monite/types/exchange_rate.py index 51350c2..e3570e4 100644 --- a/src/monite/types/exchange_rate.py +++ b/src/monite/types/exchange_rate.py @@ -9,8 +9,8 @@ class ExchangeRate(UniversalBaseModel): base: CurrencyEnum - to: CurrencyEnum rate: float + to: CurrencyEnum if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/file_response.py b/src/monite/types/file_response.py index 693b950..3bfd559 100644 --- a/src/monite/types/file_response.py +++ b/src/monite/types/file_response.py @@ -10,18 +10,74 @@ class FileResponse(UniversalBaseModel): - id: str - created_at: dt.datetime - updated_at: dt.datetime - file_type: str - md5: str - mimetype: str - name: str - region: str - s3bucket: typing_extensions.Annotated[str, FieldMetadata(alias="s3_bucket")] - s3file_path: typing_extensions.Annotated[str, FieldMetadata(alias="s3_file_path")] - size: int - url: str + id: str = pydantic.Field() + """ + A unique ID assigned to this file. + """ + + created_at: dt.datetime = pydantic.Field() + """ + Date and time when this file was uploaded to or created in Monite. Timestamps follow the ISO 8601 format. + """ + + updated_at: dt.datetime = pydantic.Field() + """ + Date and time when this file was last updated in Monite. Timestamps follow the ISO 8601 format. + """ + + file_type: str = pydantic.Field() + """ + Possible values: + + * `additional_identity_documents` and `identity_documents` - [entity verification documents](https://docs.monite.com/payments/onboarding/via-api/documents) uploaded for payments onboarding. + * `attachments` - supplementary attachments for accounts receivable invoices, quotes, and credit notes. + * `delivery_notes` - auto-generated PDF versions of delivery notes. + * `einvoices_xml` - e-invoice XML generated when sending e-invoices. + * `payables` - payables (bills) received via email or uploaded via API. + * `receivable_signatures` - images of customer signatures provided during quote acceptance. + * `receivables` - auto-generated PDF versions of invoices, quotes, and credit notes. + * `zip` - data export archives created by `POST /data_exports`. + """ + + md5: str = pydantic.Field() + """ + The MD5 hash of the file. + """ + + mimetype: str = pydantic.Field() + """ + The file's media type, for example, `application/pdf` or `image/png`. + """ + + name: str = pydantic.Field() + """ + The original file name (if available). + """ + + region: str = pydantic.Field() + """ + Geographical region of the data center where the file is stored. + """ + + s3bucket: typing_extensions.Annotated[str, FieldMetadata(alias="s3_bucket")] = pydantic.Field() + """ + Unused. + """ + + s3file_path: typing_extensions.Annotated[str, FieldMetadata(alias="s3_file_path")] = pydantic.Field() + """ + Unused. + """ + + size: int = pydantic.Field() + """ + The file size in bytes. + """ + + url: str = pydantic.Field() + """ + The URL to download the file. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/file_schema.py b/src/monite/types/file_schema.py index 1bb8bd0..bd91f09 100644 --- a/src/monite/types/file_schema.py +++ b/src/monite/types/file_schema.py @@ -29,16 +29,6 @@ class FileSchema(UniversalBaseModel): The type of the business object associated with this file. """ - name: str = pydantic.Field() - """ - The original file name (if available). - """ - - region: str = pydantic.Field() - """ - Geographical region of the data center where the file is stored. - """ - md5: str = pydantic.Field() """ The MD5 hash of the file. @@ -49,14 +39,14 @@ class FileSchema(UniversalBaseModel): The file's [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). """ - url: str = pydantic.Field() + name: str = pydantic.Field() """ - The URL to download the file. + The original file name (if available). """ - size: int = pydantic.Field() + pages: typing.Optional[typing.List[PageSchema2]] = pydantic.Field(default=None) """ - The file size in bytes. + If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. """ previews: typing.Optional[typing.List[PreviewSchema2]] = pydantic.Field(default=None) @@ -64,9 +54,19 @@ class FileSchema(UniversalBaseModel): Preview images generated for this file. There can be multiple images with different sizes. """ - pages: typing.Optional[typing.List[PageSchema2]] = pydantic.Field(default=None) + region: str = pydantic.Field() """ - If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. + Geographical region of the data center where the file is stored. + """ + + size: int = pydantic.Field() + """ + The file size in bytes. + """ + + url: str = pydantic.Field() + """ + The URL to download the file. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/financing_invoice.py b/src/monite/types/financing_invoice.py index 5aed287..cec4ebb 100644 --- a/src/monite/types/financing_invoice.py +++ b/src/monite/types/financing_invoice.py @@ -11,19 +11,24 @@ class FinancingInvoice(UniversalBaseModel): - type: FinancingInvoiceType = pydantic.Field() + advance_amount: typing.Optional[int] = pydantic.Field(default=None) """ - The type of the invoice i.e. receivable or payable. + Amount after fees the business will receive in minor units. """ - status: WcInvoiceStatus = pydantic.Field() + advance_rate_percentage: typing.Optional[int] = pydantic.Field(default=None) """ - Status of the invoice. + Advance rate percentage. 10000 means 100% """ - invoice_id: str = pydantic.Field() + currency: CurrencyEnum = pydantic.Field() """ - Monite invoice ID. + Currency code. + """ + + description: typing.Optional[str] = pydantic.Field(default=None) + """ + Description of the invoice. """ document_id: str = pydantic.Field() @@ -36,29 +41,24 @@ class FinancingInvoice(UniversalBaseModel): Monite invoice due date. """ - issue_date: str = pydantic.Field() - """ - Monite invoice issue date. - """ - - total_amount: int = pydantic.Field() + fee_amount: typing.Optional[int] = pydantic.Field(default=None) """ - Total amount of the invoice in minor units. + Fee amount in minor units. """ - currency: CurrencyEnum = pydantic.Field() + fee_percentage: typing.Optional[int] = pydantic.Field(default=None) """ - Currency code. + Fee percentage. 300 means 3% """ - description: typing.Optional[str] = pydantic.Field(default=None) + invoice_id: str = pydantic.Field() """ - Description of the invoice. + Monite invoice ID. """ - payer_type: str = pydantic.Field() + issue_date: str = pydantic.Field() """ - Payer type. BUSINESS or INDIVIDUAL + Monite invoice issue date. """ payer_business_name: typing.Optional[str] = pydantic.Field(default=None) @@ -76,9 +76,9 @@ class FinancingInvoice(UniversalBaseModel): Payer last name. Only applicable for INDIVIDUAL payer type. """ - requested_amount: typing.Optional[int] = pydantic.Field(default=None) + payer_type: str = pydantic.Field() """ - Amount the business requests to be financed in minor units. + Payer type. BUSINESS or INDIVIDUAL """ principal_amount: typing.Optional[int] = pydantic.Field(default=None) @@ -91,29 +91,29 @@ class FinancingInvoice(UniversalBaseModel): Amount the business will repay in minor units. """ - advance_amount: typing.Optional[int] = pydantic.Field(default=None) + repayment_schedule: typing.Optional[RepaymentSchedule] = pydantic.Field(default=None) """ - Amount after fees the business will receive in minor units. + Repayment schedule of the invoice. """ - advance_rate_percentage: typing.Optional[int] = pydantic.Field(default=None) + requested_amount: typing.Optional[int] = pydantic.Field(default=None) """ - Advance rate percentage. 10000 means 100% + Amount the business requests to be financed in minor units. """ - fee_amount: typing.Optional[int] = pydantic.Field(default=None) + status: WcInvoiceStatus = pydantic.Field() """ - Fee amount in minor units. + Status of the invoice. """ - fee_percentage: typing.Optional[int] = pydantic.Field(default=None) + total_amount: int = pydantic.Field() """ - Fee percentage. 300 means 3% + Total amount of the invoice in minor units. """ - repayment_schedule: typing.Optional[RepaymentSchedule] = pydantic.Field(default=None) + type: FinancingInvoiceType = pydantic.Field() """ - Repayment schedule of the invoice. + The type of the invoice i.e. receivable or payable. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/financing_invoice_list_response.py b/src/monite/types/financing_invoice_list_response.py index 72b496e..38b53c2 100644 --- a/src/monite/types/financing_invoice_list_response.py +++ b/src/monite/types/financing_invoice_list_response.py @@ -13,14 +13,14 @@ class FinancingInvoiceListResponse(UniversalBaseModel): A list of invoices requested for financing. """ - prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). + A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). """ - next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). + A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/financing_offer.py b/src/monite/types/financing_offer.py index 2db0ccf..06b3f60 100644 --- a/src/monite/types/financing_offer.py +++ b/src/monite/types/financing_offer.py @@ -10,16 +10,6 @@ class FinancingOffer(UniversalBaseModel): - status: WcOfferStatus = pydantic.Field() - """ - The status of the financing offer. - """ - - total_amount: int = pydantic.Field() - """ - The total credit limit in minor units. - """ - available_amount: typing.Optional[int] = pydantic.Field(default=None) """ The available credit limit in minor units. @@ -35,6 +25,16 @@ class FinancingOffer(UniversalBaseModel): A list of pricing plans for the offer. """ + status: WcOfferStatus = pydantic.Field() + """ + The status of the financing offer. + """ + + total_amount: int = pydantic.Field() + """ + The total credit limit in minor units. + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/monite/types/financing_offers_response.py b/src/monite/types/financing_offers_response.py index 5e16253..eaaa414 100644 --- a/src/monite/types/financing_offers_response.py +++ b/src/monite/types/financing_offers_response.py @@ -9,14 +9,14 @@ class FinancingOffersResponse(UniversalBaseModel): - offers: typing.List[FinancingOffer] = pydantic.Field() + business_status: WcBusinessStatus = pydantic.Field() """ - A list of financing offers extended to the business. + The business's onboarding status. """ - business_status: WcBusinessStatus = pydantic.Field() + offers: typing.List[FinancingOffer] = pydantic.Field() """ - The business's onboarding status. + A list of financing offers extended to the business. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/invoice.py b/src/monite/types/invoice.py index 0e54dc8..5b56dec 100644 --- a/src/monite/types/invoice.py +++ b/src/monite/types/invoice.py @@ -8,9 +8,20 @@ class Invoice(UniversalBaseModel): - due_date: typing.Optional[str] = None - file: typing.Optional[InvoiceFile] = None - issue_date: typing.Optional[str] = None + due_date: typing.Optional[str] = pydantic.Field(default=None) + """ + The invoice due date (`yyyy-mm-dd`) to be displayed on the payment page. + """ + + file: typing.Optional[InvoiceFile] = pydantic.Field(default=None) + """ + The invoice file (for example, PDF or PNG). If specified, the payment page will include a link to download this file. + """ + + issue_date: typing.Optional[str] = pydantic.Field(default=None) + """ + The invoice issue date (`yyyy-mm-dd`) to be displayed on the payment page. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/invoice_response_payload.py b/src/monite/types/invoice_response_payload.py index 12f6b19..39ec1b3 100644 --- a/src/monite/types/invoice_response_payload.py +++ b/src/monite/types/invoice_response_payload.py @@ -5,9 +5,11 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_response import AttachmentResponse from .counterpart_type import CounterpartType from .currency_enum import CurrencyEnum from .discount_response import DiscountResponse +from .document_rendering_settings import DocumentRenderingSettings from .einvoicing_credentials import EinvoicingCredentials from .invoice_response_payload_entity import InvoiceResponsePayloadEntity from .language_code_enum import LanguageCodeEnum @@ -53,6 +55,11 @@ class InvoiceResponsePayload(UniversalBaseModel): How much is left to be paid in in [minor units](https://docs.monite.com/references/currencies#minor-units), including payment_term discounts. """ + attachments: typing.Optional[typing.List[AttachmentResponse]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + based_on: typing.Optional[str] = pydantic.Field(default=None) """ The unique ID of a previous document related to the receivable if applicable. @@ -158,6 +165,11 @@ class InvoiceResponsePayload(UniversalBaseModel): The sequential code systematically assigned to invoices. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + due_date: typing.Optional[str] = pydantic.Field(default=None) """ Optional field representing date until which invoice should be paid @@ -194,7 +206,7 @@ class InvoiceResponsePayload(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. See also: `memo`, `commercial_condition_description`. """ fulfillment_date: typing.Optional[str] = pydantic.Field(default=None) @@ -219,7 +231,7 @@ class InvoiceResponsePayload(UniversalBaseModel): line_items: typing.List[ResponseItem] memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable. + An optional note for the customer, displayed above the line items table in the PDF. See also: `footer`, `commercial_condition_description`. """ network_credentials: typing.Optional[EinvoicingCredentials] = pydantic.Field(default=None) @@ -257,7 +269,7 @@ class InvoiceResponsePayload(UniversalBaseModel): payment_terms: typing.Optional[PaymentTerms] = None project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this invoice. If specified, the project name will be included in the header of the PDF invoice. """ purchase_order: typing.Optional[str] = pydantic.Field(default=None) @@ -272,7 +284,7 @@ class InvoiceResponsePayload(UniversalBaseModel): related_documents: RelatedDocuments = pydantic.Field() """ - Ids of documents that relate to invoice. I.e credit notes, proforma invoices, etc. + IDs of other documents related to this invoice. See also: `based_on`, `based_on_document_id`, `purchase_order`. """ status: ReceivablesStatusEnum = pydantic.Field() diff --git a/src/monite/types/bank_account_verifications.py b/src/monite/types/line_item_column_settings.py similarity index 64% rename from src/monite/types/bank_account_verifications.py rename to src/monite/types/line_item_column_settings.py index 00d5589..1b4099b 100644 --- a/src/monite/types/bank_account_verifications.py +++ b/src/monite/types/line_item_column_settings.py @@ -4,13 +4,13 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .airwallex_plaid_verification import AirwallexPlaidVerification -class BankAccountVerifications(UniversalBaseModel): - airwallex_plaid: typing.Optional[AirwallexPlaidVerification] = pydantic.Field(default=None) +class LineItemColumnSettings(UniversalBaseModel): + display: typing.Optional[bool] = None + label: typing.Optional[str] = pydantic.Field(default=None) """ - Airwallex Plaid verification + Line item table column header to override Monite's default. If not set, the Monite's default will be used. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/verification_airwallex_plaid_request.py b/src/monite/types/line_item_numeric_column_settings.py similarity index 52% rename from src/monite/types/verification_airwallex_plaid_request.py rename to src/monite/types/line_item_numeric_column_settings.py index 3ba8460..f965edc 100644 --- a/src/monite/types/verification_airwallex_plaid_request.py +++ b/src/monite/types/line_item_numeric_column_settings.py @@ -6,20 +6,20 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -class VerificationAirwallexPlaidRequest(UniversalBaseModel): - client_name: str = pydantic.Field() +class LineItemNumericColumnSettings(UniversalBaseModel): """ - The name of your application to be displayed in Plaid Modal + Extended settings for numeric columns in line items. """ - link_customization_name: typing.Optional[str] = pydantic.Field(default=None) + display: typing.Optional[bool] = None + label: typing.Optional[str] = pydantic.Field(default=None) """ - The name of the Link customization configured on the Plaid Dashboard. If not specified, the default customization will be applied + Line item table column header to override Monite's default. If not set, the Monite's default will be used. """ - redirect_url: str = pydantic.Field() + precision: typing.Optional[int] = pydantic.Field(default=None) """ - URL to handle the OAuth verification flow + Number of decimal places to display for numeric values in this column. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/line_items_rendering_settings.py b/src/monite/types/line_items_rendering_settings.py new file mode 100644 index 0000000..4246be7 --- /dev/null +++ b/src/monite/types/line_items_rendering_settings.py @@ -0,0 +1,69 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .line_item_column_settings import LineItemColumnSettings +from .line_item_numeric_column_settings import LineItemNumericColumnSettings + + +class LineItemsRenderingSettings(UniversalBaseModel): + discount: typing.Optional[LineItemColumnSettings] = pydantic.Field(default=None) + """ + Settings for the discount column in the line items table. + """ + + measure_unit: typing.Optional[LineItemColumnSettings] = pydantic.Field(default=None) + """ + Settings for the measure unit column in the line items table. + """ + + name: typing.Optional[LineItemColumnSettings] = pydantic.Field(default=None) + """ + Settings for the name column in the line items table. + """ + + price: typing.Optional[LineItemNumericColumnSettings] = pydantic.Field(default=None) + """ + Settings for the price column in the line items table. + """ + + price_after_vat: typing.Optional[LineItemNumericColumnSettings] = pydantic.Field(default=None) + """ + Settings for the price after VAT column in the line items table. + """ + + quantity: typing.Optional[LineItemColumnSettings] = pydantic.Field(default=None) + """ + Settings for the quantity column in the line items table. + """ + + total_price: typing.Optional[LineItemNumericColumnSettings] = pydantic.Field(default=None) + """ + Settings for the total price column in the line items table. + """ + + total_price_after_vat: typing.Optional[LineItemNumericColumnSettings] = pydantic.Field(default=None) + """ + Settings for the total price after VAT column in the line items table. + """ + + vat_amount: typing.Optional[LineItemNumericColumnSettings] = pydantic.Field(default=None) + """ + Settings for the VAT amount column in the line items table. + """ + + vat_rate: typing.Optional[LineItemNumericColumnSettings] = pydantic.Field(default=None) + """ + Settings for the VAT rate column in the line items table. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/mail_settings.py b/src/monite/types/mail_settings.py index 724ad3c..19b260c 100644 --- a/src/monite/types/mail_settings.py +++ b/src/monite/types/mail_settings.py @@ -7,9 +7,30 @@ class MailSettings(UniversalBaseModel): - attach_documents_as_pdf: bool - from_email_username: typing.Optional[str] = None - from_name: typing.Optional[str] = None + attach_documents_as_pdf: bool = pydantic.Field() + """ + This setting affects accounts receivable emails. + + If it is `true`, emails sent by [`POST /receivables/{receivable_id}/send`](https://docs.monite.com/api/receivables/post-receivables-id-send) will include the PDF version of the specified invoice, quote, or credit note as an attachment. When emailing [e-invoices](https://docs.monite.com/e-invoicing/send), e-invoice XML will also be attached to the email. + + If it is `false`, PDFs and e-invoice XML is not attached to outgoing emails. + """ + + from_email_username: typing.Optional[str] = pydantic.Field(default=None) + """ + The local part of the sender email address (the part before the @domain). If `null`, defaults to `noreply`. + + For example, to send emails from `Acme Inc. ` use "invoicing" as the `from_email_username` value. + + To customize the domain name for outgoing emails, [set up a mailbox](https://docs.monite.com/advanced/mailboxes#manage-mailboxes) for the entity. + """ + + from_name: typing.Optional[str] = pydantic.Field(default=None) + """ + The sender name in outgoing emails. For example, to send emails from `Acme Inc. ` use "Acme Inc." as the `from_name` value. + + If `null`, the sender address will be just an email address without a name. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/mailbox_object_type_enum.py b/src/monite/types/mailbox_object_type_enum.py index 2776788..9d83dda 100644 --- a/src/monite/types/mailbox_object_type_enum.py +++ b/src/monite/types/mailbox_object_type_enum.py @@ -2,4 +2,4 @@ import typing -MailboxObjectTypeEnum = typing.Literal["payable"] +MailboxObjectTypeEnum = typing.Union[typing.Literal["payable", "receipt"], typing.Any] diff --git a/src/monite/types/next_document_numbers.py b/src/monite/types/next_document_numbers.py new file mode 100644 index 0000000..9c2a666 --- /dev/null +++ b/src/monite/types/next_document_numbers.py @@ -0,0 +1,42 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class NextDocumentNumbers(UniversalBaseModel): + credit_note: typing.Optional[int] = pydantic.Field(default=None) + """ + Next credit note number + """ + + delivery_note: typing.Optional[int] = pydantic.Field(default=None) + """ + Next delivery note number + """ + + invoice: typing.Optional[int] = pydantic.Field(default=None) + """ + Next invoice number + """ + + purchase_order: typing.Optional[int] = pydantic.Field(default=None) + """ + Next purchase order number + """ + + quote: typing.Optional[int] = pydantic.Field(default=None) + """ + Next quote number + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/ocr_address_details.py b/src/monite/types/ocr_address_details.py index 8ee1ba6..3adce78 100644 --- a/src/monite/types/ocr_address_details.py +++ b/src/monite/types/ocr_address_details.py @@ -8,11 +8,11 @@ class OcrAddressDetails(UniversalBaseModel): - street_and_number: typing.Optional[str] = None city: typing.Optional[str] = None - postal_code: typing.Optional[str] = None country: typing.Optional[AllowedCountries] = None + postal_code: typing.Optional[str] = None state: typing.Optional[str] = None + street_and_number: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_counterpart_details.py b/src/monite/types/ocr_counterpart_details.py index 4eaf6e2..2f612d3 100644 --- a/src/monite/types/ocr_counterpart_details.py +++ b/src/monite/types/ocr_counterpart_details.py @@ -9,12 +9,12 @@ class OcrCounterpartDetails(UniversalBaseModel): - vat_number: typing.Optional[str] = None - tax_number: typing.Optional[str] = None - email: typing.Optional[str] = None - name: typing.Optional[str] = None address: OcrAddressDetails bank_account: OcrBankDetails + email: typing.Optional[str] = None + name: typing.Optional[str] = None + tax_number: typing.Optional[str] = None + vat_number: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_credit_note.py b/src/monite/types/ocr_credit_note.py index 1dd8228..3866a20 100644 --- a/src/monite/types/ocr_credit_note.py +++ b/src/monite/types/ocr_credit_note.py @@ -10,17 +10,17 @@ class OcrCreditNote(UniversalBaseModel): + currency: typing.Optional[CurrencyEnum] = None document_number: typing.Optional[str] = None - original_invoice_number: typing.Optional[str] = None issue_date: typing.Optional[str] = None - currency: typing.Optional[CurrencyEnum] = None + line_items: typing.List[OcrLineItem] + original_invoice_number: typing.Optional[str] = None + recipient: OcrCounterpartDetails + sender: OcrCounterpartDetails subtotal: typing.Optional[float] = None - tax_rate: typing.Optional[float] = None tax_amount: typing.Optional[float] = None + tax_rate: typing.Optional[float] = None total_amount: typing.Optional[float] = None - sender: OcrCounterpartDetails - recipient: OcrCounterpartDetails - line_items: typing.List[OcrLineItem] if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_invoice.py b/src/monite/types/ocr_invoice.py index 2c4cb7c..cb47168 100644 --- a/src/monite/types/ocr_invoice.py +++ b/src/monite/types/ocr_invoice.py @@ -10,19 +10,19 @@ class OcrInvoice(UniversalBaseModel): + amount_paid: typing.Optional[float] = None currency: typing.Optional[CurrencyEnum] = None + document_number: typing.Optional[str] = None due_date: typing.Optional[str] = None issue_date: typing.Optional[str] = None - document_number: typing.Optional[str] = None - sender: OcrCounterpartDetails + line_items: typing.Optional[typing.List[OcrLineItem]] = None + payment_terms: typing.Optional[str] = None recipient: OcrCounterpartDetails + sender: OcrCounterpartDetails subtotal: typing.Optional[float] = None - total_amount: typing.Optional[float] = None tax_amount: typing.Optional[float] = None tax_rate: typing.Optional[float] = None - amount_paid: typing.Optional[float] = None - payment_terms: typing.Optional[str] = None - line_items: typing.Optional[typing.List[OcrLineItem]] = None + total_amount: typing.Optional[float] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_line_item.py b/src/monite/types/ocr_line_item.py index 4c38a2f..57a8a46 100644 --- a/src/monite/types/ocr_line_item.py +++ b/src/monite/types/ocr_line_item.py @@ -7,16 +7,16 @@ class OcrLineItem(UniversalBaseModel): + description: typing.Optional[str] = None line_reference: typing.Optional[str] = None name: typing.Optional[str] = None - description: typing.Optional[str] = None quantity: typing.Optional[float] = None - unit_price: typing.Optional[float] = None - unit: typing.Optional[str] = None subtotal: typing.Optional[float] = None - tax_rate: typing.Optional[float] = None tax_amount: typing.Optional[float] = None + tax_rate: typing.Optional[float] = None total_amount: typing.Optional[float] = None + unit: typing.Optional[str] = None + unit_price: typing.Optional[float] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_receipt.py b/src/monite/types/ocr_receipt.py index 2b71fb0..bd6a31e 100644 --- a/src/monite/types/ocr_receipt.py +++ b/src/monite/types/ocr_receipt.py @@ -11,17 +11,17 @@ class OcrReceipt(UniversalBaseModel): + currency: typing.Optional[CurrencyEnum] = None + discount: typing.Optional[float] = None document_number: typing.Optional[str] = None issued_at: typing.Optional[dt.datetime] = None - currency: typing.Optional[CurrencyEnum] = None + line_items: typing.List[OcrReceiptLineItem] + sender: OcrCounterpartDetails subtotal: typing.Optional[float] = None - tax_rate: typing.Optional[float] = None tax_amount: typing.Optional[float] = None - total_amount: typing.Optional[float] = None - discount: typing.Optional[float] = None + tax_rate: typing.Optional[float] = None tax_type: typing.Optional[str] = None - line_items: typing.List[OcrReceiptLineItem] - sender: OcrCounterpartDetails + total_amount: typing.Optional[float] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_receipt_line_item.py b/src/monite/types/ocr_receipt_line_item.py index a6a0829..ce3180f 100644 --- a/src/monite/types/ocr_receipt_line_item.py +++ b/src/monite/types/ocr_receipt_line_item.py @@ -7,17 +7,17 @@ class OcrReceiptLineItem(UniversalBaseModel): + description: typing.Optional[str] = None + discount_amount: typing.Optional[float] = None line_reference: typing.Optional[str] = None name: typing.Optional[str] = None - description: typing.Optional[str] = None quantity: typing.Optional[float] = None - unit_price: typing.Optional[float] = None - unit: typing.Optional[str] = None subtotal: typing.Optional[float] = None - tax_rate: typing.Optional[float] = None tax_amount: typing.Optional[float] = None + tax_rate: typing.Optional[float] = None total_amount: typing.Optional[float] = None - discount_amount: typing.Optional[float] = None + unit: typing.Optional[str] = None + unit_price: typing.Optional[float] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_recognition_response.py b/src/monite/types/ocr_recognition_response.py index 65b2676..9790cd9 100644 --- a/src/monite/types/ocr_recognition_response.py +++ b/src/monite/types/ocr_recognition_response.py @@ -14,14 +14,14 @@ class OcrRecognitionResponse(UniversalBaseModel): Legacy schema used for AWS textract recognition. """ - summary: typing.Optional[typing.List[LabelNValue]] = pydantic.Field(default=None) + line_items: typing.Optional[typing.List[LabelNValue]] = pydantic.Field(default=None) """ - Invoice text content other than the line items. Such as the invoice issue and due dates, vendor name and address, and other general information. + Text content of the invoice line items as recognized by OCR. """ - line_items: typing.Optional[typing.List[LabelNValue]] = pydantic.Field(default=None) + summary: typing.Optional[typing.List[LabelNValue]] = pydantic.Field(default=None) """ - Text content of the invoice line items as recognized by OCR. + Invoice text content other than the line items. Such as the invoice issue and due dates, vendor name and address, and other general information. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/ocr_response_invoice_receipt_data.py b/src/monite/types/ocr_response_invoice_receipt_data.py index 4baff52..5473931 100644 --- a/src/monite/types/ocr_response_invoice_receipt_data.py +++ b/src/monite/types/ocr_response_invoice_receipt_data.py @@ -9,65 +9,64 @@ class OcrResponseInvoiceReceiptData(UniversalBaseModel): - type: typing.Optional[typing.Literal["invoice"]] = None - discount_raw: typing.Optional[float] = pydantic.Field(default=None) + counterpart_account_id: typing.Optional[str] = pydantic.Field(default=None) """ - Discount Raw amount + Counterpart bank ID """ - total_paid_amount_raw: typing.Optional[float] = pydantic.Field(default=None) + counterpart_account_number: typing.Optional[str] = pydantic.Field(default=None) """ - Total paid amount + The bank account number """ - total_raw: typing.Optional[float] = pydantic.Field(default=None) + counterpart_address: typing.Optional[str] = pydantic.Field(default=None) """ - Total, without minor units + Counterpart address """ - total_excl_vat_raw: typing.Optional[float] = pydantic.Field(default=None) + counterpart_address_object: typing.Optional[OcrAddress] = pydantic.Field(default=None) """ - Subtotal, without minor units + Counterpart address as a json object compatible with counterparts service """ - total_vat_amount_raw: typing.Optional[float] = pydantic.Field(default=None) + counterpart_branch_number: typing.Optional[str] = pydantic.Field(default=None) """ - VAT amount, without minor units + The bank branch number """ - total_vat_rate_raw: typing.Optional[float] = pydantic.Field(default=None) + counterpart_email: typing.Optional[str] = pydantic.Field(default=None) """ - VAT Percent raw, without minor units. + Email address of the counterpart """ - currency: typing.Optional[str] = pydantic.Field(default=None) + counterpart_name: typing.Optional[str] = pydantic.Field(default=None) """ - ISO 4217 currency code + Counterpart name """ - purchase_order_number: typing.Optional[str] = pydantic.Field(default=None) + counterpart_routing_number: typing.Optional[str] = pydantic.Field(default=None) """ - Purchase Order Number + The bank routing number """ - counterpart_name: typing.Optional[str] = pydantic.Field(default=None) + counterpart_vat_id: typing.Optional[str] = pydantic.Field(default=None) """ - Counterpart name + Counterpart VAT ID """ - counterpart_email: typing.Optional[str] = pydantic.Field(default=None) + currency: typing.Optional[str] = pydantic.Field(default=None) """ - Email address of the counterpart + ISO 4217 currency code """ - counterpart_address: typing.Optional[str] = pydantic.Field(default=None) + discount_raw: typing.Optional[float] = pydantic.Field(default=None) """ - Counterpart address + Discount Raw amount """ - counterpart_account_id: typing.Optional[str] = pydantic.Field(default=None) + document_due_date: typing.Optional[str] = pydantic.Field(default=None) """ - Counterpart bank ID + Document due date in ISO format """ document_id: typing.Optional[str] = pydantic.Field(default=None) @@ -75,51 +74,58 @@ class OcrResponseInvoiceReceiptData(UniversalBaseModel): Invoice/receipt ID """ - payment_terms_raw: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + document_issued_at_date: typing.Optional[str] = pydantic.Field(default=None) """ - Raw payment terms parsed but not calculated. + Document issuance date in ISO format """ - tax_payer_id: typing.Optional[str] = pydantic.Field(default=None) + line_items_raw: typing.Optional[typing.List[OcrResponseInvoiceReceiptLineItemRaw]] = pydantic.Field(default=None) """ - Tax payer ID + List of line items from document raw, without minor units conversion. """ - counterpart_vat_id: typing.Optional[str] = pydantic.Field(default=None) + payment_terms_raw: typing.Optional[typing.List[str]] = pydantic.Field(default=None) """ - Counterpart VAT ID + Raw payment terms parsed but not calculated. """ - document_issued_at_date: typing.Optional[str] = pydantic.Field(default=None) + purchase_order_number: typing.Optional[str] = pydantic.Field(default=None) """ - Document issuance date in ISO format + Purchase Order Number """ - document_due_date: typing.Optional[str] = pydantic.Field(default=None) + tax_payer_id: typing.Optional[str] = pydantic.Field(default=None) """ - Document due date in ISO format + Tax payer ID """ - counterpart_address_object: typing.Optional[OcrAddress] = pydantic.Field(default=None) + total_excl_vat_raw: typing.Optional[float] = pydantic.Field(default=None) """ - Counterpart address as a json object compatible with counterparts service + Subtotal, without minor units """ - counterpart_account_number: typing.Optional[str] = pydantic.Field(default=None) + total_paid_amount_raw: typing.Optional[float] = pydantic.Field(default=None) """ - The bank account number + Total paid amount """ - counterpart_routing_number: typing.Optional[str] = pydantic.Field(default=None) + total_raw: typing.Optional[float] = pydantic.Field(default=None) """ - The bank routing number + Total, without minor units """ - line_items_raw: typing.Optional[typing.List[OcrResponseInvoiceReceiptLineItemRaw]] = pydantic.Field(default=None) + total_vat_amount_raw: typing.Optional[float] = pydantic.Field(default=None) """ - List of line items from document raw, without minor units conversion. + VAT amount, without minor units """ + total_vat_rate_raw: typing.Optional[float] = pydantic.Field(default=None) + """ + VAT Percent raw, without minor units. + """ + + type: typing.Optional[typing.Literal["invoice"]] = None + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/monite/types/ocr_response_invoice_receipt_line_item_raw.py b/src/monite/types/ocr_response_invoice_receipt_line_item_raw.py index e06b2f6..d7b25e9 100644 --- a/src/monite/types/ocr_response_invoice_receipt_line_item_raw.py +++ b/src/monite/types/ocr_response_invoice_receipt_line_item_raw.py @@ -7,11 +7,6 @@ class OcrResponseInvoiceReceiptLineItemRaw(UniversalBaseModel): - line_item_ocr_id: typing.Optional[str] = pydantic.Field(default=None) - """ - OCR Id of line item - """ - description: typing.Optional[str] = pydantic.Field(default=None) """ Human-readable line item description @@ -22,14 +17,24 @@ class OcrResponseInvoiceReceiptLineItemRaw(UniversalBaseModel): Item Quantity/Unit Price adjusted """ + line_item_ocr_id: typing.Optional[str] = pydantic.Field(default=None) + """ + OCR Id of line item + """ + quantity: typing.Optional[float] = pydantic.Field(default=None) """ Quantity """ - unit_price: typing.Optional[float] = pydantic.Field(default=None) + total_excl_vat: typing.Optional[float] = pydantic.Field(default=None) """ - Price as parsed + Total excluded VAT as parsed. + """ + + total_incl_vat: typing.Optional[float] = pydantic.Field(default=None) + """ + Total included VAT as parsed. """ unit: typing.Optional[str] = pydantic.Field(default=None) @@ -37,9 +42,9 @@ class OcrResponseInvoiceReceiptLineItemRaw(UniversalBaseModel): Unit """ - vat_percentage: typing.Optional[float] = pydantic.Field(default=None) + unit_price: typing.Optional[float] = pydantic.Field(default=None) """ - VAT Percent as parsed. + Price as parsed """ vat_amount: typing.Optional[float] = pydantic.Field(default=None) @@ -47,14 +52,9 @@ class OcrResponseInvoiceReceiptLineItemRaw(UniversalBaseModel): VAT Amount as parsed. """ - total_excl_vat: typing.Optional[float] = pydantic.Field(default=None) - """ - Total excluded VAT as parsed. - """ - - total_incl_vat: typing.Optional[float] = pydantic.Field(default=None) + vat_percentage: typing.Optional[float] = pydantic.Field(default=None) """ - Total included VAT as parsed. + VAT Percent as parsed. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/ocr_task_response_schema.py b/src/monite/types/ocr_task_response_schema.py index d3a0b37..a61ef32 100644 --- a/src/monite/types/ocr_task_response_schema.py +++ b/src/monite/types/ocr_task_response_schema.py @@ -14,9 +14,9 @@ class OcrTaskResponseSchema(UniversalBaseModel): id: str created_at: dt.datetime updated_at: dt.datetime - status: OcrTaskStatus document_type: typing.Optional[OcrDocumentTypeEnum] = None recognized_data: typing.Optional[OcrTaskResponseSchemaRecognizedData] = None + status: OcrTaskStatus if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_task_response_schema_recognized_data.py b/src/monite/types/ocr_task_response_schema_recognized_data.py index c463591..a970b9c 100644 --- a/src/monite/types/ocr_task_response_schema_recognized_data.py +++ b/src/monite/types/ocr_task_response_schema_recognized_data.py @@ -15,19 +15,19 @@ class OcrTaskResponseSchemaRecognizedData_Invoice(UniversalBaseModel): type: typing.Literal["invoice"] = "invoice" + amount_paid: typing.Optional[float] = None currency: typing.Optional[CurrencyEnum] = None + document_number: typing.Optional[str] = None due_date: typing.Optional[str] = None issue_date: typing.Optional[str] = None - document_number: typing.Optional[str] = None - sender: OcrCounterpartDetails + line_items: typing.Optional[typing.List[OcrLineItem]] = None + payment_terms: typing.Optional[str] = None recipient: OcrCounterpartDetails + sender: OcrCounterpartDetails subtotal: typing.Optional[float] = None - total_amount: typing.Optional[float] = None tax_amount: typing.Optional[float] = None tax_rate: typing.Optional[float] = None - amount_paid: typing.Optional[float] = None - payment_terms: typing.Optional[str] = None - line_items: typing.Optional[typing.List[OcrLineItem]] = None + total_amount: typing.Optional[float] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 @@ -41,17 +41,17 @@ class Config: class OcrTaskResponseSchemaRecognizedData_CreditNote(UniversalBaseModel): type: typing.Literal["credit_note"] = "credit_note" + currency: typing.Optional[CurrencyEnum] = None document_number: typing.Optional[str] = None - original_invoice_number: typing.Optional[str] = None issue_date: typing.Optional[str] = None - currency: typing.Optional[CurrencyEnum] = None + line_items: typing.List[OcrLineItem] + original_invoice_number: typing.Optional[str] = None + recipient: OcrCounterpartDetails + sender: OcrCounterpartDetails subtotal: typing.Optional[float] = None - tax_rate: typing.Optional[float] = None tax_amount: typing.Optional[float] = None + tax_rate: typing.Optional[float] = None total_amount: typing.Optional[float] = None - sender: OcrCounterpartDetails - recipient: OcrCounterpartDetails - line_items: typing.List[OcrLineItem] if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 @@ -65,17 +65,17 @@ class Config: class OcrTaskResponseSchemaRecognizedData_Receipt(UniversalBaseModel): type: typing.Literal["receipt"] = "receipt" + currency: typing.Optional[CurrencyEnum] = None + discount: typing.Optional[float] = None document_number: typing.Optional[str] = None issued_at: typing.Optional[dt.datetime] = None - currency: typing.Optional[CurrencyEnum] = None + line_items: typing.List[OcrReceiptLineItem] + sender: OcrCounterpartDetails subtotal: typing.Optional[float] = None - tax_rate: typing.Optional[float] = None tax_amount: typing.Optional[float] = None - total_amount: typing.Optional[float] = None - discount: typing.Optional[float] = None + tax_rate: typing.Optional[float] = None tax_type: typing.Optional[str] = None - line_items: typing.List[OcrReceiptLineItem] - sender: OcrCounterpartDetails + total_amount: typing.Optional[float] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/ocr_tasks_pagination_response.py b/src/monite/types/ocr_tasks_pagination_response.py index d42421a..684f361 100644 --- a/src/monite/types/ocr_tasks_pagination_response.py +++ b/src/monite/types/ocr_tasks_pagination_response.py @@ -13,14 +13,14 @@ class OcrTasksPaginationResponse(UniversalBaseModel): """ data: typing.List[OcrTaskResponseSchema] - prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). + A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). """ - next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). + A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/onboarding_link_public_response.py b/src/monite/types/onboarding_link_public_response.py deleted file mode 100644 index 8f94dd5..0000000 --- a/src/monite/types/onboarding_link_public_response.py +++ /dev/null @@ -1,25 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel - - -class OnboardingLinkPublicResponse(UniversalBaseModel): - id: str - entity_id: str - expires_at: dt.datetime - refresh_url: str - return_url: str - url: str - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/onboarding_link_request.py b/src/monite/types/onboarding_link_request.py deleted file mode 100644 index 2619843..0000000 --- a/src/monite/types/onboarding_link_request.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel - - -class OnboardingLinkRequest(UniversalBaseModel): - expires_at: dt.datetime - refresh_url: str - return_url: str - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/onboarding_link_response.py b/src/monite/types/onboarding_link_response.py deleted file mode 100644 index 75773c4..0000000 --- a/src/monite/types/onboarding_link_response.py +++ /dev/null @@ -1,27 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .recipient import Recipient - - -class OnboardingLinkResponse(UniversalBaseModel): - id: str - created_at: dt.datetime - expires_at: dt.datetime - recipient: Recipient - refresh_url: str - return_url: str - url: str - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/page_schema2.py b/src/monite/types/page_schema2.py index 97a2980..f73a042 100644 --- a/src/monite/types/page_schema2.py +++ b/src/monite/types/page_schema2.py @@ -22,14 +22,14 @@ class PageSchema2(UniversalBaseModel): The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) of the image. """ - size: int = pydantic.Field() + number: int = pydantic.Field() """ - Image file size, in bytes. + The page number in the PDF document, from 0. """ - number: int = pydantic.Field() + size: int = pydantic.Field() """ - The page number in the PDF document, from 0. + Image file size, in bytes. """ url: str = pydantic.Field() diff --git a/src/monite/types/partner_project_settings_payload_output.py b/src/monite/types/partner_project_settings_payload_output.py index a0a479c..e8cff90 100644 --- a/src/monite/types/partner_project_settings_payload_output.py +++ b/src/monite/types/partner_project_settings_payload_output.py @@ -14,50 +14,57 @@ class PartnerProjectSettingsPayloadOutput(UniversalBaseModel): - currency: typing.Optional[CurrencySettingsOutput] = pydantic.Field(default=None) + api_version: typing.Optional[ApiVersion] = pydantic.Field(default=None) """ - Custom currency exchange rates. + Default API version for partner. """ - payable: typing.Optional[PayableSettings] = pydantic.Field(default=None) + commercial_conditions: typing.Optional[typing.List[str]] = pydantic.Field(default=None) """ - Settings for the payables module. + Unused. To specify commercial conditions for invoices and quotes, use the `commercial_condition_description` field in those documents. """ - receivable: typing.Optional[ReceivableSettings] = pydantic.Field(default=None) + currency: typing.Optional[CurrencySettingsOutput] = pydantic.Field(default=None) + """ + Custom currency exchange rates. """ - Settings for the receivables module. + + default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + """ + A default role to provision upon new entity creation. """ mail: typing.Optional[MailSettings] = pydantic.Field(default=None) """ - Settings for email and mailboxes. + Settings for outgoing email. Used by: + + * accounts receivable emails, for example, emails sent by `POST /recevables/{receivable_id}/send`, + * accounts payable approval notifications. """ - commercial_conditions: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + payable: typing.Optional[PayableSettings] = pydantic.Field(default=None) """ - Commercial conditions for receivables. + Settings for accounts payable. """ - units: typing.Optional[typing.List[Unit]] = pydantic.Field(default=None) + payments: typing.Optional[PaymentsSettingsOutput] = pydantic.Field(default=None) """ - Measurement units. + Settings for the payments module. """ - website: typing.Optional[str] = None - default_role: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + receivable: typing.Optional[ReceivableSettings] = pydantic.Field(default=None) """ - A default role to provision upon new entity creation. + Settings for accounts receivable. """ - payments: typing.Optional[PaymentsSettingsOutput] = pydantic.Field(default=None) + units: typing.Optional[typing.List[Unit]] = pydantic.Field(default=None) """ - Settings for the payments module. + Unused. To manage the [measure units](https://docs.monite.com/accounts-receivable/products#manage-measure-units) for your entities, use the `/measure_units` endpoints. """ - api_version: typing.Optional[ApiVersion] = pydantic.Field(default=None) + website: typing.Optional[str] = pydantic.Field(default=None) """ - Default API version for partner. + The URL of the partner's website. Must be an HTTPS URL. Required if the partner's entities use [payment links](https://docs.monite.com/payments/payment-links). The "Powered by" badge in the payment page footer will link to this website. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/payable_settings.py b/src/monite/types/payable_settings.py index 9d0e001..61bd15d 100644 --- a/src/monite/types/payable_settings.py +++ b/src/monite/types/payable_settings.py @@ -7,22 +7,45 @@ class PayableSettings(UniversalBaseModel): - allow_cancel_duplicates_automatically: typing.Optional[bool] = None - allow_counterpart_autocreation: typing.Optional[bool] = None - allow_counterpart_autolinking: typing.Optional[bool] = None - allow_credit_note_autolinking: typing.Optional[bool] = None - approve_page_url: str + allow_cancel_duplicates_automatically: typing.Optional[bool] = pydantic.Field(default=None) + """ + When enabled, Monite will automatically detect and cancel payables identified as duplicates during ingestion—reducing manual review overhead. + """ + + allow_counterpart_autocreation: typing.Optional[bool] = pydantic.Field(default=None) + """ + Enables creation of a new counterpart record (supplier) when incoming payable data doesn't match any existing counterpart. + """ + + allow_counterpart_autolinking: typing.Optional[bool] = pydantic.Field(default=None) + """ + Automatically links incoming payables to existing counterpart records using matching logic (e.g., tax ID, IBAN, name/address). + """ + + allow_credit_note_autolinking: typing.Optional[bool] = pydantic.Field(default=None) + """ + If true, Monite will attempt to automatically attach credit notes to the corresponding payables when processing them. + """ + + approve_page_url: str = pydantic.Field() + """ + The URL included in approval notification emails and UI buttons, directing approvers to complete the invoice approval workflow. Useful for linking to your custom approval portal. + """ + default_state: typing.Optional[str] = pydantic.Field(default=None) """ - A state each new payable will have upon creation + The initial status assigned to newly created payables (e.g., `draft`, `new`). Determines whether they require approval or review. """ enable_line_items: typing.Optional[bool] = pydantic.Field(default=None) """ - Starting from version 2024-05-25 by default is always set to True. + Partners can set this to True or False to control line item detection in OCR flows. """ - skip_approval_for_paid_invoice: typing.Optional[bool] = None + skip_approval_for_paid_invoice: typing.Optional[bool] = pydantic.Field(default=None) + """ + When set to true, payables that are already marked as paid bypass the approval workflow entirely. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/payment_account_object.py b/src/monite/types/payment_account_object.py index 342d79f..15a3bd5 100644 --- a/src/monite/types/payment_account_object.py +++ b/src/monite/types/payment_account_object.py @@ -10,13 +10,10 @@ class PaymentAccountObject(UniversalBaseModel): id: str = pydantic.Field() """ - ID of a payment account + ID of the entity or counterpart that issued the invoice for which you are creating a payment link. """ - type: PaymentAccountType = pydantic.Field() - """ - Type of a payment account. Can be `entity` or `counterpart` - """ + type: PaymentAccountType if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/payment_intent_payout_method.py b/src/monite/types/payment_intent_payout_method.py deleted file mode 100644 index 07947e6..0000000 --- a/src/monite/types/payment_intent_payout_method.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -PaymentIntentPayoutMethod = typing.Union[typing.Literal["bank_account", "paper_check"], typing.Any] diff --git a/src/monite/types/payment_intents_recipient.py b/src/monite/types/payment_intents_recipient.py deleted file mode 100644 index 0c83ec7..0000000 --- a/src/monite/types/payment_intents_recipient.py +++ /dev/null @@ -1,23 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .payment_intent_payout_method import PaymentIntentPayoutMethod - - -class PaymentIntentsRecipient(UniversalBaseModel): - id: str - bank_account_id: typing.Optional[str] = None - payout_method: typing.Optional[PaymentIntentPayoutMethod] = None - type: typing.Literal["counterpart"] = "counterpart" - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/payment_received_event_data.py b/src/monite/types/payment_received_event_data.py index 6005e57..d61280a 100644 --- a/src/monite/types/payment_received_event_data.py +++ b/src/monite/types/payment_received_event_data.py @@ -13,7 +13,7 @@ class PaymentReceivedEventData(UniversalBaseModel): amount_due: int = pydantic.Field() """ - The remainimg amount due of the invoice, in [minor units](https://docs.monite.com/references/currencies#minor-units) of the currency. For example, $12.5 is represented as 1250. + The remaining amount due of the invoice, in [minor units](https://docs.monite.com/references/currencies#minor-units) of the currency. For example, $12.5 is represented as 1250. """ amount_paid: int = pydantic.Field() diff --git a/src/monite/types/payment_record_response.py b/src/monite/types/payment_record_response.py index 694f0a2..2f2cfed 100644 --- a/src/monite/types/payment_record_response.py +++ b/src/monite/types/payment_record_response.py @@ -44,7 +44,7 @@ class PaymentRecordResponse(UniversalBaseModel): Timestamp marking when the payment was executed. Null if payment hasn't occurred yet. """ - payment_intent_id: str = pydantic.Field() + payment_intent_id: typing.Optional[str] = pydantic.Field(default=None) """ Identifier for an payment intent. """ diff --git a/src/monite/types/payments_batch_payment_request.py b/src/monite/types/payments_batch_payment_request.py deleted file mode 100644 index e1ea9ac..0000000 --- a/src/monite/types/payments_batch_payment_request.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .single_payment_intent import SinglePaymentIntent - - -class PaymentsBatchPaymentRequest(UniversalBaseModel): - payer_bank_account_id: str - payment_intents: typing.List[SinglePaymentIntent] - payment_method: typing.Literal["us_ach"] = "us_ach" - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/payments_batch_payment_response.py b/src/monite/types/payments_batch_payment_response.py deleted file mode 100644 index a148646..0000000 --- a/src/monite/types/payments_batch_payment_response.py +++ /dev/null @@ -1,29 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .payments_batch_payment_status import PaymentsBatchPaymentStatus -from .single_payment_intent_response import SinglePaymentIntentResponse - - -class PaymentsBatchPaymentResponse(UniversalBaseModel): - id: str - created_at: dt.datetime - error: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None - payer_bank_account_id: str - payment_intents: typing.List[SinglePaymentIntentResponse] - payment_method: typing.Literal["us_ach"] = "us_ach" - status: PaymentsBatchPaymentStatus - total_amount: typing.Optional[int] = None - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/payments_batch_payment_status.py b/src/monite/types/payments_batch_payment_status.py deleted file mode 100644 index b83294f..0000000 --- a/src/monite/types/payments_batch_payment_status.py +++ /dev/null @@ -1,7 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -PaymentsBatchPaymentStatus = typing.Union[ - typing.Literal["created", "processing", "partially_successful", "succeeded", "failed"], typing.Any -] diff --git a/src/monite/types/payments_settings_input.py b/src/monite/types/payments_settings_input.py index 6d4d087..f74c401 100644 --- a/src/monite/types/payments_settings_input.py +++ b/src/monite/types/payments_settings_input.py @@ -9,10 +9,14 @@ class PaymentsSettingsInput(UniversalBaseModel): payment_page_domain: typing.Optional[str] = None - payment_page_theme: typing.Optional[PaymentPageTheme] = None + payment_page_theme: typing.Optional[PaymentPageTheme] = pydantic.Field(default=None) + """ + See [Payment page customization](https://docs.monite.com/payments/payment-page-customization). + """ + support_email: typing.Optional[str] = pydantic.Field(default=None) """ - The support email address + Required if the partner has UK entities that want to accept Bacs Direct Debit payments. This email address will be included in Bacs debit notification emails sent to the payers, as the contact email address where the payers can send payments-related inquiries. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/payments_settings_output.py b/src/monite/types/payments_settings_output.py index acb070e..9a6bccd 100644 --- a/src/monite/types/payments_settings_output.py +++ b/src/monite/types/payments_settings_output.py @@ -9,10 +9,14 @@ class PaymentsSettingsOutput(UniversalBaseModel): payment_page_domain: typing.Optional[str] = None - payment_page_theme: typing.Optional[PaymentPageTheme] = None + payment_page_theme: typing.Optional[PaymentPageTheme] = pydantic.Field(default=None) + """ + See [Payment page customization](https://docs.monite.com/payments/payment-page-customization). + """ + support_email: typing.Optional[str] = pydantic.Field(default=None) """ - The support email address + Required if the partner has UK entities that want to accept Bacs Direct Debit payments. This email address will be included in Bacs debit notification emails sent to the payers, as the contact email address where the payers can send payments-related inquiries. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/preview_schema2.py b/src/monite/types/preview_schema2.py index f9ee31d..c5efd40 100644 --- a/src/monite/types/preview_schema2.py +++ b/src/monite/types/preview_schema2.py @@ -11,6 +11,11 @@ class PreviewSchema2(UniversalBaseModel): A preview image generated for a file. """ + height: int = pydantic.Field() + """ + The image height in pixels. + """ + url: str = pydantic.Field() """ The image URL. @@ -21,11 +26,6 @@ class PreviewSchema2(UniversalBaseModel): The image width in pixels. """ - height: int = pydantic.Field() - """ - The image height in pixels. - """ - if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/monite/types/pricing_plan.py b/src/monite/types/pricing_plan.py index dc68a0a..6c4daaa 100644 --- a/src/monite/types/pricing_plan.py +++ b/src/monite/types/pricing_plan.py @@ -22,14 +22,14 @@ class PricingPlan(UniversalBaseModel): Transaction fee percentage. 300 means 3.00% """ - repayment_type: WcRepaymentType = pydantic.Field() + repayment_duration_days: typing.Optional[int] = pydantic.Field(default=None) """ - Repayment type of the loan. + This amount of days after which the repayment duration is due. This is only applicable for FIXED_DURATION repayment type """ - repayment_duration_days: typing.Optional[int] = pydantic.Field(default=None) + repayment_type: WcRepaymentType = pydantic.Field() """ - This amount of days after which the repayment duration is due. This is only applicable for FIXED_DURATION repayment type + Repayment type of the loan. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/project_resource.py b/src/monite/types/project_resource.py index 5f5983e..544dba3 100644 --- a/src/monite/types/project_resource.py +++ b/src/monite/types/project_resource.py @@ -16,42 +16,42 @@ class ProjectResource(UniversalBaseModel): created_at: dt.datetime = pydantic.Field() """ - Project created at + UTC date and time when this project was created. """ updated_at: dt.datetime = pydantic.Field() """ - Last time project was updated at + UTC date and time when this project was last updated. """ code: typing.Optional[str] = pydantic.Field(default=None) """ - Project code + A user-defined identifier of this project. """ color: typing.Optional[str] = pydantic.Field(default=None) """ - Project color + Project color as a [CSS-compatible](https://developer.mozilla.org/en-US/docs/Web/CSS/color) value. Client applications can use this to color-code the projects or project-related data. """ created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) """ - Project created by entity user + ID of the entity user who created this project, or `null` if it was created using a partner access token. """ description: typing.Optional[str] = pydantic.Field(default=None) """ - Description of project + A user-defined description of the project. """ end_date: typing.Optional[str] = pydantic.Field(default=None) """ - Project end date + Project end date. """ entity_id: str = pydantic.Field() """ - The ID of the entity to which the project was issued. + ID of the entity that owns this project. """ name: str = pydantic.Field() @@ -61,17 +61,17 @@ class ProjectResource(UniversalBaseModel): parent_id: typing.Optional[str] = pydantic.Field(default=None) """ - Parent project ID + Unused. Reserved for future use. """ partner_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ - Project metadata + [Metadata](https://docs.monite.com/common/metadata) for partner needs. """ start_date: typing.Optional[str] = pydantic.Field(default=None) """ - Project start date + Project start date. """ tags: typing.Optional[typing.List[TagReadSchema]] = pydantic.Field(default=None) diff --git a/src/monite/types/purchase_order_counterpart_individual_root_response.py b/src/monite/types/purchase_order_counterpart_individual_root_response.py index ecea3cc..c60bfa1 100644 --- a/src/monite/types/purchase_order_counterpart_individual_root_response.py +++ b/src/monite/types/purchase_order_counterpart_individual_root_response.py @@ -35,6 +35,11 @@ class PurchaseOrderCounterpartIndividualRootResponse(UniversalBaseModel): `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. """ + created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Entity user ID of counterpart creator. + """ + default_billing_address_id: typing.Optional[str] = pydantic.Field(default=None) """ ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. @@ -45,11 +50,6 @@ class PurchaseOrderCounterpartIndividualRootResponse(UniversalBaseModel): ID of the shipping address. """ - created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) - """ - Entity user ID of counterpart creator. - """ - individual: PurchaseOrderCounterpartIndividualResponse language: typing.Optional[LanguageCodeEnum] = pydantic.Field(default=None) """ diff --git a/src/monite/types/purchase_order_counterpart_organization_root_response.py b/src/monite/types/purchase_order_counterpart_organization_root_response.py index 06716e1..60ac774 100644 --- a/src/monite/types/purchase_order_counterpart_organization_root_response.py +++ b/src/monite/types/purchase_order_counterpart_organization_root_response.py @@ -35,6 +35,11 @@ class PurchaseOrderCounterpartOrganizationRootResponse(UniversalBaseModel): `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. """ + created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Entity user ID of counterpart creator. + """ + default_billing_address_id: typing.Optional[str] = pydantic.Field(default=None) """ ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. @@ -45,11 +50,6 @@ class PurchaseOrderCounterpartOrganizationRootResponse(UniversalBaseModel): ID of the shipping address. """ - created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) - """ - Entity user ID of counterpart creator. - """ - language: typing.Optional[LanguageCodeEnum] = pydantic.Field(default=None) """ The language used to generate PDF documents for this counterpart. diff --git a/src/monite/types/quote_response_payload.py b/src/monite/types/quote_response_payload.py index e35765e..cc3bcbb 100644 --- a/src/monite/types/quote_response_payload.py +++ b/src/monite/types/quote_response_payload.py @@ -5,9 +5,11 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_response import AttachmentResponse from .counterpart_type import CounterpartType from .currency_enum import CurrencyEnum from .discount_response import DiscountResponse +from .document_rendering_settings import DocumentRenderingSettings from .language_code_enum import LanguageCodeEnum from .quote_response_payload_entity import QuoteResponsePayloadEntity from .quote_state_enum import QuoteStateEnum @@ -35,14 +37,19 @@ class QuoteResponsePayload(UniversalBaseModel): Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. """ + attachments: typing.Optional[typing.List[AttachmentResponse]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + based_on: typing.Optional[str] = pydantic.Field(default=None) """ - The unique ID of a previous document related to the receivable if applicable. + Unused. Always returns `null`. """ based_on_document_id: typing.Optional[str] = pydantic.Field(default=None) """ - The unique document ID of a previous document related to the receivable if applicable. + Unused. Always returns `null`. """ comment: typing.Optional[str] = pydantic.Field(default=None) @@ -135,14 +142,19 @@ class QuoteResponsePayload(UniversalBaseModel): The sequential code systematically assigned to invoices. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + due_date: typing.Optional[str] = pydantic.Field(default=None) """ - Optional field representing date until which invoice should be paid + Unused. Always returns `null`. """ einvoice_file_url: typing.Optional[str] = pydantic.Field(default=None) """ - E-invoice XML file that was sent to the counterpart via an e-invoicing network. Available only if `is_einvoice` is `true`. + Unused. Always returns `null`. """ entity: QuoteResponsePayloadEntity @@ -171,7 +183,7 @@ class QuoteResponsePayload(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. See also: `memo`, `commercial_condition_description`. """ issue_date: typing.Optional[dt.datetime] = pydantic.Field(default=None) @@ -182,7 +194,7 @@ class QuoteResponsePayload(UniversalBaseModel): line_items: typing.List[ResponseItem] memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable. + An optional note for the customer, displayed above the line items table in the PDF. See also: `footer`, `commercial_condition_description`. """ original_file_language: LanguageCodeEnum = pydantic.Field() @@ -202,7 +214,7 @@ class QuoteResponsePayload(UniversalBaseModel): project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this quote. If specified, the project name will be included in the header of the PDF quote. """ quote_accept_page_url: typing.Optional[str] = pydantic.Field(default=None) diff --git a/src/monite/types/receipt_cursor_fields.py b/src/monite/types/receipt_cursor_fields.py new file mode 100644 index 0000000..c79e7b2 --- /dev/null +++ b/src/monite/types/receipt_cursor_fields.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ReceiptCursorFields = typing.Union[typing.Literal["id", "created_at"], typing.Any] diff --git a/src/monite/types/receipt_line_item_cursor_fields.py b/src/monite/types/receipt_line_item_cursor_fields.py new file mode 100644 index 0000000..3d65246 --- /dev/null +++ b/src/monite/types/receipt_line_item_cursor_fields.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ReceiptLineItemCursorFields = typing.Union[typing.Literal["created_at", "updated_at"], typing.Any] diff --git a/src/monite/types/receipt_line_item_response_schema.py b/src/monite/types/receipt_line_item_response_schema.py new file mode 100644 index 0000000..2bf3348 --- /dev/null +++ b/src/monite/types/receipt_line_item_response_schema.py @@ -0,0 +1,63 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class ReceiptLineItemResponseSchema(UniversalBaseModel): + id: str = pydantic.Field() + """ + Unique line item ID. + """ + + created_at: dt.datetime = pydantic.Field() + """ + Created at. + """ + + updated_at: dt.datetime = pydantic.Field() + """ + Updated at. + """ + + accounting_tax_rate_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Accounting tax rate ID. + """ + + cost_center_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Cost center ID. + """ + + created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Created by user. + """ + + name: typing.Optional[str] = pydantic.Field(default=None) + """ + Line item name. + """ + + receipt_id: str = pydantic.Field() + """ + Receipt ID. + """ + + total: typing.Optional[int] = pydantic.Field(default=None) + """ + Total. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/single_payment_intent.py b/src/monite/types/receipt_line_items_pagination_response.py similarity index 53% rename from src/monite/types/single_payment_intent.py rename to src/monite/types/receipt_line_items_pagination_response.py index 15833af..274231b 100644 --- a/src/monite/types/single_payment_intent.py +++ b/src/monite/types/receipt_line_items_pagination_response.py @@ -4,18 +4,20 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .payment_intents_recipient import PaymentIntentsRecipient -from .payment_object_payable import PaymentObjectPayable +from .receipt_line_item_response_schema import ReceiptLineItemResponseSchema -class SinglePaymentIntent(UniversalBaseModel): - object: PaymentObjectPayable - payment_reference: typing.Optional[str] = pydantic.Field(default=None) +class ReceiptLineItemsPaginationResponse(UniversalBaseModel): + data: typing.List[ReceiptLineItemResponseSchema] + next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - Must be provided if payable's document id is missing. + Next page token. """ - recipient: PaymentIntentsRecipient + prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + """ + Previous page token. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/airwallex_plaid_account.py b/src/monite/types/receipt_pagination_response.py similarity index 56% rename from src/monite/types/airwallex_plaid_account.py rename to src/monite/types/receipt_pagination_response.py index 007fd2a..295027f 100644 --- a/src/monite/types/airwallex_plaid_account.py +++ b/src/monite/types/receipt_pagination_response.py @@ -4,22 +4,19 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .receipt_response_schema import ReceiptResponseSchema -class AirwallexPlaidAccount(UniversalBaseModel): - id: str = pydantic.Field() +class ReceiptPaginationResponse(UniversalBaseModel): + data: typing.List[ReceiptResponseSchema] + next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - Plaid`s unique identifier for the account + Next page token. """ - mask: str = pydantic.Field() + prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - The last 2-4 alphanumeric characters of an account's official account number - """ - - name: str = pydantic.Field() - """ - The name of the account, either assigned by the user or by the financial institution itself + Previous page token. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/receipt_response_schema.py b/src/monite/types/receipt_response_schema.py new file mode 100644 index 0000000..f0fa4c1 --- /dev/null +++ b/src/monite/types/receipt_response_schema.py @@ -0,0 +1,110 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .currency_enum import CurrencyEnum +from .source_of_receipt_data_enum import SourceOfReceiptDataEnum + + +class ReceiptResponseSchema(UniversalBaseModel): + id: str = pydantic.Field() + """ + Unique receipt ID. + """ + + created_at: dt.datetime = pydantic.Field() + """ + Creation timestamp. + """ + + updated_at: dt.datetime = pydantic.Field() + """ + Update timestamp. + """ + + created_by_entity_user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Entity user who created. + """ + + currency: typing.Optional[CurrencyEnum] = pydantic.Field(default=None) + """ + Currency code. + """ + + currency_exchange: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + """ + Currency exchange details. + """ + + document_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Receipt number. + """ + + file_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The id of the receipt file stored in the file saver. + """ + + file_url: typing.Optional[str] = pydantic.Field(default=None) + """ + The URL of the receipt file stored in the file saver. + """ + + issued_at: typing.Optional[dt.datetime] = pydantic.Field(default=None) + """ + Date when the receipt was issued. + """ + + merchant_location: typing.Optional[str] = pydantic.Field(default=None) + """ + Merchant location. + """ + + merchant_name: typing.Optional[str] = pydantic.Field(default=None) + """ + Merchant name. + """ + + ocr_request_id: typing.Optional[str] = pydantic.Field(default=None) + """ + OCR request id. + """ + + ocr_status: typing.Optional[str] = pydantic.Field(default=None) + """ + OCR status. + """ + + partner_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + """ + Partner metadata. + """ + + source_of_data: typing.Optional[SourceOfReceiptDataEnum] = pydantic.Field(default=None) + """ + Source of data. + """ + + total_amount: typing.Optional[int] = pydantic.Field(default=None) + """ + Total amount in minor units. + """ + + transaction_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Transaction ID. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/monite/types/receivable_facade_create_invoice_payload.py b/src/monite/types/receivable_facade_create_invoice_payload.py index 63ae028..429666f 100644 --- a/src/monite/types/receivable_facade_create_invoice_payload.py +++ b/src/monite/types/receivable_facade_create_invoice_payload.py @@ -4,8 +4,10 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_request import AttachmentRequest from .currency_enum import CurrencyEnum from .discount import Discount +from .document_rendering_settings import DocumentRenderingSettings from .inline_payment_terms_request_payload import InlinePaymentTermsRequestPayload from .line_item import LineItem from .receivable_entity_base import ReceivableEntityBase @@ -13,6 +15,11 @@ class ReceivableFacadeCreateInvoicePayload(UniversalBaseModel): + attachments: typing.Optional[typing.List[AttachmentRequest]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + commercial_condition_description: typing.Optional[str] = None counterpart_billing_address_id: str = pydantic.Field() """ @@ -61,6 +68,11 @@ class ReceivableFacadeCreateInvoicePayload(UniversalBaseModel): The document number of the receivable, which will appear in the PDF document. Can be set manually only in the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance). Otherwise (or if omitted), it will be generated automatically based on the entity's [document number customization](https://docs.monite.com/advanced/document-number-customization) settings when the document is issued. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + entity: typing.Optional[ReceivableEntityBase] = None entity_bank_account_id: typing.Optional[str] = pydantic.Field(default=None) """ @@ -74,7 +86,9 @@ class ReceivableFacadeCreateInvoicePayload(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `memo`, `commercial_condition_description`. """ fulfillment_date: typing.Optional[str] = pydantic.Field(default=None) @@ -94,7 +108,9 @@ class ReceivableFacadeCreateInvoicePayload(UniversalBaseModel): line_items: typing.List[LineItem] memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable + An optional note for the customer that will be displayed above the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `footer`, `commercial_condition_description`. """ network_credentials_id: typing.Optional[str] = pydantic.Field(default=None) @@ -118,7 +134,7 @@ class ReceivableFacadeCreateInvoicePayload(UniversalBaseModel): payment_terms_id: typing.Optional[str] = None project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this invoice. If specified, the project name will be included in the header of the PDF invoice. """ purchase_order: typing.Optional[str] = pydantic.Field(default=None) diff --git a/src/monite/types/receivable_facade_create_quote_payload.py b/src/monite/types/receivable_facade_create_quote_payload.py index 232b85d..844a2fa 100644 --- a/src/monite/types/receivable_facade_create_quote_payload.py +++ b/src/monite/types/receivable_facade_create_quote_payload.py @@ -4,14 +4,21 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_request import AttachmentRequest from .currency_enum import CurrencyEnum from .discount import Discount +from .document_rendering_settings import DocumentRenderingSettings from .line_item import LineItem from .receivable_entity_base import ReceivableEntityBase from .vat_mode_enum import VatModeEnum class ReceivableFacadeCreateQuotePayload(UniversalBaseModel): + attachments: typing.Optional[typing.List[AttachmentRequest]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + commercial_condition_description: typing.Optional[str] = None counterpart_billing_address_id: str = pydantic.Field() """ @@ -55,6 +62,11 @@ class ReceivableFacadeCreateQuotePayload(UniversalBaseModel): The document number of the receivable, which will appear in the PDF document. Can be set manually only in the [non-compliant mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance). Otherwise (or if omitted), it will be generated automatically based on the entity's [document number customization](https://docs.monite.com/advanced/document-number-customization) settings when the document is issued. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + entity: typing.Optional[ReceivableEntityBase] = None entity_bank_account_id: typing.Optional[str] = pydantic.Field(default=None) """ @@ -73,13 +85,17 @@ class ReceivableFacadeCreateQuotePayload(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `memo`, `commercial_condition_description`. """ line_items: typing.List[LineItem] memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable + An optional note for the customer that will be displayed above the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `footer`, `commercial_condition_description`. """ partner_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) @@ -89,7 +105,7 @@ class ReceivableFacadeCreateQuotePayload(UniversalBaseModel): project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this quote. If specified, the project name will be included in the header of the PDF quote. """ quote_accept_page_url: typing.Optional[str] = pydantic.Field(default=None) diff --git a/src/monite/types/receivable_response.py b/src/monite/types/receivable_response.py index aa22652..b455159 100644 --- a/src/monite/types/receivable_response.py +++ b/src/monite/types/receivable_response.py @@ -7,11 +7,13 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_response import AttachmentResponse from .counterpart_type import CounterpartType from .credit_note_response_payload_entity import CreditNoteResponsePayloadEntity from .credit_note_state_enum import CreditNoteStateEnum from .currency_enum import CurrencyEnum from .discount_response import DiscountResponse +from .document_rendering_settings import DocumentRenderingSettings from .einvoicing_credentials import EinvoicingCredentials from .invoice_response_payload_entity import InvoiceResponsePayloadEntity from .language_code_enum import LanguageCodeEnum @@ -37,6 +39,7 @@ class ReceivableResponse_Quote(UniversalBaseModel): id: str created_at: dt.datetime updated_at: dt.datetime + attachments: typing.Optional[typing.List[AttachmentResponse]] = None based_on: typing.Optional[str] = None based_on_document_id: typing.Optional[str] = None comment: typing.Optional[str] = None @@ -57,6 +60,7 @@ class ReceivableResponse_Quote(UniversalBaseModel): discount: typing.Optional[DiscountResponse] = None discounted_subtotal: typing.Optional[int] = None document_id: typing.Optional[str] = None + document_rendering: typing.Optional[DocumentRenderingSettings] = None due_date: typing.Optional[str] = None einvoice_file_url: typing.Optional[str] = None entity: QuoteResponsePayloadEntity @@ -110,6 +114,7 @@ class ReceivableResponse_Invoice(UniversalBaseModel): amount_due: int amount_paid: int amount_to_pay: typing.Optional[int] = None + attachments: typing.Optional[typing.List[AttachmentResponse]] = None based_on: typing.Optional[str] = None based_on_document_id: typing.Optional[str] = None comment: typing.Optional[str] = None @@ -131,6 +136,7 @@ class ReceivableResponse_Invoice(UniversalBaseModel): discount: typing.Optional[DiscountResponse] = None discounted_subtotal: typing.Optional[int] = None document_id: typing.Optional[str] = None + document_rendering: typing.Optional[DocumentRenderingSettings] = None due_date: typing.Optional[str] = None einvoice_error_comment: typing.Optional[str] = None einvoice_file_url: typing.Optional[str] = None @@ -191,6 +197,7 @@ class ReceivableResponse_CreditNote(UniversalBaseModel): id: str created_at: dt.datetime updated_at: dt.datetime + attachments: typing.Optional[typing.List[AttachmentResponse]] = None based_on: typing.Optional[str] = None based_on_document_id: typing.Optional[str] = None commercial_condition_description: typing.Optional[str] = None @@ -211,6 +218,7 @@ class ReceivableResponse_CreditNote(UniversalBaseModel): discount: typing.Optional[DiscountResponse] = None discounted_subtotal: typing.Optional[int] = None document_id: typing.Optional[str] = None + document_rendering: typing.Optional[DocumentRenderingSettings] = None due_date: typing.Optional[str] = None einvoice_error_comment: typing.Optional[str] = None einvoice_file_url: typing.Optional[str] = None @@ -222,6 +230,7 @@ class ReceivableResponse_CreditNote(UniversalBaseModel): file_language: LanguageCodeEnum file_url: typing.Optional[str] = None footer: typing.Optional[str] = None + is_einvoice: typing.Optional[bool] = None issue_date: typing.Optional[dt.datetime] = None line_items: typing.List[ResponseItem] memo: typing.Optional[str] = None diff --git a/src/monite/types/receivable_settings.py b/src/monite/types/receivable_settings.py index 47a63b6..c8b3c76 100644 --- a/src/monite/types/receivable_settings.py +++ b/src/monite/types/receivable_settings.py @@ -7,8 +7,15 @@ class ReceivableSettings(UniversalBaseModel): - create_without_personal_info: bool - deduction_title: typing.Optional[str] = None + create_without_personal_info: bool = pydantic.Field() + """ + Unused. + """ + + deduction_title: typing.Optional[str] = pydantic.Field(default=None) + """ + The title for the section in PDF invoices that contains [special deductions or incentives](https://docs.monite.com/accounts-receivable/special-deductions). If `null`, the title defaults to "Incentives" (localized). Custom title is not automatically localized. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/recipient_type.py b/src/monite/types/recipient_type.py deleted file mode 100644 index 0d93383..0000000 --- a/src/monite/types/recipient_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -RecipientType = typing.Union[typing.Literal["entity", "counterpart"], typing.Any] diff --git a/src/monite/types/related_documents.py b/src/monite/types/related_documents.py index e7c960e..a16ba54 100644 --- a/src/monite/types/related_documents.py +++ b/src/monite/types/related_documents.py @@ -7,8 +7,15 @@ class RelatedDocuments(UniversalBaseModel): - credit_note_ids: typing.Optional[typing.List[str]] = None - proforma_invoice_id: typing.Optional[str] = None + credit_note_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + """ + IDs of credit notes created from this invoice. The list includes both draft and issued credit notes. + """ + + proforma_invoice_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Unused. Always returns `null`. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/repayment_schedule.py b/src/monite/types/repayment_schedule.py index 54c3a8e..db22bcb 100644 --- a/src/monite/types/repayment_schedule.py +++ b/src/monite/types/repayment_schedule.py @@ -11,14 +11,14 @@ class RepaymentSchedule(UniversalBaseModel): Repayment schedule model """ - repayment_date: str = pydantic.Field() + repayment_amount: int = pydantic.Field() """ - Repayment date in ISO 8601 format + Repayment amount in minor units """ - repayment_amount: int = pydantic.Field() + repayment_date: str = pydantic.Field() """ - Repayment amount in minor units + Repayment date in ISO 8601 format """ repayment_fee_amount: int = pydantic.Field() diff --git a/src/monite/types/role_pagination_response.py b/src/monite/types/role_pagination_response.py index ce02aaf..35553e4 100644 --- a/src/monite/types/role_pagination_response.py +++ b/src/monite/types/role_pagination_response.py @@ -13,14 +13,14 @@ class RolePaginationResponse(UniversalBaseModel): array of records """ - prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). + A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). """ - next_pagination_token: typing.Optional[str] = pydantic.Field(default=None) + prev_pagination_token: typing.Optional[str] = pydantic.Field(default=None) """ - A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). + A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/role_response.py b/src/monite/types/role_response.py index e300775..09079ac 100644 --- a/src/monite/types/role_response.py +++ b/src/monite/types/role_response.py @@ -15,29 +15,29 @@ class RoleResponse(UniversalBaseModel): UUID role ID """ - name: str = pydantic.Field() + created_at: dt.datetime = pydantic.Field() """ - Role name + UTC datetime """ - permissions: BizObjectsSchemaOutput = pydantic.Field() + updated_at: dt.datetime = pydantic.Field() """ - Access permissions + UTC datetime """ - status: StatusEnum = pydantic.Field() + name: str = pydantic.Field() """ - record status, 'active' by default + Role name """ - created_at: dt.datetime = pydantic.Field() + permissions: BizObjectsSchemaOutput = pydantic.Field() """ - UTC datetime + Access permissions """ - updated_at: dt.datetime = pydantic.Field() + status: StatusEnum = pydantic.Field() """ - UTC datetime + record status, 'active' by default """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/root_schema_input.py b/src/monite/types/root_schema_input.py index 848dba3..c178590 100644 --- a/src/monite/types/root_schema_input.py +++ b/src/monite/types/root_schema_input.py @@ -318,6 +318,20 @@ class Config: extra = pydantic.Extra.allow +class RootSchemaInput_Receipt(UniversalBaseModel): + object_type: typing.Literal["receipt"] = "receipt" + actions: typing.Optional[typing.List[ActionSchema]] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow + + class RootSchemaInput_Receivable(UniversalBaseModel): object_type: typing.Literal["receivable"] = "receivable" actions: typing.Optional[typing.List[ActionSchema]] = None @@ -453,6 +467,7 @@ class Config: RootSchemaInput_Person, RootSchemaInput_Product, RootSchemaInput_Project, + RootSchemaInput_Receipt, RootSchemaInput_Receivable, RootSchemaInput_Reconciliation, RootSchemaInput_Role, diff --git a/src/monite/types/root_schema_output.py b/src/monite/types/root_schema_output.py index ea4abab..a9e89f2 100644 --- a/src/monite/types/root_schema_output.py +++ b/src/monite/types/root_schema_output.py @@ -318,6 +318,20 @@ class Config: extra = pydantic.Extra.allow +class RootSchemaOutput_Receipt(UniversalBaseModel): + object_type: typing.Literal["receipt"] = "receipt" + actions: typing.Optional[typing.List[ActionSchema]] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow + + class RootSchemaOutput_Receivable(UniversalBaseModel): object_type: typing.Literal["receivable"] = "receivable" actions: typing.Optional[typing.List[ActionSchema]] = None @@ -453,6 +467,7 @@ class Config: RootSchemaOutput_Person, RootSchemaOutput_Product, RootSchemaOutput_Project, + RootSchemaOutput_Receipt, RootSchemaOutput_Receivable, RootSchemaOutput_Reconciliation, RootSchemaOutput_Role, diff --git a/src/monite/types/settings_response.py b/src/monite/types/settings_response.py index bb3c2fd..afd1eee 100644 --- a/src/monite/types/settings_response.py +++ b/src/monite/types/settings_response.py @@ -7,7 +7,7 @@ from .accounting_settings import AccountingSettings from .currency_settings_output import CurrencySettingsOutput from .document_i_ds_settings import DocumentIDsSettings -from .document_rendering_settings import DocumentRenderingSettings +from .document_rendering_settings_output import DocumentRenderingSettingsOutput from .language_code_enum import LanguageCodeEnum from .ocr_auto_tagging_settings_request import OcrAutoTaggingSettingsRequest from .payment_priority_enum import PaymentPriorityEnum @@ -17,31 +17,31 @@ class SettingsResponse(UniversalBaseModel): - language: typing.Optional[LanguageCodeEnum] = None - currency: typing.Optional[CurrencySettingsOutput] = None - reminder: typing.Optional[RemindersSettings] = None - vat_mode: typing.Optional[VatModeEnum] = pydantic.Field(default=None) - """ - Defines whether the prices of products in receivables will already include VAT or not. - """ - - vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = pydantic.Field(default=None) + accounting: typing.Optional[AccountingSettings] = None + allow_purchase_order_autolinking: typing.Optional[bool] = pydantic.Field(default=None) """ - Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. + Automatically attempt to find a corresponding purchase order for all incoming payables. """ - payment_priority: typing.Optional[PaymentPriorityEnum] = pydantic.Field(default=None) + currency: typing.Optional[CurrencySettingsOutput] = None + document_ids: typing.Optional[DocumentIDsSettings] = None + document_rendering: typing.Optional[DocumentRenderingSettingsOutput] = pydantic.Field(default=None) """ - Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + Settings for rendering documents in PDF format. """ - allow_purchase_order_autolinking: typing.Optional[bool] = pydantic.Field(default=None) + generate_paid_invoice_pdf: typing.Optional[bool] = pydantic.Field(default=None) """ - Automatically attempt to find a corresponding purchase order for all incoming payables. + This setting affects how PDF is generated for accounts receivable invoices that are paid, partially paid, or have credit notes applied. + If this setting is `true`: + + * The totals block in the PDF invoice will include a list of all payments made and credit notes issued. + * Once an invoice becomes fully paid, the payment link and QR code are removed. + + The PDF invoice gets regenerated at the moment when an invoice payment is recorded or a credit note is issued. This PDF is not issued as a separate document, and the original PDF invoice is no longer available. """ - receivable_edit_flow: typing.Optional[ReceivableEditFlow] = None - document_ids: typing.Optional[DocumentIDsSettings] = None + language: typing.Optional[LanguageCodeEnum] = None payables_ocr_auto_tagging: typing.Optional[typing.List[OcrAutoTaggingSettingsRequest]] = pydantic.Field( default=None ) @@ -49,29 +49,39 @@ class SettingsResponse(UniversalBaseModel): Auto tagging settings for all incoming OCR payable documents. """ + payables_skip_approval_flow: typing.Optional[bool] = pydantic.Field(default=None) + """ + If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + """ + + payment_priority: typing.Optional[PaymentPriorityEnum] = pydantic.Field(default=None) + """ + Payment preferences for entity to automate calculating suggested payment date based on payment terms and entity preferences. + """ + quote_signature_required: typing.Optional[bool] = pydantic.Field(default=None) """ Sets the default behavior of whether a signature is required to accept quotes. """ - generate_paid_invoice_pdf: typing.Optional[bool] = pydantic.Field(default=None) + receivable_edit_flow: typing.Optional[ReceivableEditFlow] = pydantic.Field(default=None) """ - This setting affects how PDF is generated for paid accounts receivable invoices. If set to `true`, once an invoice is fully paid its PDF version is updated to display the amount paid and the payment-related features are removed. - - The PDF file gets regenerated at the moment when an invoice becomes paid. It is not issued as a separate document, and the original PDF invoice is no longer available. + [Invoice compliance mode](https://docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance) for accounts receivable. Possible values: - This field is deprecated and will be replaced by `document_rendering.invoice.generate_paid_invoice_pdf`. + * `compliant` - invoices cannot be edited once issued. + * `non_compliant` - issued invoices can still be edited. + * `partially_compliant` - deprecated mode, should not be used. """ - accounting: typing.Optional[AccountingSettings] = None - payables_skip_approval_flow: typing.Optional[bool] = pydantic.Field(default=None) + reminder: typing.Optional[RemindersSettings] = None + vat_inclusive_discount_mode: typing.Optional[VatModeEnum] = pydantic.Field(default=None) """ - If enabled, the approval policy will be skipped and the payable will be moved to `waiting_to_be_paid` status. + Defines whether the amount discounts (for percentage discounts it does not matter) on VAT inclusive invoices will be applied on amounts including VAT or excluding VAT. """ - document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + vat_mode: typing.Optional[VatModeEnum] = pydantic.Field(default=None) """ - Settings for rendering documents in PDF format. + Defines whether the prices of products in receivables will already include VAT or not. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/signature.py b/src/monite/types/signature.py index 33ba6ed..a757c07 100644 --- a/src/monite/types/signature.py +++ b/src/monite/types/signature.py @@ -9,17 +9,17 @@ class Signature(UniversalBaseModel): email: str = pydantic.Field() """ - The email of a person who signed a quote + The email of the person who signed the quote. """ full_name: str = pydantic.Field() """ - The full name of a person who signed a quote + The full name of the person who signed the quote. """ signature_image: str = pydantic.Field() """ - Base64 encoded PNG image of a signature + Base64-encoded PNG image of the signature of the person who signed the quote. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/single_payment_intent_response.py b/src/monite/types/single_payment_intent_response.py deleted file mode 100644 index d3e8d51..0000000 --- a/src/monite/types/single_payment_intent_response.py +++ /dev/null @@ -1,31 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .currency_enum import CurrencyEnum -from .payment_intents_recipient import PaymentIntentsRecipient -from .payment_object_payable import PaymentObjectPayable - - -class SinglePaymentIntentResponse(UniversalBaseModel): - id: str - created_at: dt.datetime - amount: int - currency: CurrencyEnum - error: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None - object: PaymentObjectPayable - payment_reference: str - recipient: PaymentIntentsRecipient - status: str - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/source_of_receipt_data_enum.py b/src/monite/types/source_of_receipt_data_enum.py new file mode 100644 index 0000000..d17708c --- /dev/null +++ b/src/monite/types/source_of_receipt_data_enum.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +SourceOfReceiptDataEnum = typing.Union[typing.Literal["ocr", "user_specified"], typing.Any] diff --git a/src/monite/types/recipient.py b/src/monite/types/suggested_counterpart_payload.py similarity index 71% rename from src/monite/types/recipient.py rename to src/monite/types/suggested_counterpart_payload.py index 36032ff..d8fdf85 100644 --- a/src/monite/types/recipient.py +++ b/src/monite/types/suggested_counterpart_payload.py @@ -4,12 +4,13 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .recipient_type import RecipientType -class Recipient(UniversalBaseModel): +class SuggestedCounterpartPayload(UniversalBaseModel): id: str - type: RecipientType + address_id: typing.Optional[str] = None + bank_account_id: typing.Optional[str] = None + vat_id_id: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/payment_object_payable.py b/src/monite/types/suggested_response.py similarity index 73% rename from src/monite/types/payment_object_payable.py rename to src/monite/types/suggested_response.py index e5c1afe..ce04664 100644 --- a/src/monite/types/payment_object_payable.py +++ b/src/monite/types/suggested_response.py @@ -4,11 +4,11 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .suggested_counterpart_payload import SuggestedCounterpartPayload -class PaymentObjectPayable(UniversalBaseModel): - id: str - type: typing.Literal["payable"] = "payable" +class SuggestedResponse(UniversalBaseModel): + suggested_counterpart: SuggestedCounterpartPayload if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/sync_record_resource.py b/src/monite/types/sync_record_resource.py index e4c0615..a608b8d 100644 --- a/src/monite/types/sync_record_resource.py +++ b/src/monite/types/sync_record_resource.py @@ -17,16 +17,16 @@ class SyncRecordResource(UniversalBaseModel): updated_at: dt.datetime errors: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None last_pulled_at: dt.datetime - object_updated_at: typing.Optional[dt.datetime] = None object_id: typing.Optional[str] = None + object_type: ObjectMatchTypes + object_updated_at: typing.Optional[dt.datetime] = None platform: typing.Optional[Platform] = None - platform_updated_at: typing.Optional[dt.datetime] = None platform_object_id: typing.Optional[str] = None + platform_updated_at: typing.Optional[dt.datetime] = None provider: typing.Optional[ServiceProvidersEnum] = None - provider_updated_at: typing.Optional[dt.datetime] = None provider_object_id: typing.Optional[str] = None + provider_updated_at: typing.Optional[dt.datetime] = None sync_status: SyncStatus - object_type: ObjectMatchTypes if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/total_vat_amount_item_component.py b/src/monite/types/total_vat_amount_item_component.py index c4f5024..36da65a 100644 --- a/src/monite/types/total_vat_amount_item_component.py +++ b/src/monite/types/total_vat_amount_item_component.py @@ -7,15 +7,15 @@ class TotalVatAmountItemComponent(UniversalBaseModel): - name: str - value: float = pydantic.Field() + amount: int = pydantic.Field() """ - Percent minor units. Example: 12.5% is 1250. + The total VAT of all line items, in [minor units](https://docs.monite.com/references/currencies#minor-units). """ - amount: int = pydantic.Field() + name: str + value: float = pydantic.Field() """ - The total VAT of all line items, in [minor units](https://docs.monite.com/references/currencies#minor-units). + Percent minor units. Example: 12.5% is 1250. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/update_credit_note.py b/src/monite/types/update_credit_note.py index 35421d8..8e1ff09 100644 --- a/src/monite/types/update_credit_note.py +++ b/src/monite/types/update_credit_note.py @@ -4,12 +4,19 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_request import AttachmentRequest +from .document_rendering_settings import DocumentRenderingSettings from .receivable_counterpart_contact import ReceivableCounterpartContact from .receivable_entity_base import ReceivableEntityBase from .update_line_item_for_credit_note import UpdateLineItemForCreditNote class UpdateCreditNote(UniversalBaseModel): + attachments: typing.Optional[typing.List[AttachmentRequest]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + counterpart_billing_address_id: typing.Optional[str] = pydantic.Field(default=None) """ Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. @@ -25,16 +32,25 @@ class UpdateCreditNote(UniversalBaseModel): Address where goods were shipped / where services were provided. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + entity: typing.Optional[ReceivableEntityBase] = None footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `memo`, `commercial_condition_description`. """ line_items: typing.Optional[UpdateLineItemForCreditNote] = None memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable + An optional note for the customer that will be displayed above the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `footer`, `commercial_condition_description`. """ partner_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) @@ -44,7 +60,7 @@ class UpdateCreditNote(UniversalBaseModel): project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this credit note. If specified, the project name will be included in the header of the PDF credit note. """ tag_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) diff --git a/src/monite/types/update_entity_request.py b/src/monite/types/update_entity_request.py index c5adc50..7829c36 100644 --- a/src/monite/types/update_entity_request.py +++ b/src/monite/types/update_entity_request.py @@ -24,39 +24,39 @@ class UpdateEntityRequest(UniversalBaseModel): An official email address of the entity """ - phone: typing.Optional[str] = pydantic.Field(default=None) + individual: typing.Optional[OptionalIndividualSchema] = pydantic.Field(default=None) """ - The contact phone number of the entity. Required for US organizations to use payments. + A set of meta data describing the individual """ - website: typing.Optional[str] = pydantic.Field(default=None) + organization: typing.Optional[OptionalOrganizationSchema] = pydantic.Field(default=None) """ - A website of the entity + A set of meta data describing the organization """ - tax_id: typing.Optional[str] = pydantic.Field(default=None) + phone: typing.Optional[str] = pydantic.Field(default=None) """ - The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. + The contact phone number of the entity. Required for US organizations to use payments. """ - registration_number: typing.Optional[str] = pydantic.Field(default=None) + registration_authority: typing.Optional[str] = pydantic.Field(default=None) """ - (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. + (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. """ - registration_authority: typing.Optional[str] = pydantic.Field(default=None) + registration_number: typing.Optional[str] = pydantic.Field(default=None) """ - (Germany only) The name of the local district court (_Amtsgericht_) where the entity is registered. Required if `registration_number` is provided. + (Germany only) The entity's commercial register number (_Handelsregisternummer_) in the German Commercial Register, if available. """ - organization: typing.Optional[OptionalOrganizationSchema] = pydantic.Field(default=None) + tax_id: typing.Optional[str] = pydantic.Field(default=None) """ - A set of meta data describing the organization + The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. """ - individual: typing.Optional[OptionalIndividualSchema] = pydantic.Field(default=None) + website: typing.Optional[str] = pydantic.Field(default=None) """ - A set of meta data describing the individual + A website of the entity """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/update_invoice.py b/src/monite/types/update_invoice.py index 1e588e2..5f2db2f 100644 --- a/src/monite/types/update_invoice.py +++ b/src/monite/types/update_invoice.py @@ -4,14 +4,21 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_request import AttachmentRequest from .currency_enum import CurrencyEnum from .discount import Discount +from .document_rendering_settings import DocumentRenderingSettings from .inline_payment_terms_request_payload import InlinePaymentTermsRequestPayload from .line_item_update import LineItemUpdate from .receivable_entity_base import ReceivableEntityBase class UpdateInvoice(UniversalBaseModel): + attachments: typing.Optional[typing.List[AttachmentRequest]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + contact_id: typing.Optional[str] = pydantic.Field(default=None) """ Unique ID of the counterpart contact. @@ -58,6 +65,11 @@ class UpdateInvoice(UniversalBaseModel): The discount for a receivable. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + entity: typing.Optional[ReceivableEntityBase] = None entity_bank_account_id: typing.Optional[str] = pydantic.Field(default=None) """ @@ -71,7 +83,9 @@ class UpdateInvoice(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `memo`, `commercial_condition_description`. """ fulfillment_date: typing.Optional[str] = pydantic.Field(default=None) @@ -91,7 +105,9 @@ class UpdateInvoice(UniversalBaseModel): line_items: typing.Optional[typing.List[LineItemUpdate]] = None memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable + An optional note for the customer that will be displayed above the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `footer`, `commercial_condition_description`. """ network_credentials_id: typing.Optional[str] = pydantic.Field(default=None) @@ -119,7 +135,7 @@ class UpdateInvoice(UniversalBaseModel): project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this invoice. If specified, the project name will be included in the header of the PDF invoice. """ tag_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) diff --git a/src/monite/types/update_issued_invoice.py b/src/monite/types/update_issued_invoice.py index 6d82fc5..c87dd55 100644 --- a/src/monite/types/update_issued_invoice.py +++ b/src/monite/types/update_issued_invoice.py @@ -5,12 +5,19 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_request import AttachmentRequest +from .document_rendering_settings import DocumentRenderingSettings from .inline_payment_terms_request_payload import InlinePaymentTermsRequestPayload from .receivable_entity_address_schema import ReceivableEntityAddressSchema from .update_issued_invoice_entity import UpdateIssuedInvoiceEntity class UpdateIssuedInvoice(UniversalBaseModel): + attachments: typing.Optional[typing.List[AttachmentRequest]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + contact_id: typing.Optional[str] = pydantic.Field(default=None) """ Unique ID of the counterpart contact. @@ -26,6 +33,11 @@ class UpdateIssuedInvoice(UniversalBaseModel): Counterpart VAT ID id """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + due_date: typing.Optional[str] = pydantic.Field(default=None) """ The date by which the invoice must be paid. @@ -40,7 +52,9 @@ class UpdateIssuedInvoice(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `memo`, `commercial_condition_description`. """ fulfillment_date: typing.Optional[str] = pydantic.Field(default=None) @@ -59,7 +73,9 @@ class UpdateIssuedInvoice(UniversalBaseModel): memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable + An optional note for the customer that will be displayed above the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `footer`, `commercial_condition_description`. """ overdue_reminder_id: typing.Optional[str] = None @@ -73,7 +89,7 @@ class UpdateIssuedInvoice(UniversalBaseModel): payment_terms_id: typing.Optional[str] = None project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this invoice. If specified, the project name will be included in the header of the PDF invoice. """ tag_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) diff --git a/src/monite/types/update_quote.py b/src/monite/types/update_quote.py index 13996b8..73eb379 100644 --- a/src/monite/types/update_quote.py +++ b/src/monite/types/update_quote.py @@ -4,14 +4,21 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .attachment_request import AttachmentRequest from .currency_enum import CurrencyEnum from .discount import Discount +from .document_rendering_settings import DocumentRenderingSettings from .inline_payment_terms_request_payload import InlinePaymentTermsRequestPayload from .line_item_update import LineItemUpdate from .receivable_entity_base import ReceivableEntityBase class UpdateQuote(UniversalBaseModel): + attachments: typing.Optional[typing.List[AttachmentRequest]] = pydantic.Field(default=None) + """ + List of attachments to include with the receivable. Each attachment can be configured for email inclusion. If not provided, no attachments will be associated. + """ + contact_id: typing.Optional[str] = pydantic.Field(default=None) """ Unique ID of the counterpart contact. @@ -53,6 +60,11 @@ class UpdateQuote(UniversalBaseModel): The discount for a receivable. """ + document_rendering: typing.Optional[DocumentRenderingSettings] = pydantic.Field(default=None) + """ + Settings for rendering documents in PDF format, including settings for line items and specific document types. + """ + entity: typing.Optional[ReceivableEntityBase] = None entity_bank_account_id: typing.Optional[str] = pydantic.Field(default=None) """ @@ -71,13 +83,17 @@ class UpdateQuote(UniversalBaseModel): footer: typing.Optional[str] = pydantic.Field(default=None) """ - Optional text displayed below the line items table in the PDF. + Optional text displayed below the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `memo`, `commercial_condition_description`. """ line_items: typing.Optional[typing.List[LineItemUpdate]] = None memo: typing.Optional[str] = pydantic.Field(default=None) """ - A note with additional information for a receivable + An optional note for the customer that will be displayed above the line items table in the PDF. The text can include [variables](https://docs.monite.com/advanced/variables). + + See also: `footer`, `commercial_condition_description`. """ partner_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) @@ -93,7 +109,7 @@ class UpdateQuote(UniversalBaseModel): project_id: typing.Optional[str] = pydantic.Field(default=None) """ - A project related to current receivable + ID of the [project](https://docs.monite.com/common/projects) associated with this quote. If specified, the project name will be included in the header of the PDF quote. """ quote_accept_page_url: typing.Optional[str] = pydantic.Field(default=None) diff --git a/src/monite/types/vat_rate_response.py b/src/monite/types/vat_rate_response.py index 94a05a8..ff16dc7 100644 --- a/src/monite/types/vat_rate_response.py +++ b/src/monite/types/vat_rate_response.py @@ -14,17 +14,17 @@ class VatRateResponse(UniversalBaseModel): id: str = pydantic.Field() """ - Unique identifier of the vat rate object. + A unique ID assigned to this VAT rate. Use this ID as the value of the `line_items[].vat_rate_id` field in invoices and quotes. """ created_at: dt.datetime = pydantic.Field() """ - Date/time when this rate was recorded in the table. + UTC date and time when this VAT rate was recorded in Monite. """ updated_at: dt.datetime = pydantic.Field() """ - Date/time when this rate was updated in the table. + UTC date and time when this VAT rate was last updated by Monite. """ components: typing.Optional[typing.List[VatRateComponent]] = pydantic.Field(default=None) @@ -39,7 +39,7 @@ class VatRateResponse(UniversalBaseModel): created_by: typing.Optional[VatRateCreator] = pydantic.Field(default=None) """ - By whom this rate was recorded: monite employee | accounting system. + Unused. """ status: typing.Optional[VatRateStatusEnum] = pydantic.Field(default=None) @@ -59,7 +59,7 @@ class VatRateResponse(UniversalBaseModel): value: int = pydantic.Field() """ - Percent minor units. Example: 12.5% is 1250. + VAT percentage multiplied by 100. For example, 12.5% is represented as 1250. """ if IS_PYDANTIC_V2: diff --git a/src/monite/types/verification_airwallex_plaid_response.py b/src/monite/types/verification_airwallex_plaid_response.py deleted file mode 100644 index 6485d7f..0000000 --- a/src/monite/types/verification_airwallex_plaid_response.py +++ /dev/null @@ -1,39 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel - - -class VerificationAirwallexPlaidResponse(UniversalBaseModel): - client_name: str = pydantic.Field() - """ - Client name from the request - """ - - expires_at: dt.datetime - link_customization_name: typing.Optional[str] = pydantic.Field(default=None) - """ - Customization name from the request - """ - - link_token: str = pydantic.Field() - """ - Link token that should be used to init Plaid SDK - """ - - redirect_url: str = pydantic.Field() - """ - URL from the request - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/verification_request.py b/src/monite/types/verification_request.py deleted file mode 100644 index 56b4560..0000000 --- a/src/monite/types/verification_request.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .bank_account_verification_type import BankAccountVerificationType -from .verification_airwallex_plaid_request import VerificationAirwallexPlaidRequest - - -class VerificationRequest(UniversalBaseModel): - airwallex_plaid: VerificationAirwallexPlaidRequest - type: BankAccountVerificationType - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/verification_response.py b/src/monite/types/verification_response.py deleted file mode 100644 index a3d7baa..0000000 --- a/src/monite/types/verification_response.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel -from .bank_account_verification_type import BankAccountVerificationType -from .verification_airwallex_plaid_response import VerificationAirwallexPlaidResponse - - -class VerificationResponse(UniversalBaseModel): - airwallex_plaid: VerificationAirwallexPlaidResponse - type: BankAccountVerificationType - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/monite/types/webhook_object_type.py b/src/monite/types/webhook_object_type.py index 18798b3..4980ec2 100644 --- a/src/monite/types/webhook_object_type.py +++ b/src/monite/types/webhook_object_type.py @@ -44,6 +44,7 @@ "workflow_pipeline", "ocr_task", "delivery_note", + "receipt", ], typing.Any, ] diff --git a/src/monite/types/webhook_subscription_resource.py b/src/monite/types/webhook_subscription_resource.py index e7f04d8..a23af0b 100644 --- a/src/monite/types/webhook_subscription_resource.py +++ b/src/monite/types/webhook_subscription_resource.py @@ -9,11 +9,26 @@ class WebhookSubscriptionResource(UniversalBaseModel): - id: str - event_types: typing.List[str] - object_type: WebhookObjectType + id: str = pydantic.Field() + """ + A unique URL assigned to this webhook subscription. This ID is also included in the webhook data as the `webhook_subscription_id` field. + """ + + event_types: typing.List[str] = pydantic.Field() + """ + [Events](https://docs.monite.com/references/webhooks/index#events) included in this webhook subscription. An empty array means the subscription includes all events triggered by the specified `object_type`. + """ + + object_type: WebhookObjectType = pydantic.Field() + """ + The object type associated with this webhook subscription. + """ + status: WebhookSubscriptionStatus - url: str + url: str = pydantic.Field() + """ + URL to which the webhooks are sent. The same URL can be used by multiple webhook subscriptions. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/types/webhook_subscription_resource_with_secret.py b/src/monite/types/webhook_subscription_resource_with_secret.py index beaeb60..34eaf69 100644 --- a/src/monite/types/webhook_subscription_resource_with_secret.py +++ b/src/monite/types/webhook_subscription_resource_with_secret.py @@ -9,12 +9,31 @@ class WebhookSubscriptionResourceWithSecret(UniversalBaseModel): - id: str - event_types: typing.List[str] - object_type: WebhookObjectType - secret: str + id: str = pydantic.Field() + """ + A unique URL assigned to this webhook subscription. This ID is also included in the webhook data as the `webhook_subscription_id` field. + """ + + event_types: typing.List[str] = pydantic.Field() + """ + [Events](https://docs.monite.com/references/webhooks/index#events) included in this webhook subscription. An empty array means the subscription includes all events triggered by the specified `object_type`. + """ + + object_type: WebhookObjectType = pydantic.Field() + """ + The object type associated with this webhook subscription. + """ + + secret: str = pydantic.Field() + """ + The webhook signing secret for this subscriptions. You can use it to [verify webhook signatures](https://docs.monite.com/references/webhooks/signatures). + """ + status: WebhookSubscriptionStatus - url: str + url: str = pydantic.Field() + """ + URL to which the webhooks are sent. The same URL can be used by multiple webhook subscriptions. + """ if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/monite/vat_rates/client.py b/src/monite/vat_rates/client.py index 58d4e56..e8193de 100644 --- a/src/monite/vat_rates/client.py +++ b/src/monite/vat_rates/client.py @@ -35,17 +35,34 @@ def get( request_options: typing.Optional[RequestOptions] = None, ) -> VatRateListResponse: """ + Monite maintains a catalog of VAT and sales tax rates for [select countries](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries). + + To query the applicable VAT/tax rates for an invoice or quote, use: + + `GET /vat_rates?counterpart_id=<...>&entity_vat_id_id=<...>` + + Or if the entity does not have a VAT ID: + + `GET /vat_rates?counterpart_id=<...>` + + **Note:** Entities from countries [not on the list](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries) should not use this endpoint. Instead, those entities can either create custom VAT/tax rates or use the invoice field `line_items[].tax_rate_value` to specify the VAT/tax rates directly. + Parameters ---------- counterpart_address_id : typing.Optional[str] + Unused. Reserved for future use. counterpart_id : typing.Optional[str] + ID of the counterpart that will be invoiced. counterpart_vat_id_id : typing.Optional[str] + Unused. Reserved for future use. entity_vat_id_id : typing.Optional[str] + ID of the entity's VAT number (if any) used for the sales transaction. product_type : typing.Optional[ProductServiceTypeEnum] + Unused. Reserved for future use. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -103,17 +120,34 @@ async def get( request_options: typing.Optional[RequestOptions] = None, ) -> VatRateListResponse: """ + Monite maintains a catalog of VAT and sales tax rates for [select countries](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries). + + To query the applicable VAT/tax rates for an invoice or quote, use: + + `GET /vat_rates?counterpart_id=<...>&entity_vat_id_id=<...>` + + Or if the entity does not have a VAT ID: + + `GET /vat_rates?counterpart_id=<...>` + + **Note:** Entities from countries [not on the list](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries) should not use this endpoint. Instead, those entities can either create custom VAT/tax rates or use the invoice field `line_items[].tax_rate_value` to specify the VAT/tax rates directly. + Parameters ---------- counterpart_address_id : typing.Optional[str] + Unused. Reserved for future use. counterpart_id : typing.Optional[str] + ID of the counterpart that will be invoiced. counterpart_vat_id_id : typing.Optional[str] + Unused. Reserved for future use. entity_vat_id_id : typing.Optional[str] + ID of the entity's VAT number (if any) used for the sales transaction. product_type : typing.Optional[ProductServiceTypeEnum] + Unused. Reserved for future use. request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/monite/vat_rates/raw_client.py b/src/monite/vat_rates/raw_client.py index b5f1145..9883e52 100644 --- a/src/monite/vat_rates/raw_client.py +++ b/src/monite/vat_rates/raw_client.py @@ -10,8 +10,8 @@ from ..core.request_options import RequestOptions from ..errors.bad_request_error import BadRequestError from ..errors.forbidden_error import ForbiddenError -from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.product_service_type_enum import ProductServiceTypeEnum @@ -33,17 +33,34 @@ def get( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[VatRateListResponse]: """ + Monite maintains a catalog of VAT and sales tax rates for [select countries](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries). + + To query the applicable VAT/tax rates for an invoice or quote, use: + + `GET /vat_rates?counterpart_id=<...>&entity_vat_id_id=<...>` + + Or if the entity does not have a VAT ID: + + `GET /vat_rates?counterpart_id=<...>` + + **Note:** Entities from countries [not on the list](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries) should not use this endpoint. Instead, those entities can either create custom VAT/tax rates or use the invoice field `line_items[].tax_rate_value` to specify the VAT/tax rates directly. + Parameters ---------- counterpart_address_id : typing.Optional[str] + Unused. Reserved for future use. counterpart_id : typing.Optional[str] + ID of the counterpart that will be invoiced. counterpart_vat_id_id : typing.Optional[str] + Unused. Reserved for future use. entity_vat_id_id : typing.Optional[str] + ID of the entity's VAT number (if any) used for the sales transaction. product_type : typing.Optional[ProductServiceTypeEnum] + Unused. Reserved for future use. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -130,8 +147,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -162,17 +179,34 @@ async def get( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[VatRateListResponse]: """ + Monite maintains a catalog of VAT and sales tax rates for [select countries](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries). + + To query the applicable VAT/tax rates for an invoice or quote, use: + + `GET /vat_rates?counterpart_id=<...>&entity_vat_id_id=<...>` + + Or if the entity does not have a VAT ID: + + `GET /vat_rates?counterpart_id=<...>` + + **Note:** Entities from countries [not on the list](https://docs.monite.com/accounts-receivable/vat-rates#supported-countries) should not use this endpoint. Instead, those entities can either create custom VAT/tax rates or use the invoice field `line_items[].tax_rate_value` to specify the VAT/tax rates directly. + Parameters ---------- counterpart_address_id : typing.Optional[str] + Unused. Reserved for future use. counterpart_id : typing.Optional[str] + ID of the counterpart that will be invoiced. counterpart_vat_id_id : typing.Optional[str] + Unused. Reserved for future use. entity_vat_id_id : typing.Optional[str] + ID of the entity's VAT number (if any) used for the sales transaction. product_type : typing.Optional[ProductServiceTypeEnum] + Unused. Reserved for future use. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -259,8 +293,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/webhook_deliveries/raw_client.py b/src/monite/webhook_deliveries/raw_client.py index 84238f6..04fa01b 100644 --- a/src/monite/webhook_deliveries/raw_client.py +++ b/src/monite/webhook_deliveries/raw_client.py @@ -10,7 +10,8 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.order_enum import OrderEnum from ..types.webhook_delivery_cursor_fields import WebhookDeliveryCursorFields @@ -111,6 +112,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -122,8 +134,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -232,6 +244,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -243,8 +266,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], diff --git a/src/monite/webhook_subscriptions/client.py b/src/monite/webhook_subscriptions/client.py index bcaa707..fd1dbf9 100644 --- a/src/monite/webhook_subscriptions/client.py +++ b/src/monite/webhook_subscriptions/client.py @@ -47,6 +47,8 @@ def get( request_options: typing.Optional[RequestOptions] = None, ) -> WebhookSubscriptionPaginationResource: """ + Returns a list of all [webhook](https://docs.monite.com/references/webhooks/index) subscriptions (both active and disabled). + Parameters ---------- order : typing.Optional[OrderEnum] @@ -66,12 +68,16 @@ def get( object_type : typing.Optional[WebhookObjectType] created_at_gt : typing.Optional[dt.datetime] + Return only subscriptions created after the specified date and time. created_at_lt : typing.Optional[dt.datetime] + Return only subscriptions created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only subscriptions created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only subscriptions created before or on the specified date and time. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -115,13 +121,22 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> WebhookSubscriptionResourceWithSecret: """ + Related guide: [Webhooks](https://docs.monite.com/references/webhooks/index). + Parameters ---------- object_type : WebhookObjectType + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : str + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -141,8 +156,13 @@ def create( token="YOUR_TOKEN", ) client.webhook_subscriptions.create( - object_type="account", - url="url", + event_types=[ + "created", + "onboarding_requirements.updated", + "onboarding_requirements.status_updated", + ], + object_type="entity", + url="https://example.com/your-webhook-listener", ) """ _response = self._raw_client.create( @@ -154,9 +174,14 @@ def get_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> WebhookSubscriptionResource: """ + Returns the details of the webhook subscription with the specified ID. + + The response does not include the [webhook signing secret](https://docs.monite.com/references/webhooks/signatures). If you lost the secret, you can [regenerate it](https://docs.monite.com/api/webhook-subscriptions/post-webhook-subscriptions-id-regenerate-secret). + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -189,6 +214,7 @@ def delete_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -223,15 +249,25 @@ def update_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> WebhookSubscriptionResource: """ + You can update the webhook listener URL or the event list. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. object_type : typing.Optional[WebhookObjectType] + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : typing.Optional[str] + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -270,6 +306,7 @@ def disable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -302,6 +339,7 @@ def enable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -331,9 +369,12 @@ def regenerate_secret_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> WebhookSubscriptionResourceWithSecret: """ + The webhook signing secret lets you [verify webhook signatures](https://docs.monite.com/references/webhooks/signatures). If you lost the original secret generated for any of your webhook subscriptions, you can regenerate it. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -390,6 +431,8 @@ async def get( request_options: typing.Optional[RequestOptions] = None, ) -> WebhookSubscriptionPaginationResource: """ + Returns a list of all [webhook](https://docs.monite.com/references/webhooks/index) subscriptions (both active and disabled). + Parameters ---------- order : typing.Optional[OrderEnum] @@ -409,12 +452,16 @@ async def get( object_type : typing.Optional[WebhookObjectType] created_at_gt : typing.Optional[dt.datetime] + Return only subscriptions created after the specified date and time. created_at_lt : typing.Optional[dt.datetime] + Return only subscriptions created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only subscriptions created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only subscriptions created before or on the specified date and time. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -466,13 +513,22 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> WebhookSubscriptionResourceWithSecret: """ + Related guide: [Webhooks](https://docs.monite.com/references/webhooks/index). + Parameters ---------- object_type : WebhookObjectType + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : str + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -497,8 +553,13 @@ async def create( async def main() -> None: await client.webhook_subscriptions.create( - object_type="account", - url="url", + event_types=[ + "created", + "onboarding_requirements.updated", + "onboarding_requirements.status_updated", + ], + object_type="entity", + url="https://example.com/your-webhook-listener", ) @@ -513,9 +574,14 @@ async def get_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> WebhookSubscriptionResource: """ + Returns the details of the webhook subscription with the specified ID. + + The response does not include the [webhook signing secret](https://docs.monite.com/references/webhooks/signatures). If you lost the secret, you can [regenerate it](https://docs.monite.com/api/webhook-subscriptions/post-webhook-subscriptions-id-regenerate-secret). + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -556,6 +622,7 @@ async def delete_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -598,15 +665,25 @@ async def update_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> WebhookSubscriptionResource: """ + You can update the webhook listener URL or the event list. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. object_type : typing.Optional[WebhookObjectType] + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : typing.Optional[str] + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -653,6 +730,7 @@ async def disable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -693,6 +771,7 @@ async def enable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -730,9 +809,12 @@ async def regenerate_secret_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> WebhookSubscriptionResourceWithSecret: """ + The webhook signing secret lets you [verify webhook signatures](https://docs.monite.com/references/webhooks/signatures). If you lost the original secret generated for any of your webhook subscriptions, you can regenerate it. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/monite/webhook_subscriptions/raw_client.py b/src/monite/webhook_subscriptions/raw_client.py index f4ed15f..fa89f60 100644 --- a/src/monite/webhook_subscriptions/raw_client.py +++ b/src/monite/webhook_subscriptions/raw_client.py @@ -11,7 +11,9 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.order_enum import OrderEnum from ..types.webhook_object_type import WebhookObjectType @@ -43,6 +45,8 @@ def get( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[WebhookSubscriptionPaginationResource]: """ + Returns a list of all [webhook](https://docs.monite.com/references/webhooks/index) subscriptions (both active and disabled). + Parameters ---------- order : typing.Optional[OrderEnum] @@ -62,12 +66,16 @@ def get( object_type : typing.Optional[WebhookObjectType] created_at_gt : typing.Optional[dt.datetime] + Return only subscriptions created after the specified date and time. created_at_lt : typing.Optional[dt.datetime] + Return only subscriptions created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only subscriptions created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only subscriptions created before or on the specified date and time. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -103,6 +111,17 @@ def get( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -114,8 +133,8 @@ def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -139,13 +158,22 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[WebhookSubscriptionResourceWithSecret]: """ + Related guide: [Webhooks](https://docs.monite.com/references/webhooks/index). + Parameters ---------- object_type : WebhookObjectType + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : str + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -179,6 +207,17 @@ def create( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -190,8 +229,8 @@ def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -210,9 +249,14 @@ def get_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[WebhookSubscriptionResource]: """ + Returns the details of the webhook subscription with the specified ID. + + The response does not include the [webhook signing secret](https://docs.monite.com/references/webhooks/signatures). If you lost the secret, you can [regenerate it](https://docs.monite.com/api/webhook-subscriptions/post-webhook-subscriptions-id-regenerate-secret). + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -237,6 +281,28 @@ def get_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -248,8 +314,8 @@ def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -271,6 +337,7 @@ def delete_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -287,6 +354,28 @@ def delete_by_id( try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -298,8 +387,8 @@ def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -324,15 +413,25 @@ def update_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[WebhookSubscriptionResource]: """ + You can update the webhook listener URL or the event list. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. object_type : typing.Optional[WebhookObjectType] + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : typing.Optional[str] + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -366,6 +465,28 @@ def update_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -377,8 +498,8 @@ def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -400,6 +521,7 @@ def disable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -424,6 +546,17 @@ def disable_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -435,8 +568,8 @@ def disable_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -458,6 +591,7 @@ def enable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -482,6 +616,17 @@ def enable_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -493,8 +638,8 @@ def enable_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -513,9 +658,12 @@ def regenerate_secret_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[WebhookSubscriptionResourceWithSecret]: """ + The webhook signing secret lets you [verify webhook signatures](https://docs.monite.com/references/webhooks/signatures). If you lost the original secret generated for any of your webhook subscriptions, you can regenerate it. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -540,6 +688,28 @@ def regenerate_secret_by_id( ), ) return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -551,8 +721,8 @@ def regenerate_secret_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -587,6 +757,8 @@ async def get( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[WebhookSubscriptionPaginationResource]: """ + Returns a list of all [webhook](https://docs.monite.com/references/webhooks/index) subscriptions (both active and disabled). + Parameters ---------- order : typing.Optional[OrderEnum] @@ -606,12 +778,16 @@ async def get( object_type : typing.Optional[WebhookObjectType] created_at_gt : typing.Optional[dt.datetime] + Return only subscriptions created after the specified date and time. created_at_lt : typing.Optional[dt.datetime] + Return only subscriptions created before the specified date and time. created_at_gte : typing.Optional[dt.datetime] + Return only subscriptions created on or after the specified date and time. created_at_lte : typing.Optional[dt.datetime] + Return only subscriptions created before or on the specified date and time. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -647,6 +823,17 @@ async def get( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -658,8 +845,8 @@ async def get( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -683,13 +870,22 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[WebhookSubscriptionResourceWithSecret]: """ + Related guide: [Webhooks](https://docs.monite.com/references/webhooks/index). + Parameters ---------- object_type : WebhookObjectType + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : str + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -723,6 +919,17 @@ async def create( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -734,8 +941,8 @@ async def create( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -754,9 +961,14 @@ async def get_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[WebhookSubscriptionResource]: """ + Returns the details of the webhook subscription with the specified ID. + + The response does not include the [webhook signing secret](https://docs.monite.com/references/webhooks/signatures). If you lost the secret, you can [regenerate it](https://docs.monite.com/api/webhook-subscriptions/post-webhook-subscriptions-id-regenerate-secret). + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -781,6 +993,28 @@ async def get_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -792,8 +1026,8 @@ async def get_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -815,6 +1049,7 @@ async def delete_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -831,6 +1066,28 @@ async def delete_by_id( try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -842,8 +1099,8 @@ async def delete_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -868,15 +1125,25 @@ async def update_by_id( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[WebhookSubscriptionResource]: """ + You can update the webhook listener URL or the event list. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. event_types : typing.Optional[typing.Sequence[str]] + A list of [events](https://docs.monite.com/references/webhooks/index#events) to subscribe to. If set to an empty array, the subscription includes all events triggered by the specified `object_type`. object_type : typing.Optional[WebhookObjectType] + The [object type](https://docs.monite.com/references/webhooks/index#events) to whose events you want to subscribe. + + To subscribe to events from multiple object types, create a separate subscription for each object type. url : typing.Optional[str] + An HTTPS URL to which Monite will send webhooks. This URL must be accessible over the public Internet, accept POST requests, and respond with status code 200. It must be a direct URL (no redirects). + + The same URL can be used by multiple webhook subscriptions. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -910,6 +1177,28 @@ async def update_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -921,8 +1210,8 @@ async def update_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -944,6 +1233,7 @@ async def disable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -968,6 +1258,17 @@ async def disable_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -979,8 +1280,8 @@ async def disable_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1002,6 +1303,7 @@ async def enable_by_id( Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1026,6 +1328,17 @@ async def enable_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1037,8 +1350,8 @@ async def enable_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any], @@ -1057,9 +1370,12 @@ async def regenerate_secret_by_id( self, webhook_subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[WebhookSubscriptionResourceWithSecret]: """ + The webhook signing secret lets you [verify webhook signatures](https://docs.monite.com/references/webhooks/signatures). If you lost the original secret generated for any of your webhook subscriptions, you can regenerate it. + Parameters ---------- webhook_subscription_id : str + ID of the webhook subscription. This is the same value as the `webhook_subscription_id` you receive in webhooks. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1084,6 +1400,28 @@ async def regenerate_secret_by_id( ), ) return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( headers=dict(_response.headers), @@ -1095,8 +1433,8 @@ async def regenerate_secret_by_id( ), ), ) - if _response.status_code == 500: - raise InternalServerError( + if _response.status_code == 429: + raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Optional[typing.Any],