Skip to content

Commit

Permalink
Merge pull request #480 from codatio/speakeasy-sdk-regen-1701853445
Browse files Browse the repository at this point in the history
chore: 🐝 Update SDK - Generate Sync for Payables library
  • Loading branch information
dcoplowe authored Dec 6, 2023
2 parents dc36048 + af93930 commit b073e89
Show file tree
Hide file tree
Showing 583 changed files with 5,266 additions and 4,087 deletions.
Empty file modified sync-for-payables/.gitattributes
100755 → 100644
Empty file.
472 changes: 372 additions & 100 deletions sync-for-payables/README.md

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion sync-for-payables/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@ Based on:
### Generated
- [go v2.2.0] sync-for-payables
### Releases
- [Go v2.2.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-payables/v2.2.0 - sync-for-payables
- [Go v2.2.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-payables/v2.2.0 - sync-for-payables

## 2023-12-06 09:04:00
### Changes
Based on:
- OpenAPI Doc 3.0.0 https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Sync-Payables.yaml
- Speakeasy CLI 1.125.2 (2.210.6) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v3.0.0] sync-for-payables
### Releases
- [Go v3.0.0] https://github.com/codatio/client-sdk-go/releases/tag/sync-for-payables/v3.0.0 - sync-for-payables
49 changes: 8 additions & 41 deletions sync-for-payables/USAGE.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<!-- Start SDK Example Usage -->


<!-- Start SDK Example Usage [usage] -->
```go
package main

import (
"context"
syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables/v2"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/models/operations"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/models/shared"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/types"
syncforpayables "github.com/codatio/client-sdk-go/sync-for-payables/v3"
"github.com/codatio/client-sdk-go/sync-for-payables/v3/pkg/models/shared"
"log"
)

Expand All @@ -21,47 +17,18 @@ func main() {
)

ctx := context.Background()
res, err := s.Accounts.Create(ctx, operations.CreateAccountRequest{
Account: &shared.Account{
Currency: syncforpayables.String("USD"),
CurrentBalance: types.MustNewDecimalFromString("0"),
Description: syncforpayables.String("Invoices the business has issued but has not yet collected payment on."),
FullyQualifiedCategory: syncforpayables.String("Asset.Current"),
FullyQualifiedName: syncforpayables.String("Cash On Hand"),
ID: syncforpayables.String("1b6266d1-1e44-46c5-8eb5-a8f98e03124e"),
Metadata: &shared.Metadata{},
ModifiedDate: syncforpayables.String("2022-10-23T00:00:00.000Z"),
Name: syncforpayables.String("Accounts Receivable"),
NominalCode: syncforpayables.String("610"),
SourceModifiedDate: syncforpayables.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",
res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
Description: syncforpayables.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
})
if err != nil {
log.Fatal(err)
}

if res.CreateAccountResponse != nil {
if res.Company != nil {
// handle response
}
}

```
<!-- End SDK Example Usage -->
<!-- End SDK Example Usage [usage] -->
96 changes: 71 additions & 25 deletions sync-for-payables/accounts.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import (
"bytes"
"context"
"fmt"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/models/operations"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/models/sdkerrors"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/models/shared"
"github.com/codatio/client-sdk-go/sync-for-payables/v2/pkg/utils"
"github.com/codatio/client-sdk-go/sync-for-payables/v3/pkg/models/operations"
"github.com/codatio/client-sdk-go/sync-for-payables/v3/pkg/models/sdkerrors"
"github.com/codatio/client-sdk-go/sync-for-payables/v3/pkg/models/shared"
"github.com/codatio/client-sdk-go/sync-for-payables/v3/pkg/utils"
"io"
"net/http"
)

// accounts - Accounts
type accounts struct {
// Accounts
type Accounts struct {
sdkConfiguration sdkConfiguration
}

func newAccounts(sdkConfig sdkConfiguration) *accounts {
return &accounts{
func newAccounts(sdkConfig sdkConfiguration) *Accounts {
return &Accounts{
sdkConfiguration: sdkConfig,
}
}
Expand All @@ -35,7 +35,7 @@ func newAccounts(sdkConfig sdkConfiguration) *accounts {
// Required data may vary by integration. To see what data to post, first call [Get create account model](https://docs.codat.io/sync-for-payables-api#/operations/get-create-chartOfAccounts-model).
//
// Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account.
func (s *accounts) Create(ctx context.Context, request operations.CreateAccountRequest, opts ...operations.Option) (*operations.CreateAccountResponse, error) {
func (s *Accounts) Create(ctx context.Context, request operations.CreateAccountRequest, opts ...operations.Option) (*operations.CreateAccountResponse, error) {
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionRetries,
Expand All @@ -52,7 +52,7 @@ func (s *accounts) Create(ctx context.Context, request operations.CreateAccountR
return nil, fmt.Errorf("error generating URL: %w", err)
}

bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, true, true, "Account", "json", `request:"mediaType=application/json"`)
bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "AccountPrototype", "json", `request:"mediaType=application/json"`)
if err != nil {
return nil, fmt.Errorf("error serializing request body: %w", err)
}
Expand Down Expand Up @@ -139,20 +139,31 @@ func (s *accounts) Create(ctx context.Context, request operations.CreateAccountR
fallthrough
case httpRes.StatusCode == 401:
fallthrough
case httpRes.StatusCode == 402:
fallthrough
case httpRes.StatusCode == 403:
fallthrough
case httpRes.StatusCode == 404:
fallthrough
case httpRes.StatusCode == 429:
fallthrough
case httpRes.StatusCode == 500:
fallthrough
case httpRes.StatusCode == 503:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out shared.ErrorMessage
var out sdkerrors.ErrorMessage
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

res.ErrorMessage = &out
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
}

return res, nil
Expand All @@ -166,7 +177,7 @@ func (s *accounts) Create(ctx context.Context, request operations.CreateAccountR
// Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support getting a specific account.
//
// Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/sync-for-payables-api#/operations/refresh-company-data).
func (s *accounts) Get(ctx context.Context, request operations.GetAccountRequest, opts ...operations.Option) (*operations.GetAccountResponse, error) {
func (s *Accounts) Get(ctx context.Context, request operations.GetAccountRequest, opts ...operations.Option) (*operations.GetAccountResponse, error) {
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionRetries,
Expand Down Expand Up @@ -257,22 +268,33 @@ func (s *accounts) Get(ctx context.Context, request operations.GetAccountRequest
}
case httpRes.StatusCode == 401:
fallthrough
case httpRes.StatusCode == 402:
fallthrough
case httpRes.StatusCode == 403:
fallthrough
case httpRes.StatusCode == 404:
fallthrough
case httpRes.StatusCode == 409:
fallthrough
case httpRes.StatusCode == 429:
fallthrough
case httpRes.StatusCode == 500:
fallthrough
case httpRes.StatusCode == 503:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out shared.ErrorMessage
var out sdkerrors.ErrorMessage
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

res.ErrorMessage = &out
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
}

return res, nil
Expand All @@ -288,7 +310,7 @@ func (s *accounts) Get(ctx context.Context, request operations.GetAccountRequest
// See the *response examples* for integration-specific indicative models.
//
// Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account.
func (s *accounts) GetCreateModel(ctx context.Context, request operations.GetCreateAccountModelRequest, opts ...operations.Option) (*operations.GetCreateAccountModelResponse, error) {
func (s *Accounts) GetCreateModel(ctx context.Context, request operations.GetCreateAccountModelRequest, opts ...operations.Option) (*operations.GetCreateAccountModelResponse, error) {
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionRetries,
Expand Down Expand Up @@ -379,20 +401,31 @@ func (s *accounts) GetCreateModel(ctx context.Context, request operations.GetCre
}
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(contentType, `application/json`):
var out shared.ErrorMessage
var out sdkerrors.ErrorMessage
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

res.ErrorMessage = &out
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
}

return res, nil
Expand All @@ -404,7 +437,7 @@ func (s *accounts) GetCreateModel(ctx context.Context, request operations.GetCre
// [Accounts](https://docs.codat.io/sync-for-payables-api#/schemas/Account) are the categories a business uses to record accounting transactions.
//
// Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/sync-for-payables-api#/operations/refresh-company-data).
func (s *accounts) List(ctx context.Context, request operations.ListAccountsRequest, opts ...operations.Option) (*operations.ListAccountsResponse, error) {
func (s *Accounts) List(ctx context.Context, request operations.ListAccountsRequest, opts ...operations.Option) (*operations.ListAccountsResponse, error) {
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionRetries,
Expand Down Expand Up @@ -501,20 +534,33 @@ func (s *accounts) List(ctx context.Context, request operations.ListAccountsRequ
fallthrough
case httpRes.StatusCode == 401:
fallthrough
case httpRes.StatusCode == 402:
fallthrough
case httpRes.StatusCode == 403:
fallthrough
case httpRes.StatusCode == 404:
fallthrough
case httpRes.StatusCode == 409:
fallthrough
case httpRes.StatusCode == 429:
fallthrough
case httpRes.StatusCode == 500:
fallthrough
case httpRes.StatusCode == 503:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out shared.ErrorMessage
var out sdkerrors.ErrorMessage
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

res.ErrorMessage = &out
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
}

return res, nil
Expand Down
Loading

0 comments on commit b073e89

Please sign in to comment.