Skip to content

Commit

Permalink
Merge pull request #413 from codatio/speakeasy-sdk-regen-1697550595
Browse files Browse the repository at this point in the history
chore: speakeasy sdk regeneration - Generate Commerce library
  • Loading branch information
dcoplowe authored Oct 17, 2023
2 parents 20969ea + b28c5e1 commit e435833
Show file tree
Hide file tree
Showing 175 changed files with 2,224 additions and 1,171 deletions.
1 change: 1 addition & 0 deletions previous-versions/commerce/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# .gitignore
.DS_Store
63 changes: 40 additions & 23 deletions previous-versions/commerce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,38 @@ go get github.com/codatio/client-sdk-go/previous-versions/commerce

## Example Usage
<!-- Start SDK Example Usage -->


```go
package main

import(
import (
"context"
"log"
"github.com/codatio/client-sdk-go/previous-versions/commerce"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/shared"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/operations"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/shared"
"log"
)

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

ctx := context.Background()
res, err := s.CompanyInfo.Get(ctx, operations.GetCompanyInfoRequest{
CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002",
ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
})
if err != nil {
log.Fatal(err)
}

if res.CompanyInfo != nil {
// handle response
}
s := commerce.New(
commerce.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)

ctx := context.Background()
res, err := s.CompanyInfo.Get(ctx, operations.GetCompanyInfoRequest{
CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002",
ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
})
if err != nil {
log.Fatal(err)
}

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

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

Expand Down Expand Up @@ -104,4 +103,22 @@ func main() {
* [Get](docs/sdks/transactions/README.md#get) - Get transaction
* [List](docs/sdks/transactions/README.md#list) - List transactions
<!-- End SDK Available Operations -->



<!-- Start Dev Containers -->



<!-- End Dev Containers -->



<!-- Start Go Types -->

<!-- End Go Types -->

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


### Library generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)
12 changes: 11 additions & 1 deletion previous-versions/commerce/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,14 @@ Based on:
### Generated
- [go v0.24.0] previous-versions/commerce
### Releases
- [Go v0.24.0] https://github.com/codatio/client-sdk-go/releases/tag/previous-versions/commerce/v0.24.0 - previous-versions/commerce
- [Go v0.24.0] https://github.com/codatio/client-sdk-go/releases/tag/previous-versions/commerce/v0.24.0 - previous-versions/commerce

## 2023-10-17 13:49:49
### Changes
Based on:
- OpenAPI Doc 3.0.0 https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Commerce.yaml
- Speakeasy CLI 1.100.2 (2.159.2) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.25.0] previous-versions/commerce
### Releases
- [Go v0.25.0] https://github.com/codatio/client-sdk-go/releases/tag/previous-versions/commerce/v0.25.0 - previous-versions/commerce
39 changes: 20 additions & 19 deletions previous-versions/commerce/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@
```go
package main

import(
import (
"context"
"log"
"github.com/codatio/client-sdk-go/previous-versions/commerce"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/shared"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/operations"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/shared"
"log"
)

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

ctx := context.Background()
res, err := s.CompanyInfo.Get(ctx, operations.GetCompanyInfoRequest{
CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002",
ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
res, err := s.CompanyInfo.Get(ctx, operations.GetCompanyInfoRequest{
CompanyID: "8a210b68-6988-11ed-a1eb-0242ac120002",
ConnectionID: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
})
if err != nil {
log.Fatal(err)
}

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

```
<!-- End SDK Example Usage -->
29 changes: 24 additions & 5 deletions previous-versions/commerce/codatcommerce.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.

package codatcommerce
package commerce

import (
"context"
"fmt"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/models/shared"
"github.com/codatio/client-sdk-go/previous-versions/commerce/pkg/utils"
Expand Down Expand Up @@ -42,13 +43,14 @@ func Float64(f float64) *float64 { return &f }
type sdkConfiguration struct {
DefaultClient HTTPClient
SecurityClient HTTPClient
Security *shared.Security
Security func(context.Context) (interface{}, error)
ServerURL string
ServerIndex int
Language string
OpenAPIDocVersion string
SDKVersion string
GenVersion string
UserAgent string
RetryConfig *utils.RetryConfig
}

Expand Down Expand Up @@ -129,10 +131,26 @@ func WithClient(client HTTPClient) SDKOption {
}
}

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 *CodatCommerce) {
sdk.sdkConfiguration.Security = &security
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 {
return func(sdk *CodatCommerce) {
sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) {
return security(ctx)
}
}
}

Expand All @@ -148,8 +166,9 @@ func New(opts ...SDKOption) *CodatCommerce {
sdkConfiguration: sdkConfiguration{
Language: "go",
OpenAPIDocVersion: "3.0.0",
SDKVersion: "0.24.0",
GenVersion: "2.109.1",
SDKVersion: "0.25.0",
GenVersion: "2.159.2",
UserAgent: "speakeasy-sdk/go 0.25.0 2.159.2 3.0.0 github.com/codatio/client-sdk-go/previous-versions/commerce",
},
}
for _, opt := range opts {
Expand Down
30 changes: 15 additions & 15 deletions previous-versions/commerce/companyinfo.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.

package codatcommerce
package commerce

import (
"bytes"
Expand Down Expand Up @@ -51,7 +51,7 @@ func (s *companyInfo) Get(ctx context.Context, request operations.GetCompanyInfo
return nil, fmt.Errorf("error creating request: %w", err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion))
req.Header.Set("user-agent", s.sdkConfiguration.UserAgent)

client := s.sdkConfiguration.SecurityClient

Expand Down Expand Up @@ -91,30 +91,30 @@ func (s *companyInfo) Get(ctx context.Context, request operations.GetCompanyInfo
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.GetCompanyInfoResponse{
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 {
case utils.MatchContentType(contentType, `application/json`):
var out *shared.CompanyInfo
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil {
var out shared.CompanyInfo
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

res.CompanyInfo = out
res.CompanyInfo = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
Expand All @@ -127,12 +127,12 @@ func (s *companyInfo) Get(ctx context.Context, request operations.GetCompanyInfo
case httpRes.StatusCode == 429:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out *shared.ErrorMessage
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil {
var out shared.ErrorMessage
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}

res.ErrorMessage = out
res.ErrorMessage = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
Expand Down
Loading

0 comments on commit e435833

Please sign in to comment.