diff --git a/sync-for-expenses/.gitignore b/sync-for-expenses/.gitignore index 8b1378917..d3c2f597f 100755 --- a/sync-for-expenses/.gitignore +++ b/sync-for-expenses/.gitignore @@ -1 +1 @@ - +# .gitignore diff --git a/sync-for-expenses/README.md b/sync-for-expenses/README.md index 7e674ed9b..eb43f1602 100755 --- a/sync-for-expenses/README.md +++ b/sync-for-expenses/README.md @@ -17,63 +17,63 @@ go get github.com/codatio/client-sdk-go/sync-for-expenses ```go package main -import( +import ( "context" - "log" syncforexpenses "github.com/codatio/client-sdk-go/sync-for-expenses/v3" - "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/models/shared" "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/models/shared" "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/types" + "log" ) func main() { - s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), - ) - - ctx := context.Background() - res, err := s.Accounts.Create(ctx, operations.CreateAccountRequest{ - Account: &shared.Account{ - Currency: syncforexpenses.String("USD"), - CurrentBalance: types.MustNewDecimalFromString("0"), - Description: syncforexpenses.String("Invoices the business has issued but has not yet collected payment on."), - FullyQualifiedCategory: syncforexpenses.String("Asset.Current"), - FullyQualifiedName: syncforexpenses.String("Cash On Hand"), - ID: syncforexpenses.String("1b6266d1-1e44-46c5-8eb5-a8f98e03124e"), - IsBankAccount: syncforexpenses.Bool(false), - Metadata: &shared.AccountMetadata{ - IsDeleted: syncforexpenses.Bool(false), - }, - ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Name: syncforexpenses.String("Accounts Receivable"), - NominalCode: syncforexpenses.String("610"), - SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Status: shared.AccountStatusActive.ToPointer(), - Type: shared.AccountTypeAsset.ToPointer(), - ValidDatatypeLinks: []shared.AccountValidDataTypeLinks{ - shared.AccountValidDataTypeLinks{ - Links: []string{ - "Money", - }, - Property: syncforexpenses.String("Cambridgeshire grey technology"), - }, - }, - }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), - CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", - ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - TimeoutInMinutes: syncforexpenses.Int(86), - }) - if err != nil { - log.Fatal(err) - } - - if res.CreateAccountResponse != nil { - // handle response - } + s := syncforexpenses.New( + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), + ) + + ctx := context.Background() + res, err := s.Accounts.Create(ctx, operations.CreateAccountRequest{ + Account: &shared.Account{ + Currency: syncforexpenses.String("USD"), + CurrentBalance: types.MustNewDecimalFromString("0"), + Description: syncforexpenses.String("Invoices the business has issued but has not yet collected payment on."), + FullyQualifiedCategory: syncforexpenses.String("Asset.Current"), + FullyQualifiedName: syncforexpenses.String("Cash On Hand"), + ID: syncforexpenses.String("1b6266d1-1e44-46c5-8eb5-a8f98e03124e"), + Metadata: &shared.AccountMetadata{}, + ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), + Name: syncforexpenses.String("Accounts Receivable"), + NominalCode: syncforexpenses.String("610"), + SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), + Status: shared.AccountStatusActive.ToPointer(), + SupplementalData: &shared.SupplementalData{ + Content: map[string]map[string]interface{}{ + "Money": map[string]interface{}{ + "blue": "shred", + }, + }, + }, + Type: shared.AccountTypeAsset.ToPointer(), + ValidDatatypeLinks: []shared.AccountValidDataTypeLinks{ + shared.AccountValidDataTypeLinks{ + Links: []string{ + "abnormally", + }, + }, + }, + }, + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }) + if err != nil { + log.Fatal(err) + } + + if res.CreateAccountResponse != nil { + // handle response + } } + ``` @@ -158,8 +158,6 @@ func main() { - - diff --git a/sync-for-expenses/RELEASES.md b/sync-for-expenses/RELEASES.md index 5aa2f47c9..053f0bbf8 100644 --- a/sync-for-expenses/RELEASES.md +++ b/sync-for-expenses/RELEASES.md @@ -372,4 +372,14 @@ Based on: ### Generated - [go v3.1.0] sync-for-expenses ### Releases -- [Go v3.1.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-expenses/v3.1.0 - sync-for-expenses \ No newline at end of file +- [Go v3.1.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-expenses/v3.1.0 - sync-for-expenses + +## 2023-10-17 14:43:23 +### Changes +Based on: +- OpenAPI Doc prealpha https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Sync-Expenses.yaml +- Speakeasy CLI 1.100.2 (2.159.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v3.2.0] sync-for-expenses +### Releases +- [Go v3.2.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-expenses/v3.2.0 - sync-for-expenses \ No newline at end of file diff --git a/sync-for-expenses/USAGE.md b/sync-for-expenses/USAGE.md index add39c736..7388b5a5f 100755 --- a/sync-for-expenses/USAGE.md +++ b/sync-for-expenses/USAGE.md @@ -4,62 +4,62 @@ ```go package main -import( +import ( "context" - "log" syncforexpenses "github.com/codatio/client-sdk-go/sync-for-expenses/v3" - "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/models/shared" "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/models/operations" + "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/models/shared" "github.com/codatio/client-sdk-go/sync-for-expenses/v3/pkg/types" + "log" ) func main() { - s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), - ) + s := syncforexpenses.New( + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), + ) - ctx := context.Background() - res, err := s.Accounts.Create(ctx, operations.CreateAccountRequest{ - Account: &shared.Account{ - Currency: syncforexpenses.String("USD"), - CurrentBalance: types.MustNewDecimalFromString("0"), - Description: syncforexpenses.String("Invoices the business has issued but has not yet collected payment on."), - FullyQualifiedCategory: syncforexpenses.String("Asset.Current"), - FullyQualifiedName: syncforexpenses.String("Cash On Hand"), - ID: syncforexpenses.String("1b6266d1-1e44-46c5-8eb5-a8f98e03124e"), - IsBankAccount: syncforexpenses.Bool(false), - Metadata: &shared.AccountMetadata{ - IsDeleted: syncforexpenses.Bool(false), - }, - ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Name: syncforexpenses.String("Accounts Receivable"), - NominalCode: syncforexpenses.String("610"), - SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Status: shared.AccountStatusActive.ToPointer(), - Type: shared.AccountTypeAsset.ToPointer(), - ValidDatatypeLinks: []shared.AccountValidDataTypeLinks{ - shared.AccountValidDataTypeLinks{ - Links: []string{ - "Money", - }, - Property: syncforexpenses.String("Cambridgeshire grey technology"), - }, - }, - }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), - CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", - ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - TimeoutInMinutes: syncforexpenses.Int(86), - }) - if err != nil { - log.Fatal(err) - } + ctx := context.Background() + res, err := s.Accounts.Create(ctx, operations.CreateAccountRequest{ + Account: &shared.Account{ + Currency: syncforexpenses.String("USD"), + CurrentBalance: types.MustNewDecimalFromString("0"), + Description: syncforexpenses.String("Invoices the business has issued but has not yet collected payment on."), + FullyQualifiedCategory: syncforexpenses.String("Asset.Current"), + FullyQualifiedName: syncforexpenses.String("Cash On Hand"), + ID: syncforexpenses.String("1b6266d1-1e44-46c5-8eb5-a8f98e03124e"), + Metadata: &shared.AccountMetadata{}, + ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), + Name: syncforexpenses.String("Accounts Receivable"), + NominalCode: syncforexpenses.String("610"), + SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), + Status: shared.AccountStatusActive.ToPointer(), + SupplementalData: &shared.SupplementalData{ + Content: map[string]map[string]interface{}{ + "Money": map[string]interface{}{ + "blue": "shred", + }, + }, + }, + Type: shared.AccountTypeAsset.ToPointer(), + ValidDatatypeLinks: []shared.AccountValidDataTypeLinks{ + shared.AccountValidDataTypeLinks{ + Links: []string{ + "abnormally", + }, + }, + }, + }, + CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", + ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }) + if err != nil { + log.Fatal(err) + } - if res.CreateAccountResponse != nil { - // handle response - } + if res.CreateAccountResponse != nil { + // handle response + } } + ``` \ No newline at end of file diff --git a/sync-for-expenses/accounts.go b/sync-for-expenses/accounts.go index 4d9e96365..efed7222f 100755 --- a/sync-for-expenses/accounts.go +++ b/sync-for-expenses/accounts.go @@ -108,13 +108,6 @@ func (s *accounts) Create(ctx context.Context, request operations.CreateAccountR return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreateAccountResponse{ @@ -122,6 +115,13 @@ func (s *accounts) Create(ctx context.Context, request operations.CreateAccountR ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -230,13 +230,6 @@ func (s *accounts) GetCreateModel(ctx context.Context, request operations.GetCre return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetCreateChartOfAccountsModelResponse{ @@ -244,6 +237,13 @@ func (s *accounts) GetCreateModel(ctx context.Context, request operations.GetCre ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/codatsyncexpenses.go b/sync-for-expenses/codatsyncexpenses.go index 94b81f43c..ab573c33d 100755 --- a/sync-for-expenses/codatsyncexpenses.go +++ b/sync-for-expenses/codatsyncexpenses.go @@ -136,6 +136,7 @@ func WithClient(client HTTPClient) SDKOption { sdk.sdkConfiguration.DefaultClient = client } } + func withSecurity(security interface{}) func(context.Context) (interface{}, error) { return func(context.Context) (interface{}, error) { return &security, nil @@ -143,18 +144,11 @@ func withSecurity(security interface{}) func(context.Context) (interface{}, erro } // WithSecurity configures the SDK to use the provided security details -func WithSecurity(security shared.Security) SDKOption { - return func(sdk *CodatSyncExpenses) { - sdk.sdkConfiguration.Security = withSecurity(security) - } -} -// WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication -func WithSecuritySource(security func(context.Context) (shared.Security, error)) SDKOption { +func WithSecurity(authHeader string) SDKOption { return func(sdk *CodatSyncExpenses) { - sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) { - return security(ctx) - } + security := shared.Security{AuthHeader: authHeader} + sdk.sdkConfiguration.Security = withSecurity(&security) } } @@ -170,9 +164,9 @@ func New(opts ...SDKOption) *CodatSyncExpenses { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "prealpha", - SDKVersion: "3.1.0", - GenVersion: "2.146.1", - UserAgent: "speakeasy-sdk/go 3.1.0 2.146.1 prealpha github.com/codatio/client-sdk-go/sync-for-expenses", + SDKVersion: "3.2.0", + GenVersion: "2.159.2", + UserAgent: "speakeasy-sdk/go 3.2.0 2.159.2 prealpha github.com/codatio/client-sdk-go/sync-for-expenses", }, } for _, opt := range opts { diff --git a/sync-for-expenses/companies.go b/sync-for-expenses/companies.go index 930c4fd0e..af5d039f9 100755 --- a/sync-for-expenses/companies.go +++ b/sync-for-expenses/companies.go @@ -96,13 +96,6 @@ func (s *companies) Create(ctx context.Context, request *shared.CompanyRequestBo return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreateCompanyResponse{ @@ -110,6 +103,13 @@ func (s *companies) Create(ctx context.Context, request *shared.CompanyRequestBo ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -209,13 +209,6 @@ func (s *companies) Delete(ctx context.Context, request operations.DeleteCompany return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.DeleteCompanyResponse{ @@ -223,6 +216,13 @@ func (s *companies) Delete(ctx context.Context, request operations.DeleteCompany ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 204: case httpRes.StatusCode == 401: @@ -310,13 +310,6 @@ func (s *companies) Get(ctx context.Context, request operations.GetCompanyReques return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetCompanyResponse{ @@ -324,6 +317,13 @@ func (s *companies) Get(ctx context.Context, request operations.GetCompanyReques ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -423,13 +423,6 @@ func (s *companies) List(ctx context.Context, request operations.ListCompaniesRe return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListCompaniesResponse{ @@ -437,6 +430,13 @@ func (s *companies) List(ctx context.Context, request operations.ListCompaniesRe ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -542,13 +542,6 @@ func (s *companies) Update(ctx context.Context, request operations.UpdateCompany return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.UpdateCompanyResponse{ @@ -556,6 +549,13 @@ func (s *companies) Update(ctx context.Context, request operations.UpdateCompany ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/configuration.go b/sync-for-expenses/configuration.go index 8a2803971..62b3ab336 100755 --- a/sync-for-expenses/configuration.go +++ b/sync-for-expenses/configuration.go @@ -89,13 +89,6 @@ func (s *configuration) Get(ctx context.Context, request operations.GetCompanyCo return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetCompanyConfigurationResponse{ @@ -103,6 +96,13 @@ func (s *configuration) Get(ctx context.Context, request operations.GetCompanyCo ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -201,13 +201,6 @@ func (s *configuration) GetMappingOptions(ctx context.Context, request operation return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetMappingOptionsResponse{ @@ -215,6 +208,13 @@ func (s *configuration) GetMappingOptions(ctx context.Context, request operation ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -320,13 +320,6 @@ func (s *configuration) Set(ctx context.Context, request operations.SetCompanyCo return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.SetCompanyConfigurationResponse{ @@ -334,6 +327,13 @@ func (s *configuration) Set(ctx context.Context, request operations.SetCompanyCo ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/connections.go b/sync-for-expenses/connections.go index 3d25262f4..2aeba2b69 100755 --- a/sync-for-expenses/connections.go +++ b/sync-for-expenses/connections.go @@ -98,13 +98,6 @@ func (s *connections) Create(ctx context.Context, request operations.CreateConne return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreateConnectionResponse{ @@ -112,6 +105,13 @@ func (s *connections) Create(ctx context.Context, request operations.CreateConne ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -210,13 +210,6 @@ func (s *connections) CreatePartnerExpenseConnection(ctx context.Context, reques return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreatePartnerExpenseConnectionResponse{ @@ -224,6 +217,13 @@ func (s *connections) CreatePartnerExpenseConnection(ctx context.Context, reques ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -325,13 +325,6 @@ func (s *connections) Delete(ctx context.Context, request operations.DeleteConne return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.DeleteConnectionResponse{ @@ -339,6 +332,13 @@ func (s *connections) Delete(ctx context.Context, request operations.DeleteConne ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: case httpRes.StatusCode == 401: @@ -426,13 +426,6 @@ func (s *connections) Get(ctx context.Context, request operations.GetConnectionR return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetConnectionResponse{ @@ -440,6 +433,13 @@ func (s *connections) Get(ctx context.Context, request operations.GetConnectionR ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -542,13 +542,6 @@ func (s *connections) List(ctx context.Context, request operations.ListConnectio return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListConnectionsResponse{ @@ -556,6 +549,13 @@ func (s *connections) List(ctx context.Context, request operations.ListConnectio ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -663,13 +663,6 @@ func (s *connections) Unlink(ctx context.Context, request operations.UnlinkConne return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.UnlinkConnectionResponse{ @@ -677,6 +670,13 @@ func (s *connections) Unlink(ctx context.Context, request operations.UnlinkConne ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/customers.go b/sync-for-expenses/customers.go index b2332d36a..785d0cdd5 100755 --- a/sync-for-expenses/customers.go +++ b/sync-for-expenses/customers.go @@ -108,13 +108,6 @@ func (s *customers) Create(ctx context.Context, request operations.CreateCustome return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreateCustomerResponse{ @@ -122,6 +115,13 @@ func (s *customers) Create(ctx context.Context, request operations.CreateCustome ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -228,13 +228,6 @@ func (s *customers) Get(ctx context.Context, request operations.GetCustomerReque return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetCustomerResponse{ @@ -242,6 +235,13 @@ func (s *customers) Get(ctx context.Context, request operations.GetCustomerReque ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -350,13 +350,6 @@ func (s *customers) List(ctx context.Context, request operations.ListCustomersRe return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListCustomersResponse{ @@ -364,6 +357,13 @@ func (s *customers) List(ctx context.Context, request operations.ListCustomersRe ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -483,13 +483,6 @@ func (s *customers) Update(ctx context.Context, request operations.UpdateCustome return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.UpdateCustomerResponse{ @@ -497,6 +490,13 @@ func (s *customers) Update(ctx context.Context, request operations.UpdateCustome ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/docs/models/shared/account.md b/sync-for-expenses/docs/models/shared/account.md index 280c22fc0..b0500fec3 100755 --- a/sync-for-expenses/docs/models/shared/account.md +++ b/sync-for-expenses/docs/models/shared/account.md @@ -47,5 +47,6 @@ To determine the list of allowed categories for a specific integration, you can: | `NominalCode` | **string* | :heavy_minus_sign: | Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. | 610 | | `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23T00:00:00.000Z | | `Status` | [*AccountStatus](../../models/shared/accountstatus.md) | :heavy_minus_sign: | Status of the account | Active | +| `SupplementalData` | [*SupplementalData](../../models/shared/supplementaldata.md) | :heavy_minus_sign: | Supplemental data is additional data you can include in our standard data types.

