Skip to content

Commit

Permalink
Merge pull request #478 from codatio/speakeasy-sdk-regen-1701853422
Browse files Browse the repository at this point in the history
chore: 🐝 Update SDK - Generate Sync for Expenses version 1 library
  • Loading branch information
dcoplowe authored Dec 6, 2023
2 parents 952afb5 + f61c1bc commit e0ab91f
Show file tree
Hide file tree
Showing 261 changed files with 2,044 additions and 1,630 deletions.
Empty file modified previous-versions/sync-for-expenses-version-1/.gitattributes
100755 → 100644
Empty file.
345 changes: 329 additions & 16 deletions previous-versions/sync-for-expenses-version-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
Push expenses to accounting platforms.
<!-- End Codat Library Description -->

<!-- Start SDK Installation -->
<!-- Start SDK Installation [installation] -->
## SDK Installation

```bash
go get github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1
```
<!-- End SDK Installation -->
<!-- End SDK Installation [installation] -->

## Example Usage
<!-- Start SDK Example Usage -->
<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage

### Example

```go
package main

Expand Down Expand Up @@ -46,12 +50,11 @@ func main() {
}

```
<!-- End SDK Example Usage -->
<!-- End SDK Example Usage [usage] -->

<!-- Start SDK Available Operations -->
<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations


### [Companies](docs/sdks/companies/README.md)

