Skip to content

Commit

Permalink
Merge pull request #422 from codatio/speakeasy-sdk-regen-1697553807
Browse files Browse the repository at this point in the history
chore: speakeasy sdk regeneration - Generate Sync for Expenses library
  • Loading branch information
dcoplowe authored Oct 17, 2023
2 parents 31d47cc + a7faaed commit 82b6c2c
Show file tree
Hide file tree
Showing 37 changed files with 523 additions and 708 deletions.
2 changes: 1 addition & 1 deletion sync-for-expenses/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@

# .gitignore
100 changes: 49 additions & 51 deletions sync-for-expenses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

```
<!-- End SDK Example Usage -->

Expand Down Expand Up @@ -158,8 +158,6 @@ func main() {

<!-- Start Dev Containers -->



<!-- End Dev Containers -->


Expand Down
12 changes: 11 additions & 1 deletion sync-for-expenses/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- [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
94 changes: 47 additions & 47 deletions sync-for-expenses/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

```
<!-- End SDK Example Usage -->
28 changes: 14 additions & 14 deletions sync-for-expenses/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ 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{
StatusCode: httpRes.StatusCode,
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 {
Expand Down Expand Up @@ -230,20 +230,20 @@ 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{
StatusCode: httpRes.StatusCode,
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 {
Expand Down
20 changes: 7 additions & 13 deletions sync-for-expenses/codatsyncexpenses.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,19 @@ 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
}
}

// 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)
}
}

Expand All @@ -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 {
Expand Down
Loading

0 comments on commit 82b6c2c

Please sign in to comment.