It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. | | | `Type` | [*AccountType](../../models/shared/accounttype.md) | :heavy_minus_sign: | Type of account | Asset | | `ValidDatatypeLinks` | [][AccountValidDataTypeLinks](../../models/shared/accountvaliddatatypelinks.md) | :heavy_minus_sign: | The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/sync-for-expenses-api#/schemas/ValidDataTypeLinks). | | \ No newline at end of file diff --git a/sync-for-expenses/docs/models/shared/accountmappinginfo.md b/sync-for-expenses/docs/models/shared/accountmappinginfo.md index 3561fdff8..ac056c8be 100755 --- a/sync-for-expenses/docs/models/shared/accountmappinginfo.md +++ b/sync-for-expenses/docs/models/shared/accountmappinginfo.md @@ -9,4 +9,4 @@ | `Currency` | **string* | :heavy_minus_sign: | Currency of the account. | GBP | | `ID` | **string* | :heavy_minus_sign: | Unique identifier of account. | 6 | | `Name` | **string* | :heavy_minus_sign: | Name of the account as it appears in the companies accounting software. | Purchases | -| `ValidTransactionTypes` | [][AccountMappingInfoValidTransactionTypes](../../models/shared/accountmappinginfovalidtransactiontypes.md) | :heavy_minus_sign: | Supported transaction types for the account. | | \ No newline at end of file +| `ValidTransactionTypes` | [][AccountMappingInfoValidTransactionTypes](../../models/shared/accountmappinginfovalidtransactiontypes.md) | :heavy_minus_sign: | Supported transaction types for the account. | Payment | \ No newline at end of file diff --git a/sync-for-expenses/docs/models/shared/supplier.md b/sync-for-expenses/docs/models/shared/supplier.md index 344ddab8d..a5078885e 100755 --- a/sync-for-expenses/docs/models/shared/supplier.md +++ b/sync-for-expenses/docs/models/shared/supplier.md @@ -22,6 +22,6 @@ From the **Suppliers** endpoints, you can retrieve a list of [all the suppliers | `RegistrationNumber` | **string* | :heavy_minus_sign: | Company number of the supplier. In the UK, this is typically the company registration number issued by Companies House. | | | `SourceModifiedDate` | **string* | :heavy_minus_sign: | N/A | 2022-10-23T00:00:00.000Z | | `Status` | [SupplierStatus](../../models/shared/supplierstatus.md) | :heavy_check_mark: | Status of the supplier. | | -| `SupplementalData` | [*SupplierSupplementalData](../../models/shared/suppliersupplementaldata.md) | :heavy_minus_sign: | Supplemental data is additional data you can include in our standard data types.

