Skip to content

Commit

Permalink
release: 0.1.0-alpha.3 (#8)
Browse files Browse the repository at this point in the history
* feat(api): update via SDK Studio (#7)

* release: 0.1.0-alpha.3

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
  • Loading branch information
stainless-app[bot] authored May 14, 2024
1 parent 6a19b27 commit 748fd0b
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.2"
".": "0.1.0-alpha.3"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.3 (2024-05-14)

Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/terminaldotshop/terminal-sdk-go/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)

### Features

* **api:** update via SDK Studio ([#7](https://github.com/terminaldotshop/terminal-sdk-go/issues/7)) ([ab172f4](https://github.com/terminaldotshop/terminal-sdk-go/commit/ab172f4711d98d02ea12313f7c3ec695ed4acfa6))

## 0.1.0-alpha.2 (2024-05-14)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/terminaldotshop/terminal-sdk-go/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/terminaldotshop/[email protected].2'
go get -u 'github.com/terminaldotshop/[email protected].3'
```

<!-- x-release-please-end -->
Expand Down Expand Up @@ -53,11 +53,11 @@ func main() {
option.WithBearerToken("My Bearer Token"), // defaults to os.LookupEnv("TERMINAL_BEARER_TOKEN")
option.WithEnvironmentDev(), // defaults to option.WithEnvironmentProduction()
)
productGetResponse, err := client.Product.Get(context.TODO())
productListResponse, err := client.Product.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", productGetResponse.Result)
fmt.Printf("%+v\n", productListResponse.Result)
}

```
Expand Down Expand Up @@ -146,7 +146,7 @@ client := terminal.NewClient(
option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Product.Get(context.TODO(), ...,
client.Product.List(context.TODO(), ...,
// Override the header
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
// Add an undocumented field to the request body, using sjson syntax
Expand Down Expand Up @@ -175,7 +175,7 @@ When the API returns a non-success status code, we return an error with type
To handle errors, we recommend that you use the `errors.As` pattern:

```go
_, err := client.Product.Get(context.TODO())
_, err := client.Product.List(context.TODO())
if err != nil {
var apierr *terminal.Error
if errors.As(err, &apierr) {
Expand All @@ -200,7 +200,7 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Product.Get(
client.Product.List(
ctx,
// This sets the per-retry timeout
option.WithRequestTimeout(20*time.Second),
Expand Down Expand Up @@ -235,7 +235,7 @@ client := terminal.NewClient(
)

// Override per-request:
client.Product.Get(context.TODO(), option.WithMaxRetries(5))
client.Product.List(context.TODO(), option.WithMaxRetries(5))
```

### Making custom/undocumented requests
Expand Down
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Response Types:

- <a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go">terminal</a>.<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go#ProductGetResponse">ProductGetResponse</a>
- <a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go">terminal</a>.<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go#ProductListResponse">ProductListResponse</a>

Methods:

- <code title="get /product">client.Product.<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go#ProductService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go">terminal</a>.<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go#ProductGetResponse">ProductGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /product">client.Product.<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go#ProductService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go">terminal</a>.<a href="https://pkg.go.dev/github.com/terminaldotshop/terminal-sdk-go#ProductListResponse">ProductListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# User
12 changes: 6 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestUserAgentHeader(t *testing.T) {
},
}),
)
client.Product.Get(context.Background())
client.Product.List(context.Background())
if userAgent != fmt.Sprintf("Terminal/Go %s", internal.PackageVersion) {
t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent)
}
Expand All @@ -59,7 +59,7 @@ func TestRetryAfter(t *testing.T) {
},
}),
)
res, err := client.Product.Get(context.Background())
res, err := client.Product.List(context.Background())
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
Expand All @@ -85,7 +85,7 @@ func TestRetryAfterMs(t *testing.T) {
},
}),
)
res, err := client.Product.Get(context.Background())
res, err := client.Product.List(context.Background())
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
Expand All @@ -107,7 +107,7 @@ func TestContextCancel(t *testing.T) {
)
cancelCtx, cancel := context.WithCancel(context.Background())
cancel()
res, err := client.Product.Get(cancelCtx)
res, err := client.Product.List(cancelCtx)
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
Expand All @@ -126,7 +126,7 @@ func TestContextCancelDelay(t *testing.T) {
)
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
defer cancel()
res, err := client.Product.Get(cancelCtx)
res, err := client.Product.List(cancelCtx)
if err == nil || res != nil {
t.Error("expected there to be a cancel error and for the response to be nil")
}
Expand All @@ -151,7 +151,7 @@ func TestContextDeadline(t *testing.T) {
},
}),
)
res, err := client.Product.Get(deadlineCtx)
res, err := client.Product.List(deadlineCtx)
if err == nil || res != nil {
t.Error("expected there to be a deadline error and for the response to be nil")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.1.0-alpha.2" // x-release-please-version
const PackageVersion = "0.1.0-alpha.3" // x-release-please-version
60 changes: 30 additions & 30 deletions product.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,45 @@ func NewProductService(opts ...option.RequestOption) (r *ProductService) {
return
}

func (r *ProductService) Get(ctx context.Context, opts ...option.RequestOption) (res *ProductGetResponse, err error) {
func (r *ProductService) List(ctx context.Context, opts ...option.RequestOption) (res *ProductListResponse, err error) {
opts = append(r.Options[:], opts...)
path := "product"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}

type ProductGetResponse struct {
Result []ProductGetResponseResult `json:"result,required"`
JSON productGetResponseJSON `json:"-"`
type ProductListResponse struct {
Result []ProductListResponseResult `json:"result,required"`
JSON productListResponseJSON `json:"-"`
}

// productGetResponseJSON contains the JSON metadata for the struct
// [ProductGetResponse]
type productGetResponseJSON struct {
// productListResponseJSON contains the JSON metadata for the struct
// [ProductListResponse]
type productListResponseJSON struct {
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *ProductGetResponse) UnmarshalJSON(data []byte) (err error) {
func (r *ProductListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r productGetResponseJSON) RawJSON() string {
func (r productListResponseJSON) RawJSON() string {
return r.raw
}

type ProductGetResponseResult struct {
ID string `json:"id,required"`
Description string `json:"description,required"`
Name string `json:"name,required"`
Variants []ProductGetResponseResultVariant `json:"variants,required"`
JSON productGetResponseResultJSON `json:"-"`
type ProductListResponseResult struct {
ID string `json:"id,required"`
Description string `json:"description,required"`
Name string `json:"name,required"`
Variants []ProductListResponseResultVariant `json:"variants,required"`
JSON productListResponseResultJSON `json:"-"`
}

// productGetResponseResultJSON contains the JSON metadata for the struct
// [ProductGetResponseResult]
type productGetResponseResultJSON struct {
// productListResponseResultJSON contains the JSON metadata for the struct
// [ProductListResponseResult]
type productListResponseResultJSON struct {
ID apijson.Field
Description apijson.Field
Name apijson.Field
Expand All @@ -77,35 +77,35 @@ type productGetResponseResultJSON struct {
ExtraFields map[string]apijson.Field
}

func (r *ProductGetResponseResult) UnmarshalJSON(data []byte) (err error) {
func (r *ProductListResponseResult) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r productGetResponseResultJSON) RawJSON() string {
func (r productListResponseResultJSON) RawJSON() string {
return r.raw
}

type ProductGetResponseResultVariant struct {
ID string `json:"id,required"`
Name string `json:"name,required"`
Price string `json:"price,required"`
JSON productGetResponseResultVariantJSON `json:"-"`
type ProductListResponseResultVariant struct {
ID string `json:"id,required"`
Name string `json:"name,required"`
Price string `json:"price,required"`
JSON productListResponseResultVariantJSON `json:"-"`
}

// productGetResponseResultVariantJSON contains the JSON metadata for the struct
// [ProductGetResponseResultVariant]
type productGetResponseResultVariantJSON struct {
// productListResponseResultVariantJSON contains the JSON metadata for the struct
// [ProductListResponseResultVariant]
type productListResponseResultVariantJSON struct {
ID apijson.Field
Name apijson.Field
Price apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *ProductGetResponseResultVariant) UnmarshalJSON(data []byte) (err error) {
func (r *ProductListResponseResultVariant) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r productGetResponseResultVariantJSON) RawJSON() string {
func (r productListResponseResultVariantJSON) RawJSON() string {
return r.raw
}
4 changes: 2 additions & 2 deletions product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/terminaldotshop/terminal-sdk-go/option"
)

func TestProductGet(t *testing.T) {
func TestProductList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand All @@ -25,7 +25,7 @@ func TestProductGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithBearerToken("My Bearer Token"),
)
_, err := client.Product.Get(context.TODO())
_, err := client.Product.List(context.TODO())
if err != nil {
var apierr *terminal.Error
if errors.As(err, &apierr) {
Expand Down
4 changes: 2 additions & 2 deletions usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func TestUsage(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithBearerToken("My Bearer Token"),
)
productGetResponse, err := client.Product.Get(context.TODO())
productListResponse, err := client.Product.List(context.TODO())
if err != nil {
t.Error(err)
}
t.Logf("%+v\n", productGetResponse.Result)
t.Logf("%+v\n", productListResponse.Result)
}

0 comments on commit 748fd0b

Please sign in to comment.