* [CreateCompany](docs/sdks/companies/README.md#createcompany) - Create company
Expand All @@ -60,11 +63,6 @@ func main() {
* [ListCompanies](docs/sdks/companies/README.md#listcompanies) - List companies
* [UpdateCompany](docs/sdks/companies/README.md#updatecompany) - Update company

### [Configuration](docs/sdks/configuration/README.md)

* [GetCompanyConfiguration](docs/sdks/configuration/README.md#getcompanyconfiguration) - Get company configuration
* [SaveCompanyConfiguration](docs/sdks/configuration/README.md#savecompanyconfiguration) - Set company configuration

### [Connections](docs/sdks/connections/README.md)

* [CreateConnection](docs/sdks/connections/README.md#createconnection) - Create connection
Expand All @@ -74,6 +72,11 @@ func main() {
* [ListConnections](docs/sdks/connections/README.md#listconnections) - List connections
* [Unlink](docs/sdks/connections/README.md#unlink) - Unlink connection

### [Configuration](docs/sdks/configuration/README.md)

* [GetCompanyConfiguration](docs/sdks/configuration/README.md#getcompanyconfiguration) - Get company configuration
* [SaveCompanyConfiguration](docs/sdks/configuration/README.md#savecompanyconfiguration) - Set company configuration

### [Expenses](docs/sdks/expenses/README.md)

* [CreateExpenseDataset](docs/sdks/expenses/README.md#createexpensedataset) - Create expense-transactions
Expand All @@ -99,21 +102,331 @@ func main() {

* [GetSyncTransaction](docs/sdks/transactionstatus/README.md#getsynctransaction) - Get sync transaction
* [ListSyncTransactions](docs/sdks/transactionstatus/README.md#listsynctransactions) - Get sync transactions
<!-- End SDK Available Operations -->
<!-- End Available Resources and Operations [operations] -->





<!-- Start Special Types [types] -->
## Special Types


<!-- End Special Types [types] -->

<!-- Start Retries [retries] -->
## Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
```go
package main

import (
"context"
syncforexpensesversion1 "github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/shared"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/utils"
"log"
"pkg/models/operations"
)

func main() {
s := syncforexpensesversion1.New(
syncforexpensesversion1.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.Companies.CreateCompany(ctx, &shared.CompanyRequestBody{
Description: syncforexpensesversion1.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
}, operations.WithRetries(
utils.RetryConfig{
Strategy: "backoff",
Backoff: &utils.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}))
if err != nil {
log.Fatal(err)
}

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

```

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
```go
package main

import (
"context"
syncforexpensesversion1 "github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/shared"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/utils"
"log"
)

func main() {
s := syncforexpensesversion1.New(
syncforexpensesversion1.WithRetryConfig(
utils.RetryConfig{
Strategy: "backoff",
Backoff: &utils.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}),
syncforexpensesversion1.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.Companies.CreateCompany(ctx, &shared.CompanyRequestBody{
Description: syncforexpensesversion1.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
})
if err != nil {
log.Fatal(err)
}

<!-- Start Dev Containers -->
if res.Company != nil {
// handle response
}
}

```
<!-- End Retries [retries] -->

<!-- Start Error Handling [errors] -->
## Error Handling

<!-- End Dev Containers -->
Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.

| Error Object | Status Code | Content Type |
| --------------------------- | --------------------------- | --------------------------- |
| sdkerrors.ErrorMessage | 400,401,402,403,429,500,503 | application/json |
| sdkerrors.SDKError | 400-600 | */* |

### Example

<!-- Start Go Types -->
```go
package main

<!-- End Go Types -->
import (
"context"
"errors"
syncforexpensesversion1 "github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/sdkerrors"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/shared"
"log"
)

func main() {
s := syncforexpensesversion1.New(
syncforexpensesversion1.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.Companies.CreateCompany(ctx, &shared.CompanyRequestBody{
Description: syncforexpensesversion1.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
})
if err != nil {

var e *sdkerrors.ErrorMessage
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}

var e *sdkerrors.SDKError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
}
}

```
<!-- End Error Handling [errors] -->

<!-- Start Server Selection [server] -->
## Server Selection

### Select Server by Index

You can override the default server globally using the `WithServerIndex` option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

| # | Server | Variables |
| - | ------ | --------- |
| 0 | `https://api.codat.io` | None |

#### Example

```go
package main

import (
"context"
syncforexpensesversion1 "github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/shared"
"log"
)

func main() {
s := syncforexpensesversion1.New(
syncforexpensesversion1.WithServerIndex(0),
syncforexpensesversion1.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.Companies.CreateCompany(ctx, &shared.CompanyRequestBody{
Description: syncforexpensesversion1.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
})
if err != nil {
log.Fatal(err)
}

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

```


### Override Server URL Per-Client

The default server can also be overridden globally using the `WithServerURL` option when initializing the SDK client instance. For example:
```go
package main

import (
"context"
syncforexpensesversion1 "github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/shared"
"log"
)

func main() {
s := syncforexpensesversion1.New(
syncforexpensesversion1.WithServerURL("https://api.codat.io"),
syncforexpensesversion1.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.Companies.CreateCompany(ctx, &shared.CompanyRequestBody{
Description: syncforexpensesversion1.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
})
if err != nil {
log.Fatal(err)
}

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

```
<!-- End Server Selection [server] -->

<!-- Start Custom HTTP Client [http-client] -->
## Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

```go
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
```

The built-in `net/http` client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

```go
import (
"net/http"
"time"
"github.com/myorg/your-go-sdk"
)

var (
httpClient = &http.Client{Timeout: 30 * time.Second}
sdkClient = sdk.New(sdk.WithClient(httpClient))
)
```

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.
<!-- End Custom HTTP Client [http-client] -->

<!-- Start Authentication [security] -->
## Authentication

### Per-Client Security Schemes

This SDK supports the following security scheme globally:

| Name | Type | Scheme |
| ------------ | ------------ | ------------ |
| `AuthHeader` | apiKey | API key |

You can configure it using the `WithSecurity` option when initializing the SDK client instance. For example:
```go
package main

import (
"context"
syncforexpensesversion1 "github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1"
"github.com/codatio/client-sdk-go/previous-versions/sync-for-expenses-version-1/pkg/models/shared"
"log"
)

func main() {
s := syncforexpensesversion1.New(
syncforexpensesversion1.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.Companies.CreateCompany(ctx, &shared.CompanyRequestBody{
Description: syncforexpensesversion1.String("Requested early access to the new financing scheme."),
Name: "Bank of Dave",
})
if err != nil {
log.Fatal(err)
}

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

```
<!-- End Authentication [security] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

Expand Down
Loading

0 comments on commit e0ab91f

Please sign in to comment.