It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. | | +| `SupplementalData` | [*SupplementalData](../../models/shared/supplementaldata.md) | :heavy_minus_sign: | Supplemental data is additional data you can include in our standard data types.

It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. | | | `SupplierName` | **string* | :heavy_minus_sign: | Name of the supplier as recorded in the accounting system, typically the company name. | | | `TaxNumber` | **string* | :heavy_minus_sign: | Supplier's company tax number. | | \ No newline at end of file diff --git a/sync-for-expenses/docs/models/shared/suppliersupplementaldata.md b/sync-for-expenses/docs/models/shared/suppliersupplementaldata.md deleted file mode 100755 index 0271547c7..000000000 --- a/sync-for-expenses/docs/models/shared/suppliersupplementaldata.md +++ /dev/null @@ -1,12 +0,0 @@ -# SupplierSupplementalData - -Supplemental data is additional data you can include in our standard data types. - -It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. - - -## Fields - -| Field | Type | Required | Description | -| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | -| `Content` | map[string]map[string]*interface{}* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/sync-for-expenses/docs/models/shared/taxratemappinginfo.md b/sync-for-expenses/docs/models/shared/taxratemappinginfo.md index 561076c8c..b853b132c 100755 --- a/sync-for-expenses/docs/models/shared/taxratemappinginfo.md +++ b/sync-for-expenses/docs/models/shared/taxratemappinginfo.md @@ -10,4 +10,4 @@ | `ID` | **string* | :heavy_minus_sign: | Unique identifier of tax rate. | 59_Bills | | `Name` | **string* | :heavy_minus_sign: | Name of the tax rate in the accounting platform. | UK Standard Rate (Bills) Bills | | `TotalTaxRate` | [*decimal.Big](https://pkg.go.dev/github.com/ericlagergren/decimal#Big) | :heavy_minus_sign: | Total (not compounded) sum of the components of a tax rate. | 20 | -| `ValidTransactionTypes` | [][TaxRateMappingInfoValidTransactionTypes](../../models/shared/taxratemappinginfovalidtransactiontypes.md) | :heavy_minus_sign: | Supported transaction types for the account. | | \ No newline at end of file +| `ValidTransactionTypes` | [][TaxRateMappingInfoValidTransactionTypes](../../models/shared/taxratemappinginfovalidtransactiontypes.md) | :heavy_minus_sign: | Supported transaction types for the account. | Payment | \ No newline at end of file diff --git a/sync-for-expenses/docs/sdks/accounts/README.md b/sync-for-expenses/docs/sdks/accounts/README.md index bed73ff0b..205cf9d80 100755 --- a/sync-for-expenses/docs/sdks/accounts/README.md +++ b/sync-for-expenses/docs/sdks/accounts/README.md @@ -39,9 +39,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -53,29 +51,30 @@ func main() { FullyQualifiedCategory: syncforexpenses.String("Asset.Current"), FullyQualifiedName: syncforexpenses.String("Cash On Hand"), ID: syncforexpenses.String("1b6266d1-1e44-46c5-8eb5-a8f98e03124e"), - IsBankAccount: syncforexpenses.Bool(false), - Metadata: &shared.AccountMetadata{ - IsDeleted: syncforexpenses.Bool(false), - }, + Metadata: &shared.AccountMetadata{}, ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), Name: syncforexpenses.String("Accounts Receivable"), NominalCode: syncforexpenses.String("610"), SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), Status: shared.AccountStatusActive.ToPointer(), + SupplementalData: &shared.SupplementalData{ + Content: map[string]map[string]interface{}{ + "Money": map[string]interface{}{ + "blue": "shred", + }, + }, + }, Type: shared.AccountTypeAsset.ToPointer(), ValidDatatypeLinks: []shared.AccountValidDataTypeLinks{ shared.AccountValidDataTypeLinks{ Links: []string{ - "Money", + "abnormally", }, - Property: syncforexpenses.String("Cambridgeshire grey technology"), }, }, }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - TimeoutInMinutes: syncforexpenses.Int(86), }) if err != nil { log.Fatal(err) @@ -129,9 +128,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() diff --git a/sync-for-expenses/docs/sdks/companies/README.md b/sync-for-expenses/docs/sdks/companies/README.md index 77f896e90..739dcd7b6 100755 --- a/sync-for-expenses/docs/sdks/companies/README.md +++ b/sync-for-expenses/docs/sdks/companies/README.md @@ -35,13 +35,11 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() - res, err := s.Companies.Create(ctx, shared.CompanyRequestBody{ + res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{ Description: syncforexpenses.String("Requested early access to the new financing scheme."), Name: "Bank of Dave", }) @@ -89,9 +87,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -141,9 +137,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -193,9 +187,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -203,7 +195,6 @@ func main() { OrderBy: syncforexpenses.String("-modifiedDate"), Page: syncforexpenses.Int(1), PageSize: syncforexpenses.Int(100), - Query: syncforexpenses.String("Northeast Metal Canada"), }) if err != nil { log.Fatal(err) @@ -248,9 +239,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() diff --git a/sync-for-expenses/docs/sdks/configuration/README.md b/sync-for-expenses/docs/sdks/configuration/README.md index c426bd399..ae8babb5f 100755 --- a/sync-for-expenses/docs/sdks/configuration/README.md +++ b/sync-for-expenses/docs/sdks/configuration/README.md @@ -30,9 +30,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -82,9 +80,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -134,9 +130,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -145,12 +139,8 @@ func main() { BankAccount: shared.BankAccount{ ID: syncforexpenses.String("32"), }, - Customer: shared.CustomerDetails{ - ID: syncforexpenses.String(""), - }, - Supplier: shared.SupplierDetails{ - ID: syncforexpenses.String(""), - }, + Customer: shared.CustomerDetails{}, + Supplier: shared.SupplierDetails{}, }, CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", }) diff --git a/sync-for-expenses/docs/sdks/connections/README.md b/sync-for-expenses/docs/sdks/connections/README.md index f7e621bc3..1ea03d481 100755 --- a/sync-for-expenses/docs/sdks/connections/README.md +++ b/sync-for-expenses/docs/sdks/connections/README.md @@ -35,9 +35,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -90,9 +88,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -143,9 +139,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -196,9 +190,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -249,9 +241,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -260,7 +250,6 @@ func main() { OrderBy: syncforexpenses.String("-modifiedDate"), Page: syncforexpenses.Int(1), PageSize: syncforexpenses.Int(100), - Query: syncforexpenses.String("Northeast Metal Canada"), }) if err != nil { log.Fatal(err) @@ -305,16 +294,12 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() res, err := s.Connections.Unlink(ctx, operations.UnlinkConnectionRequest{ - RequestBody: &operations.UnlinkConnectionUpdateConnection{ - Status: shared.DataConnectionStatusPendingAuth.ToPointer(), - }, + RequestBody: &operations.UnlinkConnectionUpdateConnection{}, CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", }) diff --git a/sync-for-expenses/docs/sdks/customers/README.md b/sync-for-expenses/docs/sdks/customers/README.md index 898b04971..e10b05e85 100755 --- a/sync-for-expenses/docs/sdks/customers/README.md +++ b/sync-for-expenses/docs/sdks/customers/README.md @@ -40,9 +40,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -50,64 +48,39 @@ func main() { Customer: &shared.Customer{ Addresses: []shared.Items{ shared.Items{ - City: syncforexpenses.String("Jenafurt"), - Country: syncforexpenses.String("Sweden"), - Line1: syncforexpenses.String("innovative blue"), - Line2: syncforexpenses.String("grey technology East"), - PostalCode: syncforexpenses.String("30778"), - Region: syncforexpenses.String("quantify Polestar mobile"), Type: shared.AccountingAddressTypeBilling, }, }, - ContactName: syncforexpenses.String("Durham after"), Contacts: []shared.Contact{ shared.Contact{ Address: &shared.Items{ - City: syncforexpenses.String("Darenberg"), - Country: syncforexpenses.String("Cote d'Ivoire"), - Line1: syncforexpenses.String("Buckinghamshire functionalities Grocery"), - Line2: syncforexpenses.String("Metal"), - PostalCode: syncforexpenses.String("61380"), - Region: syncforexpenses.String("Interactions Senior Mouse"), - Type: shared.AccountingAddressTypeUnknown, + Type: shared.AccountingAddressTypeBilling, }, - Email: syncforexpenses.String("Judd27@hotmail.com"), ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Name: syncforexpenses.String("transmit likewise"), Phone: []shared.ContactPhone{ shared.ContactPhone{ - Number: "(877) 492-8687", - Type: shared.PhoneNumberTypeFax, + Number: "01224 658 999", + Type: shared.PhoneNumberTypeMobile, }, }, - Status: shared.CustomerStatusActive, + Status: shared.CustomerStatusUnknown, }, }, - CustomerName: syncforexpenses.String("Rubber silver Indiana"), - DefaultCurrency: syncforexpenses.String("EUR"), - EmailAddress: syncforexpenses.String("Thea_Ritchie76@hotmail.com"), - ID: syncforexpenses.String(""), - Metadata: &shared.Metadata{ - IsDeleted: syncforexpenses.Bool(false), - }, + DefaultCurrency: syncforexpenses.String("GBP"), + Metadata: &shared.Metadata{}, ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Phone: syncforexpenses.String("948.595.2034"), - RegistrationNumber: syncforexpenses.String("digital"), SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Status: shared.CustomerStatusUnknown, + Status: shared.CustomerStatusArchived, SupplementalData: &shared.SupplementalData{ Content: map[string]map[string]interface{}{ - "recusandae": map[string]interface{}{ - "maiores": "Mongolia", + "grey": map[string]interface{}{ + "technology": "East", }, }, }, - TaxNumber: syncforexpenses.String("discrete"), }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - TimeoutInMinutes: syncforexpenses.Int(522311), }) if err != nil { log.Fatal(err) @@ -159,9 +132,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -217,9 +188,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -228,7 +197,6 @@ func main() { OrderBy: syncforexpenses.String("-modifiedDate"), Page: syncforexpenses.Int(1), PageSize: syncforexpenses.Int(100), - Query: syncforexpenses.String("Northeast Metal Canada"), }) if err != nil { log.Fatal(err) @@ -282,9 +250,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -292,66 +258,40 @@ func main() { Customer: &shared.Customer{ Addresses: []shared.Items{ shared.Items{ - City: syncforexpenses.String("Ann Arbor"), - Country: syncforexpenses.String("Montserrat"), - Line1: syncforexpenses.String("Reactive"), - Line2: syncforexpenses.String("Metal cheater Islands"), - PostalCode: syncforexpenses.String("43372"), - Region: syncforexpenses.String("Carolina syndicate"), - Type: shared.AccountingAddressTypeBilling, + Type: shared.AccountingAddressTypeDelivery, }, }, - ContactName: syncforexpenses.String("East"), Contacts: []shared.Contact{ shared.Contact{ Address: &shared.Items{ - City: syncforexpenses.String("Olenfurt"), - Country: syncforexpenses.String("Paraguay"), - Line1: syncforexpenses.String("Home users Sharable"), - Line2: syncforexpenses.String("Lev Wooden"), - PostalCode: syncforexpenses.String("36848"), - Region: syncforexpenses.String("brightly"), - Type: shared.AccountingAddressTypeDelivery, + Type: shared.AccountingAddressTypeUnknown, }, - Email: syncforexpenses.String("Josie49@yahoo.com"), ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Name: syncforexpenses.String("possimus navigating Diesel"), Phone: []shared.ContactPhone{ shared.ContactPhone{ Number: "+44 25691 154789", - Type: shared.PhoneNumberTypePrimary, + Type: shared.PhoneNumberTypeLandline, }, }, - Status: shared.CustomerStatusUnknown, + Status: shared.CustomerStatusArchived, }, }, - CustomerName: syncforexpenses.String("Reactive Global Northeast"), - DefaultCurrency: syncforexpenses.String("USD"), - EmailAddress: syncforexpenses.String("Abe.Bogan@hotmail.com"), - ID: syncforexpenses.String(""), - Metadata: &shared.Metadata{ - IsDeleted: syncforexpenses.Bool(false), - }, + DefaultCurrency: syncforexpenses.String("EUR"), + Metadata: &shared.Metadata{}, ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Phone: syncforexpenses.String("(883) 732-4217 x6499"), - RegistrationNumber: syncforexpenses.String("redundant ew"), SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Status: shared.CustomerStatusActive, + Status: shared.CustomerStatusArchived, SupplementalData: &shared.SupplementalData{ Content: map[string]map[string]interface{}{ - "asperiores": map[string]interface{}{ - "quibusdam": "Omnigender", + "redundant": map[string]interface{}{ + "cheater": "Islands", }, }, }, - TaxNumber: syncforexpenses.String("Volkswagen Specialist Bacon"), }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - CustomerID: "Copper port East", - ForceUpdate: syncforexpenses.Bool(false), - TimeoutInMinutes: syncforexpenses.Int(373959), + CustomerID: "withdrawal extend", }) if err != nil { log.Fatal(err) diff --git a/sync-for-expenses/docs/sdks/expenses/README.md b/sync-for-expenses/docs/sdks/expenses/README.md index 6f5f58f18..c1bdcf8e0 100755 --- a/sync-for-expenses/docs/sdks/expenses/README.md +++ b/sync-for-expenses/docs/sdks/expenses/README.md @@ -31,9 +31,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -49,7 +47,6 @@ func main() { Type: shared.ContactRefTypeSupplier.ToPointer(), }, Currency: "GBP", - CurrencyRate: types.MustNewDecimalFromString("4865.89"), ID: "4d7c6929-7770-412b-91bb-44d3bc71d111", IssueDate: "2022-10-23T00:00:00.000Z", Lines: []shared.ExpenseTransactionLine{ @@ -121,9 +118,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -137,7 +132,6 @@ func main() { Type: shared.ContactRefTypeSupplier.ToPointer(), }, Currency: syncforexpenses.String("GBP"), - CurrencyRate: types.MustNewDecimalFromString("8574.78"), IssueDate: "2022-06-28T00:00:00.000Z", Lines: []shared.ExpenseTransactionLine{ shared.ExpenseTransactionLine{ @@ -158,7 +152,7 @@ func main() { }, MerchantName: syncforexpenses.String("Amazon UK"), Notes: syncforexpenses.String("APPLE.COM/BILL - 09001077498 - Card Ending: 4590"), - Type: "New", + Type: "Van", }, CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", TransactionID: "336694d8-2dca-4cb5-a28d-3ccb83e55eee", @@ -206,9 +200,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() diff --git a/sync-for-expenses/docs/sdks/managedata/README.md b/sync-for-expenses/docs/sdks/managedata/README.md index 0e23ad5b7..729176bd3 100755 --- a/sync-for-expenses/docs/sdks/managedata/README.md +++ b/sync-for-expenses/docs/sdks/managedata/README.md @@ -32,9 +32,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -84,9 +82,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -137,9 +133,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -148,7 +142,6 @@ func main() { OrderBy: syncforexpenses.String("-modifiedDate"), Page: syncforexpenses.Int(1), PageSize: syncforexpenses.Int(100), - Query: syncforexpenses.String("Dock Elegant Buckinghamshire"), }) if err != nil { log.Fatal(err) @@ -197,9 +190,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -251,15 +242,12 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() res, err := s.ManageData.RefreshDataType(ctx, operations.RefreshDataTypeRequest{ CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", - ConnectionID: syncforexpenses.String("d6258093-be98-4f60-90e1-ca6bcd49fb9a"), DataType: shared.DataTypeInvoices, }) if err != nil { diff --git a/sync-for-expenses/docs/sdks/pushoperations/README.md b/sync-for-expenses/docs/sdks/pushoperations/README.md index 0dd1ca0a1..4a571b6f6 100755 --- a/sync-for-expenses/docs/sdks/pushoperations/README.md +++ b/sync-for-expenses/docs/sdks/pushoperations/README.md @@ -29,9 +29,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -82,9 +80,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -93,7 +89,6 @@ func main() { OrderBy: syncforexpenses.String("-modifiedDate"), Page: syncforexpenses.Int(1), PageSize: syncforexpenses.Int(100), - Query: syncforexpenses.String("Northeast Metal Canada"), }) if err != nil { log.Fatal(err) diff --git a/sync-for-expenses/docs/sdks/suppliers/README.md b/sync-for-expenses/docs/sdks/suppliers/README.md index 5a3738fe6..3447bb95f 100755 --- a/sync-for-expenses/docs/sdks/suppliers/README.md +++ b/sync-for-expenses/docs/sdks/suppliers/README.md @@ -40,9 +40,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -50,41 +48,24 @@ func main() { Supplier: &shared.Supplier{ Addresses: []shared.SupplierAccountingAddress{ shared.SupplierAccountingAddress{ - City: syncforexpenses.String("Jenafurt"), - Country: syncforexpenses.String("Sweden"), - Line1: syncforexpenses.String("innovative blue"), - Line2: syncforexpenses.String("grey technology East"), - PostalCode: syncforexpenses.String("30778"), - Region: syncforexpenses.String("quantify Polestar mobile"), Type: shared.AccountingAddressTypeBilling, }, }, - ContactName: syncforexpenses.String("Durham after"), - DefaultCurrency: syncforexpenses.String("Intelligent Fish"), - EmailAddress: syncforexpenses.String("Ricardo.Hand41@gmail.com"), - ID: syncforexpenses.String(""), - Metadata: &shared.Metadata{ - IsDeleted: syncforexpenses.Bool(false), - }, + Metadata: &shared.Metadata{}, ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), Phone: syncforexpenses.String("(877) 492-8687"), - RegistrationNumber: syncforexpenses.String("Profound"), SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), Status: shared.SupplierStatusActive, - SupplementalData: &shared.SupplierSupplementalData{ + SupplementalData: &shared.SupplementalData{ Content: map[string]map[string]interface{}{ - "pariatur": map[string]interface{}{ - "accusantium": "Minivan", + "innovative": map[string]interface{}{ + "blue": "shred", }, }, }, - SupplierName: syncforexpenses.String("Senior Mouse West"), - TaxNumber: syncforexpenses.String("Towels likewise"), }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - TimeoutInMinutes: syncforexpenses.Int(452224), }) if err != nil { log.Fatal(err) @@ -136,9 +117,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -194,9 +173,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -205,7 +182,6 @@ func main() { OrderBy: syncforexpenses.String("-modifiedDate"), Page: syncforexpenses.Int(1), PageSize: syncforexpenses.Int(100), - Query: syncforexpenses.String("Northeast Metal Canada"), }) if err != nil { log.Fatal(err) @@ -259,9 +235,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -269,43 +243,25 @@ func main() { Supplier: &shared.Supplier{ Addresses: []shared.SupplierAccountingAddress{ shared.SupplierAccountingAddress{ - City: syncforexpenses.String("Ann Arbor"), - Country: syncforexpenses.String("Montserrat"), - Line1: syncforexpenses.String("Reactive"), - Line2: syncforexpenses.String("Metal cheater Islands"), - PostalCode: syncforexpenses.String("43372"), - Region: syncforexpenses.String("Carolina syndicate"), - Type: shared.AccountingAddressTypeBilling, + Type: shared.AccountingAddressTypeDelivery, }, }, - ContactName: syncforexpenses.String("East"), - DefaultCurrency: syncforexpenses.String("Bicycle guestbook"), - EmailAddress: syncforexpenses.String("Alexys.Hayes81@yahoo.com"), - ID: syncforexpenses.String(""), - Metadata: &shared.Metadata{ - IsDeleted: syncforexpenses.Bool(false), - }, + Metadata: &shared.Metadata{}, ModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), Phone: syncforexpenses.String("(877) 492-8687"), - RegistrationNumber: syncforexpenses.String("indexing"), SourceModifiedDate: syncforexpenses.String("2022-10-23T00:00:00.000Z"), - Status: shared.SupplierStatusUnknown, - SupplementalData: &shared.SupplierSupplementalData{ + Status: shared.SupplierStatusActive, + SupplementalData: &shared.SupplementalData{ Content: map[string]map[string]interface{}{ - "consectetur": map[string]interface{}{ - "ullam": "Jaguar", + "male": map[string]interface{}{ + "Metal": "cheater", }, }, }, - SupplierName: syncforexpenses.String("visionary Buckinghamshire frictionless"), - TaxNumber: syncforexpenses.String("parse possimus"), }, - AllowSyncOnPushComplete: syncforexpenses.Bool(false), CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002", ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171", - ForceUpdate: syncforexpenses.Bool(false), - SupplierID: "7110701885", - TimeoutInMinutes: syncforexpenses.Int(427089), + SupplierID: "13d946f0-c5d5-42bc-b092-97ece17923ab", }) if err != nil { log.Fatal(err) diff --git a/sync-for-expenses/docs/sdks/sync/README.md b/sync-for-expenses/docs/sdks/sync/README.md index 6469b5743..ebbc65980 100755 --- a/sync-for-expenses/docs/sdks/sync/README.md +++ b/sync-for-expenses/docs/sdks/sync/README.md @@ -32,9 +32,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -85,9 +83,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -137,9 +133,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -189,9 +183,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -246,9 +238,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() diff --git a/sync-for-expenses/docs/sdks/transactionstatus/README.md b/sync-for-expenses/docs/sdks/transactionstatus/README.md index 71140f9a1..05e8b6f42 100755 --- a/sync-for-expenses/docs/sdks/transactionstatus/README.md +++ b/sync-for-expenses/docs/sdks/transactionstatus/README.md @@ -29,9 +29,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() @@ -83,9 +81,7 @@ import( func main() { s := syncforexpenses.New( - syncforexpenses.WithSecurity(shared.Security{ - AuthHeader: "Basic BASE_64_ENCODED(API_KEY)", - }), + syncforexpenses.WithSecurity("Basic BASE_64_ENCODED(API_KEY)"), ) ctx := context.Background() diff --git a/sync-for-expenses/expenses.go b/sync-for-expenses/expenses.go index abc502254..358907544 100755 --- a/sync-for-expenses/expenses.go +++ b/sync-for-expenses/expenses.go @@ -96,13 +96,6 @@ func (s *expenses) Create(ctx context.Context, request operations.CreateExpenseT return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreateExpenseTransactionResponse{ @@ -110,6 +103,13 @@ func (s *expenses) Create(ctx context.Context, request operations.CreateExpenseT ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -217,13 +217,6 @@ func (s *expenses) Update(ctx context.Context, request operations.UpdateExpenseT return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.UpdateExpenseTransactionResponse{ @@ -231,6 +224,13 @@ func (s *expenses) Update(ctx context.Context, request operations.UpdateExpenseT ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 202: switch { @@ -340,13 +340,6 @@ func (s *expenses) UploadAttachment(ctx context.Context, request operations.Uplo return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.UploadExpenseAttachmentResponse{ @@ -354,6 +347,13 @@ func (s *expenses) UploadAttachment(ctx context.Context, request operations.Uplo ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/files.gen b/sync-for-expenses/files.gen index be34a1408..f94f767cf 100755 --- a/sync-for-expenses/files.gen +++ b/sync-for-expenses/files.gen @@ -28,6 +28,7 @@ pkg/utils/requestbody.go pkg/utils/retries.go pkg/utils/security.go pkg/utils/utils.go +tests/helpers.go pkg/models/operations/createaccount.go pkg/models/operations/getcreatechartofaccountsmodel.go pkg/models/operations/createcompany.go @@ -77,6 +78,7 @@ pkg/models/shared/pushoperationstatus.go pkg/models/shared/datatype.go pkg/models/shared/account.go pkg/models/shared/accounttype.go +pkg/models/shared/supplementaldata.go pkg/models/shared/accountstatus.go pkg/models/shared/pushoperationchange.go pkg/models/shared/pushchangetype.go @@ -106,7 +108,6 @@ pkg/models/shared/accountmappinginfo.go pkg/models/shared/connections.go pkg/models/shared/createcustomerresponse.go pkg/models/shared/customer.go -pkg/models/shared/supplementaldata.go pkg/models/shared/customerstatus.go pkg/models/shared/metadata.go pkg/models/shared/contact.go @@ -251,6 +252,7 @@ docs/models/shared/accountmetadata.md docs/models/shared/accountvaliddatatypelinks.md docs/models/shared/account.md docs/models/shared/accounttype.md +docs/models/shared/supplementaldata.md docs/models/shared/accountstatus.md docs/models/shared/pushoperationchange.md docs/models/shared/pushchangetype.md @@ -284,7 +286,6 @@ docs/models/shared/accountmappinginfo.md docs/models/shared/connections.md docs/models/shared/createcustomerresponse.md docs/models/shared/customer.md -docs/models/shared/supplementaldata.md docs/models/shared/customerstatus.md docs/models/shared/metadata.md docs/models/shared/contactphone.md @@ -316,7 +317,6 @@ docs/models/shared/pushoperation.md docs/models/shared/pushoperations.md docs/models/shared/createsupplierresponse.md docs/models/shared/supplieraccountingaddress.md -docs/models/shared/suppliersupplementaldata.md docs/models/shared/supplier.md docs/models/shared/supplierstatus.md docs/models/shared/suppliers.md diff --git a/sync-for-expenses/gen.yaml b/sync-for-expenses/gen.yaml index e8ad2e629..28aa534ca 100644 --- a/sync-for-expenses/gen.yaml +++ b/sync-for-expenses/gen.yaml @@ -1,24 +1,25 @@ configVersion: 1.0.0 management: - docChecksum: 908430e8ef88caa5eeda9fb79d2ec363 + docChecksum: cd39427322ae650607fb0524405a4f11 docVersion: prealpha - speakeasyVersion: 1.93.3 - generationVersion: 2.146.1 + speakeasyVersion: 1.100.2 + generationVersion: 2.159.2 generation: sdkClassName: CodatSyncExpenses singleTagPerOp: false telemetryEnabled: true features: go: - constsAndDefaults: 0.1.0 - core: 2.91.1 + constsAndDefaults: 0.1.1 + core: 2.91.5 deprecations: 2.81.1 examples: 2.81.2 - globalSecurity: 2.82.1 + globalSecurity: 2.82.2 globalServerURLs: 2.82.0 nameOverrides: 2.81.1 retries: 2.82.1 go: - version: 3.1.0 + version: 3.2.0 + flattenGlobalSecurity: true maxMethodParams: 0 packageName: github.com/codatio/client-sdk-go/sync-for-expenses diff --git a/sync-for-expenses/managedata.go b/sync-for-expenses/managedata.go index f20d87cbc..e0f6141fe 100755 --- a/sync-for-expenses/managedata.go +++ b/sync-for-expenses/managedata.go @@ -89,13 +89,6 @@ func (s *manageData) Get(ctx context.Context, request operations.GetDataStatusRe return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetDataStatusResponse{ @@ -103,6 +96,13 @@ func (s *manageData) Get(ctx context.Context, request operations.GetDataStatusRe ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -201,13 +201,6 @@ func (s *manageData) GetPullOperation(ctx context.Context, request operations.Ge return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetPullOperationResponse{ @@ -215,6 +208,13 @@ func (s *manageData) GetPullOperation(ctx context.Context, request operations.Ge ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -317,13 +317,6 @@ func (s *manageData) ListPullOperations(ctx context.Context, request operations. return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListPullOperationsResponse{ @@ -331,6 +324,13 @@ func (s *manageData) ListPullOperations(ctx context.Context, request operations. ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -435,13 +435,6 @@ func (s *manageData) RefreshAllDataTypes(ctx context.Context, request operations return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.RefreshAllDataTypesResponse{ @@ -449,6 +442,13 @@ func (s *manageData) RefreshAllDataTypes(ctx context.Context, request operations ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 204: case httpRes.StatusCode == 401: @@ -542,13 +542,6 @@ func (s *manageData) RefreshDataType(ctx context.Context, request operations.Ref return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.RefreshDataTypeResponse{ @@ -556,6 +549,13 @@ func (s *manageData) RefreshDataType(ctx context.Context, request operations.Ref ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/pkg/models/shared/account.go b/sync-for-expenses/pkg/models/shared/account.go index 1652765da..5be7635d8 100755 --- a/sync-for-expenses/pkg/models/shared/account.go +++ b/sync-for-expenses/pkg/models/shared/account.go @@ -143,6 +143,10 @@ type Account struct { SourceModifiedDate *string `json:"sourceModifiedDate,omitempty"` // Status of the account Status *AccountStatus `json:"status,omitempty"` + // Supplemental data is additional data you can include in our standard data types. + // + // It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. + SupplementalData *SupplementalData `json:"supplementalData,omitempty"` // Type of account Type *AccountType `json:"type,omitempty"` // The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/sync-for-expenses-api#/schemas/ValidDataTypeLinks). @@ -251,6 +255,13 @@ func (o *Account) GetStatus() *AccountStatus { return o.Status } +func (o *Account) GetSupplementalData() *SupplementalData { + if o == nil { + return nil + } + return o.SupplementalData +} + func (o *Account) GetType() *AccountType { if o == nil { return nil diff --git a/sync-for-expenses/pkg/models/shared/supplier.go b/sync-for-expenses/pkg/models/shared/supplier.go index 60c876724..34dcc6631 100755 --- a/sync-for-expenses/pkg/models/shared/supplier.go +++ b/sync-for-expenses/pkg/models/shared/supplier.go @@ -68,20 +68,6 @@ func (o *SupplierAccountingAddress) GetType() AccountingAddressType { return o.Type } -// SupplierSupplementalData - Supplemental data is additional data you can include in our standard data types. -// -// It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. -type SupplierSupplementalData struct { - Content map[string]map[string]interface{} `json:"content,omitempty"` -} - -func (o *SupplierSupplementalData) GetContent() map[string]map[string]interface{} { - if o == nil { - return nil - } - return o.Content -} - // Supplier - > View the coverage for suppliers in the Data coverage explorer. // // ## Overview @@ -110,7 +96,7 @@ type Supplier struct { // Supplemental data is additional data you can include in our standard data types. // // It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. - SupplementalData *SupplierSupplementalData `json:"supplementalData,omitempty"` + SupplementalData *SupplementalData `json:"supplementalData,omitempty"` // Name of the supplier as recorded in the accounting system, typically the company name. SupplierName *string `json:"supplierName,omitempty"` // Supplier's company tax number. @@ -194,7 +180,7 @@ func (o *Supplier) GetStatus() SupplierStatus { return o.Status } -func (o *Supplier) GetSupplementalData() *SupplierSupplementalData { +func (o *Supplier) GetSupplementalData() *SupplementalData { if o == nil { return nil } diff --git a/sync-for-expenses/pkg/utils/utils.go b/sync-for-expenses/pkg/utils/utils.go index f630a3294..4ef632ae6 100755 --- a/sync-for-expenses/pkg/utils/utils.go +++ b/sync-for-expenses/pkg/utils/utils.go @@ -155,6 +155,14 @@ func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, p } func isNil(typ reflect.Type, val reflect.Value) bool { + // `reflect.TypeOf(nil) == nil` so calling typ.Kind() will cause a nil pointer + // dereference panic. Catch it and return early. + // https://github.com/golang/go/issues/51649 + // https://github.com/golang/go/issues/54208 + if typ == nil { + return true + } + if typ.Kind() == reflect.Ptr || typ.Kind() == reflect.Map || typ.Kind() == reflect.Slice || typ.Kind() == reflect.Interface { return val.IsNil() } diff --git a/sync-for-expenses/pushoperations.go b/sync-for-expenses/pushoperations.go index 85c5949d2..893389f79 100755 --- a/sync-for-expenses/pushoperations.go +++ b/sync-for-expenses/pushoperations.go @@ -89,13 +89,6 @@ func (s *pushOperations) Get(ctx context.Context, request operations.GetPushOper return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetPushOperationResponse{ @@ -103,6 +96,13 @@ func (s *pushOperations) Get(ctx context.Context, request operations.GetPushOper ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -205,13 +205,6 @@ func (s *pushOperations) List(ctx context.Context, request operations.ListPushOp return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListPushOperationsResponse{ @@ -219,6 +212,13 @@ func (s *pushOperations) List(ctx context.Context, request operations.ListPushOp ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/suppliers.go b/sync-for-expenses/suppliers.go index e6eb81809..8235e7b02 100755 --- a/sync-for-expenses/suppliers.go +++ b/sync-for-expenses/suppliers.go @@ -108,13 +108,6 @@ func (s *suppliers) Create(ctx context.Context, request operations.CreateSupplie return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.CreateSupplierResponse{ @@ -122,6 +115,13 @@ func (s *suppliers) Create(ctx context.Context, request operations.CreateSupplie ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -228,13 +228,6 @@ func (s *suppliers) Get(ctx context.Context, request operations.GetSupplierReque return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetSupplierResponse{ @@ -242,6 +235,13 @@ func (s *suppliers) Get(ctx context.Context, request operations.GetSupplierReque ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -350,13 +350,6 @@ func (s *suppliers) List(ctx context.Context, request operations.ListSuppliersRe return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListSuppliersResponse{ @@ -364,6 +357,13 @@ func (s *suppliers) List(ctx context.Context, request operations.ListSuppliersRe ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -483,13 +483,6 @@ func (s *suppliers) Update(ctx context.Context, request operations.UpdateSupplie return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.UpdateSupplierResponse{ @@ -497,6 +490,13 @@ func (s *suppliers) Update(ctx context.Context, request operations.UpdateSupplie ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/sync.go b/sync-for-expenses/sync.go index 55c06bad1..384c8116c 100755 --- a/sync-for-expenses/sync.go +++ b/sync-for-expenses/sync.go @@ -89,13 +89,6 @@ func (s *sync) Get(ctx context.Context, request operations.GetSyncByIDRequest, o return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetSyncByIDResponse{ @@ -103,6 +96,13 @@ func (s *sync) Get(ctx context.Context, request operations.GetSyncByIDRequest, o ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -201,13 +201,6 @@ func (s *sync) GetLastSuccessfulSync(ctx context.Context, request operations.Get return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetLastSuccessfulSyncResponse{ @@ -215,6 +208,13 @@ func (s *sync) GetLastSuccessfulSync(ctx context.Context, request operations.Get ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -313,13 +313,6 @@ func (s *sync) GetLatestSync(ctx context.Context, request operations.GetLatestSy return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetLatestSyncResponse{ @@ -327,6 +320,13 @@ func (s *sync) GetLatestSync(ctx context.Context, request operations.GetLatestSy ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -432,13 +432,6 @@ func (s *sync) InitiateSync(ctx context.Context, request operations.InitiateSync return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.InitiateSyncResponse{ @@ -446,6 +439,13 @@ func (s *sync) InitiateSync(ctx context.Context, request operations.InitiateSync ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 202: switch { @@ -544,13 +544,6 @@ func (s *sync) List(ctx context.Context, request operations.ListSyncsRequest, op return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListSyncsResponse{ @@ -558,6 +551,13 @@ func (s *sync) List(ctx context.Context, request operations.ListSyncsRequest, op ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { diff --git a/sync-for-expenses/transactionstatus.go b/sync-for-expenses/transactionstatus.go index f6c02d103..290c2eca0 100755 --- a/sync-for-expenses/transactionstatus.go +++ b/sync-for-expenses/transactionstatus.go @@ -89,13 +89,6 @@ func (s *transactionStatus) Get(ctx context.Context, request operations.GetSyncT return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.GetSyncTransactionResponse{ @@ -103,6 +96,13 @@ func (s *transactionStatus) Get(ctx context.Context, request operations.GetSyncT ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch { @@ -205,13 +205,6 @@ func (s *transactionStatus) List(ctx context.Context, request operations.ListSyn return nil, fmt.Errorf("error sending request: no response") } - 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)) - contentType := httpRes.Header.Get("Content-Type") res := &operations.ListSyncTransactionsResponse{ @@ -219,6 +212,13 @@ func (s *transactionStatus) List(ctx context.Context, request operations.ListSyn ContentType: contentType, RawResponse: httpRes, } + + 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)) switch { case httpRes.StatusCode == 200: switch {