From 5b2db4d8e3c66498c6405310d92e87fe31b8a926 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Sat, 14 Sep 2024 09:05:25 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.396.9 --- .speakeasy/workflow.lock | 14 + .speakeasy/workflow.yaml | 2 + sync-for-payables/.gitattributes | 2 + sync-for-payables/.gitignore | 1 + sync-for-payables/.speakeasy/gen.lock | 947 +++++++++++ sync-for-payables/.speakeasy/gen.yaml | 8 + sync-for-payables/CONTRIBUTING.md | 26 + sync-for-payables/README.md | 511 ++++++ sync-for-payables/RELEASES.md | 11 + sync-for-payables/USAGE.md | 36 + sync-for-payables/bankaccounts.go | 280 ++++ sync-for-payables/billpayments.go | 531 ++++++ sync-for-payables/bills.go | 1488 +++++++++++++++++ sync-for-payables/codatsyncpayables.go | 220 +++ sync-for-payables/companies.go | 1240 ++++++++++++++ sync-for-payables/companyinformation.go | 270 +++ sync-for-payables/connections.go | 1224 ++++++++++++++ .../operations/createbankaccountrequest.md | 11 + .../operations/createbankaccountresponse.md | 9 + .../operations/createbillpaymentrequest.md | 12 + .../operations/createbillpaymentresponse.md | 9 + .../models/operations/createbillrequest.md | 11 + .../models/operations/createbillresponse.md | 9 + .../operations/createcompanyresponse.md | 9 + .../operations/createconnectionrequest.md | 9 + .../operations/createconnectionrequestbody.md | 8 + .../operations/createconnectionresponse.md | 9 + .../operations/createsupplierrequest.md | 11 + .../operations/createsupplierresponse.md | 9 + .../models/operations/deletecompanyrequest.md | 8 + .../operations/deletecompanyresponse.md | 8 + .../operations/deleteconnectionrequest.md | 9 + .../operations/deleteconnectionresponse.md | 8 + .../downloadbillattachmentrequest.md | 11 + .../downloadbillattachmentresponse.md | 9 + .../getcompanyinformationrequest.md | 9 + .../getcompanyinformationresponse.md | 9 + .../models/operations/getcompanyrequest.md | 8 + .../models/operations/getcompanyresponse.md | 9 + .../models/operations/getconnectionrequest.md | 9 + .../operations/getconnectionresponse.md | 9 + .../getmappingoptionsbillsrequest.md | 11 + .../getmappingoptionsbillsresponse.md | 9 + .../getmappingoptionspaymentsrequest.md | 11 + .../getmappingoptionspaymentsresponse.md | 9 + .../operations/listbillattachmentsrequest.md | 10 + .../operations/listbillattachmentsresponse.md | 9 + .../pkg/models/operations/listbillsrequest.md | 11 + .../models/operations/listbillsresponse.md | 9 + .../models/operations/listcompaniesrequest.md | 11 + .../operations/listcompaniesresponse.md | 9 + .../operations/listconnectionsrequest.md | 12 + .../operations/listconnectionsresponse.md | 9 + .../models/operations/listsuppliersrequest.md | 11 + .../operations/listsuppliersresponse.md | 9 + .../docs/pkg/models/operations/option.md | 37 + .../operations/unlinkconnectionrequest.md | 10 + .../operations/unlinkconnectionresponse.md | 9 + .../unlinkconnectionupdateconnection.md | 8 + .../models/operations/updatecompanyrequest.md | 9 + .../operations/updatecompanyresponse.md | 9 + .../operations/uploadbillattachmentrequest.md | 11 + .../uploadbillattachmentresponse.md | 8 + .../docs/pkg/models/sdkerrors/errormessage.md | 16 + .../pkg/models/shared/accountmappingoption.md | 14 + .../docs/pkg/models/shared/accountstatus.md | 11 + .../docs/pkg/models/shared/accounttype.md | 14 + .../docs/pkg/models/shared/address.md | 14 + .../docs/pkg/models/shared/addresstype.md | 12 + .../docs/pkg/models/shared/attachment.md | 31 + .../pkg/models/shared/attachmentupload.md | 8 + .../docs/pkg/models/shared/bankaccount.md | 16 + .../models/shared/bankaccountmappingoption.md | 16 + .../pkg/models/shared/bankaccountprototype.md | 13 + .../pkg/models/shared/bankaccountstatus.md | 11 + .../docs/pkg/models/shared/bankaccounttype.md | 14 + .../docs/pkg/models/shared/bill.md | 21 + .../docs/pkg/models/shared/billaccountref.md | 10 + .../docs/pkg/models/shared/billlineitem.md | 14 + .../pkg/models/shared/billmappingoptions.md | 12 + .../docs/pkg/models/shared/billpayment.md | 13 + .../models/shared/billpaymentaccountref.md | 10 + .../pkg/models/shared/billpaymentprototype.md | 12 + .../docs/pkg/models/shared/billprototype.md | 17 + .../docs/pkg/models/shared/bills.md | 9 + .../docs/pkg/models/shared/billstatus.md | 15 + .../docs/pkg/models/shared/billtaxrateref.md | 10 + .../shared/clientratelimitreachedwebhook.md | 16 + .../clientratelimitreachedwebhookdata.md | 9 + .../shared/clientratelimitresetwebhook.md | 16 + .../shared/clientratelimitresetwebhookdata.md | 11 + .../models/shared/clientratelimitwebhook.md | 11 + .../shared/clientratelimitwebhookpayload.md | 10 + .../docs/pkg/models/shared/codatfile.md | 9 + .../docs/pkg/models/shared/companies.md | 12 + .../docs/pkg/models/shared/company.md | 22 + .../pkg/models/shared/companyinformation.md | 11 + .../pkg/models/shared/companyrequestbody.md | 10 + .../docs/pkg/models/shared/connection.md | 31 + .../docs/pkg/models/shared/connections.md | 12 + .../pkg/models/shared/dataconnectionerror.md | 13 + .../pkg/models/shared/dataconnectionstatus.md | 13 + .../docs/pkg/models/shared/errorstatus.md | 11 + .../docs/pkg/models/shared/errorvalidation.md | 11 + .../pkg/models/shared/errorvalidationitem.md | 10 + .../docs/pkg/models/shared/groupreference.md | 8 + .../docs/pkg/models/shared/halref.md | 8 + .../docs/pkg/models/shared/httpmetadata.md | 9 + .../docs/pkg/models/shared/links.md | 11 + .../docs/pkg/models/shared/one.md | 8 + .../docs/pkg/models/shared/pagination.md | 8 + .../models/shared/paymentmappingoptions.md | 11 + .../docs/pkg/models/shared/security.md | 8 + .../docs/pkg/models/shared/sourcetype.md | 16 + .../docs/pkg/models/shared/supplier.md | 22 + .../pkg/models/shared/supplierprototype.md | 15 + .../docs/pkg/models/shared/supplierref.md | 11 + .../docs/pkg/models/shared/suppliers.md | 9 + .../docs/pkg/models/shared/supplierstatus.md | 12 + .../docs/pkg/models/shared/tags.md | 9 + .../pkg/models/shared/taxratemappingoption.md | 13 + .../docs/pkg/models/shared/taxratestatus.md | 13 + .../clientratelimitreachedresponse.md | 8 + .../clientratelimitreachedresponse1.md | 8 + .../webhooks/clientratelimitresetresponse.md | 8 + .../webhooks/clientratelimitresetresponse1.md | 8 + .../docs/sdks/bankaccounts/README.md | 77 + .../docs/sdks/billpayments/README.md | 145 ++ sync-for-payables/docs/sdks/bills/README.md | 451 +++++ .../docs/sdks/codatsyncpayables/README.md | 24 + .../docs/sdks/companies/README.md | 335 ++++ .../docs/sdks/companyinformation/README.md | 69 + .../docs/sdks/connections/README.md | 314 ++++ .../docs/sdks/suppliers/README.md | 156 ++ sync-for-payables/go.mod | 8 + sync-for-payables/go.sum | 4 + sync-for-payables/internal/hooks/hooks.go | 144 ++ .../internal/hooks/registration.go | 18 + .../models/operations/createbankaccount.go | 65 + .../pkg/models/operations/createbill.go | 65 + .../models/operations/createbillpayment.go | 74 + .../pkg/models/operations/createcompany.go | 27 + .../pkg/models/operations/createconnection.go | 59 + .../pkg/models/operations/createsupplier.go | 65 + .../pkg/models/operations/deletecompany.go | 30 + .../pkg/models/operations/deleteconnection.go | 39 + .../operations/downloadbillattachment.go | 68 + .../pkg/models/operations/getcompany.go | 39 + .../operations/getcompanyinformation.go | 48 + .../pkg/models/operations/getconnection.go | 48 + .../operations/getmappingoptionsbills.go | 66 + .../operations/getmappingoptionspayments.go | 66 + .../models/operations/listbillattachments.go | 57 + .../pkg/models/operations/listbills.go | 66 + .../pkg/models/operations/listcompanies.go | 78 + .../pkg/models/operations/listconnections.go | 87 + .../pkg/models/operations/listsuppliers.go | 66 + .../pkg/models/operations/options.go | 116 ++ .../pkg/models/operations/unlinkconnection.go | 68 + .../pkg/models/operations/updatecompany.go | 47 + .../models/operations/uploadbillattachment.go | 56 + .../pkg/models/sdkerrors/errormessage.go | 33 + .../pkg/models/sdkerrors/sdkerror.go | 35 + .../pkg/models/shared/accountmappingoption.go | 74 + .../pkg/models/shared/accountstatus.go | 35 + .../pkg/models/shared/accounttype.go | 40 + .../pkg/models/shared/address.go | 69 + .../pkg/models/shared/addresstype.go | 38 + .../pkg/models/shared/attachment.go | 104 ++ .../pkg/models/shared/attachmentupload.go | 15 + .../pkg/models/shared/bankaccount.go | 137 ++ .../models/shared/bankaccountmappingoption.go | 94 ++ .../pkg/models/shared/bankaccountprototype.go | 74 + .../pkg/models/shared/bankaccountstatus.go | 35 + sync-for-payables/pkg/models/shared/bill.go | 165 ++ .../pkg/models/shared/billaccountref.go | 16 + .../pkg/models/shared/billlineitem.go | 85 + .../pkg/models/shared/billmappingoptions.go | 31 + .../pkg/models/shared/billpayment.go | 106 ++ .../models/shared/billpaymentaccountref.go | 16 + .../pkg/models/shared/billpaymentprototype.go | 97 ++ .../pkg/models/shared/billprototype.go | 147 ++ sync-for-payables/pkg/models/shared/bills.go | 22 + .../pkg/models/shared/billstatus.go | 47 + .../pkg/models/shared/billtaxrateref.go | 16 + .../shared/clientratelimitreachedwebhook.go | 71 + .../clientratelimitreachedwebhookdata.go | 42 + .../shared/clientratelimitresetwebhook.go | 71 + .../shared/clientratelimitresetwebhookdata.go | 60 + .../models/shared/clientratelimitwebhook.go | 59 + .../shared/clientratelimitwebhookpayload.go | 51 + .../pkg/models/shared/codatfile.go | 23 + .../pkg/models/shared/companies.go | 49 + .../pkg/models/shared/company.go | 131 ++ .../pkg/models/shared/companyinformation.go | 25 + .../pkg/models/shared/companyrequestbody.go | 45 + .../pkg/models/shared/connection.go | 213 +++ .../pkg/models/shared/connections.go | 49 + .../pkg/models/shared/dataconnectionerror.go | 128 ++ .../pkg/models/shared/dataconnectionstatus.go | 41 + .../pkg/models/shared/errorvalidation.go | 23 + .../pkg/models/shared/errorvalidationitem.go | 33 + sync-for-payables/pkg/models/shared/halref.go | 15 + .../pkg/models/shared/httpmetadata.go | 28 + sync-for-payables/pkg/models/shared/links.go | 38 + sync-for-payables/pkg/models/shared/one.go | 14 + .../pkg/models/shared/pagination.go | 15 + .../models/shared/paymentmappingoptions.go | 23 + .../pkg/models/shared/security.go | 14 + .../pkg/models/shared/supplier.go | 114 ++ .../pkg/models/shared/supplierprototype.go | 94 ++ .../pkg/models/shared/supplierref.go | 25 + .../pkg/models/shared/suppliers.go | 22 + .../pkg/models/shared/supplierstatus.go | 38 + .../pkg/models/shared/taxratemappingoption.go | 109 ++ .../models/webhooks/clientratelimitreached.go | 18 + .../models/webhooks/clientratelimitreset.go | 18 + sync-for-payables/pkg/retry/config.go | 16 + sync-for-payables/pkg/types/bigint.go | 21 + sync-for-payables/pkg/types/date.go | 90 + sync-for-payables/pkg/types/datetime.go | 23 + sync-for-payables/pkg/types/decimal.go | 20 + sync-for-payables/pkg/types/pointers.go | 11 + sync-for-payables/pkg/utils/contenttype.go | 37 + sync-for-payables/pkg/utils/form.go | 117 ++ sync-for-payables/pkg/utils/headers.go | 124 ++ sync-for-payables/pkg/utils/json.go | 675 ++++++++ sync-for-payables/pkg/utils/pathparams.go | 172 ++ sync-for-payables/pkg/utils/queryparams.go | 259 +++ sync-for-payables/pkg/utils/requestbody.go | 416 +++++ sync-for-payables/pkg/utils/retries.go | 110 ++ sync-for-payables/pkg/utils/security.go | 285 ++++ sync-for-payables/pkg/utils/utils.go | 230 +++ sync-for-payables/suppliers.go | 533 ++++++ 234 files changed, 17582 insertions(+) create mode 100644 sync-for-payables/.gitattributes create mode 100644 sync-for-payables/.gitignore create mode 100644 sync-for-payables/.speakeasy/gen.lock create mode 100644 sync-for-payables/CONTRIBUTING.md create mode 100644 sync-for-payables/README.md create mode 100644 sync-for-payables/RELEASES.md create mode 100644 sync-for-payables/USAGE.md create mode 100644 sync-for-payables/bankaccounts.go create mode 100644 sync-for-payables/billpayments.go create mode 100644 sync-for-payables/bills.go create mode 100644 sync-for-payables/codatsyncpayables.go create mode 100644 sync-for-payables/companies.go create mode 100644 sync-for-payables/companyinformation.go create mode 100644 sync-for-payables/connections.go create mode 100644 sync-for-payables/docs/pkg/models/operations/createbankaccountrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createbankaccountresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createbillpaymentrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createbillpaymentresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createbillrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createbillresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createcompanyresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createconnectionrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createconnectionrequestbody.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createconnectionresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createsupplierrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/createsupplierresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/deletecompanyrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/deletecompanyresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/deleteconnectionrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/deleteconnectionresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/downloadbillattachmentrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/downloadbillattachmentresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getcompanyinformationrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getcompanyinformationresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getcompanyrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getcompanyresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getconnectionrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getconnectionresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listbillattachmentsrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listbillattachmentsresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listbillsrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listbillsresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listcompaniesrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listcompaniesresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listconnectionsrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listconnectionsresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listsuppliersrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/listsuppliersresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/option.md create mode 100644 sync-for-payables/docs/pkg/models/operations/unlinkconnectionrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/unlinkconnectionresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/unlinkconnectionupdateconnection.md create mode 100644 sync-for-payables/docs/pkg/models/operations/updatecompanyrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/updatecompanyresponse.md create mode 100644 sync-for-payables/docs/pkg/models/operations/uploadbillattachmentrequest.md create mode 100644 sync-for-payables/docs/pkg/models/operations/uploadbillattachmentresponse.md create mode 100644 sync-for-payables/docs/pkg/models/sdkerrors/errormessage.md create mode 100644 sync-for-payables/docs/pkg/models/shared/accountmappingoption.md create mode 100644 sync-for-payables/docs/pkg/models/shared/accountstatus.md create mode 100644 sync-for-payables/docs/pkg/models/shared/accounttype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/address.md create mode 100644 sync-for-payables/docs/pkg/models/shared/addresstype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/attachment.md create mode 100644 sync-for-payables/docs/pkg/models/shared/attachmentupload.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bankaccount.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bankaccountmappingoption.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bankaccountprototype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bankaccountstatus.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bankaccounttype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bill.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billaccountref.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billlineitem.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billmappingoptions.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billpayment.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billpaymentaccountref.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billpaymentprototype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billprototype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/bills.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billstatus.md create mode 100644 sync-for-payables/docs/pkg/models/shared/billtaxrateref.md create mode 100644 sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhook.md create mode 100644 sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhookdata.md create mode 100644 sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhook.md create mode 100644 sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhookdata.md create mode 100644 sync-for-payables/docs/pkg/models/shared/clientratelimitwebhook.md create mode 100644 sync-for-payables/docs/pkg/models/shared/clientratelimitwebhookpayload.md create mode 100644 sync-for-payables/docs/pkg/models/shared/codatfile.md create mode 100644 sync-for-payables/docs/pkg/models/shared/companies.md create mode 100644 sync-for-payables/docs/pkg/models/shared/company.md create mode 100644 sync-for-payables/docs/pkg/models/shared/companyinformation.md create mode 100644 sync-for-payables/docs/pkg/models/shared/companyrequestbody.md create mode 100644 sync-for-payables/docs/pkg/models/shared/connection.md create mode 100644 sync-for-payables/docs/pkg/models/shared/connections.md create mode 100644 sync-for-payables/docs/pkg/models/shared/dataconnectionerror.md create mode 100644 sync-for-payables/docs/pkg/models/shared/dataconnectionstatus.md create mode 100644 sync-for-payables/docs/pkg/models/shared/errorstatus.md create mode 100644 sync-for-payables/docs/pkg/models/shared/errorvalidation.md create mode 100644 sync-for-payables/docs/pkg/models/shared/errorvalidationitem.md create mode 100644 sync-for-payables/docs/pkg/models/shared/groupreference.md create mode 100644 sync-for-payables/docs/pkg/models/shared/halref.md create mode 100644 sync-for-payables/docs/pkg/models/shared/httpmetadata.md create mode 100644 sync-for-payables/docs/pkg/models/shared/links.md create mode 100644 sync-for-payables/docs/pkg/models/shared/one.md create mode 100644 sync-for-payables/docs/pkg/models/shared/pagination.md create mode 100644 sync-for-payables/docs/pkg/models/shared/paymentmappingoptions.md create mode 100644 sync-for-payables/docs/pkg/models/shared/security.md create mode 100644 sync-for-payables/docs/pkg/models/shared/sourcetype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/supplier.md create mode 100644 sync-for-payables/docs/pkg/models/shared/supplierprototype.md create mode 100644 sync-for-payables/docs/pkg/models/shared/supplierref.md create mode 100644 sync-for-payables/docs/pkg/models/shared/suppliers.md create mode 100644 sync-for-payables/docs/pkg/models/shared/supplierstatus.md create mode 100644 sync-for-payables/docs/pkg/models/shared/tags.md create mode 100644 sync-for-payables/docs/pkg/models/shared/taxratemappingoption.md create mode 100644 sync-for-payables/docs/pkg/models/shared/taxratestatus.md create mode 100644 sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse.md create mode 100644 sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse1.md create mode 100644 sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse.md create mode 100644 sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse1.md create mode 100644 sync-for-payables/docs/sdks/bankaccounts/README.md create mode 100644 sync-for-payables/docs/sdks/billpayments/README.md create mode 100644 sync-for-payables/docs/sdks/bills/README.md create mode 100644 sync-for-payables/docs/sdks/codatsyncpayables/README.md create mode 100644 sync-for-payables/docs/sdks/companies/README.md create mode 100644 sync-for-payables/docs/sdks/companyinformation/README.md create mode 100644 sync-for-payables/docs/sdks/connections/README.md create mode 100644 sync-for-payables/docs/sdks/suppliers/README.md create mode 100644 sync-for-payables/go.mod create mode 100644 sync-for-payables/go.sum create mode 100644 sync-for-payables/internal/hooks/hooks.go create mode 100644 sync-for-payables/internal/hooks/registration.go create mode 100644 sync-for-payables/pkg/models/operations/createbankaccount.go create mode 100644 sync-for-payables/pkg/models/operations/createbill.go create mode 100644 sync-for-payables/pkg/models/operations/createbillpayment.go create mode 100644 sync-for-payables/pkg/models/operations/createcompany.go create mode 100644 sync-for-payables/pkg/models/operations/createconnection.go create mode 100644 sync-for-payables/pkg/models/operations/createsupplier.go create mode 100644 sync-for-payables/pkg/models/operations/deletecompany.go create mode 100644 sync-for-payables/pkg/models/operations/deleteconnection.go create mode 100644 sync-for-payables/pkg/models/operations/downloadbillattachment.go create mode 100644 sync-for-payables/pkg/models/operations/getcompany.go create mode 100644 sync-for-payables/pkg/models/operations/getcompanyinformation.go create mode 100644 sync-for-payables/pkg/models/operations/getconnection.go create mode 100644 sync-for-payables/pkg/models/operations/getmappingoptionsbills.go create mode 100644 sync-for-payables/pkg/models/operations/getmappingoptionspayments.go create mode 100644 sync-for-payables/pkg/models/operations/listbillattachments.go create mode 100644 sync-for-payables/pkg/models/operations/listbills.go create mode 100644 sync-for-payables/pkg/models/operations/listcompanies.go create mode 100644 sync-for-payables/pkg/models/operations/listconnections.go create mode 100644 sync-for-payables/pkg/models/operations/listsuppliers.go create mode 100644 sync-for-payables/pkg/models/operations/options.go create mode 100644 sync-for-payables/pkg/models/operations/unlinkconnection.go create mode 100644 sync-for-payables/pkg/models/operations/updatecompany.go create mode 100644 sync-for-payables/pkg/models/operations/uploadbillattachment.go create mode 100644 sync-for-payables/pkg/models/sdkerrors/errormessage.go create mode 100644 sync-for-payables/pkg/models/sdkerrors/sdkerror.go create mode 100644 sync-for-payables/pkg/models/shared/accountmappingoption.go create mode 100644 sync-for-payables/pkg/models/shared/accountstatus.go create mode 100644 sync-for-payables/pkg/models/shared/accounttype.go create mode 100644 sync-for-payables/pkg/models/shared/address.go create mode 100644 sync-for-payables/pkg/models/shared/addresstype.go create mode 100644 sync-for-payables/pkg/models/shared/attachment.go create mode 100644 sync-for-payables/pkg/models/shared/attachmentupload.go create mode 100644 sync-for-payables/pkg/models/shared/bankaccount.go create mode 100644 sync-for-payables/pkg/models/shared/bankaccountmappingoption.go create mode 100644 sync-for-payables/pkg/models/shared/bankaccountprototype.go create mode 100644 sync-for-payables/pkg/models/shared/bankaccountstatus.go create mode 100644 sync-for-payables/pkg/models/shared/bill.go create mode 100644 sync-for-payables/pkg/models/shared/billaccountref.go create mode 100644 sync-for-payables/pkg/models/shared/billlineitem.go create mode 100644 sync-for-payables/pkg/models/shared/billmappingoptions.go create mode 100644 sync-for-payables/pkg/models/shared/billpayment.go create mode 100644 sync-for-payables/pkg/models/shared/billpaymentaccountref.go create mode 100644 sync-for-payables/pkg/models/shared/billpaymentprototype.go create mode 100644 sync-for-payables/pkg/models/shared/billprototype.go create mode 100644 sync-for-payables/pkg/models/shared/bills.go create mode 100644 sync-for-payables/pkg/models/shared/billstatus.go create mode 100644 sync-for-payables/pkg/models/shared/billtaxrateref.go create mode 100644 sync-for-payables/pkg/models/shared/clientratelimitreachedwebhook.go create mode 100644 sync-for-payables/pkg/models/shared/clientratelimitreachedwebhookdata.go create mode 100644 sync-for-payables/pkg/models/shared/clientratelimitresetwebhook.go create mode 100644 sync-for-payables/pkg/models/shared/clientratelimitresetwebhookdata.go create mode 100644 sync-for-payables/pkg/models/shared/clientratelimitwebhook.go create mode 100644 sync-for-payables/pkg/models/shared/clientratelimitwebhookpayload.go create mode 100644 sync-for-payables/pkg/models/shared/codatfile.go create mode 100644 sync-for-payables/pkg/models/shared/companies.go create mode 100644 sync-for-payables/pkg/models/shared/company.go create mode 100644 sync-for-payables/pkg/models/shared/companyinformation.go create mode 100644 sync-for-payables/pkg/models/shared/companyrequestbody.go create mode 100644 sync-for-payables/pkg/models/shared/connection.go create mode 100644 sync-for-payables/pkg/models/shared/connections.go create mode 100644 sync-for-payables/pkg/models/shared/dataconnectionerror.go create mode 100644 sync-for-payables/pkg/models/shared/dataconnectionstatus.go create mode 100644 sync-for-payables/pkg/models/shared/errorvalidation.go create mode 100644 sync-for-payables/pkg/models/shared/errorvalidationitem.go create mode 100644 sync-for-payables/pkg/models/shared/halref.go create mode 100644 sync-for-payables/pkg/models/shared/httpmetadata.go create mode 100644 sync-for-payables/pkg/models/shared/links.go create mode 100644 sync-for-payables/pkg/models/shared/one.go create mode 100644 sync-for-payables/pkg/models/shared/pagination.go create mode 100644 sync-for-payables/pkg/models/shared/paymentmappingoptions.go create mode 100644 sync-for-payables/pkg/models/shared/security.go create mode 100644 sync-for-payables/pkg/models/shared/supplier.go create mode 100644 sync-for-payables/pkg/models/shared/supplierprototype.go create mode 100644 sync-for-payables/pkg/models/shared/supplierref.go create mode 100644 sync-for-payables/pkg/models/shared/suppliers.go create mode 100644 sync-for-payables/pkg/models/shared/supplierstatus.go create mode 100644 sync-for-payables/pkg/models/shared/taxratemappingoption.go create mode 100644 sync-for-payables/pkg/models/webhooks/clientratelimitreached.go create mode 100644 sync-for-payables/pkg/models/webhooks/clientratelimitreset.go create mode 100644 sync-for-payables/pkg/retry/config.go create mode 100644 sync-for-payables/pkg/types/bigint.go create mode 100644 sync-for-payables/pkg/types/date.go create mode 100644 sync-for-payables/pkg/types/datetime.go create mode 100644 sync-for-payables/pkg/types/decimal.go create mode 100644 sync-for-payables/pkg/types/pointers.go create mode 100644 sync-for-payables/pkg/utils/contenttype.go create mode 100644 sync-for-payables/pkg/utils/form.go create mode 100644 sync-for-payables/pkg/utils/headers.go create mode 100644 sync-for-payables/pkg/utils/json.go create mode 100644 sync-for-payables/pkg/utils/pathparams.go create mode 100644 sync-for-payables/pkg/utils/queryparams.go create mode 100644 sync-for-payables/pkg/utils/requestbody.go create mode 100644 sync-for-payables/pkg/utils/retries.go create mode 100644 sync-for-payables/pkg/utils/security.go create mode 100644 sync-for-payables/pkg/utils/utils.go create mode 100644 sync-for-payables/suppliers.go diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 2a6a0d7a7..07720a6cb 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -91,6 +91,13 @@ sources: tags: - latest - main + sync-for-payables-source: + sourceNamespace: sync-for-payables-source + sourceRevisionDigest: sha256:c089e0d3003774c49fbe6d87c1feb141ae3ec0f0f526375b408027808af3d8b9 + sourceBlobDigest: sha256:6ed96ad8ecab289621839d0df446a473e3dc8ea83765e3316020a6670b44da0b + tags: + - latest + - main targets: accounting-library: source: accounting-source @@ -157,6 +164,11 @@ targets: sourceNamespace: sync-for-expenses-version-1-source sourceRevisionDigest: sha256:b7665f9d81681000f18313ff0a4271b992c3309a663767bc753ba872c5e44916 sourceBlobDigest: sha256:fb29c4a7d10ab19ae39bd16dbed5a934191f5ce5630dbf829407943df1c5be9d + sync-for-payables-library: + source: sync-for-payables-source + sourceNamespace: sync-for-payables-source + sourceRevisionDigest: sha256:c089e0d3003774c49fbe6d87c1feb141ae3ec0f0f526375b408027808af3d8b9 + sourceBlobDigest: sha256:6ed96ad8ecab289621839d0df446a473e3dc8ea83765e3316020a6670b44da0b workflow: workflowVersion: 1.0.0 speakeasyVersion: latest @@ -229,6 +241,8 @@ workflow: sync-for-payables-source: inputs: - location: https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Sync-Payables.yaml + registry: + location: registry.speakeasyapi.dev/codat/codat/sync-for-payables-source sync-for-payables-version-1-source: inputs: - location: https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Sync-Payables-v1.yaml diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml index 5bb19c44d..00e210b6b 100644 --- a/.speakeasy/workflow.yaml +++ b/.speakeasy/workflow.yaml @@ -69,6 +69,8 @@ sources: sync-for-payables-source: inputs: - location: https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Sync-Payables.yaml + registry: + location: registry.speakeasyapi.dev/codat/codat/sync-for-payables-source sync-for-payables-version-1-source: inputs: - location: https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Sync-Payables-v1.yaml diff --git a/sync-for-payables/.gitattributes b/sync-for-payables/.gitattributes new file mode 100644 index 000000000..e6a994416 --- /dev/null +++ b/sync-for-payables/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.go linguist-generated=false \ No newline at end of file diff --git a/sync-for-payables/.gitignore b/sync-for-payables/.gitignore new file mode 100644 index 000000000..d3c2f597f --- /dev/null +++ b/sync-for-payables/.gitignore @@ -0,0 +1 @@ +# .gitignore diff --git a/sync-for-payables/.speakeasy/gen.lock b/sync-for-payables/.speakeasy/gen.lock new file mode 100644 index 000000000..d84a229fe --- /dev/null +++ b/sync-for-payables/.speakeasy/gen.lock @@ -0,0 +1,947 @@ +lockVersion: 2.0.0 +id: 402c5670-2c12-44b7-81b8-9ee7a4664285 +management: + docChecksum: 8f7c309d737e74dd8e124f6da34b399c + docVersion: 3.0.0 + speakeasyVersion: 1.396.9 + generationVersion: 2.415.7 + releaseVersion: 1.0.0 + configChecksum: 1ba344ade1365ee05466a257f1b9f8fe + repoURL: https://github.com/codatio/client-sdk-go.git + repoSubDirectory: sync-for-payables + installationURL: https://github.com/codatio/client-sdk-go/sync-for-payables +features: + go: + additionalDependencies: 0.1.0 + constsAndDefaults: 0.1.6 + core: 3.5.8 + decimal: 0.1.0 + defaultEnabledRetries: 0.2.0 + deprecations: 2.81.1 + downloadStreams: 0.1.2 + envVarSecurityUsage: 0.3.1 + examples: 2.81.3 + globalSecurity: 2.82.10 + globalSecurityCallbacks: 0.1.0 + globalServerURLs: 2.82.2 + intellisenseMarkdownSupport: 0.1.0 + nameOverrides: 2.81.2 + nullables: 0.1.0 + responseFormat: 0.1.2 + retries: 2.83.0 + sdkHooks: 0.1.0 + serverEventsSentinels: 0.1.0 + uploadStreams: 0.1.0 + webhooks: 1.0.0 +generatedFiles: + - .gitattributes + - /pkg/models/operations/createbankaccount.go + - /pkg/models/operations/createbill.go + - /pkg/models/operations/createbillpayment.go + - /pkg/models/operations/createcompany.go + - /pkg/models/operations/createconnection.go + - /pkg/models/operations/createsupplier.go + - /pkg/models/operations/deletecompany.go + - /pkg/models/operations/deleteconnection.go + - /pkg/models/operations/downloadbillattachment.go + - /pkg/models/operations/getcompany.go + - /pkg/models/operations/getcompanyinformation.go + - /pkg/models/operations/getconnection.go + - /pkg/models/operations/getmappingoptionsbills.go + - /pkg/models/operations/getmappingoptionspayments.go + - /pkg/models/operations/listbillattachments.go + - /pkg/models/operations/listbills.go + - /pkg/models/operations/listcompanies.go + - /pkg/models/operations/listconnections.go + - /pkg/models/operations/listsuppliers.go + - /pkg/models/operations/unlinkconnection.go + - /pkg/models/operations/updatecompany.go + - /pkg/models/operations/uploadbillattachment.go + - /pkg/models/sdkerrors/errormessage.go + - /pkg/models/shared/accountmappingoption.go + - /pkg/models/shared/accountstatus.go + - /pkg/models/shared/accounttype.go + - /pkg/models/shared/address.go + - /pkg/models/shared/addresstype.go + - /pkg/models/shared/attachment.go + - /pkg/models/shared/attachmentupload.go + - /pkg/models/shared/bankaccount.go + - /pkg/models/shared/bankaccountmappingoption.go + - /pkg/models/shared/bankaccountprototype.go + - /pkg/models/shared/bankaccountstatus.go + - /pkg/models/shared/bill.go + - /pkg/models/shared/billaccountref.go + - /pkg/models/shared/billlineitem.go + - /pkg/models/shared/billmappingoptions.go + - /pkg/models/shared/billpayment.go + - /pkg/models/shared/billpaymentaccountref.go + - /pkg/models/shared/billpaymentprototype.go + - /pkg/models/shared/billprototype.go + - /pkg/models/shared/bills.go + - /pkg/models/shared/billstatus.go + - /pkg/models/shared/billtaxrateref.go + - /pkg/models/shared/clientratelimitreachedwebhook.go + - /pkg/models/shared/clientratelimitreachedwebhookdata.go + - /pkg/models/shared/clientratelimitresetwebhook.go + - /pkg/models/shared/clientratelimitresetwebhookdata.go + - /pkg/models/shared/clientratelimitwebhook.go + - /pkg/models/shared/clientratelimitwebhookpayload.go + - /pkg/models/shared/codatfile.go + - /pkg/models/shared/companies.go + - /pkg/models/shared/company.go + - /pkg/models/shared/companyinformation.go + - /pkg/models/shared/companyrequestbody.go + - /pkg/models/shared/connection.go + - /pkg/models/shared/connections.go + - /pkg/models/shared/dataconnectionerror.go + - /pkg/models/shared/dataconnectionstatus.go + - /pkg/models/shared/errorvalidation.go + - /pkg/models/shared/errorvalidationitem.go + - /pkg/models/shared/halref.go + - /pkg/models/shared/httpmetadata.go + - /pkg/models/shared/links.go + - /pkg/models/shared/one.go + - /pkg/models/shared/pagination.go + - /pkg/models/shared/paymentmappingoptions.go + - /pkg/models/shared/security.go + - /pkg/models/shared/supplier.go + - /pkg/models/shared/supplierprototype.go + - /pkg/models/shared/supplierref.go + - /pkg/models/shared/suppliers.go + - /pkg/models/shared/supplierstatus.go + - /pkg/models/shared/taxratemappingoption.go + - /pkg/models/webhooks/clientratelimitreached.go + - /pkg/models/webhooks/clientratelimitreset.go + - CONTRIBUTING.md + - USAGE.md + - bankaccounts.go + - billpayments.go + - bills.go + - codatsyncpayables.go + - companies.go + - companyinformation.go + - connections.go + - docs/pkg/models/operations/createbankaccountrequest.md + - docs/pkg/models/operations/createbankaccountresponse.md + - docs/pkg/models/operations/createbillpaymentrequest.md + - docs/pkg/models/operations/createbillpaymentresponse.md + - docs/pkg/models/operations/createbillrequest.md + - docs/pkg/models/operations/createbillresponse.md + - docs/pkg/models/operations/createcompanyresponse.md + - docs/pkg/models/operations/createconnectionrequest.md + - docs/pkg/models/operations/createconnectionrequestbody.md + - docs/pkg/models/operations/createconnectionresponse.md + - docs/pkg/models/operations/createsupplierrequest.md + - docs/pkg/models/operations/createsupplierresponse.md + - docs/pkg/models/operations/deletecompanyrequest.md + - docs/pkg/models/operations/deletecompanyresponse.md + - docs/pkg/models/operations/deleteconnectionrequest.md + - docs/pkg/models/operations/deleteconnectionresponse.md + - docs/pkg/models/operations/downloadbillattachmentrequest.md + - docs/pkg/models/operations/downloadbillattachmentresponse.md + - docs/pkg/models/operations/getcompanyinformationrequest.md + - docs/pkg/models/operations/getcompanyinformationresponse.md + - docs/pkg/models/operations/getcompanyrequest.md + - docs/pkg/models/operations/getcompanyresponse.md + - docs/pkg/models/operations/getconnectionrequest.md + - docs/pkg/models/operations/getconnectionresponse.md + - docs/pkg/models/operations/getmappingoptionsbillsrequest.md + - docs/pkg/models/operations/getmappingoptionsbillsresponse.md + - docs/pkg/models/operations/getmappingoptionspaymentsrequest.md + - docs/pkg/models/operations/getmappingoptionspaymentsresponse.md + - docs/pkg/models/operations/listbillattachmentsrequest.md + - docs/pkg/models/operations/listbillattachmentsresponse.md + - docs/pkg/models/operations/listbillsrequest.md + - docs/pkg/models/operations/listbillsresponse.md + - docs/pkg/models/operations/listcompaniesrequest.md + - docs/pkg/models/operations/listcompaniesresponse.md + - docs/pkg/models/operations/listconnectionsrequest.md + - docs/pkg/models/operations/listconnectionsresponse.md + - docs/pkg/models/operations/listsuppliersrequest.md + - docs/pkg/models/operations/listsuppliersresponse.md + - docs/pkg/models/operations/option.md + - docs/pkg/models/operations/unlinkconnectionrequest.md + - docs/pkg/models/operations/unlinkconnectionresponse.md + - docs/pkg/models/operations/unlinkconnectionupdateconnection.md + - docs/pkg/models/operations/updatecompanyrequest.md + - docs/pkg/models/operations/updatecompanyresponse.md + - docs/pkg/models/operations/uploadbillattachmentrequest.md + - docs/pkg/models/operations/uploadbillattachmentresponse.md + - docs/pkg/models/sdkerrors/errormessage.md + - docs/pkg/models/shared/accountmappingoption.md + - docs/pkg/models/shared/accountstatus.md + - docs/pkg/models/shared/accounttype.md + - docs/pkg/models/shared/address.md + - docs/pkg/models/shared/addresstype.md + - docs/pkg/models/shared/attachment.md + - docs/pkg/models/shared/attachmentupload.md + - docs/pkg/models/shared/bankaccount.md + - docs/pkg/models/shared/bankaccountmappingoption.md + - docs/pkg/models/shared/bankaccountprototype.md + - docs/pkg/models/shared/bankaccountstatus.md + - docs/pkg/models/shared/bankaccounttype.md + - docs/pkg/models/shared/bill.md + - docs/pkg/models/shared/billaccountref.md + - docs/pkg/models/shared/billlineitem.md + - docs/pkg/models/shared/billmappingoptions.md + - docs/pkg/models/shared/billpayment.md + - docs/pkg/models/shared/billpaymentaccountref.md + - docs/pkg/models/shared/billpaymentprototype.md + - docs/pkg/models/shared/billprototype.md + - docs/pkg/models/shared/bills.md + - docs/pkg/models/shared/billstatus.md + - docs/pkg/models/shared/billtaxrateref.md + - docs/pkg/models/shared/clientratelimitreachedwebhook.md + - docs/pkg/models/shared/clientratelimitreachedwebhookdata.md + - docs/pkg/models/shared/clientratelimitresetwebhook.md + - docs/pkg/models/shared/clientratelimitresetwebhookdata.md + - docs/pkg/models/shared/clientratelimitwebhook.md + - docs/pkg/models/shared/clientratelimitwebhookpayload.md + - docs/pkg/models/shared/codatfile.md + - docs/pkg/models/shared/companies.md + - docs/pkg/models/shared/company.md + - docs/pkg/models/shared/companyinformation.md + - docs/pkg/models/shared/companyrequestbody.md + - docs/pkg/models/shared/connection.md + - docs/pkg/models/shared/connections.md + - docs/pkg/models/shared/dataconnectionerror.md + - docs/pkg/models/shared/dataconnectionstatus.md + - docs/pkg/models/shared/errorstatus.md + - docs/pkg/models/shared/errorvalidation.md + - docs/pkg/models/shared/errorvalidationitem.md + - docs/pkg/models/shared/groupreference.md + - docs/pkg/models/shared/halref.md + - docs/pkg/models/shared/httpmetadata.md + - docs/pkg/models/shared/links.md + - docs/pkg/models/shared/one.md + - docs/pkg/models/shared/pagination.md + - docs/pkg/models/shared/paymentmappingoptions.md + - docs/pkg/models/shared/security.md + - docs/pkg/models/shared/sourcetype.md + - docs/pkg/models/shared/supplier.md + - docs/pkg/models/shared/supplierprototype.md + - docs/pkg/models/shared/supplierref.md + - docs/pkg/models/shared/suppliers.md + - docs/pkg/models/shared/supplierstatus.md + - docs/pkg/models/shared/tags.md + - docs/pkg/models/shared/taxratemappingoption.md + - docs/pkg/models/shared/taxratestatus.md + - docs/pkg/models/webhooks/clientratelimitreachedresponse.md + - docs/pkg/models/webhooks/clientratelimitreachedresponse1.md + - docs/pkg/models/webhooks/clientratelimitresetresponse.md + - docs/pkg/models/webhooks/clientratelimitresetresponse1.md + - docs/sdks/bankaccounts/README.md + - docs/sdks/billpayments/README.md + - docs/sdks/bills/README.md + - docs/sdks/codatsyncpayables/README.md + - docs/sdks/companies/README.md + - docs/sdks/companyinformation/README.md + - docs/sdks/connections/README.md + - docs/sdks/suppliers/README.md + - go.mod + - internal/hooks/hooks.go + - pkg/models/operations/options.go + - pkg/models/sdkerrors/sdkerror.go + - pkg/retry/config.go + - pkg/types/bigint.go + - pkg/types/date.go + - pkg/types/datetime.go + - pkg/types/decimal.go + - pkg/types/pointers.go + - pkg/utils/contenttype.go + - pkg/utils/form.go + - pkg/utils/headers.go + - pkg/utils/json.go + - pkg/utils/pathparams.go + - pkg/utils/queryparams.go + - pkg/utils/requestbody.go + - pkg/utils/retries.go + - pkg/utils/security.go + - pkg/utils/utils.go + - suppliers.go +examples: + list-companies: + "": + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "description": "Requested early access to the new financing scheme.", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}]}], "pageNumber": 1, "pageSize": 10, "totalResults": 1, "_links": {"self": {"href": "/companies/{id}/data/{dataType}"}, "current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}}} + "400": {} + One company: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "name": "My Test Company", "description": "My Test Company make testing software", "redirect": "https://link.codat.io/company/3fa85f64-5717-4562-b3fc-2c963f66afa6", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "platformName": "Pandle", "linkUrl": "https://link-api.codat.io/companies/3fa85f64-5717-4562-b3fc-2c963f66afa6/connections/51baa045-4836-4317-a42e-3542e991e581/start", "status": "Linked", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "dataConnectionErrors": []}]}], "pageNumber": 1, "pageSize": 100, "totalResults": 1, "_links": {"self": {"href": "/companies"}, "current": {"href": "/companies?page=1&pageSize=100"}}} + List of Companies: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "d1568dde-adf6-11ed-afa1-0242ac120002", "name": "Technicalium", "description": "Technology services, including web and app design and development", "redirect": "https://link.codat.io/company/d1568dde-adf6-11ed-afa1-0242ac120002", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "createdByUserName": "Joe Bloggs", "dataConnections": [{"id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "platformName": "Pandle", "linkUrl": "https://link-api.codat.io/companies/d1568dde-adf6-11ed-afa1-0242ac120002/connections/51baa045-4836-4317-a42e-3542e991e581/start", "status": "Linked", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "dataConnectionErrors": []}]}, {"id": "096db70b-78de-4ff0-aa98-299cb5fe17a0", "name": "Godata", "description": "A new digital agency with a passion for creating amazing digital experiences", "redirect": "https://link.codat.io/company/096db70b-78de-4ff0-aa98-299cb5fe17a0", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"id": "a70bc148-dc21-46b2-a257-d9c58ac15cbb", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "platformName": "Pandle", "linkUrl": "https://link-api.codat.io/companies/096db70b-78de-4ff0-aa98-299cb5fe17a0/connections/a70bc148-dc21-46b2-a257-d9c58ac15cbb/start", "status": "Linked", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "dataConnectionErrors": []}]}], "pageNumber": 1, "pageSize": 100, "totalResults": 2, "_links": {"self": {"href": "/companies"}, "current": {"href": "/companies?page=1&pageSize=100"}}} + Malformed query: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-company: + With no description: + requestBody: + application/json: {"name": "Technicalium", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "Technicalium", "description": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": []} + "400": {} + With a description: + requestBody: + application/json: {"name": "Technicalium", "description": "Technology services, including web and app design and development", "groups": []} + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "Technicalium", "description": "Technology services, including web and app design and development", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": []} + "400": {} + With a group: + requestBody: + application/json: {"name": "Technicalium", "description": "Requested early access to the new financing scheme.", "groups": [{"id": "d7a6c4b4-dc87-45f6-b803-62f466398680"}]} + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "Technicalium", "description": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": []} + "400": {} + Malformed query: + requestBody: + application/json: {"name": "Bank of Dave", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + update-company: + Update name: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"name": "New Name", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "200": + application/json: {"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "description": "Requested early access to the new financing scheme.", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}]} + "401": {} + Update description: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"name": "Same name", "description": "Additional documents required", "groups": []} + responses: + "200": + application/json: {"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "description": "Requested early access to the new financing scheme.", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}]} + "401": {} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"name": "Bank of Dave", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + delete-company: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-company: + Simple company: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "My First Company", "description": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18Z", "createdByUserName": "Dan Tzabar", "dataConnections": []} + With groups: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "My First Company", "description": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18Z", "createdByUserName": "Dan Tzabar", "dataConnections": []} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-connections: + "": + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}], "pageNumber": 1, "pageSize": 10, "totalResults": 1, "_links": {"self": {"href": "/companies/{id}/data/{dataType}"}, "current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}}} + "400": {} + Connections: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}], "pageNumber": 0, "pageSize": 0, "totalResults": 0, "_links": {"self": {"href": "string"}, "current": {"href": "string"}, "next": {"href": "string"}, "previous": {"href": "string"}}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-connection: + Connection: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"platformKey": "gbol"} + responses: + "200": + application/json: {"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"platformKey": "gbol"} + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-connection: + Connection: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + delete-connection: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + unlink-connection: + Example: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + requestBody: + application/json: {"status": "Unlinked"} + responses: + "200": + application/json: {"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []} + "401": {} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-company-information: + Company information: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"companyName": "Bank of Dave", "baseCurrency": "GBP"} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-mapping-options-bills: + "": + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + statusQuery: "status=Archived" + responses: + "200": + application/json: {"accounts": [], "taxRate": []} + "400": {} + Mapping options: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + statusQuery: "status=Archived" + responses: + "200": + application/json: {"accounts": [{"id": "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", "nominalCode": "879-i", "name": "Accounts payable", "type": "Liability", "currency": "GBP", "status": "Active", "sourceModifiedDate": "2022-10-23T00:00:00Z"}], "taxRate": [], "pagination": {"continuationToken": "eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + statusQuery: "status=Archived" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-bills: + Status (open): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "status=Open" + responses: + "200": + application/json: {"results": []} + "400": {} + Status (partially paid): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "status=PartiallyPaid" + responses: + "200": + application/json: {"results": []} + "400": {} + Source modified date: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "sourceModifiedDate>2023-12-15T00:00:00.000Z" + responses: + "200": + application/json: {"results": []} + "400": {} + Status (open) & source modified date: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Open" + responses: + "200": + application/json: {"results": []} + "400": {} + Status (partially paid) & source modified date: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=PartiallyPaid" + responses: + "200": + application/json: {"results": []} + "400": {} + Bills: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + responses: + "200": + application/json: {"results": [{"id": "18", "reference": "12", "supplierRef": {"id": "4", "supplierName": "BILLy elliot"}, "issueDate": "2019-05-13T00:00:00", "dueDate": "2019-05-13T00:00:00", "currency": "GBP", "currencyRate": "1,", "lineItems": [{"description": "Dance shoes", "unitAmount": 5, "quantity": 1, "taxAmount": 0, "accountRef": {"id": "16"}, "totalAmount": 5, "taxRateRef": {"id": "NON"}}], "status": "Open", "totalAmount": 5, "amountDue": 0, "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}, {"id": "22", "reference": "12", "supplierRef": {"id": "4", "supplierName": "BILLy elliot"}, "issueDate": "2019-05-13T00:00:00", "dueDate": "2019-05-13T00:00:00", "currency": "GBP", "currencyRate": 1, "lineItems": [{"description": "Dance shoes", "unitAmount": 5, "quantity": 1, "taxAmount": 0, "accountRef": {"id": "16"}, "totalAmount": 5, "taxRateRef": {"id": "NON"}}], "status": "Paid", "totalAmount": 5, "amountDue": 0, "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}], "pagination": {"continuationToken": "eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-bill: + Create bill: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"reference": "bill_b8qmmj4ksf1suax", "supplierRef": {"id": "1262c350-fe0f-40ec-aeff-41c95b4a45af", "supplierName": "DIISR - Small Business Services"}, "issueDate": "2023-04-23T00:00:00", "dueDate": "2023-04-23T00:00:00", "currency": "GBP", "currencyRate": 1, "lineItems": [{"description": "Half day training - Microsoft Office", "unitAmount": 1800, "quantity": 1, "taxAmount": 360, "accountRef": {"id": "46f9461e-788b-4906-8b74-d1ea17f6dc10"}, "totalAmount": 2160, "taxRateRef": {"id": "INPUT2"}}, {"description": "Desktop/network support via email & phone.Per month fixed fee for minimum 20 hours/month.", "unitAmount": 4000, "quantity": 1, "taxAmount": 800, "accountRef": {"id": "f96c9458-d724-47bf-8f74-a9d5726465ce"}, "totalAmount": 4800, "taxRateRef": {"id": "INPUT2"}}, {"description": "Stationery charges", "unitAmount": 32, "quantity": 8, "taxAmount": 51.2, "accountRef": {"id": "cba6527d-f102-4538-b421-e483233e9d5a"}, "totalAmount": 307.2, "taxRateRef": {"id": "INPUT2"}}], "status": "Open", "totalAmount": 7267.2, "amountDue": 7267.2} + responses: + "200": + application/json: {"supplierRef": {"id": ""}, "issueDate": "2022-10-23T00:00:00Z", "dueDate": "2022-10-23T00:00:00Z", "currency": "GBP", "status": "Open", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}} + "400": {} + Created bill: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"supplierRef": {"id": ""}, "issueDate": "2022-10-23T00:00:00Z", "dueDate": "2022-10-23T00:00:00Z", "currency": "USD", "status": "Open"} + responses: + "200": + application/json: {"id": "bill-1029932", "reference": "bill_b8qmmj4ksf1suax", "supplierRef": {"id": "1262c350-fe0f-40ec-aeff-41c95b4a45af", "supplierName": "DIISR - Small Business Services"}, "issueDate": "2023-04-23T00:00:00", "dueDate": "2023-04-23T00:00:00", "currency": "GBP", "lineItems": [{"description": "Half day training - Microsoft Office", "unitAmount": 1800, "quantity": 1, "taxAmount": 360, "accountRef": {"id": "46f9461e-788b-4906-8b74-d1ea17f6dc10"}, "totalAmount": 2160, "taxRateRef": {"id": "INPUT2"}}, {"description": "Desktop/network support via email & phone.Per month fixed fee for minimum 20 hours/month.", "unitAmount": 4000, "quantity": 1, "taxAmount": 800, "accountRef": {"id": "f96c9458-d724-47bf-8f74-a9d5726465ce"}, "totalAmount": 4800, "taxRateRef": {"id": "INPUT2"}}, {"description": "Stationery charges", "unitAmount": 32, "quantity": 8, "taxAmount": 51.2, "accountRef": {"id": "cba6527d-f102-4538-b421-e483233e9d5a"}, "totalAmount": 307.2, "taxRateRef": {"id": "INPUT2"}}], "status": "Open", "totalAmount": 7267.2, "amountDue": 7267.2, "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"supplierRef": {"id": ""}, "issueDate": "2022-10-23T00:00:00Z", "dueDate": "2022-10-23T00:00:00Z", "currency": "GBP", "status": "Open"} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + upload-bill-attachment: + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "EILBDVJVNUAGVKRQ" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-bill-attachments: + Info: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "EILBDVJVNUAGVKRQ" + responses: + "200": + application/json: {"id": "422f093f-e556-4bf3-91c0-93af70c3e850", "name": "receipt.png", "contentType": "image/png", "dateCreated": "2022-10-23T00:00:00.000Z", "fileSize": 100, "includeWhenSent": true, "sourceModifiedDate": "2022-05-26T10:34:10Z"} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "9wg4lep4ush5cxs79pl8sozmsndbaukll3ind4g7buqbm1h2" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + download-bill-attachment: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "EILBDVJVNUAGVKRQ" + attachmentId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-mapping-options-payments: + "": + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + statusQuery: "status=Archived" + responses: + "200": + application/json: {"bankAccounts": []} + "400": {} + Mapping options: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + statusQuery: "status=Archived" + responses: + "200": + application/json: {"bankAccounts": [{"id": "3d5a8e00-d108-4045-8823-7f342676cffa", "name": "Bank of Dave current account", "accountNumber": "12345678", "nominalCode": "1234567", "sortCode": "123456", "currency": "GBP", "status": "Active", "accountType": "Debit", "sourceModifiedDate": "2022-10-23T00:00:00Z"}], "pagination": {"continuationToken": "eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + statusQuery: "status=Archived" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-bill-payment: + Bill payment example: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "7110701885" + header: {} + requestBody: + application/json: {"amount": 22, "date": "2022-10-23T00:00:00.000Z", "reference": "Bill Payment against bill c13e37b6 dfaa-4894-b3be-9fe97bda9f44", "accountRef": {"id": "7bda9f44sr56"}, "currencyRate": 1} + responses: + "200": + application/json: {"amount": 22, "date": "2022-10-23T00:00:00.000Z", "reference": "Bill Payment against bill c13e37b6 dfaa-4894-b3be-9fe97bda9f44", "accountRef": {"id": "9e32cbf8-e7d5-4d4d-a593-08d550682aab"}, "currencyRate": 1} + "400": {} + Bill payment: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "EILBDVJVNUAGVKRQ" + header: {} + requestBody: + application/json: {"amount": 1329.54, "date": "2022-10-23T00:00:00Z", "reference": "Bill Payment against bill c13e37b6-dfaa-4894-b3be-9fe97bda9f44", "accountRef": {"id": ""}} + responses: + "200": + application/json: {"id": "billPayment-1029932", "amount": 22, "date": "2022-10-23T00:00:00.000Z", "reference": "Bill Payment against bill c13e37b6 dfaa-4894-b3be-9fe97bda9f44", "accountRef": {"id": "7bda9f44sr56"}, "currencyRate": 1} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + billId: "9wg4lep4ush5cxs79pl8sozmsndbaukll3ind4g7buqbm1h2" + header: {} + requestBody: + application/json: {"amount": 1329.54, "date": "2022-10-23T00:00:00Z", "reference": "Bill Payment against bill c13e37b6-dfaa-4894-b3be-9fe97bda9f44", "accountRef": {"id": ""}} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-suppliers: + Source modified date: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "sourceModifiedDate>2023-12-15T00:00:00.000Z" + responses: + "200": + application/json: {"results": [{"id": "C520FFD4-F6F6-4FC2-A6D2-5D7088B2B14F", "supplierName": "Kelly's Industrial Supplies", "contactName": "Kelly Ipsum", "emailAddress": "sales@kellysupplies.com", "phone": "07999 999999", "addresses": [{"type": "Billing", "line1": "Unit 51", "line2": "Bakersfield Industrial Estate", "city": "Bakersfield", "region": "California", "country": "USA"}], "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}]} + "400": {} + Status (active): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "status=Active" + responses: + "200": + application/json: {"results": [{"id": "C520FFD4-F6F6-4FC2-A6D2-5D7088B2B14F", "supplierName": "Kelly's Industrial Supplies", "contactName": "Kelly Ipsum", "emailAddress": "sales@kellysupplies.com", "phone": "07999 999999", "addresses": [{"type": "Billing", "line1": "Unit 51", "line2": "Bakersfield Industrial Estate", "city": "Bakersfield", "region": "California", "country": "USA"}], "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}]} + "400": {} + Status (archived): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "status=Archived" + responses: + "200": + application/json: {"results": [{"id": "C520FFD4-F6F6-4FC2-A6D2-5D7088B2B14F", "supplierName": "Kelly's Industrial Supplies", "contactName": "Kelly Ipsum", "emailAddress": "sales@kellysupplies.com", "phone": "07999 999999", "addresses": [{"type": "Billing", "line1": "Unit 51", "line2": "Bakersfield Industrial Estate", "city": "Bakersfield", "region": "California", "country": "USA"}], "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}]} + "400": {} + Status (active) & source modified date: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Active" + responses: + "200": + application/json: {"results": [{"id": "C520FFD4-F6F6-4FC2-A6D2-5D7088B2B14F", "supplierName": "Kelly's Industrial Supplies", "contactName": "Kelly Ipsum", "emailAddress": "sales@kellysupplies.com", "phone": "07999 999999", "addresses": [{"type": "Billing", "line1": "Unit 51", "line2": "Bakersfield Industrial Estate", "city": "Bakersfield", "region": "California", "country": "USA"}], "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}]} + "400": {} + Status (archived) & source modified date: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + query: "sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Archived" + responses: + "200": + application/json: {"results": [{"id": "C520FFD4-F6F6-4FC2-A6D2-5D7088B2B14F", "supplierName": "Kelly's Industrial Supplies", "contactName": "Kelly Ipsum", "emailAddress": "sales@kellysupplies.com", "phone": "07999 999999", "addresses": [{"type": "Billing", "line1": "Unit 51", "line2": "Bakersfield Industrial Estate", "city": "Bakersfield", "region": "California", "country": "USA"}], "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}]} + "400": {} + Suppliers: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + responses: + "200": + application/json: {"results": [{"id": "c523e12f-8b74-4d3a-bbd8-32d7a2f598b4", "supplierName": "City Limousines", "contactName": "Martin Dale", "emailAddress": "martyd@citylim.co", "phone": "07999 999999", "addresses": [{"type": "Billing", "line1": "Unit 51", "line2": "Bakersfield Industrial Estate", "city": "Bakersfield", "region": "California", "country": "USA"}], "status": "Active", "balance": 100, "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}, {"id": "41", "supplierName": "AI Support", "contactName": "AI Support", "phone": "+44 25691 154789", "addresses": [{"type": "Billing", "line1": "test", "region": "string", "country": "Djibouti"}], "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}}], "pagination": {"continuationToken": "eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + continuationToken: "continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ==" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-supplier: + Suppliers: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"supplierName": "Greggs", "contactName": "Greg Greggs", "emailAddress": "greg@greggs.com", "phone": "+44 (0)1223 322410", "addresses": [{"type": "Billing", "line1": "Flat 1", "line2": "2 Dennis Avenue", "city": "London", "region": "Camden", "country": "GBR", "postalCode": "EC1N 7TE"}], "status": "Active", "defaultCurrency": "GBP"} + responses: + "200": + application/json: {"id": "sup-10933920", "supplierName": "Greggs", "contactName": "Greg Greggs", "emailAddress": "greg@greggs.com", "phone": "+44 (0)1223 322410", "status": "Active", "defaultCurrency": "GBP", "sourceModifiedDate": {"sourceModifiedDate": "2022-10-23T00:00:00Z"}} + "400": {} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"supplierName": "", "phone": "(877) 492-8687", "status": "Active"} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-bank-account: + Bank account example: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"nominalCode": "22", "name": "Plutus - Payables - Bank Account 12", "accountType": "Debit", "accountNumber": "0120 0440", "sortCode": "50-50-50", "currency": "GBP"} + responses: + "200": + application/json: {"currency": "USD", "status": "Active", "sourceModifiedDate": "2022-10-23T00:00:00Z"} + "400": {} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + header: {} + requestBody: + application/json: {"name": "", "accountType": "Credit", "accountNumber": "", "currency": "USD"} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} diff --git a/sync-for-payables/.speakeasy/gen.yaml b/sync-for-payables/.speakeasy/gen.yaml index f592edfc8..31ecde8c6 100644 --- a/sync-for-payables/.speakeasy/gen.yaml +++ b/sync-for-payables/.speakeasy/gen.yaml @@ -1,15 +1,21 @@ configVersion: 2.0.0 generation: sdkClassName: CodatSyncPayables + maintainOpenAPIOrder: true usageSnippets: optionalPropertyRendering: withExample + useClassNamesForArrayFields: true fixes: nameResolutionDec2023: false parameterOrderingFeb2024: false requestResponseComponentNamesFeb2024: false + auth: + oAuth2ClientCredentialsEnabled: true telemetryEnabled: true go: version: 1.0.0 + additionalDependencies: {} + allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true flattenGlobalSecurity: false imports: @@ -22,5 +28,7 @@ go: webhooks: pkg/models/webhooks inputModelSuffix: input maxMethodParams: 0 + methodArguments: require-security-and-request outputModelSuffix: output packageName: github.com/codatio/client-sdk-go/sync-for-payables + responseFormat: envelope-http diff --git a/sync-for-payables/CONTRIBUTING.md b/sync-for-payables/CONTRIBUTING.md new file mode 100644 index 000000000..d585717fc --- /dev/null +++ b/sync-for-payables/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/sync-for-payables/README.md b/sync-for-payables/README.md new file mode 100644 index 000000000..e5080f866 --- /dev/null +++ b/sync-for-payables/README.md @@ -0,0 +1,511 @@ +# github.com/codatio/client-sdk-go/sync-for-payables + +Developer-friendly & type-safe Go SDK specifically catered to leverage *github.com/codatio/client-sdk-go/sync-for-payables* API. + +
+ + + + +
+ + +## 🏗 **Welcome to your new SDK!** 🏗 + +It has been generated successfully based on your OpenAPI spec. However, it is not yet ready for production use. Here are some next steps: +- [ ] 🛠 Make your SDK feel handcrafted by [customizing it](https://www.speakeasy.com/docs/customize-sdks) +- [ ] ♻️ Refine your SDK quickly by iterating locally with the [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) +- [ ] 🎁 Publish your SDK to package managers by [configuring automatic publishing](https://www.speakeasy.com/docs/advanced-setup/publish-sdks) +- [ ] ✨ When ready to productionize, delete this section from the README + + +## Summary + +Bill pay kit: The API reference for the Bill Pay kit. + +The bill pay kit is an API and a set of supporting tools designed to integrate a bill pay flow into your app as quickly as possible. It's ideal for facilitating essential bill payment processes within your SMB's accounting software. + +[Explore product](https://docs.codat.io/payables/bill-pay-kit) | [See OpenAPI spec](https://github.com/codatio/oas) + +--- + +## Endpoints + +| Endpoints | Description | +| :- |:- | +| Companies | Create and manage your SMB users' companies. | +| Connections | Create new and manage existing data connections for a company. | +| Company information | View company profile from the source platform. | +| Bills | Get, create, and update Bills. | +| Bill payments | Get, create, and update Bill payments. | +| Suppliers | Get, create, and update Suppliers. | +| Bank accounts | Create a bank account for a given company's connection. | + + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Authentication](#authentication) +* [Special Types](#special-types) + + + +## SDK Installation + +To add the SDK as a dependency to your project: +```bash +go get github.com/codatio/client-sdk-go/sync-for-payables +``` + + + +## SDK Example Usage + +### Example + +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + + + +## Available Resources and Operations + +
+Available methods + +### [BankAccounts](docs/sdks/bankaccounts/README.md) + +* [Create](docs/sdks/bankaccounts/README.md#create) - Create bank account + +### [BillPayments](docs/sdks/billpayments/README.md) + +* [GetPaymentOptions](docs/sdks/billpayments/README.md#getpaymentoptions) - Get payment mapping options +* [Create](docs/sdks/billpayments/README.md#create) - Create bill payment + +### [Bills](docs/sdks/bills/README.md) + +* [GetBillOptions](docs/sdks/bills/README.md#getbilloptions) - Get bill mapping options +* [List](docs/sdks/bills/README.md#list) - List bills +* [Create](docs/sdks/bills/README.md#create) - Create bill +* [UploadAttachment](docs/sdks/bills/README.md#uploadattachment) - Upload bill attachment +* [ListAttachments](docs/sdks/bills/README.md#listattachments) - List bill attachments +* [DownloadAttachment](docs/sdks/bills/README.md#downloadattachment) - Download bill attachment + + +### [Companies](docs/sdks/companies/README.md) + +* [List](docs/sdks/companies/README.md#list) - List companies +* [Create](docs/sdks/companies/README.md#create) - Create company +* [Update](docs/sdks/companies/README.md#update) - Update company +* [Delete](docs/sdks/companies/README.md#delete) - Delete a company +* [Get](docs/sdks/companies/README.md#get) - Get company + +### [CompanyInformation](docs/sdks/companyinformation/README.md) + +* [Get](docs/sdks/companyinformation/README.md#get) - Get company information + +### [Connections](docs/sdks/connections/README.md) + +* [List](docs/sdks/connections/README.md#list) - List connections +* [Create](docs/sdks/connections/README.md#create) - Create connection +* [Get](docs/sdks/connections/README.md#get) - Get connection +* [Delete](docs/sdks/connections/README.md#delete) - Delete connection +* [Unlink](docs/sdks/connections/README.md#unlink) - Unlink connection + +### [Suppliers](docs/sdks/suppliers/README.md) + +* [List](docs/sdks/suppliers/README.md#list) - List suppliers +* [Create](docs/sdks/suppliers/README.md#create) - Create supplier + +
+ + + +## Retries + +Some 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 a `retry.Config` object to the call by using the `WithRetries` option: +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "log" + "pkg/models/operations" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }, operations.WithRetries( + retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 1, + MaxInterval: 50, + Exponent: 1.1, + MaxElapsedTime: 100, + }, + RetryConnectionErrors: false, + })) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + +If you'd like to override the default retry strategy for all operations that support retries, you can use the `WithRetryConfig` option at SDK initialization: +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithRetryConfig( + retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 1, + MaxInterval: 50, + Exponent: 1.1, + MaxElapsedTime: 100, + }, + RetryConnectionErrors: false, + }), + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + + + +## Error Handling + +Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass. + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +### Example + +```go +package main + +import ( + "context" + "errors" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + + var e *sdkerrors.ErrorMessage + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + + var e *sdkerrors.SDKError + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + } +} + +``` + + + +## Server Selection + +### Select Server by Index + +You can override the default server globally using the `WithServerIndex` option 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: + +| # | Server | Variables | +| - | ------ | --------- | +| 0 | `https://api.codat.io` | None | + +#### Example + +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithServerIndex(0), + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + + +### Override Server URL Per-Client + +The default server can also be overridden globally using the `WithServerURL` option when initializing the SDK client instance. For example: +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithServerURL("https://api.codat.io"), + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + + + +## Custom HTTP Client + +The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface: + +```go +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} +``` + +The built-in `net/http` client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout. + +```go +import ( + "net/http" + "time" + "github.com/myorg/your-go-sdk" +) + +var ( + httpClient = &http.Client{Timeout: 30 * time.Second} + sdkClient = sdk.New(sdk.WithClient(httpClient)) +) +``` + +This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration. + + + +## Authentication + +### Per-Client Security Schemes + +This SDK supports the following security scheme globally: + +| Name | Type | Scheme | +| ------------ | ------------ | ------------ | +| `AuthHeader` | apiKey | API key | + +You can configure it using the `WithSecurity` option when initializing the SDK client instance. For example: +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + + + +## Special Types + + + + + + +# Development + +## Maturity + +This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage +to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally +looking for the latest version. + +## Contributions + +While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. +We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release. + +### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=github-com/codatio/client-sdk-go/sync-for-payables&utm_campaign=go) diff --git a/sync-for-payables/RELEASES.md b/sync-for-payables/RELEASES.md new file mode 100644 index 000000000..a84555dda --- /dev/null +++ b/sync-for-payables/RELEASES.md @@ -0,0 +1,11 @@ + + +## 2024-09-14 09:04:12 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.396.9 (2.415.7) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v1.0.0] sync-for-payables +### Releases +- [Go v1.0.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-payables/v1.0.0 - sync-for-payables \ No newline at end of file diff --git a/sync-for-payables/USAGE.md b/sync-for-payables/USAGE.md new file mode 100644 index 000000000..af59cf522 --- /dev/null +++ b/sync-for-payables/USAGE.md @@ -0,0 +1,36 @@ + +```go +package main + +import ( + "context" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} + +``` + \ No newline at end of file diff --git a/sync-for-payables/bankaccounts.go b/sync-for-payables/bankaccounts.go new file mode 100644 index 000000000..bcbda4126 --- /dev/null +++ b/sync-for-payables/bankaccounts.go @@ -0,0 +1,280 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" +) + +// BankAccounts - Create a bank account for a given company's connection. +type BankAccounts struct { + sdkConfiguration sdkConfiguration +} + +func newBankAccounts(sdkConfig sdkConfiguration) *BankAccounts { + return &BankAccounts{ + sdkConfiguration: sdkConfig, + } +} + +// Create bank account +// The *Create bank account* endpoint creates a new [bank account](https://docs.codat.io/sync-for-payables-api#/schemas/BankAccount) for a given company's connection. +// +// [Bank accounts](https://docs.codat.io/sync-for-payables-api#/schemas/BankAccount) are financial accounts maintained by a bank or other financial institution. +func (s *BankAccounts) Create(ctx context.Context, request operations.CreateBankAccountRequest, opts ...operations.Option) (*operations.CreateBankAccountResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "create-bank-account", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/bankAccounts", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "BankAccountPrototype", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateBankAccountResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.BankAccount + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.BankAccount = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/sync-for-payables/billpayments.go b/sync-for-payables/billpayments.go new file mode 100644 index 000000000..67307718d --- /dev/null +++ b/sync-for-payables/billpayments.go @@ -0,0 +1,531 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" +) + +// BillPayments - Get, create, and update Bill payments. +type BillPayments struct { + sdkConfiguration sdkConfiguration +} + +func newBillPayments(sdkConfig sdkConfiguration) *BillPayments { + return &BillPayments{ + sdkConfiguration: sdkConfig, + } +} + +// GetPaymentOptions - Get payment mapping options +// Use the *Get mapping options - Payments* endpoint to return a list of available mapping options for a given company's connection ID. +// +// By default, this endpoint returns a list of active bank accounts. You can use [querying](https://docs.codat.io/using-the-api/querying) to change that. +// +// Mapping options are a set of bank accounts used to configure the SMB's payables integration. +func (s *BillPayments) GetPaymentOptions(ctx context.Context, request operations.GetMappingOptionsPaymentsRequest, opts ...operations.Option) (*operations.GetMappingOptionsPaymentsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "get-mapping-options-payments", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/mappingOptions/payments", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetMappingOptionsPaymentsResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.PaymentMappingOptions + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.PaymentMappingOptions = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Create bill payment +// The *Create bill payment* endpoint creates a new [bill payment](https://docs.codat.io/sync-for-payables-api#/schemas/BillPayment) for a given company's connection. +// +// [Bill payments](https://docs.codat.io/sync-for-payables-api#/schemas/BillPayment) are an allocation of money within any Accounts Payable account. +func (s *BillPayments) Create(ctx context.Context, request operations.CreateBillPaymentRequest, opts ...operations.Option) (*operations.CreateBillPaymentResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "create-bill-payment", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/bills/{billId}/payment", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "BillPaymentPrototype", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "409", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateBillPaymentResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.BillPayment + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.BillPayment = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/sync-for-payables/bills.go b/sync-for-payables/bills.go new file mode 100644 index 000000000..6b0a92d76 --- /dev/null +++ b/sync-for-payables/bills.go @@ -0,0 +1,1488 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" +) + +// Bills - Get, create, and update Bills. +type Bills struct { + sdkConfiguration sdkConfiguration +} + +func newBills(sdkConfig sdkConfiguration) *Bills { + return &Bills{ + sdkConfiguration: sdkConfig, + } +} + +// GetBillOptions - Get bill mapping options +// Use the *Get mapping options - Bills* endpoint to return a list of available mapping options for a given company's connection ID. +// +// By default, this endpoint returns a list of active accounts and tax rates. You can use [querying](https://docs.codat.io/using-the-api/querying) to change that. +// +// Mapping options are a set of accounts and tax rates used to configure the SMB's payables integration. +func (s *Bills) GetBillOptions(ctx context.Context, request operations.GetMappingOptionsBillsRequest, opts ...operations.Option) (*operations.GetMappingOptionsBillsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "get-mapping-options-bills", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/mappingOptions/bills", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetMappingOptionsBillsResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.BillMappingOptions + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.BillMappingOptions = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// List bills +// The *List bills* endpoint returns a list of [bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) for a given company's connection. +// +// [Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. +// +// By default, the endpoint will return all bills with a status of 'Open' & 'PartiallyPaid' to show all oustanding bills. +func (s *Bills) List(ctx context.Context, request operations.ListBillsRequest, opts ...operations.Option) (*operations.ListBillsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "list-bills", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/bills", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "409", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListBillsResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Bills + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Bills = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Create bill +// The *Create bill* endpoint creates a new [bill](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) for a given company's connection. +// +// [Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. +func (s *Bills) Create(ctx context.Context, request operations.CreateBillRequest, opts ...operations.Option) (*operations.CreateBillResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "create-bill", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/bills", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "BillPrototype", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "409", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateBillResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Bill + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Bill = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// UploadAttachment - Upload bill attachment +// The *Upload bill attachment* endpoint uploads an attachment and assigns it against a specific `billId`. +// +// [Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. +func (s *Bills) UploadAttachment(ctx context.Context, request operations.UploadBillAttachmentRequest, opts ...operations.Option) (*operations.UploadBillAttachmentResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "upload-bill-attachment", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/bills/{billId}/attachments", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "AttachmentUpload", "multipart", `request:"mediaType=multipart/form-data"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UploadBillAttachmentResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ListAttachments - List bill attachments +// The *List bill attachments* endpoint returns a list of attachments available to download for a given `billId`. +// +// [Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. +func (s *Bills) ListAttachments(ctx context.Context, request operations.ListBillAttachmentsRequest, opts ...operations.Option) (*operations.ListBillAttachmentsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "list-bill-attachments", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/bills/{billId}/attachments", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "409", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListBillAttachmentsResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Attachment + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Attachment = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// DownloadAttachment - Download bill attachment +// The *Download bill attachment* endpoint downloads a specific attachment for a given `billId` and `attachmentId`. +// +// [Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. +// +// Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=bills) for integrations that support downloading a bill attachment. +func (s *Bills) DownloadAttachment(ctx context.Context, request operations.DownloadBillAttachmentRequest, opts ...operations.Option) (*operations.DownloadBillAttachmentResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "download-bill-attachment", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/bills/{billId}/attachments/{attachmentId}/download", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/octet-stream") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DownloadBillAttachmentResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/octet-stream`): + res.Data = httpRes.Body + + return res, nil + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/sync-for-payables/codatsyncpayables.go b/sync-for-payables/codatsyncpayables.go new file mode 100644 index 000000000..f30ebd339 --- /dev/null +++ b/sync-for-payables/codatsyncpayables.go @@ -0,0 +1,220 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "context" + "fmt" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "net/http" + "time" +) + +// ServerList contains the list of servers available to the SDK +var ServerList = []string{ + // Production + "https://api.codat.io", +} + +// HTTPClient provides an interface for suplying the SDK with a custom HTTP client +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +// String provides a helper function to return a pointer to a string +func String(s string) *string { return &s } + +// Bool provides a helper function to return a pointer to a bool +func Bool(b bool) *bool { return &b } + +// Int provides a helper function to return a pointer to an int +func Int(i int) *int { return &i } + +// Int64 provides a helper function to return a pointer to an int64 +func Int64(i int64) *int64 { return &i } + +// Float32 provides a helper function to return a pointer to a float32 +func Float32(f float32) *float32 { return &f } + +// Float64 provides a helper function to return a pointer to a float64 +func Float64(f float64) *float64 { return &f } + +// Pointer provides a helper function to return a pointer to a type +func Pointer[T any](v T) *T { return &v } + +type sdkConfiguration struct { + Client HTTPClient + Security func(context.Context) (interface{}, error) + ServerURL string + ServerIndex int + Language string + OpenAPIDocVersion string + SDKVersion string + GenVersion string + UserAgent string + RetryConfig *retry.Config + Hooks *hooks.Hooks + Timeout *time.Duration +} + +func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { + if c.ServerURL != "" { + return c.ServerURL, nil + } + + return ServerList[c.ServerIndex], nil +} + +// CodatSyncPayables - Bill pay kit: The API reference for the Bill Pay kit. +// +// The bill pay kit is an API and a set of supporting tools designed to integrate a bill pay flow into your app as quickly as possible. It's ideal for facilitating essential bill payment processes within your SMB's accounting software. +// +// [Explore product](https://docs.codat.io/payables/bill-pay-kit) | [See OpenAPI spec](https://github.com/codatio/oas) +// +// --- +// +// ## Endpoints +// +// | Endpoints | Description | +// | :- |:- | +// | Companies | Create and manage your SMB users' companies. | +// | Connections | Create new and manage existing data connections for a company. | +// | Company information | View company profile from the source platform. | +// | Bills | Get, create, and update Bills. | +// | Bill payments | Get, create, and update Bill payments. | +// | Suppliers | Get, create, and update Suppliers. | +// | Bank accounts | Create a bank account for a given company's connection. | +// +type CodatSyncPayables struct { + // Create and manage your SMB users' companies. + Companies *Companies + // Create new and manage existing data connections for a company. + Connections *Connections + // View company profile from the source platform. + CompanyInformation *CompanyInformation + // Get, create, and update Bills. + Bills *Bills + // Get, create, and update Bill payments. + BillPayments *BillPayments + // Get, create, and update Suppliers. + Suppliers *Suppliers + // Create a bank account for a given company's connection. + BankAccounts *BankAccounts + + sdkConfiguration sdkConfiguration +} + +type SDKOption func(*CodatSyncPayables) + +// WithServerURL allows the overriding of the default server URL +func WithServerURL(serverURL string) SDKOption { + return func(sdk *CodatSyncPayables) { + sdk.sdkConfiguration.ServerURL = serverURL + } +} + +// WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters +func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption { + return func(sdk *CodatSyncPayables) { + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + sdk.sdkConfiguration.ServerURL = serverURL + } +} + +// WithServerIndex allows the overriding of the default server by index +func WithServerIndex(serverIndex int) SDKOption { + return func(sdk *CodatSyncPayables) { + if serverIndex < 0 || serverIndex >= len(ServerList) { + panic(fmt.Errorf("server index %d out of range", serverIndex)) + } + + sdk.sdkConfiguration.ServerIndex = serverIndex + } +} + +// WithClient allows the overriding of the default HTTP client used by the SDK +func WithClient(client HTTPClient) SDKOption { + return func(sdk *CodatSyncPayables) { + sdk.sdkConfiguration.Client = client + } +} + +// WithSecurity configures the SDK to use the provided security details +func WithSecurity(security shared.Security) SDKOption { + return func(sdk *CodatSyncPayables) { + sdk.sdkConfiguration.Security = utils.AsSecuritySource(security) + } +} + +// WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication +func WithSecuritySource(security func(context.Context) (shared.Security, error)) SDKOption { + return func(sdk *CodatSyncPayables) { + sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) { + return security(ctx) + } + } +} + +func WithRetryConfig(retryConfig retry.Config) SDKOption { + return func(sdk *CodatSyncPayables) { + sdk.sdkConfiguration.RetryConfig = &retryConfig + } +} + +// WithTimeout Optional request timeout applied to each operation +func WithTimeout(timeout time.Duration) SDKOption { + return func(sdk *CodatSyncPayables) { + sdk.sdkConfiguration.Timeout = &timeout + } +} + +// New creates a new instance of the SDK with the provided options +func New(opts ...SDKOption) *CodatSyncPayables { + sdk := &CodatSyncPayables{ + sdkConfiguration: sdkConfiguration{ + Language: "go", + OpenAPIDocVersion: "3.0.0", + SDKVersion: "1.0.0", + GenVersion: "2.415.7", + UserAgent: "speakeasy-sdk/go 1.0.0 2.415.7 3.0.0 github.com/codatio/client-sdk-go/sync-for-payables", + Hooks: hooks.New(), + }, + } + for _, opt := range opts { + opt(sdk) + } + + // Use WithClient to override the default client if you would like to customize the timeout + if sdk.sdkConfiguration.Client == nil { + sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second} + } + + currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails() + serverURL := currentServerURL + serverURL, sdk.sdkConfiguration.Client = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client) + if serverURL != currentServerURL { + sdk.sdkConfiguration.ServerURL = serverURL + } + + sdk.Companies = newCompanies(sdk.sdkConfiguration) + + sdk.Connections = newConnections(sdk.sdkConfiguration) + + sdk.CompanyInformation = newCompanyInformation(sdk.sdkConfiguration) + + sdk.Bills = newBills(sdk.sdkConfiguration) + + sdk.BillPayments = newBillPayments(sdk.sdkConfiguration) + + sdk.Suppliers = newSuppliers(sdk.sdkConfiguration) + + sdk.BankAccounts = newBankAccounts(sdk.sdkConfiguration) + + return sdk +} diff --git a/sync-for-payables/companies.go b/sync-for-payables/companies.go new file mode 100644 index 000000000..855b13271 --- /dev/null +++ b/sync-for-payables/companies.go @@ -0,0 +1,1240 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" + "net/url" +) + +// Companies - Create and manage your SMB users' companies. +type Companies struct { + sdkConfiguration sdkConfiguration +} + +func newCompanies(sdkConfig sdkConfiguration) *Companies { + return &Companies{ + sdkConfiguration: sdkConfig, + } +} + +// List companies +// The *List companies* endpoint returns a list of [companies] associated to your instances. +// +// A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +// Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. +func (s *Companies) List(ctx context.Context, request operations.ListCompaniesRequest, opts ...operations.Option) (*operations.ListCompaniesResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "list-companies", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/companies") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListCompaniesResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Companies + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Companies = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Create company +// Use the *Create company* endpoint to create a new [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) that represents your customer in Codat. +// +// A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +// Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. +// +// If forbidden characters (see `name` pattern) are present in the request, a company will be created with the forbidden characters removed. For example, `Company (Codat[1])` with be created as `Company Codat1`. +func (s *Companies) Create(ctx context.Context, request *shared.CompanyRequestBody, opts ...operations.Option) (*operations.CreateCompanyResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "create-company", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/companies") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateCompanyResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Company + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Company = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Update company +// Use the *Update company* endpoint to update both the name and description of the company. +// If you use [groups](https://docs.codat.io/sync-for-payables-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/sync-for-payables-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/sync-for-payables-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. +// +// A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +// Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. +func (s *Companies) Update(ctx context.Context, request operations.UpdateCompanyRequest, opts ...operations.Option) (*operations.UpdateCompanyResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "update-company", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "CompanyRequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdateCompanyResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Company + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Company = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Delete a company +// The *Delete company* endpoint permanently deletes a [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company), its [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) and any cached data. This operation is irreversible. +// +// A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +// Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. +func (s *Companies) Delete(ctx context.Context, request operations.DeleteCompanyRequest, opts ...operations.Option) (*operations.DeleteCompanyResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "delete-company", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteCompanyResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Get company +// The *Get company* endpoint returns a single company for a given `companyId`. +// +// A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +// Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. +func (s *Companies) Get(ctx context.Context, request operations.GetCompanyRequest, opts ...operations.Option) (*operations.GetCompanyResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "get-company", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetCompanyResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Company + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Company = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/sync-for-payables/companyinformation.go b/sync-for-payables/companyinformation.go new file mode 100644 index 000000000..b39ca85e8 --- /dev/null +++ b/sync-for-payables/companyinformation.go @@ -0,0 +1,270 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" +) + +// CompanyInformation - View company profile from the source platform. +type CompanyInformation struct { + sdkConfiguration sdkConfiguration +} + +func newCompanyInformation(sdkConfig sdkConfiguration) *CompanyInformation { + return &CompanyInformation{ + sdkConfiguration: sdkConfig, + } +} + +// Get company information +// Use the *Get company information* endpoint to return information about the company available from the underlying accounting software. +func (s *CompanyInformation) Get(ctx context.Context, request operations.GetCompanyInformationRequest, opts ...operations.Option) (*operations.GetCompanyInformationResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "get-company-information", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/info", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetCompanyInformationResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.CompanyInformation + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CompanyInformation = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/sync-for-payables/connections.go b/sync-for-payables/connections.go new file mode 100644 index 000000000..4e2635f52 --- /dev/null +++ b/sync-for-payables/connections.go @@ -0,0 +1,1224 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" +) + +// Connections - Create new and manage existing data connections for a company. +type Connections struct { + sdkConfiguration sdkConfiguration +} + +func newConnections(sdkConfig sdkConfiguration) *Connections { + return &Connections{ + sdkConfiguration: sdkConfig, + } +} + +// List connections +// List the connections for a company. +func (s *Connections) List(ctx context.Context, request operations.ListConnectionsRequest, opts ...operations.Option) (*operations.ListConnectionsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "list-connections", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListConnectionsResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Connections + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Connections = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Create connection +// Creates a connection for the company by providing a valid `platformKey`. +// +// Use the [List Integrations](https://docs.codat.io/sync-for-payables-api#/operations/list-integrations) endpoint to access valid platform keys. +func (s *Connections) Create(ctx context.Context, request operations.CreateConnectionRequest, opts ...operations.Option) (*operations.CreateConnectionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "create-connection", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateConnectionResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Connection + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Connection = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Get connection +// Returns a specific connection for a company when valid identifiers are provided. If the identifiers are for a deleted company and/or connection, a not found response is returned. +func (s *Connections) Get(ctx context.Context, request operations.GetConnectionRequest, opts ...operations.Option) (*operations.GetConnectionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "get-connection", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetConnectionResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Connection + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Connection = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Delete connection +// Revoke and remove a connection from a company. +// This operation is not reversible. The end user would need to reauthorize a new data connection if you wish to view new data for this company. +func (s *Connections) Delete(ctx context.Context, request operations.DeleteConnectionRequest, opts ...operations.Option) (*operations.DeleteConnectionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "delete-connection", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteConnectionResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Unlink connection +// This allows you to deauthorize a connection, without deleting it from Codat. This means you can still view any data that has previously been pulled into Codat, and also lets you re-authorize in future if your customer wishes to resume sharing their data. +func (s *Connections) Unlink(ctx context.Context, request operations.UnlinkConnectionRequest, opts ...operations.Option) (*operations.UnlinkConnectionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "unlink-connection", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UnlinkConnectionResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Connection + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Connection = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/sync-for-payables/docs/pkg/models/operations/createbankaccountrequest.md b/sync-for-payables/docs/pkg/models/operations/createbankaccountrequest.md new file mode 100644 index 000000000..580e0ae27 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createbankaccountrequest.md @@ -0,0 +1,11 @@ +# CreateBankAccountRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | A unique identifier to ensure idempotent behaviour for subsequent requests. | | +| `BankAccountPrototype` | [*shared.BankAccountPrototype](../../../pkg/models/shared/bankaccountprototype.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createbankaccountresponse.md b/sync-for-payables/docs/pkg/models/operations/createbankaccountresponse.md new file mode 100644 index 000000000..6fe132d7f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createbankaccountresponse.md @@ -0,0 +1,9 @@ +# CreateBankAccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `BankAccount` | [*shared.BankAccount](../../../pkg/models/shared/bankaccount.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createbillpaymentrequest.md b/sync-for-payables/docs/pkg/models/operations/createbillpaymentrequest.md new file mode 100644 index 000000000..b89d71cd9 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createbillpaymentrequest.md @@ -0,0 +1,12 @@ +# CreateBillPaymentRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `BillID` | *string* | :heavy_check_mark: | Unique identifier for a bill. | 13d946f0-c5d5-42bc-b092-97ece17923ab | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | A unique identifier to ensure idempotent behaviour for subsequent requests. | | +| `BillPaymentPrototype` | [*shared.BillPaymentPrototype](../../../pkg/models/shared/billpaymentprototype.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createbillpaymentresponse.md b/sync-for-payables/docs/pkg/models/operations/createbillpaymentresponse.md new file mode 100644 index 000000000..2bd91fa60 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createbillpaymentresponse.md @@ -0,0 +1,9 @@ +# CreateBillPaymentResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `BillPayment` | [*shared.BillPayment](../../../pkg/models/shared/billpayment.md) | :heavy_minus_sign: | Success | {
"amount": 22,
"date": "2022-10-23T00:00:00.000Z",
"reference": "Bill Payment against bill c13e37b6 dfaa-4894-b3be-9fe97bda9f44",
"accountRef": {
"id": "9e32cbf8-e7d5-4d4d-a593-08d550682aab"
},
"currencyRate": 1
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createbillrequest.md b/sync-for-payables/docs/pkg/models/operations/createbillrequest.md new file mode 100644 index 000000000..6790bfaaa --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createbillrequest.md @@ -0,0 +1,11 @@ +# CreateBillRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | A unique identifier to ensure idempotent behaviour for subsequent requests. | | +| `BillPrototype` | [*shared.BillPrototype](../../../pkg/models/shared/billprototype.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createbillresponse.md b/sync-for-payables/docs/pkg/models/operations/createbillresponse.md new file mode 100644 index 000000000..752a80d89 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createbillresponse.md @@ -0,0 +1,9 @@ +# CreateBillResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Bill` | [*shared.Bill](../../../pkg/models/shared/bill.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createcompanyresponse.md b/sync-for-payables/docs/pkg/models/operations/createcompanyresponse.md new file mode 100644 index 000000000..aeb05c714 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createcompanyresponse.md @@ -0,0 +1,9 @@ +# CreateCompanyResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Company` | [*shared.Company](../../../pkg/models/shared/company.md) | :heavy_minus_sign: | OK | {
"id": "0498e921-9b53-4396-a412-4f2f5983b0a2",
"name": "string",
"redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739",
"lastSync": "2022-01-01T12:00:00.000Z",
"created": "2022-01-01T12:00:00.000Z",
"createdByUserName": "string",
"tags": {
"region": "us",
"uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c"
},
"dataConnections": [
{
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
}
]
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createconnectionrequest.md b/sync-for-payables/docs/pkg/models/operations/createconnectionrequest.md new file mode 100644 index 000000000..8babb2482 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createconnectionrequest.md @@ -0,0 +1,9 @@ +# CreateConnectionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `RequestBody` | [*operations.CreateConnectionRequestBody](../../../pkg/models/operations/createconnectionrequestbody.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createconnectionrequestbody.md b/sync-for-payables/docs/pkg/models/operations/createconnectionrequestbody.md new file mode 100644 index 000000000..ffdd84a5d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createconnectionrequestbody.md @@ -0,0 +1,8 @@ +# CreateConnectionRequestBody + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `PlatformKey` | **string* | :heavy_minus_sign: | A unique 4-letter key to represent a platform in each integration. View [accounting](https://docs.codat.io/integrations/accounting/overview#platform-keys), [banking](https://docs.codat.io/integrations/banking/overview#platform-keys), and [commerce](https://docs.codat.io/integrations/commerce/overview#platform-keys) platform keys. | gbol | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createconnectionresponse.md b/sync-for-payables/docs/pkg/models/operations/createconnectionresponse.md new file mode 100644 index 000000000..f86038973 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createconnectionresponse.md @@ -0,0 +1,9 @@ +# CreateConnectionResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Connection` | [*shared.Connection](../../../pkg/models/shared/connection.md) | :heavy_minus_sign: | OK | {
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createsupplierrequest.md b/sync-for-payables/docs/pkg/models/operations/createsupplierrequest.md new file mode 100644 index 000000000..b1e5e30c6 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createsupplierrequest.md @@ -0,0 +1,11 @@ +# CreateSupplierRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | A unique identifier to ensure idempotent behaviour for subsequent requests. | | +| `SupplierPrototype` | [*shared.SupplierPrototype](../../../pkg/models/shared/supplierprototype.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/createsupplierresponse.md b/sync-for-payables/docs/pkg/models/operations/createsupplierresponse.md new file mode 100644 index 000000000..2fc838ad7 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/createsupplierresponse.md @@ -0,0 +1,9 @@ +# CreateSupplierResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Supplier` | [*shared.Supplier](../../../pkg/models/shared/supplier.md) | :heavy_minus_sign: | Success | {
"id": "C520FFD4-F6F6-4FC2-A6D2-5D7088B2B14F",
"supplierName": "Kelly's Industrial Supplies",
"contactName": "Kelly Ipsum",
"emailAddress": "sales@kellysupplies.com",
"phone": "07999 999999",
"addresses": [
{
"type": "Billing",
"line1": "Unit 51",
"line2": "Bakersfield Industrial Estate",
"city": "Bakersfield",
"region": "California",
"country": "USA",
"postalcode": "93308"
}
],
"status": "Active",
"amount": 100,
"defaultCurrency": "GBP",
"sourceModifiedDate": "2022-10-23T00:00:00Z"
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/deletecompanyrequest.md b/sync-for-payables/docs/pkg/models/operations/deletecompanyrequest.md new file mode 100644 index 000000000..494a78a47 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/deletecompanyrequest.md @@ -0,0 +1,8 @@ +# DeleteCompanyRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/deletecompanyresponse.md b/sync-for-payables/docs/pkg/models/operations/deletecompanyresponse.md new file mode 100644 index 000000000..5c4f0b707 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/deletecompanyresponse.md @@ -0,0 +1,8 @@ +# DeleteCompanyResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/deleteconnectionrequest.md b/sync-for-payables/docs/pkg/models/operations/deleteconnectionrequest.md new file mode 100644 index 000000000..d9d989f3a --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/deleteconnectionrequest.md @@ -0,0 +1,9 @@ +# DeleteConnectionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/deleteconnectionresponse.md b/sync-for-payables/docs/pkg/models/operations/deleteconnectionresponse.md new file mode 100644 index 000000000..01ca8efa7 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/deleteconnectionresponse.md @@ -0,0 +1,8 @@ +# DeleteConnectionResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/downloadbillattachmentrequest.md b/sync-for-payables/docs/pkg/models/operations/downloadbillattachmentrequest.md new file mode 100644 index 000000000..e807f98ea --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/downloadbillattachmentrequest.md @@ -0,0 +1,11 @@ +# DownloadBillAttachmentRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `BillID` | *string* | :heavy_check_mark: | Unique identifier for a bill. | 13d946f0-c5d5-42bc-b092-97ece17923ab | +| `AttachmentID` | *string* | :heavy_check_mark: | Unique identifier for an attachment. | 8a210b68-6988-11ed-a1eb-0242ac120002 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/downloadbillattachmentresponse.md b/sync-for-payables/docs/pkg/models/operations/downloadbillattachmentresponse.md new file mode 100644 index 000000000..4e2f861d1 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/downloadbillattachmentresponse.md @@ -0,0 +1,9 @@ +# DownloadBillAttachmentResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Data` | *io.ReadCloser* | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getcompanyinformationrequest.md b/sync-for-payables/docs/pkg/models/operations/getcompanyinformationrequest.md new file mode 100644 index 000000000..aff95cfb4 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getcompanyinformationrequest.md @@ -0,0 +1,9 @@ +# GetCompanyInformationRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getcompanyinformationresponse.md b/sync-for-payables/docs/pkg/models/operations/getcompanyinformationresponse.md new file mode 100644 index 000000000..9cde0aacf --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getcompanyinformationresponse.md @@ -0,0 +1,9 @@ +# GetCompanyInformationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CompanyInformation` | [*shared.CompanyInformation](../../../pkg/models/shared/companyinformation.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getcompanyrequest.md b/sync-for-payables/docs/pkg/models/operations/getcompanyrequest.md new file mode 100644 index 000000000..cea5c8a40 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getcompanyrequest.md @@ -0,0 +1,8 @@ +# GetCompanyRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getcompanyresponse.md b/sync-for-payables/docs/pkg/models/operations/getcompanyresponse.md new file mode 100644 index 000000000..268a8cba2 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getcompanyresponse.md @@ -0,0 +1,9 @@ +# GetCompanyResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Company` | [*shared.Company](../../../pkg/models/shared/company.md) | :heavy_minus_sign: | OK | {
"id": "0498e921-9b53-4396-a412-4f2f5983b0a2",
"name": "string",
"redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739",
"lastSync": "2022-01-01T12:00:00.000Z",
"created": "2022-01-01T12:00:00.000Z",
"createdByUserName": "string",
"tags": {
"region": "us",
"uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c"
},
"dataConnections": [
{
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
}
]
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getconnectionrequest.md b/sync-for-payables/docs/pkg/models/operations/getconnectionrequest.md new file mode 100644 index 000000000..c0568b22e --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getconnectionrequest.md @@ -0,0 +1,9 @@ +# GetConnectionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getconnectionresponse.md b/sync-for-payables/docs/pkg/models/operations/getconnectionresponse.md new file mode 100644 index 000000000..e4fffdafb --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getconnectionresponse.md @@ -0,0 +1,9 @@ +# GetConnectionResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Connection` | [*shared.Connection](../../../pkg/models/shared/connection.md) | :heavy_minus_sign: | OK | {
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsrequest.md b/sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsrequest.md new file mode 100644 index 000000000..d9097225e --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsrequest.md @@ -0,0 +1,11 @@ +# GetMappingOptionsBillsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `ContinuationToken` | **string* | :heavy_minus_sign: | Retrieve the next page of results using the continuation token from the previous response. | continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ== | +| `StatusQuery` | **string* | :heavy_minus_sign: | Codat query string allows you to filter by `status` (`status=Active\|\|status=Archived`). [Learn more](https://docs.codat.io/using-the-api/querying) about Codat's query string. | status=Archived | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsresponse.md b/sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsresponse.md new file mode 100644 index 000000000..78a539d40 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getmappingoptionsbillsresponse.md @@ -0,0 +1,9 @@ +# GetMappingOptionsBillsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `BillMappingOptions` | [*shared.BillMappingOptions](../../../pkg/models/shared/billmappingoptions.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsrequest.md b/sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsrequest.md new file mode 100644 index 000000000..b8f7c1879 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsrequest.md @@ -0,0 +1,11 @@ +# GetMappingOptionsPaymentsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `ContinuationToken` | **string* | :heavy_minus_sign: | Retrieve the next page of results using the continuation token from the previous response. | continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ== | +| `StatusQuery` | **string* | :heavy_minus_sign: | Codat query string allows you to filter by `status` (`status=Active\|\|status=Archived`). [Learn more](https://docs.codat.io/using-the-api/querying) about Codat's query string. | status=Archived | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsresponse.md b/sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsresponse.md new file mode 100644 index 000000000..94ff4a4a7 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/getmappingoptionspaymentsresponse.md @@ -0,0 +1,9 @@ +# GetMappingOptionsPaymentsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `PaymentMappingOptions` | [*shared.PaymentMappingOptions](../../../pkg/models/shared/paymentmappingoptions.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listbillattachmentsrequest.md b/sync-for-payables/docs/pkg/models/operations/listbillattachmentsrequest.md new file mode 100644 index 000000000..364a2297d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listbillattachmentsrequest.md @@ -0,0 +1,10 @@ +# ListBillAttachmentsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `BillID` | *string* | :heavy_check_mark: | Unique identifier for a bill. | 13d946f0-c5d5-42bc-b092-97ece17923ab | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listbillattachmentsresponse.md b/sync-for-payables/docs/pkg/models/operations/listbillattachmentsresponse.md new file mode 100644 index 000000000..1de844919 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listbillattachmentsresponse.md @@ -0,0 +1,9 @@ +# ListBillAttachmentsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Attachment` | [*shared.Attachment](../../../pkg/models/shared/attachment.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listbillsrequest.md b/sync-for-payables/docs/pkg/models/operations/listbillsrequest.md new file mode 100644 index 000000000..9b1b5f716 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listbillsrequest.md @@ -0,0 +1,11 @@ +# ListBillsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `ContinuationToken` | **string* | :heavy_minus_sign: | Retrieve the next page of results using the continuation token from the previous response. | continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ== | +| `Query` | **string* | :heavy_minus_sign: | Codat query string allows you to filter by `status` and `sourceModifiedDate`. Learn more about Codat's query string [here](https://docs.codat.io/using-the-api/querying). Platfrom specfic statuses: Xero supports Open \| PartiallyPaid \| Paid \| Void \| Draft. Qbo supports Open \| PartiallyPaid \| Paid. FreeAgent supports Open \| PartiallyPaid \| Paid. | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listbillsresponse.md b/sync-for-payables/docs/pkg/models/operations/listbillsresponse.md new file mode 100644 index 000000000..80e6fe9c2 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listbillsresponse.md @@ -0,0 +1,9 @@ +# ListBillsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Bills` | [*shared.Bills](../../../pkg/models/shared/bills.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listcompaniesrequest.md b/sync-for-payables/docs/pkg/models/operations/listcompaniesrequest.md new file mode 100644 index 000000000..3bd96be90 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listcompaniesrequest.md @@ -0,0 +1,11 @@ +# ListCompaniesRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `Page` | **int* | :heavy_minus_sign: | Page number. [Read more](https://docs.codat.io/using-the-api/paging). | 1 | +| `PageSize` | **int* | :heavy_minus_sign: | Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). | 100 | +| `Query` | **string* | :heavy_minus_sign: | Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). | id=e3334455-1aed-4e71-ab43-6bccf12092ee | +| `OrderBy` | **string* | :heavy_minus_sign: | Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). | -modifiedDate | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listcompaniesresponse.md b/sync-for-payables/docs/pkg/models/operations/listcompaniesresponse.md new file mode 100644 index 000000000..f5441c7f4 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listcompaniesresponse.md @@ -0,0 +1,9 @@ +# ListCompaniesResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Companies` | [*shared.Companies](../../../pkg/models/shared/companies.md) | :heavy_minus_sign: | OK | {
"pageNumber": 1,
"pageSize": 10,
"totalResults": 1,
"_links": {
"self": {
"href": "/companies/{id}/data/{dataType}"
},
"current": {
"href": "/companies/{id}/data/{dataType}?page=1\u0026pageSize=10"
}
}
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listconnectionsrequest.md b/sync-for-payables/docs/pkg/models/operations/listconnectionsrequest.md new file mode 100644 index 000000000..3dd24e676 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listconnectionsrequest.md @@ -0,0 +1,12 @@ +# ListConnectionsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `Page` | **int* | :heavy_minus_sign: | Page number. [Read more](https://docs.codat.io/using-the-api/paging). | 1 | +| `PageSize` | **int* | :heavy_minus_sign: | Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). | 100 | +| `Query` | **string* | :heavy_minus_sign: | Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). | id=e3334455-1aed-4e71-ab43-6bccf12092ee | +| `OrderBy` | **string* | :heavy_minus_sign: | Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). | -modifiedDate | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listconnectionsresponse.md b/sync-for-payables/docs/pkg/models/operations/listconnectionsresponse.md new file mode 100644 index 000000000..82526299d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listconnectionsresponse.md @@ -0,0 +1,9 @@ +# ListConnectionsResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Connections` | [*shared.Connections](../../../pkg/models/shared/connections.md) | :heavy_minus_sign: | OK | {
"pageNumber": 1,
"pageSize": 10,
"totalResults": 1,
"_links": {
"self": {
"href": "/companies/{id}/data/{dataType}"
},
"current": {
"href": "/companies/{id}/data/{dataType}?page=1\u0026pageSize=10"
}
}
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listsuppliersrequest.md b/sync-for-payables/docs/pkg/models/operations/listsuppliersrequest.md new file mode 100644 index 000000000..af660738b --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listsuppliersrequest.md @@ -0,0 +1,11 @@ +# ListSuppliersRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `ContinuationToken` | **string* | :heavy_minus_sign: | Retrieve the next page of results using the continuation token from the previous response. | continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ== | +| `Query` | **string* | :heavy_minus_sign: | Codat query string allows you to filter by `sourceModifiedDate` or if a supplier is `Active` or `Archived` in the accounting software. Learn more about Codat's query string [here](https://docs.codat.io/using-the-api/querying). | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/listsuppliersresponse.md b/sync-for-payables/docs/pkg/models/operations/listsuppliersresponse.md new file mode 100644 index 000000000..e5b52d4ad --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/listsuppliersresponse.md @@ -0,0 +1,9 @@ +# ListSuppliersResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Suppliers` | [*shared.Suppliers](../../../pkg/models/shared/suppliers.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/option.md b/sync-for-payables/docs/pkg/models/operations/option.md new file mode 100644 index 000000000..35d8a1e2a --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/option.md @@ -0,0 +1,37 @@ +## Options + +### WithServerURL + +WithServerURL allows providing an alternative server URL. + +```go +operations.WithServerURL("http://api.example.com") +``` + +## WithTemplatedServerURL + +WithTemplatedServerURL allows providing an alternative server URL with templated parameters. + +```go +operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ + "host": "api.example.com", + "port": "8080", +}) +``` + +### WithRetries + +WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries. + +```go +operations.WithRetries(retry.Config{ + Strategy: "backoff", + Backoff: retry.BackoffStrategy{ + InitialInterval: 500 * time.Millisecond, + MaxInterval: 60 * time.Second, + Exponent: 1.5, + MaxElapsedTime: 5 * time.Minute, + }, + RetryConnectionErrors: true, +}) +``` \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/unlinkconnectionrequest.md b/sync-for-payables/docs/pkg/models/operations/unlinkconnectionrequest.md new file mode 100644 index 000000000..5925d43ac --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/unlinkconnectionrequest.md @@ -0,0 +1,10 @@ +# UnlinkConnectionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `RequestBody` | [*operations.UnlinkConnectionUpdateConnection](../../../pkg/models/operations/unlinkconnectionupdateconnection.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/unlinkconnectionresponse.md b/sync-for-payables/docs/pkg/models/operations/unlinkconnectionresponse.md new file mode 100644 index 000000000..125ef77ca --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/unlinkconnectionresponse.md @@ -0,0 +1,9 @@ +# UnlinkConnectionResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Connection` | [*shared.Connection](../../../pkg/models/shared/connection.md) | :heavy_minus_sign: | OK | {
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/unlinkconnectionupdateconnection.md b/sync-for-payables/docs/pkg/models/operations/unlinkconnectionupdateconnection.md new file mode 100644 index 000000000..462db866a --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/unlinkconnectionupdateconnection.md @@ -0,0 +1,8 @@ +# UnlinkConnectionUpdateConnection + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `Status` | [*shared.DataConnectionStatus](../../../pkg/models/shared/dataconnectionstatus.md) | :heavy_minus_sign: | The current authorization status of the data connection. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/updatecompanyrequest.md b/sync-for-payables/docs/pkg/models/operations/updatecompanyrequest.md new file mode 100644 index 000000000..33eaeb060 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/updatecompanyrequest.md @@ -0,0 +1,9 @@ +# UpdateCompanyRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `CompanyRequestBody` | [*shared.CompanyRequestBody](../../../pkg/models/shared/companyrequestbody.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/updatecompanyresponse.md b/sync-for-payables/docs/pkg/models/operations/updatecompanyresponse.md new file mode 100644 index 000000000..91399e6d7 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/updatecompanyresponse.md @@ -0,0 +1,9 @@ +# UpdateCompanyResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | | +| `Company` | [*shared.Company](../../../pkg/models/shared/company.md) | :heavy_minus_sign: | OK | {
"id": "0498e921-9b53-4396-a412-4f2f5983b0a2",
"name": "string",
"redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739",
"lastSync": "2022-01-01T12:00:00.000Z",
"created": "2022-01-01T12:00:00.000Z",
"createdByUserName": "string",
"tags": {
"region": "us",
"uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c"
},
"dataConnections": [
{
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
}
]
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/uploadbillattachmentrequest.md b/sync-for-payables/docs/pkg/models/operations/uploadbillattachmentrequest.md new file mode 100644 index 000000000..d4cccb54b --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/uploadbillattachmentrequest.md @@ -0,0 +1,11 @@ +# UploadBillAttachmentRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ConnectionID` | *string* | :heavy_check_mark: | Unique identifier for a connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `BillID` | *string* | :heavy_check_mark: | Unique identifier for a bill. | 13d946f0-c5d5-42bc-b092-97ece17923ab | +| `AttachmentUpload` | [*shared.AttachmentUpload](../../../pkg/models/shared/attachmentupload.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/operations/uploadbillattachmentresponse.md b/sync-for-payables/docs/pkg/models/operations/uploadbillattachmentresponse.md new file mode 100644 index 000000000..81578be53 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/operations/uploadbillattachmentresponse.md @@ -0,0 +1,8 @@ +# UploadBillAttachmentResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/sdkerrors/errormessage.md b/sync-for-payables/docs/pkg/models/sdkerrors/errormessage.md new file mode 100644 index 000000000..e4f989ffe --- /dev/null +++ b/sync-for-payables/docs/pkg/models/sdkerrors/errormessage.md @@ -0,0 +1,16 @@ +# ErrorMessage + +The request made is not valid. + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `StatusCode` | **int64* | :heavy_minus_sign: | The HTTP status code returned by the error. | +| `Service` | **string* | :heavy_minus_sign: | Codat's service the returned the error. | +| `Error` | **string* | :heavy_minus_sign: | A brief description of the error. | +| `CorrelationID` | **string* | :heavy_minus_sign: | Unique identifier used to propagate to all downstream services and determine the source of the error. | +| `Validation` | [*shared.ErrorValidation](../../../pkg/models/shared/errorvalidation.md) | :heavy_minus_sign: | A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. | +| `CanBeRetried` | **string* | :heavy_minus_sign: | `True` if the error occurred transiently and can be retried. | +| `DetailedErrorCode` | **int64* | :heavy_minus_sign: | Machine readable error code used to automate processes based on the code returned. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/accountmappingoption.md b/sync-for-payables/docs/pkg/models/shared/accountmappingoption.md new file mode 100644 index 000000000..bd67a0014 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/accountmappingoption.md @@ -0,0 +1,14 @@ +# AccountMappingOption + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the account, unique for the company. | 1b6266d1-1e44-46c5-8eb5-a8f98e03124e | +| `NominalCode` | **string* | :heavy_minus_sign: | Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. | 610 | +| `Name` | **string* | :heavy_minus_sign: | Name of the account. | Accounts Payable | +| `Type` | **string* | :heavy_minus_sign: | Type of account. | Liability | +| `Currency` | **string* | :heavy_minus_sign: | The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_.

## Unknown currencies

In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction.

There are only a very small number of edge cases where this currency code is returned by the Codat system. | GBP | +| `Status` | [*shared.AccountStatus](../../../pkg/models/shared/accountstatus.md) | :heavy_minus_sign: | The current status of the account. | Active | +| `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/accountstatus.md b/sync-for-payables/docs/pkg/models/shared/accountstatus.md new file mode 100644 index 000000000..5e0eee392 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/accountstatus.md @@ -0,0 +1,11 @@ +# AccountStatus + +The current status of the account. + + +## Values + +| Name | Value | +| ----------------------- | ----------------------- | +| `AccountStatusActive` | Active | +| `AccountStatusArchived` | Archived | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/accounttype.md b/sync-for-payables/docs/pkg/models/shared/accounttype.md new file mode 100644 index 000000000..71a71f19f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/accounttype.md @@ -0,0 +1,14 @@ +# AccountType + +The type of transactions and balances on the account. +For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. +For Debit accounts, positive balances are assets, and positive transactions **increase** assets. + + +## Values + +| Name | Value | +| -------------------- | -------------------- | +| `AccountTypeUnknown` | Unknown | +| `AccountTypeCredit` | Credit | +| `AccountTypeDebit` | Debit | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/address.md b/sync-for-payables/docs/pkg/models/shared/address.md new file mode 100644 index 000000000..916cc07e3 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/address.md @@ -0,0 +1,14 @@ +# Address + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Type` | [*shared.AddressType](../../../pkg/models/shared/addresstype.md) | :heavy_minus_sign: | The type of the address | +| `Line1` | **string* | :heavy_minus_sign: | Line 1 of the customer address. | +| `Line2` | **string* | :heavy_minus_sign: | Line 2 of the customer address. | +| `City` | **string* | :heavy_minus_sign: | City of the customer address. | +| `Region` | **string* | :heavy_minus_sign: | Region of the customer address. | +| `Country` | **string* | :heavy_minus_sign: | Country of the customer's address. For NetSuite, use the 2-digit [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) country code. | +| `PostalCode` | **string* | :heavy_minus_sign: | Postal code or zip code. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/addresstype.md b/sync-for-payables/docs/pkg/models/shared/addresstype.md new file mode 100644 index 000000000..3fa6adee2 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/addresstype.md @@ -0,0 +1,12 @@ +# AddressType + +The type of the address + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `AddressTypeUnknown` | Unknown | +| `AddressTypeBilling` | Billing | +| `AddressTypeDelivery` | Delivery | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/attachment.md b/sync-for-payables/docs/pkg/models/shared/attachment.md new file mode 100644 index 000000000..44cec9866 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/attachment.md @@ -0,0 +1,31 @@ +# Attachment + + The Codat API supports pulling and pushing of file attachments for invoices, bills, direct costs, and direct incomes. + + > **Retrieving attachments** + > + > If a company is authorized, you can query the Codat API to read, download, and upload attachments without requiring a fresh sync of data. + + Unlike other data types, Codat doesn't support [sync settings](https://docs.codat.io/knowledge-base/advanced-sync-settings) for attachments. + + Note that different integrations have different requirements for file size and extension of attachments. + + | Integration | File size | File extension | + |-------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| + | Xero | 4 MB | 7Z, BMP, CSV, DOC, DOCX, EML, GIF, JPEG, JPG, KEYNOTE, MSG, NUMBERS, ODF, ODS, ODT, PAGES, PDF, PNG, PPT, PPTX, RAR, RTF, TIF, TIFF, TXT, XLS, XLSX, ZIP | + | QuickBooks Online | 100 MB | AI, CSV, DOC, DOCX, EPS, GIF, JPEG, JPG, ODS, PAGES, PDF, PNG, RTF, TIF, TXT, XLS, XLSX, XML | + | NetSuite | 100 MB | BMP, CSV, XLS, XLSX, JSON, PDF, PJPG, PJPEG, PNG, TXT, SVG, TIF, TIFF, DOC, DOCX, ZIP | + | Dynamics 365 Business Central | 350 MB | Dynamics do not explicitly outline which file types are supported but they do state here that "You can attach any type of file, such as text, image, or video files". | + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the attachment, unique for the company in the accounting software. | | +| `Name` | **string* | :heavy_minus_sign: | Name of the attachment file. | | +| `ContentType` | **string* | :heavy_minus_sign: | File type of the attachment. This is represented by appending the file type to the [IETF standard file naming requirements](https://tools.ietf.org/html/rfc6838). For example, for a jpeg file the output is **image/jpeg**.

Supported file types vary per platform. | | +| `DateCreated` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `FileSize` | **int* | :heavy_minus_sign: | File size in bytes. For example, if this reads **46153**, then the file size is 46kb. | | +| `IncludeWhenSent` | **bool* | :heavy_minus_sign: | If `true`, then the attachment is included with the associated invoice, bill or direct costs when it is printed, emailed, or sent to a customer, if the underlying accounting software allows this. | | +| `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/attachmentupload.md b/sync-for-payables/docs/pkg/models/shared/attachmentupload.md new file mode 100644 index 000000000..9492c60da --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/attachmentupload.md @@ -0,0 +1,8 @@ +# AttachmentUpload + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | +| `File` | [shared.CodatFile](../../../pkg/models/shared/codatfile.md) | :heavy_check_mark: | The file to be uploaded as an attachment. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bankaccount.md b/sync-for-payables/docs/pkg/models/shared/bankaccount.md new file mode 100644 index 000000000..f387dbb54 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bankaccount.md @@ -0,0 +1,16 @@ +# BankAccount + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the bank account, unique for the company in the accounting software. | | +| `NominalCode` | **string* | :heavy_minus_sign: | Code used to identify each nominal account for a business. | | +| `Name` | **string* | :heavy_minus_sign: | Name of the bank account in the accounting software. | | +| `AccountType` | [*shared.BankAccountType](../../../pkg/models/shared/bankaccounttype.md) | :heavy_minus_sign: | The type of transactions and balances on the account.
For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities.
For Debit accounts, positive balances are assets, and positive transactions **increase** assets. | | +| `AccountNumber` | **string* | :heavy_minus_sign: | Account number for the bank account.

Xero integrations
Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. | | +| `SortCode` | **string* | :heavy_minus_sign: | Sort code for the bank account. This is relevant to UK bank accounts.

Xero integrations
The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. | | +| `Currency` | **string* | :heavy_minus_sign: | The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_.

## Unknown currencies

In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction.

There are only a very small number of edge cases where this currency code is returned by the Codat system. | GBP | +| `Status` | [*shared.BankAccountStatus](../../../pkg/models/shared/bankaccountstatus.md) | :heavy_minus_sign: | The current status of the bank account. | Active | +| `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bankaccountmappingoption.md b/sync-for-payables/docs/pkg/models/shared/bankaccountmappingoption.md new file mode 100644 index 000000000..9e730deb3 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bankaccountmappingoption.md @@ -0,0 +1,16 @@ +# BankAccountMappingOption + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the account, unique for the company in the accounting software. | 3d5a8e00-d108-4045-8823-7f342676cffa | +| `Name` | **string* | :heavy_minus_sign: | Name of the bank account in the accounting software. | Bank of Dave current account | +| `AccountNumber` | **string* | :heavy_minus_sign: | Account number for the bank account.

Xero integrations
Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. | | +| `NominalCode` | **string* | :heavy_minus_sign: | Code used to identify each nominal account for a business. | | +| `SortCode` | **string* | :heavy_minus_sign: | Sort code for the bank account.

Xero integrations
The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. | | +| `Currency` | **string* | :heavy_minus_sign: | The bank account's base currency. | | +| `Status` | [*shared.BankAccountStatus](../../../pkg/models/shared/bankaccountstatus.md) | :heavy_minus_sign: | The current status of the bank account. | Active | +| `AccountType` | [*shared.AccountType](../../../pkg/models/shared/accounttype.md) | :heavy_minus_sign: | The type of transactions and balances on the account.
For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities.
For Debit accounts, positive balances are assets, and positive transactions **increase** assets. | | +| `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bankaccountprototype.md b/sync-for-payables/docs/pkg/models/shared/bankaccountprototype.md new file mode 100644 index 000000000..a12e7f6c7 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bankaccountprototype.md @@ -0,0 +1,13 @@ +# BankAccountPrototype + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `NominalCode` | **string* | :heavy_minus_sign: | Code used to identify each nominal account for a business. | | +| `Name` | *string* | :heavy_check_mark: | Name of the bank account in the accounting software. | | +| `AccountType` | [shared.AccountType](../../../pkg/models/shared/accounttype.md) | :heavy_check_mark: | The type of transactions and balances on the account.
For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities.
For Debit accounts, positive balances are assets, and positive transactions **increase** assets. | | +| `AccountNumber` | *string* | :heavy_check_mark: | Account number for the bank account.

Xero integrations
Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. | | +| `SortCode` | **string* | :heavy_minus_sign: | Sort code for the bank account. This is relevant to UK bank accounts.

Xero integrations
The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. | | +| `Currency` | *string* | :heavy_check_mark: | The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_.

## Unknown currencies

In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction.

There are only a very small number of edge cases where this currency code is returned by the Codat system. | GBP | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bankaccountstatus.md b/sync-for-payables/docs/pkg/models/shared/bankaccountstatus.md new file mode 100644 index 000000000..152816df4 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bankaccountstatus.md @@ -0,0 +1,11 @@ +# BankAccountStatus + +The current status of the bank account. + + +## Values + +| Name | Value | +| --------------------------- | --------------------------- | +| `BankAccountStatusActive` | Active | +| `BankAccountStatusArchived` | Archived | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bankaccounttype.md b/sync-for-payables/docs/pkg/models/shared/bankaccounttype.md new file mode 100644 index 000000000..5a1ed85a0 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bankaccounttype.md @@ -0,0 +1,14 @@ +# BankAccountType + +The type of transactions and balances on the account. +For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. +For Debit accounts, positive balances are assets, and positive transactions **increase** assets. + + +## Values + +| Name | Value | +| ------------------------ | ------------------------ | +| `BankAccountTypeUnknown` | Unknown | +| `BankAccountTypeCredit` | Credit | +| `BankAccountTypeDebit` | Debit | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bill.md b/sync-for-payables/docs/pkg/models/shared/bill.md new file mode 100644 index 000000000..f272b9449 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bill.md @@ -0,0 +1,21 @@ +# Bill + +Bills are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the bill, unique for the company in the accounting software. | | +| `Reference` | **string* | :heavy_minus_sign: | User-friendly reference for the bill. | | +| `SupplierRef` | [shared.SupplierRef](../../../pkg/models/shared/supplierref.md) | :heavy_check_mark: | Reference to the supplier the record relates to. | | +| `IssueDate` | *string* | :heavy_check_mark: | N/A | 2022-10-23 00:00:00 +0000 UTC | +| `DueDate` | *string* | :heavy_check_mark: | N/A | 2022-10-23 00:00:00 +0000 UTC | +| `Currency` | *string* | :heavy_check_mark: | The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_.

## Unknown currencies

In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction.

There are only a very small number of edge cases where this currency code is returned by the Codat system. | GBP | +| `CurrencyRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Rate to convert the total amount of the payment into the base currency for the company at the time of the payment.

Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit.

It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR.

Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places).

For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places.

## Examples with base currency of GBP

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (GBP) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **USD** \| $20 \| 0.781 \| £15.62 \|
\| **EUR** \| €20 \| 0.885 \| £17.70 \|
\| **RUB** \| ₽20 \| 0.011 \| £0.22 \|

## Examples with base currency of USD

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (USD) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **GBP** \| £20 \| 1.277 \| $25.54 \|
\| **EUR** \| €20 \| 1.134 \| $22.68 \|
\| **RUB** \| ₽20 \| 0.015 \| $0.30 \|


### Integration-specific details

\| Integration \| Scenario \| System behavior \|
\|-------------------\|-------------------------------------------------\|----------------------------------------------------------------------------------------------------------------------------------------------------------------------\|
\| QuickBooks Online \| Transaction currency differs from base currency \| If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. \| | | +| `LineItems` | [][shared.BillLineItem](../../../pkg/models/shared/billlineitem.md) | :heavy_minus_sign: | Array of Bill line items. | | +| `Status` | [shared.BillStatus](../../../pkg/models/shared/billstatus.md) | :heavy_check_mark: | Current state of the bill. If creating a bill the status must be `Open`. | Open | +| `TotalAmount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount of the bill, including tax. | | +| `AmountDue` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount outstanding on the bill. | | +| `SourceModifiedDate` | [*shared.One](../../../pkg/models/shared/one.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billaccountref.md b/sync-for-payables/docs/pkg/models/shared/billaccountref.md new file mode 100644 index 000000000..caa375929 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billaccountref.md @@ -0,0 +1,10 @@ +# BillAccountRef + +Reference to the account to which the line item is linked. + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | 'id' from the Accounts data type. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billlineitem.md b/sync-for-payables/docs/pkg/models/shared/billlineitem.md new file mode 100644 index 000000000..51380451f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billlineitem.md @@ -0,0 +1,14 @@ +# BillLineItem + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | +| `Description` | **string* | :heavy_minus_sign: | Friendly name of the goods or services received. | +| `UnitAmount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_check_mark: | Unit price of the goods or service. | +| `Quantity` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_check_mark: | Number of units of goods or services received. | +| `TaxAmount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount of tax applied to the line item. | +| `AccountRef` | [shared.BillAccountRef](../../../pkg/models/shared/billaccountref.md) | :heavy_check_mark: | Reference to the account to which the line item is linked. | +| `TotalAmount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Total amount of the line, including tax. | +| `TaxRateRef` | [shared.BillTaxRateRef](../../../pkg/models/shared/billtaxrateref.md) | :heavy_check_mark: | Reference to the tax rate to which the line item is linked. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billmappingoptions.md b/sync-for-payables/docs/pkg/models/shared/billmappingoptions.md new file mode 100644 index 000000000..f615a20e7 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billmappingoptions.md @@ -0,0 +1,12 @@ +# BillMappingOptions + +The bill mapping options for a company's accounting software. + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `Accounts` | [][shared.AccountMappingOption](../../../pkg/models/shared/accountmappingoption.md) | :heavy_minus_sign: | N/A | +| `TaxRate` | [][shared.TaxRateMappingOption](../../../pkg/models/shared/taxratemappingoption.md) | :heavy_minus_sign: | N/A | +| `Pagination` | [*shared.Pagination](../../../pkg/models/shared/pagination.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billpayment.md b/sync-for-payables/docs/pkg/models/shared/billpayment.md new file mode 100644 index 000000000..1feca5732 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billpayment.md @@ -0,0 +1,13 @@ +# BillPayment + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the bill payment, unique for the company in the accounting software. | | +| `Amount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount of the payment in the bill currency. | 1329.54 | +| `Date` | **string* | :heavy_minus_sign: | N/A | 2022-10-23 00:00:00 +0000 UTC | +| `Reference` | **string* | :heavy_minus_sign: | Additional information associated with the payment. | Bill Payment against bill c13e37b6-dfaa-4894-b3be-9fe97bda9f44 | +| `AccountRef` | [*shared.BillPaymentAccountRef](../../../pkg/models/shared/billpaymentaccountref.md) | :heavy_minus_sign: | Reference to the bank account / credit card which you are using to pay the bill. | | +| `CurrencyRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Rate to convert the total amount of the payment into the base currency for the company at the time of the payment.

Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit.

It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR.

Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places).

For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places.

## Examples with base currency of GBP

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (GBP) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **USD** \| $20 \| 0.781 \| £15.62 \|
\| **EUR** \| €20 \| 0.885 \| £17.70 \|
\| **RUB** \| ₽20 \| 0.011 \| £0.22 \|

## Examples with base currency of USD

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (USD) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **GBP** \| £20 \| 1.277 \| $25.54 \|
\| **EUR** \| €20 \| 1.134 \| $22.68 \|
\| **RUB** \| ₽20 \| 0.015 \| $0.30 \|


### Integration-specific details

\| Integration \| Scenario \| System behavior \|
\|-------------------\|-------------------------------------------------\|----------------------------------------------------------------------------------------------------------------------------------------------------------------------\|
\| QuickBooks Online \| Transaction currency differs from base currency \| If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. \| | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billpaymentaccountref.md b/sync-for-payables/docs/pkg/models/shared/billpaymentaccountref.md new file mode 100644 index 000000000..07ac3cd8e --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billpaymentaccountref.md @@ -0,0 +1,10 @@ +# BillPaymentAccountRef + +Reference to the bank account / credit card which you are using to pay the bill. + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | Unique ID of the bank account / credit card | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billpaymentprototype.md b/sync-for-payables/docs/pkg/models/shared/billpaymentprototype.md new file mode 100644 index 000000000..0111ecddb --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billpaymentprototype.md @@ -0,0 +1,12 @@ +# BillPaymentPrototype + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Amount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_check_mark: | Amount of the payment in the bill currency. | 1329.54 | +| `Date` | *string* | :heavy_check_mark: | N/A | 2022-10-23 00:00:00 +0000 UTC | +| `Reference` | **string* | :heavy_minus_sign: | Additional information associated with the payment. | Bill Payment against bill c13e37b6-dfaa-4894-b3be-9fe97bda9f44 | +| `AccountRef` | [shared.BillPaymentAccountRef](../../../pkg/models/shared/billpaymentaccountref.md) | :heavy_check_mark: | Reference to the bank account / credit card which you are using to pay the bill. | | +| `CurrencyRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Rate to convert the total amount of the payment into the base currency for the company at the time of the payment.

Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit.

It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR.

Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places).

For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places.

## Examples with base currency of GBP

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (GBP) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **USD** \| $20 \| 0.781 \| £15.62 \|
\| **EUR** \| €20 \| 0.885 \| £17.70 \|
\| **RUB** \| ₽20 \| 0.011 \| £0.22 \|

## Examples with base currency of USD

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (USD) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **GBP** \| £20 \| 1.277 \| $25.54 \|
\| **EUR** \| €20 \| 1.134 \| $22.68 \|
\| **RUB** \| ₽20 \| 0.015 \| $0.30 \|


### Integration-specific details

\| Integration \| Scenario \| System behavior \|
\|-------------------\|-------------------------------------------------\|----------------------------------------------------------------------------------------------------------------------------------------------------------------------\|
\| QuickBooks Online \| Transaction currency differs from base currency \| If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. \| | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billprototype.md b/sync-for-payables/docs/pkg/models/shared/billprototype.md new file mode 100644 index 000000000..97d4f7caa --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billprototype.md @@ -0,0 +1,17 @@ +# BillPrototype + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Reference` | **string* | :heavy_minus_sign: | User-friendly reference for the bill. | | +| `SupplierRef` | [shared.SupplierRef](../../../pkg/models/shared/supplierref.md) | :heavy_check_mark: | Reference to the supplier the record relates to. | | +| `IssueDate` | *string* | :heavy_check_mark: | N/A | 2022-10-23 00:00:00 +0000 UTC | +| `DueDate` | *string* | :heavy_check_mark: | N/A | 2022-10-23 00:00:00 +0000 UTC | +| `Currency` | *string* | :heavy_check_mark: | The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_.

## Unknown currencies

In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction.

There are only a very small number of edge cases where this currency code is returned by the Codat system. | GBP | +| `CurrencyRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Rate to convert the total amount of the payment into the base currency for the company at the time of the payment.

Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit.

It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR.

Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places).

For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places.

## Examples with base currency of GBP

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (GBP) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **USD** \| $20 \| 0.781 \| £15.62 \|
\| **EUR** \| €20 \| 0.885 \| £17.70 \|
\| **RUB** \| ₽20 \| 0.011 \| £0.22 \|

## Examples with base currency of USD

\| Foreign Currency \| Foreign Amount \| Currency Rate \| Base Currency Amount (USD) \|
\| :--------------- \| :------------- \| :------------ \| :------------------------- \|
\| **GBP** \| £20 \| 1.277 \| $25.54 \|
\| **EUR** \| €20 \| 1.134 \| $22.68 \|
\| **RUB** \| ₽20 \| 0.015 \| $0.30 \|


### Integration-specific details

\| Integration \| Scenario \| System behavior \|
\|-------------------\|-------------------------------------------------\|----------------------------------------------------------------------------------------------------------------------------------------------------------------------\|
\| QuickBooks Online \| Transaction currency differs from base currency \| If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. \| | | +| `LineItems` | [][shared.BillLineItem](../../../pkg/models/shared/billlineitem.md) | :heavy_minus_sign: | Array of Bill line items. | | +| `Status` | [shared.BillStatus](../../../pkg/models/shared/billstatus.md) | :heavy_check_mark: | Current state of the bill. If creating a bill the status must be `Open`. | Open | +| `TotalAmount` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount of the bill, including tax. | | +| `AmountDue` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount outstanding on the bill. | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/bills.md b/sync-for-payables/docs/pkg/models/shared/bills.md new file mode 100644 index 000000000..214b0e529 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/bills.md @@ -0,0 +1,9 @@ +# Bills + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Results` | [][shared.Bill](../../../pkg/models/shared/bill.md) | :heavy_minus_sign: | N/A | +| `Pagination` | [*shared.Pagination](../../../pkg/models/shared/pagination.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billstatus.md b/sync-for-payables/docs/pkg/models/shared/billstatus.md new file mode 100644 index 000000000..f0a5ac01d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billstatus.md @@ -0,0 +1,15 @@ +# BillStatus + +Current state of the bill. If creating a bill the status must be `Open`. + + +## Values + +| Name | Value | +| ------------------------- | ------------------------- | +| `BillStatusUnknown` | Unknown | +| `BillStatusOpen` | Open | +| `BillStatusPartiallyPaid` | PartiallyPaid | +| `BillStatusPaid` | Paid | +| `BillStatusVoid` | Void | +| `BillStatusDraft` | Draft | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/billtaxrateref.md b/sync-for-payables/docs/pkg/models/shared/billtaxrateref.md new file mode 100644 index 000000000..4d13c286d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/billtaxrateref.md @@ -0,0 +1,10 @@ +# BillTaxRateRef + +Reference to the tax rate to which the line item is linked. + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Unique identifier for the tax rate in the accounting software. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhook.md b/sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhook.md new file mode 100644 index 000000000..c8abdf5f0 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhook.md @@ -0,0 +1,16 @@ +# ClientRateLimitReachedWebhook + +Webhook request body for a client that has reached their rate limit. + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ClientID` | **string* | :heavy_minus_sign: | Unique identifier for your client in Codat. | +| `ClientName` | **string* | :heavy_minus_sign: | Name of your client in Codat. | +| ~~`RuleID`~~ | **string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Unique identifier for the rule. | +| `RuleType` | **string* | :heavy_minus_sign: | The type of rule. | +| `AlertID` | **string* | :heavy_minus_sign: | Unique identifier of the webhook event. | +| `Message` | **string* | :heavy_minus_sign: | A human-readable message about the webhook. | +| `Data` | [*shared.ClientRateLimitReachedWebhookData](../../../pkg/models/shared/clientratelimitreachedwebhookdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhookdata.md b/sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhookdata.md new file mode 100644 index 000000000..0dd2b01bf --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/clientratelimitreachedwebhookdata.md @@ -0,0 +1,9 @@ +# ClientRateLimitReachedWebhookData + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `DailyQuota` | **int64* | :heavy_minus_sign: | The number of available requests per day. | | +| `ExpiresUtc` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhook.md b/sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhook.md new file mode 100644 index 000000000..660206c3c --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhook.md @@ -0,0 +1,16 @@ +# ClientRateLimitResetWebhook + +Webhook request body for a client that has had their rate limit reset. + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ClientID` | **string* | :heavy_minus_sign: | Unique identifier for your client in Codat. | +| `ClientName` | **string* | :heavy_minus_sign: | Name of your client in Codat. | +| ~~`RuleID`~~ | **string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Unique identifier for the rule. | +| `RuleType` | **string* | :heavy_minus_sign: | The type of rule. | +| `AlertID` | **string* | :heavy_minus_sign: | Unique identifier of the webhook event. | +| `Message` | **string* | :heavy_minus_sign: | A human-readable message about the webhook. | +| `Data` | [*shared.ClientRateLimitResetWebhookData](../../../pkg/models/shared/clientratelimitresetwebhookdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhookdata.md b/sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhookdata.md new file mode 100644 index 000000000..f31bd5495 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/clientratelimitresetwebhookdata.md @@ -0,0 +1,11 @@ +# ClientRateLimitResetWebhookData + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `QuotaRemaining` | **int64* | :heavy_minus_sign: | Total number of requests remaining for your client. | | +| `ResetReason` | **string* | :heavy_minus_sign: | The reason for your rate limit quota being reset. | | +| `DailyQuota` | **int64* | :heavy_minus_sign: | The number of available requests per day. | | +| `ExpiresUtc` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/clientratelimitwebhook.md b/sync-for-payables/docs/pkg/models/shared/clientratelimitwebhook.md new file mode 100644 index 000000000..050c50069 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/clientratelimitwebhook.md @@ -0,0 +1,11 @@ +# ClientRateLimitWebhook + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Unique identifier of the event. | 743ec94a-8aa4-44bb-8bd4-e1855ee0e74b | +| `EventType` | **string* | :heavy_minus_sign: | The type of event. | client.rateLimit.reset | +| `GeneratedDate` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `Payload` | [*shared.ClientRateLimitWebhookPayload](../../../pkg/models/shared/clientratelimitwebhookpayload.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/clientratelimitwebhookpayload.md b/sync-for-payables/docs/pkg/models/shared/clientratelimitwebhookpayload.md new file mode 100644 index 000000000..d7cbaf1bb --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/clientratelimitwebhookpayload.md @@ -0,0 +1,10 @@ +# ClientRateLimitWebhookPayload + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `DailyQuota` | **int64* | :heavy_minus_sign: | The number of available requests per day. | | +| `QuotaRemaining` | **int64* | :heavy_minus_sign: | Total number of requests remaining for your client. | | +| `ExpiryDate` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/codatfile.md b/sync-for-payables/docs/pkg/models/shared/codatfile.md new file mode 100644 index 000000000..b1a8f5dfd --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/codatfile.md @@ -0,0 +1,9 @@ +# CodatFile + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `FileName` | *string* | :heavy_check_mark: | N/A | +| `Content` | *any* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/companies.md b/sync-for-payables/docs/pkg/models/shared/companies.md new file mode 100644 index 000000000..0b3588ba6 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/companies.md @@ -0,0 +1,12 @@ +# Companies + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `Results` | [][shared.Company](../../../pkg/models/shared/company.md) | :heavy_minus_sign: | N/A | | +| `PageNumber` | *int64* | :heavy_check_mark: | Current page number. | | +| `PageSize` | *int64* | :heavy_check_mark: | Number of items to return in results array. | | +| `TotalResults` | *int64* | :heavy_check_mark: | Total number of items. | | +| `Links` | [shared.Links](../../../pkg/models/shared/links.md) | :heavy_check_mark: | N/A | {
"self": {
"href": "/companies"
},
"current": {
"href": "/companies?page=1\u0026pageSize=10"
}
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/company.md b/sync-for-payables/docs/pkg/models/shared/company.md new file mode 100644 index 000000000..8caeb4c2f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/company.md @@ -0,0 +1,22 @@ +# Company + +In Codat, a company represents a business sharing access to their data. Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources such as one connection to [Xero](https://docs.codat.io/integrations/accounting/xero/accounting-xero) for accounting data, two connections to [Plaid](https://docs.codat.io/integrations/banking/plaid/banking-plaid) for two bank accounts and a connection to [Zettle](https://docs.codat.io/integrations/commerce/zettle/commerce-zettle) for POS data. + +Typically each company is one of your customers. + +When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company. + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | Unique identifier for your SMB in Codat. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `Name` | *string* | :heavy_check_mark: | The name of the company | Codat Ltd. | +| `Description` | **string* | :heavy_minus_sign: | Additional information about the company. This can be used to store foreign IDs, references, etc. | Requested early access to the new financing scheme. | +| `Redirect` | *string* | :heavy_check_mark: | The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. | https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739 | +| `LastSync` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `Created` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `CreatedByUserName` | **string* | :heavy_minus_sign: | Name of user that created the company in Codat. | | +| `Tags` | [*shared.Tags](../../../pkg/models/shared/tags.md) | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | +| `DataConnections` | [][shared.Connection](../../../pkg/models/shared/connection.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/companyinformation.md b/sync-for-payables/docs/pkg/models/shared/companyinformation.md new file mode 100644 index 000000000..5e72b70ae --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/companyinformation.md @@ -0,0 +1,11 @@ +# CompanyInformation + +Gets the latest basic info for a company. + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `CompanyName` | **string* | :heavy_minus_sign: | Name of the linked company. | +| `BaseCurrency` | **string* | :heavy_minus_sign: | Currency set in the accounting software of the linked company. Used by the currency rate. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/companyrequestbody.md b/sync-for-payables/docs/pkg/models/shared/companyrequestbody.md new file mode 100644 index 000000000..a8c134f49 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/companyrequestbody.md @@ -0,0 +1,10 @@ +# CompanyRequestBody + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Name of company being connected. | Bank of Dave | +| `Description` | **string* | :heavy_minus_sign: | Additional information about the company. This can be used to store foreign IDs, references, etc. | Requested early access to the new financing scheme. | +| `Groups` | [][shared.GroupReference](../../../pkg/models/shared/groupreference.md) | :heavy_minus_sign: | Reference to the groups that the company is assigned to. | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/connection.md b/sync-for-payables/docs/pkg/models/shared/connection.md new file mode 100644 index 000000000..3836edd6d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/connection.md @@ -0,0 +1,31 @@ +# Connection + +A connection represents a [company's](https://docs.codat.io/sync-for-payables-api#/schemas/Company) connection to a data source and allows you to synchronize data (pull and/or push) with that source. + +A company can have multiple data connections depending on the type of data source it is connecting to. For example, a single company can link to: + +- [Accounting data](https://docs.codat.io/accounting-api/overview) - 1 active connection. +- [Banking data](https://docs.codat.io/banking-api/overview) - Multiple active connections. +- [Commerce data](https://docs.codat.io/commerce-api/overview) - Multiple active connections. +Any combination of accounting, banking, and commerce data connections is allowed. + +Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | Unique identifier for a company's data connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `IntegrationID` | *string* | :heavy_check_mark: | A Codat ID representing the integration. | fd321cb6-7963-4506-b873-e99593a45e30 | +| `IntegrationKey` | *string* | :heavy_check_mark: | A unique four-character ID that identifies the platform of the company's data connection. This ensures continuity if the platform changes its name in the future. | | +| `SourceID` | *string* | :heavy_check_mark: | A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. | 35b92968-9851-4095-ad60-395c95cbcba4 | +| `SourceType` | [shared.SourceType](../../../pkg/models/shared/sourcetype.md) | :heavy_check_mark: | The type of platform of the connection. | Accounting | +| `PlatformName` | *string* | :heavy_check_mark: | Name of integration connected to company. | | +| `LinkURL` | *string* | :heavy_check_mark: | The link URL your customers can use to authorize access to their business application. | https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/2e2eb431-c1fa-4dc9-93fa-d29781c12bcd/start | +| `Status` | [shared.DataConnectionStatus](../../../pkg/models/shared/dataconnectionstatus.md) | :heavy_check_mark: | The current authorization status of the data connection. | | +| `LastSync` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `Created` | *string* | :heavy_check_mark: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `DataConnectionErrors` | [][shared.DataConnectionError](../../../pkg/models/shared/dataconnectionerror.md) | :heavy_minus_sign: | N/A | | +| `ConnectionInfo` | map[string]*string* | :heavy_minus_sign: | N/A | | +| `AdditionalProperties` | *any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/connections.md b/sync-for-payables/docs/pkg/models/shared/connections.md new file mode 100644 index 000000000..24b5c568c --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/connections.md @@ -0,0 +1,12 @@ +# Connections + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `Results` | [][shared.Connection](../../../pkg/models/shared/connection.md) | :heavy_minus_sign: | N/A | | +| `PageNumber` | *int64* | :heavy_check_mark: | Current page number. | | +| `PageSize` | *int64* | :heavy_check_mark: | Number of items to return in results array. | | +| `TotalResults` | *int64* | :heavy_check_mark: | Total number of items. | | +| `Links` | [shared.Links](../../../pkg/models/shared/links.md) | :heavy_check_mark: | N/A | {
"self": {
"href": "/companies"
},
"current": {
"href": "/companies?page=1\u0026pageSize=10"
}
} | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/dataconnectionerror.md b/sync-for-payables/docs/pkg/models/shared/dataconnectionerror.md new file mode 100644 index 000000000..675f96cf1 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/dataconnectionerror.md @@ -0,0 +1,13 @@ +# DataConnectionError + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `StatusCode` | **string* | :heavy_minus_sign: | The HTTP status code returned by the source platform when the error occurred. | | +| `StatusText` | **string* | :heavy_minus_sign: | A non-numeric status code/text returned by the source platform when the error occurred. | | +| `ErrorMessage` | **string* | :heavy_minus_sign: | A message about a error returned by Codat. | | +| `ErroredOnUtc` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `Status` | [*shared.ErrorStatus](../../../pkg/models/shared/errorstatus.md) | :heavy_minus_sign: | The current status of a transient error. Null statuses indicate that the error is not transient. | | +| `ResolvedOnUtc` | **string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/dataconnectionstatus.md b/sync-for-payables/docs/pkg/models/shared/dataconnectionstatus.md new file mode 100644 index 000000000..07a06ebe4 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/dataconnectionstatus.md @@ -0,0 +1,13 @@ +# DataConnectionStatus + +The current authorization status of the data connection. + + +## Values + +| Name | Value | +| ---------------------------------- | ---------------------------------- | +| `DataConnectionStatusPendingAuth` | PendingAuth | +| `DataConnectionStatusLinked` | Linked | +| `DataConnectionStatusUnlinked` | Unlinked | +| `DataConnectionStatusDeauthorized` | Deauthorized | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/errorstatus.md b/sync-for-payables/docs/pkg/models/shared/errorstatus.md new file mode 100644 index 000000000..0164bbe93 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/errorstatus.md @@ -0,0 +1,11 @@ +# ErrorStatus + +The current status of a transient error. Null statuses indicate that the error is not transient. + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `ErrorStatusActive` | Active | +| `ErrorStatusResolved` | Resolved | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/errorvalidation.md b/sync-for-payables/docs/pkg/models/shared/errorvalidation.md new file mode 100644 index 000000000..9d2fa4558 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/errorvalidation.md @@ -0,0 +1,11 @@ +# ErrorValidation + +A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `Errors` | [][shared.ErrorValidationItem](../../../pkg/models/shared/errorvalidationitem.md) | :heavy_minus_sign: | N/A | +| `Warnings` | [][shared.ErrorValidationItem](../../../pkg/models/shared/errorvalidationitem.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/errorvalidationitem.md b/sync-for-payables/docs/pkg/models/shared/errorvalidationitem.md new file mode 100644 index 000000000..3d68d9302 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/errorvalidationitem.md @@ -0,0 +1,10 @@ +# ErrorValidationItem + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `ItemID` | **string* | :heavy_minus_sign: | Unique identifier for a validation item. | +| `Message` | **string* | :heavy_minus_sign: | A message outlining validation item's issue. | +| `ValidatorName` | **string* | :heavy_minus_sign: | Name of validator. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/groupreference.md b/sync-for-payables/docs/pkg/models/shared/groupreference.md new file mode 100644 index 000000000..6bf386bd0 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/groupreference.md @@ -0,0 +1,8 @@ +# GroupReference + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `ID` | **string* | :heavy_minus_sign: | Unique identifier for the group. | 60d2fa12-8a04-11ee-b9d1-0242ac120002 | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/halref.md b/sync-for-payables/docs/pkg/models/shared/halref.md new file mode 100644 index 000000000..0d0bfe8ef --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/halref.md @@ -0,0 +1,8 @@ +# HalRef + + +## Fields + +| Field | Type | Required | Description | +| ------------------------ | ------------------------ | ------------------------ | ------------------------ | +| `Href` | **string* | :heavy_minus_sign: | Uri hypertext reference. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/httpmetadata.md b/sync-for-payables/docs/pkg/models/shared/httpmetadata.md new file mode 100644 index 000000000..df1fdd59f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/httpmetadata.md @@ -0,0 +1,9 @@ +# HTTPMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Response` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `Request` | [*http.Request](https://pkg.go.dev/net/http#Request) | :heavy_check_mark: | Raw HTTP request; suitable for debugging | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/links.md b/sync-for-payables/docs/pkg/models/shared/links.md new file mode 100644 index 000000000..3e7666ae9 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/links.md @@ -0,0 +1,11 @@ +# Links + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Self` | [shared.HalRef](../../../pkg/models/shared/halref.md) | :heavy_check_mark: | N/A | +| `Current` | [shared.HalRef](../../../pkg/models/shared/halref.md) | :heavy_check_mark: | N/A | +| `Next` | [*shared.HalRef](../../../pkg/models/shared/halref.md) | :heavy_minus_sign: | N/A | +| `Previous` | [*shared.HalRef](../../../pkg/models/shared/halref.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/one.md b/sync-for-payables/docs/pkg/models/shared/one.md new file mode 100644 index 000000000..b4f54ae29 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/one.md @@ -0,0 +1,8 @@ +# One + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | +| `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23 00:00:00 +0000 UTC | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/pagination.md b/sync-for-payables/docs/pkg/models/shared/pagination.md new file mode 100644 index 000000000..6c8c3ce9f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/pagination.md @@ -0,0 +1,8 @@ +# Pagination + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ContinuationToken` | **string* | :heavy_minus_sign: | A continuation token indicating there are more results to be fetched. Supply this value in the `continuationToken` query parameter in the next request to fetch the next set of results. Once no more results are available, the continuation token will not be present in the response. | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/paymentmappingoptions.md b/sync-for-payables/docs/pkg/models/shared/paymentmappingoptions.md new file mode 100644 index 000000000..0cb0f43c1 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/paymentmappingoptions.md @@ -0,0 +1,11 @@ +# PaymentMappingOptions + +Gets the bill payments mapping options for a company's accounting software + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `BankAccounts` | [][shared.BankAccountMappingOption](../../../pkg/models/shared/bankaccountmappingoption.md) | :heavy_minus_sign: | N/A | +| `Pagination` | [*shared.Pagination](../../../pkg/models/shared/pagination.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/security.md b/sync-for-payables/docs/pkg/models/shared/security.md new file mode 100644 index 000000000..a997c0213 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/security.md @@ -0,0 +1,8 @@ +# Security + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | +| `AuthHeader` | *string* | :heavy_check_mark: | N/A | Basic BASE_64_ENCODED(API_KEY) | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/sourcetype.md b/sync-for-payables/docs/pkg/models/shared/sourcetype.md new file mode 100644 index 000000000..b03dd8136 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/sourcetype.md @@ -0,0 +1,16 @@ +# SourceType + +The type of platform of the connection. + + +## Values + +| Name | Value | +| ---------------------- | ---------------------- | +| `SourceTypeAccounting` | Accounting | +| `SourceTypeBanking` | Banking | +| `SourceTypeBankFeed` | BankFeed | +| `SourceTypeCommerce` | Commerce | +| `SourceTypeExpense` | Expense | +| `SourceTypeOther` | Other | +| `SourceTypeUnknown` | Unknown | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/supplier.md b/sync-for-payables/docs/pkg/models/shared/supplier.md new file mode 100644 index 000000000..492fe25ed --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/supplier.md @@ -0,0 +1,22 @@ +# Supplier + +Suppliers are people or organizations that provide something, such as a product or service. Use the [List suppliers](https://docs.codat.io/sync-for-payables-v2-api#/operations/list-suppliers) endpoint to retrieve a list of all suppliers for a company. + +Suppliers' data links to accounts payable [bills](https://docs.codat.io/sync-for-payables-v2-api#/schemas/Bill). + + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the supplier, unique to the company in the accounting software. | | +| `SupplierName` | **string* | :heavy_minus_sign: | Name of the supplier as recorded in the accounting system, typically the company name. | | +| `ContactName` | **string* | :heavy_minus_sign: | Name of the main contact for the supplier. | | +| `EmailAddress` | **string* | :heavy_minus_sign: | Email address that the supplier may be contacted on. | | +| `Phone` | **string* | :heavy_minus_sign: | Phone number that the supplier may be contacted on. | +44 25691 154789 | +| `Addresses` | [][shared.Address](../../../pkg/models/shared/address.md) | :heavy_minus_sign: | An array of Addresses. | | +| `Status` | [*shared.SupplierStatus](../../../pkg/models/shared/supplierstatus.md) | :heavy_minus_sign: | Status of the supplier. | | +| `Balance` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount outstanding against the supplier. | | +| `DefaultCurrency` | **string* | :heavy_minus_sign: | Default currency the supplier's transactional data is recorded in. | | +| `SourceModifiedDate` | [*shared.One](../../../pkg/models/shared/one.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/supplierprototype.md b/sync-for-payables/docs/pkg/models/shared/supplierprototype.md new file mode 100644 index 000000000..2016c77ab --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/supplierprototype.md @@ -0,0 +1,15 @@ +# SupplierPrototype + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `SupplierName` | *string* | :heavy_check_mark: | Name of the supplier as recorded in the accounting system, typically the company name. | | +| `ContactName` | **string* | :heavy_minus_sign: | Name of the main contact for the supplier. | | +| `EmailAddress` | **string* | :heavy_minus_sign: | Email address that the supplier may be contacted on. | | +| `Phone` | **string* | :heavy_minus_sign: | Phone number that the supplier may be contacted on. | +44 25691 154789 | +| `Addresses` | [][shared.Address](../../../pkg/models/shared/address.md) | :heavy_minus_sign: | An array of Addresses. | | +| `Status` | [shared.SupplierStatus](../../../pkg/models/shared/supplierstatus.md) | :heavy_check_mark: | Status of the supplier. | | +| `Balance` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Amount outstanding against the supplier. | | +| `DefaultCurrency` | **string* | :heavy_minus_sign: | Default currency the supplier's transactional data is recorded in. | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/supplierref.md b/sync-for-payables/docs/pkg/models/shared/supplierref.md new file mode 100644 index 000000000..d6d8c0a1d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/supplierref.md @@ -0,0 +1,11 @@ +# SupplierRef + +Reference to the supplier the record relates to. + + +## Fields + +| Field | Type | Required | Description | +| ------------------------ | ------------------------ | ------------------------ | ------------------------ | +| `ID` | *string* | :heavy_check_mark: | The supplier's unique ID | +| `SupplierName` | **string* | :heavy_minus_sign: | The supplier's name | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/suppliers.md b/sync-for-payables/docs/pkg/models/shared/suppliers.md new file mode 100644 index 000000000..3c8666dfe --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/suppliers.md @@ -0,0 +1,9 @@ +# Suppliers + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Results` | [][shared.Supplier](../../../pkg/models/shared/supplier.md) | :heavy_minus_sign: | N/A | +| `Pagination` | [*shared.Pagination](../../../pkg/models/shared/pagination.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/supplierstatus.md b/sync-for-payables/docs/pkg/models/shared/supplierstatus.md new file mode 100644 index 000000000..3428eca41 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/supplierstatus.md @@ -0,0 +1,12 @@ +# SupplierStatus + +Status of the supplier. + + +## Values + +| Name | Value | +| ------------------------ | ------------------------ | +| `SupplierStatusUnknown` | Unknown | +| `SupplierStatusActive` | Active | +| `SupplierStatusArchived` | Archived | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/tags.md b/sync-for-payables/docs/pkg/models/shared/tags.md new file mode 100644 index 000000000..6de993aa8 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/tags.md @@ -0,0 +1,9 @@ +# Tags + +A collection of user-defined key-value pairs that store custom metadata against the company. + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/taxratemappingoption.md b/sync-for-payables/docs/pkg/models/shared/taxratemappingoption.md new file mode 100644 index 000000000..b5a20df3e --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/taxratemappingoption.md @@ -0,0 +1,13 @@ +# TaxRateMappingOption + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ID` | **string* | :heavy_minus_sign: | Identifier for the tax rate, unique for the company in the accounting software. | d2939064-dd3a-4c0f-9865-a238c2193515 | +| `Name` | **string* | :heavy_minus_sign: | Codat-augmented name of the tax rate in the accounting software. | | +| `Code` | **string* | :heavy_minus_sign: | Code for the tax rate from the accounting software. | | +| `EffectiveTaxRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | See Effective tax rates description. | | +| `TotalTaxRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Total (not compounded) sum of the components of a tax rate. | | +| `Status` | [*shared.TaxRateStatus](../../../pkg/models/shared/taxratestatus.md) | :heavy_minus_sign: | Status of the tax rate in the accounting software.
- `Active` - An active tax rate in use by a company.
- `Archived` - A tax rate that has been archived or is inactive in the accounting software. | | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/shared/taxratestatus.md b/sync-for-payables/docs/pkg/models/shared/taxratestatus.md new file mode 100644 index 000000000..c58b77afe --- /dev/null +++ b/sync-for-payables/docs/pkg/models/shared/taxratestatus.md @@ -0,0 +1,13 @@ +# TaxRateStatus + +Status of the tax rate in the accounting software. +- `Active` - An active tax rate in use by a company. +- `Archived` - A tax rate that has been archived or is inactive in the accounting software. + + +## Values + +| Name | Value | +| ----------------------- | ----------------------- | +| `TaxRateStatusActive` | Active | +| `TaxRateStatusArchived` | Archived | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse.md b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse.md new file mode 100644 index 000000000..4c1f53673 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse.md @@ -0,0 +1,8 @@ +# ClientRateLimitReachedResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse1.md b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse1.md new file mode 100644 index 000000000..ae463402f --- /dev/null +++ b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitreachedresponse1.md @@ -0,0 +1,8 @@ +# ClientRateLimitReachedResponse1 + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse.md b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse.md new file mode 100644 index 000000000..ad03a8b08 --- /dev/null +++ b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse.md @@ -0,0 +1,8 @@ +# ClientRateLimitResetResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse1.md b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse1.md new file mode 100644 index 000000000..a96e8f11d --- /dev/null +++ b/sync-for-payables/docs/pkg/models/webhooks/clientratelimitresetresponse1.md @@ -0,0 +1,8 @@ +# ClientRateLimitResetResponse1 + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `HTTPMeta` | [shared.HTTPMetadata](../../../pkg/models/shared/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/sync-for-payables/docs/sdks/bankaccounts/README.md b/sync-for-payables/docs/sdks/bankaccounts/README.md new file mode 100644 index 000000000..d170cd2af --- /dev/null +++ b/sync-for-payables/docs/sdks/bankaccounts/README.md @@ -0,0 +1,77 @@ +# BankAccounts +(*BankAccounts*) + +## Overview + +Create a bank account for a given company's connection. + +### Available Operations + +* [Create](#create) - Create bank account + +## Create + +The *Create bank account* endpoint creates a new [bank account](https://docs.codat.io/sync-for-payables-api#/schemas/BankAccount) for a given company's connection. + +[Bank accounts](https://docs.codat.io/sync-for-payables-api#/schemas/BankAccount) are financial accounts maintained by a bank or other financial institution. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.BankAccounts.Create(ctx, operations.CreateBankAccountRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + BankAccountPrototype: &shared.BankAccountPrototype{ + NominalCode: syncforpayables.String("22"), + Name: syncforpayables.String("Plutus - Payables - Bank Account 12"), + AccountType: shared.AccountTypeDebit, + AccountNumber: syncforpayables.String("0120 0440"), + SortCode: syncforpayables.String("50-50-50"), + Currency: "GBP", + }, + }) + if err != nil { + log.Fatal(err) + } + if res.BankAccount != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateBankAccountRequest](../../pkg/models/operations/createbankaccountrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateBankAccountResponse](../../pkg/models/operations/createbankaccountresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/docs/sdks/billpayments/README.md b/sync-for-payables/docs/sdks/billpayments/README.md new file mode 100644 index 000000000..95f72d497 --- /dev/null +++ b/sync-for-payables/docs/sdks/billpayments/README.md @@ -0,0 +1,145 @@ +# BillPayments +(*BillPayments*) + +## Overview + +Get, create, and update Bill payments. + +### Available Operations + +* [GetPaymentOptions](#getpaymentoptions) - Get payment mapping options +* [Create](#create) - Create bill payment + +## GetPaymentOptions + +Use the *Get mapping options - Payments* endpoint to return a list of available mapping options for a given company's connection ID. + +By default, this endpoint returns a list of active bank accounts. You can use [querying](https://docs.codat.io/using-the-api/querying) to change that. + +Mapping options are a set of bank accounts used to configure the SMB's payables integration. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.BillPayments.GetPaymentOptions(ctx, operations.GetMappingOptionsPaymentsRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ContinuationToken: syncforpayables.String("continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="), + StatusQuery: syncforpayables.String("status=Archived"), + }) + if err != nil { + log.Fatal(err) + } + if res.PaymentMappingOptions != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetMappingOptionsPaymentsRequest](../../pkg/models/operations/getmappingoptionspaymentsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetMappingOptionsPaymentsResponse](../../pkg/models/operations/getmappingoptionspaymentsresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Create + +The *Create bill payment* endpoint creates a new [bill payment](https://docs.codat.io/sync-for-payables-api#/schemas/BillPayment) for a given company's connection. + +[Bill payments](https://docs.codat.io/sync-for-payables-api#/schemas/BillPayment) are an allocation of money within any Accounts Payable account. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/types" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.BillPayments.Create(ctx, operations.CreateBillPaymentRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + BillID: "7110701885", + BillPaymentPrototype: &shared.BillPaymentPrototype{ + Amount: types.MustNewDecimalFromString("22"), + Date: "2022-10-23T00:00:00.000Z", + Reference: syncforpayables.String("Bill Payment against bill c13e37b6 dfaa-4894-b3be-9fe97bda9f44"), + AccountRef: shared.BillPaymentAccountRef{ + ID: "7bda9f44sr56", + }, + CurrencyRate: types.MustNewDecimalFromString("1"), + }, + }) + if err != nil { + log.Fatal(err) + } + if res.BillPayment != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateBillPaymentRequest](../../pkg/models/operations/createbillpaymentrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateBillPaymentResponse](../../pkg/models/operations/createbillpaymentresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,409,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/docs/sdks/bills/README.md b/sync-for-payables/docs/sdks/bills/README.md new file mode 100644 index 000000000..dbdada974 --- /dev/null +++ b/sync-for-payables/docs/sdks/bills/README.md @@ -0,0 +1,451 @@ +# Bills +(*Bills*) + +## Overview + +Get, create, and update Bills. + +### Available Operations + +* [GetBillOptions](#getbilloptions) - Get bill mapping options +* [List](#list) - List bills +* [Create](#create) - Create bill +* [UploadAttachment](#uploadattachment) - Upload bill attachment +* [ListAttachments](#listattachments) - List bill attachments +* [DownloadAttachment](#downloadattachment) - Download bill attachment + +## GetBillOptions + +Use the *Get mapping options - Bills* endpoint to return a list of available mapping options for a given company's connection ID. + +By default, this endpoint returns a list of active accounts and tax rates. You can use [querying](https://docs.codat.io/using-the-api/querying) to change that. + +Mapping options are a set of accounts and tax rates used to configure the SMB's payables integration. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Bills.GetBillOptions(ctx, operations.GetMappingOptionsBillsRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ContinuationToken: syncforpayables.String("continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="), + StatusQuery: syncforpayables.String("status=Archived"), + }) + if err != nil { + log.Fatal(err) + } + if res.BillMappingOptions != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetMappingOptionsBillsRequest](../../pkg/models/operations/getmappingoptionsbillsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetMappingOptionsBillsResponse](../../pkg/models/operations/getmappingoptionsbillsresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## List + +The *List bills* endpoint returns a list of [bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) for a given company's connection. + +[Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. + +By default, the endpoint will return all bills with a status of 'Open' & 'PartiallyPaid' to show all oustanding bills. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Bills.List(ctx, operations.ListBillsRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ContinuationToken: syncforpayables.String("continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="), + Query: syncforpayables.String("status=Open"), + }) + if err != nil { + log.Fatal(err) + } + if res.Bills != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListBillsRequest](../../pkg/models/operations/listbillsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListBillsResponse](../../pkg/models/operations/listbillsresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,409,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Create + +The *Create bill* endpoint creates a new [bill](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) for a given company's connection. + +[Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/types" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Bills.Create(ctx, operations.CreateBillRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + BillPrototype: &shared.BillPrototype{ + Reference: syncforpayables.String("bill_b8qmmj4ksf1suax"), + SupplierRef: shared.SupplierRef{ + ID: "1262c350-fe0f-40ec-aeff-41c95b4a45af", + SupplierName: syncforpayables.String("DIISR - Small Business Services"), + }, + IssueDate: "2023-04-23T00:00:00", + DueDate: "2023-04-23T00:00:00", + Currency: "GBP", + CurrencyRate: types.MustNewDecimalFromString("1"), + LineItems: []shared.BillLineItem{ + shared.BillLineItem{ + Description: syncforpayables.String("Half day training - Microsoft Office"), + UnitAmount: types.MustNewDecimalFromString("1800"), + Quantity: types.MustNewDecimalFromString("1"), + TaxAmount: types.MustNewDecimalFromString("360"), + AccountRef: shared.BillAccountRef{ + ID: syncforpayables.String("46f9461e-788b-4906-8b74-d1ea17f6dc10"), + }, + TotalAmount: types.MustNewDecimalFromString("2160"), + TaxRateRef: shared.BillTaxRateRef{ + ID: syncforpayables.String("INPUT2"), + }, + }, + shared.BillLineItem{ + Description: syncforpayables.String("Desktop/network support via email & phone.Per month fixed fee for minimum 20 hours/month."), + UnitAmount: types.MustNewDecimalFromString("4000"), + Quantity: types.MustNewDecimalFromString("1"), + TaxAmount: types.MustNewDecimalFromString("800"), + AccountRef: shared.BillAccountRef{ + ID: syncforpayables.String("f96c9458-d724-47bf-8f74-a9d5726465ce"), + }, + TotalAmount: types.MustNewDecimalFromString("4800"), + TaxRateRef: shared.BillTaxRateRef{ + ID: syncforpayables.String("INPUT2"), + }, + }, + shared.BillLineItem{ + Description: syncforpayables.String("Stationery charges"), + UnitAmount: types.MustNewDecimalFromString("32"), + Quantity: types.MustNewDecimalFromString("8"), + TaxAmount: types.MustNewDecimalFromString("51.2"), + AccountRef: shared.BillAccountRef{ + ID: syncforpayables.String("cba6527d-f102-4538-b421-e483233e9d5a"), + }, + TotalAmount: types.MustNewDecimalFromString("307.2"), + TaxRateRef: shared.BillTaxRateRef{ + ID: syncforpayables.String("INPUT2"), + }, + }, + }, + Status: shared.BillStatusOpen, + TotalAmount: types.MustNewDecimalFromString("7267.2"), + AmountDue: types.MustNewDecimalFromString("7267.2"), + }, + }) + if err != nil { + log.Fatal(err) + } + if res.Bill != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateBillRequest](../../pkg/models/operations/createbillrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateBillResponse](../../pkg/models/operations/createbillresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,409,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## UploadAttachment + +The *Upload bill attachment* endpoint uploads an attachment and assigns it against a specific `billId`. + +[Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "os" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + content, fileErr := os.Open("example.file") + if fileErr != nil { + panic(fileErr) + } + + ctx := context.Background() + res, err := s.Bills.UploadAttachment(ctx, operations.UploadBillAttachmentRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + BillID: "EILBDVJVNUAGVKRQ", + }) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UploadBillAttachmentRequest](../../pkg/models/operations/uploadbillattachmentrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UploadBillAttachmentResponse](../../pkg/models/operations/uploadbillattachmentresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## ListAttachments + +The *List bill attachments* endpoint returns a list of attachments available to download for a given `billId`. + +[Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Bills.ListAttachments(ctx, operations.ListBillAttachmentsRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + BillID: "EILBDVJVNUAGVKRQ", + }) + if err != nil { + log.Fatal(err) + } + if res.Attachment != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListBillAttachmentsRequest](../../pkg/models/operations/listbillattachmentsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListBillAttachmentsResponse](../../pkg/models/operations/listbillattachmentsresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,409,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## DownloadAttachment + +The *Download bill attachment* endpoint downloads a specific attachment for a given `billId` and `attachmentId`. + +[Bills](https://docs.codat.io/sync-for-payables-api#/schemas/Bill) are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. + +Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=bills) for integrations that support downloading a bill attachment. + + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Bills.DownloadAttachment(ctx, operations.DownloadBillAttachmentRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + BillID: "EILBDVJVNUAGVKRQ", + AttachmentID: "8a210b68-6988-11ed-a1eb-0242ac120002", + }) + if err != nil { + log.Fatal(err) + } + if res.Data != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DownloadBillAttachmentRequest](../../pkg/models/operations/downloadbillattachmentrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DownloadBillAttachmentResponse](../../pkg/models/operations/downloadbillattachmentresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/docs/sdks/codatsyncpayables/README.md b/sync-for-payables/docs/sdks/codatsyncpayables/README.md new file mode 100644 index 000000000..c26eaa375 --- /dev/null +++ b/sync-for-payables/docs/sdks/codatsyncpayables/README.md @@ -0,0 +1,24 @@ +# CodatSyncPayables SDK + +## Overview + +Bill pay kit: The API reference for the Bill Pay kit. + +The bill pay kit is an API and a set of supporting tools designed to integrate a bill pay flow into your app as quickly as possible. It's ideal for facilitating essential bill payment processes within your SMB's accounting software. + +[Explore product](https://docs.codat.io/payables/bill-pay-kit) | [See OpenAPI spec](https://github.com/codatio/oas) + +--- + +## Endpoints + +| Endpoints | Description | +| :- |:- | +| Companies | Create and manage your SMB users' companies. | +| Connections | Create new and manage existing data connections for a company. | +| Company information | View company profile from the source platform. | +| Bills | Get, create, and update Bills. | +| Bill payments | Get, create, and update Bill payments. | +| Suppliers | Get, create, and update Suppliers. | +| Bank accounts | Create a bank account for a given company's connection. | + \ No newline at end of file diff --git a/sync-for-payables/docs/sdks/companies/README.md b/sync-for-payables/docs/sdks/companies/README.md new file mode 100644 index 000000000..48293c0b7 --- /dev/null +++ b/sync-for-payables/docs/sdks/companies/README.md @@ -0,0 +1,335 @@ +# Companies +(*Companies*) + +## Overview + +Create and manage your SMB users' companies. + +### Available Operations + +* [List](#list) - List companies +* [Create](#create) - Create company +* [Update](#update) - Update company +* [Delete](#delete) - Delete a company +* [Get](#get) - Get company + +## List + +The *List companies* endpoint returns a list of [companies] associated to your instances. + +A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.List(ctx, operations.ListCompaniesRequest{ + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Companies != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListCompaniesRequest](../../pkg/models/operations/listcompaniesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListCompaniesResponse](../../pkg/models/operations/listcompaniesresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Create + +Use the *Create company* endpoint to create a new [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) that represents your customer in Codat. + +A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + +If forbidden characters (see `name` pattern) are present in the request, a company will be created with the forbidden characters removed. For example, `Company (Codat[1])` with be created as `Company Codat1`. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{ + Name: "Technicalium", + Description: syncforpayables.String("Requested early access to the new financing scheme."), + Groups: []shared.GroupReference{ + shared.GroupReference{ + ID: syncforpayables.String("60d2fa12-8a04-11ee-b9d1-0242ac120002"), + }, + }, + }) + if err != nil { + log.Fatal(err) + } + if res.Company != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [shared.CompanyRequestBody](../../pkg/models/shared/companyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateCompanyResponse](../../pkg/models/operations/createcompanyresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Update + +Use the *Update company* endpoint to update both the name and description of the company. +If you use [groups](https://docs.codat.io/sync-for-payables-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/sync-for-payables-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/sync-for-payables-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. + +A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.Update(ctx, operations.UpdateCompanyRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + CompanyRequestBody: &shared.CompanyRequestBody{ + Name: "New Name", + Description: syncforpayables.String("Requested early access to the new financing scheme."), + Groups: []shared.GroupReference{ + shared.GroupReference{ + ID: syncforpayables.String("60d2fa12-8a04-11ee-b9d1-0242ac120002"), + }, + }, + }, + }) + if err != nil { + log.Fatal(err) + } + if res.Company != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpdateCompanyRequest](../../pkg/models/operations/updatecompanyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpdateCompanyResponse](../../pkg/models/operations/updatecompanyresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Delete + +The *Delete company* endpoint permanently deletes a [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company), its [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) and any cached data. This operation is irreversible. + +A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.Delete(ctx, operations.DeleteCompanyRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + }) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteCompanyRequest](../../pkg/models/operations/deletecompanyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteCompanyResponse](../../pkg/models/operations/deletecompanyresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Get + +The *Get company* endpoint returns a single company for a given `companyId`. + +A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data. +Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.Get(ctx, operations.GetCompanyRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + }) + if err != nil { + log.Fatal(err) + } + if res.Company != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetCompanyRequest](../../pkg/models/operations/getcompanyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetCompanyResponse](../../pkg/models/operations/getcompanyresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/docs/sdks/companyinformation/README.md b/sync-for-payables/docs/sdks/companyinformation/README.md new file mode 100644 index 000000000..3e8f39a23 --- /dev/null +++ b/sync-for-payables/docs/sdks/companyinformation/README.md @@ -0,0 +1,69 @@ +# CompanyInformation +(*CompanyInformation*) + +## Overview + +View company profile from the source platform. + +### Available Operations + +* [Get](#get) - Get company information + +## Get + +Use the *Get company information* endpoint to return information about the company available from the underlying accounting software. + + + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.CompanyInformation.Get(ctx, operations.GetCompanyInformationRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }) + if err != nil { + log.Fatal(err) + } + if res.CompanyInformation != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetCompanyInformationRequest](../../pkg/models/operations/getcompanyinformationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetCompanyInformationResponse](../../pkg/models/operations/getcompanyinformationresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/docs/sdks/connections/README.md b/sync-for-payables/docs/sdks/connections/README.md new file mode 100644 index 000000000..af9e3b476 --- /dev/null +++ b/sync-for-payables/docs/sdks/connections/README.md @@ -0,0 +1,314 @@ +# Connections +(*Connections*) + +## Overview + +Create new and manage existing data connections for a company. + +### Available Operations + +* [List](#list) - List connections +* [Create](#create) - Create connection +* [Get](#get) - Get connection +* [Delete](#delete) - Delete connection +* [Unlink](#unlink) - Unlink connection + +## List + +List the connections for a company. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Connections.List(ctx, operations.ListConnectionsRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + Page: syncforpayables.Int(1), + PageSize: syncforpayables.Int(100), + Query: syncforpayables.String("id=e3334455-1aed-4e71-ab43-6bccf12092ee"), + OrderBy: syncforpayables.String("-modifiedDate"), + }) + if err != nil { + log.Fatal(err) + } + if res.Connections != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListConnectionsRequest](../../pkg/models/operations/listconnectionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListConnectionsResponse](../../pkg/models/operations/listconnectionsresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Create + +Creates a connection for the company by providing a valid `platformKey`. + +Use the [List Integrations](https://docs.codat.io/sync-for-payables-api#/operations/list-integrations) endpoint to access valid platform keys. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Connections.Create(ctx, operations.CreateConnectionRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + RequestBody: &operations.CreateConnectionRequestBody{ + PlatformKey: syncforpayables.String("gbol"), + }, + }) + if err != nil { + log.Fatal(err) + } + if res.Connection != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateConnectionRequest](../../pkg/models/operations/createconnectionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateConnectionResponse](../../pkg/models/operations/createconnectionresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Get + +Returns a specific connection for a company when valid identifiers are provided. If the identifiers are for a deleted company and/or connection, a not found response is returned. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Connections.Get(ctx, operations.GetConnectionRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }) + if err != nil { + log.Fatal(err) + } + if res.Connection != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetConnectionRequest](../../pkg/models/operations/getconnectionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetConnectionResponse](../../pkg/models/operations/getconnectionresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Delete + +Revoke and remove a connection from a company. +This operation is not reversible. The end user would need to reauthorize a new data connection if you wish to view new data for this company. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Connections.Delete(ctx, operations.DeleteConnectionRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteConnectionRequest](../../pkg/models/operations/deleteconnectionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteConnectionResponse](../../pkg/models/operations/deleteconnectionresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Unlink + +This allows you to deauthorize a connection, without deleting it from Codat. This means you can still view any data that has previously been pulled into Codat, and also lets you re-authorize in future if your customer wishes to resume sharing their data. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Connections.Unlink(ctx, operations.UnlinkConnectionRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + RequestBody: &operations.UnlinkConnectionUpdateConnection{ + Status: shared.DataConnectionStatusUnlinked.ToPointer(), + }, + }) + if err != nil { + log.Fatal(err) + } + if res.Connection != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UnlinkConnectionRequest](../../pkg/models/operations/unlinkconnectionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UnlinkConnectionResponse](../../pkg/models/operations/unlinkconnectionresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/docs/sdks/suppliers/README.md b/sync-for-payables/docs/sdks/suppliers/README.md new file mode 100644 index 000000000..675e6ad6b --- /dev/null +++ b/sync-for-payables/docs/sdks/suppliers/README.md @@ -0,0 +1,156 @@ +# Suppliers +(*Suppliers*) + +## Overview + +Get, create, and update Suppliers. + +### Available Operations + +* [List](#list) - List suppliers +* [Create](#create) - Create supplier + +## List + +The *List suppliers* endpoint returns a list of [suppliers](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) for a given company's connection. + +[Suppliers](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service. + +By default, this endpoint returns a list of active and archived suppliers. You can use [querying](https://docs.codat.io/using-the-api/querying) to change that. + +For example, to retrieve only active suppliers (i.e. `status=Active`) or suppliers created within the specified number of days (e.g. `sourceModifiedDate>2023-12-15T00:00:00.000Z`), query the endpoint as follows: `/payables/suppliers?query=sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Active`.For example, to retrieve active suppliers modified after a particular date use `query=sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Active`. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Suppliers.List(ctx, operations.ListSuppliersRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ContinuationToken: syncforpayables.String("continuationToken=eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MTAwLCJwYWdlQ291bnQiOjExfQ=="), + Query: syncforpayables.String("sourceModifiedDate>2023-12-15T00:00:00.000Z"), + }) + if err != nil { + log.Fatal(err) + } + if res.Suppliers != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListSuppliersRequest](../../pkg/models/operations/listsuppliersrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListSuppliersResponse](../../pkg/models/operations/listsuppliersresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,409,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + + +## Create + +The *Create supplier* endpoint creates a new [supplier](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) for a given company's connection. + +[Suppliers](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service. + + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables" + "context" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "log" +) + +func main() { + s := syncforpayables.New( + syncforpayables.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Suppliers.Create(ctx, operations.CreateSupplierRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + SupplierPrototype: &shared.SupplierPrototype{ + SupplierName: "Greggs", + ContactName: syncforpayables.String("Greg Greggs"), + EmailAddress: syncforpayables.String("greg@greggs.com"), + Phone: syncforpayables.String("+44 (0)1223 322410"), + Addresses: []shared.Address{ + shared.Address{ + Type: shared.AddressTypeBilling.ToPointer(), + Line1: syncforpayables.String("Flat 1"), + Line2: syncforpayables.String("2 Dennis Avenue"), + City: syncforpayables.String("London"), + Region: syncforpayables.String("Camden"), + Country: syncforpayables.String("GBR"), + PostalCode: syncforpayables.String("EC1N 7TE"), + }, + }, + Status: shared.SupplierStatusActive, + DefaultCurrency: syncforpayables.String("GBP"), + }, + }) + if err != nil { + log.Fatal(err) + } + if res.Supplier != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateSupplierRequest](../../pkg/models/operations/createsupplierrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateSupplierResponse](../../pkg/models/operations/createsupplierresponse.md), error** + +### Errors + +| Error Object | Status Code | Content Type | +| ------------------------------- | ------------------------------- | ------------------------------- | +| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/sync-for-payables/go.mod b/sync-for-payables/go.mod new file mode 100644 index 000000000..96045f116 --- /dev/null +++ b/sync-for-payables/go.mod @@ -0,0 +1,8 @@ +module github.com/codatio/client-sdk-go/sync-for-payables + +go 1.20 + +require ( + github.com/cenkalti/backoff/v4 v4.2.0 + github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 +) diff --git a/sync-for-payables/go.sum b/sync-for-payables/go.sum new file mode 100644 index 000000000..f95577939 --- /dev/null +++ b/sync-for-payables/go.sum @@ -0,0 +1,4 @@ +github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= +github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= diff --git a/sync-for-payables/internal/hooks/hooks.go b/sync-for-payables/internal/hooks/hooks.go new file mode 100644 index 000000000..8ea491aeb --- /dev/null +++ b/sync-for-payables/internal/hooks/hooks.go @@ -0,0 +1,144 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package hooks + +import ( + "context" + "errors" + "net/http" +) + +type FailEarly struct { + Cause error +} + +var _ error = (*FailEarly)(nil) + +func (f *FailEarly) Error() string { + return f.Cause.Error() +} + +// HTTPClient provides an interface for supplying the SDK with a custom HTTP client +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +type HookContext struct { + Context context.Context + OperationID string + OAuth2Scopes []string + SecuritySource func(context.Context) (interface{}, error) +} + +type BeforeRequestContext struct { + HookContext +} + +type AfterSuccessContext struct { + HookContext +} + +type AfterErrorContext struct { + HookContext +} + +// sdkInitHook is called when the SDK is initializing. The hook can modify and return a new baseURL and HTTP client to be used by the SDK. +type sdkInitHook interface { + SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) +} + +// beforeRequestHook is called before the SDK sends a request. The hook can modify the request before it is sent or return an error to stop the request from being sent. +type beforeRequestHook interface { + BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) +} + +// afterSuccessHook is called after the SDK receives a response. The hook can modify the response before it is handled or return an error to stop the response from being handled. +type afterSuccessHook interface { + AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) +} + +// afterErrorHook is called after the SDK encounters an error, or a non-successful response. The hook can modify the response if available otherwise modify the error. +// All afterErrorHook hooks are called and returning an error won't stop the other hooks from being called. But if you want to stop the other hooks from being called, you can return a FailEarly error wrapping your error. +type afterErrorHook interface { + AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) +} + +type Hooks struct { + sdkInitHooks []sdkInitHook + beforeRequestHook []beforeRequestHook + afterSuccessHook []afterSuccessHook + afterErrorHook []afterErrorHook +} + +func New() *Hooks { + h := &Hooks{ + sdkInitHooks: []sdkInitHook{}, + beforeRequestHook: []beforeRequestHook{}, + afterSuccessHook: []afterSuccessHook{}, + afterErrorHook: []afterErrorHook{}, + } + + initHooks(h) + + return h +} + +// registerSDKInitHook registers a hook to be used by the SDK for the initialization event. +func (h *Hooks) registerSDKInitHook(hook sdkInitHook) { + h.sdkInitHooks = append(h.sdkInitHooks, hook) +} + +// registerBeforeRequestHook registers a hook to be used by the SDK for the before request event. +func (h *Hooks) registerBeforeRequestHook(hook beforeRequestHook) { + h.beforeRequestHook = append(h.beforeRequestHook, hook) +} + +// registerAfterSuccessHook registers a hook to be used by the SDK for the after success event. +func (h *Hooks) registerAfterSuccessHook(hook afterSuccessHook) { + h.afterSuccessHook = append(h.afterSuccessHook, hook) +} + +// registerAfterErrorHook registers a hook to be used by the SDK for the after error event. +func (h *Hooks) registerAfterErrorHook(hook afterErrorHook) { + h.afterErrorHook = append(h.afterErrorHook, hook) +} + +func (h *Hooks) SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) { + for _, hook := range h.sdkInitHooks { + baseURL, client = hook.SDKInit(baseURL, client) + } + return baseURL, client +} + +func (h *Hooks) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) { + for _, hook := range h.beforeRequestHook { + var err error + req, err = hook.BeforeRequest(hookCtx, req) + if err != nil { + return req, err + } + } + return req, nil +} + +func (h *Hooks) AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) { + for _, hook := range h.afterSuccessHook { + var err error + res, err = hook.AfterSuccess(hookCtx, res) + if err != nil { + return res, err + } + } + return res, nil +} + +func (h *Hooks) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) { + for _, hook := range h.afterErrorHook { + res, err = hook.AfterError(hookCtx, res, err) + var fe *FailEarly + if errors.As(err, &fe) { + return nil, fe.Cause + } + } + return res, err +} diff --git a/sync-for-payables/internal/hooks/registration.go b/sync-for-payables/internal/hooks/registration.go new file mode 100644 index 000000000..fa131be81 --- /dev/null +++ b/sync-for-payables/internal/hooks/registration.go @@ -0,0 +1,18 @@ +package hooks + +/* + * This file is only ever generated once on the first generation and then is free to be modified. + * Any hooks you wish to add should be registered in the initHooks function. Feel free to define + * your hooks in this file or in separate files in the hooks package. + * + * Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance. + */ + +func initHooks(h *Hooks) { + // exampleHook := &ExampleHook{} + + // h.registerSDKInitHook(exampleHook) + // h.registerBeforeRequestHook(exampleHook) + // h.registerAfterErrorHook(exampleHook) + // h.registerAfterSuccessHook(exampleHook) +} diff --git a/sync-for-payables/pkg/models/operations/createbankaccount.go b/sync-for-payables/pkg/models/operations/createbankaccount.go new file mode 100644 index 000000000..a77bbfcbf --- /dev/null +++ b/sync-for-payables/pkg/models/operations/createbankaccount.go @@ -0,0 +1,65 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type CreateBankAccountRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // A unique identifier to ensure idempotent behaviour for subsequent requests. + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + BankAccountPrototype *shared.BankAccountPrototype `request:"mediaType=application/json"` +} + +func (o *CreateBankAccountRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *CreateBankAccountRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *CreateBankAccountRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *CreateBankAccountRequest) GetBankAccountPrototype() *shared.BankAccountPrototype { + if o == nil { + return nil + } + return o.BankAccountPrototype +} + +type CreateBankAccountResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + BankAccount *shared.BankAccount +} + +func (o *CreateBankAccountResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateBankAccountResponse) GetBankAccount() *shared.BankAccount { + if o == nil { + return nil + } + return o.BankAccount +} diff --git a/sync-for-payables/pkg/models/operations/createbill.go b/sync-for-payables/pkg/models/operations/createbill.go new file mode 100644 index 000000000..95d7b756f --- /dev/null +++ b/sync-for-payables/pkg/models/operations/createbill.go @@ -0,0 +1,65 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type CreateBillRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // A unique identifier to ensure idempotent behaviour for subsequent requests. + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + BillPrototype *shared.BillPrototype `request:"mediaType=application/json"` +} + +func (o *CreateBillRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *CreateBillRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *CreateBillRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *CreateBillRequest) GetBillPrototype() *shared.BillPrototype { + if o == nil { + return nil + } + return o.BillPrototype +} + +type CreateBillResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + Bill *shared.Bill +} + +func (o *CreateBillResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateBillResponse) GetBill() *shared.Bill { + if o == nil { + return nil + } + return o.Bill +} diff --git a/sync-for-payables/pkg/models/operations/createbillpayment.go b/sync-for-payables/pkg/models/operations/createbillpayment.go new file mode 100644 index 000000000..c78157136 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/createbillpayment.go @@ -0,0 +1,74 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type CreateBillPaymentRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Unique identifier for a bill. + BillID string `pathParam:"style=simple,explode=false,name=billId"` + // A unique identifier to ensure idempotent behaviour for subsequent requests. + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + BillPaymentPrototype *shared.BillPaymentPrototype `request:"mediaType=application/json"` +} + +func (o *CreateBillPaymentRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *CreateBillPaymentRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *CreateBillPaymentRequest) GetBillID() string { + if o == nil { + return "" + } + return o.BillID +} + +func (o *CreateBillPaymentRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *CreateBillPaymentRequest) GetBillPaymentPrototype() *shared.BillPaymentPrototype { + if o == nil { + return nil + } + return o.BillPaymentPrototype +} + +type CreateBillPaymentResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + BillPayment *shared.BillPayment +} + +func (o *CreateBillPaymentResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateBillPaymentResponse) GetBillPayment() *shared.BillPayment { + if o == nil { + return nil + } + return o.BillPayment +} diff --git a/sync-for-payables/pkg/models/operations/createcompany.go b/sync-for-payables/pkg/models/operations/createcompany.go new file mode 100644 index 000000000..d898870ed --- /dev/null +++ b/sync-for-payables/pkg/models/operations/createcompany.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type CreateCompanyResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Company *shared.Company +} + +func (o *CreateCompanyResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateCompanyResponse) GetCompany() *shared.Company { + if o == nil { + return nil + } + return o.Company +} diff --git a/sync-for-payables/pkg/models/operations/createconnection.go b/sync-for-payables/pkg/models/operations/createconnection.go new file mode 100644 index 000000000..ea9e53368 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/createconnection.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type CreateConnectionRequestBody struct { + // A unique 4-letter key to represent a platform in each integration. View [accounting](https://docs.codat.io/integrations/accounting/overview#platform-keys), [banking](https://docs.codat.io/integrations/banking/overview#platform-keys), and [commerce](https://docs.codat.io/integrations/commerce/overview#platform-keys) platform keys. + PlatformKey *string `json:"platformKey,omitempty"` +} + +func (o *CreateConnectionRequestBody) GetPlatformKey() *string { + if o == nil { + return nil + } + return o.PlatformKey +} + +type CreateConnectionRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + RequestBody *CreateConnectionRequestBody `request:"mediaType=application/json"` +} + +func (o *CreateConnectionRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *CreateConnectionRequest) GetRequestBody() *CreateConnectionRequestBody { + if o == nil { + return nil + } + return o.RequestBody +} + +type CreateConnectionResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Connection *shared.Connection +} + +func (o *CreateConnectionResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateConnectionResponse) GetConnection() *shared.Connection { + if o == nil { + return nil + } + return o.Connection +} diff --git a/sync-for-payables/pkg/models/operations/createsupplier.go b/sync-for-payables/pkg/models/operations/createsupplier.go new file mode 100644 index 000000000..2d4d313da --- /dev/null +++ b/sync-for-payables/pkg/models/operations/createsupplier.go @@ -0,0 +1,65 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type CreateSupplierRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // A unique identifier to ensure idempotent behaviour for subsequent requests. + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + SupplierPrototype *shared.SupplierPrototype `request:"mediaType=application/json"` +} + +func (o *CreateSupplierRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *CreateSupplierRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *CreateSupplierRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *CreateSupplierRequest) GetSupplierPrototype() *shared.SupplierPrototype { + if o == nil { + return nil + } + return o.SupplierPrototype +} + +type CreateSupplierResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + Supplier *shared.Supplier +} + +func (o *CreateSupplierResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateSupplierResponse) GetSupplier() *shared.Supplier { + if o == nil { + return nil + } + return o.Supplier +} diff --git a/sync-for-payables/pkg/models/operations/deletecompany.go b/sync-for-payables/pkg/models/operations/deletecompany.go new file mode 100644 index 000000000..fab99a38f --- /dev/null +++ b/sync-for-payables/pkg/models/operations/deletecompany.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type DeleteCompanyRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` +} + +func (o *DeleteCompanyRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +type DeleteCompanyResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` +} + +func (o *DeleteCompanyResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/sync-for-payables/pkg/models/operations/deleteconnection.go b/sync-for-payables/pkg/models/operations/deleteconnection.go new file mode 100644 index 000000000..2d616d989 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/deleteconnection.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type DeleteConnectionRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` +} + +func (o *DeleteConnectionRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *DeleteConnectionRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +type DeleteConnectionResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` +} + +func (o *DeleteConnectionResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/sync-for-payables/pkg/models/operations/downloadbillattachment.go b/sync-for-payables/pkg/models/operations/downloadbillattachment.go new file mode 100644 index 000000000..7a742a723 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/downloadbillattachment.go @@ -0,0 +1,68 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "io" +) + +type DownloadBillAttachmentRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Unique identifier for a bill. + BillID string `pathParam:"style=simple,explode=false,name=billId"` + // Unique identifier for an attachment. + AttachmentID string `pathParam:"style=simple,explode=false,name=attachmentId"` +} + +func (o *DownloadBillAttachmentRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *DownloadBillAttachmentRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *DownloadBillAttachmentRequest) GetBillID() string { + if o == nil { + return "" + } + return o.BillID +} + +func (o *DownloadBillAttachmentRequest) GetAttachmentID() string { + if o == nil { + return "" + } + return o.AttachmentID +} + +type DownloadBillAttachmentResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + // The Close method must be called on this field, even if it is not used, to prevent resource leaks. + Data io.ReadCloser +} + +func (o *DownloadBillAttachmentResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *DownloadBillAttachmentResponse) GetData() io.ReadCloser { + if o == nil { + return nil + } + return o.Data +} diff --git a/sync-for-payables/pkg/models/operations/getcompany.go b/sync-for-payables/pkg/models/operations/getcompany.go new file mode 100644 index 000000000..71eba6caf --- /dev/null +++ b/sync-for-payables/pkg/models/operations/getcompany.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type GetCompanyRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` +} + +func (o *GetCompanyRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +type GetCompanyResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Company *shared.Company +} + +func (o *GetCompanyResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetCompanyResponse) GetCompany() *shared.Company { + if o == nil { + return nil + } + return o.Company +} diff --git a/sync-for-payables/pkg/models/operations/getcompanyinformation.go b/sync-for-payables/pkg/models/operations/getcompanyinformation.go new file mode 100644 index 000000000..e5643e323 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/getcompanyinformation.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type GetCompanyInformationRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` +} + +func (o *GetCompanyInformationRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *GetCompanyInformationRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +type GetCompanyInformationResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + CompanyInformation *shared.CompanyInformation +} + +func (o *GetCompanyInformationResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetCompanyInformationResponse) GetCompanyInformation() *shared.CompanyInformation { + if o == nil { + return nil + } + return o.CompanyInformation +} diff --git a/sync-for-payables/pkg/models/operations/getconnection.go b/sync-for-payables/pkg/models/operations/getconnection.go new file mode 100644 index 000000000..4c49551d0 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/getconnection.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type GetConnectionRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` +} + +func (o *GetConnectionRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *GetConnectionRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +type GetConnectionResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Connection *shared.Connection +} + +func (o *GetConnectionResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetConnectionResponse) GetConnection() *shared.Connection { + if o == nil { + return nil + } + return o.Connection +} diff --git a/sync-for-payables/pkg/models/operations/getmappingoptionsbills.go b/sync-for-payables/pkg/models/operations/getmappingoptionsbills.go new file mode 100644 index 000000000..de69e2939 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/getmappingoptionsbills.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type GetMappingOptionsBillsRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Retrieve the next page of results using the continuation token from the previous response. + ContinuationToken *string `queryParam:"style=form,explode=true,name=continuationToken"` + // Codat query string allows you to filter by `status` (`status=Active||status=Archived`). [Learn more](https://docs.codat.io/using-the-api/querying) about Codat's query string. + StatusQuery *string `queryParam:"style=form,explode=true,name=statusQuery"` +} + +func (o *GetMappingOptionsBillsRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *GetMappingOptionsBillsRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *GetMappingOptionsBillsRequest) GetContinuationToken() *string { + if o == nil { + return nil + } + return o.ContinuationToken +} + +func (o *GetMappingOptionsBillsRequest) GetStatusQuery() *string { + if o == nil { + return nil + } + return o.StatusQuery +} + +type GetMappingOptionsBillsResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + BillMappingOptions *shared.BillMappingOptions +} + +func (o *GetMappingOptionsBillsResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetMappingOptionsBillsResponse) GetBillMappingOptions() *shared.BillMappingOptions { + if o == nil { + return nil + } + return o.BillMappingOptions +} diff --git a/sync-for-payables/pkg/models/operations/getmappingoptionspayments.go b/sync-for-payables/pkg/models/operations/getmappingoptionspayments.go new file mode 100644 index 000000000..cacfde7b3 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/getmappingoptionspayments.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type GetMappingOptionsPaymentsRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Retrieve the next page of results using the continuation token from the previous response. + ContinuationToken *string `queryParam:"style=form,explode=true,name=continuationToken"` + // Codat query string allows you to filter by `status` (`status=Active||status=Archived`). [Learn more](https://docs.codat.io/using-the-api/querying) about Codat's query string. + StatusQuery *string `queryParam:"style=form,explode=true,name=statusQuery"` +} + +func (o *GetMappingOptionsPaymentsRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *GetMappingOptionsPaymentsRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *GetMappingOptionsPaymentsRequest) GetContinuationToken() *string { + if o == nil { + return nil + } + return o.ContinuationToken +} + +func (o *GetMappingOptionsPaymentsRequest) GetStatusQuery() *string { + if o == nil { + return nil + } + return o.StatusQuery +} + +type GetMappingOptionsPaymentsResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + PaymentMappingOptions *shared.PaymentMappingOptions +} + +func (o *GetMappingOptionsPaymentsResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetMappingOptionsPaymentsResponse) GetPaymentMappingOptions() *shared.PaymentMappingOptions { + if o == nil { + return nil + } + return o.PaymentMappingOptions +} diff --git a/sync-for-payables/pkg/models/operations/listbillattachments.go b/sync-for-payables/pkg/models/operations/listbillattachments.go new file mode 100644 index 000000000..50b4433a5 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/listbillattachments.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type ListBillAttachmentsRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Unique identifier for a bill. + BillID string `pathParam:"style=simple,explode=false,name=billId"` +} + +func (o *ListBillAttachmentsRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *ListBillAttachmentsRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *ListBillAttachmentsRequest) GetBillID() string { + if o == nil { + return "" + } + return o.BillID +} + +type ListBillAttachmentsResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + Attachment *shared.Attachment +} + +func (o *ListBillAttachmentsResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListBillAttachmentsResponse) GetAttachment() *shared.Attachment { + if o == nil { + return nil + } + return o.Attachment +} diff --git a/sync-for-payables/pkg/models/operations/listbills.go b/sync-for-payables/pkg/models/operations/listbills.go new file mode 100644 index 000000000..64584476d --- /dev/null +++ b/sync-for-payables/pkg/models/operations/listbills.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type ListBillsRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Retrieve the next page of results using the continuation token from the previous response. + ContinuationToken *string `queryParam:"style=form,explode=true,name=continuationToken"` + // Codat query string allows you to filter by `status` and `sourceModifiedDate`. Learn more about Codat's query string [here](https://docs.codat.io/using-the-api/querying). Platfrom specfic statuses: Xero supports Open | PartiallyPaid | Paid | Void | Draft. Qbo supports Open | PartiallyPaid | Paid. FreeAgent supports Open | PartiallyPaid | Paid. + Query *string `queryParam:"style=form,explode=true,name=query"` +} + +func (o *ListBillsRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *ListBillsRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *ListBillsRequest) GetContinuationToken() *string { + if o == nil { + return nil + } + return o.ContinuationToken +} + +func (o *ListBillsRequest) GetQuery() *string { + if o == nil { + return nil + } + return o.Query +} + +type ListBillsResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + Bills *shared.Bills +} + +func (o *ListBillsResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListBillsResponse) GetBills() *shared.Bills { + if o == nil { + return nil + } + return o.Bills +} diff --git a/sync-for-payables/pkg/models/operations/listcompanies.go b/sync-for-payables/pkg/models/operations/listcompanies.go new file mode 100644 index 000000000..257606ff3 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/listcompanies.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" +) + +type ListCompaniesRequest struct { + // Page number. [Read more](https://docs.codat.io/using-the-api/paging). + Page *int `default:"1" queryParam:"style=form,explode=true,name=page"` + // Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + PageSize *int `default:"100" queryParam:"style=form,explode=true,name=pageSize"` + // Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + Query *string `queryParam:"style=form,explode=true,name=query"` + // Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + OrderBy *string `queryParam:"style=form,explode=true,name=orderBy"` +} + +func (l ListCompaniesRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListCompaniesRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *ListCompaniesRequest) GetPage() *int { + if o == nil { + return nil + } + return o.Page +} + +func (o *ListCompaniesRequest) GetPageSize() *int { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *ListCompaniesRequest) GetQuery() *string { + if o == nil { + return nil + } + return o.Query +} + +func (o *ListCompaniesRequest) GetOrderBy() *string { + if o == nil { + return nil + } + return o.OrderBy +} + +type ListCompaniesResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Companies *shared.Companies +} + +func (o *ListCompaniesResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListCompaniesResponse) GetCompanies() *shared.Companies { + if o == nil { + return nil + } + return o.Companies +} diff --git a/sync-for-payables/pkg/models/operations/listconnections.go b/sync-for-payables/pkg/models/operations/listconnections.go new file mode 100644 index 000000000..56f164420 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/listconnections.go @@ -0,0 +1,87 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" +) + +type ListConnectionsRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Page number. [Read more](https://docs.codat.io/using-the-api/paging). + Page *int `default:"1" queryParam:"style=form,explode=true,name=page"` + // Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + PageSize *int `default:"100" queryParam:"style=form,explode=true,name=pageSize"` + // Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + Query *string `queryParam:"style=form,explode=true,name=query"` + // Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + OrderBy *string `queryParam:"style=form,explode=true,name=orderBy"` +} + +func (l ListConnectionsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListConnectionsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *ListConnectionsRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *ListConnectionsRequest) GetPage() *int { + if o == nil { + return nil + } + return o.Page +} + +func (o *ListConnectionsRequest) GetPageSize() *int { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *ListConnectionsRequest) GetQuery() *string { + if o == nil { + return nil + } + return o.Query +} + +func (o *ListConnectionsRequest) GetOrderBy() *string { + if o == nil { + return nil + } + return o.OrderBy +} + +type ListConnectionsResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Connections *shared.Connections +} + +func (o *ListConnectionsResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListConnectionsResponse) GetConnections() *shared.Connections { + if o == nil { + return nil + } + return o.Connections +} diff --git a/sync-for-payables/pkg/models/operations/listsuppliers.go b/sync-for-payables/pkg/models/operations/listsuppliers.go new file mode 100644 index 000000000..b809d0f9b --- /dev/null +++ b/sync-for-payables/pkg/models/operations/listsuppliers.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type ListSuppliersRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Retrieve the next page of results using the continuation token from the previous response. + ContinuationToken *string `queryParam:"style=form,explode=true,name=continuationToken"` + // Codat query string allows you to filter by `sourceModifiedDate` or if a supplier is `Active` or `Archived` in the accounting software. Learn more about Codat's query string [here](https://docs.codat.io/using-the-api/querying). + Query *string `queryParam:"style=form,explode=true,name=query"` +} + +func (o *ListSuppliersRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *ListSuppliersRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *ListSuppliersRequest) GetContinuationToken() *string { + if o == nil { + return nil + } + return o.ContinuationToken +} + +func (o *ListSuppliersRequest) GetQuery() *string { + if o == nil { + return nil + } + return o.Query +} + +type ListSuppliersResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // Success + Suppliers *shared.Suppliers +} + +func (o *ListSuppliersResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListSuppliersResponse) GetSuppliers() *shared.Suppliers { + if o == nil { + return nil + } + return o.Suppliers +} diff --git a/sync-for-payables/pkg/models/operations/options.go b/sync-for-payables/pkg/models/operations/options.go new file mode 100644 index 000000000..75ed675d3 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/options.go @@ -0,0 +1,116 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "errors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "time" +) + +var ErrUnsupportedOption = errors.New("unsupported option") + +const ( + SupportedOptionServerURL = "serverURL" + SupportedOptionRetries = "retries" + SupportedOptionTimeout = "timeout" + SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" + SupportedOptionURLOverride = "urlOverride" +) + +type AcceptHeaderEnum string + +const ( + AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" + AcceptHeaderEnumApplicationOctetStream AcceptHeaderEnum = "application/octet-stream" +) + +func (e AcceptHeaderEnum) ToPointer() *AcceptHeaderEnum { + return &e +} + +type Options struct { + ServerURL *string + Retries *retry.Config + Timeout *time.Duration + AcceptHeaderOverride *AcceptHeaderEnum + URLOverride *string +} + +type Option func(*Options, ...string) error + +// WithServerURL allows providing an alternative server URL. +func WithServerURL(serverURL string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionServerURL) { + return ErrUnsupportedOption + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithTemplatedServerURL allows providing an alternative server URL with templated parameters. +func WithTemplatedServerURL(serverURL string, params map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionServerURL) { + return ErrUnsupportedOption + } + + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithRetries allows customizing the default retry configuration. +func WithRetries(config retry.Config) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Retries = &config + return nil + } +} + +// WithOperationTimeout allows setting the request timeout applied for an operation. +func WithOperationTimeout(timeout time.Duration) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Timeout = &timeout + return nil + } +} + +func WithAcceptHeaderOverride(acceptHeaderOverride AcceptHeaderEnum) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionAcceptHeaderOverride) { + return ErrUnsupportedOption + } + + opts.AcceptHeaderOverride = &acceptHeaderOverride + return nil + } +} + +// WithURLOverride allows overriding the URL. +func WithURLOverride(urlOverride string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionURLOverride) { + return ErrUnsupportedOption + } + + opts.URLOverride = &urlOverride + return nil + } +} diff --git a/sync-for-payables/pkg/models/operations/unlinkconnection.go b/sync-for-payables/pkg/models/operations/unlinkconnection.go new file mode 100644 index 000000000..78a433028 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/unlinkconnection.go @@ -0,0 +1,68 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type UnlinkConnectionUpdateConnection struct { + // The current authorization status of the data connection. + Status *shared.DataConnectionStatus `json:"status,omitempty"` +} + +func (o *UnlinkConnectionUpdateConnection) GetStatus() *shared.DataConnectionStatus { + if o == nil { + return nil + } + return o.Status +} + +type UnlinkConnectionRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + RequestBody *UnlinkConnectionUpdateConnection `request:"mediaType=application/json"` +} + +func (o *UnlinkConnectionRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *UnlinkConnectionRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *UnlinkConnectionRequest) GetRequestBody() *UnlinkConnectionUpdateConnection { + if o == nil { + return nil + } + return o.RequestBody +} + +type UnlinkConnectionResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Connection *shared.Connection +} + +func (o *UnlinkConnectionResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *UnlinkConnectionResponse) GetConnection() *shared.Connection { + if o == nil { + return nil + } + return o.Connection +} diff --git a/sync-for-payables/pkg/models/operations/updatecompany.go b/sync-for-payables/pkg/models/operations/updatecompany.go new file mode 100644 index 000000000..9523e2bc9 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/updatecompany.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type UpdateCompanyRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + CompanyRequestBody *shared.CompanyRequestBody `request:"mediaType=application/json"` +} + +func (o *UpdateCompanyRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *UpdateCompanyRequest) GetCompanyRequestBody() *shared.CompanyRequestBody { + if o == nil { + return nil + } + return o.CompanyRequestBody +} + +type UpdateCompanyResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` + // OK + Company *shared.Company +} + +func (o *UpdateCompanyResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *UpdateCompanyResponse) GetCompany() *shared.Company { + if o == nil { + return nil + } + return o.Company +} diff --git a/sync-for-payables/pkg/models/operations/uploadbillattachment.go b/sync-for-payables/pkg/models/operations/uploadbillattachment.go new file mode 100644 index 000000000..5a273a462 --- /dev/null +++ b/sync-for-payables/pkg/models/operations/uploadbillattachment.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type UploadBillAttachmentRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Unique identifier for a connection. + ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` + // Unique identifier for a bill. + BillID string `pathParam:"style=simple,explode=false,name=billId"` + AttachmentUpload *shared.AttachmentUpload `request:"mediaType=multipart/form-data"` +} + +func (o *UploadBillAttachmentRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *UploadBillAttachmentRequest) GetConnectionID() string { + if o == nil { + return "" + } + return o.ConnectionID +} + +func (o *UploadBillAttachmentRequest) GetBillID() string { + if o == nil { + return "" + } + return o.BillID +} + +func (o *UploadBillAttachmentRequest) GetAttachmentUpload() *shared.AttachmentUpload { + if o == nil { + return nil + } + return o.AttachmentUpload +} + +type UploadBillAttachmentResponse struct { + HTTPMeta shared.HTTPMetadata `json:"-"` +} + +func (o *UploadBillAttachmentResponse) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/sync-for-payables/pkg/models/sdkerrors/errormessage.go b/sync-for-payables/pkg/models/sdkerrors/errormessage.go new file mode 100644 index 000000000..b27992ae0 --- /dev/null +++ b/sync-for-payables/pkg/models/sdkerrors/errormessage.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdkerrors + +import ( + "encoding/json" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +// ErrorMessage - The request made is not valid. +type ErrorMessage struct { + // The HTTP status code returned by the error. + StatusCode *int64 `json:"statusCode,omitempty"` + // Codat's service the returned the error. + Service *string `json:"service,omitempty"` + // A brief description of the error. + Error_ *string `json:"error,omitempty"` + // Unique identifier used to propagate to all downstream services and determine the source of the error. + CorrelationID *string `json:"correlationId,omitempty"` + // A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + Validation *shared.ErrorValidation `json:"validation,omitempty"` + // `True` if the error occurred transiently and can be retried. + CanBeRetried *string `json:"canBeRetried,omitempty"` + // Machine readable error code used to automate processes based on the code returned. + DetailedErrorCode *int64 `json:"detailedErrorCode,omitempty"` +} + +var _ error = &ErrorMessage{} + +func (e *ErrorMessage) Error() string { + data, _ := json.Marshal(e) + return string(data) +} diff --git a/sync-for-payables/pkg/models/sdkerrors/sdkerror.go b/sync-for-payables/pkg/models/sdkerrors/sdkerror.go new file mode 100644 index 000000000..7d63b9813 --- /dev/null +++ b/sync-for-payables/pkg/models/sdkerrors/sdkerror.go @@ -0,0 +1,35 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdkerrors + +import ( + "fmt" + "net/http" +) + +type SDKError struct { + Message string + StatusCode int + Body string + RawResponse *http.Response +} + +var _ error = &SDKError{} + +func NewSDKError(message string, statusCode int, body string, httpRes *http.Response) *SDKError { + return &SDKError{ + Message: message, + StatusCode: statusCode, + Body: body, + RawResponse: httpRes, + } +} + +func (e *SDKError) Error() string { + body := "" + if len(e.Body) > 0 { + body = fmt.Sprintf("\n%s", e.Body) + } + + return fmt.Sprintf("%s: Status %d%s", e.Message, e.StatusCode, body) +} diff --git a/sync-for-payables/pkg/models/shared/accountmappingoption.go b/sync-for-payables/pkg/models/shared/accountmappingoption.go new file mode 100644 index 000000000..749630554 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/accountmappingoption.go @@ -0,0 +1,74 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type AccountMappingOption struct { + // Identifier for the account, unique for the company. + ID *string `json:"id,omitempty"` + // Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. + NominalCode *string `json:"nominalCode,omitempty"` + // Name of the account. + Name *string `json:"name,omitempty"` + // Type of account. + Type *string `json:"type,omitempty"` + // The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + // + // ## Unknown currencies + // + // In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + // + // There are only a very small number of edge cases where this currency code is returned by the Codat system. + Currency *string `json:"currency,omitempty"` + // The current status of the account. + Status *AccountStatus `json:"status,omitempty"` + SourceModifiedDate *string `json:"sourceModifiedDate,omitempty"` +} + +func (o *AccountMappingOption) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *AccountMappingOption) GetNominalCode() *string { + if o == nil { + return nil + } + return o.NominalCode +} + +func (o *AccountMappingOption) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *AccountMappingOption) GetType() *string { + if o == nil { + return nil + } + return o.Type +} + +func (o *AccountMappingOption) GetCurrency() *string { + if o == nil { + return nil + } + return o.Currency +} + +func (o *AccountMappingOption) GetStatus() *AccountStatus { + if o == nil { + return nil + } + return o.Status +} + +func (o *AccountMappingOption) GetSourceModifiedDate() *string { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/accountstatus.go b/sync-for-payables/pkg/models/shared/accountstatus.go new file mode 100644 index 000000000..c0e575bc7 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/accountstatus.go @@ -0,0 +1,35 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// AccountStatus - The current status of the account. +type AccountStatus string + +const ( + AccountStatusActive AccountStatus = "Active" + AccountStatusArchived AccountStatus = "Archived" +) + +func (e AccountStatus) ToPointer() *AccountStatus { + return &e +} +func (e *AccountStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Active": + fallthrough + case "Archived": + *e = AccountStatus(v) + return nil + default: + return fmt.Errorf("invalid value for AccountStatus: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/accounttype.go b/sync-for-payables/pkg/models/shared/accounttype.go new file mode 100644 index 000000000..c5ecf9308 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/accounttype.go @@ -0,0 +1,40 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// AccountType - The type of transactions and balances on the account. +// For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. +// For Debit accounts, positive balances are assets, and positive transactions **increase** assets. +type AccountType string + +const ( + AccountTypeUnknown AccountType = "Unknown" + AccountTypeCredit AccountType = "Credit" + AccountTypeDebit AccountType = "Debit" +) + +func (e AccountType) ToPointer() *AccountType { + return &e +} +func (e *AccountType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Unknown": + fallthrough + case "Credit": + fallthrough + case "Debit": + *e = AccountType(v) + return nil + default: + return fmt.Errorf("invalid value for AccountType: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/address.go b/sync-for-payables/pkg/models/shared/address.go new file mode 100644 index 000000000..18e01cc33 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/address.go @@ -0,0 +1,69 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Address struct { + // The type of the address + Type *AddressType `json:"type,omitempty"` + // Line 1 of the customer address. + Line1 *string `json:"line1,omitempty"` + // Line 2 of the customer address. + Line2 *string `json:"line2,omitempty"` + // City of the customer address. + City *string `json:"city,omitempty"` + // Region of the customer address. + Region *string `json:"region,omitempty"` + // Country of the customer's address. For NetSuite, use the 2-digit [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) country code. + Country *string `json:"country,omitempty"` + // Postal code or zip code. + PostalCode *string `json:"postalCode,omitempty"` +} + +func (o *Address) GetType() *AddressType { + if o == nil { + return nil + } + return o.Type +} + +func (o *Address) GetLine1() *string { + if o == nil { + return nil + } + return o.Line1 +} + +func (o *Address) GetLine2() *string { + if o == nil { + return nil + } + return o.Line2 +} + +func (o *Address) GetCity() *string { + if o == nil { + return nil + } + return o.City +} + +func (o *Address) GetRegion() *string { + if o == nil { + return nil + } + return o.Region +} + +func (o *Address) GetCountry() *string { + if o == nil { + return nil + } + return o.Country +} + +func (o *Address) GetPostalCode() *string { + if o == nil { + return nil + } + return o.PostalCode +} diff --git a/sync-for-payables/pkg/models/shared/addresstype.go b/sync-for-payables/pkg/models/shared/addresstype.go new file mode 100644 index 000000000..2ee7c93ef --- /dev/null +++ b/sync-for-payables/pkg/models/shared/addresstype.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// AddressType - The type of the address +type AddressType string + +const ( + AddressTypeUnknown AddressType = "Unknown" + AddressTypeBilling AddressType = "Billing" + AddressTypeDelivery AddressType = "Delivery" +) + +func (e AddressType) ToPointer() *AddressType { + return &e +} +func (e *AddressType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Unknown": + fallthrough + case "Billing": + fallthrough + case "Delivery": + *e = AddressType(v) + return nil + default: + return fmt.Errorf("invalid value for AddressType: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/attachment.go b/sync-for-payables/pkg/models/shared/attachment.go new file mode 100644 index 000000000..e47e611c7 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/attachment.go @@ -0,0 +1,104 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// Attachment - The Codat API supports pulling and pushing of file attachments for invoices, bills, direct costs, and direct incomes. +// +// > **Retrieving attachments** +// > +// > If a company is authorized, you can query the Codat API to read, download, and upload attachments without requiring a fresh sync of data. +// +// Unlike other data types, Codat doesn't support [sync settings](https://docs.codat.io/knowledge-base/advanced-sync-settings) for attachments. +// +// Note that different integrations have different requirements for file size and extension of attachments. +// +// | Integration | File size | File extension | +// |-------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| +// | Xero | 4 MB | 7Z, BMP, CSV, DOC, DOCX, EML, GIF, JPEG, JPG, KEYNOTE, MSG, NUMBERS, ODF, ODS, ODT, PAGES, PDF, PNG, PPT, PPTX, RAR, RTF, TIF, TIFF, TXT, XLS, XLSX, ZIP | +// | QuickBooks Online | 100 MB | AI, CSV, DOC, DOCX, EPS, GIF, JPEG, JPG, ODS, PAGES, PDF, PNG, RTF, TIF, TXT, XLS, XLSX, XML | +// | NetSuite | 100 MB | BMP, CSV, XLS, XLSX, JSON, PDF, PJPG, PJPEG, PNG, TXT, SVG, TIF, TIFF, DOC, DOCX, ZIP | +// | Dynamics 365 Business Central | 350 MB | Dynamics do not explicitly outline which file types are supported but they do state here that "You can attach any type of file, such as text, image, or video files". | +type Attachment struct { + // Identifier for the attachment, unique for the company in the accounting software. + ID *string `json:"id,omitempty"` + // Name of the attachment file. + Name *string `json:"name,omitempty"` + // File type of the attachment. This is represented by appending the file type to the [IETF standard file naming requirements](https://tools.ietf.org/html/rfc6838). For example, for a jpeg file the output is **image/jpeg**. + // + // Supported file types vary per platform. + ContentType *string `json:"contentType,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + DateCreated *string `json:"dateCreated,omitempty"` + // File size in bytes. For example, if this reads **46153**, then the file size is 46kb. + FileSize *int `json:"fileSize,omitempty"` + // If `true`, then the attachment is included with the associated invoice, bill or direct costs when it is printed, emailed, or sent to a customer, if the underlying accounting software allows this. + IncludeWhenSent *bool `json:"includeWhenSent,omitempty"` + SourceModifiedDate *string `json:"sourceModifiedDate,omitempty"` +} + +func (o *Attachment) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *Attachment) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *Attachment) GetContentType() *string { + if o == nil { + return nil + } + return o.ContentType +} + +func (o *Attachment) GetDateCreated() *string { + if o == nil { + return nil + } + return o.DateCreated +} + +func (o *Attachment) GetFileSize() *int { + if o == nil { + return nil + } + return o.FileSize +} + +func (o *Attachment) GetIncludeWhenSent() *bool { + if o == nil { + return nil + } + return o.IncludeWhenSent +} + +func (o *Attachment) GetSourceModifiedDate() *string { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/attachmentupload.go b/sync-for-payables/pkg/models/shared/attachmentupload.go new file mode 100644 index 000000000..fd81d447b --- /dev/null +++ b/sync-for-payables/pkg/models/shared/attachmentupload.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type AttachmentUpload struct { + // The file to be uploaded as an attachment. + File CodatFile `multipartForm:"file"` +} + +func (o *AttachmentUpload) GetFile() CodatFile { + if o == nil { + return CodatFile{} + } + return o.File +} diff --git a/sync-for-payables/pkg/models/shared/bankaccount.go b/sync-for-payables/pkg/models/shared/bankaccount.go new file mode 100644 index 000000000..a861e1887 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/bankaccount.go @@ -0,0 +1,137 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// BankAccountType - The type of transactions and balances on the account. +// For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. +// For Debit accounts, positive balances are assets, and positive transactions **increase** assets. +type BankAccountType string + +const ( + BankAccountTypeUnknown BankAccountType = "Unknown" + BankAccountTypeCredit BankAccountType = "Credit" + BankAccountTypeDebit BankAccountType = "Debit" +) + +func (e BankAccountType) ToPointer() *BankAccountType { + return &e +} +func (e *BankAccountType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Unknown": + fallthrough + case "Credit": + fallthrough + case "Debit": + *e = BankAccountType(v) + return nil + default: + return fmt.Errorf("invalid value for BankAccountType: %v", v) + } +} + +type BankAccount struct { + // Identifier for the bank account, unique for the company in the accounting software. + ID *string `json:"id,omitempty"` + // Code used to identify each nominal account for a business. + NominalCode *string `json:"nominalCode,omitempty"` + // Name of the bank account in the accounting software. + Name *string `json:"name,omitempty"` + // The type of transactions and balances on the account. + // For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. + // For Debit accounts, positive balances are assets, and positive transactions **increase** assets. + AccountType *BankAccountType `json:"accountType,omitempty"` + // Account number for the bank account. + // + // Xero integrations + // Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. + AccountNumber *string `json:"accountNumber,omitempty"` + // Sort code for the bank account. This is relevant to UK bank accounts. + // + // Xero integrations + // The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. + SortCode *string `json:"sortCode,omitempty"` + // The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + // + // ## Unknown currencies + // + // In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + // + // There are only a very small number of edge cases where this currency code is returned by the Codat system. + Currency *string `json:"currency,omitempty"` + // The current status of the bank account. + Status *BankAccountStatus `json:"status,omitempty"` + SourceModifiedDate *string `json:"sourceModifiedDate,omitempty"` +} + +func (o *BankAccount) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *BankAccount) GetNominalCode() *string { + if o == nil { + return nil + } + return o.NominalCode +} + +func (o *BankAccount) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *BankAccount) GetAccountType() *BankAccountType { + if o == nil { + return nil + } + return o.AccountType +} + +func (o *BankAccount) GetAccountNumber() *string { + if o == nil { + return nil + } + return o.AccountNumber +} + +func (o *BankAccount) GetSortCode() *string { + if o == nil { + return nil + } + return o.SortCode +} + +func (o *BankAccount) GetCurrency() *string { + if o == nil { + return nil + } + return o.Currency +} + +func (o *BankAccount) GetStatus() *BankAccountStatus { + if o == nil { + return nil + } + return o.Status +} + +func (o *BankAccount) GetSourceModifiedDate() *string { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/bankaccountmappingoption.go b/sync-for-payables/pkg/models/shared/bankaccountmappingoption.go new file mode 100644 index 000000000..e7d0b6f81 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/bankaccountmappingoption.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type BankAccountMappingOption struct { + // Identifier for the account, unique for the company in the accounting software. + ID *string `json:"id,omitempty"` + // Name of the bank account in the accounting software. + Name *string `json:"name,omitempty"` + // Account number for the bank account. + // + // Xero integrations + // Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. + AccountNumber *string `json:"accountNumber,omitempty"` + // Code used to identify each nominal account for a business. + NominalCode *string `json:"nominalCode,omitempty"` + // Sort code for the bank account. + // + // Xero integrations + // The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. + SortCode *string `json:"sortCode,omitempty"` + // The bank account's base currency. + Currency *string `json:"currency,omitempty"` + // The current status of the bank account. + Status *BankAccountStatus `json:"status,omitempty"` + // The type of transactions and balances on the account. + // For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. + // For Debit accounts, positive balances are assets, and positive transactions **increase** assets. + AccountType *AccountType `json:"accountType,omitempty"` + SourceModifiedDate *string `json:"sourceModifiedDate,omitempty"` +} + +func (o *BankAccountMappingOption) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *BankAccountMappingOption) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *BankAccountMappingOption) GetAccountNumber() *string { + if o == nil { + return nil + } + return o.AccountNumber +} + +func (o *BankAccountMappingOption) GetNominalCode() *string { + if o == nil { + return nil + } + return o.NominalCode +} + +func (o *BankAccountMappingOption) GetSortCode() *string { + if o == nil { + return nil + } + return o.SortCode +} + +func (o *BankAccountMappingOption) GetCurrency() *string { + if o == nil { + return nil + } + return o.Currency +} + +func (o *BankAccountMappingOption) GetStatus() *BankAccountStatus { + if o == nil { + return nil + } + return o.Status +} + +func (o *BankAccountMappingOption) GetAccountType() *AccountType { + if o == nil { + return nil + } + return o.AccountType +} + +func (o *BankAccountMappingOption) GetSourceModifiedDate() *string { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/bankaccountprototype.go b/sync-for-payables/pkg/models/shared/bankaccountprototype.go new file mode 100644 index 000000000..45821b431 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/bankaccountprototype.go @@ -0,0 +1,74 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type BankAccountPrototype struct { + // Code used to identify each nominal account for a business. + NominalCode *string `json:"nominalCode,omitempty"` + // Name of the bank account in the accounting software. + Name *string `json:"name"` + // The type of transactions and balances on the account. + // For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. + // For Debit accounts, positive balances are assets, and positive transactions **increase** assets. + AccountType AccountType `json:"accountType"` + // Account number for the bank account. + // + // Xero integrations + // Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. + AccountNumber *string `json:"accountNumber"` + // Sort code for the bank account. This is relevant to UK bank accounts. + // + // Xero integrations + // The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. + SortCode *string `json:"sortCode,omitempty"` + // The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + // + // ## Unknown currencies + // + // In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + // + // There are only a very small number of edge cases where this currency code is returned by the Codat system. + Currency string `json:"currency"` +} + +func (o *BankAccountPrototype) GetNominalCode() *string { + if o == nil { + return nil + } + return o.NominalCode +} + +func (o *BankAccountPrototype) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *BankAccountPrototype) GetAccountType() AccountType { + if o == nil { + return AccountType("") + } + return o.AccountType +} + +func (o *BankAccountPrototype) GetAccountNumber() *string { + if o == nil { + return nil + } + return o.AccountNumber +} + +func (o *BankAccountPrototype) GetSortCode() *string { + if o == nil { + return nil + } + return o.SortCode +} + +func (o *BankAccountPrototype) GetCurrency() string { + if o == nil { + return "" + } + return o.Currency +} diff --git a/sync-for-payables/pkg/models/shared/bankaccountstatus.go b/sync-for-payables/pkg/models/shared/bankaccountstatus.go new file mode 100644 index 000000000..7173cfb7c --- /dev/null +++ b/sync-for-payables/pkg/models/shared/bankaccountstatus.go @@ -0,0 +1,35 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// BankAccountStatus - The current status of the bank account. +type BankAccountStatus string + +const ( + BankAccountStatusActive BankAccountStatus = "Active" + BankAccountStatusArchived BankAccountStatus = "Archived" +) + +func (e BankAccountStatus) ToPointer() *BankAccountStatus { + return &e +} +func (e *BankAccountStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Active": + fallthrough + case "Archived": + *e = BankAccountStatus(v) + return nil + default: + return fmt.Errorf("invalid value for BankAccountStatus: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/bill.go b/sync-for-payables/pkg/models/shared/bill.go new file mode 100644 index 000000000..7e52350e0 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/bill.go @@ -0,0 +1,165 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +// Bill - Bills are invoices that represent the SMB's financial obligations to their supplier for a purchase of goods or services. +type Bill struct { + // Identifier for the bill, unique for the company in the accounting software. + ID *string `json:"id,omitempty"` + // User-friendly reference for the bill. + Reference *string `json:"reference,omitempty"` + // Reference to the supplier the record relates to. + SupplierRef SupplierRef `json:"supplierRef"` + IssueDate string `json:"issueDate"` + DueDate string `json:"dueDate"` + // The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + // + // ## Unknown currencies + // + // In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + // + // There are only a very small number of edge cases where this currency code is returned by the Codat system. + Currency string `json:"currency"` + // Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. + // + // Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. + // + // It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. + // + // Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). + // + // For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. + // + // ## Examples with base currency of GBP + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **USD** | $20 | 0.781 | £15.62 | + // | **EUR** | €20 | 0.885 | £17.70 | + // | **RUB** | ₽20 | 0.011 | £0.22 | + // + // ## Examples with base currency of USD + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **GBP** | £20 | 1.277 | $25.54 | + // | **EUR** | €20 | 1.134 | $22.68 | + // | **RUB** | ₽20 | 0.015 | $0.30 | + // + // + // ### Integration-specific details + // + // | Integration | Scenario | System behavior | + // |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| + // | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. | + CurrencyRate *decimal.Big `decimal:"number" json:"currencyRate,omitempty"` + // Array of Bill line items. + LineItems []BillLineItem `json:"lineItems,omitempty"` + // Current state of the bill. If creating a bill the status must be `Open`. + Status BillStatus `json:"status"` + // Amount of the bill, including tax. + TotalAmount *decimal.Big `decimal:"number" json:"totalAmount,omitempty"` + // Amount outstanding on the bill. + AmountDue *decimal.Big `decimal:"number" json:"amountDue,omitempty"` + SourceModifiedDate *One `json:"sourceModifiedDate,omitempty"` +} + +func (b Bill) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *Bill) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Bill) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *Bill) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *Bill) GetSupplierRef() SupplierRef { + if o == nil { + return SupplierRef{} + } + return o.SupplierRef +} + +func (o *Bill) GetIssueDate() string { + if o == nil { + return "" + } + return o.IssueDate +} + +func (o *Bill) GetDueDate() string { + if o == nil { + return "" + } + return o.DueDate +} + +func (o *Bill) GetCurrency() string { + if o == nil { + return "" + } + return o.Currency +} + +func (o *Bill) GetCurrencyRate() *decimal.Big { + if o == nil { + return nil + } + return o.CurrencyRate +} + +func (o *Bill) GetLineItems() []BillLineItem { + if o == nil { + return nil + } + return o.LineItems +} + +func (o *Bill) GetStatus() BillStatus { + if o == nil { + return BillStatus("") + } + return o.Status +} + +func (o *Bill) GetTotalAmount() *decimal.Big { + if o == nil { + return nil + } + return o.TotalAmount +} + +func (o *Bill) GetAmountDue() *decimal.Big { + if o == nil { + return nil + } + return o.AmountDue +} + +func (o *Bill) GetSourceModifiedDate() *One { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/billaccountref.go b/sync-for-payables/pkg/models/shared/billaccountref.go new file mode 100644 index 000000000..ef20b8c78 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billaccountref.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// BillAccountRef - Reference to the account to which the line item is linked. +type BillAccountRef struct { + // 'id' from the Accounts data type. + ID *string `json:"id,omitempty"` +} + +func (o *BillAccountRef) GetID() *string { + if o == nil { + return nil + } + return o.ID +} diff --git a/sync-for-payables/pkg/models/shared/billlineitem.go b/sync-for-payables/pkg/models/shared/billlineitem.go new file mode 100644 index 000000000..0afebb8fd --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billlineitem.go @@ -0,0 +1,85 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +type BillLineItem struct { + // Friendly name of the goods or services received. + Description *string `json:"description,omitempty"` + // Unit price of the goods or service. + UnitAmount *decimal.Big `decimal:"number" json:"unitAmount"` + // Number of units of goods or services received. + Quantity *decimal.Big `decimal:"number" json:"quantity"` + // Amount of tax applied to the line item. + TaxAmount *decimal.Big `decimal:"number" json:"taxAmount,omitempty"` + // Reference to the account to which the line item is linked. + AccountRef BillAccountRef `json:"accountRef"` + // Total amount of the line, including tax. + TotalAmount *decimal.Big `decimal:"number" json:"totalAmount,omitempty"` + // Reference to the tax rate to which the line item is linked. + TaxRateRef BillTaxRateRef `json:"taxRateRef"` +} + +func (b BillLineItem) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *BillLineItem) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *BillLineItem) GetDescription() *string { + if o == nil { + return nil + } + return o.Description +} + +func (o *BillLineItem) GetUnitAmount() *decimal.Big { + if o == nil { + return new(decimal.Big).SetFloat64(0.0) + } + return o.UnitAmount +} + +func (o *BillLineItem) GetQuantity() *decimal.Big { + if o == nil { + return new(decimal.Big).SetFloat64(0.0) + } + return o.Quantity +} + +func (o *BillLineItem) GetTaxAmount() *decimal.Big { + if o == nil { + return nil + } + return o.TaxAmount +} + +func (o *BillLineItem) GetAccountRef() BillAccountRef { + if o == nil { + return BillAccountRef{} + } + return o.AccountRef +} + +func (o *BillLineItem) GetTotalAmount() *decimal.Big { + if o == nil { + return nil + } + return o.TotalAmount +} + +func (o *BillLineItem) GetTaxRateRef() BillTaxRateRef { + if o == nil { + return BillTaxRateRef{} + } + return o.TaxRateRef +} diff --git a/sync-for-payables/pkg/models/shared/billmappingoptions.go b/sync-for-payables/pkg/models/shared/billmappingoptions.go new file mode 100644 index 000000000..d5c0cf99f --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billmappingoptions.go @@ -0,0 +1,31 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// BillMappingOptions - The bill mapping options for a company's accounting software. +type BillMappingOptions struct { + Accounts []AccountMappingOption `json:"accounts,omitempty"` + TaxRate []TaxRateMappingOption `json:"taxRate,omitempty"` + Pagination *Pagination `json:"pagination,omitempty"` +} + +func (o *BillMappingOptions) GetAccounts() []AccountMappingOption { + if o == nil { + return nil + } + return o.Accounts +} + +func (o *BillMappingOptions) GetTaxRate() []TaxRateMappingOption { + if o == nil { + return nil + } + return o.TaxRate +} + +func (o *BillMappingOptions) GetPagination() *Pagination { + if o == nil { + return nil + } + return o.Pagination +} diff --git a/sync-for-payables/pkg/models/shared/billpayment.go b/sync-for-payables/pkg/models/shared/billpayment.go new file mode 100644 index 000000000..037ee4dcb --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billpayment.go @@ -0,0 +1,106 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +type BillPayment struct { + // Identifier for the bill payment, unique for the company in the accounting software. + ID *string `json:"id,omitempty"` + // Amount of the payment in the bill currency. + Amount *decimal.Big `decimal:"number" json:"amount,omitempty"` + Date *string `json:"date,omitempty"` + // Additional information associated with the payment. + Reference *string `json:"reference,omitempty"` + // Reference to the bank account / credit card which you are using to pay the bill. + AccountRef *BillPaymentAccountRef `json:"accountRef,omitempty"` + // Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. + // + // Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. + // + // It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. + // + // Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). + // + // For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. + // + // ## Examples with base currency of GBP + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **USD** | $20 | 0.781 | £15.62 | + // | **EUR** | €20 | 0.885 | £17.70 | + // | **RUB** | ₽20 | 0.011 | £0.22 | + // + // ## Examples with base currency of USD + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **GBP** | £20 | 1.277 | $25.54 | + // | **EUR** | €20 | 1.134 | $22.68 | + // | **RUB** | ₽20 | 0.015 | $0.30 | + // + // + // ### Integration-specific details + // + // | Integration | Scenario | System behavior | + // |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| + // | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. | + CurrencyRate *decimal.Big `decimal:"number" json:"currencyRate,omitempty"` +} + +func (b BillPayment) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *BillPayment) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *BillPayment) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *BillPayment) GetAmount() *decimal.Big { + if o == nil { + return nil + } + return o.Amount +} + +func (o *BillPayment) GetDate() *string { + if o == nil { + return nil + } + return o.Date +} + +func (o *BillPayment) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *BillPayment) GetAccountRef() *BillPaymentAccountRef { + if o == nil { + return nil + } + return o.AccountRef +} + +func (o *BillPayment) GetCurrencyRate() *decimal.Big { + if o == nil { + return nil + } + return o.CurrencyRate +} diff --git a/sync-for-payables/pkg/models/shared/billpaymentaccountref.go b/sync-for-payables/pkg/models/shared/billpaymentaccountref.go new file mode 100644 index 000000000..0c61e082e --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billpaymentaccountref.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// BillPaymentAccountRef - Reference to the bank account / credit card which you are using to pay the bill. +type BillPaymentAccountRef struct { + // Unique ID of the bank account / credit card + ID string `json:"id"` +} + +func (o *BillPaymentAccountRef) GetID() string { + if o == nil { + return "" + } + return o.ID +} diff --git a/sync-for-payables/pkg/models/shared/billpaymentprototype.go b/sync-for-payables/pkg/models/shared/billpaymentprototype.go new file mode 100644 index 000000000..85efdae63 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billpaymentprototype.go @@ -0,0 +1,97 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +type BillPaymentPrototype struct { + // Amount of the payment in the bill currency. + Amount *decimal.Big `decimal:"number" json:"amount"` + Date string `json:"date"` + // Additional information associated with the payment. + Reference *string `json:"reference,omitempty"` + // Reference to the bank account / credit card which you are using to pay the bill. + AccountRef BillPaymentAccountRef `json:"accountRef"` + // Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. + // + // Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. + // + // It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. + // + // Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). + // + // For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. + // + // ## Examples with base currency of GBP + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **USD** | $20 | 0.781 | £15.62 | + // | **EUR** | €20 | 0.885 | £17.70 | + // | **RUB** | ₽20 | 0.011 | £0.22 | + // + // ## Examples with base currency of USD + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **GBP** | £20 | 1.277 | $25.54 | + // | **EUR** | €20 | 1.134 | $22.68 | + // | **RUB** | ₽20 | 0.015 | $0.30 | + // + // + // ### Integration-specific details + // + // | Integration | Scenario | System behavior | + // |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| + // | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. | + CurrencyRate *decimal.Big `decimal:"number" json:"currencyRate,omitempty"` +} + +func (b BillPaymentPrototype) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *BillPaymentPrototype) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *BillPaymentPrototype) GetAmount() *decimal.Big { + if o == nil { + return new(decimal.Big).SetFloat64(0.0) + } + return o.Amount +} + +func (o *BillPaymentPrototype) GetDate() string { + if o == nil { + return "" + } + return o.Date +} + +func (o *BillPaymentPrototype) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *BillPaymentPrototype) GetAccountRef() BillPaymentAccountRef { + if o == nil { + return BillPaymentAccountRef{} + } + return o.AccountRef +} + +func (o *BillPaymentPrototype) GetCurrencyRate() *decimal.Big { + if o == nil { + return nil + } + return o.CurrencyRate +} diff --git a/sync-for-payables/pkg/models/shared/billprototype.go b/sync-for-payables/pkg/models/shared/billprototype.go new file mode 100644 index 000000000..c12127b40 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billprototype.go @@ -0,0 +1,147 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +type BillPrototype struct { + // User-friendly reference for the bill. + Reference *string `json:"reference,omitempty"` + // Reference to the supplier the record relates to. + SupplierRef SupplierRef `json:"supplierRef"` + IssueDate string `json:"issueDate"` + DueDate string `json:"dueDate"` + // The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + // + // ## Unknown currencies + // + // In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + // + // There are only a very small number of edge cases where this currency code is returned by the Codat system. + Currency string `json:"currency"` + // Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. + // + // Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. + // + // It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. + // + // Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). + // + // For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. + // + // ## Examples with base currency of GBP + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **USD** | $20 | 0.781 | £15.62 | + // | **EUR** | €20 | 0.885 | £17.70 | + // | **RUB** | ₽20 | 0.011 | £0.22 | + // + // ## Examples with base currency of USD + // + // | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | + // | :--------------- | :------------- | :------------ | :------------------------- | + // | **GBP** | £20 | 1.277 | $25.54 | + // | **EUR** | €20 | 1.134 | $22.68 | + // | **RUB** | ₽20 | 0.015 | $0.30 | + // + // + // ### Integration-specific details + // + // | Integration | Scenario | System behavior | + // |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| + // | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. | + CurrencyRate *decimal.Big `decimal:"number" json:"currencyRate,omitempty"` + // Array of Bill line items. + LineItems []BillLineItem `json:"lineItems,omitempty"` + // Current state of the bill. If creating a bill the status must be `Open`. + Status BillStatus `json:"status"` + // Amount of the bill, including tax. + TotalAmount *decimal.Big `decimal:"number" json:"totalAmount,omitempty"` + // Amount outstanding on the bill. + AmountDue *decimal.Big `decimal:"number" json:"amountDue,omitempty"` +} + +func (b BillPrototype) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *BillPrototype) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *BillPrototype) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *BillPrototype) GetSupplierRef() SupplierRef { + if o == nil { + return SupplierRef{} + } + return o.SupplierRef +} + +func (o *BillPrototype) GetIssueDate() string { + if o == nil { + return "" + } + return o.IssueDate +} + +func (o *BillPrototype) GetDueDate() string { + if o == nil { + return "" + } + return o.DueDate +} + +func (o *BillPrototype) GetCurrency() string { + if o == nil { + return "" + } + return o.Currency +} + +func (o *BillPrototype) GetCurrencyRate() *decimal.Big { + if o == nil { + return nil + } + return o.CurrencyRate +} + +func (o *BillPrototype) GetLineItems() []BillLineItem { + if o == nil { + return nil + } + return o.LineItems +} + +func (o *BillPrototype) GetStatus() BillStatus { + if o == nil { + return BillStatus("") + } + return o.Status +} + +func (o *BillPrototype) GetTotalAmount() *decimal.Big { + if o == nil { + return nil + } + return o.TotalAmount +} + +func (o *BillPrototype) GetAmountDue() *decimal.Big { + if o == nil { + return nil + } + return o.AmountDue +} diff --git a/sync-for-payables/pkg/models/shared/bills.go b/sync-for-payables/pkg/models/shared/bills.go new file mode 100644 index 000000000..912fee521 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/bills.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Bills struct { + Results []Bill `json:"results,omitempty"` + Pagination *Pagination `json:"pagination,omitempty"` +} + +func (o *Bills) GetResults() []Bill { + if o == nil { + return nil + } + return o.Results +} + +func (o *Bills) GetPagination() *Pagination { + if o == nil { + return nil + } + return o.Pagination +} diff --git a/sync-for-payables/pkg/models/shared/billstatus.go b/sync-for-payables/pkg/models/shared/billstatus.go new file mode 100644 index 000000000..92dd9b19b --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billstatus.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// BillStatus - Current state of the bill. If creating a bill the status must be `Open`. +type BillStatus string + +const ( + BillStatusUnknown BillStatus = "Unknown" + BillStatusOpen BillStatus = "Open" + BillStatusPartiallyPaid BillStatus = "PartiallyPaid" + BillStatusPaid BillStatus = "Paid" + BillStatusVoid BillStatus = "Void" + BillStatusDraft BillStatus = "Draft" +) + +func (e BillStatus) ToPointer() *BillStatus { + return &e +} +func (e *BillStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Unknown": + fallthrough + case "Open": + fallthrough + case "PartiallyPaid": + fallthrough + case "Paid": + fallthrough + case "Void": + fallthrough + case "Draft": + *e = BillStatus(v) + return nil + default: + return fmt.Errorf("invalid value for BillStatus: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/billtaxrateref.go b/sync-for-payables/pkg/models/shared/billtaxrateref.go new file mode 100644 index 000000000..be6b64bd1 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/billtaxrateref.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// BillTaxRateRef - Reference to the tax rate to which the line item is linked. +type BillTaxRateRef struct { + // Unique identifier for the tax rate in the accounting software. + ID *string `json:"id,omitempty"` +} + +func (o *BillTaxRateRef) GetID() *string { + if o == nil { + return nil + } + return o.ID +} diff --git a/sync-for-payables/pkg/models/shared/clientratelimitreachedwebhook.go b/sync-for-payables/pkg/models/shared/clientratelimitreachedwebhook.go new file mode 100644 index 000000000..8264040b2 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/clientratelimitreachedwebhook.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ClientRateLimitReachedWebhook - Webhook request body for a client that has reached their rate limit. +type ClientRateLimitReachedWebhook struct { + // Unique identifier for your client in Codat. + ClientID *string `json:"ClientId,omitempty"` + // Name of your client in Codat. + ClientName *string `json:"ClientName,omitempty"` + // Unique identifier for the rule. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + RuleID *string `json:"RuleId,omitempty"` + // The type of rule. + RuleType *string `json:"RuleType,omitempty"` + // Unique identifier of the webhook event. + AlertID *string `json:"AlertId,omitempty"` + // A human-readable message about the webhook. + Message *string `json:"Message,omitempty"` + Data *ClientRateLimitReachedWebhookData `json:"Data,omitempty"` +} + +func (o *ClientRateLimitReachedWebhook) GetClientID() *string { + if o == nil { + return nil + } + return o.ClientID +} + +func (o *ClientRateLimitReachedWebhook) GetClientName() *string { + if o == nil { + return nil + } + return o.ClientName +} + +func (o *ClientRateLimitReachedWebhook) GetRuleID() *string { + if o == nil { + return nil + } + return o.RuleID +} + +func (o *ClientRateLimitReachedWebhook) GetRuleType() *string { + if o == nil { + return nil + } + return o.RuleType +} + +func (o *ClientRateLimitReachedWebhook) GetAlertID() *string { + if o == nil { + return nil + } + return o.AlertID +} + +func (o *ClientRateLimitReachedWebhook) GetMessage() *string { + if o == nil { + return nil + } + return o.Message +} + +func (o *ClientRateLimitReachedWebhook) GetData() *ClientRateLimitReachedWebhookData { + if o == nil { + return nil + } + return o.Data +} diff --git a/sync-for-payables/pkg/models/shared/clientratelimitreachedwebhookdata.go b/sync-for-payables/pkg/models/shared/clientratelimitreachedwebhookdata.go new file mode 100644 index 000000000..fdbf9b562 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/clientratelimitreachedwebhookdata.go @@ -0,0 +1,42 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ClientRateLimitReachedWebhookData struct { + // The number of available requests per day. + DailyQuota *int64 `json:"DailyQuota,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + ExpiresUtc *string `json:"ExpiresUtc,omitempty"` +} + +func (o *ClientRateLimitReachedWebhookData) GetDailyQuota() *int64 { + if o == nil { + return nil + } + return o.DailyQuota +} + +func (o *ClientRateLimitReachedWebhookData) GetExpiresUtc() *string { + if o == nil { + return nil + } + return o.ExpiresUtc +} diff --git a/sync-for-payables/pkg/models/shared/clientratelimitresetwebhook.go b/sync-for-payables/pkg/models/shared/clientratelimitresetwebhook.go new file mode 100644 index 000000000..a4628fab4 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/clientratelimitresetwebhook.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ClientRateLimitResetWebhook - Webhook request body for a client that has had their rate limit reset. +type ClientRateLimitResetWebhook struct { + // Unique identifier for your client in Codat. + ClientID *string `json:"ClientId,omitempty"` + // Name of your client in Codat. + ClientName *string `json:"ClientName,omitempty"` + // Unique identifier for the rule. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + RuleID *string `json:"RuleId,omitempty"` + // The type of rule. + RuleType *string `json:"RuleType,omitempty"` + // Unique identifier of the webhook event. + AlertID *string `json:"AlertId,omitempty"` + // A human-readable message about the webhook. + Message *string `json:"Message,omitempty"` + Data *ClientRateLimitResetWebhookData `json:"Data,omitempty"` +} + +func (o *ClientRateLimitResetWebhook) GetClientID() *string { + if o == nil { + return nil + } + return o.ClientID +} + +func (o *ClientRateLimitResetWebhook) GetClientName() *string { + if o == nil { + return nil + } + return o.ClientName +} + +func (o *ClientRateLimitResetWebhook) GetRuleID() *string { + if o == nil { + return nil + } + return o.RuleID +} + +func (o *ClientRateLimitResetWebhook) GetRuleType() *string { + if o == nil { + return nil + } + return o.RuleType +} + +func (o *ClientRateLimitResetWebhook) GetAlertID() *string { + if o == nil { + return nil + } + return o.AlertID +} + +func (o *ClientRateLimitResetWebhook) GetMessage() *string { + if o == nil { + return nil + } + return o.Message +} + +func (o *ClientRateLimitResetWebhook) GetData() *ClientRateLimitResetWebhookData { + if o == nil { + return nil + } + return o.Data +} diff --git a/sync-for-payables/pkg/models/shared/clientratelimitresetwebhookdata.go b/sync-for-payables/pkg/models/shared/clientratelimitresetwebhookdata.go new file mode 100644 index 000000000..40c35d39c --- /dev/null +++ b/sync-for-payables/pkg/models/shared/clientratelimitresetwebhookdata.go @@ -0,0 +1,60 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ClientRateLimitResetWebhookData struct { + // Total number of requests remaining for your client. + QuotaRemaining *int64 `json:"QuotaRemaining,omitempty"` + // The reason for your rate limit quota being reset. + ResetReason *string `json:"ResetReason,omitempty"` + // The number of available requests per day. + DailyQuota *int64 `json:"DailyQuota,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + ExpiresUtc *string `json:"ExpiresUtc,omitempty"` +} + +func (o *ClientRateLimitResetWebhookData) GetQuotaRemaining() *int64 { + if o == nil { + return nil + } + return o.QuotaRemaining +} + +func (o *ClientRateLimitResetWebhookData) GetResetReason() *string { + if o == nil { + return nil + } + return o.ResetReason +} + +func (o *ClientRateLimitResetWebhookData) GetDailyQuota() *int64 { + if o == nil { + return nil + } + return o.DailyQuota +} + +func (o *ClientRateLimitResetWebhookData) GetExpiresUtc() *string { + if o == nil { + return nil + } + return o.ExpiresUtc +} diff --git a/sync-for-payables/pkg/models/shared/clientratelimitwebhook.go b/sync-for-payables/pkg/models/shared/clientratelimitwebhook.go new file mode 100644 index 000000000..5f1bc6499 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/clientratelimitwebhook.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ClientRateLimitWebhook struct { + // Unique identifier of the event. + ID *string `json:"id,omitempty"` + // The type of event. + EventType *string `json:"eventType,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + GeneratedDate *string `json:"generatedDate,omitempty"` + Payload *ClientRateLimitWebhookPayload `json:"payload,omitempty"` +} + +func (o *ClientRateLimitWebhook) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *ClientRateLimitWebhook) GetEventType() *string { + if o == nil { + return nil + } + return o.EventType +} + +func (o *ClientRateLimitWebhook) GetGeneratedDate() *string { + if o == nil { + return nil + } + return o.GeneratedDate +} + +func (o *ClientRateLimitWebhook) GetPayload() *ClientRateLimitWebhookPayload { + if o == nil { + return nil + } + return o.Payload +} diff --git a/sync-for-payables/pkg/models/shared/clientratelimitwebhookpayload.go b/sync-for-payables/pkg/models/shared/clientratelimitwebhookpayload.go new file mode 100644 index 000000000..14bc5f361 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/clientratelimitwebhookpayload.go @@ -0,0 +1,51 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ClientRateLimitWebhookPayload struct { + // The number of available requests per day. + DailyQuota *int64 `json:"dailyQuota,omitempty"` + // Total number of requests remaining for your client. + QuotaRemaining *int64 `json:"quotaRemaining,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + ExpiryDate *string `json:"expiryDate,omitempty"` +} + +func (o *ClientRateLimitWebhookPayload) GetDailyQuota() *int64 { + if o == nil { + return nil + } + return o.DailyQuota +} + +func (o *ClientRateLimitWebhookPayload) GetQuotaRemaining() *int64 { + if o == nil { + return nil + } + return o.QuotaRemaining +} + +func (o *ClientRateLimitWebhookPayload) GetExpiryDate() *string { + if o == nil { + return nil + } + return o.ExpiryDate +} diff --git a/sync-for-payables/pkg/models/shared/codatfile.go b/sync-for-payables/pkg/models/shared/codatfile.go new file mode 100644 index 000000000..b6d66a36e --- /dev/null +++ b/sync-for-payables/pkg/models/shared/codatfile.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type CodatFile struct { + FileName string `multipartForm:"name=fileName"` + // This field accepts []byte data or io.Reader implementations, such as *os.File. + Content any `multipartForm:"content"` +} + +func (o *CodatFile) GetFileName() string { + if o == nil { + return "" + } + return o.FileName +} + +func (o *CodatFile) GetContent() any { + if o == nil { + return nil + } + return o.Content +} diff --git a/sync-for-payables/pkg/models/shared/companies.go b/sync-for-payables/pkg/models/shared/companies.go new file mode 100644 index 000000000..a3da476b2 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/companies.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Companies struct { + Results []Company `json:"results,omitempty"` + // Current page number. + PageNumber int64 `json:"pageNumber"` + // Number of items to return in results array. + PageSize int64 `json:"pageSize"` + // Total number of items. + TotalResults int64 `json:"totalResults"` + Links Links `json:"_links"` +} + +func (o *Companies) GetResults() []Company { + if o == nil { + return nil + } + return o.Results +} + +func (o *Companies) GetPageNumber() int64 { + if o == nil { + return 0 + } + return o.PageNumber +} + +func (o *Companies) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *Companies) GetTotalResults() int64 { + if o == nil { + return 0 + } + return o.TotalResults +} + +func (o *Companies) GetLinks() Links { + if o == nil { + return Links{} + } + return o.Links +} diff --git a/sync-for-payables/pkg/models/shared/company.go b/sync-for-payables/pkg/models/shared/company.go new file mode 100644 index 000000000..0f4938dd8 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/company.go @@ -0,0 +1,131 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// Tags - A collection of user-defined key-value pairs that store custom metadata against the company. +type Tags struct { +} + +// Company - In Codat, a company represents a business sharing access to their data. Each company can have multiple [connections](https://docs.codat.io/sync-for-payables-api#/schemas/Connection) to different data sources such as one connection to [Xero](https://docs.codat.io/integrations/accounting/xero/accounting-xero) for accounting data, two connections to [Plaid](https://docs.codat.io/integrations/banking/plaid/banking-plaid) for two bank accounts and a connection to [Zettle](https://docs.codat.io/integrations/commerce/zettle/commerce-zettle) for POS data. +// +// Typically each company is one of your customers. +// +// When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company. +type Company struct { + // Unique identifier for your SMB in Codat. + ID string `json:"id"` + // The name of the company + Name string `json:"name"` + // Additional information about the company. This can be used to store foreign IDs, references, etc. + Description *string `json:"description,omitempty"` + // The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. + Redirect string `json:"redirect"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + LastSync *string `json:"lastSync,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + Created *string `json:"created,omitempty"` + // Name of user that created the company in Codat. + CreatedByUserName *string `json:"createdByUserName,omitempty"` + // A collection of user-defined key-value pairs that store custom metadata against the company. + Tags *Tags `json:"tags,omitempty"` + DataConnections []Connection `json:"dataConnections,omitempty"` +} + +func (o *Company) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *Company) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Company) GetDescription() *string { + if o == nil { + return nil + } + return o.Description +} + +func (o *Company) GetRedirect() string { + if o == nil { + return "" + } + return o.Redirect +} + +func (o *Company) GetLastSync() *string { + if o == nil { + return nil + } + return o.LastSync +} + +func (o *Company) GetCreated() *string { + if o == nil { + return nil + } + return o.Created +} + +func (o *Company) GetCreatedByUserName() *string { + if o == nil { + return nil + } + return o.CreatedByUserName +} + +func (o *Company) GetTags() *Tags { + if o == nil { + return nil + } + return o.Tags +} + +func (o *Company) GetDataConnections() []Connection { + if o == nil { + return nil + } + return o.DataConnections +} diff --git a/sync-for-payables/pkg/models/shared/companyinformation.go b/sync-for-payables/pkg/models/shared/companyinformation.go new file mode 100644 index 000000000..b88ca54e7 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/companyinformation.go @@ -0,0 +1,25 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// CompanyInformation - Gets the latest basic info for a company. +type CompanyInformation struct { + // Name of the linked company. + CompanyName *string `json:"companyName,omitempty"` + // Currency set in the accounting software of the linked company. Used by the currency rate. + BaseCurrency *string `json:"baseCurrency,omitempty"` +} + +func (o *CompanyInformation) GetCompanyName() *string { + if o == nil { + return nil + } + return o.CompanyName +} + +func (o *CompanyInformation) GetBaseCurrency() *string { + if o == nil { + return nil + } + return o.BaseCurrency +} diff --git a/sync-for-payables/pkg/models/shared/companyrequestbody.go b/sync-for-payables/pkg/models/shared/companyrequestbody.go new file mode 100644 index 000000000..7e70aaf5a --- /dev/null +++ b/sync-for-payables/pkg/models/shared/companyrequestbody.go @@ -0,0 +1,45 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type GroupReference struct { + // Unique identifier for the group. + ID *string `json:"id,omitempty"` +} + +func (o *GroupReference) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +type CompanyRequestBody struct { + // Name of company being connected. + Name string `json:"name"` + // Additional information about the company. This can be used to store foreign IDs, references, etc. + Description *string `json:"description,omitempty"` + // Reference to the groups that the company is assigned to. + Groups []GroupReference `json:"groups,omitempty"` +} + +func (o *CompanyRequestBody) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *CompanyRequestBody) GetDescription() *string { + if o == nil { + return nil + } + return o.Description +} + +func (o *CompanyRequestBody) GetGroups() []GroupReference { + if o == nil { + return nil + } + return o.Groups +} diff --git a/sync-for-payables/pkg/models/shared/connection.go b/sync-for-payables/pkg/models/shared/connection.go new file mode 100644 index 000000000..b023ad26a --- /dev/null +++ b/sync-for-payables/pkg/models/shared/connection.go @@ -0,0 +1,213 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// SourceType - The type of platform of the connection. +type SourceType string + +const ( + SourceTypeAccounting SourceType = "Accounting" + SourceTypeBanking SourceType = "Banking" + SourceTypeBankFeed SourceType = "BankFeed" + SourceTypeCommerce SourceType = "Commerce" + SourceTypeExpense SourceType = "Expense" + SourceTypeOther SourceType = "Other" + SourceTypeUnknown SourceType = "Unknown" +) + +func (e SourceType) ToPointer() *SourceType { + return &e +} +func (e *SourceType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Accounting": + fallthrough + case "Banking": + fallthrough + case "BankFeed": + fallthrough + case "Commerce": + fallthrough + case "Expense": + fallthrough + case "Other": + fallthrough + case "Unknown": + *e = SourceType(v) + return nil + default: + return fmt.Errorf("invalid value for SourceType: %v", v) + } +} + +// Connection - A connection represents a [company's](https://docs.codat.io/sync-for-payables-api#/schemas/Company) connection to a data source and allows you to synchronize data (pull and/or push) with that source. +// +// A company can have multiple data connections depending on the type of data source it is connecting to. For example, a single company can link to: +// +// - [Accounting data](https://docs.codat.io/accounting-api/overview) - 1 active connection. +// - [Banking data](https://docs.codat.io/banking-api/overview) - Multiple active connections. +// - [Commerce data](https://docs.codat.io/commerce-api/overview) - Multiple active connections. +// Any combination of accounting, banking, and commerce data connections is allowed. +// +// Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). +type Connection struct { + // Unique identifier for a company's data connection. + ID string `json:"id"` + // A Codat ID representing the integration. + IntegrationID string `json:"integrationId"` + // A unique four-character ID that identifies the platform of the company's data connection. This ensures continuity if the platform changes its name in the future. + IntegrationKey string `json:"integrationKey"` + // A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. + SourceID string `json:"sourceId"` + // The type of platform of the connection. + SourceType SourceType `json:"sourceType"` + // Name of integration connected to company. + PlatformName string `json:"platformName"` + // The link URL your customers can use to authorize access to their business application. + LinkURL string `json:"linkUrl"` + // The current authorization status of the data connection. + Status DataConnectionStatus `json:"status"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + LastSync *string `json:"lastSync,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + Created string `json:"created"` + DataConnectionErrors []DataConnectionError `json:"dataConnectionErrors,omitempty"` + ConnectionInfo map[string]string `json:"connectionInfo,omitempty"` + AdditionalProperties any `json:"additionalProperties,omitempty"` +} + +func (o *Connection) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *Connection) GetIntegrationID() string { + if o == nil { + return "" + } + return o.IntegrationID +} + +func (o *Connection) GetIntegrationKey() string { + if o == nil { + return "" + } + return o.IntegrationKey +} + +func (o *Connection) GetSourceID() string { + if o == nil { + return "" + } + return o.SourceID +} + +func (o *Connection) GetSourceType() SourceType { + if o == nil { + return SourceType("") + } + return o.SourceType +} + +func (o *Connection) GetPlatformName() string { + if o == nil { + return "" + } + return o.PlatformName +} + +func (o *Connection) GetLinkURL() string { + if o == nil { + return "" + } + return o.LinkURL +} + +func (o *Connection) GetStatus() DataConnectionStatus { + if o == nil { + return DataConnectionStatus("") + } + return o.Status +} + +func (o *Connection) GetLastSync() *string { + if o == nil { + return nil + } + return o.LastSync +} + +func (o *Connection) GetCreated() string { + if o == nil { + return "" + } + return o.Created +} + +func (o *Connection) GetDataConnectionErrors() []DataConnectionError { + if o == nil { + return nil + } + return o.DataConnectionErrors +} + +func (o *Connection) GetConnectionInfo() map[string]string { + if o == nil { + return nil + } + return o.ConnectionInfo +} + +func (o *Connection) GetAdditionalProperties() any { + if o == nil { + return nil + } + return o.AdditionalProperties +} diff --git a/sync-for-payables/pkg/models/shared/connections.go b/sync-for-payables/pkg/models/shared/connections.go new file mode 100644 index 000000000..a4704c74f --- /dev/null +++ b/sync-for-payables/pkg/models/shared/connections.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Connections struct { + Results []Connection `json:"results,omitempty"` + // Current page number. + PageNumber int64 `json:"pageNumber"` + // Number of items to return in results array. + PageSize int64 `json:"pageSize"` + // Total number of items. + TotalResults int64 `json:"totalResults"` + Links Links `json:"_links"` +} + +func (o *Connections) GetResults() []Connection { + if o == nil { + return nil + } + return o.Results +} + +func (o *Connections) GetPageNumber() int64 { + if o == nil { + return 0 + } + return o.PageNumber +} + +func (o *Connections) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *Connections) GetTotalResults() int64 { + if o == nil { + return 0 + } + return o.TotalResults +} + +func (o *Connections) GetLinks() Links { + if o == nil { + return Links{} + } + return o.Links +} diff --git a/sync-for-payables/pkg/models/shared/dataconnectionerror.go b/sync-for-payables/pkg/models/shared/dataconnectionerror.go new file mode 100644 index 000000000..5eaa8f867 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/dataconnectionerror.go @@ -0,0 +1,128 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// ErrorStatus - The current status of a transient error. Null statuses indicate that the error is not transient. +type ErrorStatus string + +const ( + ErrorStatusActive ErrorStatus = "Active" + ErrorStatusResolved ErrorStatus = "Resolved" +) + +func (e ErrorStatus) ToPointer() *ErrorStatus { + return &e +} +func (e *ErrorStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Active": + fallthrough + case "Resolved": + *e = ErrorStatus(v) + return nil + default: + return fmt.Errorf("invalid value for ErrorStatus: %v", v) + } +} + +type DataConnectionError struct { + // The HTTP status code returned by the source platform when the error occurred. + StatusCode *string `json:"statusCode,omitempty"` + // A non-numeric status code/text returned by the source platform when the error occurred. + StatusText *string `json:"statusText,omitempty"` + // A message about a error returned by Codat. + ErrorMessage *string `json:"errorMessage,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + ErroredOnUtc *string `json:"erroredOnUtc,omitempty"` + // The current status of a transient error. Null statuses indicate that the error is not transient. + Status *ErrorStatus `json:"status,omitempty"` + // In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + // + // ``` + // 2020-10-08T22:40:50Z + // 2021-01-01T00:00:00 + // ``` + // + // + // + // When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + // + // - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + // - Unqualified local time: `2021-11-15T01:00:00` + // - UTC time offsets: `2021-11-15T01:00:00-05:00` + // + // > Time zones + // > + // > Not all dates from Codat will contain information about time zones. + // > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + ResolvedOnUtc *string `json:"resolvedOnUtc,omitempty"` +} + +func (o *DataConnectionError) GetStatusCode() *string { + if o == nil { + return nil + } + return o.StatusCode +} + +func (o *DataConnectionError) GetStatusText() *string { + if o == nil { + return nil + } + return o.StatusText +} + +func (o *DataConnectionError) GetErrorMessage() *string { + if o == nil { + return nil + } + return o.ErrorMessage +} + +func (o *DataConnectionError) GetErroredOnUtc() *string { + if o == nil { + return nil + } + return o.ErroredOnUtc +} + +func (o *DataConnectionError) GetStatus() *ErrorStatus { + if o == nil { + return nil + } + return o.Status +} + +func (o *DataConnectionError) GetResolvedOnUtc() *string { + if o == nil { + return nil + } + return o.ResolvedOnUtc +} diff --git a/sync-for-payables/pkg/models/shared/dataconnectionstatus.go b/sync-for-payables/pkg/models/shared/dataconnectionstatus.go new file mode 100644 index 000000000..f7e281bc9 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/dataconnectionstatus.go @@ -0,0 +1,41 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// DataConnectionStatus - The current authorization status of the data connection. +type DataConnectionStatus string + +const ( + DataConnectionStatusPendingAuth DataConnectionStatus = "PendingAuth" + DataConnectionStatusLinked DataConnectionStatus = "Linked" + DataConnectionStatusUnlinked DataConnectionStatus = "Unlinked" + DataConnectionStatusDeauthorized DataConnectionStatus = "Deauthorized" +) + +func (e DataConnectionStatus) ToPointer() *DataConnectionStatus { + return &e +} +func (e *DataConnectionStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "PendingAuth": + fallthrough + case "Linked": + fallthrough + case "Unlinked": + fallthrough + case "Deauthorized": + *e = DataConnectionStatus(v) + return nil + default: + return fmt.Errorf("invalid value for DataConnectionStatus: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/errorvalidation.go b/sync-for-payables/pkg/models/shared/errorvalidation.go new file mode 100644 index 000000000..3f12091c8 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/errorvalidation.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ErrorValidation - A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. +type ErrorValidation struct { + Errors []ErrorValidationItem `json:"errors,omitempty"` + Warnings []ErrorValidationItem `json:"warnings,omitempty"` +} + +func (o *ErrorValidation) GetErrors() []ErrorValidationItem { + if o == nil { + return nil + } + return o.Errors +} + +func (o *ErrorValidation) GetWarnings() []ErrorValidationItem { + if o == nil { + return nil + } + return o.Warnings +} diff --git a/sync-for-payables/pkg/models/shared/errorvalidationitem.go b/sync-for-payables/pkg/models/shared/errorvalidationitem.go new file mode 100644 index 000000000..b97f640eb --- /dev/null +++ b/sync-for-payables/pkg/models/shared/errorvalidationitem.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ErrorValidationItem struct { + // Unique identifier for a validation item. + ItemID *string `json:"itemId,omitempty"` + // A message outlining validation item's issue. + Message *string `json:"message,omitempty"` + // Name of validator. + ValidatorName *string `json:"validatorName,omitempty"` +} + +func (o *ErrorValidationItem) GetItemID() *string { + if o == nil { + return nil + } + return o.ItemID +} + +func (o *ErrorValidationItem) GetMessage() *string { + if o == nil { + return nil + } + return o.Message +} + +func (o *ErrorValidationItem) GetValidatorName() *string { + if o == nil { + return nil + } + return o.ValidatorName +} diff --git a/sync-for-payables/pkg/models/shared/halref.go b/sync-for-payables/pkg/models/shared/halref.go new file mode 100644 index 000000000..f7b86c830 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/halref.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type HalRef struct { + // Uri hypertext reference. + Href *string `json:"href,omitempty"` +} + +func (o *HalRef) GetHref() *string { + if o == nil { + return nil + } + return o.Href +} diff --git a/sync-for-payables/pkg/models/shared/httpmetadata.go b/sync-for-payables/pkg/models/shared/httpmetadata.go new file mode 100644 index 000000000..a83540401 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/httpmetadata.go @@ -0,0 +1,28 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "net/http" +) + +type HTTPMetadata struct { + // Raw HTTP response; suitable for custom response parsing + Response *http.Response `json:"-"` + // Raw HTTP request; suitable for debugging + Request *http.Request `json:"-"` +} + +func (o *HTTPMetadata) GetResponse() *http.Response { + if o == nil { + return nil + } + return o.Response +} + +func (o *HTTPMetadata) GetRequest() *http.Request { + if o == nil { + return nil + } + return o.Request +} diff --git a/sync-for-payables/pkg/models/shared/links.go b/sync-for-payables/pkg/models/shared/links.go new file mode 100644 index 000000000..6589f52d6 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/links.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Links struct { + Self HalRef `json:"self"` + Current HalRef `json:"current"` + Next *HalRef `json:"next,omitempty"` + Previous *HalRef `json:"previous,omitempty"` +} + +func (o *Links) GetSelf() HalRef { + if o == nil { + return HalRef{} + } + return o.Self +} + +func (o *Links) GetCurrent() HalRef { + if o == nil { + return HalRef{} + } + return o.Current +} + +func (o *Links) GetNext() *HalRef { + if o == nil { + return nil + } + return o.Next +} + +func (o *Links) GetPrevious() *HalRef { + if o == nil { + return nil + } + return o.Previous +} diff --git a/sync-for-payables/pkg/models/shared/one.go b/sync-for-payables/pkg/models/shared/one.go new file mode 100644 index 000000000..fbcdcd0ba --- /dev/null +++ b/sync-for-payables/pkg/models/shared/one.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type One struct { + SourceModifiedDate *string `json:"sourceModifiedDate,omitempty"` +} + +func (o *One) GetSourceModifiedDate() *string { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/pagination.go b/sync-for-payables/pkg/models/shared/pagination.go new file mode 100644 index 000000000..c7315a6dc --- /dev/null +++ b/sync-for-payables/pkg/models/shared/pagination.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Pagination struct { + // A continuation token indicating there are more results to be fetched. Supply this value in the `continuationToken` query parameter in the next request to fetch the next set of results. Once no more results are available, the continuation token will not be present in the response. + ContinuationToken *string `json:"continuationToken,omitempty"` +} + +func (o *Pagination) GetContinuationToken() *string { + if o == nil { + return nil + } + return o.ContinuationToken +} diff --git a/sync-for-payables/pkg/models/shared/paymentmappingoptions.go b/sync-for-payables/pkg/models/shared/paymentmappingoptions.go new file mode 100644 index 000000000..f3710bd10 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/paymentmappingoptions.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// PaymentMappingOptions - Gets the bill payments mapping options for a company's accounting software +type PaymentMappingOptions struct { + BankAccounts []BankAccountMappingOption `json:"bankAccounts,omitempty"` + Pagination *Pagination `json:"pagination,omitempty"` +} + +func (o *PaymentMappingOptions) GetBankAccounts() []BankAccountMappingOption { + if o == nil { + return nil + } + return o.BankAccounts +} + +func (o *PaymentMappingOptions) GetPagination() *Pagination { + if o == nil { + return nil + } + return o.Pagination +} diff --git a/sync-for-payables/pkg/models/shared/security.go b/sync-for-payables/pkg/models/shared/security.go new file mode 100644 index 000000000..e1f80d158 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/security.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Security struct { + AuthHeader string `security:"scheme,type=apiKey,subtype=header,name=Authorization"` +} + +func (o *Security) GetAuthHeader() string { + if o == nil { + return "" + } + return o.AuthHeader +} diff --git a/sync-for-payables/pkg/models/shared/supplier.go b/sync-for-payables/pkg/models/shared/supplier.go new file mode 100644 index 000000000..c60caeda5 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/supplier.go @@ -0,0 +1,114 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +// Supplier - Suppliers are people or organizations that provide something, such as a product or service. Use the [List suppliers](https://docs.codat.io/sync-for-payables-v2-api#/operations/list-suppliers) endpoint to retrieve a list of all suppliers for a company. +// +// Suppliers' data links to accounts payable [bills](https://docs.codat.io/sync-for-payables-v2-api#/schemas/Bill). +type Supplier struct { + // Identifier for the supplier, unique to the company in the accounting software. + ID *string `json:"id,omitempty"` + // Name of the supplier as recorded in the accounting system, typically the company name. + SupplierName *string `json:"supplierName,omitempty"` + // Name of the main contact for the supplier. + ContactName *string `json:"contactName,omitempty"` + // Email address that the supplier may be contacted on. + EmailAddress *string `json:"emailAddress,omitempty"` + // Phone number that the supplier may be contacted on. + Phone *string `json:"phone,omitempty"` + // An array of Addresses. + Addresses []Address `json:"addresses,omitempty"` + // Status of the supplier. + Status *SupplierStatus `json:"status,omitempty"` + // Amount outstanding against the supplier. + Balance *decimal.Big `decimal:"number" json:"balance,omitempty"` + // Default currency the supplier's transactional data is recorded in. + DefaultCurrency *string `json:"defaultCurrency,omitempty"` + SourceModifiedDate *One `json:"sourceModifiedDate,omitempty"` +} + +func (s Supplier) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Supplier) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Supplier) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *Supplier) GetSupplierName() *string { + if o == nil { + return nil + } + return o.SupplierName +} + +func (o *Supplier) GetContactName() *string { + if o == nil { + return nil + } + return o.ContactName +} + +func (o *Supplier) GetEmailAddress() *string { + if o == nil { + return nil + } + return o.EmailAddress +} + +func (o *Supplier) GetPhone() *string { + if o == nil { + return nil + } + return o.Phone +} + +func (o *Supplier) GetAddresses() []Address { + if o == nil { + return nil + } + return o.Addresses +} + +func (o *Supplier) GetStatus() *SupplierStatus { + if o == nil { + return nil + } + return o.Status +} + +func (o *Supplier) GetBalance() *decimal.Big { + if o == nil { + return nil + } + return o.Balance +} + +func (o *Supplier) GetDefaultCurrency() *string { + if o == nil { + return nil + } + return o.DefaultCurrency +} + +func (o *Supplier) GetSourceModifiedDate() *One { + if o == nil { + return nil + } + return o.SourceModifiedDate +} diff --git a/sync-for-payables/pkg/models/shared/supplierprototype.go b/sync-for-payables/pkg/models/shared/supplierprototype.go new file mode 100644 index 000000000..d67f03635 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/supplierprototype.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +type SupplierPrototype struct { + // Name of the supplier as recorded in the accounting system, typically the company name. + SupplierName string `json:"supplierName"` + // Name of the main contact for the supplier. + ContactName *string `json:"contactName,omitempty"` + // Email address that the supplier may be contacted on. + EmailAddress *string `json:"emailAddress,omitempty"` + // Phone number that the supplier may be contacted on. + Phone *string `json:"phone,omitempty"` + // An array of Addresses. + Addresses []Address `json:"addresses,omitempty"` + // Status of the supplier. + Status SupplierStatus `json:"status"` + // Amount outstanding against the supplier. + Balance *decimal.Big `decimal:"number" json:"balance,omitempty"` + // Default currency the supplier's transactional data is recorded in. + DefaultCurrency *string `json:"defaultCurrency,omitempty"` +} + +func (s SupplierPrototype) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *SupplierPrototype) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil { + return err + } + return nil +} + +func (o *SupplierPrototype) GetSupplierName() string { + if o == nil { + return "" + } + return o.SupplierName +} + +func (o *SupplierPrototype) GetContactName() *string { + if o == nil { + return nil + } + return o.ContactName +} + +func (o *SupplierPrototype) GetEmailAddress() *string { + if o == nil { + return nil + } + return o.EmailAddress +} + +func (o *SupplierPrototype) GetPhone() *string { + if o == nil { + return nil + } + return o.Phone +} + +func (o *SupplierPrototype) GetAddresses() []Address { + if o == nil { + return nil + } + return o.Addresses +} + +func (o *SupplierPrototype) GetStatus() SupplierStatus { + if o == nil { + return SupplierStatus("") + } + return o.Status +} + +func (o *SupplierPrototype) GetBalance() *decimal.Big { + if o == nil { + return nil + } + return o.Balance +} + +func (o *SupplierPrototype) GetDefaultCurrency() *string { + if o == nil { + return nil + } + return o.DefaultCurrency +} diff --git a/sync-for-payables/pkg/models/shared/supplierref.go b/sync-for-payables/pkg/models/shared/supplierref.go new file mode 100644 index 000000000..3373584e0 --- /dev/null +++ b/sync-for-payables/pkg/models/shared/supplierref.go @@ -0,0 +1,25 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// SupplierRef - Reference to the supplier the record relates to. +type SupplierRef struct { + // The supplier's unique ID + ID string `json:"id"` + // The supplier's name + SupplierName *string `json:"supplierName,omitempty"` +} + +func (o *SupplierRef) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *SupplierRef) GetSupplierName() *string { + if o == nil { + return nil + } + return o.SupplierName +} diff --git a/sync-for-payables/pkg/models/shared/suppliers.go b/sync-for-payables/pkg/models/shared/suppliers.go new file mode 100644 index 000000000..652eedb7e --- /dev/null +++ b/sync-for-payables/pkg/models/shared/suppliers.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Suppliers struct { + Results []Supplier `json:"results,omitempty"` + Pagination *Pagination `json:"pagination,omitempty"` +} + +func (o *Suppliers) GetResults() []Supplier { + if o == nil { + return nil + } + return o.Results +} + +func (o *Suppliers) GetPagination() *Pagination { + if o == nil { + return nil + } + return o.Pagination +} diff --git a/sync-for-payables/pkg/models/shared/supplierstatus.go b/sync-for-payables/pkg/models/shared/supplierstatus.go new file mode 100644 index 000000000..3a697817b --- /dev/null +++ b/sync-for-payables/pkg/models/shared/supplierstatus.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// SupplierStatus - Status of the supplier. +type SupplierStatus string + +const ( + SupplierStatusUnknown SupplierStatus = "Unknown" + SupplierStatusActive SupplierStatus = "Active" + SupplierStatusArchived SupplierStatus = "Archived" +) + +func (e SupplierStatus) ToPointer() *SupplierStatus { + return &e +} +func (e *SupplierStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Unknown": + fallthrough + case "Active": + fallthrough + case "Archived": + *e = SupplierStatus(v) + return nil + default: + return fmt.Errorf("invalid value for SupplierStatus: %v", v) + } +} diff --git a/sync-for-payables/pkg/models/shared/taxratemappingoption.go b/sync-for-payables/pkg/models/shared/taxratemappingoption.go new file mode 100644 index 000000000..4688c1d5f --- /dev/null +++ b/sync-for-payables/pkg/models/shared/taxratemappingoption.go @@ -0,0 +1,109 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "github.com/ericlagergren/decimal" +) + +// TaxRateStatus - Status of the tax rate in the accounting software. +// - `Active` - An active tax rate in use by a company. +// - `Archived` - A tax rate that has been archived or is inactive in the accounting software. +type TaxRateStatus string + +const ( + TaxRateStatusActive TaxRateStatus = "Active" + TaxRateStatusArchived TaxRateStatus = "Archived" +) + +func (e TaxRateStatus) ToPointer() *TaxRateStatus { + return &e +} +func (e *TaxRateStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "Active": + fallthrough + case "Archived": + *e = TaxRateStatus(v) + return nil + default: + return fmt.Errorf("invalid value for TaxRateStatus: %v", v) + } +} + +type TaxRateMappingOption struct { + // Identifier for the tax rate, unique for the company in the accounting software. + ID *string `json:"id,omitempty"` + // Codat-augmented name of the tax rate in the accounting software. + Name *string `json:"name,omitempty"` + // Code for the tax rate from the accounting software. + Code *string `json:"code,omitempty"` + // See Effective tax rates description. + EffectiveTaxRate *decimal.Big `decimal:"number" json:"effectiveTaxRate,omitempty"` + // Total (not compounded) sum of the components of a tax rate. + TotalTaxRate *decimal.Big `decimal:"number" json:"totalTaxRate,omitempty"` + // Status of the tax rate in the accounting software. + // - `Active` - An active tax rate in use by a company. + // - `Archived` - A tax rate that has been archived or is inactive in the accounting software. + Status *TaxRateStatus `json:"status,omitempty"` +} + +func (t TaxRateMappingOption) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *TaxRateMappingOption) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, false); err != nil { + return err + } + return nil +} + +func (o *TaxRateMappingOption) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *TaxRateMappingOption) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *TaxRateMappingOption) GetCode() *string { + if o == nil { + return nil + } + return o.Code +} + +func (o *TaxRateMappingOption) GetEffectiveTaxRate() *decimal.Big { + if o == nil { + return nil + } + return o.EffectiveTaxRate +} + +func (o *TaxRateMappingOption) GetTotalTaxRate() *decimal.Big { + if o == nil { + return nil + } + return o.TotalTaxRate +} + +func (o *TaxRateMappingOption) GetStatus() *TaxRateStatus { + if o == nil { + return nil + } + return o.Status +} diff --git a/sync-for-payables/pkg/models/webhooks/clientratelimitreached.go b/sync-for-payables/pkg/models/webhooks/clientratelimitreached.go new file mode 100644 index 000000000..93962f189 --- /dev/null +++ b/sync-for-payables/pkg/models/webhooks/clientratelimitreached.go @@ -0,0 +1,18 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type ClientRateLimitReachedResponse1 struct { + HTTPMeta shared.HTTPMetadata `json:"-"` +} + +func (o *ClientRateLimitReachedResponse1) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/sync-for-payables/pkg/models/webhooks/clientratelimitreset.go b/sync-for-payables/pkg/models/webhooks/clientratelimitreset.go new file mode 100644 index 000000000..c5c7ff1cf --- /dev/null +++ b/sync-for-payables/pkg/models/webhooks/clientratelimitreset.go @@ -0,0 +1,18 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" +) + +type ClientRateLimitResetResponse1 struct { + HTTPMeta shared.HTTPMetadata `json:"-"` +} + +func (o *ClientRateLimitResetResponse1) GetHTTPMeta() shared.HTTPMetadata { + if o == nil { + return shared.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/sync-for-payables/pkg/retry/config.go b/sync-for-payables/pkg/retry/config.go new file mode 100644 index 000000000..c051b0a46 --- /dev/null +++ b/sync-for-payables/pkg/retry/config.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package retry + +type BackoffStrategy struct { + InitialInterval int + MaxInterval int + Exponent float64 + MaxElapsedTime int +} + +type Config struct { + Strategy string + Backoff *BackoffStrategy + RetryConnectionErrors bool +} diff --git a/sync-for-payables/pkg/types/bigint.go b/sync-for-payables/pkg/types/bigint.go new file mode 100644 index 000000000..9c6a086d5 --- /dev/null +++ b/sync-for-payables/pkg/types/bigint.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "fmt" + "math/big" +) + +// MustNewBigIntFromString returns an instance of big.Int from a string +// The string is assumed to be base 10 and if it is not a valid big.Int +// then the function panics. +// Avoid using this function in production code. +func MustNewBigIntFromString(s string) *big.Int { + i, ok := new(big.Int).SetString(s, 10) + if !ok { + panic(fmt.Errorf("failed to parse string as big.Int")) + } + + return i +} diff --git a/sync-for-payables/pkg/types/date.go b/sync-for-payables/pkg/types/date.go new file mode 100644 index 000000000..5b2782f21 --- /dev/null +++ b/sync-for-payables/pkg/types/date.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "encoding/json" + "fmt" + "strings" + "time" +) + +// Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02". +type Date struct { + time.Time +} + +var ( + _ json.Marshaler = &Date{} + _ json.Unmarshaler = &Date{} + _ fmt.Stringer = &Date{} +) + +// NewDate returns an instance of Date from a time.Time. +func NewDate(t time.Time) *Date { + d := DateFromTime(t) + return &d +} + +// DateFromTime returns a Date from a time.Time. +func DateFromTime(t time.Time) Date { + return Date{t} +} + +// NewDateFromString returns an instance of Date from a string formatted as "2006-01-02". +func NewDateFromString(str string) (*Date, error) { + d, err := DateFromString(str) + if err != nil { + return nil, err + } + + return &d, nil +} + +// DateFromString returns a Date from a string formatted as "2006-01-02". +func DateFromString(str string) (Date, error) { + var d Date + var err error + + d.Time, err = time.Parse("2006-01-02", str) + return d, err +} + +// MustNewDateFromString returns an instance of Date from a string formatted as "2006-01-02" or panics. +// Avoid using this function in production code. +func MustNewDateFromString(str string) *Date { + d := MustDateFromString(str) + return &d +} + +// MustDateFromString returns a Date from a string formatted as "2006-01-02" or panics. +// Avoid using this function in production code. +func MustDateFromString(str string) Date { + d, err := DateFromString(str) + if err != nil { + panic(err) + } + return d +} + +func (d Date) GetTime() time.Time { + return d.Time +} + +func (d Date) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"%s"`, d.Time.Format("2006-01-02"))), nil +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var err error + + str := string(data) + str = strings.Trim(str, `"`) + + d.Time, err = time.Parse("2006-01-02", str) + return err +} + +func (d Date) String() string { + return d.Time.Format("2006-01-02") +} diff --git a/sync-for-payables/pkg/types/datetime.go b/sync-for-payables/pkg/types/datetime.go new file mode 100644 index 000000000..3eff332da --- /dev/null +++ b/sync-for-payables/pkg/types/datetime.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import "time" + +// MustTimeFromString returns a time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. +// Avoid using this function in production code. +func MustTimeFromString(str string) time.Time { + t, err := time.Parse(time.RFC3339, str) + if err != nil { + panic(err) + } + + return t +} + +// MustNewTimeFromString returns an instance of time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. +// Avoid using this function in production code. +func MustNewTimeFromString(str string) *time.Time { + t := MustTimeFromString(str) + return &t +} diff --git a/sync-for-payables/pkg/types/decimal.go b/sync-for-payables/pkg/types/decimal.go new file mode 100644 index 000000000..d8429bc6b --- /dev/null +++ b/sync-for-payables/pkg/types/decimal.go @@ -0,0 +1,20 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "fmt" + + "github.com/ericlagergren/decimal" +) + +// MustNewDecimalFromString returns an instance of Decimal from a string +// Avoid using this function in production code. +func MustNewDecimalFromString(s string) *decimal.Big { + d, ok := new(decimal.Big).SetString(s) + if !ok { + panic(fmt.Errorf("failed to parse string as decimal.Big")) + } + + return d +} diff --git a/sync-for-payables/pkg/types/pointers.go b/sync-for-payables/pkg/types/pointers.go new file mode 100644 index 000000000..35c439d26 --- /dev/null +++ b/sync-for-payables/pkg/types/pointers.go @@ -0,0 +1,11 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +func String(s string) *string { return &s } +func Bool(b bool) *bool { return &b } +func Int(i int) *int { return &i } +func Int64(i int64) *int64 { return &i } +func Float32(f float32) *float32 { return &f } +func Float64(f float64) *float64 { return &f } +func Pointer[T any](v T) *T { return &v } diff --git a/sync-for-payables/pkg/utils/contenttype.go b/sync-for-payables/pkg/utils/contenttype.go new file mode 100644 index 000000000..f6487e01e --- /dev/null +++ b/sync-for-payables/pkg/utils/contenttype.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "fmt" + "mime" + "strings" +) + +func MatchContentType(contentType string, pattern string) bool { + if contentType == "" { + contentType = "application/octet-stream" + } + + if contentType == pattern || pattern == "*" || pattern == "*/*" { + return true + } + + mediaType, _, err := mime.ParseMediaType(contentType) + if err != nil { + return false + } + + if mediaType == pattern { + return true + } + + parts := strings.Split(mediaType, "/") + if len(parts) == 2 { + if fmt.Sprintf("%s/*", parts[0]) == pattern || fmt.Sprintf("*/%s", parts[1]) == pattern { + return true + } + } + + return false +} diff --git a/sync-for-payables/pkg/utils/form.go b/sync-for-payables/pkg/utils/form.go new file mode 100644 index 000000000..2864977cb --- /dev/null +++ b/sync-for-payables/pkg/utils/form.go @@ -0,0 +1,117 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "fmt" + "math/big" + "net/url" + "reflect" + "strings" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/types" +) + +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { + + formValues := url.Values{} + + if isNil(objType, objValue) { + return formValues + } + + if objType.Kind() == reflect.Pointer { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Struct: + switch objValue.Interface().(type) { + case time.Time: + formValues.Add(paramName, valToString(objValue.Interface())) + case types.Date: + formValues.Add(paramName, valToString(objValue.Interface())) + case big.Int: + formValues.Add(paramName, valToString(objValue.Interface())) + case decimal.Big: + formValues.Add(paramName, valToString(objValue.Interface())) + default: + var items []string + + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if valType.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + fieldName := getFieldName(fieldType) + if fieldName == "" { + continue + } + + if explode { + formValues.Add(fieldName, valToString(valType.Interface())) + } else { + items = append(items, fmt.Sprintf("%s%s%s", fieldName, delimiter, valToString(valType.Interface()))) + } + } + + if len(items) > 0 { + formValues.Add(paramName, strings.Join(items, delimiter)) + } + } + case reflect.Map: + items := []string{} + + iter := objValue.MapRange() + for iter.Next() { + if explode { + formValues.Add(iter.Key().String(), valToString(iter.Value().Interface())) + } else { + items = append(items, fmt.Sprintf("%s%s%s", iter.Key().String(), delimiter, valToString(iter.Value().Interface()))) + } + } + + if len(items) > 0 { + formValues.Add(paramName, strings.Join(items, delimiter)) + } + case reflect.Slice, reflect.Array: + values := parseDelimitedArray(explode, objValue, delimiter) + for _, v := range values { + formValues.Add(paramName, v) + } + default: + formValues.Add(paramName, valToString(objValue.Interface())) + } + + return formValues +} + +func parseDelimitedArray(explode bool, objValue reflect.Value, delimiter string) []string { + values := []string{} + items := []string{} + + for i := 0; i < objValue.Len(); i++ { + if explode { + values = append(values, valToString(objValue.Index(i).Interface())) + } else { + items = append(items, valToString(objValue.Index(i).Interface())) + } + } + + if len(items) > 0 { + values = append(values, strings.Join(items, delimiter)) + } + + return values +} diff --git a/sync-for-payables/pkg/utils/headers.go b/sync-for-payables/pkg/utils/headers.go new file mode 100644 index 000000000..a07608bdc --- /dev/null +++ b/sync-for-payables/pkg/utils/headers.go @@ -0,0 +1,124 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "net/http" + "reflect" + "strings" +) + +func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) { + globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{}) + if globals != nil { + _ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated) + } +} + +func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string { + headerParamsStructType, headerParamsValType := dereferencePointers(reflect.TypeOf(headers), reflect.ValueOf(headers)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < headerParamsStructType.NumField(); i++ { + fieldType := headerParamsStructType.Field(i) + valType := headerParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) + if tag == nil { + continue + } + + value := serializeHeader(fieldType.Type, valType, tag.Explode) + if value != "" { + reqHeaders.Add(tag.ParamName, value) + } + } + + return globalsAlreadyPopulated +} + +func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { + if isNil(objType, objValue) { + return "" + } + + if objType.Kind() == reflect.Pointer { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Struct: + items := []string{} + + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) + if tag == nil { + continue + } + + fieldName := tag.ParamName + + if fieldName == "" { + continue + } + + if explode { + items = append(items, fmt.Sprintf("%s=%s", fieldName, valToString(valType.Interface()))) + } else { + items = append(items, fieldName, valToString(valType.Interface())) + } + } + + return strings.Join(items, ",") + case reflect.Map: + items := []string{} + + iter := objValue.MapRange() + for iter.Next() { + if explode { + items = append(items, fmt.Sprintf("%s=%s", iter.Key().String(), valToString(iter.Value().Interface()))) + } else { + items = append(items, iter.Key().String(), valToString(iter.Value().Interface())) + } + } + + return strings.Join(items, ",") + case reflect.Slice, reflect.Array: + items := []string{} + + for i := 0; i < objValue.Len(); i++ { + items = append(items, valToString(objValue.Index(i).Interface())) + } + + return strings.Join(items, ",") + default: + return valToString(objValue.Interface()) + } +} diff --git a/sync-for-payables/pkg/utils/json.go b/sync-for-payables/pkg/utils/json.go new file mode 100644 index 000000000..bac99dded --- /dev/null +++ b/sync-for-payables/pkg/utils/json.go @@ -0,0 +1,675 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "encoding/json" + "fmt" + "math/big" + "reflect" + "strconv" + "strings" + "time" + "unsafe" + + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/types" + + "github.com/ericlagergren/decimal" +) + +func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error) { + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + + switch { + case isModelType(typ): + if topLevel { + return json.Marshal(v) + } + + if isNil(typ, val) { + return []byte("null"), nil + } + + out := map[string]json.RawMessage{} + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + fieldName := field.Name + + omitEmpty := false + jsonTag := field.Tag.Get("json") + if jsonTag != "" { + for _, tag := range strings.Split(jsonTag, ",") { + if tag == "omitempty" { + omitEmpty = true + } else { + fieldName = tag + } + } + } + + if isNil(field.Type, fieldVal) && field.Tag.Get("const") == "" { + if omitEmpty { + continue + } + } + + if !field.IsExported() && field.Tag.Get("const") == "" { + continue + } + + additionalProperties := field.Tag.Get("additionalProperties") + if fieldName == "-" && additionalProperties == "" { + continue + } + + if additionalProperties == "true" { + if isNil(field.Type, fieldVal) { + continue + } + fieldVal := trueReflectValue(fieldVal) + if fieldVal.Type().Kind() != reflect.Map { + return nil, fmt.Errorf("additionalProperties must be a map") + } + + for _, key := range fieldVal.MapKeys() { + r, err := marshalValue(fieldVal.MapIndex(key).Interface(), field.Tag) + if err != nil { + return nil, err + } + + out[key.String()] = r + } + + continue + } + + var fv interface{} + + if field.IsExported() { + fv = fieldVal.Interface() + } else { + pt := reflect.New(typ).Elem() + pt.Set(val) + + pf := pt.Field(i) + + fv = reflect.NewAt(pf.Type(), unsafe.Pointer(pf.UnsafeAddr())).Elem().Interface() + } + + r, err := marshalValue(fv, field.Tag) + if err != nil { + return nil, err + } + + out[fieldName] = r + } + + return json.Marshal(out) + default: + return marshalValue(v, tag) + } +} + +func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, disallowUnknownFields bool) error { + if reflect.TypeOf(v).Kind() != reflect.Ptr { + return fmt.Errorf("v must be a pointer") + } + + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + + switch { + case isModelType(typ): + if topLevel || bytes.Equal(b, []byte("null")) { + d := json.NewDecoder(bytes.NewReader(b)) + if disallowUnknownFields { + d.DisallowUnknownFields() + } + return d.Decode(v) + } + + var unmarhsaled map[string]json.RawMessage + + if err := json.Unmarshal(b, &unmarhsaled); err != nil { + return err + } + + var additionalPropertiesField *reflect.StructField + var additionalPropertiesValue *reflect.Value + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + fieldName := field.Name + + jsonTag := field.Tag.Get("json") + if jsonTag != "" { + for _, tag := range strings.Split(jsonTag, ",") { + if tag != "omitempty" { + fieldName = tag + } + } + } + + if field.Tag.Get("additionalProperties") == "true" { + additionalPropertiesField = &field + additionalPropertiesValue = &fieldVal + continue + } + + // If we receive a value for a const field ignore it but mark it as unmarshaled + if field.Tag.Get("const") != "" { + if r, ok := unmarhsaled[fieldName]; ok { + val := string(r) + + if strings.HasPrefix(val, `"`) && strings.HasSuffix(val, `"`) { + var err error + val, err = strconv.Unquote(val) + if err != nil { + return fmt.Errorf("failed to unquote const field `%s` value `%s`: %w", fieldName, val, err) + } + } + constValue := field.Tag.Get("const") + if val != constValue { + return fmt.Errorf("const field `%s` does not match expected value `%s` got `%s`", fieldName, constValue, val) + } + + delete(unmarhsaled, fieldName) + } + } else if !field.IsExported() { + continue + } + + value, ok := unmarhsaled[fieldName] + if !ok { + defaultTag := field.Tag.Get("default") + if defaultTag != "" { + value = handleDefaultConstValue(defaultTag, fieldVal.Interface(), field.Tag) + ok = true + } + } else { + delete(unmarhsaled, fieldName) + } + + if ok { + if err := unmarshalValue(value, fieldVal, field.Tag, disallowUnknownFields); err != nil { + return err + } + } + } + + keys := make([]string, 0, len(unmarhsaled)) + for k := range unmarhsaled { + keys = append(keys, k) + } + + if len(keys) > 0 { + if disallowUnknownFields && (additionalPropertiesField == nil || additionalPropertiesValue == nil) { + return fmt.Errorf("unknown fields: %v", keys) + } + + if additionalPropertiesField != nil && additionalPropertiesValue != nil { + typeOfMap := additionalPropertiesField.Type + if additionalPropertiesValue.Type().Kind() == reflect.Interface { + typeOfMap = reflect.TypeOf(map[string]interface{}{}) + } else if additionalPropertiesValue.Type().Kind() != reflect.Map { + return fmt.Errorf("additionalProperties must be a map") + } + + mapValue := reflect.MakeMap(typeOfMap) + + for key, value := range unmarhsaled { + val := reflect.New(typeOfMap.Elem()) + + if err := unmarshalValue(value, val, additionalPropertiesField.Tag, disallowUnknownFields); err != nil { + return err + } + + if val.Elem().Type().String() == typeOfMap.Elem().String() { + mapValue.SetMapIndex(reflect.ValueOf(key), val.Elem()) + } else { + mapValue.SetMapIndex(reflect.ValueOf(key), trueReflectValue(val)) + } + + } + if additionalPropertiesValue.Type().Kind() == reflect.Interface { + additionalPropertiesValue.Set(mapValue) + } else { + additionalPropertiesValue.Set(mapValue) + } + } + } + default: + return unmarshalValue(b, reflect.ValueOf(v), tag, disallowUnknownFields) + } + + return nil +} + +func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) { + constTag := tag.Get("const") + if constTag != "" { + return handleDefaultConstValue(constTag, v, tag), nil + } + + if isNil(reflect.TypeOf(v), reflect.ValueOf(v)) { + defaultTag := tag.Get("default") + if defaultTag != "" { + return handleDefaultConstValue(defaultTag, v, tag), nil + } + + return []byte("null"), nil + } + + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + switch typ.Kind() { + case reflect.Int64: + format := tag.Get("integer") + if format == "string" { + b := val.Interface().(int64) + return []byte(fmt.Sprintf(`"%d"`, b)), nil + } + case reflect.Float64: + format := tag.Get("number") + if format == "string" { + b := val.Interface().(float64) + return []byte(fmt.Sprintf(`"%g"`, b)), nil + } + case reflect.Map: + if isNil(typ, val) { + return []byte("null"), nil + } + + out := map[string]json.RawMessage{} + + for _, key := range val.MapKeys() { + itemVal := val.MapIndex(key) + + if isNil(itemVal.Type(), itemVal) { + out[key.String()] = []byte("null") + continue + } + + r, err := marshalValue(itemVal.Interface(), tag) + if err != nil { + return nil, err + } + + out[key.String()] = r + } + + return json.Marshal(out) + case reflect.Slice, reflect.Array: + if isNil(typ, val) { + return []byte("null"), nil + } + + out := []json.RawMessage{} + + for i := 0; i < val.Len(); i++ { + itemVal := val.Index(i) + + if isNil(itemVal.Type(), itemVal) { + out = append(out, []byte("null")) + continue + } + + r, err := marshalValue(itemVal.Interface(), tag) + if err != nil { + return nil, err + } + + out = append(out, r) + } + + return json.Marshal(out) + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + return []byte(fmt.Sprintf(`"%s"`, val.Interface().(time.Time).Format(time.RFC3339Nano))), nil + case reflect.TypeOf(big.Int{}): + format := tag.Get("bigint") + if format == "string" { + b := val.Interface().(big.Int) + return []byte(fmt.Sprintf(`"%s"`, (&b).String())), nil + } + case reflect.TypeOf(decimal.Big{}): + format := tag.Get("decimal") + if format == "number" { + b := val.Interface().(decimal.Big) + f, ok := (&b).Float64() + if ok { + return []byte(b.String()), nil + } + + return []byte(fmt.Sprintf(`%f`, f)), nil + } + } + } + + return json.Marshal(v) +} + +func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.StructTag) json.RawMessage { + if tagValue == "null" { + return []byte("null") + } + + typ := dereferenceTypePointer(reflect.TypeOf(val)) + switch typ { + case reflect.TypeOf(time.Time{}): + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + case reflect.TypeOf(big.Int{}): + bigIntTag := tag.Get("bigint") + if bigIntTag == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(int64(0)): + format := tag.Get("integer") + if format == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(float64(0)): + format := tag.Get("number") + if format == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(decimal.Big{}): + decimalTag := tag.Get("decimal") + if decimalTag != "number" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(types.Date{}): + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + default: + if typ.Kind() == reflect.String { + return []byte(fmt.Sprintf("%q", tagValue)) + } + } + + return []byte(tagValue) +} + +func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTag, disallowUnknownFields bool) error { + if bytes.Equal(value, []byte("null")) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + typ := dereferenceTypePointer(v.Type()) + + switch typ.Kind() { + case reflect.Int64: + var b int64 + + format := tag.Get("integer") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var err error + b, err = strconv.ParseInt(s, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse string as int64: %w", err) + } + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + } + case reflect.Float64: + var b float64 + + format := tag.Get("number") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var err error + b, err = strconv.ParseFloat(s, 64) + if err != nil { + return fmt.Errorf("failed to parse string as float64: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + } + case reflect.Map: + if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + var unmarhsaled map[string]json.RawMessage + + if err := json.Unmarshal(value, &unmarhsaled); err != nil { + return err + } + + m := reflect.MakeMap(typ) + + for k, value := range unmarhsaled { + itemVal := reflect.New(typ.Elem()) + + if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { + return err + } + + m.SetMapIndex(reflect.ValueOf(k), itemVal.Elem()) + } + + v.Set(m) + return nil + case reflect.Slice, reflect.Array: + var unmarshaled []json.RawMessage + + if err := json.Unmarshal(value, &unmarshaled); err != nil { + return err + } + + arrVal := reflect.MakeSlice(typ, len(unmarshaled), len(unmarshaled)) + + for index, value := range unmarshaled { + itemVal := reflect.New(typ.Elem()) + + if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { + return err + } + + arrVal.Index(index).Set(itemVal.Elem()) + } + + if v.Kind() == reflect.Pointer { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(arrVal) + return nil + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + t, err := time.Parse(time.RFC3339Nano, s) + if err != nil { + return fmt.Errorf("failed to parse string as time.Time: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(t)) + return nil + case reflect.TypeOf(big.Int{}): + var b *big.Int + + format := tag.Get("bigint") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var ok bool + b, ok = new(big.Int).SetString(s, 10) + if !ok { + return fmt.Errorf("failed to parse string as big.Int") + } + } else { + if err := json.Unmarshal(value, &b); err != nil { + return err + } + } + + if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + case reflect.TypeOf(decimal.Big{}): + var d *decimal.Big + format := tag.Get("decimal") + if format == "number" { + var ok bool + d, ok = new(decimal.Big).SetString(string(value)) + if !ok { + return fmt.Errorf("failed to parse number as decimal.Big") + } + } else { + if err := json.Unmarshal(value, &d); err != nil { + return err + } + } + + if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { + v = v.Elem() + } + + v.Set(reflect.ValueOf(d)) + return nil + case reflect.TypeOf(types.Date{}): + var s string + + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + d, err := types.DateFromString(s) + if err != nil { + return fmt.Errorf("failed to parse string as types.Date: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(d)) + return nil + } + } + + var val interface{} + + if v.CanAddr() { + val = v.Addr().Interface() + } else { + val = v.Interface() + } + + d := json.NewDecoder(bytes.NewReader(value)) + if disallowUnknownFields { + d.DisallowUnknownFields() + } + return d.Decode(val) +} + +func dereferencePointers(typ reflect.Type, val reflect.Value) (reflect.Type, reflect.Value) { + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return typ, val + } + + return dereferencePointers(typ, val) +} + +func dereferenceTypePointer(typ reflect.Type) reflect.Type { + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + } else { + return typ + } + + return dereferenceTypePointer(typ) +} + +func isComplexValueType(typ reflect.Type) bool { + switch typ.Kind() { + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + fallthrough + case reflect.TypeOf(big.Int{}): + fallthrough + case reflect.TypeOf(decimal.Big{}): + fallthrough + case reflect.TypeOf(types.Date{}): + return true + } + } + + return false +} + +func isModelType(typ reflect.Type) bool { + if isComplexValueType(typ) { + return false + } + + if typ.Kind() == reflect.Struct { + return true + } + + return false +} diff --git a/sync-for-payables/pkg/utils/pathparams.go b/sync-for-payables/pkg/utils/pathparams.go new file mode 100644 index 000000000..0c655dc74 --- /dev/null +++ b/sync-for-payables/pkg/utils/pathparams.go @@ -0,0 +1,172 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "math/big" + "net/url" + "reflect" + "strings" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/types" +) + +func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) { + uri := strings.TrimSuffix(serverURL, "/") + path + + parsedParameters := map[string]string{} + + globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{}) + if err != nil { + return "", err + } + + if globals != nil { + _, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated) + if err != nil { + return "", err + } + } + + // TODO should we handle the case where there are no matching path params? + return ReplaceParameters(uri, parsedParameters), nil +} + +func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) { + pathParamsStructType, pathParamsValType := dereferencePointers(reflect.TypeOf(pathParams), reflect.ValueOf(pathParams)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < pathParamsStructType.NumField(); i++ { + fieldType := pathParamsStructType.Field(i) + valType := pathParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + requestTag := getRequestTag(fieldType) + if requestTag != nil { + continue + } + + ppTag := parseParamTag(pathParamTagKey, fieldType, "simple", false) + if ppTag == nil { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + if ppTag.Serialization != "" { + vals, err := populateSerializedParams(ppTag, fieldType.Type, valType) + if err != nil { + return nil, err + } + for k, v := range vals { + parsedParameters[k] = url.PathEscape(v) + } + } else { + // TODO: support other styles + switch ppTag.Style { + case "simple": + simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode) + for k, v := range simpleParams { + parsedParameters[k] = v + } + } + } + } + + return globalsAlreadyPopulated, nil +} + +func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { + pathParams := make(map[string]string) + + if isNil(objType, objValue) { + return nil + } + + if objType.Kind() == reflect.Ptr { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Array, reflect.Slice: + if objValue.Len() == 0 { + return nil + } + var ppVals []string + for i := 0; i < objValue.Len(); i++ { + ppVals = append(ppVals, valToString(objValue.Index(i).Interface())) + } + pathParams[parentName] = strings.Join(ppVals, ",") + case reflect.Map: + if objValue.Len() == 0 { + return nil + } + var ppVals []string + objMap := objValue.MapRange() + for objMap.Next() { + if explode { + ppVals = append(ppVals, fmt.Sprintf("%s=%s", objMap.Key().String(), valToString(objMap.Value().Interface()))) + } else { + ppVals = append(ppVals, fmt.Sprintf("%s,%s", objMap.Key().String(), valToString(objMap.Value().Interface()))) + } + } + pathParams[parentName] = strings.Join(ppVals, ",") + case reflect.Struct: + switch objValue.Interface().(type) { + case time.Time: + pathParams[parentName] = valToString(objValue.Interface()) + case types.Date: + pathParams[parentName] = valToString(objValue.Interface()) + case big.Int: + pathParams[parentName] = valToString(objValue.Interface()) + case decimal.Big: + pathParams[parentName] = valToString(objValue.Interface()) + default: + var ppVals []string + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + ppTag := parseParamTag(pathParamTagKey, fieldType, "simple", explode) + if ppTag == nil { + continue + } + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + if explode { + ppVals = append(ppVals, fmt.Sprintf("%s=%s", ppTag.ParamName, valToString(valType.Interface()))) + } else { + ppVals = append(ppVals, fmt.Sprintf("%s,%s", ppTag.ParamName, valToString(valType.Interface()))) + } + } + pathParams[parentName] = strings.Join(ppVals, ",") + } + default: + pathParams[parentName] = valToString(objValue.Interface()) + } + + return pathParams +} diff --git a/sync-for-payables/pkg/utils/queryparams.go b/sync-for-payables/pkg/utils/queryparams.go new file mode 100644 index 000000000..ac0f5a8c5 --- /dev/null +++ b/sync-for-payables/pkg/utils/queryparams.go @@ -0,0 +1,259 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "encoding/json" + "fmt" + "math/big" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/types" +) + +func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error { + // Query parameters may already be present from overriding URL + if req.URL.RawQuery != "" { + return nil + } + + values := url.Values{} + + globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{}) + if err != nil { + return err + } + + if globals != nil { + _, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated) + if err != nil { + return err + } + } + + req.URL.RawQuery = values.Encode() + + return nil +} + +func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { + queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), reflect.ValueOf(queryParams)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < queryParamsStructType.NumField(); i++ { + fieldType := queryParamsStructType.Field(i) + valType := queryParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + requestTag := getRequestTag(fieldType) + if requestTag != nil { + continue + } + + qpTag := parseQueryParamTag(fieldType) + if qpTag == nil { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + if qpTag.Serialization != "" { + vals, err := populateSerializedParams(qpTag, fieldType.Type, valType) + if err != nil { + return nil, err + } + for k, v := range vals { + values.Add(k, v) + } + } else { + switch qpTag.Style { + case "deepObject": + vals := populateDeepObjectParams(qpTag, fieldType.Type, valType) + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + case "form": + vals := populateFormParams(qpTag, fieldType.Type, valType, ",") + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + case "pipeDelimited": + vals := populateFormParams(qpTag, fieldType.Type, valType, "|") + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + default: + return nil, fmt.Errorf("unsupported style: %s", qpTag.Style) + } + } + } + + return globalsAlreadyPopulated, nil +} + +func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) { + if isNil(objType, objValue) { + return nil, nil + } + + if objType.Kind() == reflect.Pointer { + objValue = objValue.Elem() + } + + values := map[string]string{} + + switch tag.Serialization { + case "json": + data, err := json.Marshal(objValue.Interface()) + if err != nil { + return nil, fmt.Errorf("error marshaling json: %v", err) + } + values[tag.ParamName] = string(data) + } + + return values, nil +} + +func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { + values := url.Values{} + + if isNil(objType, objValue) { + return values + } + + if objValue.Kind() == reflect.Pointer { + objValue = objValue.Elem() + } + + switch objValue.Kind() { + case reflect.Map: + populateDeepObjectParamsMap(values, tag.ParamName, objValue) + case reflect.Struct: + populateDeepObjectParamsStruct(values, tag.ParamName, objValue) + } + + return values +} + +func populateDeepObjectParamsArray(qsValues url.Values, priorScope string, value reflect.Value) { + if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { + return + } + + for i := 0; i < value.Len(); i++ { + qsValues.Add(priorScope, valToString(value.Index(i).Interface())) + } +} + +func populateDeepObjectParamsMap(qsValues url.Values, priorScope string, mapValue reflect.Value) { + if mapValue.Kind() != reflect.Map { + return + } + + iter := mapValue.MapRange() + + for iter.Next() { + scope := priorScope + "[" + iter.Key().String() + "]" + iterValue := iter.Value() + + switch iterValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, iterValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, iterValue) + default: + qsValues.Add(scope, valToString(iterValue.Interface())) + } + } +} + +func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, structValue reflect.Value) { + if structValue.Kind() != reflect.Struct { + return + } + + structType := structValue.Type() + + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + fieldValue := structValue.Field(i) + + if isNil(field.Type, fieldValue) { + continue + } + + if fieldValue.Kind() == reflect.Pointer { + fieldValue = fieldValue.Elem() + } + + qpTag := parseQueryParamTag(field) + + if qpTag == nil { + continue + } + + scope := priorScope + "[" + qpTag.ParamName + "]" + + switch fieldValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, fieldValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, fieldValue) + case reflect.Struct: + switch fieldValue.Type() { + case reflect.TypeOf(big.Int{}), reflect.TypeOf(decimal.Big{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): + qsValues.Add(scope, valToString(fieldValue.Interface())) + + continue + } + + populateDeepObjectParamsStruct(qsValues, scope, fieldValue) + default: + qsValues.Add(scope, valToString(fieldValue.Interface())) + } + } +} + +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { + qpTag := parseQueryParamTag(fieldType) + if qpTag == nil { + return "" + } + + return qpTag.ParamName + }) +} + +type paramTag struct { + Style string + Explode bool + ParamName string + Serialization string +} + +func parseQueryParamTag(field reflect.StructField) *paramTag { + return parseParamTag(queryParamTagKey, field, "form", true) +} diff --git a/sync-for-payables/pkg/utils/requestbody.go b/sync-for-payables/pkg/utils/requestbody.go new file mode 100644 index 000000000..000226ef9 --- /dev/null +++ b/sync-for-payables/pkg/utils/requestbody.go @@ -0,0 +1,416 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/url" + "reflect" + "regexp" +) + +const ( + requestTagKey = "request" + multipartFormTagKey = "multipartForm" + formTagKey = "form" +) + +var ( + jsonEncodingRegex = regexp.MustCompile(`(application|text)\/.*?\+*json.*`) + multipartEncodingRegex = regexp.MustCompile(`multipart\/.*`) + urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) +) + +func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag) + if err != nil { + return nil, "", fmt.Errorf("error serializing request body: %w", err) + } + + if bodyReader == nil && !optional { + return nil, "", fmt.Errorf("request body is required") + } + + return bodyReader, contentType, nil +} + +func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + requestStructType := reflect.TypeOf(request) + requestValType := reflect.ValueOf(request) + + if isNil(requestStructType, requestValType) { + if !nullable && optional { + return nil, "", nil + } + + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], requestValType, tag) + } + + if requestStructType.Kind() == reflect.Pointer { + requestStructType = requestStructType.Elem() + requestValType = requestValType.Elem() + } + + if requestStructType.Kind() != reflect.Struct { + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], requestValType, tag) + } + + requestField, ok := requestStructType.FieldByName(requestFieldName) + + if ok { + tag := getRequestTag(requestField) + if tag != nil { + // request object (non-flattened) + requestVal := requestValType.FieldByName(requestFieldName) + val := reflect.ValueOf(requestVal.Interface()) + if isNil(requestField.Type, requestVal) { + if !nullable && optional { + return nil, "", nil + } + + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) + } + + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) + } + } + + // flattened request object + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], reflect.ValueOf(request), tag) +} + +func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (io.Reader, string, error) { + buf := &bytes.Buffer{} + + if isNil(val.Type(), val) { + // TODO: what does a null mean for other content types? Just returning an empty buffer for now + if jsonEncodingRegex.MatchString(mediaType) { + if _, err := buf.Write([]byte("null")); err != nil { + return nil, "", err + } + } + + return buf, mediaType, nil + } + + switch { + case jsonEncodingRegex.MatchString(mediaType): + data, err := MarshalJSON(val.Interface(), reflect.StructTag(tag), true) + if err != nil { + return nil, "", err + } + + if _, err := buf.Write(data); err != nil { + return nil, "", err + } + case multipartEncodingRegex.MatchString(mediaType): + var err error + mediaType, err = encodeMultipartFormData(buf, val.Interface()) + if err != nil { + return nil, "", err + } + case urlEncodedEncodingRegex.MatchString(mediaType): + if err := encodeFormData(fieldName, buf, val.Interface()); err != nil { + return nil, "", err + } + case val.Type().Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()): + return val.Interface().(io.Reader), mediaType, nil + default: + val = reflect.Indirect(val) + + switch { + case val.Type().Kind() == reflect.String: + if _, err := buf.WriteString(valToString(val.Interface())); err != nil { + return nil, "", err + } + case reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)): + if _, err := buf.Write(val.Interface().([]byte)); err != nil { + return nil, "", err + } + default: + return nil, "", fmt.Errorf("invalid request body type %s for mediaType %s", val.Type(), mediaType) + } + } + + return buf, mediaType, nil +} + +func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { + requestStructType := reflect.TypeOf(data) + requestValType := reflect.ValueOf(data) + + if requestStructType.Kind() == reflect.Pointer { + requestStructType = requestStructType.Elem() + requestValType = requestValType.Elem() + } + + writer := multipart.NewWriter(w) + + for i := 0; i < requestStructType.NumField(); i++ { + field := requestStructType.Field(i) + fieldType := field.Type + valType := requestValType.Field(i) + + if isNil(fieldType, valType) { + continue + } + + if fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + valType = valType.Elem() + } + + tag := parseMultipartFormTag(field) + if tag.File { + if err := encodeMultipartFormDataFile(writer, fieldType, valType); err != nil { + writer.Close() + return "", err + } + } else if tag.JSON { + jw, err := writer.CreateFormField(tag.Name) + if err != nil { + writer.Close() + return "", err + } + d, err := MarshalJSON(valType.Interface(), field.Tag, true) + if err != nil { + writer.Close() + return "", err + } + if _, err := jw.Write(d); err != nil { + writer.Close() + return "", err + } + } else { + switch fieldType.Kind() { + case reflect.Slice, reflect.Array: + values := parseDelimitedArray(true, valType, ",") + for _, v := range values { + if err := writer.WriteField(tag.Name+"[]", v); err != nil { + writer.Close() + return "", err + } + } + default: + if err := writer.WriteField(tag.Name, valToString(valType.Interface())); err != nil { + writer.Close() + return "", err + } + } + } + } + + if err := writer.Close(); err != nil { + return "", err + } + + return writer.FormDataContentType(), nil +} + +func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, valType reflect.Value) error { + if fieldType.Kind() != reflect.Struct { + return fmt.Errorf("invalid type %s for multipart/form-data file", valType.Type()) + } + + var fieldName string + var fileName string + var reader io.Reader + + for i := 0; i < fieldType.NumField(); i++ { + field := fieldType.Field(i) + val := valType.Field(i) + + tag := parseMultipartFormTag(field) + if !tag.Content && tag.Name == "" { + continue + } + + if tag.Content && val.CanInterface() { + if reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)) { + reader = bytes.NewReader(val.Interface().([]byte)) + } else if reflect.TypeOf(val.Interface()).Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()) { + reader = val.Interface().(io.Reader) + } + } else { + fieldName = tag.Name + fileName = val.String() + } + } + + if fieldName == "" || fileName == "" || reader == nil { + return fmt.Errorf("invalid multipart/form-data file") + } + + fw, err := w.CreateFormFile(fieldName, fileName) + if err != nil { + return err + } + if _, err := io.Copy(fw, reader); err != nil { + return err + } + + return nil +} + +func encodeFormData(fieldName string, w io.Writer, data interface{}) error { + requestType := reflect.TypeOf(data) + requestValType := reflect.ValueOf(data) + + if requestType.Kind() == reflect.Pointer { + requestType = requestType.Elem() + requestValType = requestValType.Elem() + } + + dataValues := url.Values{} + + switch requestType.Kind() { + case reflect.Struct: + for i := 0; i < requestType.NumField(); i++ { + field := requestType.Field(i) + fieldType := field.Type + valType := requestValType.Field(i) + + if isNil(fieldType, valType) { + continue + } + + if fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + valType = valType.Elem() + } + + tag := parseFormTag(field) + if tag.JSON { + data, err := MarshalJSON(valType.Interface(), field.Tag, true) + if err != nil { + return err + } + dataValues.Set(tag.Name, string(data)) + } else { + switch tag.Style { + // TODO: support other styles + case "form": + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", func(sf reflect.StructField) string { + tag := parseFormTag(field) + if tag == nil { + return "" + } + + return tag.Name + }) + for k, v := range values { + for _, vv := range v { + dataValues.Add(k, vv) + } + } + } + } + } + case reflect.Map: + for _, k := range requestValType.MapKeys() { + v := requestValType.MapIndex(k) + dataValues.Set(fmt.Sprintf("%v", k.Interface()), valToString(v.Interface())) + } + case reflect.Slice, reflect.Array: + for i := 0; i < requestValType.Len(); i++ { + v := requestValType.Index(i) + dataValues.Set(fieldName, valToString(v.Interface())) + } + } + + if _, err := w.Write([]byte(dataValues.Encode())); err != nil { + return err + } + + return nil +} + +type requestTag struct { + MediaType string +} + +func getRequestTag(field reflect.StructField) *requestTag { + // example `request:"mediaType=multipart/form-data"` + values := parseStructTag(requestTagKey, field) + if values == nil { + return nil + } + + tag := &requestTag{ + MediaType: "application/octet-stream", + } + + for k, v := range values { + switch k { + case "mediaType": + tag.MediaType = v + } + } + + return tag +} + +type multipartFormTag struct { + File bool + Content bool + JSON bool + Name string +} + +func parseMultipartFormTag(field reflect.StructField) *multipartFormTag { + // example `multipartForm:"name=file"` + values := parseStructTag(multipartFormTagKey, field) + + tag := &multipartFormTag{} + + for k, v := range values { + switch k { + case "file": + tag.File = v == "true" + case "content": + tag.Content = v == "true" + case "name": + tag.Name = v + case "json": + tag.JSON = v == "true" + } + } + + return tag +} + +type formTag struct { + Name string + JSON bool + Style string + Explode bool +} + +func parseFormTag(field reflect.StructField) *formTag { + // example `form:"name=propName,style=spaceDelimited,explode"` + values := parseStructTag(formTagKey, field) + + tag := &formTag{ + Style: "form", + Explode: true, + } + + for k, v := range values { + switch k { + case "name": + tag.Name = v + case "json": + tag.JSON = v == "true" + case "style": + tag.Style = v + case "explode": + tag.Explode = v == "true" + } + } + + return tag +} diff --git a/sync-for-payables/pkg/utils/retries.go b/sync-for-payables/pkg/utils/retries.go new file mode 100644 index 000000000..82b0417a9 --- /dev/null +++ b/sync-for-payables/pkg/utils/retries.go @@ -0,0 +1,110 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "errors" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +var errRequestFailed = errors.New("request failed") + +// Deprecated: Use retry.BackoffStrategy instead. +type BackoffStrategy = retry.BackoffStrategy + +// Deprecated: Use retry.Config instead. +type RetryConfig = retry.Config + +type Retries struct { + Config *retry.Config + StatusCodes []string +} + +func Retry(ctx context.Context, r Retries, action func() (*http.Response, error)) (*http.Response, error) { + switch r.Config.Strategy { + case "backoff": + if r.Config.Backoff == nil { + return action() + } + + config := backoff.NewExponentialBackOff() + config.InitialInterval = time.Duration(r.Config.Backoff.InitialInterval) * time.Millisecond + config.MaxInterval = time.Duration(r.Config.Backoff.MaxInterval) * time.Millisecond + config.Multiplier = r.Config.Backoff.Exponent + config.MaxElapsedTime = time.Duration(r.Config.Backoff.MaxElapsedTime) * time.Millisecond + config.Reset() + + var resp *http.Response + + err := backoff.Retry(func() error { + if resp != nil { + resp.Body.Close() + } + + select { + case <-ctx.Done(): + return backoff.Permanent(ctx.Err()) + default: + } + + res, err := action() + if err != nil { + urlError := new(url.Error) + if errors.As(err, &urlError) { + if (urlError.Temporary() || urlError.Timeout()) && r.Config.RetryConnectionErrors { + return err + } + } + + return backoff.Permanent(err) + } + resp = res + if res == nil { + return fmt.Errorf("no response") + } + + for _, code := range r.StatusCodes { + if strings.Contains(strings.ToUpper(code), "X") { + codeRange, err := strconv.Atoi(code[:1]) + if err != nil { + continue + } + + s := res.StatusCode / 100 + + if s >= codeRange && s < codeRange+1 { + return errRequestFailed + } + } else { + parsedCode, err := strconv.Atoi(code) + if err != nil { + continue + } + + if res.StatusCode == parsedCode { + return errRequestFailed + } + } + } + + resp = res + + return nil + }, config) + if err != nil && !errors.Is(err, errRequestFailed) { + return nil, err + } + + return resp, nil + default: + return action() + } +} diff --git a/sync-for-payables/pkg/utils/security.go b/sync-for-payables/pkg/utils/security.go new file mode 100644 index 000000000..19dfa6f46 --- /dev/null +++ b/sync-for-payables/pkg/utils/security.go @@ -0,0 +1,285 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "encoding/base64" + "fmt" + "net/http" + "reflect" + "strings" +) + +const ( + securityTagKey = "security" +) + +type securityTag struct { + Option bool + Scheme bool + Name string + Type string + SubType string + Env string +} + +func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error { + if securitySource == nil { + return nil + } + + security, err := securitySource(ctx) + if err != nil { + return err + } + + headers := make(map[string]string) + queryParams := make(map[string]string) + + securityValType := trueReflectValue(reflect.ValueOf(security)) + securityStructType := securityValType.Type() + + if isNil(securityStructType, securityValType) { + return nil + } + + if securityStructType.Kind() == reflect.Ptr { + securityStructType = securityStructType.Elem() + securityValType = securityValType.Elem() + } + + for i := 0; i < securityStructType.NumField(); i++ { + fieldType := securityStructType.Field(i) + valType := securityValType.Field(i) + + kind := valType.Kind() + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + kind = valType.Elem().Kind() + } + + secTag := parseSecurityTag(fieldType) + if secTag != nil { + if secTag.Option { + handleSecurityOption(headers, queryParams, valType.Interface()) + } else if secTag.Scheme { + // Special case for basic auth which could be a flattened struct + if secTag.SubType == "basic" && kind != reflect.Struct { + parseSecurityScheme(headers, queryParams, secTag, security) + } else { + parseSecurityScheme(headers, queryParams, secTag, valType.Interface()) + } + } + } + } + + for key, value := range headers { + req.Header.Add(key, value) + } + + query := req.URL.Query() + for key, value := range queryParams { + query.Add(key, value) + } + req.URL.RawQuery = query.Encode() + + return nil +} + +func handleSecurityOption(headers, queryParams map[string]string, option interface{}) { + optionValType := trueReflectValue(reflect.ValueOf(option)) + optionStructType := optionValType.Type() + + if isNil(optionStructType, optionValType) { + return + } + + for i := 0; i < optionStructType.NumField(); i++ { + fieldType := optionStructType.Field(i) + valType := optionValType.Field(i) + + secTag := parseSecurityTag(fieldType) + if secTag != nil && secTag.Scheme { + parseSecurityScheme(headers, queryParams, secTag, valType.Interface()) + } + } +} + +func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *securityTag, scheme interface{}) { + schemeVal := trueReflectValue(reflect.ValueOf(scheme)) + schemeType := schemeVal.Type() + + if isNil(schemeType, schemeVal) { + return + } + + if schemeType.Kind() == reflect.Struct { + if schemeTag.Type == "http" { + switch schemeTag.SubType { + case "basic": + handleBasicAuthScheme(headers, schemeVal.Interface()) + return + case "custom": + return + } + } + + for i := 0; i < schemeType.NumField(); i++ { + fieldType := schemeType.Field(i) + valType := schemeVal.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + + secTag := parseSecurityTag(fieldType) + if secTag == nil || secTag.Name == "" { + return + } + + parseSecuritySchemeValue(headers, queryParams, schemeTag, secTag, valType.Interface()) + } + } else { + parseSecuritySchemeValue(headers, queryParams, schemeTag, schemeTag, schemeVal.Interface()) + } +} + +func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag *securityTag, secTag *securityTag, val interface{}) { + switch schemeTag.Type { + case "apiKey": + switch schemeTag.SubType { + case "header": + headers[secTag.Name] = valToString(val) + case "query": + queryParams[secTag.Name] = valToString(val) + case "cookie": + headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val)) + default: + panic("not supported") + } + case "openIdConnect": + headers[secTag.Name] = prefixBearer(valToString(val)) + case "oauth2": + if schemeTag.SubType != "client_credentials" { + headers[secTag.Name] = prefixBearer(valToString(val)) + } + case "http": + switch schemeTag.SubType { + case "bearer": + headers[secTag.Name] = prefixBearer(valToString(val)) + case "custom": + default: + panic("not supported") + } + default: + panic("not supported") + } +} + +func prefixBearer(authHeaderValue string) string { + if strings.HasPrefix(strings.ToLower(authHeaderValue), "bearer ") { + return authHeaderValue + } + + return fmt.Sprintf("Bearer %s", authHeaderValue) +} + +func handleBasicAuthScheme(headers map[string]string, scheme interface{}) { + schemeStructType := reflect.TypeOf(scheme) + schemeValType := reflect.ValueOf(scheme) + + var username, password string + + for i := 0; i < schemeStructType.NumField(); i++ { + fieldType := schemeStructType.Field(i) + valType := schemeValType.Field(i) + + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + + secTag := parseSecurityTag(fieldType) + if secTag == nil || secTag.Name == "" { + continue + } + + switch secTag.Name { + case "username": + username = valType.String() + case "password": + password = valType.String() + } + } + + headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password)))) +} + +func parseSecurityTag(field reflect.StructField) *securityTag { + tag := field.Tag.Get(securityTagKey) + if tag == "" { + return nil + } + + option := false + scheme := false + name := "" + securityType := "" + securitySubType := "" + env := "" + + options := strings.Split(tag, ",") + for _, optionConf := range options { + parts := strings.Split(optionConf, "=") + if len(parts) < 1 || len(parts) > 2 { + continue + } + + switch parts[0] { + case "name": + name = parts[1] + case "type": + securityType = parts[1] + case "subtype": + securitySubType = parts[1] + case "option": + option = true + case "scheme": + scheme = true + case "env": + env = parts[1] + } + } + + // TODO: validate tag? + + return &securityTag{ + Option: option, + Scheme: scheme, + Name: name, + Type: securityType, + SubType: securitySubType, + Env: env, + } +} + +func trueReflectValue(val reflect.Value) reflect.Value { + kind := val.Type().Kind() + for kind == reflect.Interface || kind == reflect.Ptr { + innerVal := val.Elem() + if !innerVal.IsValid() { + break + } + val = innerVal + kind = val.Type().Kind() + } + return val +} diff --git a/sync-for-payables/pkg/utils/utils.go b/sync-for-payables/pkg/utils/utils.go new file mode 100644 index 000000000..adb2f7055 --- /dev/null +++ b/sync-for-payables/pkg/utils/utils.go @@ -0,0 +1,230 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "io" + "math/big" + "reflect" + "regexp" + "strconv" + "strings" + "time" + + "github.com/ericlagergren/decimal" +) + +const ( + queryParamTagKey = "queryParam" + headerParamTagKey = "header" + pathParamTagKey = "pathParam" +) + +var ( + paramRegex = regexp.MustCompile(`({.*?})`) + SerializationMethodToContentType = map[string]string{ + "json": "application/json", + "form": "application/x-www-form-urlencoded", + "multipart": "multipart/form-data", + "raw": "application/octet-stream", + "string": "text/plain", + } +) + +func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}, tag string) error { + data, err := io.ReadAll(body) + if err != nil { + return fmt.Errorf("error reading response body: %w", err) + } + if err := UnmarshalJSON(data, out, reflect.StructTag(tag), true, false); err != nil { + return fmt.Errorf("error unmarshalling json response body: %w", err) + } + + return nil +} + +func ReplaceParameters(stringWithParams string, params map[string]string) string { + if len(params) == 0 { + return stringWithParams + } + + return paramRegex.ReplaceAllStringFunc(stringWithParams, func(match string) string { + match = match[1 : len(match)-1] + return params[match] + }) +} + +func Contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} + +func MatchStatusCodes(expectedCodes []string, statusCode int) bool { + for _, codeStr := range expectedCodes { + code, err := strconv.Atoi(codeStr) + if err == nil { + if code == statusCode { + return true + } + continue + } + + codeRange, err := strconv.Atoi(string(codeStr[0])) + if err != nil { + continue + } + + if statusCode >= (codeRange*100) && statusCode < ((codeRange+1)*100) { + return true + } + } + + return false +} + +func AsSecuritySource(security interface{}) func(context.Context) (interface{}, error) { + return func(context.Context) (interface{}, error) { + return security, nil + } +} + +func parseStructTag(tagKey string, field reflect.StructField) map[string]string { + tag := field.Tag.Get(tagKey) + if tag == "" { + return nil + } + + values := map[string]string{} + + options := strings.Split(tag, ",") + for _, optionConf := range options { + parts := strings.Split(optionConf, "=") + + switch len(parts) { + case 1: + // flag option + parts = append(parts, "true") + case 2: + // key=value option + default: + // invalid option + continue + } + + values[parts[0]] = parts[1] + } + + return values +} + +func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string, defaultExplode bool) *paramTag { + // example `{tagKey}:"style=simple,explode=false,name=apiID"` + values := parseStructTag(tagKey, field) + if values == nil { + return nil + } + + tag := ¶mTag{ + Style: defaultStyle, + Explode: defaultExplode, + ParamName: strings.ToLower(field.Name), + } + + for k, v := range values { + switch k { + case "style": + tag.Style = v + case "explode": + tag.Explode = v == "true" + case "name": + tag.ParamName = v + case "serialization": + tag.Serialization = v + } + } + + return tag +} + +func valToString(val interface{}) string { + switch v := val.(type) { + case time.Time: + return v.Format(time.RFC3339Nano) + case big.Int: + return v.String() + case decimal.Big: + return v.String() + default: + return fmt.Sprintf("%v", v) + } +} + +func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) { + if globals == nil { + return fieldType, valType, false + } + + globalsStruct := reflect.TypeOf(globals) + globalsStructVal := reflect.ValueOf(globals) + + globalsField, found := globalsStruct.FieldByName(fieldType.Name) + if !found { + return fieldType, valType, false + } + + if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() { + return fieldType, valType, true + } + + globalsVal := globalsStructVal.FieldByName(fieldType.Name) + + if !globalsVal.IsValid() { + return fieldType, valType, false + } + + switch paramType { + case queryParamTagKey: + qpTag := parseQueryParamTag(globalsField) + if qpTag == nil { + return fieldType, valType, false + } + default: + tag := parseParamTag(paramType, fieldType, "simple", false) + if tag == nil { + return fieldType, valType, false + } + } + + return globalsField, globalsVal, true +} + +func isNil(typ reflect.Type, val reflect.Value) bool { + // `reflect.TypeOf(nil) == nil` so calling typ.Kind() will cause a nil pointer + // dereference panic. Catch it and return early. + // https://github.com/golang/go/issues/51649 + // https://github.com/golang/go/issues/54208 + if typ == nil { + return true + } + + if typ.Kind() == reflect.Ptr || typ.Kind() == reflect.Map || typ.Kind() == reflect.Slice || typ.Kind() == reflect.Interface { + return val.IsNil() + } + + return false +} + +func contains(arr []string, str string) bool { + for _, a := range arr { + if a == str { + return true + } + } + return false +} diff --git a/sync-for-payables/suppliers.go b/sync-for-payables/suppliers.go new file mode 100644 index 000000000..d10f011e1 --- /dev/null +++ b/sync-for-payables/suppliers.go @@ -0,0 +1,533 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package syncforpayables + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/codatio/client-sdk-go/sync-for-payables/internal/hooks" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/models/shared" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/retry" + "github.com/codatio/client-sdk-go/sync-for-payables/pkg/utils" + "io" + "net/http" +) + +// Suppliers - Get, create, and update Suppliers. +type Suppliers struct { + sdkConfiguration sdkConfiguration +} + +func newSuppliers(sdkConfig sdkConfiguration) *Suppliers { + return &Suppliers{ + sdkConfiguration: sdkConfig, + } +} + +// List suppliers +// The *List suppliers* endpoint returns a list of [suppliers](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) for a given company's connection. +// +// [Suppliers](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service. +// +// By default, this endpoint returns a list of active and archived suppliers. You can use [querying](https://docs.codat.io/using-the-api/querying) to change that. +// +// For example, to retrieve only active suppliers (i.e. `status=Active`) or suppliers created within the specified number of days (e.g. `sourceModifiedDate>2023-12-15T00:00:00.000Z`), query the endpoint as follows: `/payables/suppliers?query=sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Active`.For example, to retrieve active suppliers modified after a particular date use `query=sourceModifiedDate>2023-12-15T00:00:00.000Z&&status=Active`. +func (s *Suppliers) List(ctx context.Context, request operations.ListSuppliersRequest, opts ...operations.Option) (*operations.ListSuppliersResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "list-suppliers", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/suppliers", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "409", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListSuppliersResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Suppliers + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Suppliers = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// Create supplier +// The *Create supplier* endpoint creates a new [supplier](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) for a given company's connection. +// +// [Suppliers](https://docs.codat.io/sync-for-payables-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service. +func (s *Suppliers) Create(ctx context.Context, request operations.CreateSupplierRequest, opts ...operations.Option) (*operations.CreateSupplierResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "create-supplier", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/companies/{companyId}/connections/{connectionId}/payables/suppliers", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "SupplierPrototype", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 500, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "408", + "429", + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateSupplierResponse{ + HTTPMeta: shared.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + getRawBody := func() ([]byte, error) { + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.Supplier + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Supplier = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 402: + fallthrough + case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + case httpRes.StatusCode == 500: + fallthrough + case httpRes.StatusCode == 503: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrorMessage + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +}