Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌿 Fern Regeneration -- January 12, 2024 #14

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 161 additions & 23 deletions access_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ import (
)

type AccessCodesCreateRequest struct {
DeviceId string `json:"device_id"`
Name *string `json:"name,omitempty"`
StartsAt *string `json:"starts_at,omitempty"`
EndsAt *string `json:"ends_at,omitempty"`
Code *string `json:"code,omitempty"`
Sync *bool `json:"sync,omitempty"`
AttemptForOfflineDevice *bool `json:"attempt_for_offline_device,omitempty"`
CommonCodeKey *string `json:"common_code_key,omitempty"`
PreferNativeScheduling *bool `json:"prefer_native_scheduling,omitempty"`
UseBackupAccessCodePool *bool `json:"use_backup_access_code_pool,omitempty"`
DeviceId string `json:"device_id"`
Name *string `json:"name,omitempty"`
StartsAt *string `json:"starts_at,omitempty"`
EndsAt *string `json:"ends_at,omitempty"`
Code *string `json:"code,omitempty"`
Sync *bool `json:"sync,omitempty"`
AttemptForOfflineDevice *bool `json:"attempt_for_offline_device,omitempty"`
CommonCodeKey *string `json:"common_code_key,omitempty"`
PreferNativeScheduling *bool `json:"prefer_native_scheduling,omitempty"`
UseBackupAccessCodePool *bool `json:"use_backup_access_code_pool,omitempty"`
AllowExternalModification *bool `json:"allow_external_modification,omitempty"`
IsExternalModificationAllowed *bool `json:"is_external_modification_allowed,omitempty"`
UseOfflineAccessCode *bool `json:"use_offline_access_code,omitempty"`
IsOfflineAccessCode *bool `json:"is_offline_access_code,omitempty"`
IsOneTimeUse *bool `json:"is_one_time_use,omitempty"`
MaxTimeRounding *AccessCodesCreateRequestMaxTimeRounding `json:"max_time_rounding,omitempty"`
}

type AccessCodesCreateMultipleRequest struct {
Expand All @@ -31,6 +37,12 @@ type AccessCodesCreateMultipleRequest struct {
AttemptForOfflineDevice *bool `json:"attempt_for_offline_device,omitempty"`
PreferNativeScheduling *bool `json:"prefer_native_scheduling,omitempty"`
UseBackupAccessCodePool *bool `json:"use_backup_access_code_pool,omitempty"`
AllowExternalModification *bool `json:"allow_external_modification,omitempty"`
IsExternalModificationAllowed *bool `json:"is_external_modification_allowed,omitempty"`
UseOfflineAccessCode *bool `json:"use_offline_access_code,omitempty"`
IsOfflineAccessCode *bool `json:"is_offline_access_code,omitempty"`
IsOneTimeUse *bool `json:"is_one_time_use,omitempty"`
MaxTimeRounding *AccessCodesCreateMultipleRequestMaxTimeRounding `json:"max_time_rounding,omitempty"`
}

type AccessCodesDeleteRequest struct {
Expand All @@ -39,15 +51,20 @@ type AccessCodesDeleteRequest struct {
Sync *bool `json:"sync,omitempty"`
}

type AccessCodesGenerateCodeRequest struct {
DeviceId string `json:"device_id"`
}

type AccessCodesGetRequest struct {
DeviceId *string `json:"device_id,omitempty"`
AccessCodeId *string `json:"access_code_id,omitempty"`
Code *string `json:"code,omitempty"`
}

type AccessCodesListRequest struct {
DeviceId string `json:"device_id"`
AccessCodeIds []string `json:"access_code_ids,omitempty"`
DeviceId string `json:"device_id"`
AccessCodeIds []string `json:"access_code_ids,omitempty"`
UserIdentifierKey *string `json:"user_identifier_key,omitempty"`
}

type AccessCodesPullBackupAccessCodeRequest struct {
Expand Down Expand Up @@ -76,6 +93,34 @@ func (a AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared) Ptr() *A
return &a
}

type AccessCodesCreateMultipleRequestMaxTimeRounding string

const (
AccessCodesCreateMultipleRequestMaxTimeRoundingOneHour AccessCodesCreateMultipleRequestMaxTimeRounding = "1hour"
AccessCodesCreateMultipleRequestMaxTimeRoundingOneDay AccessCodesCreateMultipleRequestMaxTimeRounding = "1day"
AccessCodesCreateMultipleRequestMaxTimeRoundingOneH AccessCodesCreateMultipleRequestMaxTimeRounding = "1h"
AccessCodesCreateMultipleRequestMaxTimeRoundingOneD AccessCodesCreateMultipleRequestMaxTimeRounding = "1d"
)

func NewAccessCodesCreateMultipleRequestMaxTimeRoundingFromString(s string) (AccessCodesCreateMultipleRequestMaxTimeRounding, error) {
switch s {
case "1hour":
return AccessCodesCreateMultipleRequestMaxTimeRoundingOneHour, nil
case "1day":
return AccessCodesCreateMultipleRequestMaxTimeRoundingOneDay, nil
case "1h":
return AccessCodesCreateMultipleRequestMaxTimeRoundingOneH, nil
case "1d":
return AccessCodesCreateMultipleRequestMaxTimeRoundingOneD, nil
}
var t AccessCodesCreateMultipleRequestMaxTimeRounding
return "", fmt.Errorf("%s is not a valid %T", s, t)
}

func (a AccessCodesCreateMultipleRequestMaxTimeRounding) Ptr() *AccessCodesCreateMultipleRequestMaxTimeRounding {
return &a
}

type AccessCodesCreateMultipleResponse struct {
AccessCodes []*AccessCode `json:"access_codes,omitempty"`
Ok bool `json:"ok"`
Expand Down Expand Up @@ -106,6 +151,34 @@ func (a *AccessCodesCreateMultipleResponse) String() string {
return fmt.Sprintf("%#v", a)
}

type AccessCodesCreateRequestMaxTimeRounding string

const (
AccessCodesCreateRequestMaxTimeRoundingOneHour AccessCodesCreateRequestMaxTimeRounding = "1hour"
AccessCodesCreateRequestMaxTimeRoundingOneDay AccessCodesCreateRequestMaxTimeRounding = "1day"
AccessCodesCreateRequestMaxTimeRoundingOneH AccessCodesCreateRequestMaxTimeRounding = "1h"
AccessCodesCreateRequestMaxTimeRoundingOneD AccessCodesCreateRequestMaxTimeRounding = "1d"
)

func NewAccessCodesCreateRequestMaxTimeRoundingFromString(s string) (AccessCodesCreateRequestMaxTimeRounding, error) {
switch s {
case "1hour":
return AccessCodesCreateRequestMaxTimeRoundingOneHour, nil
case "1day":
return AccessCodesCreateRequestMaxTimeRoundingOneDay, nil
case "1h":
return AccessCodesCreateRequestMaxTimeRoundingOneH, nil
case "1d":
return AccessCodesCreateRequestMaxTimeRoundingOneD, nil
}
var t AccessCodesCreateRequestMaxTimeRounding
return "", fmt.Errorf("%s is not a valid %T", s, t)
}

func (a AccessCodesCreateRequestMaxTimeRounding) Ptr() *AccessCodesCreateRequestMaxTimeRounding {
return &a
}

type AccessCodesCreateResponse struct {
ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"`
AccessCode *AccessCode `json:"access_code,omitempty"`
Expand Down Expand Up @@ -167,6 +240,36 @@ func (a *AccessCodesDeleteResponse) String() string {
return fmt.Sprintf("%#v", a)
}

type AccessCodesGenerateCodeResponse struct {
GeneratedCode *AccessCode `json:"generated_code,omitempty"`
Ok bool `json:"ok"`

_rawJSON json.RawMessage
}

func (a *AccessCodesGenerateCodeResponse) UnmarshalJSON(data []byte) error {
type unmarshaler AccessCodesGenerateCodeResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AccessCodesGenerateCodeResponse(value)
a._rawJSON = json.RawMessage(data)
return nil
}

func (a *AccessCodesGenerateCodeResponse) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}

type AccessCodesGetResponse struct {
AccessCode *AccessCode `json:"access_code,omitempty"`
Ok bool `json:"ok"`
Expand Down Expand Up @@ -257,6 +360,34 @@ func (a *AccessCodesPullBackupAccessCodeResponse) String() string {
return fmt.Sprintf("%#v", a)
}

type AccessCodesUpdateRequestMaxTimeRounding string

const (
AccessCodesUpdateRequestMaxTimeRoundingOneHour AccessCodesUpdateRequestMaxTimeRounding = "1hour"
AccessCodesUpdateRequestMaxTimeRoundingOneDay AccessCodesUpdateRequestMaxTimeRounding = "1day"
AccessCodesUpdateRequestMaxTimeRoundingOneH AccessCodesUpdateRequestMaxTimeRounding = "1h"
AccessCodesUpdateRequestMaxTimeRoundingOneD AccessCodesUpdateRequestMaxTimeRounding = "1d"
)

func NewAccessCodesUpdateRequestMaxTimeRoundingFromString(s string) (AccessCodesUpdateRequestMaxTimeRounding, error) {
switch s {
case "1hour":
return AccessCodesUpdateRequestMaxTimeRoundingOneHour, nil
case "1day":
return AccessCodesUpdateRequestMaxTimeRoundingOneDay, nil
case "1h":
return AccessCodesUpdateRequestMaxTimeRoundingOneH, nil
case "1d":
return AccessCodesUpdateRequestMaxTimeRoundingOneD, nil
}
var t AccessCodesUpdateRequestMaxTimeRounding
return "", fmt.Errorf("%s is not a valid %T", s, t)
}

func (a AccessCodesUpdateRequestMaxTimeRounding) Ptr() *AccessCodesUpdateRequestMaxTimeRounding {
return &a
}

type AccessCodesUpdateRequestType string

const (
Expand Down Expand Up @@ -310,15 +441,22 @@ func (a *AccessCodesUpdateResponse) String() string {
}

type AccessCodesUpdateRequest struct {
Name *string `json:"name,omitempty"`
StartsAt *string `json:"starts_at,omitempty"`
EndsAt *string `json:"ends_at,omitempty"`
Code *string `json:"code,omitempty"`
Sync *bool `json:"sync,omitempty"`
AttemptForOfflineDevice *bool `json:"attempt_for_offline_device,omitempty"`
PreferNativeScheduling *bool `json:"prefer_native_scheduling,omitempty"`
UseBackupAccessCodePool *bool `json:"use_backup_access_code_pool,omitempty"`
AccessCodeId string `json:"access_code_id"`
DeviceId *string `json:"device_id,omitempty"`
Type *AccessCodesUpdateRequestType `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
StartsAt *string `json:"starts_at,omitempty"`
EndsAt *string `json:"ends_at,omitempty"`
Code *string `json:"code,omitempty"`
Sync *bool `json:"sync,omitempty"`
AttemptForOfflineDevice *bool `json:"attempt_for_offline_device,omitempty"`
PreferNativeScheduling *bool `json:"prefer_native_scheduling,omitempty"`
UseBackupAccessCodePool *bool `json:"use_backup_access_code_pool,omitempty"`
AllowExternalModification *bool `json:"allow_external_modification,omitempty"`
IsExternalModificationAllowed *bool `json:"is_external_modification_allowed,omitempty"`
UseOfflineAccessCode *bool `json:"use_offline_access_code,omitempty"`
IsOfflineAccessCode *bool `json:"is_offline_access_code,omitempty"`
IsOneTimeUse *bool `json:"is_one_time_use,omitempty"`
MaxTimeRounding *AccessCodesUpdateRequestMaxTimeRounding `json:"max_time_rounding,omitempty"`
AccessCodeId string `json:"access_code_id"`
DeviceId *string `json:"device_id,omitempty"`
Type *AccessCodesUpdateRequestType `json:"type,omitempty"`
IsManaged *bool `json:"is_managed,omitempty"`
}
52 changes: 51 additions & 1 deletion accesscodes/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.AccessCodesDelet
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodDelete,
Method: http.MethodPost,
Headers: c.header,
Request: request,
Response: &response,
Expand All @@ -188,6 +188,56 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.AccessCodesDelet
return response.ActionAttempt, nil
}

func (c *Client) GenerateCode(ctx context.Context, request *seamapigo.AccessCodesGenerateCodeRequest) (*seamapigo.AccessCode, error) {
baseURL := "https://connect.getseam.com"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "access_codes/generate_code"

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
}
return value
case 401:
value := new(seamapigo.UnauthorizedError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *seamapigo.AccessCodesGenerateCodeResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodPost,
Headers: c.header,
Request: request,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response.GeneratedCode, nil
}

func (c *Client) Get(ctx context.Context, request *seamapigo.AccessCodesGetRequest) (*seamapigo.AccessCode, error) {
baseURL := "https://connect.getseam.com"
if c.baseURL != "" {
Expand Down
37 changes: 37 additions & 0 deletions accesscodes/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,45 @@

package accesscodes

import (
json "encoding/json"
fmt "fmt"
seamapigo "github.com/seamapi/go"
core "github.com/seamapi/go/core"
)

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

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

_rawJSON json.RawMessage
}

func (s *SimulateCreateUnmanagedAccessCodeResponse) UnmarshalJSON(data []byte) error {
type unmarshaler SimulateCreateUnmanagedAccessCodeResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SimulateCreateUnmanagedAccessCodeResponse(value)
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 {
return value
}
}
if value, err := core.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
6 changes: 3 additions & 3 deletions accesscodes/simulate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewClient(opts ...core.ClientOption) *Client {
}
}

func (c *Client) CreateUnmanagedAccessCode(ctx context.Context, request *accesscodes.SimulateCreateUnmanagedAccessCodeRequest) (*seamapigo.SimulateCreateUnmanagedAccessCodeResponse, error) {
func (c *Client) CreateUnmanagedAccessCode(ctx context.Context, request *accesscodes.SimulateCreateUnmanagedAccessCodeRequest) (*seamapigo.UnmanagedAccessCode, error) {
baseURL := "https://connect.getseam.com"
if c.baseURL != "" {
baseURL = c.baseURL
Expand Down Expand Up @@ -65,7 +65,7 @@ func (c *Client) CreateUnmanagedAccessCode(ctx context.Context, request *accessc
return apiError
}

var response *seamapigo.SimulateCreateUnmanagedAccessCodeResponse
var response *accesscodes.SimulateCreateUnmanagedAccessCodeResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
Expand All @@ -79,5 +79,5 @@ func (c *Client) CreateUnmanagedAccessCode(ctx context.Context, request *accessc
); err != nil {
return nil, err
}
return response, nil
return response.AccessCode, nil
}
Loading
Loading