Package: codat-sync-for-expenses
Sync for Expenses﻿Embedded accounting integrations for corporate card providers.SDK Installationpipinstallcodat-sync-for-expensesExample UsageSDK Example UsageExampleimportcodatsyncexpensesfromcodatsyncexpenses.modelsimportshareds=codatsyncexpenses.CodatSyncExpenses(security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=s.companies.create(req)ifres.companyisnotNone:# handle responsepassAvailable Resources and Operationscompaniescreate- Create companydelete- Delete a companyget- Get companylist- List companiesupdate- Update companyconnectionscreate- Create connectioncreate_partner_expense_connection- Create partner expense connectiondelete- Delete connectionget- Get connectionlist- List connectionsunlink- Unlink connectionaccountscreate- Create accountget_create_model- Get create account modelcustomerscreate- Create customerget- Get customerlist- List customersupdate- Update customersupplierscreate- Create supplierget- Get supplierlist- List suppliersupdate- Update suppliermanage_dataget- Get data statusget_pull_operation- Get pull operationlist_pull_operations- List pull operationsrefresh_all_data_types- Refresh all datarefresh_data_type- Refresh data typepush_operationsget- Get push operationlist- List push operationsconfigurationget- Get company configurationget_mapping_options- Mapping optionsset- Set company configurationexpensescreate- Create expense transactionupdate- Update expense-transactionsupload_attachment- Upload attachmentsyncget- Get sync statusget_last_successful_sync- Last successful syncget_latest_sync- Latest sync statusinitiate_sync- Initiate synclist- List sync statusestransaction_statusget- Get sync transactionlist- List sync transactionsRetriesSome of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.To change the default retry strategy for a single API call, simply provide aRetryConfigobject to the call:importcodatsyncexpensesfromcodatsyncexpenses.modelsimportsharedfromcodatsyncexpenses.utilsimportBackoffStrategy,RetryConfigs=codatsyncexpenses.CodatSyncExpenses(security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=s.companies.create(req,RetryConfig('backoff',BackoffStrategy(1,50,1.1,100),False))ifres.companyisnotNone:# handle responsepassIf you'd like to override the default retry strategy for all operations that support retries, you can use theretry_configoptional parameter when initializing the SDK:importcodatsyncexpensesfromcodatsyncexpenses.modelsimportsharedfromcodatsyncexpenses.utilsimportBackoffStrategy,RetryConfigs=codatsyncexpenses.CodatSyncExpenses(retry_config=RetryConfig('backoff',BackoffStrategy(1,50,1.1,100),False)security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=s.companies.create(req)ifres.companyisnotNone:# handle responsepassError HandlingHandling errors in this SDK should largely match your expectations.  All operations return a response object or raise an error.  If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.Error ObjectStatus CodeContent Typeerrors.ErrorMessage400,401,402,403,429,500,503application/jsonerrors.SDKError4x-5xx/Exampleimportcodatsyncexpensesfromcodatsyncexpenses.modelsimporterrors,shareds=codatsyncexpenses.CodatSyncExpenses(security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=Nonetry:res=s.companies.create(req)excepterrors.ErrorMessagease:# handle exceptionraise(e)excepterrors.SDKErrorase:# handle exceptionraise(e)ifres.companyisnotNone:# handle responsepassServer SelectionSelect Server by IndexYou can override the default server globally by passing a server index to theserver_idx: intoptional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:#ServerVariables0https://api.codat.ioNoneExampleimportcodatsyncexpensesfromcodatsyncexpenses.modelsimportshareds=codatsyncexpenses.CodatSyncExpenses(server_idx=0,security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=s.companies.create(req)ifres.companyisnotNone:# handle responsepassOverride Server URL Per-ClientThe default server can also be overridden globally by passing a URL to theserver_url: stroptional parameter when initializing the SDK client instance. For example:importcodatsyncexpensesfromcodatsyncexpenses.modelsimportshareds=codatsyncexpenses.CodatSyncExpenses(server_url="https://api.codat.io",security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=s.companies.create(req)ifres.companyisnotNone:# handle responsepassCustom HTTP ClientThe Python SDK makes API calls using therequestsHTTP library.  In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a customrequests.Sessionobject.For example, you could specify a header for every request that this sdk makes as follows:importcodatsyncexpensesimportrequestshttp_client=requests.Session()http_client.headers.update({'x-custom-header':'someValue'})s=codatsyncexpenses.CodatSyncExpenses(client:http_client)AuthenticationPer-Client Security SchemesThis SDK supports the following security scheme globally:NameTypeSchemeauth_headerapiKeyAPI keyYou can set the security parameters through thesecurityoptional parameter when initializing the SDK client instance. For example:importcodatsyncexpensesfromcodatsyncexpenses.modelsimportshareds=codatsyncexpenses.CodatSyncExpenses(security=shared.Security(auth_header="Basic BASE_64_ENCODED(API_KEY)",),)req=shared.CompanyRequestBody(name='Bank of Dave',description='Requested early access to the new financing scheme.',)res=s.companies.create(req)ifres.companyisnotNone:# handle responsepassSupportIf you encounter any challenges while utilizing our SDKs, please don't hesitate to reach out for assistance.
You can raise any issues by contacting your dedicated Codat representative or reaching out to oursupport team.
We're here to help ensure a smooth experience for you.Library generated bySpeakeasy