From e0bc5abddaaffe20a736e5c3b9f6baa85fca01af Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Tue, 29 Oct 2024 19:32:42 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.423.1 --- .speakeasy/workflow.lock | 8 +- platform/.speakeasy/gen.lock | 119 ++- platform/.speakeasy/gen.yaml | 2 +- platform/README.md | 71 +- platform/RELEASES.md | 12 +- platform/USAGE.md | 4 +- platform/codatplatform.go | 19 +- platform/companies.go | 549 ++++++++-- platform/connectionmanagement.go | 39 +- platform/connections.go | 164 +-- platform/corssettings.go | 65 +- platform/customdatatype.go | 117 +-- .../operations/addcompanytogrouprequest.md | 9 - .../models/operations/addproductrequest.md | 9 + ...groupresponse.md => addproductresponse.md} | 2 +- .../models/operations/deleteapikeyresponse.md | 2 +- ...eateupdatemodeloptionsbydatatyperequest.md | 2 +- .../operations/refreshdatatyperequest.md | 2 +- .../removecompanyfromgrouprequest.md | 9 - .../models/operations/removeproductrequest.md | 9 + ...upresponse.md => removeproductresponse.md} | 3 +- .../docs/pkg/models/sdkerrors/errormessage.md | 2 +- platform/docs/pkg/models/shared/company.md | 3 +- .../docs/pkg/models/shared/companydetails.md | 3 +- .../models/shared/companygroupassignment.md | 8 - .../pkg/models/shared/companyreference.md | 4 +- .../models/shared/companyreferencelinks.md | 10 + .../pkg/models/shared/companyrequestbody.md | 4 +- .../docs/pkg/models/shared/companytags.md | 9 - platform/docs/pkg/models/shared/connection.md | 1 - .../connectionmanagementallowedorigins.md | 2 + .../connectionwebhook.md} | 14 +- .../models/shared/connectionwebhookpayload.md | 9 + platform/docs/pkg/models/shared/datastatus.md | 2 +- .../pkg/models/shared/datastatusdatatypes.md | 52 + platform/docs/pkg/models/shared/datatypes.md | 55 +- .../docs/pkg/models/shared/errormessage.md | 16 + platform/docs/pkg/models/shared/group.md | 11 - .../docs/pkg/models/shared/groupprototype.md | 10 - platform/docs/pkg/models/shared/groupref.md | 8 - platform/docs/pkg/models/shared/groups.md | 8 - .../pkg/models/shared/readcompletedwebhook.md | 11 + .../shared/readcompletedwebhookpayload.md | 10 + platform/docs/pkg/models/shared/tags.md | 9 - .../docs/pkg/models/shared/webhookconsumer.md | 15 +- .../models/shared/webhookconsumerprototype.md | 13 +- .../connectionconnectedresponse.md} | 5 +- .../webhooks/connectioncreatedresponse.md | 10 + .../webhooks/connectiondeletedresponse.md | 10 + .../connectiondisconnectedresponse.md | 10 + .../webhooks/connectionfailedresponse.md | 10 + .../webhooks/connectionreconnectedresponse.md | 10 + .../webhooks/readcompletedinitialresponse.md | 10 + .../models/webhooks/readcompletedresponse.md | 10 + platform/docs/sdks/codatplatform/README.md | 1 - platform/docs/sdks/companies/README.md | 201 +++- .../docs/sdks/connectionmanagement/README.md | 14 +- platform/docs/sdks/connections/README.md | 89 +- platform/docs/sdks/corssettings/README.md | 25 +- platform/docs/sdks/customdatatype/README.md | 59 +- platform/docs/sdks/groups/README.md | 252 ----- platform/docs/sdks/integrations/README.md | 44 +- platform/docs/sdks/pushdata/README.md | 52 +- platform/docs/sdks/refreshdata/README.md | 74 +- platform/docs/sdks/settings/README.md | 94 +- platform/docs/sdks/supplementaldata/README.md | 29 +- platform/docs/sdks/webhooks/README.md | 101 +- platform/go.mod | 2 +- platform/groups.go | 984 ------------------ platform/integrations.go | 91 +- .../models/operations/addcompanytogroup.go | 67 -- ...emovecompanyfromgroup.go => addproduct.go} | 20 +- .../operations/configurecustomdatatype.go | 2 +- .../operations/configuresupplementaldata.go | 2 +- .../pkg/models/operations/createapikey.go | 2 +- .../pkg/models/operations/createcompany.go | 2 +- .../pkg/models/operations/createconnection.go | 2 +- platform/pkg/models/operations/createrule.go | 2 +- .../operations/createwebhookconsumer.go | 2 +- .../pkg/models/operations/deleteapikey.go | 6 +- platform/pkg/models/operations/getcompany.go | 2 +- .../models/operations/getcompanydatastatus.go | 2 +- .../operations/getcompanypushhistory.go | 4 +- .../pkg/models/operations/getconnection.go | 2 +- .../getconnectionmanagementaccesstoken.go | 2 +- .../getconnectionmanagementcorssettings.go | 2 +- .../getcreateupdatemodeloptionsbydatatype.go | 4 +- .../getcustomdatatypeconfiguration.go | 2 +- .../pkg/models/operations/getintegration.go | 2 +- .../operations/getintegrationsbranding.go | 2 +- platform/pkg/models/operations/getprofile.go | 2 +- .../operations/getprofilesyncsettings.go | 2 +- .../pkg/models/operations/getpulloperation.go | 2 +- .../pkg/models/operations/getpushoperation.go | 2 +- .../getsupplementaldataconfiguration.go | 2 +- platform/pkg/models/operations/getwebhook.go | 2 +- platform/pkg/models/operations/listapikeys.go | 2 +- .../pkg/models/operations/listcompanies.go | 4 +- .../pkg/models/operations/listconnections.go | 4 +- .../operations/listcustomdatatyperecords.go | 4 +- .../pkg/models/operations/listintegrations.go | 4 +- .../models/operations/listpulloperations.go | 4 +- platform/pkg/models/operations/listrules.go | 4 +- .../models/operations/listwebhookconsumers.go | 2 +- platform/pkg/models/operations/options.go | 4 +- .../operations/refreshcustomdatatype.go | 2 +- .../pkg/models/operations/refreshdatatype.go | 4 +- .../pkg/models/operations/removeproduct.go | 58 ++ .../setconnectionmanagementcorssettings.go | 2 +- .../pkg/models/operations/unlinkconnection.go | 2 +- .../pkg/models/operations/updatecompany.go | 2 +- .../updateconnectionauthorization.go | 2 +- .../pkg/models/operations/updateprofile.go | 2 +- .../operations/updateprofilesyncsettings.go | 4 +- platform/pkg/models/sdkerrors/errormessage.go | 4 +- platform/pkg/models/shared/company.go | 17 +- platform/pkg/models/shared/companydetails.go | 17 +- .../models/shared/companygroupassignment.go | 14 - .../pkg/models/shared/companyreference.go | 31 + .../pkg/models/shared/companyrequestbody.go | 16 +- platform/pkg/models/shared/connection.go | 10 +- .../connectionmanagementallowedorigins.go | 1 + .../pkg/models/shared/connectionwebhook.go | 59 ++ .../models/shared/connectionwebhookpayload.go | 32 + platform/pkg/models/shared/datastatus.go | 104 +- platform/pkg/models/shared/errormessage.go | 70 ++ platform/pkg/models/shared/group.go | 25 - platform/pkg/models/shared/groupprototype.go | 16 - platform/pkg/models/shared/groupref.go | 15 - platform/pkg/models/shared/groups.go | 14 - .../pkg/models/shared/readcompletedwebhook.go | 59 ++ .../shared/readcompletedwebhookpayload.go | 88 ++ platform/pkg/models/shared/webhookconsumer.go | 13 +- .../models/shared/webhookconsumerprototype.go | 13 +- .../connectionconnected.go} | 20 +- .../pkg/models/webhooks/connectioncreated.go | 37 + .../pkg/models/webhooks/connectiondeleted.go | 37 + .../models/webhooks/connectiondisconnected.go | 37 + .../pkg/models/webhooks/connectionfailed.go | 37 + .../models/webhooks/connectionreconnected.go | 37 + platform/pkg/models/webhooks/readcompleted.go | 37 + .../readcompletedinitial.go} | 20 +- platform/pkg/utils/form.go | 2 +- platform/pkg/utils/json.go | 2 +- platform/pkg/utils/pathparams.go | 2 +- platform/pkg/utils/queryparams.go | 2 +- platform/pkg/utils/retries.go | 2 +- platform/pkg/utils/utils.go | 14 + platform/pushdata.go | 99 +- platform/refreshdata.go | 138 +-- platform/settings.go | 192 +--- platform/supplementaldata.go | 60 +- platform/webhooks.go | 182 +--- 153 files changed, 2383 insertions(+), 3137 deletions(-) delete mode 100644 platform/docs/pkg/models/operations/addcompanytogrouprequest.md create mode 100644 platform/docs/pkg/models/operations/addproductrequest.md rename platform/docs/pkg/models/operations/{removecompanyfromgroupresponse.md => addproductresponse.md} (97%) delete mode 100644 platform/docs/pkg/models/operations/removecompanyfromgrouprequest.md create mode 100644 platform/docs/pkg/models/operations/removeproductrequest.md rename platform/docs/pkg/models/operations/{creategroupresponse.md => removeproductresponse.md} (82%) delete mode 100644 platform/docs/pkg/models/shared/companygroupassignment.md create mode 100644 platform/docs/pkg/models/shared/companyreferencelinks.md delete mode 100644 platform/docs/pkg/models/shared/companytags.md rename platform/docs/pkg/models/{operations/addcompanytogroupresponse.md => shared/connectionwebhook.md} (83%) create mode 100644 platform/docs/pkg/models/shared/connectionwebhookpayload.md create mode 100644 platform/docs/pkg/models/shared/datastatusdatatypes.md create mode 100644 platform/docs/pkg/models/shared/errormessage.md delete mode 100644 platform/docs/pkg/models/shared/group.md delete mode 100644 platform/docs/pkg/models/shared/groupprototype.md delete mode 100644 platform/docs/pkg/models/shared/groupref.md delete mode 100644 platform/docs/pkg/models/shared/groups.md create mode 100644 platform/docs/pkg/models/shared/readcompletedwebhook.md create mode 100644 platform/docs/pkg/models/shared/readcompletedwebhookpayload.md delete mode 100644 platform/docs/pkg/models/shared/tags.md rename platform/docs/pkg/models/{operations/listgroupsresponse.md => webhooks/connectionconnectedresponse.md} (79%) create mode 100644 platform/docs/pkg/models/webhooks/connectioncreatedresponse.md create mode 100644 platform/docs/pkg/models/webhooks/connectiondeletedresponse.md create mode 100644 platform/docs/pkg/models/webhooks/connectiondisconnectedresponse.md create mode 100644 platform/docs/pkg/models/webhooks/connectionfailedresponse.md create mode 100644 platform/docs/pkg/models/webhooks/connectionreconnectedresponse.md create mode 100644 platform/docs/pkg/models/webhooks/readcompletedinitialresponse.md create mode 100644 platform/docs/pkg/models/webhooks/readcompletedresponse.md delete mode 100644 platform/docs/sdks/groups/README.md delete mode 100644 platform/groups.go delete mode 100644 platform/pkg/models/operations/addcompanytogroup.go rename platform/pkg/models/operations/{removecompanyfromgroup.go => addproduct.go} (56%) create mode 100644 platform/pkg/models/operations/removeproduct.go delete mode 100644 platform/pkg/models/shared/companygroupassignment.go create mode 100644 platform/pkg/models/shared/connectionwebhook.go create mode 100644 platform/pkg/models/shared/connectionwebhookpayload.go create mode 100644 platform/pkg/models/shared/errormessage.go delete mode 100644 platform/pkg/models/shared/group.go delete mode 100644 platform/pkg/models/shared/groupprototype.go delete mode 100644 platform/pkg/models/shared/groupref.go delete mode 100644 platform/pkg/models/shared/groups.go create mode 100644 platform/pkg/models/shared/readcompletedwebhook.go create mode 100644 platform/pkg/models/shared/readcompletedwebhookpayload.go rename platform/pkg/models/{operations/listgroups.go => webhooks/connectionconnected.go} (52%) create mode 100644 platform/pkg/models/webhooks/connectioncreated.go create mode 100644 platform/pkg/models/webhooks/connectiondeleted.go create mode 100644 platform/pkg/models/webhooks/connectiondisconnected.go create mode 100644 platform/pkg/models/webhooks/connectionfailed.go create mode 100644 platform/pkg/models/webhooks/connectionreconnected.go create mode 100644 platform/pkg/models/webhooks/readcompleted.go rename platform/pkg/models/{operations/creategroup.go => webhooks/readcompletedinitial.go} (53%) diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index a34deafc5..2b0774128 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -58,8 +58,8 @@ sources: - main platform-source: sourceNamespace: platform-source - sourceRevisionDigest: sha256:9d1b7d84cf409ce52032d4c8b3e484355297cdc001d4d9169d5df5301efecabc - sourceBlobDigest: sha256:e1e3f4c3ed16022322bc656bb0e4ef28c04fff8c92c271cc859c6e2b32af5613 + sourceRevisionDigest: sha256:79f704c98bf458bc595e6607b6bf1fc95a6ba5da522953eedbba8fc9cce25e21 + sourceBlobDigest: sha256:e4fb24c2ca300a5005adef27857ad9afba70f056e51a84fb38368609c61cafc8 tags: - latest - main @@ -156,8 +156,8 @@ targets: platform-library: source: platform-source sourceNamespace: platform-source - sourceRevisionDigest: sha256:9d1b7d84cf409ce52032d4c8b3e484355297cdc001d4d9169d5df5301efecabc - sourceBlobDigest: sha256:e1e3f4c3ed16022322bc656bb0e4ef28c04fff8c92c271cc859c6e2b32af5613 + sourceRevisionDigest: sha256:79f704c98bf458bc595e6607b6bf1fc95a6ba5da522953eedbba8fc9cce25e21 + sourceBlobDigest: sha256:e4fb24c2ca300a5005adef27857ad9afba70f056e51a84fb38368609c61cafc8 sync-for-commerce-library: source: sync-for-commerce-source sourceNamespace: sync-for-commerce-source diff --git a/platform/.speakeasy/gen.lock b/platform/.speakeasy/gen.lock index 4920cdf3d..a9ad9aead 100755 --- a/platform/.speakeasy/gen.lock +++ b/platform/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: f309bed8-ee34-4982-948d-d0a2535e6a36 management: - docChecksum: ef83be90b9eb0e15a21f5dbf01fbe486 + docChecksum: 1b72366d9ec3e09f6de64e940eaeb62b docVersion: 3.0.0 - speakeasyVersion: 1.396.7 - generationVersion: 2.415.6 - releaseVersion: 3.4.0 - configChecksum: 9ef3ead80748b32c53c78ccaba23225c + speakeasyVersion: 1.423.1 + generationVersion: 2.442.11 + releaseVersion: 4.0.0 + configChecksum: fce5cbaed45fc091d0739e45e354e9c1 repoURL: https://github.com/codatio/client-sdk-go.git repoSubDirectory: platform installationURL: https://github.com/codatio/client-sdk-go/platform @@ -15,7 +15,7 @@ features: go: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.6 - core: 3.5.8 + core: 3.5.14 defaultEnabledRetries: 0.2.0 deprecations: 2.81.1 envVarSecurityUsage: 0.3.1 @@ -33,16 +33,16 @@ features: retries: 2.83.0 sdkHooks: 0.1.0 serverEventsSentinels: 0.1.0 + tests: 0.6.0 webhooks: 1.0.0 generatedFiles: - .gitattributes - - /pkg/models/operations/addcompanytogroup.go + - /pkg/models/operations/addproduct.go - /pkg/models/operations/configurecustomdatatype.go - /pkg/models/operations/configuresupplementaldata.go - /pkg/models/operations/createapikey.go - /pkg/models/operations/createcompany.go - /pkg/models/operations/createconnection.go - - /pkg/models/operations/creategroup.go - /pkg/models/operations/createrule.go - /pkg/models/operations/createwebhookconsumer.go - /pkg/models/operations/deleteapikey.go @@ -69,7 +69,6 @@ generatedFiles: - /pkg/models/operations/listcompanies.go - /pkg/models/operations/listconnections.go - /pkg/models/operations/listcustomdatatyperecords.go - - /pkg/models/operations/listgroups.go - /pkg/models/operations/listintegrations.go - /pkg/models/operations/listpulloperations.go - /pkg/models/operations/listrules.go @@ -77,7 +76,7 @@ generatedFiles: - /pkg/models/operations/refreshcompanydata.go - /pkg/models/operations/refreshcustomdatatype.go - /pkg/models/operations/refreshdatatype.go - - /pkg/models/operations/removecompanyfromgroup.go + - /pkg/models/operations/removeproduct.go - /pkg/models/operations/setconnectionmanagementcorssettings.go - /pkg/models/operations/unlinkconnection.go - /pkg/models/operations/updatecompany.go @@ -100,7 +99,6 @@ generatedFiles: - /pkg/models/shared/companies.go - /pkg/models/shared/company.go - /pkg/models/shared/companydetails.go - - /pkg/models/shared/companygroupassignment.go - /pkg/models/shared/companyreference.go - /pkg/models/shared/companyrequestbody.go - /pkg/models/shared/companywebhook.go @@ -110,6 +108,8 @@ generatedFiles: - /pkg/models/shared/connections.go - /pkg/models/shared/connectionstatuschangedwebhook.go - /pkg/models/shared/connectionstatuschangedwebhookdata.go + - /pkg/models/shared/connectionwebhook.go + - /pkg/models/shared/connectionwebhookpayload.go - /pkg/models/shared/createapikey.go - /pkg/models/shared/createrule.go - /pkg/models/shared/customdatatypeconfiguration.go @@ -129,14 +129,11 @@ generatedFiles: - /pkg/models/shared/datatypewritewebhook.go - /pkg/models/shared/datatypewritewebhookpayload.go - /pkg/models/shared/datatypewritewebhookrecord.go + - /pkg/models/shared/errormessage.go - /pkg/models/shared/errorvalidation.go - /pkg/models/shared/errorvalidationitem.go - /pkg/models/shared/featurestate.go - /pkg/models/shared/featuretype.go - - /pkg/models/shared/group.go - - /pkg/models/shared/groupprototype.go - - /pkg/models/shared/groupref.go - - /pkg/models/shared/groups.go - /pkg/models/shared/halref.go - /pkg/models/shared/imagereference.go - /pkg/models/shared/integration.go @@ -162,6 +159,8 @@ generatedFiles: - /pkg/models/shared/pushoptionproperty.go - /pkg/models/shared/pushoptiontype.go - /pkg/models/shared/pushvalidationinfo.go + - /pkg/models/shared/readcompletedwebhook.go + - /pkg/models/shared/readcompletedwebhookpayload.go - /pkg/models/shared/schemadatatype.go - /pkg/models/shared/security.go - /pkg/models/shared/sourcetype.go @@ -186,6 +185,12 @@ generatedFiles: - /pkg/models/webhooks/companycreated.go - /pkg/models/webhooks/companydataconnectionstatuschanged.go - /pkg/models/webhooks/companydeleted.go + - /pkg/models/webhooks/connectionconnected.go + - /pkg/models/webhooks/connectioncreated.go + - /pkg/models/webhooks/connectiondeleted.go + - /pkg/models/webhooks/connectiondisconnected.go + - /pkg/models/webhooks/connectionfailed.go + - /pkg/models/webhooks/connectionreconnected.go - /pkg/models/webhooks/datasetdatachanged.go - /pkg/models/webhooks/datasetstatushaschangedtoanerrorstate.go - /pkg/models/webhooks/datasynccompleted.go @@ -194,6 +199,8 @@ generatedFiles: - /pkg/models/webhooks/newcompanysynchronized.go - /pkg/models/webhooks/pushoperationhastimedout.go - /pkg/models/webhooks/pushoperationstatushaschanged.go + - /pkg/models/webhooks/readcompleted.go + - /pkg/models/webhooks/readcompletedinitial.go - CONTRIBUTING.md - USAGE.md - codatplatform.go @@ -202,8 +209,8 @@ generatedFiles: - connections.go - corssettings.go - customdatatype.go - - docs/pkg/models/operations/addcompanytogrouprequest.md - - docs/pkg/models/operations/addcompanytogroupresponse.md + - docs/pkg/models/operations/addproductrequest.md + - docs/pkg/models/operations/addproductresponse.md - docs/pkg/models/operations/configurecustomdatatyperequest.md - docs/pkg/models/operations/configurecustomdatatyperesponse.md - docs/pkg/models/operations/configuresupplementaldatarequest.md @@ -213,7 +220,6 @@ generatedFiles: - docs/pkg/models/operations/createconnectionrequest.md - docs/pkg/models/operations/createconnectionrequestbody.md - docs/pkg/models/operations/createconnectionresponse.md - - docs/pkg/models/operations/creategroupresponse.md - docs/pkg/models/operations/createruleresponse.md - docs/pkg/models/operations/createwebhookconsumerresponse.md - docs/pkg/models/operations/datatype.md @@ -261,7 +267,6 @@ generatedFiles: - docs/pkg/models/operations/listconnectionsresponse.md - docs/pkg/models/operations/listcustomdatatyperecordsrequest.md - docs/pkg/models/operations/listcustomdatatyperecordsresponse.md - - docs/pkg/models/operations/listgroupsresponse.md - docs/pkg/models/operations/listintegrationsrequest.md - docs/pkg/models/operations/listintegrationsresponse.md - docs/pkg/models/operations/listpulloperationsrequest.md @@ -277,8 +282,8 @@ generatedFiles: - docs/pkg/models/operations/refreshcustomdatatyperesponse.md - docs/pkg/models/operations/refreshdatatyperequest.md - docs/pkg/models/operations/refreshdatatyperesponse.md - - docs/pkg/models/operations/removecompanyfromgrouprequest.md - - docs/pkg/models/operations/removecompanyfromgroupresponse.md + - docs/pkg/models/operations/removeproductrequest.md + - docs/pkg/models/operations/removeproductresponse.md - docs/pkg/models/operations/setconnectionmanagementcorssettingsresponse.md - docs/pkg/models/operations/unlinkconnectionrequest.md - docs/pkg/models/operations/unlinkconnectionresponse.md @@ -305,10 +310,9 @@ generatedFiles: - docs/pkg/models/shared/companies.md - docs/pkg/models/shared/company.md - docs/pkg/models/shared/companydetails.md - - docs/pkg/models/shared/companygroupassignment.md - docs/pkg/models/shared/companyreference.md + - docs/pkg/models/shared/companyreferencelinks.md - docs/pkg/models/shared/companyrequestbody.md - - docs/pkg/models/shared/companytags.md - docs/pkg/models/shared/companywebhook.md - docs/pkg/models/shared/connection.md - docs/pkg/models/shared/connectionmanagementaccesstoken.md @@ -316,6 +320,8 @@ generatedFiles: - docs/pkg/models/shared/connections.md - docs/pkg/models/shared/connectionstatuschangedwebhook.md - docs/pkg/models/shared/connectionstatuschangedwebhookdata.md + - docs/pkg/models/shared/connectionwebhook.md + - docs/pkg/models/shared/connectionwebhookpayload.md - docs/pkg/models/shared/content.md - docs/pkg/models/shared/createapikey.md - docs/pkg/models/shared/createrule.md @@ -330,6 +336,7 @@ generatedFiles: - docs/pkg/models/shared/datasetstatuschangederrorwebhook.md - docs/pkg/models/shared/datasetstatuschangederrorwebhookdata.md - docs/pkg/models/shared/datastatus.md + - docs/pkg/models/shared/datastatusdatatypes.md - docs/pkg/models/shared/datastatuses.md - docs/pkg/models/shared/datasynccompletedwebhook.md - docs/pkg/models/shared/datasynccompletedwebhookdata.md @@ -339,15 +346,12 @@ generatedFiles: - docs/pkg/models/shared/datatypewritewebhook.md - docs/pkg/models/shared/datatypewritewebhookpayload.md - docs/pkg/models/shared/datatypewritewebhookrecord.md + - docs/pkg/models/shared/errormessage.md - docs/pkg/models/shared/errorstatus.md - docs/pkg/models/shared/errorvalidation.md - docs/pkg/models/shared/errorvalidationitem.md - docs/pkg/models/shared/featurestate.md - docs/pkg/models/shared/featuretype.md - - docs/pkg/models/shared/group.md - - docs/pkg/models/shared/groupprototype.md - - docs/pkg/models/shared/groupref.md - - docs/pkg/models/shared/groups.md - docs/pkg/models/shared/halref.md - docs/pkg/models/shared/imagereference.md - docs/pkg/models/shared/integration.md @@ -374,6 +378,8 @@ generatedFiles: - docs/pkg/models/shared/pushoptionproperty.md - docs/pkg/models/shared/pushoptiontype.md - docs/pkg/models/shared/pushvalidationinfo.md + - docs/pkg/models/shared/readcompletedwebhook.md + - docs/pkg/models/shared/readcompletedwebhookpayload.md - docs/pkg/models/shared/schemadatatype.md - docs/pkg/models/shared/security.md - docs/pkg/models/shared/sourcetype.md @@ -383,7 +389,6 @@ generatedFiles: - docs/pkg/models/shared/supportedfeature.md - docs/pkg/models/shared/syncsetting.md - docs/pkg/models/shared/syncsettings.md - - docs/pkg/models/shared/tags.md - docs/pkg/models/shared/updateconnectionstatus.md - docs/pkg/models/shared/validation.md - docs/pkg/models/shared/validationitem.md @@ -402,6 +407,12 @@ generatedFiles: - docs/pkg/models/webhooks/companycreatedresponse.md - docs/pkg/models/webhooks/companydataconnectionstatuschangedresponse.md - docs/pkg/models/webhooks/companydeletedresponse.md + - docs/pkg/models/webhooks/connectionconnectedresponse.md + - docs/pkg/models/webhooks/connectioncreatedresponse.md + - docs/pkg/models/webhooks/connectiondeletedresponse.md + - docs/pkg/models/webhooks/connectiondisconnectedresponse.md + - docs/pkg/models/webhooks/connectionfailedresponse.md + - docs/pkg/models/webhooks/connectionreconnectedresponse.md - docs/pkg/models/webhooks/datasetdatachangedresponse.md - docs/pkg/models/webhooks/datasetstatushaschangedtoanerrorstateresponse.md - docs/pkg/models/webhooks/datasynccompletedresponse.md @@ -410,13 +421,14 @@ generatedFiles: - docs/pkg/models/webhooks/newcompanysynchronizedresponse.md - docs/pkg/models/webhooks/pushoperationhastimedoutresponse.md - docs/pkg/models/webhooks/pushoperationstatushaschangedresponse.md + - docs/pkg/models/webhooks/readcompletedinitialresponse.md + - docs/pkg/models/webhooks/readcompletedresponse.md - docs/sdks/codatplatform/README.md - docs/sdks/companies/README.md - docs/sdks/connectionmanagement/README.md - docs/sdks/connections/README.md - docs/sdks/corssettings/README.md - docs/sdks/customdatatype/README.md - - docs/sdks/groups/README.md - docs/sdks/integrations/README.md - docs/sdks/pushdata/README.md - docs/sdks/refreshdata/README.md @@ -424,7 +436,6 @@ generatedFiles: - docs/sdks/supplementaldata/README.md - docs/sdks/webhooks/README.md - go.mod - - groups.go - integrations.go - internal/hooks/hooks.go - pkg/models/operations/options.go @@ -527,14 +538,14 @@ examples: create-company: With no description: requestBody: - application/json: {"description": "Requested early access to the new financing scheme.", "groups": [], "name": "Technicalium"} + application/json: {"description": "Requested early access to the new financing scheme.", "name": "Technicalium"} responses: "200": application/json: {"created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "description": "", "id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "name": "Technicalium", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0"} "400": {} With a description: requestBody: - application/json: {"description": "Technology services, including web and app design and development", "groups": [], "name": "Technicalium"} + application/json: {"description": "Technology services, including web and app design and development", "name": "Technicalium"} responses: "200": application/json: {"created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "description": "Technology services, including web and app design and development", "id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "name": "Technicalium", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0"} @@ -548,10 +559,16 @@ examples: "400": {} Malformed query: requestBody: - application/json: {"description": "Requested early access to the new financing scheme.", "groups": [], "name": "Bank of Dave"} + application/json: {"description": "Requested early access to the new financing scheme.", "name": "Bank of Dave"} responses: "400": application/json: {"canBeRetried": "Unknown", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "detailedErrorCode": 0, "error": "Error processing request - not valid.", "service": "PublicApi", "statusCode": 400} + With a tag: + requestBody: + application/json: {"description": "Requested early access to the new financing scheme.", "name": "Bank of Dave"} + responses: + "200": + application/json: {"created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "description": "", "id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "name": "Technicalium", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "tags": {"region": "us"}} delete-company: Unauthorized: parameters: @@ -603,7 +620,7 @@ examples: orderBy: "-modifiedDate" responses: "200": - application/json: {"_links": {"current": {"href": "/companies?page=1&pageSize=100"}, "self": {"href": "/companies"}}, "pageNumber": 1, "pageSize": 100, "results": [{"created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"created": "2022-01-01T11:30:00Z", "dataConnectionErrors": [], "id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "lastSync": "2022-01-01T12:30:00.000Z", "linkUrl": "https://link-api.codat.io/companies/3fa85f64-5717-4562-b3fc-2c963f66afa6/connections/51baa045-4836-4317-a42e-3542e991e581/start", "platformName": "Pandle", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "status": "Linked"}], "description": "My Test Company make testing software", "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "lastSync": "2022-01-01T12:30:00.000Z", "name": "My Test Company", "redirect": "https://link.codat.io/company/3fa85f64-5717-4562-b3fc-2c963f66afa6"}], "totalResults": 1} + application/json: {"_links": {"current": {"href": "/companies?page=1&pageSize=100"}, "self": {"href": "/companies"}}, "pageNumber": 1, "pageSize": 100, "results": [{"created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"created": "2022-01-01T11:30:00Z", "dataConnectionErrors": [{"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}], "id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "lastSync": "2022-01-01T12:30:00.000Z", "linkUrl": "https://link-api.codat.io/companies/3fa85f64-5717-4562-b3fc-2c963f66afa6/connections/51baa045-4836-4317-a42e-3542e991e581/start", "platformName": "Pandle", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "status": "Linked"}], "description": "My Test Company make testing software", "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "lastSync": "2022-01-01T12:30:00.000Z", "name": "My Test Company", "redirect": "https://link.codat.io/company/3fa85f64-5717-4562-b3fc-2c963f66afa6"}], "totalResults": 1} List of Companies: parameters: query: @@ -613,7 +630,7 @@ examples: orderBy: "-modifiedDate" responses: "200": - application/json: {"_links": {"current": {"href": "/companies?page=1&pageSize=100"}, "self": {"href": "/companies"}}, "pageNumber": 1, "pageSize": 100, "results": [{"created": "2022-01-01T11:30:00Z", "createdByUserName": "Joe Bloggs", "dataConnections": [{"created": "2022-01-01T11:30:00Z", "dataConnectionErrors": [], "id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "lastSync": "2022-01-01T12:30:00.000Z", "linkUrl": "https://link-api.codat.io/companies/d1568dde-adf6-11ed-afa1-0242ac120002/connections/51baa045-4836-4317-a42e-3542e991e581/start", "platformName": "Pandle", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "status": "Linked"}], "description": "Technology services, including web and app design and development", "id": "d1568dde-adf6-11ed-afa1-0242ac120002", "lastSync": "2022-01-01T12:30:00.000Z", "name": "Technicalium", "redirect": "https://link.codat.io/company/d1568dde-adf6-11ed-afa1-0242ac120002"}, {"created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"created": "2022-01-01T11:30:00Z", "dataConnectionErrors": [], "id": "a70bc148-dc21-46b2-a257-d9c58ac15cbb", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "lastSync": "2022-01-01T12:30:00.000Z", "linkUrl": "https://link-api.codat.io/companies/096db70b-78de-4ff0-aa98-299cb5fe17a0/connections/a70bc148-dc21-46b2-a257-d9c58ac15cbb/start", "platformName": "Pandle", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "status": "Linked"}], "description": "A new digital agency with a passion for creating amazing digital experiences", "id": "096db70b-78de-4ff0-aa98-299cb5fe17a0", "lastSync": "2022-01-01T12:30:00.000Z", "name": "Godata", "redirect": "https://link.codat.io/company/096db70b-78de-4ff0-aa98-299cb5fe17a0"}], "totalResults": 2} + application/json: {"_links": {"current": {"href": "/companies?page=1&pageSize=100"}, "self": {"href": "/companies"}}, "pageNumber": 1, "pageSize": 100, "results": [{"created": "2022-01-01T11:30:00Z", "createdByUserName": "Joe Bloggs", "dataConnections": [{"created": "2022-01-01T11:30:00Z", "dataConnectionErrors": [{"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}], "id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "lastSync": "2022-01-01T12:30:00.000Z", "linkUrl": "https://link-api.codat.io/companies/d1568dde-adf6-11ed-afa1-0242ac120002/connections/51baa045-4836-4317-a42e-3542e991e581/start", "platformName": "Pandle", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "status": "Linked"}], "description": "Technology services, including web and app design and development", "id": "d1568dde-adf6-11ed-afa1-0242ac120002", "lastSync": "2022-01-01T12:30:00.000Z", "name": "Technicalium", "redirect": "https://link.codat.io/company/d1568dde-adf6-11ed-afa1-0242ac120002"}, {"created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"created": "2022-01-01T11:30:00Z", "dataConnectionErrors": [{"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}], "id": "a70bc148-dc21-46b2-a257-d9c58ac15cbb", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "lastSync": "2022-01-01T12:30:00.000Z", "linkUrl": "https://link-api.codat.io/companies/096db70b-78de-4ff0-aa98-299cb5fe17a0/connections/a70bc148-dc21-46b2-a257-d9c58ac15cbb/start", "platformName": "Pandle", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "status": "Linked"}], "description": "A new digital agency with a passion for creating amazing digital experiences", "id": "096db70b-78de-4ff0-aa98-299cb5fe17a0", "lastSync": "2022-01-01T12:30:00.000Z", "name": "Godata", "redirect": "https://link.codat.io/company/096db70b-78de-4ff0-aa98-299cb5fe17a0"}], "totalResults": 2} Malformed query: parameters: query: @@ -640,27 +657,27 @@ examples: path: companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" requestBody: - application/json: {"description": "Requested early access to the new financing scheme.", "groups": [], "name": "New Name"} + application/json: {"description": "Requested early access to the new financing scheme.", "name": "New Name"} responses: "200": - application/json: {"created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"created": "2022-10-27T09:53:29Z", "dataConnectionErrors": [], "id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "lastSync": "2022-10-27T10:22:43.6464237Z", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "platformName": "Basiq", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "status": "Linked"}], "description": "Requested early access to the new financing scheme.", "id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "lastSync": "2022-01-01T12:00:00.000Z", "name": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739"} + application/json: {"created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"created": "2022-10-27T09:53:29Z", "dataConnectionErrors": [{"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}], "id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "lastSync": "2022-10-27T10:22:43.6464237Z", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "platformName": "Basiq", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "status": "Linked"}], "description": "Requested early access to the new financing scheme.", "id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "lastSync": "2022-01-01T12:00:00.000Z", "name": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "tags": {"region": "us", "uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c"}} "401": {} Update description: parameters: path: companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" requestBody: - application/json: {"description": "Additional documents required", "groups": [], "name": "Same name"} + application/json: {"description": "Additional documents required", "name": "Same name"} responses: "200": - application/json: {"created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"created": "2022-10-27T09:53:29Z", "dataConnectionErrors": [], "id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "lastSync": "2022-10-27T10:22:43.6464237Z", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "platformName": "Basiq", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "status": "Linked"}], "description": "Requested early access to the new financing scheme.", "id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "lastSync": "2022-01-01T12:00:00.000Z", "name": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739"} + application/json: {"created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"created": "2022-10-27T09:53:29Z", "dataConnectionErrors": [], "id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "lastSync": "2022-10-27T10:22:43.6464237Z", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "platformName": "Basiq", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "status": "Linked"}], "description": "Requested early access to the new financing scheme.", "id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "lastSync": "2022-01-01T12:00:00.000Z", "name": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "tags": {"region": "us", "uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c"}} "401": {} Unauthorized: parameters: path: companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" requestBody: - application/json: {"description": "Requested early access to the new financing scheme.", "groups": [], "name": "Bank of Dave"} + application/json: {"description": "Requested early access to the new financing scheme.", "name": "Bank of Dave"} responses: "401": application/json: {"canBeRetried": "Unknown", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "detailedErrorCode": 0, "error": "Unauthorized", "service": "PublicApi", "statusCode": 401} @@ -772,7 +789,7 @@ examples: orderBy: "-modifiedDate" responses: "200": - application/json: {"_links": {"current": {"href": "string"}, "next": {"href": "string"}, "previous": {"href": "string"}, "self": {"href": "string"}}, "pageNumber": 0, "pageSize": 0, "results": [{"created": "2022-10-27T09:53:29Z", "dataConnectionErrors": [], "id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "lastSync": "2022-10-27T10:22:43.6464237Z", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "platformName": "Basiq", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "status": "Linked"}], "totalResults": 0} + application/json: {"_links": {"current": {"href": "string"}, "next": {"href": "string"}, "previous": {"href": "string"}, "self": {"href": "string"}}, "pageNumber": 0, "pageSize": 0, "results": [{"created": "2022-10-27T09:53:29Z", "dataConnectionErrors": [{"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}, {"erroredOnUtc": "2022-10-23T00:00:00Z", "resolvedOnUtc": "2022-10-23T00:00:00Z"}], "id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "lastSync": "2022-10-27T10:22:43.6464237Z", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "platformName": "Basiq", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "status": "Linked"}], "totalResults": 0} Malformed query: parameters: path: @@ -1420,8 +1437,26 @@ examples: Webhook consumers: responses: "200": - application/json: {"results": [{"companyId": "8a210b68-6988-11ed-a1eb-0242ac120002", "disabled": false, "eventTypes": ["DataSyncCompleted"], "id": "12571faf-0898-47e7-afdd-0fe9eb0a9bf5", "url": "https://example.com/webhoook-consumers/sync-complete"}, {"companyId": "8a210b68-6988-11ed-a1eb-0242ac120002", "disabled": true, "eventTypes": ["DatasetDataChanged"], "id": "ca3cac86-7925-4759-abc2-96405780fdfa", "url": "https://example.com/webhoook-consumers/dataset-changed"}]} + application/json: {"results": [{"disabled": false, "eventTypes": ["DataSyncCompleted"], "id": "12571faf-0898-47e7-afdd-0fe9eb0a9bf5", "url": "https://example.com/webhoook-consumers/sync-complete"}, {"disabled": true, "eventTypes": ["DatasetDataChanged"], "id": "ca3cac86-7925-4759-abc2-96405780fdfa", "url": "https://example.com/webhoook-consumers/dataset-changed"}]} Malformed query: responses: "400": application/json: {"canBeRetried": "Unknown", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "detailedErrorCode": 0, "error": "Error processing request - not valid.", "service": "PublicApi", "statusCode": 400} + add-product: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + productIdentifier: "lending" + responses: + "401": + application/json: {"canBeRetried": "Unknown", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "detailedErrorCode": 0, "error": "Unauthorized", "service": "PublicApi", "statusCode": 401} + remove-product: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + productIdentifier: "expenses" + responses: + "401": + application/json: {"canBeRetried": "Unknown", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "detailedErrorCode": 0, "error": "Unauthorized", "service": "PublicApi", "statusCode": 401} diff --git a/platform/.speakeasy/gen.yaml b/platform/.speakeasy/gen.yaml index 1f5b9908b..d67c440cd 100644 --- a/platform/.speakeasy/gen.yaml +++ b/platform/.speakeasy/gen.yaml @@ -11,7 +11,7 @@ generation: oAuth2ClientCredentialsEnabled: false telemetryEnabled: true go: - version: 3.4.0 + version: 4.0.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/platform/README.md b/platform/README.md index 8688c4acf..0de1ee653 100644 --- a/platform/README.md +++ b/platform/README.md @@ -24,7 +24,6 @@ These end points cover creating and managing your companies, data connections, a | Companies | Create and manage your SMB users' companies. | | Connections | Create new and manage existing data connections for a company. | | Connection management | Configure connection management UI and retrieve access tokens for authentication. | -| Groups | Define and manage sets of companies based on a chosen characteristic. | | Webhooks | Create and manage webhooks that listen to Codat's events. | | Integrations | Get a list of integrations supported by Codat and their logos. | | Refresh data | Initiate data refreshes, view pull status and history. | @@ -46,7 +45,6 @@ These end points cover creating and managing your companies, data connections, a * [Server Selection](#server-selection) * [Custom HTTP Client](#custom-http-client) * [Authentication](#authentication) -* [Special Types](#special-types) @@ -69,8 +67,8 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "log" ) @@ -105,10 +103,12 @@ func main() { ### [Companies](docs/sdks/companies/README.md) +* [AddProduct](docs/sdks/companies/README.md#addproduct) - Add product * [Create](docs/sdks/companies/README.md#create) - Create company * [Delete](docs/sdks/companies/README.md#delete) - Delete a company * [Get](docs/sdks/companies/README.md#get) - Get company * [List](docs/sdks/companies/README.md#list) - List companies +* [RemoveProduct](docs/sdks/companies/README.md#removeproduct) - Remove product * [Update](docs/sdks/companies/README.md#update) - Update company ### [ConnectionManagement](docs/sdks/connectionmanagement/README.md) @@ -136,13 +136,6 @@ func main() { * [List](docs/sdks/customdatatype/README.md#list) - List custom data type records * [Refresh](docs/sdks/customdatatype/README.md#refresh) - Refresh custom data type -### [Groups](docs/sdks/groups/README.md) - -* [AddCompany](docs/sdks/groups/README.md#addcompany) - Add company -* [Create](docs/sdks/groups/README.md#create) - Create group -* [List](docs/sdks/groups/README.md#list) - List groups -* [RemoveCompany](docs/sdks/groups/README.md#removecompany) - Remove company - ### [Integrations](docs/sdks/integrations/README.md) * [Get](docs/sdks/integrations/README.md#get) - Get integration @@ -180,11 +173,11 @@ func main() { ### [Webhooks](docs/sdks/webhooks/README.md) -* [~~Create~~](docs/sdks/webhooks/README.md#create) - Create webhook :warning: **Deprecated** +* [~~Create~~](docs/sdks/webhooks/README.md#create) - Create webhook (legacy) :warning: **Deprecated** * [CreateConsumer](docs/sdks/webhooks/README.md#createconsumer) - Create webhook consumer * [DeleteConsumer](docs/sdks/webhooks/README.md#deleteconsumer) - Delete webhook consumer -* [~~Get~~](docs/sdks/webhooks/README.md#get) - Get webhook :warning: **Deprecated** -* [~~List~~](docs/sdks/webhooks/README.md#list) - List webhooks :warning: **Deprecated** +* [~~Get~~](docs/sdks/webhooks/README.md#get) - Get webhook (legacy) :warning: **Deprecated** +* [~~List~~](docs/sdks/webhooks/README.md#list) - List webhooks (legacy) :warning: **Deprecated** * [ListConsumers](docs/sdks/webhooks/README.md#listconsumers) - List webhook consumers @@ -194,12 +187,6 @@ func main() { - -## Special Types - - - - ## Retries @@ -211,9 +198,9 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" "log" "pkg/models/operations" ) @@ -255,9 +242,9 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" "log" ) @@ -297,12 +284,16 @@ func main() { ## 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. +Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. + +By Default, an API error will return `sdkerrors.SDKError`. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. + +For example, the `CreateAPIKey` function may return the following errors: -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,409,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 409, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ### Example @@ -312,9 +303,9 @@ package main import ( "context" "errors" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "log" ) @@ -366,8 +357,8 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "log" ) @@ -402,8 +393,8 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "log" ) @@ -476,8 +467,8 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "log" ) diff --git a/platform/RELEASES.md b/platform/RELEASES.md index ef56c2caf..0bc9da13e 100644 --- a/platform/RELEASES.md +++ b/platform/RELEASES.md @@ -118,4 +118,14 @@ Based on: ### Generated - [go v3.4.0] platform ### Releases -- [Go v3.4.0] https://github.com/codatio/client-sdk-go/releases/tag/platform/v3.4.0 - platform \ No newline at end of file +- [Go v3.4.0] https://github.com/codatio/client-sdk-go/releases/tag/platform/v3.4.0 - platform + +## 2024-10-29 19:31:45 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.423.1 (2.442.11) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v4.0.0] platform +### Releases +- [Go v4.0.0] https://github.com/codatio/client-sdk-go/releases/tag/platform/v4.0.0 - platform \ No newline at end of file diff --git a/platform/USAGE.md b/platform/USAGE.md index 82cfcf6ac..883ae6340 100644 --- a/platform/USAGE.md +++ b/platform/USAGE.md @@ -4,8 +4,8 @@ package main import ( "context" - platform "github.com/codatio/client-sdk-go/platform/v3" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "log" ) diff --git a/platform/codatplatform.go b/platform/codatplatform.go index fcb252c07..c35d54ac8 100644 --- a/platform/codatplatform.go +++ b/platform/codatplatform.go @@ -5,10 +5,10 @@ package platform import ( "context" "fmt" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" "time" ) @@ -84,7 +84,6 @@ func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { // | Companies | Create and manage your SMB users' companies. | // | Connections | Create new and manage existing data connections for a company. | // | Connection management | Configure connection management UI and retrieve access tokens for authentication. | -// | Groups | Define and manage sets of companies based on a chosen characteristic. | // | Webhooks | Create and manage webhooks that listen to Codat's events. | // | Integrations | Get a list of integrations supported by Codat and their logos. | // | Refresh data | Initiate data refreshes, view pull status and history. | @@ -108,8 +107,6 @@ type CodatPlatform struct { PushData *PushData // Initiate data refreshes, view pull status and history. RefreshData *RefreshData - // Define and manage sets of companies based on a chosen characteristic. - Groups *Groups // Get a list of integrations supported by Codat and their logos. Integrations *Integrations // Configure and pull additional data you can include in Codat's standard data types. @@ -193,9 +190,9 @@ func New(opts ...SDKOption) *CodatPlatform { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "3.0.0", - SDKVersion: "3.4.0", - GenVersion: "2.415.6", - UserAgent: "speakeasy-sdk/go 3.4.0 2.415.6 3.0.0 github.com/codatio/client-sdk-go/platform", + SDKVersion: "4.0.0", + GenVersion: "2.442.11", + UserAgent: "speakeasy-sdk/go 4.0.0 2.442.11 3.0.0 github.com/codatio/client-sdk-go/platform", Hooks: hooks.New(), }, } @@ -229,8 +226,6 @@ func New(opts ...SDKOption) *CodatPlatform { sdk.RefreshData = newRefreshData(sdk.sdkConfiguration) - sdk.Groups = newGroups(sdk.sdkConfiguration) - sdk.Integrations = newIntegrations(sdk.sdkConfiguration) sdk.SupplementalData = newSupplementalData(sdk.sdkConfiguration) diff --git a/platform/companies.go b/platform/companies.go index 612341df3..d5b6ac01f 100644 --- a/platform/companies.go +++ b/platform/companies.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" "net/url" ) @@ -29,6 +28,212 @@ func newCompanies(sdkConfig sdkConfiguration) *Companies { } } +// AddProduct - Add product +// Use the *Add product* endpoint to enable a product for the company specified by `companyId`. +// +// > Note: This feature is currently in alpha and available only to participants in the development program. +func (s *Companies) AddProduct(ctx context.Context, request operations.AddProductRequest, opts ...operations.Option) (*operations.AddProductResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "add-product", + 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}/products/{productIdentifier}", 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, "PUT", 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.AddProductResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 := utils.ConsumeRawBody(httpRes) + 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 := utils.ConsumeRawBody(httpRes) + 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 := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + 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/platform-api#/schemas/Company) that represents your customer in Codat. // @@ -189,21 +394,11 @@ func (s *Companies) Create(ctx context.Context, request *shared.CompanyRequestBo RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -215,11 +410,10 @@ func (s *Companies) Create(ctx context.Context, request *shared.CompanyRequestBo res.Company = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -237,7 +431,7 @@ func (s *Companies) Create(ctx context.Context, request *shared.CompanyRequestBo case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -249,28 +443,25 @@ func (s *Companies) Create(ctx context.Context, request *shared.CompanyRequestBo return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -430,16 +621,6 @@ func (s *Companies) Delete(ctx context.Context, request operations.DeleteCompany RawResponse: 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: @@ -457,7 +638,7 @@ func (s *Companies) Delete(ctx context.Context, request operations.DeleteCompany case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -469,28 +650,25 @@ func (s *Companies) Delete(ctx context.Context, request operations.DeleteCompany return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -650,21 +828,11 @@ func (s *Companies) Get(ctx context.Context, request operations.GetCompanyReques RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -676,11 +844,10 @@ func (s *Companies) Get(ctx context.Context, request operations.GetCompanyReques res.Company = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -698,7 +865,7 @@ func (s *Companies) Get(ctx context.Context, request operations.GetCompanyReques case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -710,28 +877,25 @@ func (s *Companies) Get(ctx context.Context, request operations.GetCompanyReques return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -895,21 +1059,11 @@ func (s *Companies) List(ctx context.Context, request operations.ListCompaniesRe RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -921,11 +1075,10 @@ func (s *Companies) List(ctx context.Context, request operations.ListCompaniesRe res.Companies = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -945,7 +1098,7 @@ func (s *Companies) List(ctx context.Context, request operations.ListCompaniesRe case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -957,28 +1110,231 @@ func (s *Companies) List(ctx context.Context, request operations.ListCompaniesRe return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// RemoveProduct - Remove product +// Use the *Remove product* endpoint to disable a product for the company specified by `companyId`. +// +// > Note: This feature is currently in alpha and available only to participants in the development program. +func (s *Companies) RemoveProduct(ctx context.Context, request operations.RemoveProductRequest, opts ...operations.Option) (*operations.RemoveProductResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "remove-product", + 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}/products/{productIdentifier}", 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.RemoveProductResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 := utils.ConsumeRawBody(httpRes) + 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 := utils.ConsumeRawBody(httpRes) + 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 := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -988,7 +1344,6 @@ func (s *Companies) List(ctx context.Context, request operations.ListCompaniesRe // 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/platform-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/platform-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/platform-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. // // A [company](https://docs.codat.io/platform-api#/schemas/Company) represents a business sharing access to their data. // Each company can have multiple [connections](https://docs.codat.io/platform-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. @@ -1145,21 +1500,11 @@ func (s *Companies) Update(ctx context.Context, request operations.UpdateCompany RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1171,11 +1516,10 @@ func (s *Companies) Update(ctx context.Context, request operations.UpdateCompany res.Company = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1193,7 +1537,7 @@ func (s *Companies) Update(ctx context.Context, request operations.UpdateCompany case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1205,28 +1549,25 @@ func (s *Companies) Update(ctx context.Context, request operations.UpdateCompany return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/connectionmanagement.go b/platform/connectionmanagement.go index 1c9f9de14..d16810405 100644 --- a/platform/connectionmanagement.go +++ b/platform/connectionmanagement.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) @@ -182,21 +181,11 @@ func (s *ConnectionManagement) GetAccessToken(ctx context.Context, request opera RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -208,11 +197,10 @@ func (s *ConnectionManagement) GetAccessToken(ctx context.Context, request opera res.ConnectionManagementAccessToken = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -230,7 +218,7 @@ func (s *ConnectionManagement) GetAccessToken(ctx context.Context, request opera case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -242,28 +230,25 @@ func (s *ConnectionManagement) GetAccessToken(ctx context.Context, request opera return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/connections.go b/platform/connections.go index b37f2b943..de1f59494 100644 --- a/platform/connections.go +++ b/platform/connections.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) @@ -185,21 +184,11 @@ func (s *Connections) Create(ctx context.Context, request operations.CreateConne RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -211,11 +200,10 @@ func (s *Connections) Create(ctx context.Context, request operations.CreateConne res.Connection = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -233,7 +221,7 @@ func (s *Connections) Create(ctx context.Context, request operations.CreateConne case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -245,28 +233,25 @@ func (s *Connections) Create(ctx context.Context, request operations.CreateConne return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -424,16 +409,6 @@ func (s *Connections) Delete(ctx context.Context, request operations.DeleteConne RawResponse: 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: @@ -451,7 +426,7 @@ func (s *Connections) Delete(ctx context.Context, request operations.DeleteConne case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -463,28 +438,25 @@ func (s *Connections) Delete(ctx context.Context, request operations.DeleteConne return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -641,21 +613,11 @@ func (s *Connections) Get(ctx context.Context, request operations.GetConnectionR RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -667,11 +629,10 @@ func (s *Connections) Get(ctx context.Context, request operations.GetConnectionR res.Connection = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -689,7 +650,7 @@ func (s *Connections) Get(ctx context.Context, request operations.GetConnectionR case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -701,28 +662,25 @@ func (s *Connections) Get(ctx context.Context, request operations.GetConnectionR return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -883,21 +841,11 @@ func (s *Connections) List(ctx context.Context, request operations.ListConnectio RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -909,11 +857,10 @@ func (s *Connections) List(ctx context.Context, request operations.ListConnectio res.Connections = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -933,7 +880,7 @@ func (s *Connections) List(ctx context.Context, request operations.ListConnectio case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -945,28 +892,25 @@ func (s *Connections) List(ctx context.Context, request operations.ListConnectio return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1129,21 +1073,11 @@ func (s *Connections) Unlink(ctx context.Context, request operations.UnlinkConne RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1155,11 +1089,10 @@ func (s *Connections) Unlink(ctx context.Context, request operations.UnlinkConne res.Connection = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1177,7 +1110,7 @@ func (s *Connections) Unlink(ctx context.Context, request operations.UnlinkConne case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1189,28 +1122,25 @@ func (s *Connections) Unlink(ctx context.Context, request operations.UnlinkConne return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1373,21 +1303,11 @@ func (s *Connections) UpdateAuthorization(ctx context.Context, request operation RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1399,11 +1319,10 @@ func (s *Connections) UpdateAuthorization(ctx context.Context, request operation res.Connection = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1421,7 +1340,7 @@ func (s *Connections) UpdateAuthorization(ctx context.Context, request operation case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1433,28 +1352,25 @@ func (s *Connections) UpdateAuthorization(ctx context.Context, request operation return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/corssettings.go b/platform/corssettings.go index 7d955f1de..368c48223 100644 --- a/platform/corssettings.go +++ b/platform/corssettings.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" "net/url" ) @@ -181,21 +180,11 @@ func (s *CorsSettings) Get(ctx context.Context, opts ...operations.Option) (*ope RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -207,11 +196,10 @@ func (s *CorsSettings) Get(ctx context.Context, opts ...operations.Option) (*ope res.ConnectionManagementAllowedOrigins = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -229,7 +217,7 @@ func (s *CorsSettings) Get(ctx context.Context, opts ...operations.Option) (*ope case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -241,28 +229,25 @@ func (s *CorsSettings) Get(ctx context.Context, opts ...operations.Option) (*ope return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -429,21 +414,11 @@ func (s *CorsSettings) Set(ctx context.Context, request *shared.ConnectionManage RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -455,11 +430,10 @@ func (s *CorsSettings) Set(ctx context.Context, request *shared.ConnectionManage res.ConnectionManagementAllowedOrigins = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -477,7 +451,7 @@ func (s *CorsSettings) Set(ctx context.Context, request *shared.ConnectionManage case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -489,28 +463,25 @@ func (s *CorsSettings) Set(ctx context.Context, request *shared.ConnectionManage return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/customdatatype.go b/platform/customdatatype.go index f16310514..85a5ddc83 100644 --- a/platform/customdatatype.go +++ b/platform/customdatatype.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) @@ -193,21 +192,11 @@ func (s *CustomDataType) Configure(ctx context.Context, request operations.Confi RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -219,11 +208,10 @@ func (s *CustomDataType) Configure(ctx context.Context, request operations.Confi res.CustomDataTypeConfiguration = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -241,7 +229,7 @@ func (s *CustomDataType) Configure(ctx context.Context, request operations.Confi case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -253,28 +241,25 @@ func (s *CustomDataType) Configure(ctx context.Context, request operations.Confi return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -433,21 +418,11 @@ func (s *CustomDataType) GetConfiguration(ctx context.Context, request operation RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -459,11 +434,10 @@ func (s *CustomDataType) GetConfiguration(ctx context.Context, request operation res.CustomDataTypeRecords = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -481,7 +455,7 @@ func (s *CustomDataType) GetConfiguration(ctx context.Context, request operation case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -493,28 +467,25 @@ func (s *CustomDataType) GetConfiguration(ctx context.Context, request operation return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -677,21 +648,11 @@ func (s *CustomDataType) List(ctx context.Context, request operations.ListCustom RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -703,11 +664,10 @@ func (s *CustomDataType) List(ctx context.Context, request operations.ListCustom res.CustomDataTypeRecords = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -729,7 +689,7 @@ func (s *CustomDataType) List(ctx context.Context, request operations.ListCustom case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -741,28 +701,25 @@ func (s *CustomDataType) List(ctx context.Context, request operations.ListCustom return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -919,21 +876,11 @@ func (s *CustomDataType) Refresh(ctx context.Context, request operations.Refresh RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -945,11 +892,10 @@ func (s *CustomDataType) Refresh(ctx context.Context, request operations.Refresh res.PullOperation = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -969,7 +915,7 @@ func (s *CustomDataType) Refresh(ctx context.Context, request operations.Refresh case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -981,28 +927,25 @@ func (s *CustomDataType) Refresh(ctx context.Context, request operations.Refresh return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/docs/pkg/models/operations/addcompanytogrouprequest.md b/platform/docs/pkg/models/operations/addcompanytogrouprequest.md deleted file mode 100644 index ed5c4a3f5..000000000 --- a/platform/docs/pkg/models/operations/addcompanytogrouprequest.md +++ /dev/null @@ -1,9 +0,0 @@ -# AddCompanyToGroupRequest - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| `CompanyGroupAssignment` | [*shared.CompanyGroupAssignment](../../../pkg/models/shared/companygroupassignment.md) | :heavy_minus_sign: | N/A | | -| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/addproductrequest.md b/platform/docs/pkg/models/operations/addproductrequest.md new file mode 100644 index 000000000..56bc7e14e --- /dev/null +++ b/platform/docs/pkg/models/operations/addproductrequest.md @@ -0,0 +1,9 @@ +# AddProductRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ProductIdentifier` | *string* | :heavy_check_mark: | Human-readable product identifier for a product. | bank-feeds | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/removecompanyfromgroupresponse.md b/platform/docs/pkg/models/operations/addproductresponse.md similarity index 97% rename from platform/docs/pkg/models/operations/removecompanyfromgroupresponse.md rename to platform/docs/pkg/models/operations/addproductresponse.md index 855ac90c1..b2c155aff 100644 --- a/platform/docs/pkg/models/operations/removecompanyfromgroupresponse.md +++ b/platform/docs/pkg/models/operations/addproductresponse.md @@ -1,4 +1,4 @@ -# RemoveCompanyFromGroupResponse +# AddProductResponse ## Fields diff --git a/platform/docs/pkg/models/operations/deleteapikeyresponse.md b/platform/docs/pkg/models/operations/deleteapikeyresponse.md index 6c9263776..095adae9e 100644 --- a/platform/docs/pkg/models/operations/deleteapikeyresponse.md +++ b/platform/docs/pkg/models/operations/deleteapikeyresponse.md @@ -6,6 +6,6 @@ | Field | Type | Required | Description | | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | | `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | -| `ErrorMessage` | **sdkerrors.ErrorMessage* | :heavy_minus_sign: | Too many requests were made in a given amount of time. Wait a short period and then try again. | +| `ErrorMessage` | [*shared.ErrorMessage](../../../pkg/models/shared/errormessage.md) | :heavy_minus_sign: | Too many requests were made in a given amount of time. Wait a short period and then try again. | | `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | | `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/getcreateupdatemodeloptionsbydatatyperequest.md b/platform/docs/pkg/models/operations/getcreateupdatemodeloptionsbydatatyperequest.md index e742b1b30..9343015c8 100644 --- a/platform/docs/pkg/models/operations/getcreateupdatemodeloptionsbydatatyperequest.md +++ b/platform/docs/pkg/models/operations/getcreateupdatemodeloptionsbydatatyperequest.md @@ -7,4 +7,4 @@ | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | | `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 | -| `DataType` | [shared.SchemaDataType](../../../pkg/models/shared/schemadatatype.md) | :heavy_check_mark: | The key of a Codat data type | invoices | \ No newline at end of file +| `DataType` | [shared.SchemaDataType](../../../pkg/models/shared/schemadatatype.md) | :heavy_check_mark: | The key of a Codat data type. | invoices | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/refreshdatatyperequest.md b/platform/docs/pkg/models/operations/refreshdatatyperequest.md index beaf79aa9..de1e012c3 100644 --- a/platform/docs/pkg/models/operations/refreshdatatyperequest.md +++ b/platform/docs/pkg/models/operations/refreshdatatyperequest.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | | `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | | `ConnectionID` | **string* | :heavy_minus_sign: | Optionally, provide a data connection id to only queue pull operations on that connection. | | -| `DataType` | [shared.SchemaDataType](../../../pkg/models/shared/schemadatatype.md) | :heavy_check_mark: | The key of a Codat data type | invoices | \ No newline at end of file +| `DataType` | [shared.SchemaDataType](../../../pkg/models/shared/schemadatatype.md) | :heavy_check_mark: | The key of a Codat data type. | invoices | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/removecompanyfromgrouprequest.md b/platform/docs/pkg/models/operations/removecompanyfromgrouprequest.md deleted file mode 100644 index 37c3fa6b2..000000000 --- a/platform/docs/pkg/models/operations/removecompanyfromgrouprequest.md +++ /dev/null @@ -1,9 +0,0 @@ -# RemoveCompanyFromGroupRequest - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | -| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | -| `GroupID` | *string* | :heavy_check_mark: | Unique identifier for the group. | 60d2fa12-8a04-11ee-b9d1-0242ac120002 | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/removeproductrequest.md b/platform/docs/pkg/models/operations/removeproductrequest.md new file mode 100644 index 000000000..2385c8332 --- /dev/null +++ b/platform/docs/pkg/models/operations/removeproductrequest.md @@ -0,0 +1,9 @@ +# RemoveProductRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | +| `CompanyID` | *string* | :heavy_check_mark: | Unique identifier for a company. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `ProductIdentifier` | *string* | :heavy_check_mark: | Human-readable product identifier for a product. | bank-feeds | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/creategroupresponse.md b/platform/docs/pkg/models/operations/removeproductresponse.md similarity index 82% rename from platform/docs/pkg/models/operations/creategroupresponse.md rename to platform/docs/pkg/models/operations/removeproductresponse.md index a2c4cef01..dcd389905 100644 --- a/platform/docs/pkg/models/operations/creategroupresponse.md +++ b/platform/docs/pkg/models/operations/removeproductresponse.md @@ -1,4 +1,4 @@ -# CreateGroupResponse +# RemoveProductResponse ## Fields @@ -6,6 +6,5 @@ | Field | Type | Required | Description | | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | | `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | -| `Group` | [*shared.Group](../../../pkg/models/shared/group.md) | :heavy_minus_sign: | Success | | `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | | `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/sdkerrors/errormessage.md b/platform/docs/pkg/models/sdkerrors/errormessage.md index a204d665a..f95c4e2f6 100644 --- a/platform/docs/pkg/models/sdkerrors/errormessage.md +++ b/platform/docs/pkg/models/sdkerrors/errormessage.md @@ -1,6 +1,6 @@ # ErrorMessage -Bad Request +Your API request was not properly authorized. ## Fields diff --git a/platform/docs/pkg/models/shared/company.md b/platform/docs/pkg/models/shared/company.md index 378573680..e54e352c8 100644 --- a/platform/docs/pkg/models/shared/company.md +++ b/platform/docs/pkg/models/shared/company.md @@ -18,5 +18,6 @@ When you create a company, you can specify a `name` and we will automatically ge | `ID` | *string* | :heavy_check_mark: | Unique identifier for your SMB in Codat. | 8a210b68-6988-11ed-a1eb-0242ac120002 | | `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 | | `Name` | *string* | :heavy_check_mark: | The name of the company | Codat Ltd. | +| `Products` | []*string* | :heavy_minus_sign: | An array of products that are currently enabled for the company. | | | `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 | -| `Tags` | [*shared.CompanyTags](../../../pkg/models/shared/companytags.md) | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file +| `Tags` | map[string]*string* | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/companydetails.md b/platform/docs/pkg/models/shared/companydetails.md index 4a9642098..a89dd17c9 100644 --- a/platform/docs/pkg/models/shared/companydetails.md +++ b/platform/docs/pkg/models/shared/companydetails.md @@ -11,5 +11,6 @@ | `ID` | *string* | :heavy_check_mark: | Unique identifier for your SMB in Codat. | 8a210b68-6988-11ed-a1eb-0242ac120002 | | `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 | | `Name` | *string* | :heavy_check_mark: | The name of the company | Codat Ltd. | +| `Products` | []*string* | :heavy_minus_sign: | An array of products that are currently enabled for the company. | | | `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 | -| `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. | | \ No newline at end of file +| `Tags` | map[string]*string* | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/companygroupassignment.md b/platform/docs/pkg/models/shared/companygroupassignment.md deleted file mode 100644 index 9c65380f3..000000000 --- a/platform/docs/pkg/models/shared/companygroupassignment.md +++ /dev/null @@ -1,8 +0,0 @@ -# CompanyGroupAssignment - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | -| `GroupID` | **string* | :heavy_minus_sign: | N/A | 60d2fa12-8a04-11ee-b9d1-0242ac120002 | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/companyreference.md b/platform/docs/pkg/models/shared/companyreference.md index a9c3e1a09..846191395 100644 --- a/platform/docs/pkg/models/shared/companyreference.md +++ b/platform/docs/pkg/models/shared/companyreference.md @@ -7,4 +7,6 @@ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | `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. | | `ID` | **string* | :heavy_minus_sign: | Unique identifier for your SMB in Codat. | 8a210b68-6988-11ed-a1eb-0242ac120002 | -| `Name` | **string* | :heavy_minus_sign: | The name of the company | Codat Ltd. | \ No newline at end of file +| `Links` | [*shared.CompanyReferenceLinks](../../../pkg/models/shared/companyreferencelinks.md) | :heavy_minus_sign: | A collection of links for the company. | | +| `Name` | **string* | :heavy_minus_sign: | The name of the company | Codat Ltd. | +| `Tags` | map[string]*string* | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/companyreferencelinks.md b/platform/docs/pkg/models/shared/companyreferencelinks.md new file mode 100644 index 000000000..18ebbd889 --- /dev/null +++ b/platform/docs/pkg/models/shared/companyreferencelinks.md @@ -0,0 +1,10 @@ +# CompanyReferenceLinks + +A collection of links for the company. + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------- | --------------------------------------- | --------------------------------------- | --------------------------------------- | +| `Portal` | **string* | :heavy_minus_sign: | Link to the company page in the portal. | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/companyrequestbody.md b/platform/docs/pkg/models/shared/companyrequestbody.md index 2a142a13e..1112f18df 100644 --- a/platform/docs/pkg/models/shared/companyrequestbody.md +++ b/platform/docs/pkg/models/shared/companyrequestbody.md @@ -6,5 +6,5 @@ | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | `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.GroupRef](../../../pkg/models/shared/groupref.md) | :heavy_minus_sign: | Reference to the groups that the company is assigned to. | | -| `Name` | *string* | :heavy_check_mark: | Name of company being connected. | Bank of Dave | \ No newline at end of file +| `Name` | *string* | :heavy_check_mark: | Name of company being connected. | Bank of Dave | +| `Tags` | map[string]*string* | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/companytags.md b/platform/docs/pkg/models/shared/companytags.md deleted file mode 100644 index cbbb3f90f..000000000 --- a/platform/docs/pkg/models/shared/companytags.md +++ /dev/null @@ -1,9 +0,0 @@ -# CompanyTags - -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/platform/docs/pkg/models/shared/connection.md b/platform/docs/pkg/models/shared/connection.md index c0825639c..d6057383c 100644 --- a/platform/docs/pkg/models/shared/connection.md +++ b/platform/docs/pkg/models/shared/connection.md @@ -16,7 +16,6 @@ Before you can use a data connection to pull or push data, the company must gran | Field | Type | Required | Description | Example | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `AdditionalProperties` | *any* | :heavy_minus_sign: | N/A | | | `ConnectionInfo` | map[string]*string* | :heavy_minus_sign: | N/A | | | `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 | | diff --git a/platform/docs/pkg/models/shared/connectionmanagementallowedorigins.md b/platform/docs/pkg/models/shared/connectionmanagementallowedorigins.md index 95b4d4e9b..e95883ade 100644 --- a/platform/docs/pkg/models/shared/connectionmanagementallowedorigins.md +++ b/platform/docs/pkg/models/shared/connectionmanagementallowedorigins.md @@ -1,5 +1,7 @@ # ConnectionManagementAllowedOrigins +Success + ## Fields diff --git a/platform/docs/pkg/models/operations/addcompanytogroupresponse.md b/platform/docs/pkg/models/shared/connectionwebhook.md similarity index 83% rename from platform/docs/pkg/models/operations/addcompanytogroupresponse.md rename to platform/docs/pkg/models/shared/connectionwebhook.md index e0932a80c..67ab18649 100644 --- a/platform/docs/pkg/models/operations/addcompanytogroupresponse.md +++ b/platform/docs/pkg/models/shared/connectionwebhook.md @@ -1,11 +1,11 @@ -# AddCompanyToGroupResponse +# ConnectionWebhook ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Company` | [*shared.Company](../../../pkg/models/shared/company.md) | :heavy_minus_sign: | Success | {
"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"
}
]
} | -| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | | -| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | | -| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `EventType` | **string* | :heavy_minus_sign: | The type of event. | connection.created | +| `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 | +| `ID` | **string* | :heavy_minus_sign: | Unique identifier of the event. | ba29118f-5406-4e59-b05c-ba307ca38d01 | +| `Payload` | [*shared.ConnectionWebhookPayload](../../../pkg/models/shared/connectionwebhookpayload.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/connectionwebhookpayload.md b/platform/docs/pkg/models/shared/connectionwebhookpayload.md new file mode 100644 index 000000000..0c7788229 --- /dev/null +++ b/platform/docs/pkg/models/shared/connectionwebhookpayload.md @@ -0,0 +1,9 @@ +# ConnectionWebhookPayload + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Connection` | [*shared.Connection](../../../pkg/models/shared/connection.md) | :heavy_minus_sign: | A connection represents a [company's](https://docs.codat.io/platform-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). | {
"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"
} | +| `ReferenceCompany` | [*shared.CompanyReference](../../../pkg/models/shared/companyreference.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/datastatus.md b/platform/docs/pkg/models/shared/datastatus.md index 08183a434..0b10781b8 100644 --- a/platform/docs/pkg/models/shared/datastatus.md +++ b/platform/docs/pkg/models/shared/datastatus.md @@ -8,7 +8,7 @@ Describes the state of data in the Codat cache for a company and data type | Field | Type | Required | Description | Example | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `CurrentStatus` | [shared.Status](../../../pkg/models/shared/status.md) | :heavy_check_mark: | The current status of the dataset. | | -| `DataType` | [shared.DataTypes](../../../pkg/models/shared/datatypes.md) | :heavy_check_mark: | Available data types | invoices | +| `DataType` | [shared.DataStatusDataTypes](../../../pkg/models/shared/datastatusdatatypes.md) | :heavy_check_mark: | Available data types | invoices | | `LastSuccessfulSync` | *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 | | `LatestSuccessfulSyncID` | **string* | :heavy_minus_sign: | Unique identifier for the most recent successful sync of data type. | 8220fc90-55b6-47bc-9417-48ac6ea93101 | | `LatestSyncID` | **string* | :heavy_minus_sign: | Unique identifier for most recent sync of data type. | ad474a37-2003-478e-baee-9af9f1ec2fe3 | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/datastatusdatatypes.md b/platform/docs/pkg/models/shared/datastatusdatatypes.md new file mode 100644 index 000000000..a810312b0 --- /dev/null +++ b/platform/docs/pkg/models/shared/datastatusdatatypes.md @@ -0,0 +1,52 @@ +# DataStatusDataTypes + +Available data types + + +## Values + +| Name | Value | +| ------------------------------------------------- | ------------------------------------------------- | +| `DataStatusDataTypesAccountTransactions` | accountTransactions | +| `DataStatusDataTypesBalanceSheet` | balanceSheet | +| `DataStatusDataTypesBankAccounts` | bankAccounts | +| `DataStatusDataTypesBankTransactions` | bankTransactions | +| `DataStatusDataTypesBillCreditNotes` | billCreditNotes | +| `DataStatusDataTypesBillPayments` | billPayments | +| `DataStatusDataTypesBills` | bills | +| `DataStatusDataTypesCashFlowStatement` | cashFlowStatement | +| `DataStatusDataTypesChartOfAccounts` | chartOfAccounts | +| `DataStatusDataTypesCompany` | company | +| `DataStatusDataTypesCreditNotes` | creditNotes | +| `DataStatusDataTypesCustomers` | customers | +| `DataStatusDataTypesDirectCosts` | directCosts | +| `DataStatusDataTypesDirectIncomes` | directIncomes | +| `DataStatusDataTypesInvoices` | invoices | +| `DataStatusDataTypesItemReceipts` | itemReceipts | +| `DataStatusDataTypesItems` | items | +| `DataStatusDataTypesJournalEntries` | journalEntries | +| `DataStatusDataTypesJournals` | journals | +| `DataStatusDataTypesPaymentMethods` | paymentMethods | +| `DataStatusDataTypesPayments` | payments | +| `DataStatusDataTypesProfitAndLoss` | profitAndLoss | +| `DataStatusDataTypesPurchaseOrders` | purchaseOrders | +| `DataStatusDataTypesSalesOrders` | salesOrders | +| `DataStatusDataTypesSuppliers` | suppliers | +| `DataStatusDataTypesTaxRates` | taxRates | +| `DataStatusDataTypesTrackingCategories` | trackingCategories | +| `DataStatusDataTypesTransfers` | transfers | +| `DataStatusDataTypesBankingAccountBalances` | banking-accountBalances | +| `DataStatusDataTypesBankingAccounts` | banking-accounts | +| `DataStatusDataTypesBankingTransactionCategories` | banking-transactionCategories | +| `DataStatusDataTypesBankingTransactions` | banking-transactions | +| `DataStatusDataTypesCommerceCompanyInfo` | commerce-companyInfo | +| `DataStatusDataTypesCommerceCustomers` | commerce-customers | +| `DataStatusDataTypesCommerceDisputes` | commerce-disputes | +| `DataStatusDataTypesCommerceLocations` | commerce-locations | +| `DataStatusDataTypesCommerceOrders` | commerce-orders | +| `DataStatusDataTypesCommercePaymentMethods` | commerce-paymentMethods | +| `DataStatusDataTypesCommercePayments` | commerce-payments | +| `DataStatusDataTypesCommerceProductCategories` | commerce-productCategories | +| `DataStatusDataTypesCommerceProducts` | commerce-products | +| `DataStatusDataTypesCommerceTaxComponents` | commerce-taxComponents | +| `DataStatusDataTypesCommerceTransactions` | commerce-transactions | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/datatypes.md b/platform/docs/pkg/models/shared/datatypes.md index 61fa6bc31..4ad4b1019 100644 --- a/platform/docs/pkg/models/shared/datatypes.md +++ b/platform/docs/pkg/models/shared/datatypes.md @@ -1,52 +1,11 @@ # DataTypes -Available data types +## Fields -## Values - -| Name | Value | -| --------------------------------------- | --------------------------------------- | -| `DataTypesAccountTransactions` | accountTransactions | -| `DataTypesBalanceSheet` | balanceSheet | -| `DataTypesBankAccounts` | bankAccounts | -| `DataTypesBankTransactions` | bankTransactions | -| `DataTypesBillCreditNotes` | billCreditNotes | -| `DataTypesBillPayments` | billPayments | -| `DataTypesBills` | bills | -| `DataTypesCashFlowStatement` | cashFlowStatement | -| `DataTypesChartOfAccounts` | chartOfAccounts | -| `DataTypesCompany` | company | -| `DataTypesCreditNotes` | creditNotes | -| `DataTypesCustomers` | customers | -| `DataTypesDirectCosts` | directCosts | -| `DataTypesDirectIncomes` | directIncomes | -| `DataTypesInvoices` | invoices | -| `DataTypesItemReceipts` | itemReceipts | -| `DataTypesItems` | items | -| `DataTypesJournalEntries` | journalEntries | -| `DataTypesJournals` | journals | -| `DataTypesPaymentMethods` | paymentMethods | -| `DataTypesPayments` | payments | -| `DataTypesProfitAndLoss` | profitAndLoss | -| `DataTypesPurchaseOrders` | purchaseOrders | -| `DataTypesSalesOrders` | salesOrders | -| `DataTypesSuppliers` | suppliers | -| `DataTypesTaxRates` | taxRates | -| `DataTypesTrackingCategories` | trackingCategories | -| `DataTypesTransfers` | transfers | -| `DataTypesBankingAccountBalances` | banking-accountBalances | -| `DataTypesBankingAccounts` | banking-accounts | -| `DataTypesBankingTransactionCategories` | banking-transactionCategories | -| `DataTypesBankingTransactions` | banking-transactions | -| `DataTypesCommerceCompanyInfo` | commerce-companyInfo | -| `DataTypesCommerceCustomers` | commerce-customers | -| `DataTypesCommerceDisputes` | commerce-disputes | -| `DataTypesCommerceLocations` | commerce-locations | -| `DataTypesCommerceOrders` | commerce-orders | -| `DataTypesCommercePaymentMethods` | commerce-paymentMethods | -| `DataTypesCommercePayments` | commerce-payments | -| `DataTypesCommerceProductCategories` | commerce-productCategories | -| `DataTypesCommerceProducts` | commerce-products | -| `DataTypesCommerceTaxComponents` | commerce-taxComponents | -| `DataTypesCommerceTransactions` | commerce-transactions | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `ConnectionID` | **string* | :heavy_minus_sign: | Unique identifier for a company's data connection. | 2e9d2c44-f675-40ba-8049-353bfcb5e171 | +| `DataType` | [*shared.DataType](../../../pkg/models/shared/datatype.md) | :heavy_minus_sign: | Available data types | invoices | +| `RecordsModified` | **bool* | :heavy_minus_sign: | `True` if records have been created, updated or deleted in Codat's cache. | false | +| `Status` | [*shared.Status](../../../pkg/models/shared/status.md) | :heavy_minus_sign: | The current status of the dataset. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/errormessage.md b/platform/docs/pkg/models/shared/errormessage.md new file mode 100644 index 000000000..f95c4e2f6 --- /dev/null +++ b/platform/docs/pkg/models/shared/errormessage.md @@ -0,0 +1,16 @@ +# ErrorMessage + +Your API request was not properly authorized. + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `CanBeRetried` | **string* | :heavy_minus_sign: | `True` if the error occurred transiently and can be retried. | +| `CorrelationID` | **string* | :heavy_minus_sign: | Unique identifier used to propagate to all downstream services and determine the source of the error. | +| `DetailedErrorCode` | **int64* | :heavy_minus_sign: | Machine readable error code used to automate processes based on the code returned. | +| `Error` | **string* | :heavy_minus_sign: | A brief description of the error. | +| `Service` | **string* | :heavy_minus_sign: | Codat's service the returned the error. | +| `StatusCode` | **int64* | :heavy_minus_sign: | The HTTP status code returned by 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. | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/group.md b/platform/docs/pkg/models/shared/group.md deleted file mode 100644 index 818114209..000000000 --- a/platform/docs/pkg/models/shared/group.md +++ /dev/null @@ -1,11 +0,0 @@ -# Group - -A container you can use to organize companies together according to a shared characteristic of your choice. - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | -| `ID` | **string* | :heavy_minus_sign: | Unique identifier for the group. | 60d2fa12-8a04-11ee-b9d1-0242ac120002 | -| `Name` | **string* | :heavy_minus_sign: | Descriptive name of the group. | Invoice finance team | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/groupprototype.md b/platform/docs/pkg/models/shared/groupprototype.md deleted file mode 100644 index 70d0a4a1b..000000000 --- a/platform/docs/pkg/models/shared/groupprototype.md +++ /dev/null @@ -1,10 +0,0 @@ -# GroupPrototype - -The group template used to create a group. - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | -| `Name` | **string* | :heavy_minus_sign: | Descriptive name of the group. | Invoice finance team | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/groupref.md b/platform/docs/pkg/models/shared/groupref.md deleted file mode 100644 index 1378c60ee..000000000 --- a/platform/docs/pkg/models/shared/groupref.md +++ /dev/null @@ -1,8 +0,0 @@ -# GroupRef - - -## 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/platform/docs/pkg/models/shared/groups.md b/platform/docs/pkg/models/shared/groups.md deleted file mode 100644 index db0a65895..000000000 --- a/platform/docs/pkg/models/shared/groups.md +++ /dev/null @@ -1,8 +0,0 @@ -# Groups - - -## Fields - -| Field | Type | Required | Description | -| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | -| `Results` | [][shared.Group](../../../pkg/models/shared/group.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/readcompletedwebhook.md b/platform/docs/pkg/models/shared/readcompletedwebhook.md new file mode 100644 index 000000000..dd12e6275 --- /dev/null +++ b/platform/docs/pkg/models/shared/readcompletedwebhook.md @@ -0,0 +1,11 @@ +# ReadCompletedWebhook + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `EventType` | **string* | :heavy_minus_sign: | The type of event. | | +| `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 | +| `ID` | **string* | :heavy_minus_sign: | Unique identifier of the event. | 743ec94a-8aa4-44bb-8bd4-e1855ee0e74b | +| `Payload` | [*shared.ReadCompletedWebhookPayload](../../../pkg/models/shared/readcompletedwebhookpayload.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/readcompletedwebhookpayload.md b/platform/docs/pkg/models/shared/readcompletedwebhookpayload.md new file mode 100644 index 000000000..65df32e14 --- /dev/null +++ b/platform/docs/pkg/models/shared/readcompletedwebhookpayload.md @@ -0,0 +1,10 @@ +# ReadCompletedWebhookPayload + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `DataTypes` | [][shared.DataTypes](../../../pkg/models/shared/datatypes.md) | :heavy_minus_sign: | N/A | | +| `ModifiedFromDate` | **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 | +| `ReferenceCompany` | [*shared.CompanyReference](../../../pkg/models/shared/companyreference.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/tags.md b/platform/docs/pkg/models/shared/tags.md deleted file mode 100644 index 6de993aa8..000000000 --- a/platform/docs/pkg/models/shared/tags.md +++ /dev/null @@ -1,9 +0,0 @@ -# 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/platform/docs/pkg/models/shared/webhookconsumer.md b/platform/docs/pkg/models/shared/webhookconsumer.md index a80ef9511..98ac9d7ef 100644 --- a/platform/docs/pkg/models/shared/webhookconsumer.md +++ b/platform/docs/pkg/models/shared/webhookconsumer.md @@ -8,10 +8,11 @@ See our documentation for more details on [Codat's webhook service](https://docs ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CompanyID` | **string* | :heavy_minus_sign: | Unique identifier of the company to indicate company-specific events. The associated webhook consumer will receive events only for the specified ID. | 8a210b68-6988-11ed-a1eb-0242ac120002 | -| `Disabled` | **bool* | :heavy_minus_sign: | Flag that enables or disables the endpoint from receiving events. Disabled when set to `true`. | | -| `EventTypes` | []*string* | :heavy_minus_sign: | An array of event types the webhook consumer subscribes to. | | -| `ID` | **string* | :heavy_minus_sign: | Unique identifier for the webhook consumer. | 8a210b68-6988-11ed-a1eb-0242ac120002 | -| `URL` | **string* | :heavy_minus_sign: | The URL that will consume webhook events dispatched by Codat. | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ~~`CompanyID`~~ | **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 of the company to indicate company-specific events. The associated webhook consumer will receive events only for the specified ID. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `CompanyTags` | []*string* | :heavy_minus_sign: | Company tags provide an additional way to filter messages, independent of event types. Company tags are case-sensitive, and only messages from companies with matching tags will be sent to this endpoint. Use the format `tagKey:tagValue`. | | +| `Disabled` | **bool* | :heavy_minus_sign: | Flag that enables or disables the endpoint from receiving events. Disabled when set to `true`. | | +| `EventTypes` | []*string* | :heavy_minus_sign: | An array of event types the webhook consumer subscribes to. | | +| `ID` | **string* | :heavy_minus_sign: | Unique identifier for the webhook consumer. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `URL` | **string* | :heavy_minus_sign: | The URL that will consume webhook events dispatched by Codat. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/shared/webhookconsumerprototype.md b/platform/docs/pkg/models/shared/webhookconsumerprototype.md index 1d8cc469a..aeae3262f 100644 --- a/platform/docs/pkg/models/shared/webhookconsumerprototype.md +++ b/platform/docs/pkg/models/shared/webhookconsumerprototype.md @@ -3,9 +3,10 @@ ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CompanyID` | **string* | :heavy_minus_sign: | Unique identifier of the company to indicate company-specific events. The associated webhook consumer will receive events only for the specified ID. | 8a210b68-6988-11ed-a1eb-0242ac120002 | -| `Disabled` | **bool* | :heavy_minus_sign: | Flag that enables or disables the endpoint from receiving events. Disabled when set to `true`. | | -| `EventTypes` | []*string* | :heavy_minus_sign: | An array of event types the webhook consumer subscribes to. | | -| `URL` | **string* | :heavy_minus_sign: | The URL that will consume webhook events dispatched by Codat. | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ~~`CompanyID`~~ | **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 of the company to indicate company-specific events. The associated webhook consumer will receive events only for the specified ID. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `CompanyTags` | []*string* | :heavy_minus_sign: | Company tags provide an additional way to filter messages, independent of event types. Company tags are case-sensitive, and only messages from companies with matching tags will be sent to this endpoint. Use the format `tagKey:tagValue`. | | +| `Disabled` | **bool* | :heavy_minus_sign: | Flag that enables or disables the endpoint from receiving events. Disabled when set to `true`. | | +| `EventTypes` | []*string* | :heavy_minus_sign: | An array of event types the webhook consumer subscribes to. | | +| `URL` | **string* | :heavy_minus_sign: | The URL that will consume webhook events dispatched by Codat. | | \ No newline at end of file diff --git a/platform/docs/pkg/models/operations/listgroupsresponse.md b/platform/docs/pkg/models/webhooks/connectionconnectedresponse.md similarity index 79% rename from platform/docs/pkg/models/operations/listgroupsresponse.md rename to platform/docs/pkg/models/webhooks/connectionconnectedresponse.md index f39cabb25..b76582949 100644 --- a/platform/docs/pkg/models/operations/listgroupsresponse.md +++ b/platform/docs/pkg/models/webhooks/connectionconnectedresponse.md @@ -1,4 +1,4 @@ -# ListGroupsResponse +# ConnectionConnectedResponse ## Fields @@ -7,5 +7,4 @@ | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | | `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | | `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | -| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | -| `Groups` | [*shared.Groups](../../../pkg/models/shared/groups.md) | :heavy_minus_sign: | Success | \ No newline at end of file +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/connectioncreatedresponse.md b/platform/docs/pkg/models/webhooks/connectioncreatedresponse.md new file mode 100644 index 000000000..9ccbc1ff2 --- /dev/null +++ b/platform/docs/pkg/models/webhooks/connectioncreatedresponse.md @@ -0,0 +1,10 @@ +# ConnectionCreatedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/connectiondeletedresponse.md b/platform/docs/pkg/models/webhooks/connectiondeletedresponse.md new file mode 100644 index 000000000..fcf6e8633 --- /dev/null +++ b/platform/docs/pkg/models/webhooks/connectiondeletedresponse.md @@ -0,0 +1,10 @@ +# ConnectionDeletedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/connectiondisconnectedresponse.md b/platform/docs/pkg/models/webhooks/connectiondisconnectedresponse.md new file mode 100644 index 000000000..309302e43 --- /dev/null +++ b/platform/docs/pkg/models/webhooks/connectiondisconnectedresponse.md @@ -0,0 +1,10 @@ +# ConnectionDisconnectedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/connectionfailedresponse.md b/platform/docs/pkg/models/webhooks/connectionfailedresponse.md new file mode 100644 index 000000000..d10d06063 --- /dev/null +++ b/platform/docs/pkg/models/webhooks/connectionfailedresponse.md @@ -0,0 +1,10 @@ +# ConnectionFailedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/connectionreconnectedresponse.md b/platform/docs/pkg/models/webhooks/connectionreconnectedresponse.md new file mode 100644 index 000000000..2877e4976 --- /dev/null +++ b/platform/docs/pkg/models/webhooks/connectionreconnectedresponse.md @@ -0,0 +1,10 @@ +# ConnectionReconnectedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/readcompletedinitialresponse.md b/platform/docs/pkg/models/webhooks/readcompletedinitialresponse.md new file mode 100644 index 000000000..68a6f0e5a --- /dev/null +++ b/platform/docs/pkg/models/webhooks/readcompletedinitialresponse.md @@ -0,0 +1,10 @@ +# ReadCompletedInitialResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/pkg/models/webhooks/readcompletedresponse.md b/platform/docs/pkg/models/webhooks/readcompletedresponse.md new file mode 100644 index 000000000..3a7927857 --- /dev/null +++ b/platform/docs/pkg/models/webhooks/readcompletedresponse.md @@ -0,0 +1,10 @@ +# ReadCompletedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/platform/docs/sdks/codatplatform/README.md b/platform/docs/sdks/codatplatform/README.md index 2667f7245..7d44d62e5 100644 --- a/platform/docs/sdks/codatplatform/README.md +++ b/platform/docs/sdks/codatplatform/README.md @@ -17,7 +17,6 @@ These end points cover creating and managing your companies, data connections, a | Companies | Create and manage your SMB users' companies. | | Connections | Create new and manage existing data connections for a company. | | Connection management | Configure connection management UI and retrieve access tokens for authentication. | -| Groups | Define and manage sets of companies based on a chosen characteristic. | | Webhooks | Create and manage webhooks that listen to Codat's events. | | Integrations | Get a list of integrations supported by Codat and their logos. | | Refresh data | Initiate data refreshes, view pull status and history. | diff --git a/platform/docs/sdks/companies/README.md b/platform/docs/sdks/companies/README.md index 7a3b11d89..0942e0922 100644 --- a/platform/docs/sdks/companies/README.md +++ b/platform/docs/sdks/companies/README.md @@ -7,12 +7,73 @@ Create and manage your SMB users' companies. ### Available Operations +* [AddProduct](#addproduct) - Add product * [Create](#create) - Create company * [Delete](#delete) - Delete a company * [Get](#get) - Get company * [List](#list) - List companies +* [RemoveProduct](#removeproduct) - Remove product * [Update](#update) - Update company +## AddProduct + +Use the *Add product* endpoint to enable a product for the company specified by `companyId`. + +> Note: This feature is currently in alpha and available only to participants in the development program. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "context" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "log" +) + +func main() { + s := platform.New( + platform.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.AddProduct(ctx, operations.AddProductRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ProductIdentifier: "lending", + }) + 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.AddProductRequest](../../pkg/models/operations/addproductrequest.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.AddProductResponse](../../pkg/models/operations/addproductresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 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/platform-api#/schemas/Company) that represents your customer in Codat. @@ -28,8 +89,8 @@ If forbidden characters (see `name` pattern) are present in the request, a compa package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -44,11 +105,6 @@ func main() { ctx := context.Background() res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{ Description: platform.String("Requested early access to the new financing scheme."), - Groups: []shared.GroupRef{ - shared.GroupRef{ - ID: platform.String("60d2fa12-8a04-11ee-b9d1-0242ac120002"), - }, - }, Name: "Technicalium", }) if err != nil { @@ -74,11 +130,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -94,10 +149,10 @@ Each company can have multiple [connections](https://docs.codat.io/platform-api# package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -135,11 +190,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -155,10 +209,10 @@ Each company can have multiple [connections](https://docs.codat.io/platform-api# package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -196,11 +250,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## List @@ -215,10 +268,10 @@ Each company can have multiple [connections](https://docs.codat.io/platform-api# package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -259,16 +312,73 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | + +## RemoveProduct + +Use the *Remove product* endpoint to disable a product for the company specified by `companyId`. + +> Note: This feature is currently in alpha and available only to participants in the development program. + +### Example Usage + +```go +package main + +import( + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" + "context" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "log" +) + +func main() { + s := platform.New( + platform.WithSecurity(shared.Security{ + AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", + }), + ) + + ctx := context.Background() + res, err := s.Companies.RemoveProduct(ctx, operations.RemoveProductRequest{ + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ProductIdentifier: "expenses", + }) + 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.RemoveProductRequest](../../pkg/models/operations/removeproductrequest.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.RemoveProductResponse](../../pkg/models/operations/removeproductresponse.md), error** + +### Errors +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 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/platform-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/platform-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/platform-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. A [company](https://docs.codat.io/platform-api#/schemas/Company) represents a business sharing access to their data. Each company can have multiple [connections](https://docs.codat.io/platform-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. @@ -279,10 +389,10 @@ Each company can have multiple [connections](https://docs.codat.io/platform-api# package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -297,11 +407,6 @@ func main() { res, err := s.Companies.Update(ctx, operations.UpdateCompanyRequest{ CompanyRequestBody: &shared.CompanyRequestBody{ Description: platform.String("Requested early access to the new financing scheme."), - Groups: []shared.GroupRef{ - shared.GroupRef{ - ID: platform.String("60d2fa12-8a04-11ee-b9d1-0242ac120002"), - }, - }, Name: "New Name", }, CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", @@ -329,7 +434,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/connectionmanagement/README.md b/platform/docs/sdks/connectionmanagement/README.md index 820214ad4..f4b39234d 100644 --- a/platform/docs/sdks/connectionmanagement/README.md +++ b/platform/docs/sdks/connectionmanagement/README.md @@ -21,10 +21,10 @@ The embeddable [Connections SDK](https://docs.codat.io/auth-flow/optimize/connec package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -62,7 +62,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/connections/README.md b/platform/docs/sdks/connections/README.md index b03debe25..f0a358afc 100644 --- a/platform/docs/sdks/connections/README.md +++ b/platform/docs/sdks/connections/README.md @@ -26,10 +26,10 @@ Use the [List Integrations](https://docs.codat.io/platform-api#/operations/list- package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -70,11 +70,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -87,10 +86,10 @@ This operation is not reversible. The end user would need to reauthorize a new d package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -129,11 +128,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -145,10 +143,10 @@ func main() { package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -187,11 +185,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## List @@ -203,10 +200,10 @@ func main() { package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -248,11 +245,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Unlink @@ -264,10 +260,10 @@ func main() { package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -309,11 +305,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## UpdateAuthorization @@ -325,10 +320,10 @@ Update data connection's authorization. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -367,7 +362,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/corssettings/README.md b/platform/docs/sdks/corssettings/README.md index c06cdc871..15dbe97f3 100644 --- a/platform/docs/sdks/corssettings/README.md +++ b/platform/docs/sdks/corssettings/README.md @@ -22,8 +22,8 @@ The embeddable [Connections SDK](https://docs.codat.io/auth-flow/optimize/connec package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -59,11 +59,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Set @@ -79,8 +78,8 @@ The embeddable [Connections SDK](https://docs.codat.io/auth-flow/optimize/connec package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -121,7 +120,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/customdatatype/README.md b/platform/docs/sdks/customdatatype/README.md index e146d0dd6..467f46f2e 100644 --- a/platform/docs/sdks/customdatatype/README.md +++ b/platform/docs/sdks/customdatatype/README.md @@ -32,10 +32,10 @@ A [custom data type](https://docs.codat.io/using-the-api/custom-data) is an addi package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -91,11 +91,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetConfiguration @@ -109,10 +108,10 @@ A [custom data type](https://docs.codat.io/using-the-api/custom-data) is an addi package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -151,11 +150,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## List @@ -169,10 +167,10 @@ A [custom data type](https://docs.codat.io/using-the-api/custom-data) is an addi package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -214,11 +212,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------------------- | ----------------------------------- | ----------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,404,429,451,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 404, 429, 451, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Refresh @@ -230,10 +227,10 @@ The *Refresh custom data type* endpoint refreshes the specified custom data type package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -273,7 +270,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,451,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 451, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/groups/README.md b/platform/docs/sdks/groups/README.md deleted file mode 100644 index d29f7c691..000000000 --- a/platform/docs/sdks/groups/README.md +++ /dev/null @@ -1,252 +0,0 @@ -# Groups -(*Groups*) - -## Overview - -Define and manage sets of companies based on a chosen characteristic. - -### Available Operations - -* [AddCompany](#addcompany) - Add company -* [Create](#create) - Create group -* [List](#list) - List groups -* [RemoveCompany](#removecompany) - Remove company - -## AddCompany - -Use the *Add company* endpoint to assign a company to a group. A company can belong to multiple groups, but can only be added to one group at a time. - -[Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. - -### Example Usage - -```go -package main - -import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" - "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "log" -) - -func main() { - s := platform.New( - platform.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), - ) - - ctx := context.Background() - res, err := s.Groups.AddCompany(ctx, operations.AddCompanyToGroupRequest{ - CompanyGroupAssignment: &shared.CompanyGroupAssignment{ - GroupID: platform.String("d7a6c4b4-dc87-45f6-b803-62f466398680"), - }, - 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.AddCompanyToGroupRequest](../../pkg/models/operations/addcompanytogrouprequest.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.AddCompanyToGroupResponse](../../pkg/models/operations/addcompanytogroupresponse.md), error** - -### Errors - -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - - -## Create - -Use the *Create group* endpoint to generate a new group that you can assign your companies to. - -[Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. - -### Tips and traps - -* The maximum length for the group name is 50 characters. -* It's possible to create up to 20 groups per client. - -### Example Usage - -```go -package main - -import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" - "context" - "log" -) - -func main() { - s := platform.New( - platform.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), - ) - - ctx := context.Background() - res, err := s.Groups.Create(ctx, &shared.GroupPrototype{ - Name: platform.String("Corporate cards department"), - }) - if err != nil { - log.Fatal(err) - } - if res.Group != 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.GroupPrototype](../../pkg/models/shared/groupprototype.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.CreateGroupResponse](../../pkg/models/operations/creategroupresponse.md), error** - -### Errors - -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,409,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - - -## List - -Use the *List group* endpoint to return a list of all groups that currently exist for your client. - -[Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. - -### Example Usage - -```go -package main - -import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" - "context" - "log" -) - -func main() { - s := platform.New( - platform.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), - ) - - ctx := context.Background() - res, err := s.Groups.List(ctx) - if err != nil { - log.Fatal(err) - } - if res.Groups != 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. | -| `opts` | [][operations.Option](../../pkg/models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.ListGroupsResponse](../../pkg/models/operations/listgroupsresponse.md), error** - -### Errors - -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - - -## RemoveCompany - -Use the *Remove company* endpoint to remove a company from a group. - -[Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. - -### Example Usage - -```go -package main - -import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" - "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "log" -) - -func main() { - s := platform.New( - platform.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), - ) - - ctx := context.Background() - res, err := s.Groups.RemoveCompany(ctx, operations.RemoveCompanyFromGroupRequest{ - CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", - GroupID: "60d2fa12-8a04-11ee-b9d1-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.RemoveCompanyFromGroupRequest](../../pkg/models/operations/removecompanyfromgrouprequest.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.RemoveCompanyFromGroupResponse](../../pkg/models/operations/removecompanyfromgroupresponse.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/platform/docs/sdks/integrations/README.md b/platform/docs/sdks/integrations/README.md index 42e2c6b6a..27373d2f2 100644 --- a/platform/docs/sdks/integrations/README.md +++ b/platform/docs/sdks/integrations/README.md @@ -21,10 +21,10 @@ Get single integration, by platformKey package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -62,11 +62,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetBranding @@ -78,10 +77,10 @@ Get branding for platform. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -119,11 +118,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## List @@ -135,10 +133,10 @@ List your available integrations package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -179,7 +177,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/pushdata/README.md b/platform/docs/sdks/pushdata/README.md index eca8a1ee7..0383989f4 100644 --- a/platform/docs/sdks/pushdata/README.md +++ b/platform/docs/sdks/pushdata/README.md @@ -30,10 +30,10 @@ Codat tries not to limit users to pushing to a very limited number of standard c package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -73,15 +73,16 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetOperation -Retrieve push operation. +The **Get push operation** endpoint returns a specific [push operation](/using-the-api/push) identified by the `pushOperationKey` that was performed on the company. + +Write operations are actions that send requests to Codat, enabling the creation, updating, deletion of records, or uploading attachments in the connected accounting software. ### Example Usage @@ -89,10 +90,10 @@ Retrieve push operation. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -131,15 +132,16 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ListOperations -List push operation records. +The **List push operations** endpoint returns a list of [push operations](/using-the-api/push) performed on the company. + +Write operations are actions that send requests to Codat, enabling the creation, updating, deletion of records, or uploading attachments in the connected accounting software. ### Example Usage @@ -147,10 +149,10 @@ List push operation records. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -192,7 +194,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/refreshdata/README.md b/platform/docs/sdks/refreshdata/README.md index a5cdc4066..23dc1ce35 100644 --- a/platform/docs/sdks/refreshdata/README.md +++ b/platform/docs/sdks/refreshdata/README.md @@ -27,10 +27,10 @@ This is an asynchronous operation, and will bring updated data into Codat from t package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -68,11 +68,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ByDataType @@ -86,10 +85,10 @@ This is an asynchronous operation, and will bring updated data into Codat from t package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -128,11 +127,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -144,10 +142,10 @@ Get the state of each data type for a company package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -185,11 +183,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetPullOperation @@ -201,10 +198,10 @@ Retrieve information about a single dataset or pull operation. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -243,11 +240,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ListPullOperations @@ -259,10 +255,10 @@ Gets the pull operation history (datasets) for a given company. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -304,7 +300,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/settings/README.md b/platform/docs/sdks/settings/README.md index 4ac1dfd04..70c965517 100644 --- a/platform/docs/sdks/settings/README.md +++ b/platform/docs/sdks/settings/README.md @@ -35,8 +35,8 @@ You can [read more](https://docs.codat.io/using-the-api/authentication) about au package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -75,11 +75,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,409,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 409, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## DeleteAPIKey @@ -100,10 +99,10 @@ You can [read more](https://docs.codat.io/using-the-api/authentication) about au package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -141,11 +140,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetProfile @@ -157,8 +155,8 @@ Fetch your Codat profile. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -194,11 +192,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetSyncSettings @@ -210,8 +207,8 @@ Retrieve the [sync settings](https://docs.codat.io/knowledge-base/advanced-sync- package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -247,11 +244,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ListAPIKeys @@ -267,8 +263,8 @@ You can [read more](https://docs.codat.io/using-the-api/authentication) about au package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -304,11 +300,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## UpdateProfile @@ -320,8 +315,8 @@ Update your Codat profile package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -369,11 +364,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## UpdateSyncSettings @@ -385,10 +379,10 @@ Update sync settings for all data types. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -438,7 +432,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/supplementaldata/README.md b/platform/docs/sdks/supplementaldata/README.md index 4cc294b67..817015a4a 100644 --- a/platform/docs/sdks/supplementaldata/README.md +++ b/platform/docs/sdks/supplementaldata/README.md @@ -25,10 +25,10 @@ See the *examples* for integration-specific frequently requested properties. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -68,11 +68,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetConfiguration @@ -86,10 +85,10 @@ The *Get configuration* endpoint returns supplemental data configuration previou package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -128,7 +127,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/docs/sdks/webhooks/README.md b/platform/docs/sdks/webhooks/README.md index e9ad1ffe4..65cef70d5 100644 --- a/platform/docs/sdks/webhooks/README.md +++ b/platform/docs/sdks/webhooks/README.md @@ -7,16 +7,18 @@ Create and manage webhooks that listen to Codat's events. ### Available Operations -* [~~Create~~](#create) - Create webhook :warning: **Deprecated** +* [~~Create~~](#create) - Create webhook (legacy) :warning: **Deprecated** * [CreateConsumer](#createconsumer) - Create webhook consumer * [DeleteConsumer](#deleteconsumer) - Delete webhook consumer -* [~~Get~~](#get) - Get webhook :warning: **Deprecated** -* [~~List~~](#list) - List webhooks :warning: **Deprecated** +* [~~Get~~](#get) - Get webhook (legacy) :warning: **Deprecated** +* [~~List~~](#list) - List webhooks (legacy) :warning: **Deprecated** * [ListConsumers](#listconsumers) - List webhook consumers ## ~~Create~~ -Create a new webhook configuration +Use the *Create webhooks (legacy)* endpoint to create a rule-based webhook for your client. + +**Note:** This endpoint has been deprecated. Please use the [*Create webhook consumer*](https://docs.codat.io/platform-api#/operations/create-webhook-consumer) endpoint to create a webhook moving forward. > :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. @@ -26,8 +28,8 @@ Create a new webhook configuration package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -73,11 +75,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| sdkerrors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## CreateConsumer @@ -94,8 +95,8 @@ func main() { package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -139,11 +140,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## DeleteConsumer @@ -157,10 +157,10 @@ func main() { package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -198,15 +198,16 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~Get~~ -Get a single webhook +Use the *Get webhook (legacy)* endpoint to retrieve a specific webhook for your client. + +**Note:** This endpoint has been deprecated. Please use the [*List webhook consumers*](https://docs.codat.io/platform-api#/operations/list-webhook-consumers) endpoint for listing webhooks moving forward. > :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. @@ -216,10 +217,10 @@ Get a single webhook package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -257,15 +258,16 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~List~~ -List webhooks that you are subscribed to. +Use the *List webhooks (legacy)* endpoint to retrieve all existing rule-based webhooks for your client. + +**Note:** This endpoint has been deprecated. Please use the [*List webhook consumers*](https://docs.codat.io/platform-api#/operations/list-webhook-consumers) endpoint for listing webhooks moving forward. > :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. @@ -275,10 +277,10 @@ List webhooks that you are subscribed to. package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" "log" ) @@ -319,11 +321,10 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ListConsumers @@ -337,8 +338,8 @@ func main() { package main import( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - platform "github.com/codatio/client-sdk-go/platform/v3" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + platform "github.com/codatio/client-sdk-go/platform/v4" "context" "log" ) @@ -374,7 +375,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| sdkerrors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| sdkerrors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/platform/go.mod b/platform/go.mod index 80b483020..3676e622f 100644 --- a/platform/go.mod +++ b/platform/go.mod @@ -1,4 +1,4 @@ -module github.com/codatio/client-sdk-go/platform/v3 +module github.com/codatio/client-sdk-go/platform/v4 go 1.20 diff --git a/platform/groups.go b/platform/groups.go deleted file mode 100644 index 7e9476e32..000000000 --- a/platform/groups.go +++ /dev/null @@ -1,984 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package platform - -import ( - "bytes" - "context" - "fmt" - "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" - "net/http" - "net/url" -) - -// Groups - Define and manage sets of companies based on a chosen characteristic. -type Groups struct { - sdkConfiguration sdkConfiguration -} - -func newGroups(sdkConfig sdkConfiguration) *Groups { - return &Groups{ - sdkConfiguration: sdkConfig, - } -} - -// AddCompany - Add company -// Use the *Add company* endpoint to assign a company to a group. A company can belong to multiple groups, but can only be added to one group at a time. -// -// [Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. -func (s *Groups) AddCompany(ctx context.Context, request operations.AddCompanyToGroupRequest, opts ...operations.Option) (*operations.AddCompanyToGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "add-company-to-group", - 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}/groups", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "CompanyGroupAssignment", "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.AddCompanyToGroupResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: 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 - -} - -// Create group -// Use the *Create group* endpoint to generate a new group that you can assign your companies to. -// -// [Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. -// -// ### Tips and traps -// -// * The maximum length for the group name is 50 characters. -// * It's possible to create up to 20 groups per client. -func (s *Groups) Create(ctx context.Context, request *shared.GroupPrototype, opts ...operations.Option) (*operations.CreateGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "create-group", - 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, "/groups") - 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{"401", "402", "403", "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.CreateGroupResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: 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.Group - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Group = &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 == 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 - -} - -// List groups -// Use the *List group* endpoint to return a list of all groups that currently exist for your client. -// -// [Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. -func (s *Groups) List(ctx context.Context, opts ...operations.Option) (*operations.ListGroupsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "list-groups", - 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, "/groups") - 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", "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.ListGroupsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: 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.Groups - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Groups = &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 == 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 - -} - -// RemoveCompany - Remove company -// Use the *Remove company* endpoint to remove a company from a group. -// -// [Groups](https://docs.codat.io/platform-api#/schemas/Group) define a set of companies that are organized based on a chosen characteristic and can be managed in the same way. -func (s *Groups) RemoveCompany(ctx context.Context, request operations.RemoveCompanyFromGroupRequest, opts ...operations.Option) (*operations.RemoveCompanyFromGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "remove-company-from-group", - 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}/groups/{groupId}", 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.RemoveCompanyFromGroupResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: 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 - -} diff --git a/platform/integrations.go b/platform/integrations.go index 8f4ee2494..54f2264ac 100644 --- a/platform/integrations.go +++ b/platform/integrations.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" "net/url" ) @@ -178,21 +177,11 @@ func (s *Integrations) Get(ctx context.Context, request operations.GetIntegratio RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -204,11 +193,10 @@ func (s *Integrations) Get(ctx context.Context, request operations.GetIntegratio res.Integration = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -226,7 +214,7 @@ func (s *Integrations) Get(ctx context.Context, request operations.GetIntegratio case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -238,28 +226,25 @@ func (s *Integrations) Get(ctx context.Context, request operations.GetIntegratio return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -416,21 +401,11 @@ func (s *Integrations) GetBranding(ctx context.Context, request operations.GetIn RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -442,11 +417,10 @@ func (s *Integrations) GetBranding(ctx context.Context, request operations.GetIn res.Branding = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -464,7 +438,7 @@ func (s *Integrations) GetBranding(ctx context.Context, request operations.GetIn case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -476,28 +450,25 @@ func (s *Integrations) GetBranding(ctx context.Context, request operations.GetIn return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -658,21 +629,11 @@ func (s *Integrations) List(ctx context.Context, request operations.ListIntegrat RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -684,11 +645,10 @@ func (s *Integrations) List(ctx context.Context, request operations.ListIntegrat res.Integrations = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -706,7 +666,7 @@ func (s *Integrations) List(ctx context.Context, request operations.ListIntegrat case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -718,28 +678,25 @@ func (s *Integrations) List(ctx context.Context, request operations.ListIntegrat return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/pkg/models/operations/addcompanytogroup.go b/platform/pkg/models/operations/addcompanytogroup.go deleted file mode 100644 index 98aec5092..000000000 --- a/platform/pkg/models/operations/addcompanytogroup.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "net/http" -) - -type AddCompanyToGroupRequest struct { - CompanyGroupAssignment *shared.CompanyGroupAssignment `request:"mediaType=application/json"` - // Unique identifier for a company. - CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` -} - -func (o *AddCompanyToGroupRequest) GetCompanyGroupAssignment() *shared.CompanyGroupAssignment { - if o == nil { - return nil - } - return o.CompanyGroupAssignment -} - -func (o *AddCompanyToGroupRequest) GetCompanyID() string { - if o == nil { - return "" - } - return o.CompanyID -} - -type AddCompanyToGroupResponse struct { - // Success - Company *shared.Company - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *AddCompanyToGroupResponse) GetCompany() *shared.Company { - if o == nil { - return nil - } - return o.Company -} - -func (o *AddCompanyToGroupResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *AddCompanyToGroupResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *AddCompanyToGroupResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/platform/pkg/models/operations/removecompanyfromgroup.go b/platform/pkg/models/operations/addproduct.go similarity index 56% rename from platform/pkg/models/operations/removecompanyfromgroup.go rename to platform/pkg/models/operations/addproduct.go index 99f9a90c5..f9f9100e0 100644 --- a/platform/pkg/models/operations/removecompanyfromgroup.go +++ b/platform/pkg/models/operations/addproduct.go @@ -6,28 +6,28 @@ import ( "net/http" ) -type RemoveCompanyFromGroupRequest struct { +type AddProductRequest struct { // Unique identifier for a company. CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` - // Unique identifier for the group. - GroupID string `pathParam:"style=simple,explode=false,name=groupId"` + // Human-readable product identifier for a product. + ProductIdentifier string `pathParam:"style=simple,explode=false,name=productIdentifier"` } -func (o *RemoveCompanyFromGroupRequest) GetCompanyID() string { +func (o *AddProductRequest) GetCompanyID() string { if o == nil { return "" } return o.CompanyID } -func (o *RemoveCompanyFromGroupRequest) GetGroupID() string { +func (o *AddProductRequest) GetProductIdentifier() string { if o == nil { return "" } - return o.GroupID + return o.ProductIdentifier } -type RemoveCompanyFromGroupResponse struct { +type AddProductResponse struct { // HTTP response content type for this operation ContentType string // HTTP response status code for this operation @@ -36,21 +36,21 @@ type RemoveCompanyFromGroupResponse struct { RawResponse *http.Response } -func (o *RemoveCompanyFromGroupResponse) GetContentType() string { +func (o *AddProductResponse) GetContentType() string { if o == nil { return "" } return o.ContentType } -func (o *RemoveCompanyFromGroupResponse) GetStatusCode() int { +func (o *AddProductResponse) GetStatusCode() int { if o == nil { return 0 } return o.StatusCode } -func (o *RemoveCompanyFromGroupResponse) GetRawResponse() *http.Response { +func (o *AddProductResponse) GetRawResponse() *http.Response { if o == nil { return nil } diff --git a/platform/pkg/models/operations/configurecustomdatatype.go b/platform/pkg/models/operations/configurecustomdatatype.go index ccc08e41e..2f50f41ed 100644 --- a/platform/pkg/models/operations/configurecustomdatatype.go +++ b/platform/pkg/models/operations/configurecustomdatatype.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/configuresupplementaldata.go b/platform/pkg/models/operations/configuresupplementaldata.go index fc9ef2733..c857735d2 100644 --- a/platform/pkg/models/operations/configuresupplementaldata.go +++ b/platform/pkg/models/operations/configuresupplementaldata.go @@ -5,7 +5,7 @@ package operations import ( "encoding/json" "fmt" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/createapikey.go b/platform/pkg/models/operations/createapikey.go index 28582eec8..c22c75f16 100644 --- a/platform/pkg/models/operations/createapikey.go +++ b/platform/pkg/models/operations/createapikey.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/createcompany.go b/platform/pkg/models/operations/createcompany.go index 6808b62f3..eb8c30d57 100644 --- a/platform/pkg/models/operations/createcompany.go +++ b/platform/pkg/models/operations/createcompany.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/createconnection.go b/platform/pkg/models/operations/createconnection.go index cadd31a8a..c5083fe52 100644 --- a/platform/pkg/models/operations/createconnection.go +++ b/platform/pkg/models/operations/createconnection.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/createrule.go b/platform/pkg/models/operations/createrule.go index 0a3906221..e5ef46027 100644 --- a/platform/pkg/models/operations/createrule.go +++ b/platform/pkg/models/operations/createrule.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/createwebhookconsumer.go b/platform/pkg/models/operations/createwebhookconsumer.go index a7cf064b8..fc6f2abe7 100644 --- a/platform/pkg/models/operations/createwebhookconsumer.go +++ b/platform/pkg/models/operations/createwebhookconsumer.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/deleteapikey.go b/platform/pkg/models/operations/deleteapikey.go index f9aa279a7..0222449bc 100644 --- a/platform/pkg/models/operations/deleteapikey.go +++ b/platform/pkg/models/operations/deleteapikey.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) @@ -23,7 +23,7 @@ type DeleteAPIKeyResponse struct { // HTTP response content type for this operation ContentType string // Too many requests were made in a given amount of time. Wait a short period and then try again. - ErrorMessage *sdkerrors.ErrorMessage + ErrorMessage *shared.ErrorMessage // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing @@ -37,7 +37,7 @@ func (o *DeleteAPIKeyResponse) GetContentType() string { return o.ContentType } -func (o *DeleteAPIKeyResponse) GetErrorMessage() *sdkerrors.ErrorMessage { +func (o *DeleteAPIKeyResponse) GetErrorMessage() *shared.ErrorMessage { if o == nil { return nil } diff --git a/platform/pkg/models/operations/getcompany.go b/platform/pkg/models/operations/getcompany.go index 1e7d5200a..5dc934fea 100644 --- a/platform/pkg/models/operations/getcompany.go +++ b/platform/pkg/models/operations/getcompany.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getcompanydatastatus.go b/platform/pkg/models/operations/getcompanydatastatus.go index 34e4f3fe9..c5880ab95 100644 --- a/platform/pkg/models/operations/getcompanydatastatus.go +++ b/platform/pkg/models/operations/getcompanydatastatus.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getcompanypushhistory.go b/platform/pkg/models/operations/getcompanypushhistory.go index a0481b95a..782b50aa9 100644 --- a/platform/pkg/models/operations/getcompanypushhistory.go +++ b/platform/pkg/models/operations/getcompanypushhistory.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/getconnection.go b/platform/pkg/models/operations/getconnection.go index 4b93af761..90cd894c7 100644 --- a/platform/pkg/models/operations/getconnection.go +++ b/platform/pkg/models/operations/getconnection.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getconnectionmanagementaccesstoken.go b/platform/pkg/models/operations/getconnectionmanagementaccesstoken.go index 2a5b584c9..8bec15488 100644 --- a/platform/pkg/models/operations/getconnectionmanagementaccesstoken.go +++ b/platform/pkg/models/operations/getconnectionmanagementaccesstoken.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getconnectionmanagementcorssettings.go b/platform/pkg/models/operations/getconnectionmanagementcorssettings.go index baff4d94d..0a184fb4f 100644 --- a/platform/pkg/models/operations/getconnectionmanagementcorssettings.go +++ b/platform/pkg/models/operations/getconnectionmanagementcorssettings.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getcreateupdatemodeloptionsbydatatype.go b/platform/pkg/models/operations/getcreateupdatemodeloptionsbydatatype.go index aff051cf7..ac35f04ba 100644 --- a/platform/pkg/models/operations/getcreateupdatemodeloptionsbydatatype.go +++ b/platform/pkg/models/operations/getcreateupdatemodeloptionsbydatatype.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) @@ -12,7 +12,7 @@ type GetCreateUpdateModelOptionsByDataTypeRequest struct { CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` // Unique identifier for a connection. ConnectionID string `pathParam:"style=simple,explode=false,name=connectionId"` - // The key of a Codat data type + // The key of a Codat data type. DataType shared.SchemaDataType `pathParam:"style=simple,explode=false,name=dataType"` } diff --git a/platform/pkg/models/operations/getcustomdatatypeconfiguration.go b/platform/pkg/models/operations/getcustomdatatypeconfiguration.go index 5b3f686e1..65eb0087f 100644 --- a/platform/pkg/models/operations/getcustomdatatypeconfiguration.go +++ b/platform/pkg/models/operations/getcustomdatatypeconfiguration.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getintegration.go b/platform/pkg/models/operations/getintegration.go index 098d5be5f..ede1978e0 100644 --- a/platform/pkg/models/operations/getintegration.go +++ b/platform/pkg/models/operations/getintegration.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getintegrationsbranding.go b/platform/pkg/models/operations/getintegrationsbranding.go index 85c0ff63a..6ba6f3c4e 100644 --- a/platform/pkg/models/operations/getintegrationsbranding.go +++ b/platform/pkg/models/operations/getintegrationsbranding.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getprofile.go b/platform/pkg/models/operations/getprofile.go index 565a6c027..864e117c6 100644 --- a/platform/pkg/models/operations/getprofile.go +++ b/platform/pkg/models/operations/getprofile.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getprofilesyncsettings.go b/platform/pkg/models/operations/getprofilesyncsettings.go index 2941e331f..e49f38a87 100644 --- a/platform/pkg/models/operations/getprofilesyncsettings.go +++ b/platform/pkg/models/operations/getprofilesyncsettings.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getpulloperation.go b/platform/pkg/models/operations/getpulloperation.go index bc4c580ea..46bda3abe 100644 --- a/platform/pkg/models/operations/getpulloperation.go +++ b/platform/pkg/models/operations/getpulloperation.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getpushoperation.go b/platform/pkg/models/operations/getpushoperation.go index 8541b1c6c..06d7724a8 100644 --- a/platform/pkg/models/operations/getpushoperation.go +++ b/platform/pkg/models/operations/getpushoperation.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getsupplementaldataconfiguration.go b/platform/pkg/models/operations/getsupplementaldataconfiguration.go index 4b7f32231..e66a4e2f1 100644 --- a/platform/pkg/models/operations/getsupplementaldataconfiguration.go +++ b/platform/pkg/models/operations/getsupplementaldataconfiguration.go @@ -5,7 +5,7 @@ package operations import ( "encoding/json" "fmt" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/getwebhook.go b/platform/pkg/models/operations/getwebhook.go index bce75a377..b514f82e8 100644 --- a/platform/pkg/models/operations/getwebhook.go +++ b/platform/pkg/models/operations/getwebhook.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/listapikeys.go b/platform/pkg/models/operations/listapikeys.go index 1b4b181b4..129e0257e 100644 --- a/platform/pkg/models/operations/listapikeys.go +++ b/platform/pkg/models/operations/listapikeys.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/listcompanies.go b/platform/pkg/models/operations/listcompanies.go index 8f4ca578f..033cd9088 100644 --- a/platform/pkg/models/operations/listcompanies.go +++ b/platform/pkg/models/operations/listcompanies.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/listconnections.go b/platform/pkg/models/operations/listconnections.go index 5512e9290..d7297d4c8 100644 --- a/platform/pkg/models/operations/listconnections.go +++ b/platform/pkg/models/operations/listconnections.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/listcustomdatatyperecords.go b/platform/pkg/models/operations/listcustomdatatyperecords.go index d7889d280..e3c8437c4 100644 --- a/platform/pkg/models/operations/listcustomdatatyperecords.go +++ b/platform/pkg/models/operations/listcustomdatatyperecords.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/listintegrations.go b/platform/pkg/models/operations/listintegrations.go index de683feb7..27d23298e 100644 --- a/platform/pkg/models/operations/listintegrations.go +++ b/platform/pkg/models/operations/listintegrations.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/listpulloperations.go b/platform/pkg/models/operations/listpulloperations.go index a9b3963b6..23e6e1047 100644 --- a/platform/pkg/models/operations/listpulloperations.go +++ b/platform/pkg/models/operations/listpulloperations.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/listrules.go b/platform/pkg/models/operations/listrules.go index 3bb3a37b5..4b9ad0680 100644 --- a/platform/pkg/models/operations/listrules.go +++ b/platform/pkg/models/operations/listrules.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/operations/listwebhookconsumers.go b/platform/pkg/models/operations/listwebhookconsumers.go index 99aca9447..7e377e983 100644 --- a/platform/pkg/models/operations/listwebhookconsumers.go +++ b/platform/pkg/models/operations/listwebhookconsumers.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/options.go b/platform/pkg/models/operations/options.go index 1fb2500a8..738e6a172 100644 --- a/platform/pkg/models/operations/options.go +++ b/platform/pkg/models/operations/options.go @@ -4,8 +4,8 @@ package operations import ( "errors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "time" ) diff --git a/platform/pkg/models/operations/refreshcustomdatatype.go b/platform/pkg/models/operations/refreshcustomdatatype.go index f54b14898..73e4c5c9e 100644 --- a/platform/pkg/models/operations/refreshcustomdatatype.go +++ b/platform/pkg/models/operations/refreshcustomdatatype.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/refreshdatatype.go b/platform/pkg/models/operations/refreshdatatype.go index e5fbf487f..c57a5d095 100644 --- a/platform/pkg/models/operations/refreshdatatype.go +++ b/platform/pkg/models/operations/refreshdatatype.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) @@ -12,7 +12,7 @@ type RefreshDataTypeRequest struct { CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` // Optionally, provide a data connection id to only queue pull operations on that connection. ConnectionID *string `queryParam:"style=form,explode=true,name=connectionId"` - // The key of a Codat data type + // The key of a Codat data type. DataType shared.SchemaDataType `pathParam:"style=simple,explode=false,name=dataType"` } diff --git a/platform/pkg/models/operations/removeproduct.go b/platform/pkg/models/operations/removeproduct.go new file mode 100644 index 000000000..13fabf63b --- /dev/null +++ b/platform/pkg/models/operations/removeproduct.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "net/http" +) + +type RemoveProductRequest struct { + // Unique identifier for a company. + CompanyID string `pathParam:"style=simple,explode=false,name=companyId"` + // Human-readable product identifier for a product. + ProductIdentifier string `pathParam:"style=simple,explode=false,name=productIdentifier"` +} + +func (o *RemoveProductRequest) GetCompanyID() string { + if o == nil { + return "" + } + return o.CompanyID +} + +func (o *RemoveProductRequest) GetProductIdentifier() string { + if o == nil { + return "" + } + return o.ProductIdentifier +} + +type RemoveProductResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *RemoveProductResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *RemoveProductResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *RemoveProductResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/operations/setconnectionmanagementcorssettings.go b/platform/pkg/models/operations/setconnectionmanagementcorssettings.go index 273274e6c..85a8e676c 100644 --- a/platform/pkg/models/operations/setconnectionmanagementcorssettings.go +++ b/platform/pkg/models/operations/setconnectionmanagementcorssettings.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/unlinkconnection.go b/platform/pkg/models/operations/unlinkconnection.go index 20e2720a5..976860f19 100644 --- a/platform/pkg/models/operations/unlinkconnection.go +++ b/platform/pkg/models/operations/unlinkconnection.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/updatecompany.go b/platform/pkg/models/operations/updatecompany.go index 968f1a4da..dc04d6398 100644 --- a/platform/pkg/models/operations/updatecompany.go +++ b/platform/pkg/models/operations/updatecompany.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/updateconnectionauthorization.go b/platform/pkg/models/operations/updateconnectionauthorization.go index 04c0b4f1f..a784b4630 100644 --- a/platform/pkg/models/operations/updateconnectionauthorization.go +++ b/platform/pkg/models/operations/updateconnectionauthorization.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/updateprofile.go b/platform/pkg/models/operations/updateprofile.go index 1569798bb..f347ee485 100644 --- a/platform/pkg/models/operations/updateprofile.go +++ b/platform/pkg/models/operations/updateprofile.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" "net/http" ) diff --git a/platform/pkg/models/operations/updateprofilesyncsettings.go b/platform/pkg/models/operations/updateprofilesyncsettings.go index ec0747089..574635693 100644 --- a/platform/pkg/models/operations/updateprofilesyncsettings.go +++ b/platform/pkg/models/operations/updateprofilesyncsettings.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) diff --git a/platform/pkg/models/sdkerrors/errormessage.go b/platform/pkg/models/sdkerrors/errormessage.go index 5e2dc2096..5433178ab 100644 --- a/platform/pkg/models/sdkerrors/errormessage.go +++ b/platform/pkg/models/sdkerrors/errormessage.go @@ -4,10 +4,10 @@ package sdkerrors import ( "encoding/json" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" ) -// ErrorMessage - Bad Request +// ErrorMessage - Your API request was not properly authorized. type ErrorMessage struct { // `True` if the error occurred transiently and can be retried. CanBeRetried *string `json:"canBeRetried,omitempty"` diff --git a/platform/pkg/models/shared/company.go b/platform/pkg/models/shared/company.go index b44af0a4c..3f2ced48f 100644 --- a/platform/pkg/models/shared/company.go +++ b/platform/pkg/models/shared/company.go @@ -2,10 +2,6 @@ package shared -// CompanyTags - A collection of user-defined key-value pairs that store custom metadata against the company. -type CompanyTags struct { -} - // Company - In Codat, a company represents a business sharing access to their data. Each company can have multiple [connections](https://docs.codat.io/platform-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. @@ -61,10 +57,12 @@ type Company struct { LastSync *string `json:"lastSync,omitempty"` // The name of the company Name string `json:"name"` + // An array of products that are currently enabled for the company. + Products []string `json:"products,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"` // A collection of user-defined key-value pairs that store custom metadata against the company. - Tags *CompanyTags `json:"tags,omitempty"` + Tags map[string]string `json:"tags,omitempty"` } func (o *Company) GetCreated() *string { @@ -116,6 +114,13 @@ func (o *Company) GetName() string { return o.Name } +func (o *Company) GetProducts() []string { + if o == nil { + return nil + } + return o.Products +} + func (o *Company) GetRedirect() string { if o == nil { return "" @@ -123,7 +128,7 @@ func (o *Company) GetRedirect() string { return o.Redirect } -func (o *Company) GetTags() *CompanyTags { +func (o *Company) GetTags() map[string]string { if o == nil { return nil } diff --git a/platform/pkg/models/shared/companydetails.go b/platform/pkg/models/shared/companydetails.go index 77a56f77b..500943812 100644 --- a/platform/pkg/models/shared/companydetails.go +++ b/platform/pkg/models/shared/companydetails.go @@ -2,10 +2,6 @@ package shared -// Tags - A collection of user-defined key-value pairs that store custom metadata against the company. -type Tags struct { -} - type CompanyDetails struct { // 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: // @@ -55,10 +51,12 @@ type CompanyDetails struct { LastSync *string `json:"lastSync,omitempty"` // The name of the company Name string `json:"name"` + // An array of products that are currently enabled for the company. + Products []string `json:"products,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"` // A collection of user-defined key-value pairs that store custom metadata against the company. - Tags *Tags `json:"tags,omitempty"` + Tags map[string]string `json:"tags,omitempty"` } func (o *CompanyDetails) GetCreated() *string { @@ -103,6 +101,13 @@ func (o *CompanyDetails) GetName() string { return o.Name } +func (o *CompanyDetails) GetProducts() []string { + if o == nil { + return nil + } + return o.Products +} + func (o *CompanyDetails) GetRedirect() string { if o == nil { return "" @@ -110,7 +115,7 @@ func (o *CompanyDetails) GetRedirect() string { return o.Redirect } -func (o *CompanyDetails) GetTags() *Tags { +func (o *CompanyDetails) GetTags() map[string]string { if o == nil { return nil } diff --git a/platform/pkg/models/shared/companygroupassignment.go b/platform/pkg/models/shared/companygroupassignment.go deleted file mode 100644 index b7d772ffa..000000000 --- a/platform/pkg/models/shared/companygroupassignment.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type CompanyGroupAssignment struct { - GroupID *string `json:"groupId,omitempty"` -} - -func (o *CompanyGroupAssignment) GetGroupID() *string { - if o == nil { - return nil - } - return o.GroupID -} diff --git a/platform/pkg/models/shared/companyreference.go b/platform/pkg/models/shared/companyreference.go index 1d92b8cda..c8695e09d 100644 --- a/platform/pkg/models/shared/companyreference.go +++ b/platform/pkg/models/shared/companyreference.go @@ -2,13 +2,30 @@ package shared +// CompanyReferenceLinks - A collection of links for the company. +type CompanyReferenceLinks struct { + // Link to the company page in the portal. + Portal *string `json:"portal,omitempty"` +} + +func (o *CompanyReferenceLinks) GetPortal() *string { + if o == nil { + return nil + } + return o.Portal +} + type CompanyReference struct { // Additional information about the company. This can be used to store foreign IDs, references, etc. Description *string `json:"description,omitempty"` // Unique identifier for your SMB in Codat. ID *string `json:"id,omitempty"` + // A collection of links for the company. + Links *CompanyReferenceLinks `json:"links,omitempty"` // The name of the company Name *string `json:"name,omitempty"` + // A collection of user-defined key-value pairs that store custom metadata against the company. + Tags map[string]string `json:"tags,omitempty"` } func (o *CompanyReference) GetDescription() *string { @@ -25,9 +42,23 @@ func (o *CompanyReference) GetID() *string { return o.ID } +func (o *CompanyReference) GetLinks() *CompanyReferenceLinks { + if o == nil { + return nil + } + return o.Links +} + func (o *CompanyReference) GetName() *string { if o == nil { return nil } return o.Name } + +func (o *CompanyReference) GetTags() map[string]string { + if o == nil { + return nil + } + return o.Tags +} diff --git a/platform/pkg/models/shared/companyrequestbody.go b/platform/pkg/models/shared/companyrequestbody.go index 8a3d51f1e..75ed8a6e9 100644 --- a/platform/pkg/models/shared/companyrequestbody.go +++ b/platform/pkg/models/shared/companyrequestbody.go @@ -5,10 +5,10 @@ package shared type CompanyRequestBody struct { // 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 []GroupRef `json:"groups,omitempty"` // Name of company being connected. Name string `json:"name"` + // A collection of user-defined key-value pairs that store custom metadata against the company. + Tags map[string]string `json:"tags,omitempty"` } func (o *CompanyRequestBody) GetDescription() *string { @@ -18,16 +18,16 @@ func (o *CompanyRequestBody) GetDescription() *string { return o.Description } -func (o *CompanyRequestBody) GetGroups() []GroupRef { +func (o *CompanyRequestBody) GetName() string { if o == nil { - return nil + return "" } - return o.Groups + return o.Name } -func (o *CompanyRequestBody) GetName() string { +func (o *CompanyRequestBody) GetTags() map[string]string { if o == nil { - return "" + return nil } - return o.Name + return o.Tags } diff --git a/platform/pkg/models/shared/connection.go b/platform/pkg/models/shared/connection.go index fab7a6630..05ddbb612 100644 --- a/platform/pkg/models/shared/connection.go +++ b/platform/pkg/models/shared/connection.go @@ -13,8 +13,7 @@ package shared // // 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 { - AdditionalProperties any `json:"additionalProperties,omitempty"` - ConnectionInfo map[string]string `json:"connectionInfo,omitempty"` + ConnectionInfo map[string]string `json:"connectionInfo,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: // // ``` @@ -74,13 +73,6 @@ type Connection struct { Status DataConnectionStatus `json:"status"` } -func (o *Connection) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - func (o *Connection) GetConnectionInfo() map[string]string { if o == nil { return nil diff --git a/platform/pkg/models/shared/connectionmanagementallowedorigins.go b/platform/pkg/models/shared/connectionmanagementallowedorigins.go index fc456b3fc..13c86ebb2 100644 --- a/platform/pkg/models/shared/connectionmanagementallowedorigins.go +++ b/platform/pkg/models/shared/connectionmanagementallowedorigins.go @@ -2,6 +2,7 @@ package shared +// ConnectionManagementAllowedOrigins - Success type ConnectionManagementAllowedOrigins struct { // An array of allowed origins (i.e. your domains) to permit cross-origin resource sharing ([CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)).n resource sharing ([CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)). AllowedOrigins []string `json:"allowedOrigins,omitempty"` diff --git a/platform/pkg/models/shared/connectionwebhook.go b/platform/pkg/models/shared/connectionwebhook.go new file mode 100644 index 000000000..74d07d3e0 --- /dev/null +++ b/platform/pkg/models/shared/connectionwebhook.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ConnectionWebhook struct { + // 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"` + // Unique identifier of the event. + ID *string `json:"id,omitempty"` + Payload *ConnectionWebhookPayload `json:"payload,omitempty"` +} + +func (o *ConnectionWebhook) GetEventType() *string { + if o == nil { + return nil + } + return o.EventType +} + +func (o *ConnectionWebhook) GetGeneratedDate() *string { + if o == nil { + return nil + } + return o.GeneratedDate +} + +func (o *ConnectionWebhook) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *ConnectionWebhook) GetPayload() *ConnectionWebhookPayload { + if o == nil { + return nil + } + return o.Payload +} diff --git a/platform/pkg/models/shared/connectionwebhookpayload.go b/platform/pkg/models/shared/connectionwebhookpayload.go new file mode 100644 index 000000000..b8b890eb6 --- /dev/null +++ b/platform/pkg/models/shared/connectionwebhookpayload.go @@ -0,0 +1,32 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ConnectionWebhookPayload struct { + // A connection represents a [company's](https://docs.codat.io/platform-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). + Connection *Connection `json:"connection,omitempty"` + ReferenceCompany *CompanyReference `json:"referenceCompany,omitempty"` +} + +func (o *ConnectionWebhookPayload) GetConnection() *Connection { + if o == nil { + return nil + } + return o.Connection +} + +func (o *ConnectionWebhookPayload) GetReferenceCompany() *CompanyReference { + if o == nil { + return nil + } + return o.ReferenceCompany +} diff --git a/platform/pkg/models/shared/datastatus.go b/platform/pkg/models/shared/datastatus.go index 83281553c..691b1b082 100644 --- a/platform/pkg/models/shared/datastatus.go +++ b/platform/pkg/models/shared/datastatus.go @@ -7,59 +7,59 @@ import ( "fmt" ) -// DataTypes - Available data types -type DataTypes string +// DataStatusDataTypes - Available data types +type DataStatusDataTypes string const ( - DataTypesAccountTransactions DataTypes = "accountTransactions" - DataTypesBalanceSheet DataTypes = "balanceSheet" - DataTypesBankAccounts DataTypes = "bankAccounts" - DataTypesBankTransactions DataTypes = "bankTransactions" - DataTypesBillCreditNotes DataTypes = "billCreditNotes" - DataTypesBillPayments DataTypes = "billPayments" - DataTypesBills DataTypes = "bills" - DataTypesCashFlowStatement DataTypes = "cashFlowStatement" - DataTypesChartOfAccounts DataTypes = "chartOfAccounts" - DataTypesCompany DataTypes = "company" - DataTypesCreditNotes DataTypes = "creditNotes" - DataTypesCustomers DataTypes = "customers" - DataTypesDirectCosts DataTypes = "directCosts" - DataTypesDirectIncomes DataTypes = "directIncomes" - DataTypesInvoices DataTypes = "invoices" - DataTypesItemReceipts DataTypes = "itemReceipts" - DataTypesItems DataTypes = "items" - DataTypesJournalEntries DataTypes = "journalEntries" - DataTypesJournals DataTypes = "journals" - DataTypesPaymentMethods DataTypes = "paymentMethods" - DataTypesPayments DataTypes = "payments" - DataTypesProfitAndLoss DataTypes = "profitAndLoss" - DataTypesPurchaseOrders DataTypes = "purchaseOrders" - DataTypesSalesOrders DataTypes = "salesOrders" - DataTypesSuppliers DataTypes = "suppliers" - DataTypesTaxRates DataTypes = "taxRates" - DataTypesTrackingCategories DataTypes = "trackingCategories" - DataTypesTransfers DataTypes = "transfers" - DataTypesBankingAccountBalances DataTypes = "banking-accountBalances" - DataTypesBankingAccounts DataTypes = "banking-accounts" - DataTypesBankingTransactionCategories DataTypes = "banking-transactionCategories" - DataTypesBankingTransactions DataTypes = "banking-transactions" - DataTypesCommerceCompanyInfo DataTypes = "commerce-companyInfo" - DataTypesCommerceCustomers DataTypes = "commerce-customers" - DataTypesCommerceDisputes DataTypes = "commerce-disputes" - DataTypesCommerceLocations DataTypes = "commerce-locations" - DataTypesCommerceOrders DataTypes = "commerce-orders" - DataTypesCommercePaymentMethods DataTypes = "commerce-paymentMethods" - DataTypesCommercePayments DataTypes = "commerce-payments" - DataTypesCommerceProductCategories DataTypes = "commerce-productCategories" - DataTypesCommerceProducts DataTypes = "commerce-products" - DataTypesCommerceTaxComponents DataTypes = "commerce-taxComponents" - DataTypesCommerceTransactions DataTypes = "commerce-transactions" + DataStatusDataTypesAccountTransactions DataStatusDataTypes = "accountTransactions" + DataStatusDataTypesBalanceSheet DataStatusDataTypes = "balanceSheet" + DataStatusDataTypesBankAccounts DataStatusDataTypes = "bankAccounts" + DataStatusDataTypesBankTransactions DataStatusDataTypes = "bankTransactions" + DataStatusDataTypesBillCreditNotes DataStatusDataTypes = "billCreditNotes" + DataStatusDataTypesBillPayments DataStatusDataTypes = "billPayments" + DataStatusDataTypesBills DataStatusDataTypes = "bills" + DataStatusDataTypesCashFlowStatement DataStatusDataTypes = "cashFlowStatement" + DataStatusDataTypesChartOfAccounts DataStatusDataTypes = "chartOfAccounts" + DataStatusDataTypesCompany DataStatusDataTypes = "company" + DataStatusDataTypesCreditNotes DataStatusDataTypes = "creditNotes" + DataStatusDataTypesCustomers DataStatusDataTypes = "customers" + DataStatusDataTypesDirectCosts DataStatusDataTypes = "directCosts" + DataStatusDataTypesDirectIncomes DataStatusDataTypes = "directIncomes" + DataStatusDataTypesInvoices DataStatusDataTypes = "invoices" + DataStatusDataTypesItemReceipts DataStatusDataTypes = "itemReceipts" + DataStatusDataTypesItems DataStatusDataTypes = "items" + DataStatusDataTypesJournalEntries DataStatusDataTypes = "journalEntries" + DataStatusDataTypesJournals DataStatusDataTypes = "journals" + DataStatusDataTypesPaymentMethods DataStatusDataTypes = "paymentMethods" + DataStatusDataTypesPayments DataStatusDataTypes = "payments" + DataStatusDataTypesProfitAndLoss DataStatusDataTypes = "profitAndLoss" + DataStatusDataTypesPurchaseOrders DataStatusDataTypes = "purchaseOrders" + DataStatusDataTypesSalesOrders DataStatusDataTypes = "salesOrders" + DataStatusDataTypesSuppliers DataStatusDataTypes = "suppliers" + DataStatusDataTypesTaxRates DataStatusDataTypes = "taxRates" + DataStatusDataTypesTrackingCategories DataStatusDataTypes = "trackingCategories" + DataStatusDataTypesTransfers DataStatusDataTypes = "transfers" + DataStatusDataTypesBankingAccountBalances DataStatusDataTypes = "banking-accountBalances" + DataStatusDataTypesBankingAccounts DataStatusDataTypes = "banking-accounts" + DataStatusDataTypesBankingTransactionCategories DataStatusDataTypes = "banking-transactionCategories" + DataStatusDataTypesBankingTransactions DataStatusDataTypes = "banking-transactions" + DataStatusDataTypesCommerceCompanyInfo DataStatusDataTypes = "commerce-companyInfo" + DataStatusDataTypesCommerceCustomers DataStatusDataTypes = "commerce-customers" + DataStatusDataTypesCommerceDisputes DataStatusDataTypes = "commerce-disputes" + DataStatusDataTypesCommerceLocations DataStatusDataTypes = "commerce-locations" + DataStatusDataTypesCommerceOrders DataStatusDataTypes = "commerce-orders" + DataStatusDataTypesCommercePaymentMethods DataStatusDataTypes = "commerce-paymentMethods" + DataStatusDataTypesCommercePayments DataStatusDataTypes = "commerce-payments" + DataStatusDataTypesCommerceProductCategories DataStatusDataTypes = "commerce-productCategories" + DataStatusDataTypesCommerceProducts DataStatusDataTypes = "commerce-products" + DataStatusDataTypesCommerceTaxComponents DataStatusDataTypes = "commerce-taxComponents" + DataStatusDataTypesCommerceTransactions DataStatusDataTypes = "commerce-transactions" ) -func (e DataTypes) ToPointer() *DataTypes { +func (e DataStatusDataTypes) ToPointer() *DataStatusDataTypes { return &e } -func (e *DataTypes) UnmarshalJSON(data []byte) error { +func (e *DataStatusDataTypes) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -150,10 +150,10 @@ func (e *DataTypes) UnmarshalJSON(data []byte) error { case "commerce-taxComponents": fallthrough case "commerce-transactions": - *e = DataTypes(v) + *e = DataStatusDataTypes(v) return nil default: - return fmt.Errorf("invalid value for DataTypes: %v", v) + return fmt.Errorf("invalid value for DataStatusDataTypes: %v", v) } } @@ -162,7 +162,7 @@ type DataStatus struct { // The current status of the dataset. CurrentStatus Status `json:"currentStatus"` // Available data types - DataType DataTypes `json:"dataType"` + DataType DataStatusDataTypes `json:"dataType"` // 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: // // ``` @@ -196,9 +196,9 @@ func (o *DataStatus) GetCurrentStatus() Status { return o.CurrentStatus } -func (o *DataStatus) GetDataType() DataTypes { +func (o *DataStatus) GetDataType() DataStatusDataTypes { if o == nil { - return DataTypes("") + return DataStatusDataTypes("") } return o.DataType } diff --git a/platform/pkg/models/shared/errormessage.go b/platform/pkg/models/shared/errormessage.go new file mode 100644 index 000000000..b66f45a7a --- /dev/null +++ b/platform/pkg/models/shared/errormessage.go @@ -0,0 +1,70 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ErrorMessage - Your API request was not properly authorized. +type ErrorMessage struct { + // `True` if the error occurred transiently and can be retried. + CanBeRetried *string `json:"canBeRetried,omitempty"` + // Unique identifier used to propagate to all downstream services and determine the source of the error. + CorrelationID *string `json:"correlationId,omitempty"` + // Machine readable error code used to automate processes based on the code returned. + DetailedErrorCode *int64 `json:"detailedErrorCode,omitempty"` + // A brief description of the error. + Error *string `json:"error,omitempty"` + // Codat's service the returned the error. + Service *string `json:"service,omitempty"` + // The HTTP status code returned by the error. + StatusCode *int64 `json:"statusCode,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 *ErrorValidation `json:"validation,omitempty"` +} + +func (o *ErrorMessage) GetCanBeRetried() *string { + if o == nil { + return nil + } + return o.CanBeRetried +} + +func (o *ErrorMessage) GetCorrelationID() *string { + if o == nil { + return nil + } + return o.CorrelationID +} + +func (o *ErrorMessage) GetDetailedErrorCode() *int64 { + if o == nil { + return nil + } + return o.DetailedErrorCode +} + +func (o *ErrorMessage) GetError() *string { + if o == nil { + return nil + } + return o.Error +} + +func (o *ErrorMessage) GetService() *string { + if o == nil { + return nil + } + return o.Service +} + +func (o *ErrorMessage) GetStatusCode() *int64 { + if o == nil { + return nil + } + return o.StatusCode +} + +func (o *ErrorMessage) GetValidation() *ErrorValidation { + if o == nil { + return nil + } + return o.Validation +} diff --git a/platform/pkg/models/shared/group.go b/platform/pkg/models/shared/group.go deleted file mode 100644 index 9ddb756dd..000000000 --- a/platform/pkg/models/shared/group.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -// Group - A container you can use to organize companies together according to a shared characteristic of your choice. -type Group struct { - // Unique identifier for the group. - ID *string `json:"id,omitempty"` - // Descriptive name of the group. - Name *string `json:"name,omitempty"` -} - -func (o *Group) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *Group) GetName() *string { - if o == nil { - return nil - } - return o.Name -} diff --git a/platform/pkg/models/shared/groupprototype.go b/platform/pkg/models/shared/groupprototype.go deleted file mode 100644 index 0fb37e16d..000000000 --- a/platform/pkg/models/shared/groupprototype.go +++ /dev/null @@ -1,16 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -// GroupPrototype - The group template used to create a group. -type GroupPrototype struct { - // Descriptive name of the group. - Name *string `json:"name,omitempty"` -} - -func (o *GroupPrototype) GetName() *string { - if o == nil { - return nil - } - return o.Name -} diff --git a/platform/pkg/models/shared/groupref.go b/platform/pkg/models/shared/groupref.go deleted file mode 100644 index 5aac2382e..000000000 --- a/platform/pkg/models/shared/groupref.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type GroupRef struct { - // Unique identifier for the group. - ID *string `json:"id,omitempty"` -} - -func (o *GroupRef) GetID() *string { - if o == nil { - return nil - } - return o.ID -} diff --git a/platform/pkg/models/shared/groups.go b/platform/pkg/models/shared/groups.go deleted file mode 100644 index 9c2e92d04..000000000 --- a/platform/pkg/models/shared/groups.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type Groups struct { - Results []Group `json:"results,omitempty"` -} - -func (o *Groups) GetResults() []Group { - if o == nil { - return nil - } - return o.Results -} diff --git a/platform/pkg/models/shared/readcompletedwebhook.go b/platform/pkg/models/shared/readcompletedwebhook.go new file mode 100644 index 000000000..7b6b89787 --- /dev/null +++ b/platform/pkg/models/shared/readcompletedwebhook.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ReadCompletedWebhook struct { + // 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"` + // Unique identifier of the event. + ID *string `json:"id,omitempty"` + Payload *ReadCompletedWebhookPayload `json:"payload,omitempty"` +} + +func (o *ReadCompletedWebhook) GetEventType() *string { + if o == nil { + return nil + } + return o.EventType +} + +func (o *ReadCompletedWebhook) GetGeneratedDate() *string { + if o == nil { + return nil + } + return o.GeneratedDate +} + +func (o *ReadCompletedWebhook) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *ReadCompletedWebhook) GetPayload() *ReadCompletedWebhookPayload { + if o == nil { + return nil + } + return o.Payload +} diff --git a/platform/pkg/models/shared/readcompletedwebhookpayload.go b/platform/pkg/models/shared/readcompletedwebhookpayload.go new file mode 100644 index 000000000..f40c761ef --- /dev/null +++ b/platform/pkg/models/shared/readcompletedwebhookpayload.go @@ -0,0 +1,88 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type DataTypes struct { + // Unique identifier for a company's data connection. + ConnectionID *string `json:"connectionId,omitempty"` + // Available data types + DataType *DataType `json:"dataType,omitempty"` + // `True` if records have been created, updated or deleted in Codat's cache. + RecordsModified *bool `json:"recordsModified,omitempty"` + // The current status of the dataset. + Status *Status `json:"status,omitempty"` +} + +func (o *DataTypes) GetConnectionID() *string { + if o == nil { + return nil + } + return o.ConnectionID +} + +func (o *DataTypes) GetDataType() *DataType { + if o == nil { + return nil + } + return o.DataType +} + +func (o *DataTypes) GetRecordsModified() *bool { + if o == nil { + return nil + } + return o.RecordsModified +} + +func (o *DataTypes) GetStatus() *Status { + if o == nil { + return nil + } + return o.Status +} + +type ReadCompletedWebhookPayload struct { + DataTypes []DataTypes `json:"dataTypes,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. + ModifiedFromDate *string `json:"modifiedFromDate,omitempty"` + ReferenceCompany *CompanyReference `json:"referenceCompany,omitempty"` +} + +func (o *ReadCompletedWebhookPayload) GetDataTypes() []DataTypes { + if o == nil { + return nil + } + return o.DataTypes +} + +func (o *ReadCompletedWebhookPayload) GetModifiedFromDate() *string { + if o == nil { + return nil + } + return o.ModifiedFromDate +} + +func (o *ReadCompletedWebhookPayload) GetReferenceCompany() *CompanyReference { + if o == nil { + return nil + } + return o.ReferenceCompany +} diff --git a/platform/pkg/models/shared/webhookconsumer.go b/platform/pkg/models/shared/webhookconsumer.go index 96c82e151..5fd6c4f1c 100644 --- a/platform/pkg/models/shared/webhookconsumer.go +++ b/platform/pkg/models/shared/webhookconsumer.go @@ -3,7 +3,7 @@ package shared import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" ) // WebhookConsumer - A webhook consumer is an HTTP endpoint that developers can configure to subscribe to Codat's supported event types. @@ -11,7 +11,11 @@ import ( // See our documentation for more details on [Codat's webhook service](https://docs.codat.io/using-the-api/webhooks/overview). type WebhookConsumer struct { // Unique identifier of the company to indicate company-specific events. The associated webhook consumer will receive events only for the specified ID. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. CompanyID *string `json:"companyId,omitempty"` + // Company tags provide an additional way to filter messages, independent of event types. Company tags are case-sensitive, and only messages from companies with matching tags will be sent to this endpoint. Use the format `tagKey:tagValue`. + CompanyTags []string `json:"companyTags,omitempty"` // Flag that enables or disables the endpoint from receiving events. Disabled when set to `true`. Disabled *bool `default:"false" json:"disabled"` // An array of event types the webhook consumer subscribes to. @@ -40,6 +44,13 @@ func (o *WebhookConsumer) GetCompanyID() *string { return o.CompanyID } +func (o *WebhookConsumer) GetCompanyTags() []string { + if o == nil { + return nil + } + return o.CompanyTags +} + func (o *WebhookConsumer) GetDisabled() *bool { if o == nil { return nil diff --git a/platform/pkg/models/shared/webhookconsumerprototype.go b/platform/pkg/models/shared/webhookconsumerprototype.go index db6674a3a..a069dfa58 100644 --- a/platform/pkg/models/shared/webhookconsumerprototype.go +++ b/platform/pkg/models/shared/webhookconsumerprototype.go @@ -3,12 +3,16 @@ package shared import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" ) type WebhookConsumerPrototype struct { // Unique identifier of the company to indicate company-specific events. The associated webhook consumer will receive events only for the specified ID. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. CompanyID *string `json:"companyId,omitempty"` + // Company tags provide an additional way to filter messages, independent of event types. Company tags are case-sensitive, and only messages from companies with matching tags will be sent to this endpoint. Use the format `tagKey:tagValue`. + CompanyTags []string `json:"companyTags,omitempty"` // Flag that enables or disables the endpoint from receiving events. Disabled when set to `true`. Disabled *bool `default:"false" json:"disabled"` // An array of event types the webhook consumer subscribes to. @@ -35,6 +39,13 @@ func (o *WebhookConsumerPrototype) GetCompanyID() *string { return o.CompanyID } +func (o *WebhookConsumerPrototype) GetCompanyTags() []string { + if o == nil { + return nil + } + return o.CompanyTags +} + func (o *WebhookConsumerPrototype) GetDisabled() *bool { if o == nil { return nil diff --git a/platform/pkg/models/operations/listgroups.go b/platform/pkg/models/webhooks/connectionconnected.go similarity index 52% rename from platform/pkg/models/operations/listgroups.go rename to platform/pkg/models/webhooks/connectionconnected.go index 02a8e8c11..119afa660 100644 --- a/platform/pkg/models/operations/listgroups.go +++ b/platform/pkg/models/webhooks/connectionconnected.go @@ -1,47 +1,37 @@ // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. -package operations +package webhooks import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" "net/http" ) -type ListGroupsResponse struct { +type ConnectionConnectedResponse struct { // HTTP response content type for this operation ContentType string // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response - // Success - Groups *shared.Groups } -func (o *ListGroupsResponse) GetContentType() string { +func (o *ConnectionConnectedResponse) GetContentType() string { if o == nil { return "" } return o.ContentType } -func (o *ListGroupsResponse) GetStatusCode() int { +func (o *ConnectionConnectedResponse) GetStatusCode() int { if o == nil { return 0 } return o.StatusCode } -func (o *ListGroupsResponse) GetRawResponse() *http.Response { +func (o *ConnectionConnectedResponse) GetRawResponse() *http.Response { if o == nil { return nil } return o.RawResponse } - -func (o *ListGroupsResponse) GetGroups() *shared.Groups { - if o == nil { - return nil - } - return o.Groups -} diff --git a/platform/pkg/models/webhooks/connectioncreated.go b/platform/pkg/models/webhooks/connectioncreated.go new file mode 100644 index 000000000..2ea6cd179 --- /dev/null +++ b/platform/pkg/models/webhooks/connectioncreated.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "net/http" +) + +type ConnectionCreatedResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ConnectionCreatedResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ConnectionCreatedResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ConnectionCreatedResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/webhooks/connectiondeleted.go b/platform/pkg/models/webhooks/connectiondeleted.go new file mode 100644 index 000000000..6f1386a23 --- /dev/null +++ b/platform/pkg/models/webhooks/connectiondeleted.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "net/http" +) + +type ConnectionDeletedResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ConnectionDeletedResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ConnectionDeletedResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ConnectionDeletedResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/webhooks/connectiondisconnected.go b/platform/pkg/models/webhooks/connectiondisconnected.go new file mode 100644 index 000000000..528218f2f --- /dev/null +++ b/platform/pkg/models/webhooks/connectiondisconnected.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "net/http" +) + +type ConnectionDisconnectedResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ConnectionDisconnectedResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ConnectionDisconnectedResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ConnectionDisconnectedResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/webhooks/connectionfailed.go b/platform/pkg/models/webhooks/connectionfailed.go new file mode 100644 index 000000000..3b871b513 --- /dev/null +++ b/platform/pkg/models/webhooks/connectionfailed.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "net/http" +) + +type ConnectionFailedResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ConnectionFailedResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ConnectionFailedResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ConnectionFailedResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/webhooks/connectionreconnected.go b/platform/pkg/models/webhooks/connectionreconnected.go new file mode 100644 index 000000000..980bf8bd8 --- /dev/null +++ b/platform/pkg/models/webhooks/connectionreconnected.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "net/http" +) + +type ConnectionReconnectedResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ConnectionReconnectedResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ConnectionReconnectedResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ConnectionReconnectedResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/webhooks/readcompleted.go b/platform/pkg/models/webhooks/readcompleted.go new file mode 100644 index 000000000..cbb2d6caa --- /dev/null +++ b/platform/pkg/models/webhooks/readcompleted.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package webhooks + +import ( + "net/http" +) + +type ReadCompletedResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ReadCompletedResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ReadCompletedResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ReadCompletedResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/platform/pkg/models/operations/creategroup.go b/platform/pkg/models/webhooks/readcompletedinitial.go similarity index 53% rename from platform/pkg/models/operations/creategroup.go rename to platform/pkg/models/webhooks/readcompletedinitial.go index 86cf50e9a..209df7257 100644 --- a/platform/pkg/models/operations/creategroup.go +++ b/platform/pkg/models/webhooks/readcompletedinitial.go @@ -1,45 +1,35 @@ // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. -package operations +package webhooks import ( - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" "net/http" ) -type CreateGroupResponse struct { +type ReadCompletedInitialResponse struct { // HTTP response content type for this operation ContentType string - // Success - Group *shared.Group // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } -func (o *CreateGroupResponse) GetContentType() string { +func (o *ReadCompletedInitialResponse) GetContentType() string { if o == nil { return "" } return o.ContentType } -func (o *CreateGroupResponse) GetGroup() *shared.Group { - if o == nil { - return nil - } - return o.Group -} - -func (o *CreateGroupResponse) GetStatusCode() int { +func (o *ReadCompletedInitialResponse) GetStatusCode() int { if o == nil { return 0 } return o.StatusCode } -func (o *CreateGroupResponse) GetRawResponse() *http.Response { +func (o *ReadCompletedInitialResponse) GetRawResponse() *http.Response { if o == nil { return nil } diff --git a/platform/pkg/utils/form.go b/platform/pkg/utils/form.go index 5164dfe69..f63811e3d 100644 --- a/platform/pkg/utils/form.go +++ b/platform/pkg/utils/form.go @@ -12,7 +12,7 @@ import ( "github.com/ericlagergren/decimal" - "github.com/codatio/client-sdk-go/platform/v3/pkg/types" + "github.com/codatio/client-sdk-go/platform/v4/pkg/types" ) func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { diff --git a/platform/pkg/utils/json.go b/platform/pkg/utils/json.go index eadc833ac..ac708768f 100644 --- a/platform/pkg/utils/json.go +++ b/platform/pkg/utils/json.go @@ -13,7 +13,7 @@ import ( "time" "unsafe" - "github.com/codatio/client-sdk-go/platform/v3/pkg/types" + "github.com/codatio/client-sdk-go/platform/v4/pkg/types" "github.com/ericlagergren/decimal" ) diff --git a/platform/pkg/utils/pathparams.go b/platform/pkg/utils/pathparams.go index b124a2777..380c4c8bc 100644 --- a/platform/pkg/utils/pathparams.go +++ b/platform/pkg/utils/pathparams.go @@ -13,7 +13,7 @@ import ( "github.com/ericlagergren/decimal" - "github.com/codatio/client-sdk-go/platform/v3/pkg/types" + "github.com/codatio/client-sdk-go/platform/v4/pkg/types" ) func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) { diff --git a/platform/pkg/utils/queryparams.go b/platform/pkg/utils/queryparams.go index bb46e71c8..0a821f075 100644 --- a/platform/pkg/utils/queryparams.go +++ b/platform/pkg/utils/queryparams.go @@ -14,7 +14,7 @@ import ( "github.com/ericlagergren/decimal" - "github.com/codatio/client-sdk-go/platform/v3/pkg/types" + "github.com/codatio/client-sdk-go/platform/v4/pkg/types" ) func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error { diff --git a/platform/pkg/utils/retries.go b/platform/pkg/utils/retries.go index 796e5564d..ce817ee94 100644 --- a/platform/pkg/utils/retries.go +++ b/platform/pkg/utils/retries.go @@ -7,7 +7,7 @@ import ( "errors" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" "net/http" "net/url" "strconv" diff --git a/platform/pkg/utils/utils.go b/platform/pkg/utils/utils.go index adb2f7055..f1ff9e0aa 100644 --- a/platform/pkg/utils/utils.go +++ b/platform/pkg/utils/utils.go @@ -3,10 +3,12 @@ package utils import ( + "bytes" "context" "fmt" "io" "math/big" + "net/http" "reflect" "regexp" "strconv" @@ -228,3 +230,15 @@ func contains(arr []string, str string) bool { } return false } + +func ConsumeRawBody(res *http.Response) ([]byte, error) { + rawBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + + res.Body.Close() + res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + return rawBody, nil +} diff --git a/platform/pushdata.go b/platform/pushdata.go index b29e35457..6d277d43d 100644 --- a/platform/pushdata.go +++ b/platform/pushdata.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) @@ -185,21 +184,11 @@ func (s *PushData) GetModelOptions(ctx context.Context, request operations.GetCr RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -211,11 +200,10 @@ func (s *PushData) GetModelOptions(ctx context.Context, request operations.GetCr res.PushOption = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -233,7 +221,7 @@ func (s *PushData) GetModelOptions(ctx context.Context, request operations.GetCr case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -245,28 +233,25 @@ func (s *PushData) GetModelOptions(ctx context.Context, request operations.GetCr return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -275,7 +260,9 @@ func (s *PushData) GetModelOptions(ctx context.Context, request operations.GetCr } // GetOperation - Get push operation -// Retrieve push operation. +// The **Get push operation** endpoint returns a specific [push operation](/using-the-api/push) identified by the `pushOperationKey` that was performed on the company. +// +// Write operations are actions that send requests to Codat, enabling the creation, updating, deletion of records, or uploading attachments in the connected accounting software. func (s *PushData) GetOperation(ctx context.Context, request operations.GetPushOperationRequest, opts ...operations.Option) (*operations.GetPushOperationResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, @@ -423,21 +410,11 @@ func (s *PushData) GetOperation(ctx context.Context, request operations.GetPushO RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -449,11 +426,10 @@ func (s *PushData) GetOperation(ctx context.Context, request operations.GetPushO res.PushOperation = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -471,7 +447,7 @@ func (s *PushData) GetOperation(ctx context.Context, request operations.GetPushO case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -483,28 +459,25 @@ func (s *PushData) GetOperation(ctx context.Context, request operations.GetPushO return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -513,7 +486,9 @@ func (s *PushData) GetOperation(ctx context.Context, request operations.GetPushO } // ListOperations - List push operations -// List push operation records. +// The **List push operations** endpoint returns a list of [push operations](/using-the-api/push) performed on the company. +// +// Write operations are actions that send requests to Codat, enabling the creation, updating, deletion of records, or uploading attachments in the connected accounting software. func (s *PushData) ListOperations(ctx context.Context, request operations.GetCompanyPushHistoryRequest, opts ...operations.Option) (*operations.GetCompanyPushHistoryResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, @@ -665,21 +640,11 @@ func (s *PushData) ListOperations(ctx context.Context, request operations.GetCom RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -691,11 +656,10 @@ func (s *PushData) ListOperations(ctx context.Context, request operations.GetCom res.PushOperations = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -715,7 +679,7 @@ func (s *PushData) ListOperations(ctx context.Context, request operations.GetCom case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -727,28 +691,25 @@ func (s *PushData) ListOperations(ctx context.Context, request operations.GetCom return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/refreshdata.go b/platform/refreshdata.go index 0d323f94b..1c265a5fc 100644 --- a/platform/refreshdata.go +++ b/platform/refreshdata.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) @@ -181,16 +180,6 @@ func (s *RefreshData) All(ctx context.Context, request operations.RefreshCompany RawResponse: 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: @@ -208,7 +197,7 @@ func (s *RefreshData) All(ctx context.Context, request operations.RefreshCompany case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -220,28 +209,25 @@ func (s *RefreshData) All(ctx context.Context, request operations.RefreshCompany return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -404,21 +390,11 @@ func (s *RefreshData) ByDataType(ctx context.Context, request operations.Refresh RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -430,11 +406,10 @@ func (s *RefreshData) ByDataType(ctx context.Context, request operations.Refresh res.PullOperation = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -452,7 +427,7 @@ func (s *RefreshData) ByDataType(ctx context.Context, request operations.Refresh case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -464,28 +439,25 @@ func (s *RefreshData) ByDataType(ctx context.Context, request operations.Refresh return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -642,21 +614,11 @@ func (s *RefreshData) Get(ctx context.Context, request operations.GetCompanyData RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -668,11 +630,10 @@ func (s *RefreshData) Get(ctx context.Context, request operations.GetCompanyData res.DataStatuses = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -690,7 +651,7 @@ func (s *RefreshData) Get(ctx context.Context, request operations.GetCompanyData case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -702,28 +663,25 @@ func (s *RefreshData) Get(ctx context.Context, request operations.GetCompanyData return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -880,21 +838,11 @@ func (s *RefreshData) GetPullOperation(ctx context.Context, request operations.G RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -906,11 +854,10 @@ func (s *RefreshData) GetPullOperation(ctx context.Context, request operations.G res.PullOperation = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -928,7 +875,7 @@ func (s *RefreshData) GetPullOperation(ctx context.Context, request operations.G case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -940,28 +887,25 @@ func (s *RefreshData) GetPullOperation(ctx context.Context, request operations.G return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1122,21 +1066,11 @@ func (s *RefreshData) ListPullOperations(ctx context.Context, request operations RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1148,11 +1082,10 @@ func (s *RefreshData) ListPullOperations(ctx context.Context, request operations res.PullOperations = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1172,7 +1105,7 @@ func (s *RefreshData) ListPullOperations(ctx context.Context, request operations case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1184,28 +1117,25 @@ func (s *RefreshData) ListPullOperations(ctx context.Context, request operations return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/settings.go b/platform/settings.go index 26cdac02d..73862f016 100644 --- a/platform/settings.go +++ b/platform/settings.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" "net/url" ) @@ -194,21 +193,11 @@ func (s *Settings) CreateAPIKey(ctx context.Context, request *shared.CreateAPIKe RawResponse: 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 == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -220,11 +209,10 @@ func (s *Settings) CreateAPIKey(ctx context.Context, request *shared.CreateAPIKe res.APIKeyDetails = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -244,7 +232,7 @@ func (s *Settings) CreateAPIKey(ctx context.Context, request *shared.CreateAPIKe case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -256,28 +244,25 @@ func (s *Settings) CreateAPIKey(ctx context.Context, request *shared.CreateAPIKe return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -443,37 +428,26 @@ func (s *Settings) DeleteAPIKey(ctx context.Context, request operations.DeleteAP RawResponse: 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: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.ErrorMessage + var out shared.ErrorMessage if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.ErrorMessage = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -491,7 +465,7 @@ func (s *Settings) DeleteAPIKey(ctx context.Context, request operations.DeleteAP case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -503,28 +477,25 @@ func (s *Settings) DeleteAPIKey(ctx context.Context, request operations.DeleteAP return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -681,21 +652,11 @@ func (s *Settings) GetProfile(ctx context.Context, opts ...operations.Option) (* RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -707,11 +668,10 @@ func (s *Settings) GetProfile(ctx context.Context, opts ...operations.Option) (* res.Profile = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -727,7 +687,7 @@ func (s *Settings) GetProfile(ctx context.Context, opts ...operations.Option) (* case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -739,28 +699,25 @@ func (s *Settings) GetProfile(ctx context.Context, opts ...operations.Option) (* return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -917,21 +874,11 @@ func (s *Settings) GetSyncSettings(ctx context.Context, opts ...operations.Optio RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -943,11 +890,10 @@ func (s *Settings) GetSyncSettings(ctx context.Context, opts ...operations.Optio res.SyncSettings = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -963,7 +909,7 @@ func (s *Settings) GetSyncSettings(ctx context.Context, opts ...operations.Optio case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -975,28 +921,25 @@ func (s *Settings) GetSyncSettings(ctx context.Context, opts ...operations.Optio return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1157,21 +1100,11 @@ func (s *Settings) ListAPIKeys(ctx context.Context, opts ...operations.Option) ( RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1183,11 +1116,10 @@ func (s *Settings) ListAPIKeys(ctx context.Context, opts ...operations.Option) ( res.APIKeys = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1203,7 +1135,7 @@ func (s *Settings) ListAPIKeys(ctx context.Context, opts ...operations.Option) ( case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1215,28 +1147,25 @@ func (s *Settings) ListAPIKeys(ctx context.Context, opts ...operations.Option) ( return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1399,21 +1328,11 @@ func (s *Settings) UpdateProfile(ctx context.Context, request *shared.Profile, o RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1425,11 +1344,10 @@ func (s *Settings) UpdateProfile(ctx context.Context, request *shared.Profile, o res.Profile = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1445,7 +1363,7 @@ func (s *Settings) UpdateProfile(ctx context.Context, request *shared.Profile, o case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1457,28 +1375,25 @@ func (s *Settings) UpdateProfile(ctx context.Context, request *shared.Profile, o return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1641,16 +1556,6 @@ func (s *Settings) UpdateSyncSettings(ctx context.Context, request *operations.U RawResponse: 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: @@ -1666,7 +1571,7 @@ func (s *Settings) UpdateSyncSettings(ctx context.Context, request *operations.U case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1678,28 +1583,25 @@ func (s *Settings) UpdateSyncSettings(ctx context.Context, request *operations.U return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/supplementaldata.go b/platform/supplementaldata.go index 2b99633e0..6ccb3d527 100644 --- a/platform/supplementaldata.go +++ b/platform/supplementaldata.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" ) @@ -188,16 +187,6 @@ func (s *SupplementalData) Configure(ctx context.Context, request operations.Con RawResponse: 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: @@ -215,7 +204,7 @@ func (s *SupplementalData) Configure(ctx context.Context, request operations.Con case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -227,28 +216,25 @@ func (s *SupplementalData) Configure(ctx context.Context, request operations.Con return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -407,21 +393,11 @@ func (s *SupplementalData) GetConfiguration(ctx context.Context, request operati RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -433,11 +409,10 @@ func (s *SupplementalData) GetConfiguration(ctx context.Context, request operati res.SupplementalDataConfiguration = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -455,7 +430,7 @@ func (s *SupplementalData) GetConfiguration(ctx context.Context, request operati case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -467,28 +442,25 @@ func (s *SupplementalData) GetConfiguration(ctx context.Context, request operati return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/platform/webhooks.go b/platform/webhooks.go index c154fdde2..a147eb49b 100644 --- a/platform/webhooks.go +++ b/platform/webhooks.go @@ -7,13 +7,12 @@ import ( "context" "fmt" "github.com/cenkalti/backoff/v4" - "github.com/codatio/client-sdk-go/platform/v3/internal/hooks" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/operations" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/sdkerrors" - "github.com/codatio/client-sdk-go/platform/v3/pkg/models/shared" - "github.com/codatio/client-sdk-go/platform/v3/pkg/retry" - "github.com/codatio/client-sdk-go/platform/v3/pkg/utils" - "io" + "github.com/codatio/client-sdk-go/platform/v4/internal/hooks" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/operations" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/sdkerrors" + "github.com/codatio/client-sdk-go/platform/v4/pkg/models/shared" + "github.com/codatio/client-sdk-go/platform/v4/pkg/retry" + "github.com/codatio/client-sdk-go/platform/v4/pkg/utils" "net/http" "net/url" ) @@ -29,8 +28,10 @@ func newWebhooks(sdkConfig sdkConfiguration) *Webhooks { } } -// Create webhook -// Create a new webhook configuration +// Create webhook (legacy) +// Use the *Create webhooks (legacy)* endpoint to create a rule-based webhook for your client. +// +// **Note:** This endpoint has been deprecated. Please use the [*Create webhook consumer*](https://docs.codat.io/platform-api#/operations/create-webhook-consumer) endpoint to create a webhook moving forward. // // Deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. func (s *Webhooks) Create(ctx context.Context, request *shared.CreateRule, opts ...operations.Option) (*operations.CreateRuleResponse, error) { @@ -186,21 +187,11 @@ func (s *Webhooks) Create(ctx context.Context, request *shared.CreateRule, opts RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -212,11 +203,10 @@ func (s *Webhooks) Create(ctx context.Context, request *shared.CreateRule, opts res.Webhook = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -232,7 +222,7 @@ func (s *Webhooks) Create(ctx context.Context, request *shared.CreateRule, opts case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -244,28 +234,25 @@ func (s *Webhooks) Create(ctx context.Context, request *shared.CreateRule, opts return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -433,21 +420,11 @@ func (s *Webhooks) CreateConsumer(ctx context.Context, request *shared.WebhookCo RawResponse: 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 == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -459,11 +436,10 @@ func (s *Webhooks) CreateConsumer(ctx context.Context, request *shared.WebhookCo res.WebhookConsumer = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -481,7 +457,7 @@ func (s *Webhooks) CreateConsumer(ctx context.Context, request *shared.WebhookCo case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -493,28 +469,25 @@ func (s *Webhooks) CreateConsumer(ctx context.Context, request *shared.WebhookCo return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -673,16 +646,6 @@ func (s *Webhooks) DeleteConsumer(ctx context.Context, request operations.Delete RawResponse: 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: @@ -700,7 +663,7 @@ func (s *Webhooks) DeleteConsumer(ctx context.Context, request operations.Delete case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -712,28 +675,25 @@ func (s *Webhooks) DeleteConsumer(ctx context.Context, request operations.Delete return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -741,8 +701,10 @@ func (s *Webhooks) DeleteConsumer(ctx context.Context, request operations.Delete } -// Get webhook -// Get a single webhook +// Get webhook (legacy) +// Use the *Get webhook (legacy)* endpoint to retrieve a specific webhook for your client. +// +// **Note:** This endpoint has been deprecated. Please use the [*List webhook consumers*](https://docs.codat.io/platform-api#/operations/list-webhook-consumers) endpoint for listing webhooks moving forward. // // Deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. func (s *Webhooks) Get(ctx context.Context, request operations.GetWebhookRequest, opts ...operations.Option) (*operations.GetWebhookResponse, error) { @@ -892,21 +854,11 @@ func (s *Webhooks) Get(ctx context.Context, request operations.GetWebhookRequest RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -918,11 +870,10 @@ func (s *Webhooks) Get(ctx context.Context, request operations.GetWebhookRequest res.Webhook = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -940,7 +891,7 @@ func (s *Webhooks) Get(ctx context.Context, request operations.GetWebhookRequest case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -952,28 +903,25 @@ func (s *Webhooks) Get(ctx context.Context, request operations.GetWebhookRequest return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -981,8 +929,10 @@ func (s *Webhooks) Get(ctx context.Context, request operations.GetWebhookRequest } -// List webhooks -// List webhooks that you are subscribed to. +// List webhooks (legacy) +// Use the *List webhooks (legacy)* endpoint to retrieve all existing rule-based webhooks for your client. +// +// **Note:** This endpoint has been deprecated. Please use the [*List webhook consumers*](https://docs.codat.io/platform-api#/operations/list-webhook-consumers) endpoint for listing webhooks moving forward. // // Deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. func (s *Webhooks) List(ctx context.Context, request operations.ListRulesRequest, opts ...operations.Option) (*operations.ListRulesResponse, error) { @@ -1136,21 +1086,11 @@ func (s *Webhooks) List(ctx context.Context, request operations.ListRulesRequest RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1162,11 +1102,10 @@ func (s *Webhooks) List(ctx context.Context, request operations.ListRulesRequest res.Webhooks = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1186,7 +1125,7 @@ func (s *Webhooks) List(ctx context.Context, request operations.ListRulesRequest case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1198,28 +1137,25 @@ func (s *Webhooks) List(ctx context.Context, request operations.ListRulesRequest return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1378,21 +1314,11 @@ func (s *Webhooks) ListConsumers(ctx context.Context, opts ...operations.Option) RawResponse: 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1404,11 +1330,10 @@ func (s *Webhooks) ListConsumers(ctx context.Context, opts ...operations.Option) res.WebhookConsumers = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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: @@ -1426,7 +1351,7 @@ func (s *Webhooks) ListConsumers(ctx context.Context, opts ...operations.Option) case httpRes.StatusCode == 503: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1438,28 +1363,25 @@ func (s *Webhooks) ListConsumers(ctx context.Context, opts ...operations.Option) return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) }