Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Dec 10, 2024
1 parent e470714 commit 2604bbc
Show file tree
Hide file tree
Showing 85 changed files with 24,296 additions and 9,328 deletions.
736 changes: 635 additions & 101 deletions access_codes.go

Large diffs are not rendered by default.

603 changes: 252 additions & 351 deletions accesscodes/client/client.go

Large diffs are not rendered by default.

42 changes: 33 additions & 9 deletions accesscodes/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,39 @@ import (
json "encoding/json"
fmt "fmt"
seamapigo "github.com/seamapi/go"
core "github.com/seamapi/go/core"
internal "github.com/seamapi/go/internal"
)

type SimulateCreateUnmanagedAccessCodeRequest struct {
DeviceId string `json:"device_id" url:"device_id"`
Name string `json:"name" url:"name"`
Code string `json:"code" url:"code"`
DeviceId string `json:"device_id" url:"-"`
Name string `json:"name" url:"-"`
Code string `json:"code" url:"-"`
}

type SimulateCreateUnmanagedAccessCodeResponse struct {
AccessCode *seamapigo.UnmanagedAccessCode `json:"access_code,omitempty" url:"access_code,omitempty"`
Ok bool `json:"ok" url:"ok"`

_rawJSON json.RawMessage
extraProperties map[string]interface{}
rawJSON json.RawMessage
}

func (s *SimulateCreateUnmanagedAccessCodeResponse) GetAccessCode() *seamapigo.UnmanagedAccessCode {
if s == nil {
return nil
}
return s.AccessCode
}

func (s *SimulateCreateUnmanagedAccessCodeResponse) GetOk() bool {
if s == nil {
return false
}
return s.Ok
}

func (s *SimulateCreateUnmanagedAccessCodeResponse) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}

func (s *SimulateCreateUnmanagedAccessCodeResponse) UnmarshalJSON(data []byte) error {
Expand All @@ -29,17 +48,22 @@ func (s *SimulateCreateUnmanagedAccessCodeResponse) UnmarshalJSON(data []byte) e
return err
}
*s = SimulateCreateUnmanagedAccessCodeResponse(value)
s._rawJSON = json.RawMessage(data)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}

func (s *SimulateCreateUnmanagedAccessCodeResponse) String() string {
if len(s._rawJSON) > 0 {
if value, err := core.StringifyJSON(s._rawJSON); err == nil {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(s); err == nil {
if value, err := internal.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
Expand Down
85 changes: 35 additions & 50 deletions accesscodes/simulate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
package simulate

import (
bytes "bytes"
context "context"
json "encoding/json"
errors "errors"
seamapigo "github.com/seamapi/go"
accesscodes "github.com/seamapi/go/accesscodes"
core "github.com/seamapi/go/core"
internal "github.com/seamapi/go/internal"
option "github.com/seamapi/go/option"
io "io"
http "net/http"
)

type Client struct {
baseURL string
caller *core.Caller
caller *internal.Caller
header http.Header
}

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
&core.CallerParams{
caller: internal.NewCaller(
&internal.CallerParams{
Client: options.HTTPClient,
MaxAttempts: options.MaxAttempts,
},
Expand All @@ -41,56 +38,44 @@ func (c *Client) CreateUnmanagedAccessCode(
opts ...option.RequestOption,
) (*seamapigo.UnmanagedAccessCode, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://connect.getseam.com"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := baseURL + "/" + "access_codes/simulate/create_unmanaged_access_code"

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(seamapigo.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
baseURL := internal.ResolveBaseURL(
options.BaseURL,
c.baseURL,
"https://connect.getseam.com",
)
endpointURL := baseURL + "/access_codes/simulate/create_unmanaged_access_code"
headers := internal.MergeHeaders(
c.header.Clone(),
options.ToHeader(),
)
headers.Set("Content-Type", "application/json")
errorCodes := internal.ErrorCodes{
400: func(apiError *core.APIError) error {
return &seamapigo.BadRequestError{
APIError: apiError,
}
return value
case 401:
value := new(seamapigo.UnauthorizedError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
},
401: func(apiError *core.APIError) error {
return &seamapigo.UnauthorizedError{
APIError: apiError,
}
return value
}
return apiError
},
}

var response *accesscodes.SimulateCreateUnmanagedAccessCodeResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodPost,
MaxAttempts: options.MaxAttempts,
Headers: headers,
Client: options.HTTPClient,
Request: request,
Response: &response,
ErrorDecoder: errorDecoder,
&internal.CallParams{
URL: endpointURL,
Method: http.MethodPost,
Headers: headers,
MaxAttempts: options.MaxAttempts,
BodyProperties: options.BodyProperties,
QueryParameters: options.QueryParameters,
Client: options.HTTPClient,
Request: request,
Response: &response,
ErrorDecoder: internal.NewErrorDecoder(errorCodes),
},
); err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 2604bbc

Please sign in to comment.