From b4d934f012b4f13ef1a0462eead67de77497ebe3 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Sat, 13 Jan 2024 00:10:29 +0000 Subject: [PATCH] SDK regeneration --- access_codes.go | 184 +- accesscodes/client/client.go | 52 +- accesscodes/simulate.go | 37 + accesscodes/simulate/client.go | 6 +- accesscodes/unmanaged.go | 174 +- accesscodes/unmanaged/client.go | 28 +- acs/credentials.go | 27 +- acs/entrances.go | 3 +- acs/types.go | 73 + acs/users.go | 69 +- acs/users/client.go | 50 + client/client.go | 22 +- client/options.go | 16 +- client_sessions.go | 119 +- clientsessions/client.go | 158 +- connect_webviews.go | 306 +- connected_accounts.go | 36 + connectedaccounts/client.go | 58 +- connectwebviews/client.go | 13 +- core/client_option.go | 20 +- devices.go | 58 +- devices/client/client.go | 16 +- devices/unmanaged.go | 101 +- devices/unmanaged/client.go | 60 +- events.go | 72 + health/service.go | 38 + health/service/client.go | 4 +- locks.go | 14 +- networks.go | 76 + networks/client.go | 132 + noisesensors/noise_thresholds.go | 161 +- noisesensors/noisethresholds/client.go | 12 +- noisesensors/simulate.go | 35 + noisesensors/simulate/client.go | 4 +- phones.go | 43 + phones/client/client.go | 86 + phones/simulate.go | 114 + phones/simulate/client.go | 83 + phones/types.go | 29 + thermostats.go | 186 +- thermostats/client/client.go | 162 +- thermostats/climate_setting_schedules.go | 263 +- thermostats/climatesettingschedules/client.go | 30 +- types.go | 5172 +++++++++++++---- .../user_identities.go => user_identities.go | 80 +- useridentities/client/client.go | 91 +- useridentities/enrollment_automations.go | 69 + .../enrollmentautomations/client.go | 100 + useridentities/types.go | 198 - webhooks/client.go | 16 +- workspaces.go | 65 +- workspaces/client.go | 58 +- 52 files changed, 7194 insertions(+), 1885 deletions(-) create mode 100644 networks.go create mode 100644 networks/client.go create mode 100644 phones.go create mode 100644 phones/client/client.go create mode 100644 phones/simulate.go create mode 100644 phones/simulate/client.go create mode 100644 phones/types.go rename useridentities/user_identities.go => user_identities.go (81%) diff --git a/access_codes.go b/access_codes.go index e1b3477..c973874 100644 --- a/access_codes.go +++ b/access_codes.go @@ -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 { @@ -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 { @@ -39,6 +51,10 @@ 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"` @@ -46,8 +62,9 @@ type AccessCodesGetRequest struct { } 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 { @@ -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"` @@ -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"` @@ -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"` @@ -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 ( @@ -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"` } diff --git a/accesscodes/client/client.go b/accesscodes/client/client.go index 12051e4..e6bc886 100644 --- a/accesscodes/client/client.go +++ b/accesscodes/client/client.go @@ -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, @@ -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 != "" { diff --git a/accesscodes/simulate.go b/accesscodes/simulate.go index 78dd7d9..df1fe6a 100644 --- a/accesscodes/simulate.go +++ b/accesscodes/simulate.go @@ -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) +} diff --git a/accesscodes/simulate/client.go b/accesscodes/simulate/client.go index fad3b7f..17113be 100644 --- a/accesscodes/simulate/client.go +++ b/accesscodes/simulate/client.go @@ -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 @@ -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{ @@ -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 } diff --git a/accesscodes/unmanaged.go b/accesscodes/unmanaged.go index 8815100..051b063 100644 --- a/accesscodes/unmanaged.go +++ b/accesscodes/unmanaged.go @@ -2,10 +2,19 @@ package accesscodes +import ( + json "encoding/json" + fmt "fmt" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" +) + type UnmanagedConvertToManagedRequest struct { - AccessCodeId string `json:"access_code_id"` - Force *bool `json:"force,omitempty"` - Sync *bool `json:"sync,omitempty"` + AccessCodeId string `json:"access_code_id"` + IsExternalModificationAllowed *bool `json:"is_external_modification_allowed,omitempty"` + AllowExternalModification *bool `json:"allow_external_modification,omitempty"` + Force *bool `json:"force,omitempty"` + Sync *bool `json:"sync,omitempty"` } type UnmanagedDeleteRequest struct { @@ -20,11 +29,162 @@ type UnmanagedGetRequest struct { } type UnmanagedListRequest struct { - DeviceId string `json:"device_id"` + DeviceId string `json:"device_id"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + +type UnmanagedConvertToManagedResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedConvertToManagedResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedConvertToManagedResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedConvertToManagedResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedConvertToManagedResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UnmanagedDeleteResponse struct { + ActionAttempt *seamapigo.ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedDeleteResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeleteResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedDeleteResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedDeleteResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UnmanagedGetResponse struct { + AccessCode *seamapigo.UnmanagedAccessCode `json:"access_code,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedGetResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedGetResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedGetResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedGetResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UnmanagedListResponse struct { + AccessCodes []*seamapigo.UnmanagedAccessCode `json:"access_codes,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedListResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedListResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UnmanagedUpdateResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedUpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedUpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedUpdateResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedUpdateResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) } type UnmanagedUpdateRequest struct { - AccessCodeId string `json:"access_code_id"` - IsManaged bool `json:"is_managed"` - Force *bool `json:"force,omitempty"` + AccessCodeId string `json:"access_code_id"` + IsManaged bool `json:"is_managed"` + AllowExternalModification *bool `json:"allow_external_modification,omitempty"` + IsExternalModificationAllowed *bool `json:"is_external_modification_allowed,omitempty"` + Force *bool `json:"force,omitempty"` } diff --git a/accesscodes/unmanaged/client.go b/accesscodes/unmanaged/client.go index 9c46cc1..e240e80 100644 --- a/accesscodes/unmanaged/client.go +++ b/accesscodes/unmanaged/client.go @@ -32,7 +32,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) ConvertToManaged(ctx context.Context, request *accesscodes.UnmanagedConvertToManagedRequest) (*seamapigo.UnmanagedConvertToManagedResponse, error) { +func (c *Client) ConvertToManaged(ctx context.Context, request *accesscodes.UnmanagedConvertToManagedRequest) (*accesscodes.UnmanagedConvertToManagedResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -65,7 +65,7 @@ func (c *Client) ConvertToManaged(ctx context.Context, request *accesscodes.Unma return apiError } - var response *seamapigo.UnmanagedConvertToManagedResponse + var response *accesscodes.UnmanagedConvertToManagedResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -82,7 +82,7 @@ func (c *Client) ConvertToManaged(ctx context.Context, request *accesscodes.Unma return response, nil } -func (c *Client) Delete(ctx context.Context, request *accesscodes.UnmanagedDeleteRequest) (*seamapigo.UnmanagedDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *accesscodes.UnmanagedDeleteRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -115,12 +115,12 @@ func (c *Client) Delete(ctx context.Context, request *accesscodes.UnmanagedDelet return apiError } - var response *seamapigo.UnmanagedDeleteResponse + var response *accesscodes.UnmanagedDeleteResponse if err := c.caller.Call( ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, @@ -129,10 +129,10 @@ func (c *Client) Delete(ctx context.Context, request *accesscodes.UnmanagedDelet ); err != nil { return nil, err } - return response, nil + return response.ActionAttempt, nil } -func (c *Client) Get(ctx context.Context, request *accesscodes.UnmanagedGetRequest) (*seamapigo.UnmanagedGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *accesscodes.UnmanagedGetRequest) (*seamapigo.UnmanagedAccessCode, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -165,7 +165,7 @@ func (c *Client) Get(ctx context.Context, request *accesscodes.UnmanagedGetReque return apiError } - var response *seamapigo.UnmanagedGetResponse + var response *accesscodes.UnmanagedGetResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -179,10 +179,10 @@ func (c *Client) Get(ctx context.Context, request *accesscodes.UnmanagedGetReque ); err != nil { return nil, err } - return response, nil + return response.AccessCode, nil } -func (c *Client) List(ctx context.Context, request *accesscodes.UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) { +func (c *Client) List(ctx context.Context, request *accesscodes.UnmanagedListRequest) ([]*seamapigo.UnmanagedAccessCode, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -215,7 +215,7 @@ func (c *Client) List(ctx context.Context, request *accesscodes.UnmanagedListReq return apiError } - var response *seamapigo.UnmanagedListResponse + var response *accesscodes.UnmanagedListResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -229,10 +229,10 @@ func (c *Client) List(ctx context.Context, request *accesscodes.UnmanagedListReq ); err != nil { return nil, err } - return response, nil + return response.AccessCodes, nil } -func (c *Client) Update(ctx context.Context, request *accesscodes.UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *accesscodes.UnmanagedUpdateRequest) (*accesscodes.UnmanagedUpdateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -265,7 +265,7 @@ func (c *Client) Update(ctx context.Context, request *accesscodes.UnmanagedUpdat return apiError } - var response *seamapigo.UnmanagedUpdateResponse + var response *accesscodes.UnmanagedUpdateResponse if err := c.caller.Call( ctx, &core.CallParams{ diff --git a/acs/credentials.go b/acs/credentials.go index 591275e..314e9b4 100644 --- a/acs/credentials.go +++ b/acs/credentials.go @@ -6,6 +6,7 @@ import ( json "encoding/json" fmt "fmt" core "github.com/seamapi/go/core" + time "time" ) type CredentialsAssignRequest struct { @@ -22,6 +23,8 @@ type CredentialsCreateRequest struct { ExternalType *CredentialsCreateRequestExternalType `json:"external_type,omitempty"` CardFormat *CredentialsCreateRequestCardFormat `json:"card_format,omitempty"` IsOverrideKey *bool `json:"is_override_key,omitempty"` + StartsAt *time.Time `json:"starts_at,omitempty"` + EndsAt *time.Time `json:"ends_at,omitempty"` } type CredentialsDeleteRequest struct { @@ -227,10 +230,11 @@ func (c *CredentialsGetResponse) String() string { } type CredentialsListRequest struct { - typeName string - CredentialsListRequestZero *CredentialsListRequestZero - CredentialsListRequestOne *CredentialsListRequestOne - CredentialsListRequestTwo *CredentialsListRequestTwo + typeName string + CredentialsListRequestZero *CredentialsListRequestZero + CredentialsListRequestOne *CredentialsListRequestOne + CredentialsListRequestTwo *CredentialsListRequestTwo + CredentialsListRequestUserIdentityId *CredentialsListRequestUserIdentityId } func NewCredentialsListRequestFromCredentialsListRequestZero(value *CredentialsListRequestZero) *CredentialsListRequest { @@ -245,6 +249,10 @@ func NewCredentialsListRequestFromCredentialsListRequestTwo(value *CredentialsLi return &CredentialsListRequest{typeName: "credentialsListRequestTwo", CredentialsListRequestTwo: value} } +func NewCredentialsListRequestFromCredentialsListRequestUserIdentityId(value *CredentialsListRequestUserIdentityId) *CredentialsListRequest { + return &CredentialsListRequest{typeName: "credentialsListRequestUserIdentityId", CredentialsListRequestUserIdentityId: value} +} + func (c *CredentialsListRequest) UnmarshalJSON(data []byte) error { valueCredentialsListRequestZero := new(CredentialsListRequestZero) if err := json.Unmarshal(data, &valueCredentialsListRequestZero); err == nil { @@ -264,6 +272,12 @@ func (c *CredentialsListRequest) UnmarshalJSON(data []byte) error { c.CredentialsListRequestTwo = valueCredentialsListRequestTwo return nil } + valueCredentialsListRequestUserIdentityId := new(CredentialsListRequestUserIdentityId) + if err := json.Unmarshal(data, &valueCredentialsListRequestUserIdentityId); err == nil { + c.typeName = "credentialsListRequestUserIdentityId" + c.CredentialsListRequestUserIdentityId = valueCredentialsListRequestUserIdentityId + return nil + } return fmt.Errorf("%s cannot be deserialized as a %T", data, c) } @@ -277,6 +291,8 @@ func (c CredentialsListRequest) MarshalJSON() ([]byte, error) { return json.Marshal(c.CredentialsListRequestOne) case "credentialsListRequestTwo": return json.Marshal(c.CredentialsListRequestTwo) + case "credentialsListRequestUserIdentityId": + return json.Marshal(c.CredentialsListRequestUserIdentityId) } } @@ -284,6 +300,7 @@ type CredentialsListRequestVisitor interface { VisitCredentialsListRequestZero(*CredentialsListRequestZero) error VisitCredentialsListRequestOne(*CredentialsListRequestOne) error VisitCredentialsListRequestTwo(*CredentialsListRequestTwo) error + VisitCredentialsListRequestUserIdentityId(*CredentialsListRequestUserIdentityId) error } func (c *CredentialsListRequest) Accept(visitor CredentialsListRequestVisitor) error { @@ -296,6 +313,8 @@ func (c *CredentialsListRequest) Accept(visitor CredentialsListRequestVisitor) e return visitor.VisitCredentialsListRequestOne(c.CredentialsListRequestOne) case "credentialsListRequestTwo": return visitor.VisitCredentialsListRequestTwo(c.CredentialsListRequestTwo) + case "credentialsListRequestUserIdentityId": + return visitor.VisitCredentialsListRequestUserIdentityId(c.CredentialsListRequestUserIdentityId) } } diff --git a/acs/entrances.go b/acs/entrances.go index c7c0a60..903fc61 100644 --- a/acs/entrances.go +++ b/acs/entrances.go @@ -18,7 +18,8 @@ type EntrancesGrantAccessRequest struct { } type EntrancesListRequest struct { - AcsSystemId *string `json:"acs_system_id,omitempty"` + AcsSystemId *string `json:"acs_system_id,omitempty"` + AcsCredentialId *string `json:"acs_credential_id,omitempty"` } type EntrancesGetResponse struct { diff --git a/acs/types.go b/acs/types.go index 01fce68..255eaf1 100644 --- a/acs/types.go +++ b/acs/types.go @@ -106,6 +106,8 @@ type CredentialsAssignResponseAcsCredential struct { ExternalTypeDisplayName *string `json:"external_type_display_name,omitempty"` CreatedAt time.Time `json:"created_at"` WorkspaceId string `json:"workspace_id"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` _rawJSON json.RawMessage } @@ -198,6 +200,8 @@ type CredentialsCreateResponseAcsCredential struct { ExternalTypeDisplayName *string `json:"external_type_display_name,omitempty"` CreatedAt time.Time `json:"created_at"` WorkspaceId string `json:"workspace_id"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` _rawJSON json.RawMessage } @@ -290,6 +294,8 @@ type CredentialsGetResponseAcsCredential struct { ExternalTypeDisplayName *string `json:"external_type_display_name,omitempty"` CreatedAt time.Time `json:"created_at"` WorkspaceId string `json:"workspace_id"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` _rawJSON json.RawMessage } @@ -429,6 +435,35 @@ func (c *CredentialsListRequestTwo) String() string { return fmt.Sprintf("%#v", c) } +type CredentialsListRequestUserIdentityId struct { + UserIdentityId string `json:"user_identity_id"` + + _rawJSON json.RawMessage +} + +func (c *CredentialsListRequestUserIdentityId) UnmarshalJSON(data []byte) error { + type unmarshaler CredentialsListRequestUserIdentityId + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CredentialsListRequestUserIdentityId(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *CredentialsListRequestUserIdentityId) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + type CredentialsListRequestZero struct { AcsUserId string `json:"acs_user_id"` @@ -470,6 +505,8 @@ type CredentialsListResponseAcsCredentialsItem struct { ExternalTypeDisplayName *string `json:"external_type_display_name,omitempty"` CreatedAt time.Time `json:"created_at"` WorkspaceId string `json:"workspace_id"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` _rawJSON json.RawMessage } @@ -562,6 +599,8 @@ type CredentialsUnassignResponseAcsCredential struct { ExternalTypeDisplayName *string `json:"external_type_display_name,omitempty"` CreatedAt time.Time `json:"created_at"` WorkspaceId string `json:"workspace_id"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` _rawJSON json.RawMessage } @@ -654,6 +693,8 @@ type CredentialsUpdateResponseAcsCredential struct { ExternalTypeDisplayName *string `json:"external_type_display_name,omitempty"` CreatedAt time.Time `json:"created_at"` WorkspaceId string `json:"workspace_id"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` _rawJSON json.RawMessage } @@ -797,3 +838,35 @@ func (e *EntrancesListResponseAcsEntrancesItem) String() string { } return fmt.Sprintf("%#v", e) } + +type UsersListAccessibleEntrancesResponseAcsEntrancesItem struct { + AcsEntranceId string `json:"acs_entrance_id"` + DisplayName string `json:"display_name"` + AcsSystemId string `json:"acs_system_id"` + CreatedAt time.Time `json:"created_at"` + + _rawJSON json.RawMessage +} + +func (u *UsersListAccessibleEntrancesResponseAcsEntrancesItem) UnmarshalJSON(data []byte) error { + type unmarshaler UsersListAccessibleEntrancesResponseAcsEntrancesItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UsersListAccessibleEntrancesResponseAcsEntrancesItem(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UsersListAccessibleEntrancesResponseAcsEntrancesItem) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/acs/users.go b/acs/users.go index 50fdf32..b845d14 100644 --- a/acs/users.go +++ b/acs/users.go @@ -42,6 +42,10 @@ type UsersListRequest struct { AcsSystemId *string `json:"acs_system_id,omitempty"` } +type UsersListAccessibleEntrancesRequest struct { + AcsUserId string `json:"acs_user_id"` +} + type UsersRemoveFromAccessGroupRequest struct { AcsUserId string `json:"acs_user_id"` AcsAccessGroupId string `json:"acs_access_group_id"` @@ -170,6 +174,36 @@ func (u *UsersGetResponse) String() string { return fmt.Sprintf("%#v", u) } +type UsersListAccessibleEntrancesResponse struct { + AcsEntrances []*UsersListAccessibleEntrancesResponseAcsEntrancesItem `json:"acs_entrances,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UsersListAccessibleEntrancesResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UsersListAccessibleEntrancesResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UsersListAccessibleEntrancesResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UsersListAccessibleEntrancesResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UsersListResponse struct { AcsUsers []*seamapigo.AcsUser `json:"acs_users,omitempty"` Ok bool `json:"ok"` @@ -258,6 +292,36 @@ func (u *UsersUnsuspendResponse) String() string { return fmt.Sprintf("%#v", u) } +type UsersUpdateRequestAccessSchedule struct { + StartsAt time.Time `json:"starts_at"` + EndsAt time.Time `json:"ends_at"` + + _rawJSON json.RawMessage +} + +func (u *UsersUpdateRequestAccessSchedule) UnmarshalJSON(data []byte) error { + type unmarshaler UsersUpdateRequestAccessSchedule + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UsersUpdateRequestAccessSchedule(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UsersUpdateRequestAccessSchedule) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UsersUpdateResponse struct { Ok bool `json:"ok"` @@ -292,8 +356,9 @@ type UsersUnsuspendRequest struct { } type UsersUpdateRequest struct { - AcsUserId string `json:"acs_user_id"` - FullName *string `json:"full_name,omitempty"` + AccessSchedule *UsersUpdateRequestAccessSchedule `json:"access_schedule,omitempty"` + AcsUserId string `json:"acs_user_id"` + FullName *string `json:"full_name,omitempty"` // Deprecated: use email_address. Email *string `json:"email,omitempty"` PhoneNumber *string `json:"phone_number,omitempty"` diff --git a/acs/users/client.go b/acs/users/client.go index ea9c280..1af2850 100644 --- a/acs/users/client.go +++ b/acs/users/client.go @@ -280,6 +280,56 @@ func (c *Client) List(ctx context.Context, request *acs.UsersListRequest) (*acs. return response, nil } +func (c *Client) ListAccessibleEntrances(ctx context.Context, request *acs.UsersListAccessibleEntrancesRequest) (*acs.UsersListAccessibleEntrancesResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "acs/users/list_accessible_entrances" + + 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 *acs.UsersListAccessibleEntrancesResponse + 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, nil +} + func (c *Client) RemoveFromAccessGroup(ctx context.Context, request *acs.UsersRemoveFromAccessGroupRequest) error { baseURL := "https://connect.getseam.com" if c.baseURL != "" { diff --git a/client/client.go b/client/client.go index c6d99bf..b5bfb19 100644 --- a/client/client.go +++ b/client/client.go @@ -14,7 +14,9 @@ import ( events "github.com/seamapi/go/events" healthclient "github.com/seamapi/go/health/client" locks "github.com/seamapi/go/locks" + networks "github.com/seamapi/go/networks" noisesensorsclient "github.com/seamapi/go/noisesensors/client" + phonesclient "github.com/seamapi/go/phones/client" thermostatsclient "github.com/seamapi/go/thermostats/client" useridentitiesclient "github.com/seamapi/go/useridentities/client" webhooks "github.com/seamapi/go/webhooks" @@ -27,21 +29,23 @@ type Client struct { caller *core.Caller header http.Header - UserIdentities *useridentitiesclient.Client AccessCodes *accesscodesclient.Client - Acs *acsclient.Client ActionAttempts *actionattempts.Client ClientSessions *clientsessions.Client - ConnectedAccounts *connectedaccounts.Client ConnectWebviews *connectwebviews.Client + ConnectedAccounts *connectedaccounts.Client Devices *devicesclient.Client Events *events.Client Health *healthclient.Client Locks *locks.Client - NoiseSensors *noisesensorsclient.Client + Networks *networks.Client + Phones *phonesclient.Client Thermostats *thermostatsclient.Client + UserIdentities *useridentitiesclient.Client Webhooks *webhooks.Client Workspaces *workspaces.Client + Acs *acsclient.Client + NoiseSensors *noisesensorsclient.Client } func NewClient(opts ...core.ClientOption) *Client { @@ -53,20 +57,22 @@ func NewClient(opts ...core.ClientOption) *Client { baseURL: options.BaseURL, caller: core.NewCaller(options.HTTPClient), header: options.ToHeader(), - UserIdentities: useridentitiesclient.NewClient(opts...), AccessCodes: accesscodesclient.NewClient(opts...), - Acs: acsclient.NewClient(opts...), ActionAttempts: actionattempts.NewClient(opts...), ClientSessions: clientsessions.NewClient(opts...), - ConnectedAccounts: connectedaccounts.NewClient(opts...), ConnectWebviews: connectwebviews.NewClient(opts...), + ConnectedAccounts: connectedaccounts.NewClient(opts...), Devices: devicesclient.NewClient(opts...), Events: events.NewClient(opts...), Health: healthclient.NewClient(opts...), Locks: locks.NewClient(opts...), - NoiseSensors: noisesensorsclient.NewClient(opts...), + Networks: networks.NewClient(opts...), + Phones: phonesclient.NewClient(opts...), Thermostats: thermostatsclient.NewClient(opts...), + UserIdentities: useridentitiesclient.NewClient(opts...), Webhooks: webhooks.NewClient(opts...), Workspaces: workspaces.NewClient(opts...), + Acs: acsclient.NewClient(opts...), + NoiseSensors: noisesensorsclient.NewClient(opts...), } } diff --git a/client/options.go b/client/options.go index 0a20c3d..49a702f 100644 --- a/client/options.go +++ b/client/options.go @@ -39,8 +39,22 @@ func WithApiKey(apiKey string) core.ClientOption { } // WithSeamWorkspace sets the seamWorkspace header on every request. -func WithSeamWorkspace(seamWorkspace *string) core.ClientOption { +func WithSeamWorkspace(seamWorkspace string) core.ClientOption { return func(opts *core.ClientOptions) { opts.SeamWorkspace = seamWorkspace } } + +// WithSeamClientSessionToken sets the seamClientSessionToken header on every request. +func WithSeamClientSessionToken(seamClientSessionToken string) core.ClientOption { + return func(opts *core.ClientOptions) { + opts.SeamClientSessionToken = seamClientSessionToken + } +} + +// WithClientSessionToken sets the clientSessionToken header on every request. +func WithClientSessionToken(clientSessionToken string) core.ClientOption { + return func(opts *core.ClientOptions) { + opts.ClientSessionToken = clientSessionToken + } +} diff --git a/client_sessions.go b/client_sessions.go index 276414b..4b0f42b 100644 --- a/client_sessions.go +++ b/client_sessions.go @@ -6,12 +6,15 @@ import ( json "encoding/json" fmt "fmt" core "github.com/seamapi/go/core" + time "time" ) type ClientSessionsCreateRequest struct { - UserIdentifierKey *string `json:"user_identifier_key,omitempty"` - ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` - ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` + ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` + UserIdentityIds []string `json:"user_identity_ids,omitempty"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` } type ClientSessionsDeleteRequest struct { @@ -23,12 +26,33 @@ type ClientSessionsGetRequest struct { UserIdentifierKey *string `json:"user_identifier_key,omitempty"` } +type ClientSessionsGetOrCreateRequest struct { + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` + ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` + UserIdentityIds []string `json:"user_identity_ids,omitempty"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` +} + +type ClientSessionsGrantAccessRequest struct { + ClientSessionId *string `json:"client_session_id,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` + ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` + UserIdentityIds []string `json:"user_identity_ids,omitempty"` +} + type ClientSessionsListRequest struct { ClientSessionId *string `json:"client_session_id,omitempty"` UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + ConnectWebviewId *string `json:"connect_webview_id,omitempty"` WithoutUserIdentifierKey *bool `json:"without_user_identifier_key,omitempty"` } +type ClientSessionsRevokeRequest struct { + ClientSessionId string `json:"client_session_id"` +} + type ClientSessionsCreateResponse struct { ClientSession *ClientSession `json:"client_session,omitempty"` Ok bool `json:"ok"` @@ -88,6 +112,36 @@ func (c *ClientSessionsDeleteResponse) String() string { return fmt.Sprintf("%#v", c) } +type ClientSessionsGetOrCreateResponse struct { + ClientSession *ClientSession `json:"client_session,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClientSessionsGetOrCreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClientSessionsGetOrCreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClientSessionsGetOrCreateResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClientSessionsGetOrCreateResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + type ClientSessionsGetResponse struct { ClientSession *ClientSession `json:"client_session,omitempty"` Ok bool `json:"ok"` @@ -118,6 +172,36 @@ func (c *ClientSessionsGetResponse) String() string { return fmt.Sprintf("%#v", c) } +type ClientSessionsGrantAccessResponse struct { + ClientSession *ClientSession `json:"client_session,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClientSessionsGrantAccessResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClientSessionsGrantAccessResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClientSessionsGrantAccessResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClientSessionsGrantAccessResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + type ClientSessionsListResponse struct { ClientSessions []*ClientSession `json:"client_sessions,omitempty"` Ok bool `json:"ok"` @@ -147,3 +231,32 @@ func (c *ClientSessionsListResponse) String() string { } return fmt.Sprintf("%#v", c) } + +type ClientSessionsRevokeResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClientSessionsRevokeResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClientSessionsRevokeResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClientSessionsRevokeResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClientSessionsRevokeResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} diff --git a/clientsessions/client.go b/clientsessions/client.go index 86b36d1..c0bbe95 100644 --- a/clientsessions/client.go +++ b/clientsessions/client.go @@ -81,7 +81,7 @@ func (c *Client) Create(ctx context.Context, request *seamapigo.ClientSessionsCr return response.ClientSession, nil } -func (c *Client) Delete(ctx context.Context, request *seamapigo.ClientSessionsDeleteRequest) (bool, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.ClientSessionsDeleteRequest) (*seamapigo.ClientSessionsDeleteResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -119,16 +119,16 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.ClientSessionsDe ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil } func (c *Client) Get(ctx context.Context, request *seamapigo.ClientSessionsGetRequest) (*seamapigo.ClientSession, error) { @@ -181,6 +181,106 @@ func (c *Client) Get(ctx context.Context, request *seamapigo.ClientSessionsGetRe return response.ClientSession, nil } +func (c *Client) GetOrCreate(ctx context.Context, request *seamapigo.ClientSessionsGetOrCreateRequest) (*seamapigo.ClientSession, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "client_sessions/get_or_create" + + 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.ClientSessionsGetOrCreateResponse + 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.ClientSession, nil +} + +func (c *Client) GrantAccess(ctx context.Context, request *seamapigo.ClientSessionsGrantAccessRequest) (*seamapigo.ClientSessionsGrantAccessResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "client_sessions/grant_access" + + 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.ClientSessionsGrantAccessResponse + 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, nil +} + func (c *Client) List(ctx context.Context, request *seamapigo.ClientSessionsListRequest) ([]*seamapigo.ClientSession, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { @@ -230,3 +330,53 @@ func (c *Client) List(ctx context.Context, request *seamapigo.ClientSessionsList } return response.ClientSessions, nil } + +func (c *Client) Revoke(ctx context.Context, request *seamapigo.ClientSessionsRevokeRequest) (*seamapigo.ClientSessionsRevokeResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "client_sessions/revoke" + + 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.ClientSessionsRevokeResponse + 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, nil +} diff --git a/connect_webviews.go b/connect_webviews.go index 5f66647..9a539fc 100644 --- a/connect_webviews.go +++ b/connect_webviews.go @@ -9,14 +9,14 @@ import ( ) type ConnectWebviewsCreateRequest struct { - DeviceSelectionMode *SelectionMode `json:"device_selection_mode,omitempty"` - CustomRedirectUrl *string `json:"custom_redirect_url,omitempty"` - CustomRedirectFailureUrl *string `json:"custom_redirect_failure_url,omitempty"` - AcceptedProviders []AcceptedProvider `json:"accepted_providers,omitempty"` - ProviderCategory *ProviderCategory `json:"provider_category,omitempty"` - CustomMetadata map[string]*CustomMetadataValue `json:"custom_metadata,omitempty"` - AutomaticallyManageNewDevices *bool `json:"automatically_manage_new_devices,omitempty"` - WaitForDeviceCreation *bool `json:"wait_for_device_creation,omitempty"` + DeviceSelectionMode *ConnectWebviewsCreateRequestDeviceSelectionMode `json:"device_selection_mode,omitempty"` + CustomRedirectUrl *string `json:"custom_redirect_url,omitempty"` + CustomRedirectFailureUrl *string `json:"custom_redirect_failure_url,omitempty"` + AcceptedProviders []AcceptedProvider `json:"accepted_providers,omitempty"` + ProviderCategory *ProviderCategory `json:"provider_category,omitempty"` + CustomMetadata map[string]*ConnectWebviewsCreateRequestCustomMetadataValue `json:"custom_metadata,omitempty"` + AutomaticallyManageNewDevices *bool `json:"automatically_manage_new_devices,omitempty"` + WaitForDeviceCreation *bool `json:"wait_for_device_creation,omitempty"` } type ConnectWebviewsDeleteRequest struct { @@ -27,36 +27,49 @@ type ConnectWebviewsGetRequest struct { ConnectWebviewId string `json:"connect_webview_id"` } +type ConnectWebviewsListRequest struct { + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + type AcceptedProvider string const ( - AcceptedProviderAkuvox AcceptedProvider = "akuvox" - AcceptedProviderAugust AcceptedProvider = "august" - AcceptedProviderAvigilonAlta AcceptedProvider = "avigilon_alta" - AcceptedProviderBrivo AcceptedProvider = "brivo" - AcceptedProviderButterflymx AcceptedProvider = "butterflymx" - AcceptedProviderSchlage AcceptedProvider = "schlage" - AcceptedProviderSmartthings AcceptedProvider = "smartthings" - AcceptedProviderYale AcceptedProvider = "yale" - AcceptedProviderGenie AcceptedProvider = "genie" - AcceptedProviderDoorking AcceptedProvider = "doorking" - AcceptedProviderSalto AcceptedProvider = "salto" - AcceptedProviderLockly AcceptedProvider = "lockly" - AcceptedProviderTtlock AcceptedProvider = "ttlock" - AcceptedProviderLinear AcceptedProvider = "linear" - AcceptedProviderNoiseaware AcceptedProvider = "noiseaware" - AcceptedProviderNuki AcceptedProvider = "nuki" - AcceptedProviderSeamRelayAdmin AcceptedProvider = "seam_relay_admin" - AcceptedProviderIgloo AcceptedProvider = "igloo" - AcceptedProviderKwikset AcceptedProvider = "kwikset" - AcceptedProviderMinut AcceptedProvider = "minut" - AcceptedProviderMy2N AcceptedProvider = "my_2n" - AcceptedProviderControlbyweb AcceptedProvider = "controlbyweb" - AcceptedProviderNest AcceptedProvider = "nest" - AcceptedProviderIgloohome AcceptedProvider = "igloohome" - AcceptedProviderEcobee AcceptedProvider = "ecobee" - AcceptedProviderHubitat AcceptedProvider = "hubitat" - AcceptedProviderYaleAccess AcceptedProvider = "yale_access" + AcceptedProviderAkuvox AcceptedProvider = "akuvox" + AcceptedProviderAugust AcceptedProvider = "august" + AcceptedProviderAvigilonAlta AcceptedProvider = "avigilon_alta" + AcceptedProviderBrivo AcceptedProvider = "brivo" + AcceptedProviderButterflymx AcceptedProvider = "butterflymx" + AcceptedProviderSchlage AcceptedProvider = "schlage" + AcceptedProviderSmartthings AcceptedProvider = "smartthings" + AcceptedProviderYale AcceptedProvider = "yale" + AcceptedProviderGenie AcceptedProvider = "genie" + AcceptedProviderDoorking AcceptedProvider = "doorking" + AcceptedProviderSalto AcceptedProvider = "salto" + AcceptedProviderLockly AcceptedProvider = "lockly" + AcceptedProviderTtlock AcceptedProvider = "ttlock" + AcceptedProviderLinear AcceptedProvider = "linear" + AcceptedProviderNoiseaware AcceptedProvider = "noiseaware" + AcceptedProviderNuki AcceptedProvider = "nuki" + AcceptedProviderSeamRelayAdmin AcceptedProvider = "seam_relay_admin" + AcceptedProviderIgloo AcceptedProvider = "igloo" + AcceptedProviderKwikset AcceptedProvider = "kwikset" + AcceptedProviderMinut AcceptedProvider = "minut" + AcceptedProviderMy2N AcceptedProvider = "my_2n" + AcceptedProviderControlbyweb AcceptedProvider = "controlbyweb" + AcceptedProviderNest AcceptedProvider = "nest" + AcceptedProviderIgloohome AcceptedProvider = "igloohome" + AcceptedProviderEcobee AcceptedProvider = "ecobee" + AcceptedProviderHubitat AcceptedProvider = "hubitat" + AcceptedProviderFourSuites AcceptedProvider = "four_suites" + AcceptedProviderDormakabaOracode AcceptedProvider = "dormakaba_oracode" + AcceptedProviderPti AcceptedProvider = "pti" + AcceptedProviderWyze AcceptedProvider = "wyze" + AcceptedProviderSeamPassport AcceptedProvider = "seam_passport" + AcceptedProviderVisionline AcceptedProvider = "visionline" + AcceptedProviderAssaAbloyCredentialService AcceptedProvider = "assa_abloy_credential_service" + AcceptedProviderSeamBridge AcceptedProvider = "seam_bridge" + AcceptedProviderYaleAccess AcceptedProvider = "yale_access" + AcceptedProviderHidCm AcceptedProvider = "hid_cm" ) func NewAcceptedProviderFromString(s string) (AcceptedProvider, error) { @@ -113,8 +126,26 @@ func NewAcceptedProviderFromString(s string) (AcceptedProvider, error) { return AcceptedProviderEcobee, nil case "hubitat": return AcceptedProviderHubitat, nil + case "four_suites": + return AcceptedProviderFourSuites, nil + case "dormakaba_oracode": + return AcceptedProviderDormakabaOracode, nil + case "pti": + return AcceptedProviderPti, nil + case "wyze": + return AcceptedProviderWyze, nil + case "seam_passport": + return AcceptedProviderSeamPassport, nil + case "visionline": + return AcceptedProviderVisionline, nil + case "assa_abloy_credential_service": + return AcceptedProviderAssaAbloyCredentialService, nil + case "seam_bridge": + return AcceptedProviderSeamBridge, nil case "yale_access": return AcceptedProviderYaleAccess, nil + case "hid_cm": + return AcceptedProviderHidCm, nil } var t AcceptedProvider return "", fmt.Errorf("%s is not a valid %T", s, t) @@ -124,6 +155,88 @@ func (a AcceptedProvider) Ptr() *AcceptedProvider { return &a } +type ConnectWebviewsCreateRequestCustomMetadataValue struct { + typeName string + String string + Boolean bool +} + +func NewConnectWebviewsCreateRequestCustomMetadataValueFromString(value string) *ConnectWebviewsCreateRequestCustomMetadataValue { + return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "string", String: value} +} + +func NewConnectWebviewsCreateRequestCustomMetadataValueFromBoolean(value bool) *ConnectWebviewsCreateRequestCustomMetadataValue { + return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "boolean", Boolean: value} +} + +func (c *ConnectWebviewsCreateRequestCustomMetadataValue) UnmarshalJSON(data []byte) error { + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + c.typeName = "string" + c.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + c.typeName = "boolean" + c.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, c) +} + +func (c ConnectWebviewsCreateRequestCustomMetadataValue) MarshalJSON() ([]byte, error) { + switch c.typeName { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.typeName, c) + case "string": + return json.Marshal(c.String) + case "boolean": + return json.Marshal(c.Boolean) + } +} + +type ConnectWebviewsCreateRequestCustomMetadataValueVisitor interface { + VisitString(string) error + VisitBoolean(bool) error +} + +func (c *ConnectWebviewsCreateRequestCustomMetadataValue) Accept(visitor ConnectWebviewsCreateRequestCustomMetadataValueVisitor) error { + switch c.typeName { + default: + return fmt.Errorf("invalid type %s in %T", c.typeName, c) + case "string": + return visitor.VisitString(c.String) + case "boolean": + return visitor.VisitBoolean(c.Boolean) + } +} + +type ConnectWebviewsCreateRequestDeviceSelectionMode string + +const ( + ConnectWebviewsCreateRequestDeviceSelectionModeNone ConnectWebviewsCreateRequestDeviceSelectionMode = "none" + ConnectWebviewsCreateRequestDeviceSelectionModeSingle ConnectWebviewsCreateRequestDeviceSelectionMode = "single" + ConnectWebviewsCreateRequestDeviceSelectionModeMultiple ConnectWebviewsCreateRequestDeviceSelectionMode = "multiple" +) + +func NewConnectWebviewsCreateRequestDeviceSelectionModeFromString(s string) (ConnectWebviewsCreateRequestDeviceSelectionMode, error) { + switch s { + case "none": + return ConnectWebviewsCreateRequestDeviceSelectionModeNone, nil + case "single": + return ConnectWebviewsCreateRequestDeviceSelectionModeSingle, nil + case "multiple": + return ConnectWebviewsCreateRequestDeviceSelectionModeMultiple, nil + } + var t ConnectWebviewsCreateRequestDeviceSelectionMode + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ConnectWebviewsCreateRequestDeviceSelectionMode) Ptr() *ConnectWebviewsCreateRequestDeviceSelectionMode { + return &c +} + type ConnectWebviewsCreateResponse struct { ConnectWebview *ConnectWebview `json:"connect_webview,omitempty"` Ok bool `json:"ok"` @@ -243,129 +356,6 @@ func (c *ConnectWebviewsListResponse) String() string { return fmt.Sprintf("%#v", c) } -type CustomMetadataValue struct { - typeName string - StringOptional *string - Double float64 - Boolean bool -} - -func NewCustomMetadataValueFromStringOptional(value *string) *CustomMetadataValue { - return &CustomMetadataValue{typeName: "stringOptional", StringOptional: value} -} - -func NewCustomMetadataValueFromDouble(value float64) *CustomMetadataValue { - return &CustomMetadataValue{typeName: "double", Double: value} -} - -func NewCustomMetadataValueFromBoolean(value bool) *CustomMetadataValue { - return &CustomMetadataValue{typeName: "boolean", Boolean: value} -} - -func (c *CustomMetadataValue) UnmarshalJSON(data []byte) error { - var valueStringOptional *string - if err := json.Unmarshal(data, &valueStringOptional); err == nil { - c.typeName = "stringOptional" - c.StringOptional = valueStringOptional - return nil - } - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - c.typeName = "double" - c.Double = valueDouble - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - c.typeName = "boolean" - c.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, c) -} - -func (c CustomMetadataValue) MarshalJSON() ([]byte, error) { - switch c.typeName { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.typeName, c) - case "stringOptional": - return json.Marshal(c.StringOptional) - case "double": - return json.Marshal(c.Double) - case "boolean": - return json.Marshal(c.Boolean) - } -} - -type CustomMetadataValueVisitor interface { - VisitStringOptional(*string) error - VisitDouble(float64) error - VisitBoolean(bool) error -} - -func (c *CustomMetadataValue) Accept(visitor CustomMetadataValueVisitor) error { - switch c.typeName { - default: - return fmt.Errorf("invalid type %s in %T", c.typeName, c) - case "stringOptional": - return visitor.VisitStringOptional(c.StringOptional) - case "double": - return visitor.VisitDouble(c.Double) - case "boolean": - return visitor.VisitBoolean(c.Boolean) - } -} - -type ProviderCategory string - -const ( - ProviderCategoryStable ProviderCategory = "stable" - ProviderCategoryConsumerSmartlocks ProviderCategory = "consumer_smartlocks" - ProviderCategoryInternalBeta ProviderCategory = "internal_beta" -) - -func NewProviderCategoryFromString(s string) (ProviderCategory, error) { - switch s { - case "stable": - return ProviderCategoryStable, nil - case "consumer_smartlocks": - return ProviderCategoryConsumerSmartlocks, nil - case "internal_beta": - return ProviderCategoryInternalBeta, nil - } - var t ProviderCategory - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p ProviderCategory) Ptr() *ProviderCategory { - return &p -} - -type SelectionMode string - -const ( - SelectionModeNone SelectionMode = "none" - SelectionModeSingle SelectionMode = "single" - SelectionModeMultiple SelectionMode = "multiple" -) - -func NewSelectionModeFromString(s string) (SelectionMode, error) { - switch s { - case "none": - return SelectionModeNone, nil - case "single": - return SelectionModeSingle, nil - case "multiple": - return SelectionModeMultiple, nil - } - var t SelectionMode - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (s SelectionMode) Ptr() *SelectionMode { - return &s -} - type ConnectWebviewsViewRequest struct { ConnectWebviewId string `json:"-"` AuthToken string `json:"-"` diff --git a/connected_accounts.go b/connected_accounts.go index 31ec844..ace0c1b 100644 --- a/connected_accounts.go +++ b/connected_accounts.go @@ -10,6 +10,7 @@ import ( type ConnectedAccountsDeleteRequest struct { ConnectedAccountId string `json:"connected_account_id"` + Sync *bool `json:"sync,omitempty"` } type ConnectedAccountsDeleteResponse struct { @@ -157,3 +158,38 @@ func (c *ConnectedAccountsListResponse) String() string { } return fmt.Sprintf("%#v", c) } + +type ConnectedAccountsUpdateResponse struct { + ConnectedAccount *ConnectedAccount `json:"connected_account,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ConnectedAccountsUpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ConnectedAccountsUpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ConnectedAccountsUpdateResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ConnectedAccountsUpdateResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type ConnectedAccountsUpdateRequest struct { + ConnectedAccountId string `json:"connected_account_id"` + AutomaticallyManageNewDevices *bool `json:"automatically_manage_new_devices,omitempty"` +} diff --git a/connectedaccounts/client.go b/connectedaccounts/client.go index 91f411f..9be0ed7 100644 --- a/connectedaccounts/client.go +++ b/connectedaccounts/client.go @@ -31,7 +31,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectedAccountsDeleteRequest) (bool, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectedAccountsDeleteRequest) (*seamapigo.ConnectedAccountsDeleteResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -69,16 +69,16 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectedAccount ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil } func (c *Client) Get(ctx context.Context, request *seamapigo.ConnectedAccountsGetRequest) (*seamapigo.ConnectedAccount, error) { @@ -179,3 +179,53 @@ func (c *Client) List(ctx context.Context) ([]*seamapigo.ConnectedAccount, error } return response.ConnectedAccounts, nil } + +func (c *Client) Update(ctx context.Context, request *seamapigo.ConnectedAccountsUpdateRequest) (*seamapigo.ConnectedAccount, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "connected_accounts/update" + + 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.ConnectedAccountsUpdateResponse + 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.ConnectedAccount, nil +} diff --git a/connectwebviews/client.go b/connectwebviews/client.go index 2456794..9cc88f6 100644 --- a/connectwebviews/client.go +++ b/connectwebviews/client.go @@ -83,7 +83,7 @@ func (c *Client) Create(ctx context.Context, request *seamapigo.ConnectWebviewsC return response.ConnectWebview, nil } -func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectWebviewsDeleteRequest) (bool, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectWebviewsDeleteRequest) (*seamapigo.ConnectWebviewsDeleteResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -121,16 +121,16 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectWebviewsD ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil } func (c *Client) Get(ctx context.Context, request *seamapigo.ConnectWebviewsGetRequest) (*seamapigo.ConnectWebview, error) { @@ -183,7 +183,7 @@ func (c *Client) Get(ctx context.Context, request *seamapigo.ConnectWebviewsGetR return response.ConnectWebview, nil } -func (c *Client) List(ctx context.Context) (*seamapigo.ConnectWebviewsListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.ConnectWebviewsListRequest) ([]*seamapigo.ConnectWebview, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -223,13 +223,14 @@ func (c *Client) List(ctx context.Context) (*seamapigo.ConnectWebviewsListRespon URL: endpointURL, Method: http.MethodPost, Headers: c.header, + Request: request, Response: &response, ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err } - return response, nil + return response.ConnectWebviews, nil } func (c *Client) View(ctx context.Context, request *seamapigo.ConnectWebviewsViewRequest) error { diff --git a/core/client_option.go b/core/client_option.go index db6850c..816836f 100644 --- a/core/client_option.go +++ b/core/client_option.go @@ -14,11 +14,13 @@ type ClientOption func(*ClientOptions) // This type is primarily used by the generated code and is // not meant to be used directly; use ClientOption instead. type ClientOptions struct { - BaseURL string - HTTPClient HTTPClient - HTTPHeader http.Header - ApiKey string - SeamWorkspace *string + BaseURL string + HTTPClient HTTPClient + HTTPHeader http.Header + ApiKey string + SeamWorkspace string + SeamClientSessionToken string + ClientSessionToken string } // NewClientOptions returns a new *ClientOptions value. @@ -38,9 +40,9 @@ func (c *ClientOptions) ToHeader() http.Header { if c.ApiKey != "" { header.Set("Authorization", "Bearer "+c.ApiKey) } - if c.SeamWorkspace != nil { - header.Set("Seam-Workspace", fmt.Sprintf("%v", *c.SeamWorkspace)) - } + header.Set("seam-workspace", fmt.Sprintf("%v", c.SeamWorkspace)) + header.Set("seam-client-session-token", fmt.Sprintf("%v", c.SeamClientSessionToken)) + header.Set("client-session-token", fmt.Sprintf("%v", c.ClientSessionToken)) return header } @@ -48,6 +50,6 @@ func (c *ClientOptions) cloneHeader() http.Header { headers := c.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") headers.Set("X-Fern-SDK-Name", "github.com/seamapi/go") - headers.Set("X-Fern-SDK-Version", "v0.2.2") + headers.Set("X-Fern-SDK-Version", "v0.3.0") return headers } diff --git a/devices.go b/devices.go index 06c4579..403531f 100644 --- a/devices.go +++ b/devices.go @@ -19,6 +19,7 @@ type DevicesGetRequest struct { } type DevicesListRequest struct { + // List all devices owned by this connected account ConnectedAccountId *string `json:"connected_account_id,omitempty"` ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` ConnectWebviewId *string `json:"connect_webview_id,omitempty"` @@ -28,10 +29,11 @@ type DevicesListRequest struct { DeviceIds []string `json:"device_ids,omitempty"` Limit *float64 `json:"limit,omitempty"` CreatedBefore *time.Time `json:"created_before,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` } type DevicesListDeviceProvidersRequest struct { - ProviderCategory *DevicesListDeviceProvidersRequestProviderCategory `json:"provider_category,omitempty"` + ProviderCategory *ProviderCategory `json:"provider_category,omitempty"` } type DevicesDeleteResponse struct { @@ -93,31 +95,9 @@ func (d *DevicesGetResponse) String() string { return fmt.Sprintf("%#v", d) } -type DevicesListDeviceProvidersRequestProviderCategory string - -const ( - DevicesListDeviceProvidersRequestProviderCategoryStable DevicesListDeviceProvidersRequestProviderCategory = "stable" - DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks DevicesListDeviceProvidersRequestProviderCategory = "consumer_smartlocks" -) - -func NewDevicesListDeviceProvidersRequestProviderCategoryFromString(s string) (DevicesListDeviceProvidersRequestProviderCategory, error) { - switch s { - case "stable": - return DevicesListDeviceProvidersRequestProviderCategoryStable, nil - case "consumer_smartlocks": - return DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks, nil - } - var t DevicesListDeviceProvidersRequestProviderCategory - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (d DevicesListDeviceProvidersRequestProviderCategory) Ptr() *DevicesListDeviceProvidersRequestProviderCategory { - return &d -} - type DevicesListDeviceProvidersResponse struct { - DeviceProviders []*DevicesListDeviceProvidersResponseDeviceProvidersItem `json:"device_providers,omitempty"` - Ok bool `json:"ok"` + DeviceProviders []*DeviceProvider `json:"device_providers,omitempty"` + Ok bool `json:"ok"` _rawJSON json.RawMessage } @@ -175,33 +155,6 @@ func (d *DevicesListResponse) String() string { return fmt.Sprintf("%#v", d) } -type DevicesUpdateRequestLocation struct { - _rawJSON json.RawMessage -} - -func (d *DevicesUpdateRequestLocation) UnmarshalJSON(data []byte) error { - type unmarshaler DevicesUpdateRequestLocation - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DevicesUpdateRequestLocation(value) - d._rawJSON = json.RawMessage(data) - return nil -} - -func (d *DevicesUpdateRequestLocation) String() string { - if len(d._rawJSON) > 0 { - if value, err := core.StringifyJSON(d._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - type DevicesUpdateRequestProperties struct { Name *string `json:"name,omitempty"` @@ -264,6 +217,5 @@ type DevicesUpdateRequest struct { DeviceId string `json:"device_id"` Properties *DevicesUpdateRequestProperties `json:"properties,omitempty"` Name *string `json:"name,omitempty"` - Location *DevicesUpdateRequestLocation `json:"location,omitempty"` IsManaged *bool `json:"is_managed,omitempty"` } diff --git a/devices/client/client.go b/devices/client/client.go index 273f1ea..d76b84f 100644 --- a/devices/client/client.go +++ b/devices/client/client.go @@ -35,7 +35,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) Delete(ctx context.Context, request *seamapigo.DevicesDeleteRequest) (bool, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.DevicesDeleteRequest) (*seamapigo.DevicesDeleteResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -73,16 +73,16 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.DevicesDeleteReq ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil } func (c *Client) Get(ctx context.Context, request *seamapigo.DevicesGetRequest) (*seamapigo.Device, error) { @@ -185,7 +185,7 @@ func (c *Client) List(ctx context.Context, request *seamapigo.DevicesListRequest return response.Devices, nil } -func (c *Client) ListDeviceProviders(ctx context.Context, request *seamapigo.DevicesListDeviceProvidersRequest) ([]*seamapigo.DevicesListDeviceProvidersResponseDeviceProvidersItem, error) { +func (c *Client) ListDeviceProviders(ctx context.Context, request *seamapigo.DevicesListDeviceProvidersRequest) ([]*seamapigo.DeviceProvider, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -235,7 +235,7 @@ func (c *Client) ListDeviceProviders(ctx context.Context, request *seamapigo.Dev return response.DeviceProviders, nil } -func (c *Client) Update(ctx context.Context, request *seamapigo.DevicesUpdateRequest) (bool, error) { +func (c *Client) Update(ctx context.Context, request *seamapigo.DevicesUpdateRequest) (*seamapigo.DevicesUpdateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -280,7 +280,7 @@ func (c *Client) Update(ctx context.Context, request *seamapigo.DevicesUpdateReq ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil } diff --git a/devices/unmanaged.go b/devices/unmanaged.go index 93aef3e..e2564bf 100644 --- a/devices/unmanaged.go +++ b/devices/unmanaged.go @@ -3,11 +3,20 @@ package devices import ( + json "encoding/json" + fmt "fmt" seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" time "time" ) +type UnmanagedGetRequest struct { + DeviceId *string `json:"device_id,omitempty"` + Name *string `json:"name,omitempty"` +} + type UnmanagedListRequest struct { + // List all devices owned by this connected account ConnectedAccountId *string `json:"connected_account_id,omitempty"` ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` ConnectWebviewId *string `json:"connect_webview_id,omitempty"` @@ -17,9 +26,99 @@ type UnmanagedListRequest struct { DeviceIds []string `json:"device_ids,omitempty"` Limit *float64 `json:"limit,omitempty"` CreatedBefore *time.Time `json:"created_before,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + +type UnmanagedGetResponse struct { + Device *seamapigo.UnmanagedDevice `json:"device,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedGetResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedGetResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedGetResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedGetResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UnmanagedListResponse struct { + Devices []*seamapigo.UnmanagedDevice `json:"devices,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedListResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedListResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UnmanagedUpdateResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UnmanagedUpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedUpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedUpdateResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UnmanagedUpdateResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) } type UnmanagedUpdateRequest struct { DeviceId string `json:"device_id"` - IsManaged bool `json:"is_managed"` + IsManaged string `json:"is_managed"` } diff --git a/devices/unmanaged/client.go b/devices/unmanaged/client.go index 34fc11c..007ebfe 100644 --- a/devices/unmanaged/client.go +++ b/devices/unmanaged/client.go @@ -32,7 +32,57 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) List(ctx context.Context, request *devices.UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) { +func (c *Client) Get(ctx context.Context, request *devices.UnmanagedGetRequest) (*seamapigo.UnmanagedDevice, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "devices/unmanaged/get" + + 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 *devices.UnmanagedGetResponse + 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.Device, nil +} + +func (c *Client) List(ctx context.Context, request *devices.UnmanagedListRequest) ([]*seamapigo.UnmanagedDevice, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -65,7 +115,7 @@ func (c *Client) List(ctx context.Context, request *devices.UnmanagedListRequest return apiError } - var response *seamapigo.UnmanagedListResponse + var response *devices.UnmanagedListResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -79,10 +129,10 @@ func (c *Client) List(ctx context.Context, request *devices.UnmanagedListRequest ); err != nil { return nil, err } - return response, nil + return response.Devices, nil } -func (c *Client) Update(ctx context.Context, request *devices.UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *devices.UnmanagedUpdateRequest) (*devices.UnmanagedUpdateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -115,7 +165,7 @@ func (c *Client) Update(ctx context.Context, request *devices.UnmanagedUpdateReq return apiError } - var response *seamapigo.UnmanagedUpdateResponse + var response *devices.UnmanagedUpdateResponse if err := c.caller.Call( ctx, &core.CallParams{ diff --git a/events.go b/events.go index 23b7159..e3b2241 100644 --- a/events.go +++ b/events.go @@ -128,6 +128,14 @@ const ( EventsListRequestEventTypeDeviceTampered EventsListRequestEventType = "device.tampered" EventsListRequestEventTypeDeviceLowBattery EventsListRequestEventType = "device.low_battery" EventsListRequestEventTypeDeviceBatteryStatusChanged EventsListRequestEventType = "device.battery_status_changed" + EventsListRequestEventTypeDeviceThirdPartyIntegrationDetected EventsListRequestEventType = "device.third_party_integration_detected" + EventsListRequestEventTypeDeviceThirdPartyIntegrationNoLongerDetected EventsListRequestEventType = "device.third_party_integration_no_longer_detected" + EventsListRequestEventTypeDeviceSaltoPrivacyModeActivated EventsListRequestEventType = "device.salto.privacy_mode_activated" + EventsListRequestEventTypeDeviceSaltoPrivacyModeDeactivated EventsListRequestEventType = "device.salto.privacy_mode_deactivated" + EventsListRequestEventTypeDeviceConnectionBecameFlaky EventsListRequestEventType = "device.connection_became_flaky" + EventsListRequestEventTypeDeviceConnectionStabilized EventsListRequestEventType = "device.connection_stabilized" + EventsListRequestEventTypeDeviceErrorSubscriptionRequired EventsListRequestEventType = "device.error.subscription_required" + EventsListRequestEventTypeDeviceErrorSubscriptionRequiredResolved EventsListRequestEventType = "device.error.subscription_required.resolved" EventsListRequestEventTypeAccessCodeCreated EventsListRequestEventType = "access_code.created" EventsListRequestEventTypeAccessCodeChanged EventsListRequestEventType = "access_code.changed" EventsListRequestEventTypeAccessCodeScheduledOnDevice EventsListRequestEventType = "access_code.scheduled_on_device" @@ -138,6 +146,8 @@ const ( EventsListRequestEventTypeAccessCodeDelayInSettingOnDevice EventsListRequestEventType = "access_code.delay_in_setting_on_device" EventsListRequestEventTypeAccessCodeFailedToRemoveFromDevice EventsListRequestEventType = "access_code.failed_to_remove_from_device" EventsListRequestEventTypeAccessCodeDelayInRemovingFromDevice EventsListRequestEventType = "access_code.delay_in_removing_from_device" + EventsListRequestEventTypeAccessCodeDeletedExternalToSeam EventsListRequestEventType = "access_code.deleted_external_to_seam" + EventsListRequestEventTypeAccessCodeModifiedExternalToSeam EventsListRequestEventType = "access_code.modified_external_to_seam" EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged EventsListRequestEventType = "access_code.unmanaged.converted_to_managed" EventsListRequestEventTypeAccessCodeUnmanagedFailedToConvertToManaged EventsListRequestEventType = "access_code.unmanaged.failed_to_convert_to_managed" EventsListRequestEventTypeAccessCodeUnmanagedCreated EventsListRequestEventType = "access_code.unmanaged.created" @@ -145,7 +155,9 @@ const ( EventsListRequestEventTypeLockLocked EventsListRequestEventType = "lock.locked" EventsListRequestEventTypeLockUnlocked EventsListRequestEventType = "lock.unlocked" EventsListRequestEventTypeConnectedAccountConnected EventsListRequestEventType = "connected_account.connected" + EventsListRequestEventTypeConnectedAccountSuccessfulLogin EventsListRequestEventType = "connected_account.successful_login" EventsListRequestEventTypeConnectedAccountCreated EventsListRequestEventType = "connected_account.created" + EventsListRequestEventTypeConnectedAccountDeleted EventsListRequestEventType = "connected_account.deleted" EventsListRequestEventTypeConnectedAccountDisconnected EventsListRequestEventType = "connected_account.disconnected" EventsListRequestEventTypeConnectedAccountCompletedFirstSync EventsListRequestEventType = "connected_account.completed_first_sync" EventsListRequestEventTypeNoiseSensorNoiseThresholdTriggered EventsListRequestEventType = "noise_sensor.noise_threshold_triggered" @@ -174,6 +186,22 @@ func NewEventsListRequestEventTypeFromString(s string) (EventsListRequestEventTy return EventsListRequestEventTypeDeviceLowBattery, nil case "device.battery_status_changed": return EventsListRequestEventTypeDeviceBatteryStatusChanged, nil + case "device.third_party_integration_detected": + return EventsListRequestEventTypeDeviceThirdPartyIntegrationDetected, nil + case "device.third_party_integration_no_longer_detected": + return EventsListRequestEventTypeDeviceThirdPartyIntegrationNoLongerDetected, nil + case "device.salto.privacy_mode_activated": + return EventsListRequestEventTypeDeviceSaltoPrivacyModeActivated, nil + case "device.salto.privacy_mode_deactivated": + return EventsListRequestEventTypeDeviceSaltoPrivacyModeDeactivated, nil + case "device.connection_became_flaky": + return EventsListRequestEventTypeDeviceConnectionBecameFlaky, nil + case "device.connection_stabilized": + return EventsListRequestEventTypeDeviceConnectionStabilized, nil + case "device.error.subscription_required": + return EventsListRequestEventTypeDeviceErrorSubscriptionRequired, nil + case "device.error.subscription_required.resolved": + return EventsListRequestEventTypeDeviceErrorSubscriptionRequiredResolved, nil case "access_code.created": return EventsListRequestEventTypeAccessCodeCreated, nil case "access_code.changed": @@ -194,6 +222,10 @@ func NewEventsListRequestEventTypeFromString(s string) (EventsListRequestEventTy return EventsListRequestEventTypeAccessCodeFailedToRemoveFromDevice, nil case "access_code.delay_in_removing_from_device": return EventsListRequestEventTypeAccessCodeDelayInRemovingFromDevice, nil + case "access_code.deleted_external_to_seam": + return EventsListRequestEventTypeAccessCodeDeletedExternalToSeam, nil + case "access_code.modified_external_to_seam": + return EventsListRequestEventTypeAccessCodeModifiedExternalToSeam, nil case "access_code.unmanaged.converted_to_managed": return EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged, nil case "access_code.unmanaged.failed_to_convert_to_managed": @@ -208,8 +240,12 @@ func NewEventsListRequestEventTypeFromString(s string) (EventsListRequestEventTy return EventsListRequestEventTypeLockUnlocked, nil case "connected_account.connected": return EventsListRequestEventTypeConnectedAccountConnected, nil + case "connected_account.successful_login": + return EventsListRequestEventTypeConnectedAccountSuccessfulLogin, nil case "connected_account.created": return EventsListRequestEventTypeConnectedAccountCreated, nil + case "connected_account.deleted": + return EventsListRequestEventTypeConnectedAccountDeleted, nil case "connected_account.disconnected": return EventsListRequestEventTypeConnectedAccountDisconnected, nil case "connected_account.completed_first_sync": @@ -240,6 +276,14 @@ const ( EventsListRequestEventTypesItemDeviceTampered EventsListRequestEventTypesItem = "device.tampered" EventsListRequestEventTypesItemDeviceLowBattery EventsListRequestEventTypesItem = "device.low_battery" EventsListRequestEventTypesItemDeviceBatteryStatusChanged EventsListRequestEventTypesItem = "device.battery_status_changed" + EventsListRequestEventTypesItemDeviceThirdPartyIntegrationDetected EventsListRequestEventTypesItem = "device.third_party_integration_detected" + EventsListRequestEventTypesItemDeviceThirdPartyIntegrationNoLongerDetected EventsListRequestEventTypesItem = "device.third_party_integration_no_longer_detected" + EventsListRequestEventTypesItemDeviceSaltoPrivacyModeActivated EventsListRequestEventTypesItem = "device.salto.privacy_mode_activated" + EventsListRequestEventTypesItemDeviceSaltoPrivacyModeDeactivated EventsListRequestEventTypesItem = "device.salto.privacy_mode_deactivated" + EventsListRequestEventTypesItemDeviceConnectionBecameFlaky EventsListRequestEventTypesItem = "device.connection_became_flaky" + EventsListRequestEventTypesItemDeviceConnectionStabilized EventsListRequestEventTypesItem = "device.connection_stabilized" + EventsListRequestEventTypesItemDeviceErrorSubscriptionRequired EventsListRequestEventTypesItem = "device.error.subscription_required" + EventsListRequestEventTypesItemDeviceErrorSubscriptionRequiredResolved EventsListRequestEventTypesItem = "device.error.subscription_required.resolved" EventsListRequestEventTypesItemAccessCodeCreated EventsListRequestEventTypesItem = "access_code.created" EventsListRequestEventTypesItemAccessCodeChanged EventsListRequestEventTypesItem = "access_code.changed" EventsListRequestEventTypesItemAccessCodeScheduledOnDevice EventsListRequestEventTypesItem = "access_code.scheduled_on_device" @@ -250,6 +294,8 @@ const ( EventsListRequestEventTypesItemAccessCodeDelayInSettingOnDevice EventsListRequestEventTypesItem = "access_code.delay_in_setting_on_device" EventsListRequestEventTypesItemAccessCodeFailedToRemoveFromDevice EventsListRequestEventTypesItem = "access_code.failed_to_remove_from_device" EventsListRequestEventTypesItemAccessCodeDelayInRemovingFromDevice EventsListRequestEventTypesItem = "access_code.delay_in_removing_from_device" + EventsListRequestEventTypesItemAccessCodeDeletedExternalToSeam EventsListRequestEventTypesItem = "access_code.deleted_external_to_seam" + EventsListRequestEventTypesItemAccessCodeModifiedExternalToSeam EventsListRequestEventTypesItem = "access_code.modified_external_to_seam" EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged EventsListRequestEventTypesItem = "access_code.unmanaged.converted_to_managed" EventsListRequestEventTypesItemAccessCodeUnmanagedFailedToConvertToManaged EventsListRequestEventTypesItem = "access_code.unmanaged.failed_to_convert_to_managed" EventsListRequestEventTypesItemAccessCodeUnmanagedCreated EventsListRequestEventTypesItem = "access_code.unmanaged.created" @@ -257,7 +303,9 @@ const ( EventsListRequestEventTypesItemLockLocked EventsListRequestEventTypesItem = "lock.locked" EventsListRequestEventTypesItemLockUnlocked EventsListRequestEventTypesItem = "lock.unlocked" EventsListRequestEventTypesItemConnectedAccountConnected EventsListRequestEventTypesItem = "connected_account.connected" + EventsListRequestEventTypesItemConnectedAccountSuccessfulLogin EventsListRequestEventTypesItem = "connected_account.successful_login" EventsListRequestEventTypesItemConnectedAccountCreated EventsListRequestEventTypesItem = "connected_account.created" + EventsListRequestEventTypesItemConnectedAccountDeleted EventsListRequestEventTypesItem = "connected_account.deleted" EventsListRequestEventTypesItemConnectedAccountDisconnected EventsListRequestEventTypesItem = "connected_account.disconnected" EventsListRequestEventTypesItemConnectedAccountCompletedFirstSync EventsListRequestEventTypesItem = "connected_account.completed_first_sync" EventsListRequestEventTypesItemNoiseSensorNoiseThresholdTriggered EventsListRequestEventTypesItem = "noise_sensor.noise_threshold_triggered" @@ -286,6 +334,22 @@ func NewEventsListRequestEventTypesItemFromString(s string) (EventsListRequestEv return EventsListRequestEventTypesItemDeviceLowBattery, nil case "device.battery_status_changed": return EventsListRequestEventTypesItemDeviceBatteryStatusChanged, nil + case "device.third_party_integration_detected": + return EventsListRequestEventTypesItemDeviceThirdPartyIntegrationDetected, nil + case "device.third_party_integration_no_longer_detected": + return EventsListRequestEventTypesItemDeviceThirdPartyIntegrationNoLongerDetected, nil + case "device.salto.privacy_mode_activated": + return EventsListRequestEventTypesItemDeviceSaltoPrivacyModeActivated, nil + case "device.salto.privacy_mode_deactivated": + return EventsListRequestEventTypesItemDeviceSaltoPrivacyModeDeactivated, nil + case "device.connection_became_flaky": + return EventsListRequestEventTypesItemDeviceConnectionBecameFlaky, nil + case "device.connection_stabilized": + return EventsListRequestEventTypesItemDeviceConnectionStabilized, nil + case "device.error.subscription_required": + return EventsListRequestEventTypesItemDeviceErrorSubscriptionRequired, nil + case "device.error.subscription_required.resolved": + return EventsListRequestEventTypesItemDeviceErrorSubscriptionRequiredResolved, nil case "access_code.created": return EventsListRequestEventTypesItemAccessCodeCreated, nil case "access_code.changed": @@ -306,6 +370,10 @@ func NewEventsListRequestEventTypesItemFromString(s string) (EventsListRequestEv return EventsListRequestEventTypesItemAccessCodeFailedToRemoveFromDevice, nil case "access_code.delay_in_removing_from_device": return EventsListRequestEventTypesItemAccessCodeDelayInRemovingFromDevice, nil + case "access_code.deleted_external_to_seam": + return EventsListRequestEventTypesItemAccessCodeDeletedExternalToSeam, nil + case "access_code.modified_external_to_seam": + return EventsListRequestEventTypesItemAccessCodeModifiedExternalToSeam, nil case "access_code.unmanaged.converted_to_managed": return EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged, nil case "access_code.unmanaged.failed_to_convert_to_managed": @@ -320,8 +388,12 @@ func NewEventsListRequestEventTypesItemFromString(s string) (EventsListRequestEv return EventsListRequestEventTypesItemLockUnlocked, nil case "connected_account.connected": return EventsListRequestEventTypesItemConnectedAccountConnected, nil + case "connected_account.successful_login": + return EventsListRequestEventTypesItemConnectedAccountSuccessfulLogin, nil case "connected_account.created": return EventsListRequestEventTypesItemConnectedAccountCreated, nil + case "connected_account.deleted": + return EventsListRequestEventTypesItemConnectedAccountDeleted, nil case "connected_account.disconnected": return EventsListRequestEventTypesItemConnectedAccountDisconnected, nil case "connected_account.completed_first_sync": diff --git a/health/service.go b/health/service.go index 7fc86c9..3d6a429 100644 --- a/health/service.go +++ b/health/service.go @@ -2,6 +2,44 @@ package health +import ( + json "encoding/json" + fmt "fmt" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" +) + type ServiceByServiceNameRequest struct { ServiceName string `json:"service_name"` } + +type ServiceByServiceNameResponse struct { + Ok bool `json:"ok"` + LastServiceEvaluationAt string `json:"last_service_evaluation_at"` + ServiceHealth *seamapigo.ServiceHealth `json:"service_health,omitempty"` + + _rawJSON json.RawMessage +} + +func (s *ServiceByServiceNameResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ServiceByServiceNameResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = ServiceByServiceNameResponse(value) + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *ServiceByServiceNameResponse) 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) +} diff --git a/health/service/client.go b/health/service/client.go index 284004a..92af547 100644 --- a/health/service/client.go +++ b/health/service/client.go @@ -32,7 +32,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) ByServiceName(ctx context.Context, request *health.ServiceByServiceNameRequest) (*seamapigo.ServiceByServiceNameResponse, error) { +func (c *Client) ByServiceName(ctx context.Context, request *health.ServiceByServiceNameRequest) (*health.ServiceByServiceNameResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -65,7 +65,7 @@ func (c *Client) ByServiceName(ctx context.Context, request *health.ServiceBySer return apiError } - var response *seamapigo.ServiceByServiceNameResponse + var response *health.ServiceByServiceNameResponse if err := c.caller.Call( ctx, &core.CallParams{ diff --git a/locks.go b/locks.go index a21793a..7ef096a 100644 --- a/locks.go +++ b/locks.go @@ -15,6 +15,7 @@ type LocksGetRequest struct { } type LocksListRequest struct { + // List all devices owned by this connected account ConnectedAccountId *string `json:"connected_account_id,omitempty"` ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` ConnectWebviewId *string `json:"connect_webview_id,omitempty"` @@ -24,6 +25,7 @@ type LocksListRequest struct { DeviceIds []string `json:"device_ids,omitempty"` Limit *float64 `json:"limit,omitempty"` CreatedBefore *time.Time `json:"created_before,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` } type LocksLockDoorRequest struct { @@ -32,9 +34,9 @@ type LocksLockDoorRequest struct { } type LocksGetResponse struct { - Lock interface{} `json:"lock,omitempty"` - Device *Device `json:"device,omitempty"` - Ok bool `json:"ok"` + Lock *Device `json:"lock,omitempty"` + Device *Device `json:"device,omitempty"` + Ok bool `json:"ok"` _rawJSON json.RawMessage } @@ -63,9 +65,9 @@ func (l *LocksGetResponse) String() string { } type LocksListResponse struct { - Locks interface{} `json:"locks,omitempty"` - Devices []*Device `json:"devices,omitempty"` - Ok bool `json:"ok"` + Locks []*Device `json:"locks,omitempty"` + Devices []*Device `json:"devices,omitempty"` + Ok bool `json:"ok"` _rawJSON json.RawMessage } diff --git a/networks.go b/networks.go new file mode 100644 index 0000000..f6af2e8 --- /dev/null +++ b/networks.go @@ -0,0 +1,76 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/seamapi/go/core" +) + +type NetworksGetRequest struct { + NetworkId string `json:"network_id"` +} + +type NetworksListRequest struct { +} + +type NetworksGetResponse struct { + Network *NetworksGetResponseNetwork `json:"network,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NetworksGetResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NetworksGetResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NetworksGetResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NetworksGetResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type NetworksListResponse struct { + Networks []*NetworksListResponseNetworksItem `json:"networks,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NetworksListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NetworksListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NetworksListResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NetworksListResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} diff --git a/networks/client.go b/networks/client.go new file mode 100644 index 0000000..477a3e6 --- /dev/null +++ b/networks/client.go @@ -0,0 +1,132 @@ +// This file was auto-generated by Fern from our API Definition. + +package networks + +import ( + bytes "bytes" + context "context" + json "encoding/json" + errors "errors" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" + io "io" + http "net/http" +) + +type Client struct { + baseURL string + caller *core.Caller + header http.Header +} + +func NewClient(opts ...core.ClientOption) *Client { + options := core.NewClientOptions() + for _, opt := range opts { + opt(options) + } + return &Client{ + baseURL: options.BaseURL, + caller: core.NewCaller(options.HTTPClient), + header: options.ToHeader(), + } +} + +func (c *Client) Get(ctx context.Context, request *seamapigo.NetworksGetRequest) (*seamapigo.NetworksGetResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "networks/get" + + 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.NetworksGetResponse + 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, nil +} + +func (c *Client) List(ctx context.Context, request *seamapigo.NetworksListRequest) (*seamapigo.NetworksListResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "networks/list" + + 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.NetworksListResponse + 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, nil +} diff --git a/noisesensors/noise_thresholds.go b/noisesensors/noise_thresholds.go index 61a43c6..1b64d32 100644 --- a/noisesensors/noise_thresholds.go +++ b/noisesensors/noise_thresholds.go @@ -2,6 +2,13 @@ package noisesensors +import ( + json "encoding/json" + fmt "fmt" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" +) + type NoiseThresholdsCreateRequest struct { DeviceId string `json:"device_id"` Sync *bool `json:"sync,omitempty"` @@ -23,7 +30,159 @@ type NoiseThresholdsGetRequest struct { } type NoiseThresholdsListRequest struct { - DeviceId string `json:"device_id"` + DeviceId string `json:"device_id"` + IsProgrammed *bool `json:"is_programmed,omitempty"` +} + +type NoiseThresholdsCreateResponse struct { + ActionAttempt *seamapigo.ActionAttempt `json:"action_attempt,omitempty"` + NoiseThreshold *seamapigo.NoiseThreshold `json:"noise_threshold,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NoiseThresholdsCreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NoiseThresholdsCreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NoiseThresholdsCreateResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NoiseThresholdsCreateResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type NoiseThresholdsDeleteResponse struct { + ActionAttempt *seamapigo.ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NoiseThresholdsDeleteResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NoiseThresholdsDeleteResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NoiseThresholdsDeleteResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NoiseThresholdsDeleteResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type NoiseThresholdsGetResponse struct { + NoiseThreshold *seamapigo.NoiseThreshold `json:"noise_threshold,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NoiseThresholdsGetResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NoiseThresholdsGetResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NoiseThresholdsGetResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NoiseThresholdsGetResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type NoiseThresholdsListResponse struct { + NoiseThresholds []*seamapigo.NoiseThreshold `json:"noise_thresholds,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NoiseThresholdsListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NoiseThresholdsListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NoiseThresholdsListResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NoiseThresholdsListResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type NoiseThresholdsUpdateResponse struct { + ActionAttempt *seamapigo.ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (n *NoiseThresholdsUpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler NoiseThresholdsUpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NoiseThresholdsUpdateResponse(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NoiseThresholdsUpdateResponse) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) } type NoiseThresholdsUpdateRequest struct { diff --git a/noisesensors/noisethresholds/client.go b/noisesensors/noisethresholds/client.go index cc37d84..cde4298 100644 --- a/noisesensors/noisethresholds/client.go +++ b/noisesensors/noisethresholds/client.go @@ -65,7 +65,7 @@ func (c *Client) Create(ctx context.Context, request *noisesensors.NoiseThreshol return apiError } - var response *seamapigo.NoiseThresholdsCreateResponse + var response *noisesensors.NoiseThresholdsCreateResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -115,12 +115,12 @@ func (c *Client) Delete(ctx context.Context, request *noisesensors.NoiseThreshol return apiError } - var response *seamapigo.NoiseThresholdsDeleteResponse + var response *noisesensors.NoiseThresholdsDeleteResponse if err := c.caller.Call( ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, @@ -165,7 +165,7 @@ func (c *Client) Get(ctx context.Context, request *noisesensors.NoiseThresholdsG return apiError } - var response *seamapigo.NoiseThresholdsGetResponse + var response *noisesensors.NoiseThresholdsGetResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -215,7 +215,7 @@ func (c *Client) List(ctx context.Context, request *noisesensors.NoiseThresholds return apiError } - var response *seamapigo.NoiseThresholdsListResponse + var response *noisesensors.NoiseThresholdsListResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -265,7 +265,7 @@ func (c *Client) Update(ctx context.Context, request *noisesensors.NoiseThreshol return apiError } - var response *seamapigo.NoiseThresholdsUpdateResponse + var response *noisesensors.NoiseThresholdsUpdateResponse if err := c.caller.Call( ctx, &core.CallParams{ diff --git a/noisesensors/simulate.go b/noisesensors/simulate.go index 8aef28e..f81a8ae 100644 --- a/noisesensors/simulate.go +++ b/noisesensors/simulate.go @@ -2,6 +2,41 @@ package noisesensors +import ( + json "encoding/json" + fmt "fmt" + core "github.com/seamapi/go/core" +) + type SimulateTriggerNoiseThresholdRequest struct { DeviceId string `json:"device_id"` } + +type SimulateTriggerNoiseThresholdResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (s *SimulateTriggerNoiseThresholdResponse) UnmarshalJSON(data []byte) error { + type unmarshaler SimulateTriggerNoiseThresholdResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SimulateTriggerNoiseThresholdResponse(value) + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *SimulateTriggerNoiseThresholdResponse) 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) +} diff --git a/noisesensors/simulate/client.go b/noisesensors/simulate/client.go index da8973b..51cc294 100644 --- a/noisesensors/simulate/client.go +++ b/noisesensors/simulate/client.go @@ -32,7 +32,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) TriggerNoiseThreshold(ctx context.Context, request *noisesensors.SimulateTriggerNoiseThresholdRequest) (*seamapigo.SimulateTriggerNoiseThresholdResponse, error) { +func (c *Client) TriggerNoiseThreshold(ctx context.Context, request *noisesensors.SimulateTriggerNoiseThresholdRequest) (*noisesensors.SimulateTriggerNoiseThresholdResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -65,7 +65,7 @@ func (c *Client) TriggerNoiseThreshold(ctx context.Context, request *noisesensor return apiError } - var response *seamapigo.SimulateTriggerNoiseThresholdResponse + var response *noisesensors.SimulateTriggerNoiseThresholdResponse if err := c.caller.Call( ctx, &core.CallParams{ diff --git a/phones.go b/phones.go new file mode 100644 index 0000000..61bb9ba --- /dev/null +++ b/phones.go @@ -0,0 +1,43 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/seamapi/go/core" +) + +type PhonesListRequest struct { + OwnerUserIdentityId *string `json:"owner_user_identity_id,omitempty"` +} + +type PhonesListResponse struct { + Phones []*Phone `json:"phones,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (p *PhonesListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler PhonesListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonesListResponse(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonesListResponse) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} diff --git a/phones/client/client.go b/phones/client/client.go new file mode 100644 index 0000000..053ae4a --- /dev/null +++ b/phones/client/client.go @@ -0,0 +1,86 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + bytes "bytes" + context "context" + json "encoding/json" + errors "errors" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" + simulate "github.com/seamapi/go/phones/simulate" + io "io" + http "net/http" +) + +type Client struct { + baseURL string + caller *core.Caller + header http.Header + + Simulate *simulate.Client +} + +func NewClient(opts ...core.ClientOption) *Client { + options := core.NewClientOptions() + for _, opt := range opts { + opt(options) + } + return &Client{ + baseURL: options.BaseURL, + caller: core.NewCaller(options.HTTPClient), + header: options.ToHeader(), + Simulate: simulate.NewClient(opts...), + } +} + +func (c *Client) List(ctx context.Context, request *seamapigo.PhonesListRequest) ([]*seamapigo.Phone, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "phones/list" + + 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.PhonesListResponse + 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.Phones, nil +} diff --git a/phones/simulate.go b/phones/simulate.go new file mode 100644 index 0000000..f87ffad --- /dev/null +++ b/phones/simulate.go @@ -0,0 +1,114 @@ +// This file was auto-generated by Fern from our API Definition. + +package phones + +import ( + json "encoding/json" + fmt "fmt" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" +) + +type SimulateCreateSandboxPhoneRequest struct { + AssaAbloyCredentialServiceAcsSystemId string `json:"assa_abloy_credential_service_acs_system_id"` + CustomSdkInstallationId *string `json:"custom_sdk_installation_id,omitempty"` + UserIdentityId string `json:"user_identity_id"` + PhoneMetadata *SimulateCreateSandboxPhoneRequestPhoneMetadata `json:"phone_metadata,omitempty"` + AssaAbloyMetadata *SimulateCreateSandboxPhoneRequestAssaAbloyMetadata `json:"assa_abloy_metadata,omitempty"` +} + +type SimulateCreateSandboxPhoneRequestAssaAbloyMetadata struct { + BleCapability *bool `json:"ble_capability,omitempty"` + HceCapability *bool `json:"hce_capability,omitempty"` + NfcCapability *bool `json:"nfc_capability,omitempty"` + ApplicationVersion *string `json:"application_version,omitempty"` + SeosAppletVersion *string `json:"seos_applet_version,omitempty"` + SeosTsmEndpointId *float64 `json:"seos_tsm_endpoint_id,omitempty"` + + _rawJSON json.RawMessage +} + +func (s *SimulateCreateSandboxPhoneRequestAssaAbloyMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler SimulateCreateSandboxPhoneRequestAssaAbloyMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SimulateCreateSandboxPhoneRequestAssaAbloyMetadata(value) + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *SimulateCreateSandboxPhoneRequestAssaAbloyMetadata) 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) +} + +type SimulateCreateSandboxPhoneRequestPhoneMetadata struct { + OperatingSystem *SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem `json:"operating_system,omitempty"` + OsVersion *string `json:"os_version,omitempty"` + DeviceManufacturer *string `json:"device_manufacturer,omitempty"` + DeviceModel *string `json:"device_model,omitempty"` + + _rawJSON json.RawMessage +} + +func (s *SimulateCreateSandboxPhoneRequestPhoneMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler SimulateCreateSandboxPhoneRequestPhoneMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SimulateCreateSandboxPhoneRequestPhoneMetadata(value) + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *SimulateCreateSandboxPhoneRequestPhoneMetadata) 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) +} + +type SimulateCreateSandboxPhoneResponse struct { + Phone *seamapigo.Phone `json:"phone,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (s *SimulateCreateSandboxPhoneResponse) UnmarshalJSON(data []byte) error { + type unmarshaler SimulateCreateSandboxPhoneResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SimulateCreateSandboxPhoneResponse(value) + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *SimulateCreateSandboxPhoneResponse) 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) +} diff --git a/phones/simulate/client.go b/phones/simulate/client.go new file mode 100644 index 0000000..deca55d --- /dev/null +++ b/phones/simulate/client.go @@ -0,0 +1,83 @@ +// This file was auto-generated by Fern from our API Definition. + +package simulate + +import ( + bytes "bytes" + context "context" + json "encoding/json" + errors "errors" + seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" + phones "github.com/seamapi/go/phones" + io "io" + http "net/http" +) + +type Client struct { + baseURL string + caller *core.Caller + header http.Header +} + +func NewClient(opts ...core.ClientOption) *Client { + options := core.NewClientOptions() + for _, opt := range opts { + opt(options) + } + return &Client{ + baseURL: options.BaseURL, + caller: core.NewCaller(options.HTTPClient), + header: options.ToHeader(), + } +} + +func (c *Client) CreateSandboxPhone(ctx context.Context, request *phones.SimulateCreateSandboxPhoneRequest) (*seamapigo.Phone, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "phones/simulate/create_sandbox_phone" + + 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 *phones.SimulateCreateSandboxPhoneResponse + 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.Phone, nil +} diff --git a/phones/types.go b/phones/types.go new file mode 100644 index 0000000..75ae81d --- /dev/null +++ b/phones/types.go @@ -0,0 +1,29 @@ +// This file was auto-generated by Fern from our API Definition. + +package phones + +import ( + fmt "fmt" +) + +type SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem string + +const ( + SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystemAndroid SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem = "android" + SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystemIos SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem = "ios" +) + +func NewSimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystemFromString(s string) (SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem, error) { + switch s { + case "android": + return SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystemAndroid, nil + case "ios": + return SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystemIos, nil + } + var t SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (s SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem) Ptr() *SimulateCreateSandboxPhoneRequestPhoneMetadataOperatingSystem { + return &s +} diff --git a/thermostats.go b/thermostats.go index f17b5d1..37f3cb5 100644 --- a/thermostats.go +++ b/thermostats.go @@ -9,6 +9,13 @@ import ( time "time" ) +type ThermostatsCoolRequest struct { + DeviceId string `json:"device_id"` + CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` + CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` + Sync *bool `json:"sync,omitempty"` +} + type ThermostatsGetRequest struct { DeviceId *string `json:"device_id,omitempty"` Name *string `json:"name,omitempty"` @@ -21,7 +28,17 @@ type ThermostatsHeatRequest struct { Sync *bool `json:"sync,omitempty"` } +type ThermostatsHeatCoolRequest struct { + DeviceId string `json:"device_id"` + HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` + HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` + CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` + CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` + Sync *bool `json:"sync,omitempty"` +} + type ThermostatsListRequest struct { + // List all devices owned by this connected account ConnectedAccountId *string `json:"connected_account_id,omitempty"` ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` ConnectWebviewId *string `json:"connect_webview_id,omitempty"` @@ -31,35 +48,48 @@ type ThermostatsListRequest struct { DeviceIds []string `json:"device_ids,omitempty"` Limit *float64 `json:"limit,omitempty"` CreatedBefore *time.Time `json:"created_before,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + +type ThermostatsOffRequest struct { + DeviceId string `json:"device_id"` + Sync *bool `json:"sync,omitempty"` } type ThermostatsSetFanModeRequest struct { - DeviceId string `json:"device_id"` - FanMode *FanModeSetting `json:"fan_mode,omitempty"` - FanModeSetting *FanModeSetting `json:"fan_mode_setting,omitempty"` - Sync *bool `json:"sync,omitempty"` + DeviceId string `json:"device_id"` + FanMode *ThermostatsSetFanModeRequestFanMode `json:"fan_mode,omitempty"` + FanModeSetting *ThermostatsSetFanModeRequestFanModeSetting `json:"fan_mode_setting,omitempty"` + Sync *bool `json:"sync,omitempty"` } -type FanModeSetting string +type ThermostatsCoolResponse struct { + Ok bool `json:"ok"` -const ( - FanModeSettingAuto FanModeSetting = "auto" - FanModeSettingOn FanModeSetting = "on" -) + _rawJSON json.RawMessage +} -func NewFanModeSettingFromString(s string) (FanModeSetting, error) { - switch s { - case "auto": - return FanModeSettingAuto, nil - case "on": - return FanModeSettingOn, nil +func (t *ThermostatsCoolResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ThermostatsCoolResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err } - var t FanModeSetting - return "", fmt.Errorf("%s is not a valid %T", s, t) + *t = ThermostatsCoolResponse(value) + t._rawJSON = json.RawMessage(data) + return nil } -func (f FanModeSetting) Ptr() *FanModeSetting { - return &f +func (t *ThermostatsCoolResponse) String() string { + if len(t._rawJSON) > 0 { + if value, err := core.StringifyJSON(t._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) } type ThermostatsGetResponse struct { @@ -92,6 +122,35 @@ func (t *ThermostatsGetResponse) String() string { return fmt.Sprintf("%#v", t) } +type ThermostatsHeatCoolResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (t *ThermostatsHeatCoolResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ThermostatsHeatCoolResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = ThermostatsHeatCoolResponse(value) + t._rawJSON = json.RawMessage(data) + return nil +} + +func (t *ThermostatsHeatCoolResponse) String() string { + if len(t._rawJSON) > 0 { + if value, err := core.StringifyJSON(t._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} + type ThermostatsHeatResponse struct { Ok bool `json:"ok"` @@ -151,6 +210,79 @@ func (t *ThermostatsListResponse) String() string { return fmt.Sprintf("%#v", t) } +type ThermostatsOffResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (t *ThermostatsOffResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ThermostatsOffResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = ThermostatsOffResponse(value) + t._rawJSON = json.RawMessage(data) + return nil +} + +func (t *ThermostatsOffResponse) String() string { + if len(t._rawJSON) > 0 { + if value, err := core.StringifyJSON(t._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} + +type ThermostatsSetFanModeRequestFanMode string + +const ( + ThermostatsSetFanModeRequestFanModeAuto ThermostatsSetFanModeRequestFanMode = "auto" + ThermostatsSetFanModeRequestFanModeOn ThermostatsSetFanModeRequestFanMode = "on" +) + +func NewThermostatsSetFanModeRequestFanModeFromString(s string) (ThermostatsSetFanModeRequestFanMode, error) { + switch s { + case "auto": + return ThermostatsSetFanModeRequestFanModeAuto, nil + case "on": + return ThermostatsSetFanModeRequestFanModeOn, nil + } + var t ThermostatsSetFanModeRequestFanMode + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (t ThermostatsSetFanModeRequestFanMode) Ptr() *ThermostatsSetFanModeRequestFanMode { + return &t +} + +type ThermostatsSetFanModeRequestFanModeSetting string + +const ( + ThermostatsSetFanModeRequestFanModeSettingAuto ThermostatsSetFanModeRequestFanModeSetting = "auto" + ThermostatsSetFanModeRequestFanModeSettingOn ThermostatsSetFanModeRequestFanModeSetting = "on" +) + +func NewThermostatsSetFanModeRequestFanModeSettingFromString(s string) (ThermostatsSetFanModeRequestFanModeSetting, error) { + switch s { + case "auto": + return ThermostatsSetFanModeRequestFanModeSettingAuto, nil + case "on": + return ThermostatsSetFanModeRequestFanModeSettingOn, nil + } + var t ThermostatsSetFanModeRequestFanModeSetting + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (t ThermostatsSetFanModeRequestFanModeSetting) Ptr() *ThermostatsSetFanModeRequestFanModeSetting { + return &t +} + type ThermostatsSetFanModeResponse struct { Ok bool `json:"ok"` @@ -181,14 +313,14 @@ func (t *ThermostatsSetFanModeResponse) String() string { } type ThermostatsUpdateRequestDefaultClimateSetting struct { - AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` - AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` - HvacModeSetting *HvacModeSetting `json:"hvac_mode_setting,omitempty"` - CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` - HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` - CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` - HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` - ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` + AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` + AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` + HvacModeSetting *ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting `json:"hvac_mode_setting,omitempty"` + CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` + HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` + CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` + HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` + ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` _rawJSON json.RawMessage } diff --git a/thermostats/client/client.go b/thermostats/client/client.go index 7fb6856..f0c1fa2 100644 --- a/thermostats/client/client.go +++ b/thermostats/client/client.go @@ -35,6 +35,56 @@ func NewClient(opts ...core.ClientOption) *Client { } } +func (c *Client) Cool(ctx context.Context, request *seamapigo.ThermostatsCoolRequest) (*seamapigo.ThermostatsCoolResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "thermostats/cool" + + 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.ThermostatsCoolResponse + 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, nil +} + func (c *Client) Get(ctx context.Context, request *seamapigo.ThermostatsGetRequest) (*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { @@ -85,7 +135,7 @@ func (c *Client) Get(ctx context.Context, request *seamapigo.ThermostatsGetReque return response.Thermostat, nil } -func (c *Client) Heat(ctx context.Context, request *seamapigo.ThermostatsHeatRequest) (bool, error) { +func (c *Client) Heat(ctx context.Context, request *seamapigo.ThermostatsHeatRequest) (*seamapigo.ThermostatsHeatResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -130,9 +180,59 @@ func (c *Client) Heat(ctx context.Context, request *seamapigo.ThermostatsHeatReq ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil +} + +func (c *Client) HeatCool(ctx context.Context, request *seamapigo.ThermostatsHeatCoolRequest) (*seamapigo.ThermostatsHeatCoolResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "thermostats/heat_cool" + + 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.ThermostatsHeatCoolResponse + 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, nil } func (c *Client) List(ctx context.Context, request *seamapigo.ThermostatsListRequest) ([]*seamapigo.Device, error) { @@ -185,6 +285,56 @@ func (c *Client) List(ctx context.Context, request *seamapigo.ThermostatsListReq return response.Thermostats, nil } +func (c *Client) Off(ctx context.Context, request *seamapigo.ThermostatsOffRequest) (*seamapigo.ThermostatsOffResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "thermostats/off" + + 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.ThermostatsOffResponse + 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, nil +} + func (c *Client) SetFanMode(ctx context.Context, request *seamapigo.ThermostatsSetFanModeRequest) (*seamapigo.ThermostatsSetFanModeResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { @@ -235,7 +385,7 @@ func (c *Client) SetFanMode(ctx context.Context, request *seamapigo.ThermostatsS return response, nil } -func (c *Client) Update(ctx context.Context, request *seamapigo.ThermostatsUpdateRequest) (bool, error) { +func (c *Client) Update(ctx context.Context, request *seamapigo.ThermostatsUpdateRequest) (*seamapigo.ThermostatsUpdateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -280,7 +430,7 @@ func (c *Client) Update(ctx context.Context, request *seamapigo.ThermostatsUpdat ErrorDecoder: errorDecoder, }, ); err != nil { - return false, err + return nil, err } - return response.Ok, nil + return response, nil } diff --git a/thermostats/climate_setting_schedules.go b/thermostats/climate_setting_schedules.go index d8585e3..c78809d 100644 --- a/thermostats/climate_setting_schedules.go +++ b/thermostats/climate_setting_schedules.go @@ -3,23 +3,26 @@ package thermostats import ( + json "encoding/json" + fmt "fmt" seamapigo "github.com/seamapi/go" + core "github.com/seamapi/go/core" ) type ClimateSettingSchedulesCreateRequest struct { - ScheduleType *string `json:"schedule_type,omitempty"` - DeviceId string `json:"device_id"` - Name *string `json:"name,omitempty"` - ScheduleStartsAt string `json:"schedule_starts_at"` - ScheduleEndsAt string `json:"schedule_ends_at"` - AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` - AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` - HvacModeSetting *seamapigo.HvacModeSetting `json:"hvac_mode_setting,omitempty"` - CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` - HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` - CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` - HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` - ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` + ScheduleType *string `json:"schedule_type,omitempty"` + DeviceId string `json:"device_id"` + Name *string `json:"name,omitempty"` + ScheduleStartsAt string `json:"schedule_starts_at"` + ScheduleEndsAt string `json:"schedule_ends_at"` + AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` + AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` + HvacModeSetting *ClimateSettingSchedulesCreateRequestHvacModeSetting `json:"hvac_mode_setting,omitempty"` + CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` + HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` + CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` + HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` + ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` } type ClimateSettingSchedulesDeleteRequest struct { @@ -32,21 +35,227 @@ type ClimateSettingSchedulesGetRequest struct { } type ClimateSettingSchedulesListRequest struct { - DeviceId string `json:"device_id"` + DeviceId string `json:"device_id"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + +type ClimateSettingSchedulesCreateRequestHvacModeSetting string + +const ( + ClimateSettingSchedulesCreateRequestHvacModeSettingOff ClimateSettingSchedulesCreateRequestHvacModeSetting = "off" + ClimateSettingSchedulesCreateRequestHvacModeSettingHeat ClimateSettingSchedulesCreateRequestHvacModeSetting = "heat" + ClimateSettingSchedulesCreateRequestHvacModeSettingCool ClimateSettingSchedulesCreateRequestHvacModeSetting = "cool" + ClimateSettingSchedulesCreateRequestHvacModeSettingHeatCool ClimateSettingSchedulesCreateRequestHvacModeSetting = "heat_cool" +) + +func NewClimateSettingSchedulesCreateRequestHvacModeSettingFromString(s string) (ClimateSettingSchedulesCreateRequestHvacModeSetting, error) { + switch s { + case "off": + return ClimateSettingSchedulesCreateRequestHvacModeSettingOff, nil + case "heat": + return ClimateSettingSchedulesCreateRequestHvacModeSettingHeat, nil + case "cool": + return ClimateSettingSchedulesCreateRequestHvacModeSettingCool, nil + case "heat_cool": + return ClimateSettingSchedulesCreateRequestHvacModeSettingHeatCool, nil + } + var t ClimateSettingSchedulesCreateRequestHvacModeSetting + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ClimateSettingSchedulesCreateRequestHvacModeSetting) Ptr() *ClimateSettingSchedulesCreateRequestHvacModeSetting { + return &c +} + +type ClimateSettingSchedulesCreateResponse struct { + ClimateSettingSchedule *seamapigo.ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClimateSettingSchedulesCreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClimateSettingSchedulesCreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClimateSettingSchedulesCreateResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClimateSettingSchedulesCreateResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type ClimateSettingSchedulesDeleteResponse struct { + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClimateSettingSchedulesDeleteResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClimateSettingSchedulesDeleteResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClimateSettingSchedulesDeleteResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClimateSettingSchedulesDeleteResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type ClimateSettingSchedulesGetResponse struct { + ClimateSettingSchedule *seamapigo.ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClimateSettingSchedulesGetResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClimateSettingSchedulesGetResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClimateSettingSchedulesGetResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClimateSettingSchedulesGetResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type ClimateSettingSchedulesListResponse struct { + ClimateSettingSchedules []*seamapigo.ClimateSettingSchedule `json:"climate_setting_schedules,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClimateSettingSchedulesListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClimateSettingSchedulesListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClimateSettingSchedulesListResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClimateSettingSchedulesListResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type ClimateSettingSchedulesUpdateRequestHvacModeSetting string + +const ( + ClimateSettingSchedulesUpdateRequestHvacModeSettingOff ClimateSettingSchedulesUpdateRequestHvacModeSetting = "off" + ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat ClimateSettingSchedulesUpdateRequestHvacModeSetting = "heat" + ClimateSettingSchedulesUpdateRequestHvacModeSettingCool ClimateSettingSchedulesUpdateRequestHvacModeSetting = "cool" + ClimateSettingSchedulesUpdateRequestHvacModeSettingHeatCool ClimateSettingSchedulesUpdateRequestHvacModeSetting = "heat_cool" +) + +func NewClimateSettingSchedulesUpdateRequestHvacModeSettingFromString(s string) (ClimateSettingSchedulesUpdateRequestHvacModeSetting, error) { + switch s { + case "off": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingOff, nil + case "heat": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat, nil + case "cool": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingCool, nil + case "heat_cool": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingHeatCool, nil + } + var t ClimateSettingSchedulesUpdateRequestHvacModeSetting + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ClimateSettingSchedulesUpdateRequestHvacModeSetting) Ptr() *ClimateSettingSchedulesUpdateRequestHvacModeSetting { + return &c +} + +type ClimateSettingSchedulesUpdateResponse struct { + ClimateSettingSchedule *seamapigo.ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (c *ClimateSettingSchedulesUpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ClimateSettingSchedulesUpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClimateSettingSchedulesUpdateResponse(value) + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ClimateSettingSchedulesUpdateResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) } type ClimateSettingSchedulesUpdateRequest struct { - ClimateSettingScheduleId string `json:"climate_setting_schedule_id"` - ScheduleType *string `json:"schedule_type,omitempty"` - Name *string `json:"name,omitempty"` - ScheduleStartsAt *string `json:"schedule_starts_at,omitempty"` - ScheduleEndsAt *string `json:"schedule_ends_at,omitempty"` - AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` - AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` - HvacModeSetting *seamapigo.HvacModeSetting `json:"hvac_mode_setting,omitempty"` - CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` - HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` - CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` - HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` - ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` + ClimateSettingScheduleId string `json:"climate_setting_schedule_id"` + ScheduleType *string `json:"schedule_type,omitempty"` + Name *string `json:"name,omitempty"` + ScheduleStartsAt *string `json:"schedule_starts_at,omitempty"` + ScheduleEndsAt *string `json:"schedule_ends_at,omitempty"` + AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` + AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` + HvacModeSetting *ClimateSettingSchedulesUpdateRequestHvacModeSetting `json:"hvac_mode_setting,omitempty"` + CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` + HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` + CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` + HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` + ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` } diff --git a/thermostats/climatesettingschedules/client.go b/thermostats/climatesettingschedules/client.go index d78f190..66733ce 100644 --- a/thermostats/climatesettingschedules/client.go +++ b/thermostats/climatesettingschedules/client.go @@ -32,7 +32,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) Create(ctx context.Context, request *thermostats.ClimateSettingSchedulesCreateRequest) (*seamapigo.ClimateSettingSchedulesCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *thermostats.ClimateSettingSchedulesCreateRequest) (*seamapigo.ClimateSettingSchedule, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -65,7 +65,7 @@ func (c *Client) Create(ctx context.Context, request *thermostats.ClimateSetting return apiError } - var response *seamapigo.ClimateSettingSchedulesCreateResponse + var response *thermostats.ClimateSettingSchedulesCreateResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -79,10 +79,10 @@ func (c *Client) Create(ctx context.Context, request *thermostats.ClimateSetting ); err != nil { return nil, err } - return response, nil + return response.ClimateSettingSchedule, nil } -func (c *Client) Delete(ctx context.Context, request *thermostats.ClimateSettingSchedulesDeleteRequest) (*seamapigo.ClimateSettingSchedulesDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *thermostats.ClimateSettingSchedulesDeleteRequest) (*thermostats.ClimateSettingSchedulesDeleteResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -115,12 +115,12 @@ func (c *Client) Delete(ctx context.Context, request *thermostats.ClimateSetting return apiError } - var response *seamapigo.ClimateSettingSchedulesDeleteResponse + var response *thermostats.ClimateSettingSchedulesDeleteResponse if err := c.caller.Call( ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, @@ -132,7 +132,7 @@ func (c *Client) Delete(ctx context.Context, request *thermostats.ClimateSetting return response, nil } -func (c *Client) Get(ctx context.Context, request *thermostats.ClimateSettingSchedulesGetRequest) (*seamapigo.ClimateSettingSchedulesGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *thermostats.ClimateSettingSchedulesGetRequest) (*seamapigo.ClimateSettingSchedule, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -165,7 +165,7 @@ func (c *Client) Get(ctx context.Context, request *thermostats.ClimateSettingSch return apiError } - var response *seamapigo.ClimateSettingSchedulesGetResponse + var response *thermostats.ClimateSettingSchedulesGetResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -179,10 +179,10 @@ func (c *Client) Get(ctx context.Context, request *thermostats.ClimateSettingSch ); err != nil { return nil, err } - return response, nil + return response.ClimateSettingSchedule, nil } -func (c *Client) List(ctx context.Context, request *thermostats.ClimateSettingSchedulesListRequest) (*seamapigo.ClimateSettingSchedulesListResponse, error) { +func (c *Client) List(ctx context.Context, request *thermostats.ClimateSettingSchedulesListRequest) ([]*seamapigo.ClimateSettingSchedule, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -215,7 +215,7 @@ func (c *Client) List(ctx context.Context, request *thermostats.ClimateSettingSc return apiError } - var response *seamapigo.ClimateSettingSchedulesListResponse + var response *thermostats.ClimateSettingSchedulesListResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -229,10 +229,10 @@ func (c *Client) List(ctx context.Context, request *thermostats.ClimateSettingSc ); err != nil { return nil, err } - return response, nil + return response.ClimateSettingSchedules, nil } -func (c *Client) Update(ctx context.Context, request *thermostats.ClimateSettingSchedulesUpdateRequest) (*seamapigo.ClimateSettingSchedulesUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *thermostats.ClimateSettingSchedulesUpdateRequest) (*seamapigo.ClimateSettingSchedule, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -265,7 +265,7 @@ func (c *Client) Update(ctx context.Context, request *thermostats.ClimateSetting return apiError } - var response *seamapigo.ClimateSettingSchedulesUpdateResponse + var response *thermostats.ClimateSettingSchedulesUpdateResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -279,5 +279,5 @@ func (c *Client) Update(ctx context.Context, request *thermostats.ClimateSetting ); err != nil { return nil, err } - return response, nil + return response.ClimateSettingSchedule, nil } diff --git a/types.go b/types.go index 182a23a..93d38ad 100644 --- a/types.go +++ b/types.go @@ -10,24 +10,46 @@ import ( ) type AccessCode struct { - CommonCodeKey *string `json:"common_code_key,omitempty"` - IsScheduledOnDevice *bool `json:"is_scheduled_on_device,omitempty"` - Type AccessCodeType `json:"type,omitempty"` - IsWaitingForCodeAssignment *bool `json:"is_waiting_for_code_assignment,omitempty"` - AccessCodeId string `json:"access_code_id"` - DeviceId string `json:"device_id"` - Name *string `json:"name,omitempty"` - Code *string `json:"code,omitempty"` - CreatedAt time.Time `json:"created_at"` - Errors interface{} `json:"errors,omitempty"` - Warnings interface{} `json:"warnings,omitempty"` - IsManaged bool `json:"is_managed"` - StartsAt *time.Time `json:"starts_at,omitempty"` - EndsAt *time.Time `json:"ends_at,omitempty"` - Status AccessCodeStatus `json:"status,omitempty"` - IsBackupAccessCodeAvailable bool `json:"is_backup_access_code_available"` - IsBackup *bool `json:"is_backup,omitempty"` - PulledBackupAccessCodeId *string `json:"pulled_backup_access_code_id,omitempty"` + // Unique identifier for a group of access codes that share the same code. + CommonCodeKey *string `json:"common_code_key,omitempty"` + // Indicates whether the code is set on the device according to a preconfigured schedule. + IsScheduledOnDevice *bool `json:"is_scheduled_on_device,omitempty"` + // Nature of the access code. Values are "ongoing" for access codes that are active continuously until deactivated manually or "time_bound" for access codes that have a specific duration. + Type AccessCodeType `json:"type,omitempty"` + // Indicates whether the access code is waiting for a code assignment. + IsWaitingForCodeAssignment *bool `json:"is_waiting_for_code_assignment,omitempty"` + // Unique identifier for the access code. + AccessCodeId string `json:"access_code_id"` + // Unique identifier for the device associated with the access code. + DeviceId string `json:"device_id"` + // Name of the access code. Enables administrators and users to identify the access code easily, especially when there are numerous access codes. + Name *string `json:"name,omitempty"` + // Code used for access. Typically, a numeric or alphanumeric string. + Code *string `json:"code,omitempty"` + // Date and time at which the access code was created. + CreatedAt time.Time `json:"created_at"` + Errors interface{} `json:"errors,omitempty"` + Warnings interface{} `json:"warnings,omitempty"` + // Indicates whether Seam manages the access code. + IsManaged string `json:"is_managed"` + // Date and time at which the time-bound access code becomes active. + StartsAt *time.Time `json:"starts_at,omitempty"` + // Date and time after which the time-bound access code becomes inactive. + EndsAt *time.Time `json:"ends_at,omitempty"` + // Current status of the access code within the operational lifecycle. Values are "setting," a transitional phase that indicates that the code is being configured or activated; "set", which indicates that the code is active and operational; "unset," which indicates a deactivated or unused state, either before activation or after deliberate deactivation; "removing," which indicates a transitional period in which the code is being deleted or made inactive; and "unknown," which indicates an indeterminate state, due to reasons such as system errors or incomplete data, that highlights a potential need for system review or troubleshooting. + Status AccessCodeStatus `json:"status,omitempty"` + // Indicates whether a backup access code is available for use if the primary access code is lost or compromised. + IsBackupAccessCodeAvailable bool `json:"is_backup_access_code_available"` + // Indicates whether the access code is a backup code. + IsBackup *bool `json:"is_backup,omitempty"` + // Identifier of the pulled backup access code. Used to associate the pulled backup access code with the original access code. + PulledBackupAccessCodeId *string `json:"pulled_backup_access_code_id,omitempty"` + // Indicates whether changes to the access code from external sources are permitted. + IsExternalModificationAllowed bool `json:"is_external_modification_allowed"` + // Indicates whether the access code can only be used once. If "true," the code becomes invalid after the first use. + IsOneTimeUse bool `json:"is_one_time_use"` + // Indicates whether the access code is intended for use in offline scenarios. If "true," this code can be created on a device without a network connection. + IsOfflineAccessCode bool `json:"is_offline_access_code"` _rawJSON json.RawMessage } @@ -55,6 +77,7 @@ func (a *AccessCode) String() string { return fmt.Sprintf("%#v", a) } +// Current status of the access code within the operational lifecycle. Values are "setting," a transitional phase that indicates that the code is being configured or activated; "set", which indicates that the code is active and operational; "unset," which indicates a deactivated or unused state, either before activation or after deliberate deactivation; "removing," which indicates a transitional period in which the code is being deleted or made inactive; and "unknown," which indicates an indeterminate state, due to reasons such as system errors or incomplete data, that highlights a potential need for system review or troubleshooting. type AccessCodeStatus string const ( @@ -86,6 +109,7 @@ func (a AccessCodeStatus) Ptr() *AccessCodeStatus { return &a } +// Nature of the access code. Values are "ongoing" for access codes that are active continuously until deactivated manually or "time_bound" for access codes that have a specific duration. type AccessCodeType string const ( @@ -252,7 +276,7 @@ const ( AcsSystemExternalTypeBrivoAccount AcsSystemExternalType = "brivo_account" AcsSystemExternalTypeHidCredentialManagerOrganization AcsSystemExternalType = "hid_credential_manager_organization" AcsSystemExternalTypeVisionlineSystem AcsSystemExternalType = "visionline_system" - AcsSystemExternalTypeAssaAbloyCredentialServiceUser AcsSystemExternalType = "assa_abloy_credential_service_user" + AcsSystemExternalTypeAssaAbloyCredentialService AcsSystemExternalType = "assa_abloy_credential_service" ) func NewAcsSystemExternalTypeFromString(s string) (AcsSystemExternalType, error) { @@ -269,8 +293,8 @@ func NewAcsSystemExternalTypeFromString(s string) (AcsSystemExternalType, error) return AcsSystemExternalTypeHidCredentialManagerOrganization, nil case "visionline_system": return AcsSystemExternalTypeVisionlineSystem, nil - case "assa_abloy_credential_service_user": - return AcsSystemExternalTypeAssaAbloyCredentialServiceUser, nil + case "assa_abloy_credential_service": + return AcsSystemExternalTypeAssaAbloyCredentialService, nil } var t AcsSystemExternalType return "", fmt.Errorf("%s is not a valid %T", s, t) @@ -290,7 +314,7 @@ const ( AcsSystemSystemTypeBrivoAccount AcsSystemSystemType = "brivo_account" AcsSystemSystemTypeHidCredentialManagerOrganization AcsSystemSystemType = "hid_credential_manager_organization" AcsSystemSystemTypeVisionlineSystem AcsSystemSystemType = "visionline_system" - AcsSystemSystemTypeAssaAbloyCredentialServiceUser AcsSystemSystemType = "assa_abloy_credential_service_user" + AcsSystemSystemTypeAssaAbloyCredentialService AcsSystemSystemType = "assa_abloy_credential_service" ) func NewAcsSystemSystemTypeFromString(s string) (AcsSystemSystemType, error) { @@ -307,8 +331,8 @@ func NewAcsSystemSystemTypeFromString(s string) (AcsSystemSystemType, error) { return AcsSystemSystemTypeHidCredentialManagerOrganization, nil case "visionline_system": return AcsSystemSystemTypeVisionlineSystem, nil - case "assa_abloy_credential_service_user": - return AcsSystemSystemTypeAssaAbloyCredentialServiceUser, nil + case "assa_abloy_credential_service": + return AcsSystemSystemTypeAssaAbloyCredentialService, nil } var t AcsSystemSystemType return "", fmt.Errorf("%s is not a valid %T", s, t) @@ -397,10 +421,10 @@ func (a *AcsUserAccessSchedule) String() string { type AcsUserExternalType string const ( - AcsUserExternalTypePtiUser AcsUserExternalType = "pti_user" - AcsUserExternalTypeBrivoUser AcsUserExternalType = "brivo_user" - AcsUserExternalTypeHidCmUser AcsUserExternalType = "hid_cm_user" - AcsUserExternalTypeSaltoSiteUser AcsUserExternalType = "salto_site_user" + AcsUserExternalTypePtiUser AcsUserExternalType = "pti_user" + AcsUserExternalTypeBrivoUser AcsUserExternalType = "brivo_user" + AcsUserExternalTypeHidCredentialManagerUser AcsUserExternalType = "hid_credential_manager_user" + AcsUserExternalTypeSaltoSiteUser AcsUserExternalType = "salto_site_user" ) func NewAcsUserExternalTypeFromString(s string) (AcsUserExternalType, error) { @@ -409,8 +433,8 @@ func NewAcsUserExternalTypeFromString(s string) (AcsUserExternalType, error) { return AcsUserExternalTypePtiUser, nil case "brivo_user": return AcsUserExternalTypeBrivoUser, nil - case "hid_cm_user": - return AcsUserExternalTypeHidCmUser, nil + case "hid_credential_manager_user": + return AcsUserExternalTypeHidCredentialManagerUser, nil case "salto_site_user": return AcsUserExternalTypeSaltoSiteUser, nil } @@ -651,41 +675,6 @@ func (a *ActionAttemptSuccess) String() string { return fmt.Sprintf("%#v", a) } -type AugustDeviceMetadata struct { - LockId string `json:"lock_id"` - LockName string `json:"lock_name"` - HouseName string `json:"house_name"` - HouseId *string `json:"house_id,omitempty"` - HasKeypad bool `json:"has_keypad"` - Model *string `json:"model,omitempty"` - KeypadBatteryLevel *string `json:"keypad_battery_level,omitempty"` - - _rawJSON json.RawMessage -} - -func (a *AugustDeviceMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler AugustDeviceMetadata - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = AugustDeviceMetadata(value) - a._rawJSON = json.RawMessage(data) - return nil -} - -func (a *AugustDeviceMetadata) 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 ClientSession struct { ClientSessionId string `json:"client_session_id"` UserIdentifierKey *string `json:"user_identifier_key,omitempty"` @@ -694,6 +683,7 @@ type ClientSession struct { DeviceCount float64 `json:"device_count"` ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` + UserIdentityIds []string `json:"user_identity_ids,omitempty"` WorkspaceId string `json:"workspace_id"` _rawJSON json.RawMessage @@ -723,20 +713,21 @@ func (c *ClientSession) String() string { } type ClimateSettingSchedule struct { - ClimateSettingScheduleId string `json:"climate_setting_schedule_id"` - DeviceId string `json:"device_id"` - Name *string `json:"name,omitempty"` - ScheduleStartsAt string `json:"schedule_starts_at"` - ScheduleEndsAt string `json:"schedule_ends_at"` - CreatedAt time.Time `json:"created_at"` - AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` - AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` - HvacModeSetting *HvacModeSetting `json:"hvac_mode_setting,omitempty"` - CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` - HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` - CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` - HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` - ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` + ClimateSettingScheduleId string `json:"climate_setting_schedule_id"` + DeviceId string `json:"device_id"` + Name *string `json:"name,omitempty"` + ScheduleStartsAt string `json:"schedule_starts_at"` + ScheduleEndsAt string `json:"schedule_ends_at"` + CreatedAt time.Time `json:"created_at"` + Errors interface{} `json:"errors,omitempty"` + AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` + AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` + HvacModeSetting *ClimateSettingScheduleHvacModeSetting `json:"hvac_mode_setting,omitempty"` + CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` + HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` + CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` + HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` + ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` scheduleType string _rawJSON json.RawMessage @@ -782,54 +773,70 @@ func (c *ClimateSettingSchedule) String() string { return fmt.Sprintf("%#v", c) } -type ClimateSettingSchedulesCreateResponse struct { - ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` - Ok bool `json:"ok"` +type ClimateSettingScheduleHvacModeSetting string - _rawJSON json.RawMessage -} +const ( + ClimateSettingScheduleHvacModeSettingOff ClimateSettingScheduleHvacModeSetting = "off" + ClimateSettingScheduleHvacModeSettingHeat ClimateSettingScheduleHvacModeSetting = "heat" + ClimateSettingScheduleHvacModeSettingCool ClimateSettingScheduleHvacModeSetting = "cool" + ClimateSettingScheduleHvacModeSettingHeatCool ClimateSettingScheduleHvacModeSetting = "heat_cool" +) -func (c *ClimateSettingSchedulesCreateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ClimateSettingSchedulesCreateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err +func NewClimateSettingScheduleHvacModeSettingFromString(s string) (ClimateSettingScheduleHvacModeSetting, error) { + switch s { + case "off": + return ClimateSettingScheduleHvacModeSettingOff, nil + case "heat": + return ClimateSettingScheduleHvacModeSettingHeat, nil + case "cool": + return ClimateSettingScheduleHvacModeSettingCool, nil + case "heat_cool": + return ClimateSettingScheduleHvacModeSettingHeatCool, nil } - *c = ClimateSettingSchedulesCreateResponse(value) - c._rawJSON = json.RawMessage(data) - return nil + var t ClimateSettingScheduleHvacModeSetting + return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (c *ClimateSettingSchedulesCreateResponse) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) +func (c ClimateSettingScheduleHvacModeSetting) Ptr() *ClimateSettingScheduleHvacModeSetting { + return &c } -type ClimateSettingSchedulesDeleteResponse struct { - Ok bool `json:"ok"` +type ConnectWebview struct { + ConnectWebviewId string `json:"connect_webview_id"` + ConnectedAccountId *string `json:"connected_account_id,omitempty"` + Url string `json:"url"` + WorkspaceId string `json:"workspace_id"` + DeviceSelectionMode ConnectWebviewDeviceSelectionMode `json:"device_selection_mode,omitempty"` + AcceptedProviders []string `json:"accepted_providers,omitempty"` + AcceptedDevices []string `json:"accepted_devices,omitempty"` + AnyProviderAllowed bool `json:"any_provider_allowed"` + AnyDeviceAllowed bool `json:"any_device_allowed"` + CreatedAt time.Time `json:"created_at"` + LoginSuccessful bool `json:"login_successful"` + Status ConnectWebviewStatus `json:"status,omitempty"` + CustomRedirectUrl *string `json:"custom_redirect_url,omitempty"` + CustomRedirectFailureUrl *string `json:"custom_redirect_failure_url,omitempty"` + CustomMetadata map[string]*ConnectWebviewCustomMetadataValue `json:"custom_metadata,omitempty"` + AutomaticallyManageNewDevices bool `json:"automatically_manage_new_devices"` + WaitForDeviceCreation bool `json:"wait_for_device_creation"` + AuthorizedAt *time.Time `json:"authorized_at,omitempty"` + SelectedProvider *string `json:"selected_provider,omitempty"` _rawJSON json.RawMessage } -func (c *ClimateSettingSchedulesDeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ClimateSettingSchedulesDeleteResponse +func (c *ConnectWebview) UnmarshalJSON(data []byte) error { + type unmarshaler ConnectWebview var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *c = ClimateSettingSchedulesDeleteResponse(value) + *c = ConnectWebview(value) c._rawJSON = json.RawMessage(data) return nil } -func (c *ClimateSettingSchedulesDeleteResponse) String() string { +func (c *ConnectWebview) String() string { if len(c._rawJSON) > 0 { if value, err := core.StringifyJSON(c._rawJSON); err == nil { return value @@ -841,134 +848,86 @@ func (c *ClimateSettingSchedulesDeleteResponse) String() string { return fmt.Sprintf("%#v", c) } -type ClimateSettingSchedulesGetResponse struct { - ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` - Ok bool `json:"ok"` - - _rawJSON json.RawMessage -} - -func (c *ClimateSettingSchedulesGetResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ClimateSettingSchedulesGetResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ClimateSettingSchedulesGetResponse(value) - c._rawJSON = json.RawMessage(data) - return nil -} - -func (c *ClimateSettingSchedulesGetResponse) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) +type ConnectWebviewCustomMetadataValue struct { + typeName string + String string + Boolean bool } -type ClimateSettingSchedulesListResponse struct { - ClimateSettingSchedules []*ClimateSettingSchedule `json:"climate_setting_schedules,omitempty"` - Ok bool `json:"ok"` - - _rawJSON json.RawMessage +func NewConnectWebviewCustomMetadataValueFromString(value string) *ConnectWebviewCustomMetadataValue { + return &ConnectWebviewCustomMetadataValue{typeName: "string", String: value} } -func (c *ClimateSettingSchedulesListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ClimateSettingSchedulesListResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ClimateSettingSchedulesListResponse(value) - c._rawJSON = json.RawMessage(data) - return nil +func NewConnectWebviewCustomMetadataValueFromBoolean(value bool) *ConnectWebviewCustomMetadataValue { + return &ConnectWebviewCustomMetadataValue{typeName: "boolean", Boolean: value} } -func (c *ClimateSettingSchedulesListResponse) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } +func (c *ConnectWebviewCustomMetadataValue) UnmarshalJSON(data []byte) error { + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + c.typeName = "string" + c.String = valueString + return nil } - if value, err := core.StringifyJSON(c); err == nil { - return value + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + c.typeName = "boolean" + c.Boolean = valueBoolean + return nil } - return fmt.Sprintf("%#v", c) + return fmt.Errorf("%s cannot be deserialized as a %T", data, c) } -type ClimateSettingSchedulesUpdateResponse struct { - ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` - Ok bool `json:"ok"` - - _rawJSON json.RawMessage +func (c ConnectWebviewCustomMetadataValue) MarshalJSON() ([]byte, error) { + switch c.typeName { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.typeName, c) + case "string": + return json.Marshal(c.String) + case "boolean": + return json.Marshal(c.Boolean) + } } -func (c *ClimateSettingSchedulesUpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ClimateSettingSchedulesUpdateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ClimateSettingSchedulesUpdateResponse(value) - c._rawJSON = json.RawMessage(data) - return nil +type ConnectWebviewCustomMetadataValueVisitor interface { + VisitString(string) error + VisitBoolean(bool) error } -func (c *ClimateSettingSchedulesUpdateResponse) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value +func (c *ConnectWebviewCustomMetadataValue) Accept(visitor ConnectWebviewCustomMetadataValueVisitor) error { + switch c.typeName { + default: + return fmt.Errorf("invalid type %s in %T", c.typeName, c) + case "string": + return visitor.VisitString(c.String) + case "boolean": + return visitor.VisitBoolean(c.Boolean) } - return fmt.Sprintf("%#v", c) } -type ConnectWebview struct { - ConnectWebviewId string `json:"connect_webview_id"` - ConnectedAccountId *string `json:"connected_account_id,omitempty"` - Url string `json:"url"` - WorkspaceId string `json:"workspace_id"` - DeviceSelectionMode SelectionMode `json:"device_selection_mode,omitempty"` - AcceptedProviders []string `json:"accepted_providers,omitempty"` - AcceptedDevices []string `json:"accepted_devices,omitempty"` - AnyProviderAllowed bool `json:"any_provider_allowed"` - AnyDeviceAllowed bool `json:"any_device_allowed"` - CreatedAt time.Time `json:"created_at"` - LoginSuccessful bool `json:"login_successful"` - Status ConnectWebviewStatus `json:"status,omitempty"` +type ConnectWebviewDeviceSelectionMode string - _rawJSON json.RawMessage -} +const ( + ConnectWebviewDeviceSelectionModeNone ConnectWebviewDeviceSelectionMode = "none" + ConnectWebviewDeviceSelectionModeSingle ConnectWebviewDeviceSelectionMode = "single" + ConnectWebviewDeviceSelectionModeMultiple ConnectWebviewDeviceSelectionMode = "multiple" +) -func (c *ConnectWebview) UnmarshalJSON(data []byte) error { - type unmarshaler ConnectWebview - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ConnectWebview(value) - c._rawJSON = json.RawMessage(data) - return nil +func NewConnectWebviewDeviceSelectionModeFromString(s string) (ConnectWebviewDeviceSelectionMode, error) { + switch s { + case "none": + return ConnectWebviewDeviceSelectionModeNone, nil + case "single": + return ConnectWebviewDeviceSelectionModeSingle, nil + case "multiple": + return ConnectWebviewDeviceSelectionModeMultiple, nil + } + var t ConnectWebviewDeviceSelectionMode + return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (c *ConnectWebview) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) +func (c ConnectWebviewDeviceSelectionMode) Ptr() *ConnectWebviewDeviceSelectionMode { + return &c } type ConnectWebviewStatus string @@ -997,13 +956,15 @@ func (c ConnectWebviewStatus) Ptr() *ConnectWebviewStatus { } type ConnectedAccount struct { - ConnectedAccountId *string `json:"connected_account_id,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UserIdentifier *ConnectedAccountUserIdentifier `json:"user_identifier,omitempty"` - AccountType *string `json:"account_type,omitempty"` - Errors interface{} `json:"errors,omitempty"` - Warnings interface{} `json:"warnings,omitempty"` - CustomMetadata map[string]*ConnectedAccountCustomMetadataValue `json:"custom_metadata,omitempty"` + ConnectedAccountId *string `json:"connected_account_id,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UserIdentifier *ConnectedAccountUserIdentifier `json:"user_identifier,omitempty"` + AccountType *string `json:"account_type,omitempty"` + AccountTypeDisplayName string `json:"account_type_display_name"` + Errors interface{} `json:"errors,omitempty"` + Warnings interface{} `json:"warnings,omitempty"` + CustomMetadata map[string]*ConnectedAccountCustomMetadataValue `json:"custom_metadata,omitempty"` + AutomaticallyManageNewDevices bool `json:"automatically_manage_new_devices"` _rawJSON json.RawMessage } @@ -1032,29 +993,19 @@ func (c *ConnectedAccount) String() string { } type ConnectedAccountCustomMetadataValue struct { - typeName string - String string - Double float64 - Boolean bool - StringOptional *string + typeName string + String string + Boolean bool } func NewConnectedAccountCustomMetadataValueFromString(value string) *ConnectedAccountCustomMetadataValue { return &ConnectedAccountCustomMetadataValue{typeName: "string", String: value} } -func NewConnectedAccountCustomMetadataValueFromDouble(value float64) *ConnectedAccountCustomMetadataValue { - return &ConnectedAccountCustomMetadataValue{typeName: "double", Double: value} -} - func NewConnectedAccountCustomMetadataValueFromBoolean(value bool) *ConnectedAccountCustomMetadataValue { return &ConnectedAccountCustomMetadataValue{typeName: "boolean", Boolean: value} } -func NewConnectedAccountCustomMetadataValueFromStringOptional(value *string) *ConnectedAccountCustomMetadataValue { - return &ConnectedAccountCustomMetadataValue{typeName: "stringOptional", StringOptional: value} -} - func (c *ConnectedAccountCustomMetadataValue) UnmarshalJSON(data []byte) error { var valueString string if err := json.Unmarshal(data, &valueString); err == nil { @@ -1062,24 +1013,12 @@ func (c *ConnectedAccountCustomMetadataValue) UnmarshalJSON(data []byte) error { c.String = valueString return nil } - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - c.typeName = "double" - c.Double = valueDouble - return nil - } var valueBoolean bool if err := json.Unmarshal(data, &valueBoolean); err == nil { c.typeName = "boolean" c.Boolean = valueBoolean return nil } - var valueStringOptional *string - if err := json.Unmarshal(data, &valueStringOptional); err == nil { - c.typeName = "stringOptional" - c.StringOptional = valueStringOptional - return nil - } return fmt.Errorf("%s cannot be deserialized as a %T", data, c) } @@ -1089,20 +1028,14 @@ func (c ConnectedAccountCustomMetadataValue) MarshalJSON() ([]byte, error) { return nil, fmt.Errorf("invalid type %s in %T", c.typeName, c) case "string": return json.Marshal(c.String) - case "double": - return json.Marshal(c.Double) case "boolean": return json.Marshal(c.Boolean) - case "stringOptional": - return json.Marshal(c.StringOptional) } } type ConnectedAccountCustomMetadataValueVisitor interface { VisitString(string) error - VisitDouble(float64) error VisitBoolean(bool) error - VisitStringOptional(*string) error } func (c *ConnectedAccountCustomMetadataValue) Accept(visitor ConnectedAccountCustomMetadataValueVisitor) error { @@ -1111,12 +1044,8 @@ func (c *ConnectedAccountCustomMetadataValue) Accept(visitor ConnectedAccountCus return fmt.Errorf("invalid type %s in %T", c.typeName, c) case "string": return visitor.VisitString(c.String) - case "double": - return visitor.VisitDouble(c.Double) case "boolean": return visitor.VisitBoolean(c.Boolean) - case "stringOptional": - return visitor.VisitStringOptional(c.StringOptional) } } @@ -1153,128 +1082,231 @@ func (c *ConnectedAccountUserIdentifier) String() string { return fmt.Sprintf("%#v", c) } -type ConnectedAccountsGetRequestConnectedAccountId struct { +type Device struct { + // Unique identifier for the device. + DeviceId string `json:"device_id"` + // Type of the device. + DeviceType DeviceType `json:"device_type,omitempty"` + // Collection of capabilities that the device supports when connected to Seam. Values are "access_code," which indicates that the device can manage and utilize digital PIN codes for secure access; "lock," which indicates that the device controls a door locking mechanism, enabling the remote opening and closing of doors and other entry points; "noise_detection," which indicates that the device supports monitoring and responding to ambient noise levels; "thermostat," which indicates that the device can regulate and adjust indoor temperatures; and "battery," which indicates that the device can manage battery life and health. + CapabilitiesSupported []DeviceCapabilitiesSupportedItem `json:"capabilities_supported,omitempty"` + // Properties of the device. + Properties *DeviceProperties `json:"properties,omitempty"` + // Location information for the device. + Location *DeviceLocation `json:"location,omitempty"` + // Unique identifier for the account associated with the device. ConnectedAccountId string `json:"connected_account_id"` + // Unique identifier for the Seam workspace associated with the device. + WorkspaceId string `json:"workspace_id"` + // Array of errors associated with the device. Each error object within the array contains two fields: "error_code" and "message." "error_code" is a string that uniquely identifies the type of error, enabling quick recognition and categorization of the issue. "message" provides a more detailed description of the error, offering insights into the issue and potentially how to rectify it. + Errors []*DeviceErrorsItem `json:"errors,omitempty"` + // Array of warnings associated with the device. Each warning object within the array contains two fields: "warning_code" and "message." "warning_code" is a string that uniquely identifies the type of warning, enabling quick recognition and categorization of the issue. "message" provides a more detailed description of the warning, offering insights into the issue and potentially how to rectify it. + Warnings []*DeviceWarningsItem `json:"warnings,omitempty"` + // Date and time at which the device object was created. + CreatedAt time.Time `json:"created_at"` + // Indicates whether Seam manages the device. + IsManaged string `json:"is_managed"` _rawJSON json.RawMessage } -func (c *ConnectedAccountsGetRequestConnectedAccountId) UnmarshalJSON(data []byte) error { - type unmarshaler ConnectedAccountsGetRequestConnectedAccountId +func (d *Device) UnmarshalJSON(data []byte) error { + type unmarshaler Device var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *c = ConnectedAccountsGetRequestConnectedAccountId(value) - c._rawJSON = json.RawMessage(data) + *d = Device(value) + d._rawJSON = json.RawMessage(data) return nil } -func (c *ConnectedAccountsGetRequestConnectedAccountId) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { +func (d *Device) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(c); err == nil { + if value, err := core.StringifyJSON(d); err == nil { return value } - return fmt.Sprintf("%#v", c) + return fmt.Sprintf("%#v", d) } -type ConnectedAccountsGetRequestEmail struct { - Email string `json:"email"` +type DeviceCapabilitiesSupportedItem string + +const ( + DeviceCapabilitiesSupportedItemAccessCode DeviceCapabilitiesSupportedItem = "access_code" + DeviceCapabilitiesSupportedItemLock DeviceCapabilitiesSupportedItem = "lock" + DeviceCapabilitiesSupportedItemNoiseDetection DeviceCapabilitiesSupportedItem = "noise_detection" + DeviceCapabilitiesSupportedItemThermostat DeviceCapabilitiesSupportedItem = "thermostat" + DeviceCapabilitiesSupportedItemBattery DeviceCapabilitiesSupportedItem = "battery" + DeviceCapabilitiesSupportedItemPhone DeviceCapabilitiesSupportedItem = "phone" +) + +func NewDeviceCapabilitiesSupportedItemFromString(s string) (DeviceCapabilitiesSupportedItem, error) { + switch s { + case "access_code": + return DeviceCapabilitiesSupportedItemAccessCode, nil + case "lock": + return DeviceCapabilitiesSupportedItemLock, nil + case "noise_detection": + return DeviceCapabilitiesSupportedItemNoiseDetection, nil + case "thermostat": + return DeviceCapabilitiesSupportedItemThermostat, nil + case "battery": + return DeviceCapabilitiesSupportedItemBattery, nil + case "phone": + return DeviceCapabilitiesSupportedItemPhone, nil + } + var t DeviceCapabilitiesSupportedItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DeviceCapabilitiesSupportedItem) Ptr() *DeviceCapabilitiesSupportedItem { + return &d +} + +type DeviceErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` _rawJSON json.RawMessage } -func (c *ConnectedAccountsGetRequestEmail) UnmarshalJSON(data []byte) error { - type unmarshaler ConnectedAccountsGetRequestEmail +func (d *DeviceErrorsItem) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceErrorsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *c = ConnectedAccountsGetRequestEmail(value) - c._rawJSON = json.RawMessage(data) + *d = DeviceErrorsItem(value) + d._rawJSON = json.RawMessage(data) return nil } -func (c *ConnectedAccountsGetRequestEmail) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { +func (d *DeviceErrorsItem) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(c); err == nil { + if value, err := core.StringifyJSON(d); err == nil { return value } - return fmt.Sprintf("%#v", c) + return fmt.Sprintf("%#v", d) } -type CurrentClimateSetting struct { - AutomaticHeatingEnabled *bool `json:"automatic_heating_enabled,omitempty"` - AutomaticCoolingEnabled *bool `json:"automatic_cooling_enabled,omitempty"` - HvacModeSetting *string `json:"hvac_mode_setting,omitempty"` - CoolingSetPointCelsius *float64 `json:"cooling_set_point_celsius,omitempty"` - HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` - CoolingSetPointFahrenheit *float64 `json:"cooling_set_point_fahrenheit,omitempty"` - HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` - ManualOverrideAllowed *bool `json:"manual_override_allowed,omitempty"` +// Location information for the device. +type DeviceLocation struct { + // Name of the device location. + LocationName *string `json:"location_name,omitempty"` + // Time zone of the device location. + Timezone *string `json:"timezone,omitempty"` _rawJSON json.RawMessage } -func (c *CurrentClimateSetting) UnmarshalJSON(data []byte) error { - type unmarshaler CurrentClimateSetting +func (d *DeviceLocation) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceLocation var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *c = CurrentClimateSetting(value) - c._rawJSON = json.RawMessage(data) + *d = DeviceLocation(value) + d._rawJSON = json.RawMessage(data) return nil } -func (c *CurrentClimateSetting) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { +func (d *DeviceLocation) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(c); err == nil { + if value, err := core.StringifyJSON(d); err == nil { return value } - return fmt.Sprintf("%#v", c) + return fmt.Sprintf("%#v", d) } -type Device struct { - DeviceId string `json:"device_id"` - DeviceType DeviceType `json:"device_type,omitempty"` - CapabilitiesSupported []DeviceCapabilitiesSupportedItem `json:"capabilities_supported,omitempty"` - Properties *DeviceProperties `json:"properties,omitempty"` - Location interface{} `json:"location,omitempty"` - ConnectedAccountId string `json:"connected_account_id"` - WorkspaceId string `json:"workspace_id"` - Errors []*DeviceErrorsItem `json:"errors,omitempty"` - Warnings []*DeviceWarningsItem `json:"warnings,omitempty"` - CreatedAt time.Time `json:"created_at"` - IsManaged bool `json:"is_managed"` +// Properties of the device. +type DeviceProperties struct { + // Indicates whether the device is online. + Online bool `json:"online"` + // Name of the device. Enables administrators and users to identify the device easily, especially when there are numerous devices. + Name string `json:"name"` + Model *DevicePropertiesModel `json:"model,omitempty"` + // Indicates whether the device has direct power. + HasDirectPower *bool `json:"has_direct_power,omitempty"` + // Indicates the battery level of the device as a decimal value between 0 and 1, inclusive. + BatteryLevel *float64 `json:"battery_level,omitempty"` + // Represents the current status of the battery charge level. Values are "critical," which indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging; "low," which signifies that the battery is under the preferred threshold and should be charged soon; "good," which denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging; and "full," which represents a battery that is fully charged, providing the maximum duration of usage. + Battery *DevicePropertiesBattery `json:"battery,omitempty"` + // Manufacturer of the device. + Manufacturer *string `json:"manufacturer,omitempty"` + // Image URL for the device. + ImageUrl *string `json:"image_url,omitempty"` + // Alt text for the device image. + ImageAltText *string `json:"image_alt_text,omitempty"` + // Serial number of the device. + SerialNumber *string `json:"serial_number,omitempty"` + // Indicates whether it is currently possible to use online access codes for the device. + OnlineAccessCodesEnabled *bool `json:"online_access_codes_enabled,omitempty"` + // Indicates whether it is currently possible to use offline access codes for the device. + OfflineAccessCodesEnabled *bool `json:"offline_access_codes_enabled,omitempty"` + // Deprecated. Use model.accessory_keypad_supported. + SupportsAccessoryKeypad *bool `json:"supports_accessory_keypad,omitempty"` + // Deprecated. Use offline_access_codes_enabled. + SupportsOfflineAccessCodes *bool `json:"supports_offline_access_codes,omitempty"` + AugustMetadata *DevicePropertiesAugustMetadata `json:"august_metadata,omitempty"` + AvigilonAltaMetadata *DevicePropertiesAvigilonAltaMetadata `json:"avigilon_alta_metadata,omitempty"` + SchlageMetadata *DevicePropertiesSchlageMetadata `json:"schlage_metadata,omitempty"` + SmartthingsMetadata *DevicePropertiesSmartthingsMetadata `json:"smartthings_metadata,omitempty"` + LocklyMetadata *DevicePropertiesLocklyMetadata `json:"lockly_metadata,omitempty"` + NukiMetadata *DevicePropertiesNukiMetadata `json:"nuki_metadata,omitempty"` + KwiksetMetadata *DevicePropertiesKwiksetMetadata `json:"kwikset_metadata,omitempty"` + SaltoMetadata *DevicePropertiesSaltoMetadata `json:"salto_metadata,omitempty"` + GenieMetadata *DevicePropertiesGenieMetadata `json:"genie_metadata,omitempty"` + BrivoMetadata *DevicePropertiesBrivoMetadata `json:"brivo_metadata,omitempty"` + IglooMetadata *DevicePropertiesIglooMetadata `json:"igloo_metadata,omitempty"` + NoiseawareMetadata *DevicePropertiesNoiseawareMetadata `json:"noiseaware_metadata,omitempty"` + MinutMetadata *DevicePropertiesMinutMetadata `json:"minut_metadata,omitempty"` + FourSuitesMetadata *DevicePropertiesFourSuitesMetadata `json:"four_suites_metadata,omitempty"` + TwoNMetadata *DevicePropertiesTwoNMetadata `json:"two_n_metadata,omitempty"` + ControlbywebMetadata *DevicePropertiesControlbywebMetadata `json:"controlbyweb_metadata,omitempty"` + TtlockMetadata *DevicePropertiesTtlockMetadata `json:"ttlock_metadata,omitempty"` + SeamBridgeMetadata *DevicePropertiesSeamBridgeMetadata `json:"seam_bridge_metadata,omitempty"` + IgloohomeMetadata *DevicePropertiesIgloohomeMetadata `json:"igloohome_metadata,omitempty"` + NestMetadata *DevicePropertiesNestMetadata `json:"nest_metadata,omitempty"` + EcobeeMetadata *DevicePropertiesEcobeeMetadata `json:"ecobee_metadata,omitempty"` + HubitatMetadata *DevicePropertiesHubitatMetadata `json:"hubitat_metadata,omitempty"` + DormakabaOracodeMetadata *DevicePropertiesDormakabaOracodeMetadata `json:"dormakaba_oracode_metadata,omitempty"` + WyzeMetadata *DevicePropertiesWyzeMetadata `json:"wyze_metadata,omitempty"` + CodeConstraints []*DevicePropertiesCodeConstraintsItem `json:"code_constraints,omitempty"` + SupportedCodeLengths []float64 `json:"supported_code_lengths,omitempty"` + MaxActiveCodesSupported *float64 `json:"max_active_codes_supported,omitempty"` + SupportsBackupAccessCodePool *bool `json:"supports_backup_access_code_pool,omitempty"` + HasNativeEntryEvents *bool `json:"has_native_entry_events,omitempty"` + Locked *bool `json:"locked,omitempty"` + KeypadBattery *DevicePropertiesKeypadBattery `json:"keypad_battery,omitempty"` + DoorOpen *bool `json:"door_open,omitempty"` + AssaAbloyCredentialServiceMetadata *DevicePropertiesAssaAbloyCredentialServiceMetadata `json:"assa_abloy_credential_service_metadata,omitempty"` _rawJSON json.RawMessage } -func (d *Device) UnmarshalJSON(data []byte) error { - type unmarshaler Device +func (d *DeviceProperties) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceProperties var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = Device(value) + *d = DeviceProperties(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *Device) String() string { +func (d *DeviceProperties) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1286,56 +1318,25 @@ func (d *Device) String() string { return fmt.Sprintf("%#v", d) } -type DeviceCapabilitiesSupportedItem string - -const ( - DeviceCapabilitiesSupportedItemAccessCode DeviceCapabilitiesSupportedItem = "access_code" - DeviceCapabilitiesSupportedItemLock DeviceCapabilitiesSupportedItem = "lock" - DeviceCapabilitiesSupportedItemNoiseDetection DeviceCapabilitiesSupportedItem = "noise_detection" - DeviceCapabilitiesSupportedItemThermostat DeviceCapabilitiesSupportedItem = "thermostat" - DeviceCapabilitiesSupportedItemBattery DeviceCapabilitiesSupportedItem = "battery" -) - -func NewDeviceCapabilitiesSupportedItemFromString(s string) (DeviceCapabilitiesSupportedItem, error) { - switch s { - case "access_code": - return DeviceCapabilitiesSupportedItemAccessCode, nil - case "lock": - return DeviceCapabilitiesSupportedItemLock, nil - case "noise_detection": - return DeviceCapabilitiesSupportedItemNoiseDetection, nil - case "thermostat": - return DeviceCapabilitiesSupportedItemThermostat, nil - case "battery": - return DeviceCapabilitiesSupportedItemBattery, nil - } - var t DeviceCapabilitiesSupportedItem - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (d DeviceCapabilitiesSupportedItem) Ptr() *DeviceCapabilitiesSupportedItem { - return &d -} - -type DeviceErrorsItem struct { - ErrorCode string `json:"error_code"` - Message string `json:"message"` +type DevicePropertiesAssaAbloyCredentialServiceMetadata struct { + HasActiveEndpoint bool `json:"has_active_endpoint"` + Endpoints []*DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem `json:"endpoints,omitempty"` _rawJSON json.RawMessage } -func (d *DeviceErrorsItem) UnmarshalJSON(data []byte) error { - type unmarshaler DeviceErrorsItem +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesAssaAbloyCredentialServiceMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DeviceErrorsItem(value) + *d = DevicePropertiesAssaAbloyCredentialServiceMetadata(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DeviceErrorsItem) String() string { +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadata) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1347,30 +1348,25 @@ func (d *DeviceErrorsItem) String() string { return fmt.Sprintf("%#v", d) } -type DeviceProperties struct { - Online bool `json:"online"` - Name string `json:"name"` - Model *DevicePropertiesModel `json:"model,omitempty"` - AugustMetadata *AugustDeviceMetadata `json:"august_metadata,omitempty"` - SchlageMetadata *SchlageDeviceMetadata `json:"schlage_metadata,omitempty"` - SmartthingsMetadata interface{} `json:"smartthings_metadata,omitempty"` - CurrentClimateSetting *CurrentClimateSetting `json:"current_climate_setting,omitempty"` +type DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem struct { + EndpointId string `json:"endpoint_id"` + IsActive bool `json:"is_active"` _rawJSON json.RawMessage } -func (d *DeviceProperties) UnmarshalJSON(data []byte) error { - type unmarshaler DeviceProperties +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DeviceProperties(value) + *d = DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DeviceProperties) String() string { +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1382,24 +1378,30 @@ func (d *DeviceProperties) String() string { return fmt.Sprintf("%#v", d) } -type DevicePropertiesModel struct { - DisplayName string `json:"display_name"` +type DevicePropertiesAugustMetadata struct { + LockId string `json:"lock_id"` + LockName string `json:"lock_name"` + HouseName string `json:"house_name"` + HasKeypad bool `json:"has_keypad"` + KeypadBatteryLevel *string `json:"keypad_battery_level,omitempty"` + Model *string `json:"model,omitempty"` + HouseId *string `json:"house_id,omitempty"` _rawJSON json.RawMessage } -func (d *DevicePropertiesModel) UnmarshalJSON(data []byte) error { - type unmarshaler DevicePropertiesModel +func (d *DevicePropertiesAugustMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesAugustMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DevicePropertiesModel(value) + *d = DevicePropertiesAugustMetadata(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DevicePropertiesModel) String() string { +func (d *DevicePropertiesAugustMetadata) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1411,116 +1413,29 @@ func (d *DevicePropertiesModel) String() string { return fmt.Sprintf("%#v", d) } -type DeviceType string - -const ( - DeviceTypeAkuvoxLock DeviceType = "akuvox_lock" - DeviceTypeAugustLock DeviceType = "august_lock" - DeviceTypeBrivoAccessPoint DeviceType = "brivo_access_point" - DeviceTypeButterflymxPanel DeviceType = "butterflymx_panel" - DeviceTypeDoorkingLock DeviceType = "doorking_lock" - DeviceTypeGenieDoor DeviceType = "genie_door" - DeviceTypeIglooLock DeviceType = "igloo_lock" - DeviceTypeLinearLock DeviceType = "linear_lock" - DeviceTypeLocklyLock DeviceType = "lockly_lock" - DeviceTypeKwiksetLock DeviceType = "kwikset_lock" - DeviceTypeNukiLock DeviceType = "nuki_lock" - DeviceTypeSaltoLock DeviceType = "salto_lock" - DeviceTypeSchlageLock DeviceType = "schlage_lock" - DeviceTypeSeamRelay DeviceType = "seam_relay" - DeviceTypeSmartthingsLock DeviceType = "smartthings_lock" - DeviceTypeYaleLock DeviceType = "yale_lock" - DeviceTypeTwoNIntercom DeviceType = "two_n_intercom" - DeviceTypeControlbywebDevice DeviceType = "controlbyweb_device" - DeviceTypeTtlockLock DeviceType = "ttlock_lock" - DeviceTypeIgloohomeLock DeviceType = "igloohome_lock" - DeviceTypeHubitatLock DeviceType = "hubitat_lock" - DeviceTypeNoiseawareActivityZone DeviceType = "noiseaware_activity_zone" - DeviceTypeMinutSensor DeviceType = "minut_sensor" - DeviceTypeEcobeeThermostat DeviceType = "ecobee_thermostat" - DeviceTypeNestThermostat DeviceType = "nest_thermostat" -) - -func NewDeviceTypeFromString(s string) (DeviceType, error) { - switch s { - case "akuvox_lock": - return DeviceTypeAkuvoxLock, nil - case "august_lock": - return DeviceTypeAugustLock, nil - case "brivo_access_point": - return DeviceTypeBrivoAccessPoint, nil - case "butterflymx_panel": - return DeviceTypeButterflymxPanel, nil - case "doorking_lock": - return DeviceTypeDoorkingLock, nil - case "genie_door": - return DeviceTypeGenieDoor, nil - case "igloo_lock": - return DeviceTypeIglooLock, nil - case "linear_lock": - return DeviceTypeLinearLock, nil - case "lockly_lock": - return DeviceTypeLocklyLock, nil - case "kwikset_lock": - return DeviceTypeKwiksetLock, nil - case "nuki_lock": - return DeviceTypeNukiLock, nil - case "salto_lock": - return DeviceTypeSaltoLock, nil - case "schlage_lock": - return DeviceTypeSchlageLock, nil - case "seam_relay": - return DeviceTypeSeamRelay, nil - case "smartthings_lock": - return DeviceTypeSmartthingsLock, nil - case "yale_lock": - return DeviceTypeYaleLock, nil - case "two_n_intercom": - return DeviceTypeTwoNIntercom, nil - case "controlbyweb_device": - return DeviceTypeControlbywebDevice, nil - case "ttlock_lock": - return DeviceTypeTtlockLock, nil - case "igloohome_lock": - return DeviceTypeIgloohomeLock, nil - case "hubitat_lock": - return DeviceTypeHubitatLock, nil - case "noiseaware_activity_zone": - return DeviceTypeNoiseawareActivityZone, nil - case "minut_sensor": - return DeviceTypeMinutSensor, nil - case "ecobee_thermostat": - return DeviceTypeEcobeeThermostat, nil - case "nest_thermostat": - return DeviceTypeNestThermostat, nil - } - var t DeviceType - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (d DeviceType) Ptr() *DeviceType { - return &d -} - -type DeviceWarningsItem struct { - WarningCode string `json:"warning_code"` - Message string `json:"message"` +type DevicePropertiesAvigilonAltaMetadata struct { + EntryName string `json:"entry_name"` + OrgName string `json:"org_name"` + ZoneId float64 `json:"zone_id"` + ZoneName string `json:"zone_name"` + SiteId float64 `json:"site_id"` + SiteName string `json:"site_name"` _rawJSON json.RawMessage } -func (d *DeviceWarningsItem) UnmarshalJSON(data []byte) error { - type unmarshaler DeviceWarningsItem +func (d *DevicePropertiesAvigilonAltaMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesAvigilonAltaMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DeviceWarningsItem(value) + *d = DevicePropertiesAvigilonAltaMetadata(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DeviceWarningsItem) String() string { +func (d *DevicePropertiesAvigilonAltaMetadata) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1532,27 +1447,26 @@ func (d *DeviceWarningsItem) String() string { return fmt.Sprintf("%#v", d) } -type DevicesListDeviceProvidersResponseDeviceProvidersItem struct { - DeviceProviderName string `json:"device_provider_name"` - DisplayName string `json:"display_name"` - ImageUrl string `json:"image_url"` - ProviderCategories []DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem `json:"provider_categories,omitempty"` +// Represents the current status of the battery charge level. Values are "critical," which indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging; "low," which signifies that the battery is under the preferred threshold and should be charged soon; "good," which denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging; and "full," which represents a battery that is fully charged, providing the maximum duration of usage. +type DevicePropertiesBattery struct { + Level float64 `json:"level"` + Status DevicePropertiesBatteryStatus `json:"status,omitempty"` _rawJSON json.RawMessage } -func (d *DevicesListDeviceProvidersResponseDeviceProvidersItem) UnmarshalJSON(data []byte) error { - type unmarshaler DevicesListDeviceProvidersResponseDeviceProvidersItem +func (d *DevicePropertiesBattery) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesBattery var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DevicesListDeviceProvidersResponseDeviceProvidersItem(value) + *d = DevicePropertiesBattery(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DevicesListDeviceProvidersResponseDeviceProvidersItem) String() string { +func (d *DevicePropertiesBattery) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1564,159 +1478,1566 @@ func (d *DevicesListDeviceProvidersResponseDeviceProvidersItem) String() string return fmt.Sprintf("%#v", d) } -type DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem string +type DevicePropertiesBatteryStatus string const ( - DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = "stable" - DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = "consumer_smartlocks" + DevicePropertiesBatteryStatusCritical DevicePropertiesBatteryStatus = "critical" + DevicePropertiesBatteryStatusLow DevicePropertiesBatteryStatus = "low" + DevicePropertiesBatteryStatusGood DevicePropertiesBatteryStatus = "good" + DevicePropertiesBatteryStatusFull DevicePropertiesBatteryStatus = "full" ) -func NewDevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemFromString(s string) (DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem, error) { +func NewDevicePropertiesBatteryStatusFromString(s string) (DevicePropertiesBatteryStatus, error) { switch s { - case "stable": - return DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable, nil - case "consumer_smartlocks": - return DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks, nil - } - var t DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem + case "critical": + return DevicePropertiesBatteryStatusCritical, nil + case "low": + return DevicePropertiesBatteryStatusLow, nil + case "good": + return DevicePropertiesBatteryStatusGood, nil + case "full": + return DevicePropertiesBatteryStatusFull, nil + } + var t DevicePropertiesBatteryStatus return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (d DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem) Ptr() *DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem { +func (d DevicePropertiesBatteryStatus) Ptr() *DevicePropertiesBatteryStatus { return &d } -type Event struct { - EventId string `json:"event_id"` - DeviceId *string `json:"device_id,omitempty"` - EventType string `json:"event_type"` - WorkspaceId string `json:"workspace_id"` - CreatedAt time.Time `json:"created_at"` - OccurredAt time.Time `json:"occurred_at"` +type DevicePropertiesBrivoMetadata struct { + DeviceName string `json:"device_name"` _rawJSON json.RawMessage } -func (e *Event) UnmarshalJSON(data []byte) error { - type unmarshaler Event +func (d *DevicePropertiesBrivoMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesBrivoMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *e = Event(value) - e._rawJSON = json.RawMessage(data) + *d = DevicePropertiesBrivoMetadata(value) + d._rawJSON = json.RawMessage(data) return nil } -func (e *Event) String() string { - if len(e._rawJSON) > 0 { - if value, err := core.StringifyJSON(e._rawJSON); err == nil { +func (d *DevicePropertiesBrivoMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(e); err == nil { + if value, err := core.StringifyJSON(d); err == nil { return value } - return fmt.Sprintf("%#v", e) + return fmt.Sprintf("%#v", d) } -type HvacModeSetting string +type DevicePropertiesCodeConstraintsItem struct { + typeName string + DevicePropertiesCodeConstraintsItemZero *DevicePropertiesCodeConstraintsItemZero + DevicePropertiesCodeConstraintsItemMaxLength *DevicePropertiesCodeConstraintsItemMaxLength +} -const ( - HvacModeSettingOff HvacModeSetting = "off" - HvacModeSettingHeat HvacModeSetting = "heat" - HvacModeSettingCool HvacModeSetting = "cool" - HvacModeSettingHeatCool HvacModeSetting = "heat_cool" -) +func NewDevicePropertiesCodeConstraintsItemFromDevicePropertiesCodeConstraintsItemZero(value *DevicePropertiesCodeConstraintsItemZero) *DevicePropertiesCodeConstraintsItem { + return &DevicePropertiesCodeConstraintsItem{typeName: "devicePropertiesCodeConstraintsItemZero", DevicePropertiesCodeConstraintsItemZero: value} +} -func NewHvacModeSettingFromString(s string) (HvacModeSetting, error) { - switch s { - case "off": - return HvacModeSettingOff, nil - case "heat": - return HvacModeSettingHeat, nil - case "cool": - return HvacModeSettingCool, nil - case "heat_cool": - return HvacModeSettingHeatCool, nil +func NewDevicePropertiesCodeConstraintsItemFromDevicePropertiesCodeConstraintsItemMaxLength(value *DevicePropertiesCodeConstraintsItemMaxLength) *DevicePropertiesCodeConstraintsItem { + return &DevicePropertiesCodeConstraintsItem{typeName: "devicePropertiesCodeConstraintsItemMaxLength", DevicePropertiesCodeConstraintsItemMaxLength: value} +} + +func (d *DevicePropertiesCodeConstraintsItem) UnmarshalJSON(data []byte) error { + valueDevicePropertiesCodeConstraintsItemZero := new(DevicePropertiesCodeConstraintsItemZero) + if err := json.Unmarshal(data, &valueDevicePropertiesCodeConstraintsItemZero); err == nil { + d.typeName = "devicePropertiesCodeConstraintsItemZero" + d.DevicePropertiesCodeConstraintsItemZero = valueDevicePropertiesCodeConstraintsItemZero + return nil } - var t HvacModeSetting - return "", fmt.Errorf("%s is not a valid %T", s, t) + valueDevicePropertiesCodeConstraintsItemMaxLength := new(DevicePropertiesCodeConstraintsItemMaxLength) + if err := json.Unmarshal(data, &valueDevicePropertiesCodeConstraintsItemMaxLength); err == nil { + d.typeName = "devicePropertiesCodeConstraintsItemMaxLength" + d.DevicePropertiesCodeConstraintsItemMaxLength = valueDevicePropertiesCodeConstraintsItemMaxLength + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, d) } -func (h HvacModeSetting) Ptr() *HvacModeSetting { - return &h +func (d DevicePropertiesCodeConstraintsItem) MarshalJSON() ([]byte, error) { + switch d.typeName { + default: + return nil, fmt.Errorf("invalid type %s in %T", d.typeName, d) + case "devicePropertiesCodeConstraintsItemZero": + return json.Marshal(d.DevicePropertiesCodeConstraintsItemZero) + case "devicePropertiesCodeConstraintsItemMaxLength": + return json.Marshal(d.DevicePropertiesCodeConstraintsItemMaxLength) + } } -type Manufacturer string +type DevicePropertiesCodeConstraintsItemVisitor interface { + VisitDevicePropertiesCodeConstraintsItemZero(*DevicePropertiesCodeConstraintsItemZero) error + VisitDevicePropertiesCodeConstraintsItemMaxLength(*DevicePropertiesCodeConstraintsItemMaxLength) error +} -const ( - ManufacturerAkuvox Manufacturer = "akuvox" - ManufacturerAugust Manufacturer = "august" - ManufacturerBrivo Manufacturer = "brivo" - ManufacturerButterflymx Manufacturer = "butterflymx" - ManufacturerDoorking Manufacturer = "doorking" - ManufacturerGenie Manufacturer = "genie" - ManufacturerIgloo Manufacturer = "igloo" - ManufacturerKeywe Manufacturer = "keywe" - ManufacturerKwikset Manufacturer = "kwikset" - ManufacturerLinear Manufacturer = "linear" - ManufacturerLockly Manufacturer = "lockly" - ManufacturerNuki Manufacturer = "nuki" - ManufacturerPhilia Manufacturer = "philia" - ManufacturerSalto Manufacturer = "salto" - ManufacturerSamsung Manufacturer = "samsung" - ManufacturerSchlage Manufacturer = "schlage" - ManufacturerSeam Manufacturer = "seam" - ManufacturerUnknown Manufacturer = "unknown" - ManufacturerYale Manufacturer = "yale" - ManufacturerMinut Manufacturer = "minut" - ManufacturerTwoN Manufacturer = "two_n" - ManufacturerTtlock Manufacturer = "ttlock" - ManufacturerNest Manufacturer = "nest" - ManufacturerIgloohome Manufacturer = "igloohome" - ManufacturerEcobee Manufacturer = "ecobee" - ManufacturerHubitat Manufacturer = "hubitat" -) +func (d *DevicePropertiesCodeConstraintsItem) Accept(visitor DevicePropertiesCodeConstraintsItemVisitor) error { + switch d.typeName { + default: + return fmt.Errorf("invalid type %s in %T", d.typeName, d) + case "devicePropertiesCodeConstraintsItemZero": + return visitor.VisitDevicePropertiesCodeConstraintsItemZero(d.DevicePropertiesCodeConstraintsItemZero) + case "devicePropertiesCodeConstraintsItemMaxLength": + return visitor.VisitDevicePropertiesCodeConstraintsItemMaxLength(d.DevicePropertiesCodeConstraintsItemMaxLength) + } +} -func NewManufacturerFromString(s string) (Manufacturer, error) { - switch s { - case "akuvox": - return ManufacturerAkuvox, nil - case "august": - return ManufacturerAugust, nil - case "brivo": - return ManufacturerBrivo, nil - case "butterflymx": - return ManufacturerButterflymx, nil - case "doorking": - return ManufacturerDoorking, nil - case "genie": - return ManufacturerGenie, nil - case "igloo": - return ManufacturerIgloo, nil - case "keywe": - return ManufacturerKeywe, nil - case "kwikset": - return ManufacturerKwikset, nil - case "linear": - return ManufacturerLinear, nil - case "lockly": - return ManufacturerLockly, nil - case "nuki": - return ManufacturerNuki, nil - case "philia": - return ManufacturerPhilia, nil - case "salto": - return ManufacturerSalto, nil - case "samsung": - return ManufacturerSamsung, nil - case "schlage": - return ManufacturerSchlage, nil - case "seam": +type DevicePropertiesCodeConstraintsItemMaxLength struct { + MinLength *float64 `json:"min_length,omitempty"` + MaxLength *float64 `json:"max_length,omitempty"` + constraintType string + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesCodeConstraintsItemMaxLength) ConstraintType() string { + return d.constraintType +} + +func (d *DevicePropertiesCodeConstraintsItemMaxLength) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesCodeConstraintsItemMaxLength + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesCodeConstraintsItemMaxLength(value) + d.constraintType = "name_length" + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesCodeConstraintsItemMaxLength) MarshalJSON() ([]byte, error) { + type embed DevicePropertiesCodeConstraintsItemMaxLength + var marshaler = struct { + embed + ConstraintType string `json:"constraint_type"` + }{ + embed: embed(*d), + ConstraintType: "name_length", + } + return json.Marshal(marshaler) +} + +func (d *DevicePropertiesCodeConstraintsItemMaxLength) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesCodeConstraintsItemZero struct { + ConstraintType DevicePropertiesCodeConstraintsItemZeroConstraintType `json:"constraint_type,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesCodeConstraintsItemZero) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesCodeConstraintsItemZero + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesCodeConstraintsItemZero(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesCodeConstraintsItemZero) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesCodeConstraintsItemZeroConstraintType string + +const ( + DevicePropertiesCodeConstraintsItemZeroConstraintTypeNoZeros DevicePropertiesCodeConstraintsItemZeroConstraintType = "no_zeros" + DevicePropertiesCodeConstraintsItemZeroConstraintTypeCannotStartWith12 DevicePropertiesCodeConstraintsItemZeroConstraintType = "cannot_start_with_12" + DevicePropertiesCodeConstraintsItemZeroConstraintTypeNoTripleConsecutiveInts DevicePropertiesCodeConstraintsItemZeroConstraintType = "no_triple_consecutive_ints" + DevicePropertiesCodeConstraintsItemZeroConstraintTypeCannotSpecifyPinCode DevicePropertiesCodeConstraintsItemZeroConstraintType = "cannot_specify_pin_code" + DevicePropertiesCodeConstraintsItemZeroConstraintTypePinCodeMatchesExistingSet DevicePropertiesCodeConstraintsItemZeroConstraintType = "pin_code_matches_existing_set" + DevicePropertiesCodeConstraintsItemZeroConstraintTypeStartDateInFuture DevicePropertiesCodeConstraintsItemZeroConstraintType = "start_date_in_future" +) + +func NewDevicePropertiesCodeConstraintsItemZeroConstraintTypeFromString(s string) (DevicePropertiesCodeConstraintsItemZeroConstraintType, error) { + switch s { + case "no_zeros": + return DevicePropertiesCodeConstraintsItemZeroConstraintTypeNoZeros, nil + case "cannot_start_with_12": + return DevicePropertiesCodeConstraintsItemZeroConstraintTypeCannotStartWith12, nil + case "no_triple_consecutive_ints": + return DevicePropertiesCodeConstraintsItemZeroConstraintTypeNoTripleConsecutiveInts, nil + case "cannot_specify_pin_code": + return DevicePropertiesCodeConstraintsItemZeroConstraintTypeCannotSpecifyPinCode, nil + case "pin_code_matches_existing_set": + return DevicePropertiesCodeConstraintsItemZeroConstraintTypePinCodeMatchesExistingSet, nil + case "start_date_in_future": + return DevicePropertiesCodeConstraintsItemZeroConstraintTypeStartDateInFuture, nil + } + var t DevicePropertiesCodeConstraintsItemZeroConstraintType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DevicePropertiesCodeConstraintsItemZeroConstraintType) Ptr() *DevicePropertiesCodeConstraintsItemZeroConstraintType { + return &d +} + +type DevicePropertiesControlbywebMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + RelayName *string `json:"relay_name,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesControlbywebMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesControlbywebMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesControlbywebMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesControlbywebMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesDormakabaOracodeMetadata struct { + DoorId float64 `json:"door_id"` + DoorName string `json:"door_name"` + DeviceId *float64 `json:"device_id,omitempty"` + SiteId float64 `json:"site_id"` + SiteName string `json:"site_name"` + IanaTimezone *string `json:"iana_timezone,omitempty"` + PredefinedTimeSlots []*DevicePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem `json:"predefined_time_slots,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesDormakabaOracodeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesDormakabaOracodeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesDormakabaOracodeMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesDormakabaOracodeMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem struct { + Name string `json:"name"` + Prefix float64 `json:"prefix"` + CheckInTime string `json:"check_in_time"` + CheckOutTime string `json:"check_out_time"` + Is24Hour bool `json:"is_24_hour"` + IsBiweeklyMode bool `json:"is_biweekly_mode"` + IsOneShot bool `json:"is_one_shot"` + IsMaster bool `json:"is_master"` + ExtDormakabaOracodeUserLevelPrefix float64 `json:"ext_dormakaba_oracode_user_level_prefix"` + DormakabaOracodeUserLevelId string `json:"dormakaba_oracode_user_level_id"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesEcobeeMetadata struct { + EcobeeDeviceId string `json:"ecobee_device_id"` + DeviceName string `json:"device_name"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesEcobeeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesEcobeeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesEcobeeMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesEcobeeMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesFourSuitesMetadata struct { + DeviceId float64 `json:"device_id"` + DeviceName string `json:"device_name"` + RecloseDelayInSeconds float64 `json:"reclose_delay_in_seconds"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesFourSuitesMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesFourSuitesMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesFourSuitesMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesFourSuitesMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesGenieMetadata struct { + DeviceName string `json:"device_name"` + DoorName string `json:"door_name"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesGenieMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesGenieMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesGenieMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesGenieMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesHubitatMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + DeviceLabel string `json:"device_label"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesHubitatMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesHubitatMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesHubitatMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesHubitatMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesIglooMetadata struct { + DeviceId string `json:"device_id"` + BridgeId string `json:"bridge_id"` + Model *string `json:"model,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesIglooMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesIglooMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesIglooMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesIglooMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesIgloohomeMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + BridgeId *string `json:"bridge_id,omitempty"` + BridgeName *string `json:"bridge_name,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesIgloohomeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesIgloohomeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesIgloohomeMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesIgloohomeMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesKeypadBattery struct { + Level float64 `json:"level"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesKeypadBattery) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesKeypadBattery + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesKeypadBattery(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesKeypadBattery) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesKwiksetMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + ModelNumber string `json:"model_number"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesKwiksetMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesKwiksetMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesKwiksetMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesKwiksetMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesLocklyMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + Model *string `json:"model,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesLocklyMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesLocklyMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesLocklyMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesLocklyMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + LatestSensorValues *DevicePropertiesMinutMetadataLatestSensorValues `json:"latest_sensor_values,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadataLatestSensorValues struct { + Temperature *DevicePropertiesMinutMetadataLatestSensorValuesTemperature `json:"temperature,omitempty"` + Sound *DevicePropertiesMinutMetadataLatestSensorValuesSound `json:"sound,omitempty"` + Humidity *DevicePropertiesMinutMetadataLatestSensorValuesHumidity `json:"humidity,omitempty"` + Pressure *DevicePropertiesMinutMetadataLatestSensorValuesPressure `json:"pressure,omitempty"` + AccelerometerZ *DevicePropertiesMinutMetadataLatestSensorValuesAccelerometerZ `json:"accelerometer_z,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValues) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadataLatestSensorValues + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadataLatestSensorValues(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValues) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadataLatestSensorValuesAccelerometerZ struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesAccelerometerZ) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadataLatestSensorValuesAccelerometerZ + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadataLatestSensorValuesAccelerometerZ(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesAccelerometerZ) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadataLatestSensorValuesHumidity struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesHumidity) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadataLatestSensorValuesHumidity + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadataLatestSensorValuesHumidity(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesHumidity) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadataLatestSensorValuesPressure struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesPressure) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadataLatestSensorValuesPressure + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadataLatestSensorValuesPressure(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesPressure) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadataLatestSensorValuesSound struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesSound) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadataLatestSensorValuesSound + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadataLatestSensorValuesSound(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesSound) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesMinutMetadataLatestSensorValuesTemperature struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesTemperature) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesMinutMetadataLatestSensorValuesTemperature + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesMinutMetadataLatestSensorValuesTemperature(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesMinutMetadataLatestSensorValuesTemperature) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesModel struct { + // Display name of the device model. + DisplayName string `json:"display_name"` + // Display name that corresponds to the manufacturer-specific terminology for the device. + ManufacturerDisplayName string `json:"manufacturer_display_name"` + // Indicates whether the device supports offline access codes. + OfflineAccessCodesSupported *bool `json:"offline_access_codes_supported,omitempty"` + // Indicates whether the device supports online access codes. + OnlineAccessCodesSupported *bool `json:"online_access_codes_supported,omitempty"` + // Indicates whether the device supports an accessory keypad. + AccessoryKeypadSupported *bool `json:"accessory_keypad_supported,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesModel) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesModel + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesModel(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesModel) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesNestMetadata struct { + NestDeviceId string `json:"nest_device_id"` + DeviceName string `json:"device_name"` + CustomName string `json:"custom_name"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesNestMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesNestMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesNestMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesNestMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesNoiseawareMetadata struct { + DeviceModel DevicePropertiesNoiseawareMetadataDeviceModel `json:"device_model,omitempty"` + NoiseLevelNrs float64 `json:"noise_level_nrs"` + NoiseLevelDecibel float64 `json:"noise_level_decibel"` + DeviceName string `json:"device_name"` + DeviceId string `json:"device_id"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesNoiseawareMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesNoiseawareMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesNoiseawareMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesNoiseawareMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesNoiseawareMetadataDeviceModel string + +const ( + DevicePropertiesNoiseawareMetadataDeviceModelIndoor DevicePropertiesNoiseawareMetadataDeviceModel = "indoor" + DevicePropertiesNoiseawareMetadataDeviceModelOutdoor DevicePropertiesNoiseawareMetadataDeviceModel = "outdoor" +) + +func NewDevicePropertiesNoiseawareMetadataDeviceModelFromString(s string) (DevicePropertiesNoiseawareMetadataDeviceModel, error) { + switch s { + case "indoor": + return DevicePropertiesNoiseawareMetadataDeviceModelIndoor, nil + case "outdoor": + return DevicePropertiesNoiseawareMetadataDeviceModelOutdoor, nil + } + var t DevicePropertiesNoiseawareMetadataDeviceModel + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DevicePropertiesNoiseawareMetadataDeviceModel) Ptr() *DevicePropertiesNoiseawareMetadataDeviceModel { + return &d +} + +type DevicePropertiesNukiMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + KeypadBatteryCritical *bool `json:"keypad_battery_critical,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesNukiMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesNukiMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesNukiMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesNukiMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesSaltoMetadata struct { + LockId string `json:"lock_id"` + CustomerReference string `json:"customer_reference"` + LockType string `json:"lock_type"` + BatteryLevel string `json:"battery_level"` + LockedState string `json:"locked_state"` + Model *string `json:"model,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesSaltoMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesSaltoMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesSaltoMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesSaltoMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesSchlageMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + AccessCodeLength float64 `json:"access_code_length"` + Model *string `json:"model,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesSchlageMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesSchlageMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesSchlageMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesSchlageMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesSeamBridgeMetadata struct { + UnlockMethod *DevicePropertiesSeamBridgeMetadataUnlockMethod `json:"unlock_method,omitempty"` + DeviceNum float64 `json:"device_num"` + Name string `json:"name"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesSeamBridgeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesSeamBridgeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesSeamBridgeMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesSeamBridgeMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesSeamBridgeMetadataUnlockMethod string + +const ( + DevicePropertiesSeamBridgeMetadataUnlockMethodBridge DevicePropertiesSeamBridgeMetadataUnlockMethod = "bridge" + DevicePropertiesSeamBridgeMetadataUnlockMethodDoorking DevicePropertiesSeamBridgeMetadataUnlockMethod = "doorking" +) + +func NewDevicePropertiesSeamBridgeMetadataUnlockMethodFromString(s string) (DevicePropertiesSeamBridgeMetadataUnlockMethod, error) { + switch s { + case "bridge": + return DevicePropertiesSeamBridgeMetadataUnlockMethodBridge, nil + case "doorking": + return DevicePropertiesSeamBridgeMetadataUnlockMethodDoorking, nil + } + var t DevicePropertiesSeamBridgeMetadataUnlockMethod + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DevicePropertiesSeamBridgeMetadataUnlockMethod) Ptr() *DevicePropertiesSeamBridgeMetadataUnlockMethod { + return &d +} + +type DevicePropertiesSmartthingsMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + Model *string `json:"model,omitempty"` + LocationId *string `json:"location_id,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesSmartthingsMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesSmartthingsMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesSmartthingsMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesSmartthingsMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesTtlockMetadata struct { + LockId float64 `json:"lock_id"` + LockAlias string `json:"lock_alias"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesTtlockMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesTtlockMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesTtlockMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesTtlockMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesTwoNMetadata struct { + DeviceId float64 `json:"device_id"` + DeviceName string `json:"device_name"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesTwoNMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesTwoNMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesTwoNMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesTwoNMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DevicePropertiesWyzeMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + ProductName string `json:"product_name"` + ProductType string `json:"product_type"` + ProductModel string `json:"product_model"` + DeviceInfoModel string `json:"device_info_model"` + + _rawJSON json.RawMessage +} + +func (d *DevicePropertiesWyzeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesWyzeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DevicePropertiesWyzeMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DevicePropertiesWyzeMetadata) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DeviceProvider struct { + DeviceProviderName string `json:"device_provider_name"` + DisplayName string `json:"display_name"` + ImageUrl string `json:"image_url"` + ProviderCategories []DeviceProviderProviderCategoriesItem `json:"provider_categories,omitempty"` + + _rawJSON json.RawMessage +} + +func (d *DeviceProvider) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceProvider + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DeviceProvider(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DeviceProvider) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DeviceProviderProviderCategoriesItem string + +const ( + DeviceProviderProviderCategoriesItemStable DeviceProviderProviderCategoriesItem = "stable" + DeviceProviderProviderCategoriesItemConsumerSmartlocks DeviceProviderProviderCategoriesItem = "consumer_smartlocks" +) + +func NewDeviceProviderProviderCategoriesItemFromString(s string) (DeviceProviderProviderCategoriesItem, error) { + switch s { + case "stable": + return DeviceProviderProviderCategoriesItemStable, nil + case "consumer_smartlocks": + return DeviceProviderProviderCategoriesItemConsumerSmartlocks, nil + } + var t DeviceProviderProviderCategoriesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DeviceProviderProviderCategoriesItem) Ptr() *DeviceProviderProviderCategoriesItem { + return &d +} + +type DeviceType string + +const ( + DeviceTypeAkuvoxLock DeviceType = "akuvox_lock" + DeviceTypeAugustLock DeviceType = "august_lock" + DeviceTypeBrivoAccessPoint DeviceType = "brivo_access_point" + DeviceTypeButterflymxPanel DeviceType = "butterflymx_panel" + DeviceTypeAvigilonAltaEntry DeviceType = "avigilon_alta_entry" + DeviceTypeDoorkingLock DeviceType = "doorking_lock" + DeviceTypeGenieDoor DeviceType = "genie_door" + DeviceTypeIglooLock DeviceType = "igloo_lock" + DeviceTypeLinearLock DeviceType = "linear_lock" + DeviceTypeLocklyLock DeviceType = "lockly_lock" + DeviceTypeKwiksetLock DeviceType = "kwikset_lock" + DeviceTypeNukiLock DeviceType = "nuki_lock" + DeviceTypeSaltoLock DeviceType = "salto_lock" + DeviceTypeSchlageLock DeviceType = "schlage_lock" + DeviceTypeSeamRelay DeviceType = "seam_relay" + DeviceTypeSmartthingsLock DeviceType = "smartthings_lock" + DeviceTypeWyzeLock DeviceType = "wyze_lock" + DeviceTypeYaleLock DeviceType = "yale_lock" + DeviceTypeTwoNIntercom DeviceType = "two_n_intercom" + DeviceTypeControlbywebDevice DeviceType = "controlbyweb_device" + DeviceTypeTtlockLock DeviceType = "ttlock_lock" + DeviceTypeIgloohomeLock DeviceType = "igloohome_lock" + DeviceTypeHubitatLock DeviceType = "hubitat_lock" + DeviceTypeFourSuitesDoor DeviceType = "four_suites_door" + DeviceTypeDormakabaOracodeDoor DeviceType = "dormakaba_oracode_door" + DeviceTypeNoiseawareActivityZone DeviceType = "noiseaware_activity_zone" + DeviceTypeMinutSensor DeviceType = "minut_sensor" + DeviceTypeEcobeeThermostat DeviceType = "ecobee_thermostat" + DeviceTypeNestThermostat DeviceType = "nest_thermostat" + DeviceTypeIosPhone DeviceType = "ios_phone" + DeviceTypeAndroidPhone DeviceType = "android_phone" +) + +func NewDeviceTypeFromString(s string) (DeviceType, error) { + switch s { + case "akuvox_lock": + return DeviceTypeAkuvoxLock, nil + case "august_lock": + return DeviceTypeAugustLock, nil + case "brivo_access_point": + return DeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return DeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return DeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return DeviceTypeDoorkingLock, nil + case "genie_door": + return DeviceTypeGenieDoor, nil + case "igloo_lock": + return DeviceTypeIglooLock, nil + case "linear_lock": + return DeviceTypeLinearLock, nil + case "lockly_lock": + return DeviceTypeLocklyLock, nil + case "kwikset_lock": + return DeviceTypeKwiksetLock, nil + case "nuki_lock": + return DeviceTypeNukiLock, nil + case "salto_lock": + return DeviceTypeSaltoLock, nil + case "schlage_lock": + return DeviceTypeSchlageLock, nil + case "seam_relay": + return DeviceTypeSeamRelay, nil + case "smartthings_lock": + return DeviceTypeSmartthingsLock, nil + case "wyze_lock": + return DeviceTypeWyzeLock, nil + case "yale_lock": + return DeviceTypeYaleLock, nil + case "two_n_intercom": + return DeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return DeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return DeviceTypeTtlockLock, nil + case "igloohome_lock": + return DeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return DeviceTypeHubitatLock, nil + case "four_suites_door": + return DeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return DeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return DeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return DeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return DeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return DeviceTypeNestThermostat, nil + case "ios_phone": + return DeviceTypeIosPhone, nil + case "android_phone": + return DeviceTypeAndroidPhone, nil + } + var t DeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DeviceType) Ptr() *DeviceType { + return &d +} + +type DeviceWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` + + _rawJSON json.RawMessage +} + +func (d *DeviceWarningsItem) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceWarningsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DeviceWarningsItem(value) + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DeviceWarningsItem) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type EnrollmentAutomation struct { + CredentialManagerAcsSystemId string `json:"credential_manager_acs_system_id"` + UserIdentityId string `json:"user_identity_id"` + CreatedAt time.Time `json:"created_at"` + WorkspaceId string `json:"workspace_id"` + EnrollmentAutomationId string `json:"enrollment_automation_id"` + + _rawJSON json.RawMessage +} + +func (e *EnrollmentAutomation) UnmarshalJSON(data []byte) error { + type unmarshaler EnrollmentAutomation + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = EnrollmentAutomation(value) + e._rawJSON = json.RawMessage(data) + return nil +} + +func (e *EnrollmentAutomation) String() string { + if len(e._rawJSON) > 0 { + if value, err := core.StringifyJSON(e._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type Event struct { + EventId string `json:"event_id"` + DeviceId *string `json:"device_id,omitempty"` + EventType string `json:"event_type"` + WorkspaceId string `json:"workspace_id"` + CreatedAt time.Time `json:"created_at"` + OccurredAt time.Time `json:"occurred_at"` + + _rawJSON json.RawMessage +} + +func (e *Event) UnmarshalJSON(data []byte) error { + type unmarshaler Event + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = Event(value) + e._rawJSON = json.RawMessage(data) + return nil +} + +func (e *Event) String() string { + if len(e._rawJSON) > 0 { + if value, err := core.StringifyJSON(e._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type Manufacturer string + +const ( + ManufacturerAkuvox Manufacturer = "akuvox" + ManufacturerAugust Manufacturer = "august" + ManufacturerAvigilonAlta Manufacturer = "avigilon_alta" + ManufacturerBrivo Manufacturer = "brivo" + ManufacturerButterflymx Manufacturer = "butterflymx" + ManufacturerDoorking Manufacturer = "doorking" + ManufacturerFourSuites Manufacturer = "four_suites" + ManufacturerGenie Manufacturer = "genie" + ManufacturerIgloo Manufacturer = "igloo" + ManufacturerKeywe Manufacturer = "keywe" + ManufacturerKwikset Manufacturer = "kwikset" + ManufacturerLinear Manufacturer = "linear" + ManufacturerLockly Manufacturer = "lockly" + ManufacturerNuki Manufacturer = "nuki" + ManufacturerPhilia Manufacturer = "philia" + ManufacturerSalto Manufacturer = "salto" + ManufacturerSamsung Manufacturer = "samsung" + ManufacturerSchlage Manufacturer = "schlage" + ManufacturerSeam Manufacturer = "seam" + ManufacturerUnknown Manufacturer = "unknown" + ManufacturerWyze Manufacturer = "wyze" + ManufacturerYale Manufacturer = "yale" + ManufacturerMinut Manufacturer = "minut" + ManufacturerTwoN Manufacturer = "two_n" + ManufacturerTtlock Manufacturer = "ttlock" + ManufacturerNest Manufacturer = "nest" + ManufacturerIgloohome Manufacturer = "igloohome" + ManufacturerEcobee Manufacturer = "ecobee" + ManufacturerHubitat Manufacturer = "hubitat" + ManufacturerControlbyweb Manufacturer = "controlbyweb" + ManufacturerSmartthings Manufacturer = "smartthings" + ManufacturerDormakabaOracode Manufacturer = "dormakaba_oracode" +) + +func NewManufacturerFromString(s string) (Manufacturer, error) { + switch s { + case "akuvox": + return ManufacturerAkuvox, nil + case "august": + return ManufacturerAugust, nil + case "avigilon_alta": + return ManufacturerAvigilonAlta, nil + case "brivo": + return ManufacturerBrivo, nil + case "butterflymx": + return ManufacturerButterflymx, nil + case "doorking": + return ManufacturerDoorking, nil + case "four_suites": + return ManufacturerFourSuites, nil + case "genie": + return ManufacturerGenie, nil + case "igloo": + return ManufacturerIgloo, nil + case "keywe": + return ManufacturerKeywe, nil + case "kwikset": + return ManufacturerKwikset, nil + case "linear": + return ManufacturerLinear, nil + case "lockly": + return ManufacturerLockly, nil + case "nuki": + return ManufacturerNuki, nil + case "philia": + return ManufacturerPhilia, nil + case "salto": + return ManufacturerSalto, nil + case "samsung": + return ManufacturerSamsung, nil + case "schlage": + return ManufacturerSchlage, nil + case "seam": return ManufacturerSeam, nil case "unknown": return ManufacturerUnknown, nil + case "wyze": + return ManufacturerWyze, nil case "yale": return ManufacturerYale, nil case "minut": @@ -1733,291 +3054,1801 @@ func NewManufacturerFromString(s string) (Manufacturer, error) { return ManufacturerEcobee, nil case "hubitat": return ManufacturerHubitat, nil + case "controlbyweb": + return ManufacturerControlbyweb, nil + case "smartthings": + return ManufacturerSmartthings, nil + case "dormakaba_oracode": + return ManufacturerDormakabaOracode, nil + } + var t Manufacturer + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (m Manufacturer) Ptr() *Manufacturer { + return &m +} + +type NoiseThreshold struct { + NoiseThresholdId string `json:"noise_threshold_id"` + DeviceId string `json:"device_id"` + Name string `json:"name"` + NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` + StartsDailyAt string `json:"starts_daily_at"` + EndsDailyAt string `json:"ends_daily_at"` + NoiseThresholdDecibels float64 `json:"noise_threshold_decibels"` + + _rawJSON json.RawMessage +} + +func (n *NoiseThreshold) UnmarshalJSON(data []byte) error { + type unmarshaler NoiseThreshold + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NoiseThreshold(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NoiseThreshold) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Phone struct { + // Unique identifier for the device. + DeviceId string `json:"device_id"` + DeviceType PhoneDeviceType `json:"device_type,omitempty"` + // Collection of capabilities that the device supports when connected to Seam. Values are "access_code," which indicates that the device can manage and utilize digital PIN codes for secure access; "lock," which indicates that the device controls a door locking mechanism, enabling the remote opening and closing of doors and other entry points; "noise_detection," which indicates that the device supports monitoring and responding to ambient noise levels; "thermostat," which indicates that the device can regulate and adjust indoor temperatures; and "battery," which indicates that the device can manage battery life and health. + CapabilitiesSupported []PhoneCapabilitiesSupportedItem `json:"capabilities_supported,omitempty"` + // Properties of the device. + Properties *PhoneProperties `json:"properties,omitempty"` + // Location information for the device. + Location *PhoneLocation `json:"location,omitempty"` + // Unique identifier for the Seam workspace associated with the device. + WorkspaceId string `json:"workspace_id"` + // Array of errors associated with the device. Each error object within the array contains two fields: "error_code" and "message." "error_code" is a string that uniquely identifies the type of error, enabling quick recognition and categorization of the issue. "message" provides a more detailed description of the error, offering insights into the issue and potentially how to rectify it. + Errors []*PhoneErrorsItem `json:"errors,omitempty"` + // Array of warnings associated with the device. Each warning object within the array contains two fields: "warning_code" and "message." "warning_code" is a string that uniquely identifies the type of warning, enabling quick recognition and categorization of the issue. "message" provides a more detailed description of the warning, offering insights into the issue and potentially how to rectify it. + Warnings []*PhoneWarningsItem `json:"warnings,omitempty"` + // Date and time at which the device object was created. + CreatedAt time.Time `json:"created_at"` + // Indicates whether Seam manages the device. + IsManaged string `json:"is_managed"` + AssaAbloyCredentialServiceMetadata *PhoneAssaAbloyCredentialServiceMetadata `json:"assa_abloy_credential_service_metadata,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *Phone) UnmarshalJSON(data []byte) error { + type unmarshaler Phone + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Phone(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *Phone) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhoneAssaAbloyCredentialServiceMetadata struct { + HasActiveEndpoint bool `json:"has_active_endpoint"` + Endpoints []*PhoneAssaAbloyCredentialServiceMetadataEndpointsItem `json:"endpoints,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhoneAssaAbloyCredentialServiceMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneAssaAbloyCredentialServiceMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhoneAssaAbloyCredentialServiceMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhoneAssaAbloyCredentialServiceMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhoneAssaAbloyCredentialServiceMetadataEndpointsItem struct { + EndpointId string `json:"endpoint_id"` + IsActive bool `json:"is_active"` + + _rawJSON json.RawMessage +} + +func (p *PhoneAssaAbloyCredentialServiceMetadataEndpointsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneAssaAbloyCredentialServiceMetadataEndpointsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhoneAssaAbloyCredentialServiceMetadataEndpointsItem(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhoneAssaAbloyCredentialServiceMetadataEndpointsItem) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhoneCapabilitiesSupportedItem string + +const ( + PhoneCapabilitiesSupportedItemAccessCode PhoneCapabilitiesSupportedItem = "access_code" + PhoneCapabilitiesSupportedItemLock PhoneCapabilitiesSupportedItem = "lock" + PhoneCapabilitiesSupportedItemNoiseDetection PhoneCapabilitiesSupportedItem = "noise_detection" + PhoneCapabilitiesSupportedItemThermostat PhoneCapabilitiesSupportedItem = "thermostat" + PhoneCapabilitiesSupportedItemBattery PhoneCapabilitiesSupportedItem = "battery" + PhoneCapabilitiesSupportedItemPhone PhoneCapabilitiesSupportedItem = "phone" +) + +func NewPhoneCapabilitiesSupportedItemFromString(s string) (PhoneCapabilitiesSupportedItem, error) { + switch s { + case "access_code": + return PhoneCapabilitiesSupportedItemAccessCode, nil + case "lock": + return PhoneCapabilitiesSupportedItemLock, nil + case "noise_detection": + return PhoneCapabilitiesSupportedItemNoiseDetection, nil + case "thermostat": + return PhoneCapabilitiesSupportedItemThermostat, nil + case "battery": + return PhoneCapabilitiesSupportedItemBattery, nil + case "phone": + return PhoneCapabilitiesSupportedItemPhone, nil + } + var t PhoneCapabilitiesSupportedItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PhoneCapabilitiesSupportedItem) Ptr() *PhoneCapabilitiesSupportedItem { + return &p +} + +type PhoneDeviceType string + +const ( + PhoneDeviceTypeAndroidPhone PhoneDeviceType = "android_phone" + PhoneDeviceTypeIosPhone PhoneDeviceType = "ios_phone" +) + +func NewPhoneDeviceTypeFromString(s string) (PhoneDeviceType, error) { + switch s { + case "android_phone": + return PhoneDeviceTypeAndroidPhone, nil + case "ios_phone": + return PhoneDeviceTypeIosPhone, nil + } + var t PhoneDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PhoneDeviceType) Ptr() *PhoneDeviceType { + return &p +} + +type PhoneErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` + + _rawJSON json.RawMessage +} + +func (p *PhoneErrorsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneErrorsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhoneErrorsItem(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhoneErrorsItem) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +// Location information for the device. +type PhoneLocation struct { + // Name of the device location. + LocationName *string `json:"location_name,omitempty"` + // Time zone of the device location. + Timezone *string `json:"timezone,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhoneLocation) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneLocation + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhoneLocation(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhoneLocation) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +// Properties of the device. +type PhoneProperties struct { + // Indicates whether the device is online. + Online bool `json:"online"` + // Name of the device. Enables administrators and users to identify the device easily, especially when there are numerous devices. + Name string `json:"name"` + Model *PhonePropertiesModel `json:"model,omitempty"` + // Indicates whether the device has direct power. + HasDirectPower *bool `json:"has_direct_power,omitempty"` + // Indicates the battery level of the device as a decimal value between 0 and 1, inclusive. + BatteryLevel *float64 `json:"battery_level,omitempty"` + // Represents the current status of the battery charge level. Values are "critical," which indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging; "low," which signifies that the battery is under the preferred threshold and should be charged soon; "good," which denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging; and "full," which represents a battery that is fully charged, providing the maximum duration of usage. + Battery *PhonePropertiesBattery `json:"battery,omitempty"` + // Manufacturer of the device. + Manufacturer *string `json:"manufacturer,omitempty"` + // Image URL for the device. + ImageUrl *string `json:"image_url,omitempty"` + // Alt text for the device image. + ImageAltText *string `json:"image_alt_text,omitempty"` + // Serial number of the device. + SerialNumber *string `json:"serial_number,omitempty"` + // Indicates whether it is currently possible to use online access codes for the device. + OnlineAccessCodesEnabled *bool `json:"online_access_codes_enabled,omitempty"` + // Indicates whether it is currently possible to use offline access codes for the device. + OfflineAccessCodesEnabled *bool `json:"offline_access_codes_enabled,omitempty"` + // Deprecated. Use model.accessory_keypad_supported. + SupportsAccessoryKeypad *bool `json:"supports_accessory_keypad,omitempty"` + // Deprecated. Use offline_access_codes_enabled. + SupportsOfflineAccessCodes *bool `json:"supports_offline_access_codes,omitempty"` + AugustMetadata *PhonePropertiesAugustMetadata `json:"august_metadata,omitempty"` + AvigilonAltaMetadata *PhonePropertiesAvigilonAltaMetadata `json:"avigilon_alta_metadata,omitempty"` + SchlageMetadata *PhonePropertiesSchlageMetadata `json:"schlage_metadata,omitempty"` + SmartthingsMetadata *PhonePropertiesSmartthingsMetadata `json:"smartthings_metadata,omitempty"` + LocklyMetadata *PhonePropertiesLocklyMetadata `json:"lockly_metadata,omitempty"` + NukiMetadata *PhonePropertiesNukiMetadata `json:"nuki_metadata,omitempty"` + KwiksetMetadata *PhonePropertiesKwiksetMetadata `json:"kwikset_metadata,omitempty"` + SaltoMetadata *PhonePropertiesSaltoMetadata `json:"salto_metadata,omitempty"` + GenieMetadata *PhonePropertiesGenieMetadata `json:"genie_metadata,omitempty"` + BrivoMetadata *PhonePropertiesBrivoMetadata `json:"brivo_metadata,omitempty"` + IglooMetadata *PhonePropertiesIglooMetadata `json:"igloo_metadata,omitempty"` + NoiseawareMetadata *PhonePropertiesNoiseawareMetadata `json:"noiseaware_metadata,omitempty"` + MinutMetadata *PhonePropertiesMinutMetadata `json:"minut_metadata,omitempty"` + FourSuitesMetadata *PhonePropertiesFourSuitesMetadata `json:"four_suites_metadata,omitempty"` + TwoNMetadata *PhonePropertiesTwoNMetadata `json:"two_n_metadata,omitempty"` + ControlbywebMetadata *PhonePropertiesControlbywebMetadata `json:"controlbyweb_metadata,omitempty"` + TtlockMetadata *PhonePropertiesTtlockMetadata `json:"ttlock_metadata,omitempty"` + SeamBridgeMetadata *PhonePropertiesSeamBridgeMetadata `json:"seam_bridge_metadata,omitempty"` + IgloohomeMetadata *PhonePropertiesIgloohomeMetadata `json:"igloohome_metadata,omitempty"` + NestMetadata *PhonePropertiesNestMetadata `json:"nest_metadata,omitempty"` + EcobeeMetadata *PhonePropertiesEcobeeMetadata `json:"ecobee_metadata,omitempty"` + HubitatMetadata *PhonePropertiesHubitatMetadata `json:"hubitat_metadata,omitempty"` + DormakabaOracodeMetadata *PhonePropertiesDormakabaOracodeMetadata `json:"dormakaba_oracode_metadata,omitempty"` + WyzeMetadata *PhonePropertiesWyzeMetadata `json:"wyze_metadata,omitempty"` + CodeConstraints []*PhonePropertiesCodeConstraintsItem `json:"code_constraints,omitempty"` + SupportedCodeLengths []float64 `json:"supported_code_lengths,omitempty"` + MaxActiveCodesSupported *float64 `json:"max_active_codes_supported,omitempty"` + SupportsBackupAccessCodePool *bool `json:"supports_backup_access_code_pool,omitempty"` + HasNativeEntryEvents *bool `json:"has_native_entry_events,omitempty"` + Locked *bool `json:"locked,omitempty"` + KeypadBattery *PhonePropertiesKeypadBattery `json:"keypad_battery,omitempty"` + DoorOpen *bool `json:"door_open,omitempty"` + AssaAbloyCredentialServiceMetadata *PhonePropertiesAssaAbloyCredentialServiceMetadata `json:"assa_abloy_credential_service_metadata,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhoneProperties) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneProperties + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhoneProperties(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhoneProperties) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesAssaAbloyCredentialServiceMetadata struct { + HasActiveEndpoint bool `json:"has_active_endpoint"` + Endpoints []*PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem `json:"endpoints,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesAssaAbloyCredentialServiceMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesAssaAbloyCredentialServiceMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesAssaAbloyCredentialServiceMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesAssaAbloyCredentialServiceMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem struct { + EndpointId string `json:"endpoint_id"` + IsActive bool `json:"is_active"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesAugustMetadata struct { + LockId string `json:"lock_id"` + LockName string `json:"lock_name"` + HouseName string `json:"house_name"` + HasKeypad bool `json:"has_keypad"` + KeypadBatteryLevel *string `json:"keypad_battery_level,omitempty"` + Model *string `json:"model,omitempty"` + HouseId *string `json:"house_id,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesAugustMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesAugustMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesAugustMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesAugustMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesAvigilonAltaMetadata struct { + EntryName string `json:"entry_name"` + OrgName string `json:"org_name"` + ZoneId float64 `json:"zone_id"` + ZoneName string `json:"zone_name"` + SiteId float64 `json:"site_id"` + SiteName string `json:"site_name"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesAvigilonAltaMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesAvigilonAltaMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesAvigilonAltaMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesAvigilonAltaMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +// Represents the current status of the battery charge level. Values are "critical," which indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging; "low," which signifies that the battery is under the preferred threshold and should be charged soon; "good," which denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging; and "full," which represents a battery that is fully charged, providing the maximum duration of usage. +type PhonePropertiesBattery struct { + Level float64 `json:"level"` + Status PhonePropertiesBatteryStatus `json:"status,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesBattery) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesBattery + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesBattery(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesBattery) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesBatteryStatus string + +const ( + PhonePropertiesBatteryStatusCritical PhonePropertiesBatteryStatus = "critical" + PhonePropertiesBatteryStatusLow PhonePropertiesBatteryStatus = "low" + PhonePropertiesBatteryStatusGood PhonePropertiesBatteryStatus = "good" + PhonePropertiesBatteryStatusFull PhonePropertiesBatteryStatus = "full" +) + +func NewPhonePropertiesBatteryStatusFromString(s string) (PhonePropertiesBatteryStatus, error) { + switch s { + case "critical": + return PhonePropertiesBatteryStatusCritical, nil + case "low": + return PhonePropertiesBatteryStatusLow, nil + case "good": + return PhonePropertiesBatteryStatusGood, nil + case "full": + return PhonePropertiesBatteryStatusFull, nil + } + var t PhonePropertiesBatteryStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PhonePropertiesBatteryStatus) Ptr() *PhonePropertiesBatteryStatus { + return &p +} + +type PhonePropertiesBrivoMetadata struct { + DeviceName string `json:"device_name"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesBrivoMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesBrivoMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesBrivoMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesBrivoMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesCodeConstraintsItem struct { + typeName string + PhonePropertiesCodeConstraintsItemZero *PhonePropertiesCodeConstraintsItemZero + PhonePropertiesCodeConstraintsItemMaxLength *PhonePropertiesCodeConstraintsItemMaxLength +} + +func NewPhonePropertiesCodeConstraintsItemFromPhonePropertiesCodeConstraintsItemZero(value *PhonePropertiesCodeConstraintsItemZero) *PhonePropertiesCodeConstraintsItem { + return &PhonePropertiesCodeConstraintsItem{typeName: "phonePropertiesCodeConstraintsItemZero", PhonePropertiesCodeConstraintsItemZero: value} +} + +func NewPhonePropertiesCodeConstraintsItemFromPhonePropertiesCodeConstraintsItemMaxLength(value *PhonePropertiesCodeConstraintsItemMaxLength) *PhonePropertiesCodeConstraintsItem { + return &PhonePropertiesCodeConstraintsItem{typeName: "phonePropertiesCodeConstraintsItemMaxLength", PhonePropertiesCodeConstraintsItemMaxLength: value} +} + +func (p *PhonePropertiesCodeConstraintsItem) UnmarshalJSON(data []byte) error { + valuePhonePropertiesCodeConstraintsItemZero := new(PhonePropertiesCodeConstraintsItemZero) + if err := json.Unmarshal(data, &valuePhonePropertiesCodeConstraintsItemZero); err == nil { + p.typeName = "phonePropertiesCodeConstraintsItemZero" + p.PhonePropertiesCodeConstraintsItemZero = valuePhonePropertiesCodeConstraintsItemZero + return nil + } + valuePhonePropertiesCodeConstraintsItemMaxLength := new(PhonePropertiesCodeConstraintsItemMaxLength) + if err := json.Unmarshal(data, &valuePhonePropertiesCodeConstraintsItemMaxLength); err == nil { + p.typeName = "phonePropertiesCodeConstraintsItemMaxLength" + p.PhonePropertiesCodeConstraintsItemMaxLength = valuePhonePropertiesCodeConstraintsItemMaxLength + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, p) +} + +func (p PhonePropertiesCodeConstraintsItem) MarshalJSON() ([]byte, error) { + switch p.typeName { + default: + return nil, fmt.Errorf("invalid type %s in %T", p.typeName, p) + case "phonePropertiesCodeConstraintsItemZero": + return json.Marshal(p.PhonePropertiesCodeConstraintsItemZero) + case "phonePropertiesCodeConstraintsItemMaxLength": + return json.Marshal(p.PhonePropertiesCodeConstraintsItemMaxLength) + } +} + +type PhonePropertiesCodeConstraintsItemVisitor interface { + VisitPhonePropertiesCodeConstraintsItemZero(*PhonePropertiesCodeConstraintsItemZero) error + VisitPhonePropertiesCodeConstraintsItemMaxLength(*PhonePropertiesCodeConstraintsItemMaxLength) error +} + +func (p *PhonePropertiesCodeConstraintsItem) Accept(visitor PhonePropertiesCodeConstraintsItemVisitor) error { + switch p.typeName { + default: + return fmt.Errorf("invalid type %s in %T", p.typeName, p) + case "phonePropertiesCodeConstraintsItemZero": + return visitor.VisitPhonePropertiesCodeConstraintsItemZero(p.PhonePropertiesCodeConstraintsItemZero) + case "phonePropertiesCodeConstraintsItemMaxLength": + return visitor.VisitPhonePropertiesCodeConstraintsItemMaxLength(p.PhonePropertiesCodeConstraintsItemMaxLength) + } +} + +type PhonePropertiesCodeConstraintsItemMaxLength struct { + MinLength *float64 `json:"min_length,omitempty"` + MaxLength *float64 `json:"max_length,omitempty"` + constraintType string + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesCodeConstraintsItemMaxLength) ConstraintType() string { + return p.constraintType +} + +func (p *PhonePropertiesCodeConstraintsItemMaxLength) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesCodeConstraintsItemMaxLength + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesCodeConstraintsItemMaxLength(value) + p.constraintType = "name_length" + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesCodeConstraintsItemMaxLength) MarshalJSON() ([]byte, error) { + type embed PhonePropertiesCodeConstraintsItemMaxLength + var marshaler = struct { + embed + ConstraintType string `json:"constraint_type"` + }{ + embed: embed(*p), + ConstraintType: "name_length", + } + return json.Marshal(marshaler) +} + +func (p *PhonePropertiesCodeConstraintsItemMaxLength) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesCodeConstraintsItemZero struct { + ConstraintType PhonePropertiesCodeConstraintsItemZeroConstraintType `json:"constraint_type,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesCodeConstraintsItemZero) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesCodeConstraintsItemZero + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesCodeConstraintsItemZero(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesCodeConstraintsItemZero) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesCodeConstraintsItemZeroConstraintType string + +const ( + PhonePropertiesCodeConstraintsItemZeroConstraintTypeNoZeros PhonePropertiesCodeConstraintsItemZeroConstraintType = "no_zeros" + PhonePropertiesCodeConstraintsItemZeroConstraintTypeCannotStartWith12 PhonePropertiesCodeConstraintsItemZeroConstraintType = "cannot_start_with_12" + PhonePropertiesCodeConstraintsItemZeroConstraintTypeNoTripleConsecutiveInts PhonePropertiesCodeConstraintsItemZeroConstraintType = "no_triple_consecutive_ints" + PhonePropertiesCodeConstraintsItemZeroConstraintTypeCannotSpecifyPinCode PhonePropertiesCodeConstraintsItemZeroConstraintType = "cannot_specify_pin_code" + PhonePropertiesCodeConstraintsItemZeroConstraintTypePinCodeMatchesExistingSet PhonePropertiesCodeConstraintsItemZeroConstraintType = "pin_code_matches_existing_set" + PhonePropertiesCodeConstraintsItemZeroConstraintTypeStartDateInFuture PhonePropertiesCodeConstraintsItemZeroConstraintType = "start_date_in_future" +) + +func NewPhonePropertiesCodeConstraintsItemZeroConstraintTypeFromString(s string) (PhonePropertiesCodeConstraintsItemZeroConstraintType, error) { + switch s { + case "no_zeros": + return PhonePropertiesCodeConstraintsItemZeroConstraintTypeNoZeros, nil + case "cannot_start_with_12": + return PhonePropertiesCodeConstraintsItemZeroConstraintTypeCannotStartWith12, nil + case "no_triple_consecutive_ints": + return PhonePropertiesCodeConstraintsItemZeroConstraintTypeNoTripleConsecutiveInts, nil + case "cannot_specify_pin_code": + return PhonePropertiesCodeConstraintsItemZeroConstraintTypeCannotSpecifyPinCode, nil + case "pin_code_matches_existing_set": + return PhonePropertiesCodeConstraintsItemZeroConstraintTypePinCodeMatchesExistingSet, nil + case "start_date_in_future": + return PhonePropertiesCodeConstraintsItemZeroConstraintTypeStartDateInFuture, nil + } + var t PhonePropertiesCodeConstraintsItemZeroConstraintType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PhonePropertiesCodeConstraintsItemZeroConstraintType) Ptr() *PhonePropertiesCodeConstraintsItemZeroConstraintType { + return &p +} + +type PhonePropertiesControlbywebMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + RelayName *string `json:"relay_name,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesControlbywebMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesControlbywebMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesControlbywebMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesControlbywebMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesDormakabaOracodeMetadata struct { + DoorId float64 `json:"door_id"` + DoorName string `json:"door_name"` + DeviceId *float64 `json:"device_id,omitempty"` + SiteId float64 `json:"site_id"` + SiteName string `json:"site_name"` + IanaTimezone *string `json:"iana_timezone,omitempty"` + PredefinedTimeSlots []*PhonePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem `json:"predefined_time_slots,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesDormakabaOracodeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesDormakabaOracodeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesDormakabaOracodeMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesDormakabaOracodeMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem struct { + Name string `json:"name"` + Prefix float64 `json:"prefix"` + CheckInTime string `json:"check_in_time"` + CheckOutTime string `json:"check_out_time"` + Is24Hour bool `json:"is_24_hour"` + IsBiweeklyMode bool `json:"is_biweekly_mode"` + IsOneShot bool `json:"is_one_shot"` + IsMaster bool `json:"is_master"` + ExtDormakabaOracodeUserLevelPrefix float64 `json:"ext_dormakaba_oracode_user_level_prefix"` + DormakabaOracodeUserLevelId string `json:"dormakaba_oracode_user_level_id"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesDormakabaOracodeMetadataPredefinedTimeSlotsItem) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesEcobeeMetadata struct { + EcobeeDeviceId string `json:"ecobee_device_id"` + DeviceName string `json:"device_name"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesEcobeeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesEcobeeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesEcobeeMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesEcobeeMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesFourSuitesMetadata struct { + DeviceId float64 `json:"device_id"` + DeviceName string `json:"device_name"` + RecloseDelayInSeconds float64 `json:"reclose_delay_in_seconds"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesFourSuitesMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesFourSuitesMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesFourSuitesMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesFourSuitesMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesGenieMetadata struct { + DeviceName string `json:"device_name"` + DoorName string `json:"door_name"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesGenieMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesGenieMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesGenieMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesGenieMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesHubitatMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + DeviceLabel string `json:"device_label"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesHubitatMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesHubitatMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesHubitatMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesHubitatMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesIglooMetadata struct { + DeviceId string `json:"device_id"` + BridgeId string `json:"bridge_id"` + Model *string `json:"model,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesIglooMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesIglooMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesIglooMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesIglooMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesIgloohomeMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + BridgeId *string `json:"bridge_id,omitempty"` + BridgeName *string `json:"bridge_name,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesIgloohomeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesIgloohomeMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesIgloohomeMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesIgloohomeMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesKeypadBattery struct { + Level float64 `json:"level"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesKeypadBattery) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesKeypadBattery + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesKeypadBattery(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesKeypadBattery) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesKwiksetMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + ModelNumber string `json:"model_number"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesKwiksetMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesKwiksetMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesKwiksetMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesKwiksetMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } } - var t Manufacturer + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesLocklyMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + Model *string `json:"model,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesLocklyMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesLocklyMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesLocklyMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesLocklyMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + LatestSensorValues *PhonePropertiesMinutMetadataLatestSensorValues `json:"latest_sensor_values,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadataLatestSensorValues struct { + Temperature *PhonePropertiesMinutMetadataLatestSensorValuesTemperature `json:"temperature,omitempty"` + Sound *PhonePropertiesMinutMetadataLatestSensorValuesSound `json:"sound,omitempty"` + Humidity *PhonePropertiesMinutMetadataLatestSensorValuesHumidity `json:"humidity,omitempty"` + Pressure *PhonePropertiesMinutMetadataLatestSensorValuesPressure `json:"pressure,omitempty"` + AccelerometerZ *PhonePropertiesMinutMetadataLatestSensorValuesAccelerometerZ `json:"accelerometer_z,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValues) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadataLatestSensorValues + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadataLatestSensorValues(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValues) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadataLatestSensorValuesAccelerometerZ struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesAccelerometerZ) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadataLatestSensorValuesAccelerometerZ + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadataLatestSensorValuesAccelerometerZ(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesAccelerometerZ) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadataLatestSensorValuesHumidity struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesHumidity) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadataLatestSensorValuesHumidity + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadataLatestSensorValuesHumidity(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesHumidity) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadataLatestSensorValuesPressure struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesPressure) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadataLatestSensorValuesPressure + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadataLatestSensorValuesPressure(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesPressure) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadataLatestSensorValuesSound struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesSound) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadataLatestSensorValuesSound + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadataLatestSensorValuesSound(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesSound) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesMinutMetadataLatestSensorValuesTemperature struct { + Time string `json:"time"` + Value float64 `json:"value"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesTemperature) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesMinutMetadataLatestSensorValuesTemperature + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesMinutMetadataLatestSensorValuesTemperature(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesMinutMetadataLatestSensorValuesTemperature) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesModel struct { + // Display name of the device model. + DisplayName string `json:"display_name"` + // Display name that corresponds to the manufacturer-specific terminology for the device. + ManufacturerDisplayName string `json:"manufacturer_display_name"` + // Indicates whether the device supports offline access codes. + OfflineAccessCodesSupported *bool `json:"offline_access_codes_supported,omitempty"` + // Indicates whether the device supports online access codes. + OnlineAccessCodesSupported *bool `json:"online_access_codes_supported,omitempty"` + // Indicates whether the device supports an accessory keypad. + AccessoryKeypadSupported *bool `json:"accessory_keypad_supported,omitempty"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesModel) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesModel + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesModel(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesModel) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesNestMetadata struct { + NestDeviceId string `json:"nest_device_id"` + DeviceName string `json:"device_name"` + CustomName string `json:"custom_name"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesNestMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesNestMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesNestMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesNestMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesNoiseawareMetadata struct { + DeviceModel PhonePropertiesNoiseawareMetadataDeviceModel `json:"device_model,omitempty"` + NoiseLevelNrs float64 `json:"noise_level_nrs"` + NoiseLevelDecibel float64 `json:"noise_level_decibel"` + DeviceName string `json:"device_name"` + DeviceId string `json:"device_id"` + + _rawJSON json.RawMessage +} + +func (p *PhonePropertiesNoiseawareMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesNoiseawareMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhonePropertiesNoiseawareMetadata(value) + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *PhonePropertiesNoiseawareMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesNoiseawareMetadataDeviceModel string + +const ( + PhonePropertiesNoiseawareMetadataDeviceModelIndoor PhonePropertiesNoiseawareMetadataDeviceModel = "indoor" + PhonePropertiesNoiseawareMetadataDeviceModelOutdoor PhonePropertiesNoiseawareMetadataDeviceModel = "outdoor" +) + +func NewPhonePropertiesNoiseawareMetadataDeviceModelFromString(s string) (PhonePropertiesNoiseawareMetadataDeviceModel, error) { + switch s { + case "indoor": + return PhonePropertiesNoiseawareMetadataDeviceModelIndoor, nil + case "outdoor": + return PhonePropertiesNoiseawareMetadataDeviceModelOutdoor, nil + } + var t PhonePropertiesNoiseawareMetadataDeviceModel return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (m Manufacturer) Ptr() *Manufacturer { - return &m +func (p PhonePropertiesNoiseawareMetadataDeviceModel) Ptr() *PhonePropertiesNoiseawareMetadataDeviceModel { + return &p } -type NoiseThreshold struct { - NoiseThresholdId string `json:"noise_threshold_id"` - DeviceId string `json:"device_id"` - Name string `json:"name"` - NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` - StartsDailyAt string `json:"starts_daily_at"` - EndsDailyAt string `json:"ends_daily_at"` - NoiseThresholdDecibels float64 `json:"noise_threshold_decibels"` +type PhonePropertiesNukiMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + KeypadBatteryCritical *bool `json:"keypad_battery_critical,omitempty"` _rawJSON json.RawMessage } -func (n *NoiseThreshold) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThreshold +func (p *PhonePropertiesNukiMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesNukiMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThreshold(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesNukiMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NoiseThreshold) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesNukiMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) } -type NoiseThresholdsCreateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` +type PhonePropertiesSaltoMetadata struct { + LockId string `json:"lock_id"` + CustomerReference string `json:"customer_reference"` + LockType string `json:"lock_type"` + BatteryLevel string `json:"battery_level"` + LockedState string `json:"locked_state"` + Model *string `json:"model,omitempty"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsCreateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsCreateResponse +func (p *PhonePropertiesSaltoMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesSaltoMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsCreateResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesSaltoMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NoiseThresholdsCreateResponse) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesSaltoMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) } -type NoiseThresholdsDeleteResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` +type PhonePropertiesSchlageMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + AccessCodeLength float64 `json:"access_code_length"` + Model *string `json:"model,omitempty"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsDeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsDeleteResponse +func (p *PhonePropertiesSchlageMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesSchlageMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsDeleteResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesSchlageMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NoiseThresholdsDeleteResponse) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesSchlageMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) } -type NoiseThresholdsGetResponse struct { - NoiseThreshold *NoiseThreshold `json:"noise_threshold,omitempty"` - Ok bool `json:"ok"` +type PhonePropertiesSeamBridgeMetadata struct { + UnlockMethod *PhonePropertiesSeamBridgeMetadataUnlockMethod `json:"unlock_method,omitempty"` + DeviceNum float64 `json:"device_num"` + Name string `json:"name"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsGetResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsGetResponse +func (p *PhonePropertiesSeamBridgeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesSeamBridgeMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsGetResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesSeamBridgeMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NoiseThresholdsGetResponse) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesSeamBridgeMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) +} + +type PhonePropertiesSeamBridgeMetadataUnlockMethod string + +const ( + PhonePropertiesSeamBridgeMetadataUnlockMethodBridge PhonePropertiesSeamBridgeMetadataUnlockMethod = "bridge" + PhonePropertiesSeamBridgeMetadataUnlockMethodDoorking PhonePropertiesSeamBridgeMetadataUnlockMethod = "doorking" +) + +func NewPhonePropertiesSeamBridgeMetadataUnlockMethodFromString(s string) (PhonePropertiesSeamBridgeMetadataUnlockMethod, error) { + switch s { + case "bridge": + return PhonePropertiesSeamBridgeMetadataUnlockMethodBridge, nil + case "doorking": + return PhonePropertiesSeamBridgeMetadataUnlockMethodDoorking, nil + } + var t PhonePropertiesSeamBridgeMetadataUnlockMethod + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PhonePropertiesSeamBridgeMetadataUnlockMethod) Ptr() *PhonePropertiesSeamBridgeMetadataUnlockMethod { + return &p } -type NoiseThresholdsListResponse struct { - NoiseThresholds []*NoiseThreshold `json:"noise_thresholds,omitempty"` - Ok bool `json:"ok"` +type PhonePropertiesSmartthingsMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + Model *string `json:"model,omitempty"` + LocationId *string `json:"location_id,omitempty"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsListResponse +func (p *PhonePropertiesSmartthingsMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesSmartthingsMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsListResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesSmartthingsMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NoiseThresholdsListResponse) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesSmartthingsMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) } -type NoiseThresholdsUpdateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` +type PhonePropertiesTtlockMetadata struct { + LockId float64 `json:"lock_id"` + LockAlias string `json:"lock_alias"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsUpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsUpdateResponse +func (p *PhonePropertiesTtlockMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesTtlockMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsUpdateResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesTtlockMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NoiseThresholdsUpdateResponse) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesTtlockMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) } -type NukiDeviceMetadata struct { - KeypadBatteryCritical *bool `json:"keypad_battery_critical,omitempty"` +type PhonePropertiesTwoNMetadata struct { + DeviceId float64 `json:"device_id"` + DeviceName string `json:"device_name"` _rawJSON json.RawMessage } -func (n *NukiDeviceMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler NukiDeviceMetadata +func (p *PhonePropertiesTwoNMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesTwoNMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NukiDeviceMetadata(value) - n._rawJSON = json.RawMessage(data) + *p = PhonePropertiesTwoNMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (n *NukiDeviceMetadata) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { +func (p *PhonePropertiesTwoNMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(n); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", n) + return fmt.Sprintf("%#v", p) } -type SchlageDeviceMetadata struct { - DeviceId string `json:"device_id"` - DeviceName string `json:"device_name"` - AccessCodeLength int `json:"access_code_length"` - Model *string `json:"model,omitempty"` - LocationId *string `json:"location_id,omitempty"` +type PhonePropertiesWyzeMetadata struct { + DeviceId string `json:"device_id"` + DeviceName string `json:"device_name"` + ProductName string `json:"product_name"` + ProductType string `json:"product_type"` + ProductModel string `json:"product_model"` + DeviceInfoModel string `json:"device_info_model"` _rawJSON json.RawMessage } -func (s *SchlageDeviceMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler SchlageDeviceMetadata +func (p *PhonePropertiesWyzeMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesWyzeMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SchlageDeviceMetadata(value) - s._rawJSON = json.RawMessage(data) + *p = PhonePropertiesWyzeMetadata(value) + p._rawJSON = json.RawMessage(data) return nil } -func (s *SchlageDeviceMetadata) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { +func (p *PhonePropertiesWyzeMetadata) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(s); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", s) + return fmt.Sprintf("%#v", p) } -type ServiceByServiceNameResponse struct { - Ok bool `json:"ok"` - LastServiceEvaluationAt string `json:"last_service_evaluation_at"` - ServiceHealth *ServiceHealth `json:"service_health,omitempty"` +type PhoneWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` _rawJSON json.RawMessage } -func (s *ServiceByServiceNameResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ServiceByServiceNameResponse +func (p *PhoneWarningsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneWarningsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = ServiceByServiceNameResponse(value) - s._rawJSON = json.RawMessage(data) + *p = PhoneWarningsItem(value) + p._rawJSON = json.RawMessage(data) return nil } -func (s *ServiceByServiceNameResponse) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { +func (p *PhoneWarningsItem) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(s); err == nil { + if value, err := core.StringifyJSON(p); err == nil { return value } - return fmt.Sprintf("%#v", s) + return fmt.Sprintf("%#v", p) +} + +type ProviderCategory string + +const ( + ProviderCategoryStable ProviderCategory = "stable" + ProviderCategoryConsumerSmartlocks ProviderCategory = "consumer_smartlocks" +) + +func NewProviderCategoryFromString(s string) (ProviderCategory, error) { + switch s { + case "stable": + return ProviderCategoryStable, nil + case "consumer_smartlocks": + return ProviderCategoryConsumerSmartlocks, nil + } + var t ProviderCategory + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p ProviderCategory) Ptr() *ProviderCategory { + return &p } type ServiceHealth struct { @@ -2076,412 +4907,270 @@ func (s ServiceHealthStatus) Ptr() *ServiceHealthStatus { return &s } -type SimulateCreateUnmanagedAccessCodeResponse struct { - AccessCode *SimulateCreateUnmanagedAccessCodeResponseAccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` +type UnmanagedAccessCode struct { + // Nature of the access code. Values are "ongoing" for access codes that are active continuously until deactivated manually or "time_bound" for access codes that have a specific duration. + Type UnmanagedAccessCodeType `json:"type,omitempty"` + // Unique identifier for the access code. + AccessCodeId string `json:"access_code_id"` + // Unique identifier for the device associated with the access code. + DeviceId string `json:"device_id"` + // Name of the access code. Enables administrators and users to identify the access code easily, especially when there are numerous access codes. + Name *string `json:"name,omitempty"` + // Code used for access. Typically, a numeric or alphanumeric string. + Code *string `json:"code,omitempty"` + // Date and time at which the access code was created. + CreatedAt time.Time `json:"created_at"` + Errors interface{} `json:"errors,omitempty"` + Warnings interface{} `json:"warnings,omitempty"` + IsManaged string `json:"is_managed"` + // Date and time at which the time-bound access code becomes active. + StartsAt *time.Time `json:"starts_at,omitempty"` + // Date and time after which the time-bound access code becomes inactive. + EndsAt *time.Time `json:"ends_at,omitempty"` + status string _rawJSON json.RawMessage } -func (s *SimulateCreateUnmanagedAccessCodeResponse) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateCreateUnmanagedAccessCodeResponse +func (u *UnmanagedAccessCode) Status() string { + return u.status +} + +func (u *UnmanagedAccessCode) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedAccessCode var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SimulateCreateUnmanagedAccessCodeResponse(value) - s._rawJSON = json.RawMessage(data) + *u = UnmanagedAccessCode(value) + u.status = "set" + u._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 { +func (u *UnmanagedAccessCode) MarshalJSON() ([]byte, error) { + type embed UnmanagedAccessCode + var marshaler = struct { + embed + Status string `json:"status"` + }{ + embed: embed(*u), + Status: "set", + } + return json.Marshal(marshaler) +} + +func (u *UnmanagedAccessCode) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(s); err == nil { + if value, err := core.StringifyJSON(u); err == nil { return value } - return fmt.Sprintf("%#v", s) -} - -type SimulateCreateUnmanagedAccessCodeResponseAccessCode struct { - Type string - Ongoing *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing - TimeBound *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound + return fmt.Sprintf("%#v", u) } -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeFromOngoing(value *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) *SimulateCreateUnmanagedAccessCodeResponseAccessCode { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCode{Type: "ongoing", Ongoing: value} -} +// Nature of the access code. Values are "ongoing" for access codes that are active continuously until deactivated manually or "time_bound" for access codes that have a specific duration. +type UnmanagedAccessCodeType string -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeFromTimeBound(value *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) *SimulateCreateUnmanagedAccessCodeResponseAccessCode { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCode{Type: "time_bound", TimeBound: value} -} +const ( + UnmanagedAccessCodeTypeTimeBound UnmanagedAccessCodeType = "time_bound" + UnmanagedAccessCodeTypeOngoing UnmanagedAccessCodeType = "ongoing" +) -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCode) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - s.Type = unmarshaler.Type - switch unmarshaler.Type { - case "ongoing": - value := new(SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.Ongoing = value +func NewUnmanagedAccessCodeTypeFromString(s string) (UnmanagedAccessCodeType, error) { + switch s { case "time_bound": - value := new(SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.TimeBound = value - } - return nil -} - -func (s SimulateCreateUnmanagedAccessCodeResponseAccessCode) MarshalJSON() ([]byte, error) { - switch s.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) + return UnmanagedAccessCodeTypeTimeBound, nil case "ongoing": - var marshaler = struct { - Type string `json:"type"` - *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing - }{ - Type: s.Type, - SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing: s.Ongoing, - } - return json.Marshal(marshaler) - case "time_bound": - var marshaler = struct { - Type string `json:"type"` - *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound - }{ - Type: s.Type, - SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound: s.TimeBound, - } - return json.Marshal(marshaler) + return UnmanagedAccessCodeTypeOngoing, nil } + var t UnmanagedAccessCodeType + return "", fmt.Errorf("%s is not a valid %T", s, t) } -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeVisitor interface { - VisitOngoing(*SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) error - VisitTimeBound(*SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) error -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCode) Accept(visitor SimulateCreateUnmanagedAccessCodeResponseAccessCodeVisitor) error { - switch s.Type { - default: - return fmt.Errorf("invalid type %s in %T", s.Type, s) - case "ongoing": - return visitor.VisitOngoing(s.Ongoing) - case "time_bound": - return visitor.VisitTimeBound(s.TimeBound) - } +func (u UnmanagedAccessCodeType) Ptr() *UnmanagedAccessCodeType { + return &u } -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing struct { - AccessCodeId string `json:"access_code_id"` - Code *string `json:"code,omitempty"` - CreatedAt *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt `json:"created_at,omitempty"` - IsManaged bool `json:"is_managed"` - StartsAt *string `json:"starts_at,omitempty"` - EndsAt *string `json:"ends_at,omitempty"` - status string +type UnmanagedDevice struct { + // Unique identifier for the device. + DeviceId string `json:"device_id"` + // Type of the device. + DeviceType DeviceType `json:"device_type,omitempty"` + // Unique identifier for the account associated with the device. + ConnectedAccountId string `json:"connected_account_id"` + // Collection of capabilities that the device supports when connected to Seam. Values are "access_code," which indicates that the device can manage and utilize digital PIN codes for secure access; "lock," which indicates that the device controls a door locking mechanism, enabling the remote opening and closing of doors and other entry points; "noise_detection," which indicates that the device supports monitoring and responding to ambient noise levels; "thermostat," which indicates that the device can regulate and adjust indoor temperatures; and "battery," which indicates that the device can manage battery life and health. + CapabilitiesSupported []UnmanagedDeviceCapabilitiesSupportedItem `json:"capabilities_supported,omitempty"` + // Unique identifier for the Seam workspace associated with the device. + WorkspaceId string `json:"workspace_id"` + // Array of errors associated with the device. Each error object within the array contains two fields: "error_code" and "message." "error_code" is a string that uniquely identifies the type of error, enabling quick recognition and categorization of the issue. "message" provides a more detailed description of the error, offering insights into the issue and potentially how to rectify it. + Errors []*UnmanagedDeviceErrorsItem `json:"errors,omitempty"` + // Array of warnings associated with the device. Each warning object within the array contains two fields: "warning_code" and "message." "warning_code" is a string that uniquely identifies the type of warning, enabling quick recognition and categorization of the issue. "message" provides a more detailed description of the warning, offering insights into the issue and potentially how to rectify it. + Warnings []*UnmanagedDeviceWarningsItem `json:"warnings,omitempty"` + // Date and time at which the device object was created. + CreatedAt time.Time `json:"created_at"` + IsManaged string `json:"is_managed"` + Properties *UnmanagedDeviceProperties `json:"properties,omitempty"` + DeviceProvider *UnmanagedDeviceDeviceProvider `json:"device_provider,omitempty"` _rawJSON json.RawMessage } -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) Status() string { - return s.status -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing +func (u *UnmanagedDevice) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDevice var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing(value) - s.status = "set" - s._rawJSON = json.RawMessage(data) + *u = UnmanagedDevice(value) + u._rawJSON = json.RawMessage(data) return nil } -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) MarshalJSON() ([]byte, error) { - type embed SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing - var marshaler = struct { - embed - Status string `json:"status"` - }{ - embed: embed(*s), - Status: "set", - } - return json.Marshal(marshaler) -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { +func (u *UnmanagedDevice) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(s); err == nil { + if value, err := core.StringifyJSON(u); err == nil { return value } - return fmt.Sprintf("%#v", s) -} - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt struct { - typeName string - String string - DateTime time.Time -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromString(value string) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "string", String: value} + return fmt.Sprintf("%#v", u) } -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromDateTime(value time.Time) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "dateTime", DateTime: value} -} +type UnmanagedDeviceCapabilitiesSupportedItem string -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) UnmarshalJSON(data []byte) error { - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - s.typeName = "string" - s.String = valueString - return nil - } - var valueDateTime time.Time - if err := json.Unmarshal(data, &valueDateTime); err == nil { - s.typeName = "dateTime" - s.DateTime = valueDateTime - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, s) -} +const ( + UnmanagedDeviceCapabilitiesSupportedItemAccessCode UnmanagedDeviceCapabilitiesSupportedItem = "access_code" + UnmanagedDeviceCapabilitiesSupportedItemLock UnmanagedDeviceCapabilitiesSupportedItem = "lock" + UnmanagedDeviceCapabilitiesSupportedItemNoiseDetection UnmanagedDeviceCapabilitiesSupportedItem = "noise_detection" + UnmanagedDeviceCapabilitiesSupportedItemThermostat UnmanagedDeviceCapabilitiesSupportedItem = "thermostat" + UnmanagedDeviceCapabilitiesSupportedItemBattery UnmanagedDeviceCapabilitiesSupportedItem = "battery" + UnmanagedDeviceCapabilitiesSupportedItemPhone UnmanagedDeviceCapabilitiesSupportedItem = "phone" +) -func (s SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) MarshalJSON() ([]byte, error) { - switch s.typeName { - default: - return nil, fmt.Errorf("invalid type %s in %T", s.typeName, s) - case "string": - return json.Marshal(s.String) - case "dateTime": - return json.Marshal(s.DateTime) +func NewUnmanagedDeviceCapabilitiesSupportedItemFromString(s string) (UnmanagedDeviceCapabilitiesSupportedItem, error) { + switch s { + case "access_code": + return UnmanagedDeviceCapabilitiesSupportedItemAccessCode, nil + case "lock": + return UnmanagedDeviceCapabilitiesSupportedItemLock, nil + case "noise_detection": + return UnmanagedDeviceCapabilitiesSupportedItemNoiseDetection, nil + case "thermostat": + return UnmanagedDeviceCapabilitiesSupportedItemThermostat, nil + case "battery": + return UnmanagedDeviceCapabilitiesSupportedItemBattery, nil + case "phone": + return UnmanagedDeviceCapabilitiesSupportedItemPhone, nil } + var t UnmanagedDeviceCapabilitiesSupportedItem + return "", fmt.Errorf("%s is not a valid %T", s, t) } -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor interface { - VisitString(string) error - VisitDateTime(time.Time) error -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) Accept(visitor SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor) error { - switch s.typeName { - default: - return fmt.Errorf("invalid type %s in %T", s.typeName, s) - case "string": - return visitor.VisitString(s.String) - case "dateTime": - return visitor.VisitDateTime(s.DateTime) - } +func (u UnmanagedDeviceCapabilitiesSupportedItem) Ptr() *UnmanagedDeviceCapabilitiesSupportedItem { + return &u } -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound struct { - AccessCodeId string `json:"access_code_id"` - Code *string `json:"code,omitempty"` - CreatedAt *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt `json:"created_at,omitempty"` - IsManaged bool `json:"is_managed"` - StartsAt *string `json:"starts_at,omitempty"` - EndsAt *string `json:"ends_at,omitempty"` - status string +type UnmanagedDeviceDeviceProvider struct { + ProviderCategories interface{} `json:"provider_categories,omitempty"` _rawJSON json.RawMessage } -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) Status() string { - return s.status -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound +func (u *UnmanagedDeviceDeviceProvider) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceDeviceProvider var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound(value) - s.status = "set" - s._rawJSON = json.RawMessage(data) + *u = UnmanagedDeviceDeviceProvider(value) + u._rawJSON = json.RawMessage(data) return nil } -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) MarshalJSON() ([]byte, error) { - type embed SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound - var marshaler = struct { - embed - Status string `json:"status"` - }{ - embed: embed(*s), - Status: "set", - } - return json.Marshal(marshaler) -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { +func (u *UnmanagedDeviceDeviceProvider) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(s); err == nil { + if value, err := core.StringifyJSON(u); err == nil { return value } - return fmt.Sprintf("%#v", s) -} - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt struct { - typeName string - String string - DateTime time.Time -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAtFromString(value string) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt{typeName: "string", String: value} -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAtFromDateTime(value time.Time) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt{typeName: "dateTime", DateTime: value} -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt) UnmarshalJSON(data []byte) error { - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - s.typeName = "string" - s.String = valueString - return nil - } - var valueDateTime time.Time - if err := json.Unmarshal(data, &valueDateTime); err == nil { - s.typeName = "dateTime" - s.DateTime = valueDateTime - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, s) -} - -func (s SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt) MarshalJSON() ([]byte, error) { - switch s.typeName { - default: - return nil, fmt.Errorf("invalid type %s in %T", s.typeName, s) - case "string": - return json.Marshal(s.String) - case "dateTime": - return json.Marshal(s.DateTime) - } -} - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAtVisitor interface { - VisitString(string) error - VisitDateTime(time.Time) error -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt) Accept(visitor SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAtVisitor) error { - switch s.typeName { - default: - return fmt.Errorf("invalid type %s in %T", s.typeName, s) - case "string": - return visitor.VisitString(s.String) - case "dateTime": - return visitor.VisitDateTime(s.DateTime) - } + return fmt.Sprintf("%#v", u) } -type SimulateTriggerNoiseThresholdResponse struct { - Ok bool `json:"ok"` +type UnmanagedDeviceErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` _rawJSON json.RawMessage } -func (s *SimulateTriggerNoiseThresholdResponse) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateTriggerNoiseThresholdResponse +func (u *UnmanagedDeviceErrorsItem) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceErrorsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SimulateTriggerNoiseThresholdResponse(value) - s._rawJSON = json.RawMessage(data) + *u = UnmanagedDeviceErrorsItem(value) + u._rawJSON = json.RawMessage(data) return nil } -func (s *SimulateTriggerNoiseThresholdResponse) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { +func (u *UnmanagedDeviceErrorsItem) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value - } - } - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type SupportedCapabililty string - -const ( - SupportedCapabililtyAccessCode SupportedCapabililty = "access_code" - SupportedCapabililtyLock SupportedCapabililty = "lock" - SupportedCapabililtyNoiseDetection SupportedCapabililty = "noise_detection" - SupportedCapabililtyThermostat SupportedCapabililty = "thermostat" - SupportedCapabililtyBattery SupportedCapabililty = "battery" -) - -func NewSupportedCapabililtyFromString(s string) (SupportedCapabililty, error) { - switch s { - case "access_code": - return SupportedCapabililtyAccessCode, nil - case "lock": - return SupportedCapabililtyLock, nil - case "noise_detection": - return SupportedCapabililtyNoiseDetection, nil - case "thermostat": - return SupportedCapabililtyThermostat, nil - case "battery": - return SupportedCapabililtyBattery, nil + } } - var t SupportedCapabililty - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (s SupportedCapabililty) Ptr() *SupportedCapabililty { - return &s + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) } -type UnmanagedConvertToManagedResponse struct { - Ok bool `json:"ok"` +type UnmanagedDeviceProperties struct { + // Name of the device. Enables administrators and users to identify the device easily, especially when there are numerous devices. + Name string `json:"name"` + // Indicates whether the device is online. + Online bool `json:"online"` + // Manufacturer of the device. + Manufacturer *string `json:"manufacturer,omitempty"` + // Image URL for the device. + ImageUrl *string `json:"image_url,omitempty"` + // Alt text for the device image. + ImageAltText *string `json:"image_alt_text,omitempty"` + // Indicates the battery level of the device as a decimal value between 0 and 1, inclusive. + BatteryLevel *float64 `json:"battery_level,omitempty"` + // Represents the current status of the battery charge level. Values are "critical," which indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging; "low," which signifies that the battery is under the preferred threshold and should be charged soon; "good," which denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging; and "full," which represents a battery that is fully charged, providing the maximum duration of usage. + Battery *UnmanagedDevicePropertiesBattery `json:"battery,omitempty"` + // Indicates whether it is currently possible to use online access codes for the device. + OnlineAccessCodesEnabled *bool `json:"online_access_codes_enabled,omitempty"` + // Indicates whether it is currently possible to use offline access codes for the device. + OfflineAccessCodesEnabled *bool `json:"offline_access_codes_enabled,omitempty"` + Model *UnmanagedDevicePropertiesModel `json:"model,omitempty"` _rawJSON json.RawMessage } -func (u *UnmanagedConvertToManagedResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedConvertToManagedResponse +func (u *UnmanagedDeviceProperties) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceProperties var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedConvertToManagedResponse(value) + *u = UnmanagedDeviceProperties(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedConvertToManagedResponse) String() string { +func (u *UnmanagedDeviceProperties) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2493,25 +5182,26 @@ func (u *UnmanagedConvertToManagedResponse) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedDeleteResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` +// Represents the current status of the battery charge level. Values are "critical," which indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging; "low," which signifies that the battery is under the preferred threshold and should be charged soon; "good," which denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging; and "full," which represents a battery that is fully charged, providing the maximum duration of usage. +type UnmanagedDevicePropertiesBattery struct { + Level float64 `json:"level"` + Status UnmanagedDevicePropertiesBatteryStatus `json:"status,omitempty"` _rawJSON json.RawMessage } -func (u *UnmanagedDeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeleteResponse +func (u *UnmanagedDevicePropertiesBattery) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDevicePropertiesBattery var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeleteResponse(value) + *u = UnmanagedDevicePropertiesBattery(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDeleteResponse) String() string { +func (u *UnmanagedDevicePropertiesBattery) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2523,33 +5213,61 @@ func (u *UnmanagedDeleteResponse) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedDevice struct { - DeviceId string `json:"device_id"` - DeviceType DeviceType `json:"device_type,omitempty"` - ConnectedAccountId string `json:"connected_account_id"` - CapabilitiesSupported []SupportedCapabililty `json:"capabilities_supported,omitempty"` - WorkspaceId string `json:"workspace_id"` - Errors []*UnmanagedDeviceErrorsItem `json:"errors,omitempty"` - Warnings []*UnmanagedDeviceWarningsItem `json:"warnings,omitempty"` - CreatedAt time.Time `json:"created_at"` - IsManaged bool `json:"is_managed"` - Properties *UnmanagedDeviceProperties `json:"properties,omitempty"` +type UnmanagedDevicePropertiesBatteryStatus string + +const ( + UnmanagedDevicePropertiesBatteryStatusCritical UnmanagedDevicePropertiesBatteryStatus = "critical" + UnmanagedDevicePropertiesBatteryStatusLow UnmanagedDevicePropertiesBatteryStatus = "low" + UnmanagedDevicePropertiesBatteryStatusGood UnmanagedDevicePropertiesBatteryStatus = "good" + UnmanagedDevicePropertiesBatteryStatusFull UnmanagedDevicePropertiesBatteryStatus = "full" +) + +func NewUnmanagedDevicePropertiesBatteryStatusFromString(s string) (UnmanagedDevicePropertiesBatteryStatus, error) { + switch s { + case "critical": + return UnmanagedDevicePropertiesBatteryStatusCritical, nil + case "low": + return UnmanagedDevicePropertiesBatteryStatusLow, nil + case "good": + return UnmanagedDevicePropertiesBatteryStatusGood, nil + case "full": + return UnmanagedDevicePropertiesBatteryStatusFull, nil + } + var t UnmanagedDevicePropertiesBatteryStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (u UnmanagedDevicePropertiesBatteryStatus) Ptr() *UnmanagedDevicePropertiesBatteryStatus { + return &u +} + +type UnmanagedDevicePropertiesModel struct { + // Display name of the device model. + DisplayName string `json:"display_name"` + // Display name that corresponds to the manufacturer-specific terminology for the device. + ManufacturerDisplayName string `json:"manufacturer_display_name"` + // Indicates whether the device supports offline access codes. + OfflineAccessCodesSupported *bool `json:"offline_access_codes_supported,omitempty"` + // Indicates whether the device supports online access codes. + OnlineAccessCodesSupported *bool `json:"online_access_codes_supported,omitempty"` + // Indicates whether the device supports an accessory keypad. + AccessoryKeypadSupported *bool `json:"accessory_keypad_supported,omitempty"` _rawJSON json.RawMessage } -func (u *UnmanagedDevice) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDevice +func (u *UnmanagedDevicePropertiesModel) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDevicePropertiesModel var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDevice(value) + *u = UnmanagedDevicePropertiesModel(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDevice) String() string { +func (u *UnmanagedDevicePropertiesModel) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2561,25 +5279,25 @@ func (u *UnmanagedDevice) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedDeviceErrorsItem struct { - ErrorCode string `json:"error_code"` - Message string `json:"message"` +type UnmanagedDeviceWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` _rawJSON json.RawMessage } -func (u *UnmanagedDeviceErrorsItem) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeviceErrorsItem +func (u *UnmanagedDeviceWarningsItem) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceWarningsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeviceErrorsItem(value) + *u = UnmanagedDeviceWarningsItem(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDeviceErrorsItem) String() string { +func (u *UnmanagedDeviceWarningsItem) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2591,227 +5309,245 @@ func (u *UnmanagedDeviceErrorsItem) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedDeviceProperties struct { - Name string `json:"name"` - Online bool `json:"online"` - Manufacturer *string `json:"manufacturer,omitempty"` - ImageUrl *string `json:"image_url,omitempty"` - ImageAltText *string `json:"image_alt_text,omitempty"` - Model *UnmanagedDevicePropertiesModel `json:"model,omitempty"` +type Webhook struct { + WebhookId string `json:"webhook_id"` + Url string `json:"url"` + EventTypes []string `json:"event_types,omitempty"` + Secret *string `json:"secret,omitempty"` _rawJSON json.RawMessage } -func (u *UnmanagedDeviceProperties) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeviceProperties +func (w *Webhook) UnmarshalJSON(data []byte) error { + type unmarshaler Webhook var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeviceProperties(value) - u._rawJSON = json.RawMessage(data) + *w = Webhook(value) + w._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDeviceProperties) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { +func (w *Webhook) String() string { + if len(w._rawJSON) > 0 { + if value, err := core.StringifyJSON(w._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(u); err == nil { + if value, err := core.StringifyJSON(w); err == nil { return value } - return fmt.Sprintf("%#v", u) + return fmt.Sprintf("%#v", w) } -type UnmanagedDevicePropertiesModel struct { - DisplayName string `json:"display_name"` +type Workspace struct { + WorkspaceId string `json:"workspace_id"` + Name string `json:"name"` + IsSandbox bool `json:"is_sandbox"` + ConnectPartnerName *string `json:"connect_partner_name,omitempty"` _rawJSON json.RawMessage } -func (u *UnmanagedDevicePropertiesModel) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDevicePropertiesModel +func (w *Workspace) UnmarshalJSON(data []byte) error { + type unmarshaler Workspace var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDevicePropertiesModel(value) - u._rawJSON = json.RawMessage(data) + *w = Workspace(value) + w._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDevicePropertiesModel) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { +func (w *Workspace) String() string { + if len(w._rawJSON) > 0 { + if value, err := core.StringifyJSON(w._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(u); err == nil { + if value, err := core.StringifyJSON(w); err == nil { return value } - return fmt.Sprintf("%#v", u) + return fmt.Sprintf("%#v", w) } -type UnmanagedDeviceWarningsItem struct { - WarningCode string `json:"warning_code"` - Message string `json:"message"` +type ConnectedAccountsGetRequestConnectedAccountId struct { + ConnectedAccountId string `json:"connected_account_id"` _rawJSON json.RawMessage } -func (u *UnmanagedDeviceWarningsItem) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeviceWarningsItem +func (c *ConnectedAccountsGetRequestConnectedAccountId) UnmarshalJSON(data []byte) error { + type unmarshaler ConnectedAccountsGetRequestConnectedAccountId var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeviceWarningsItem(value) - u._rawJSON = json.RawMessage(data) + *c = ConnectedAccountsGetRequestConnectedAccountId(value) + c._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDeviceWarningsItem) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { +func (c *ConnectedAccountsGetRequestConnectedAccountId) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(u); err == nil { + if value, err := core.StringifyJSON(c); err == nil { return value } - return fmt.Sprintf("%#v", u) + return fmt.Sprintf("%#v", c) } -type UnmanagedGetResponse struct { - AccessCode *UnmanagedGetResponseAccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` +type ConnectedAccountsGetRequestEmail struct { + Email string `json:"email"` _rawJSON json.RawMessage } -func (u *UnmanagedGetResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedGetResponse +func (c *ConnectedAccountsGetRequestEmail) UnmarshalJSON(data []byte) error { + type unmarshaler ConnectedAccountsGetRequestEmail var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedGetResponse(value) - u._rawJSON = json.RawMessage(data) + *c = ConnectedAccountsGetRequestEmail(value) + c._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedGetResponse) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { +func (c *ConnectedAccountsGetRequestEmail) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(u); err == nil { + if value, err := core.StringifyJSON(c); err == nil { return value } - return fmt.Sprintf("%#v", u) + return fmt.Sprintf("%#v", c) } -type UnmanagedGetResponseAccessCode struct { - Type UnmanagedGetResponseAccessCodeType `json:"type,omitempty"` - AccessCodeId string `json:"access_code_id"` - DeviceId string `json:"device_id"` - Name *string `json:"name,omitempty"` - Code *string `json:"code,omitempty"` - CreatedAt time.Time `json:"created_at"` - Errors interface{} `json:"errors,omitempty"` - Warnings interface{} `json:"warnings,omitempty"` - IsManaged bool `json:"is_managed"` - StartsAt *time.Time `json:"starts_at,omitempty"` - EndsAt *time.Time `json:"ends_at,omitempty"` - status string +type NetworksGetResponseNetwork struct { + NetworkId string `json:"network_id"` + WorkspaceId string `json:"workspace_id"` + DisplayName string `json:"display_name"` + CreatedAt time.Time `json:"created_at"` _rawJSON json.RawMessage } -func (u *UnmanagedGetResponseAccessCode) Status() string { - return u.status -} - -func (u *UnmanagedGetResponseAccessCode) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedGetResponseAccessCode +func (n *NetworksGetResponseNetwork) UnmarshalJSON(data []byte) error { + type unmarshaler NetworksGetResponseNetwork var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedGetResponseAccessCode(value) - u.status = "set" - u._rawJSON = json.RawMessage(data) + *n = NetworksGetResponseNetwork(value) + n._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedGetResponseAccessCode) MarshalJSON() ([]byte, error) { - type embed UnmanagedGetResponseAccessCode - var marshaler = struct { - embed - Status string `json:"status"` - }{ - embed: embed(*u), - Status: "set", +func (n *NetworksGetResponseNetwork) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } } - return json.Marshal(marshaler) + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) } -func (u *UnmanagedGetResponseAccessCode) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { +type NetworksListResponseNetworksItem struct { + NetworkId string `json:"network_id"` + WorkspaceId string `json:"workspace_id"` + DisplayName string `json:"display_name"` + CreatedAt time.Time `json:"created_at"` + + _rawJSON json.RawMessage +} + +func (n *NetworksListResponseNetworksItem) UnmarshalJSON(data []byte) error { + type unmarshaler NetworksListResponseNetworksItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NetworksListResponseNetworksItem(value) + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NetworksListResponseNetworksItem) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(u); err == nil { + if value, err := core.StringifyJSON(n); err == nil { return value } - return fmt.Sprintf("%#v", u) + return fmt.Sprintf("%#v", n) } -type UnmanagedGetResponseAccessCodeType string +type ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting string const ( - UnmanagedGetResponseAccessCodeTypeTimeBound UnmanagedGetResponseAccessCodeType = "time_bound" - UnmanagedGetResponseAccessCodeTypeOngoing UnmanagedGetResponseAccessCodeType = "ongoing" + ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingOff ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting = "off" + ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingHeat ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting = "heat" + ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingCool ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting = "cool" + ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingHeatCool ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting = "heat_cool" ) -func NewUnmanagedGetResponseAccessCodeTypeFromString(s string) (UnmanagedGetResponseAccessCodeType, error) { +func NewThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingFromString(s string) (ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting, error) { switch s { - case "time_bound": - return UnmanagedGetResponseAccessCodeTypeTimeBound, nil - case "ongoing": - return UnmanagedGetResponseAccessCodeTypeOngoing, nil + case "off": + return ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingOff, nil + case "heat": + return ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingHeat, nil + case "cool": + return ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingCool, nil + case "heat_cool": + return ThermostatsUpdateRequestDefaultClimateSettingHvacModeSettingHeatCool, nil } - var t UnmanagedGetResponseAccessCodeType + var t ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (u UnmanagedGetResponseAccessCodeType) Ptr() *UnmanagedGetResponseAccessCodeType { - return &u +func (t ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting) Ptr() *ThermostatsUpdateRequestDefaultClimateSettingHvacModeSetting { + return &t } -type UnmanagedListResponse struct { - Devices []*UnmanagedDevice `json:"devices,omitempty"` - Ok bool `json:"ok"` +type UserIdentitiesCreateResponseUserIdentity struct { + UserIdentityId string `json:"user_identity_id"` + UserIdentityKey *string `json:"user_identity_key,omitempty"` + EmailAddress *string `json:"email_address,omitempty"` + PhoneNumber *string `json:"phone_number,omitempty"` + DisplayName string `json:"display_name"` + FullName *string `json:"full_name,omitempty"` + CreatedAt time.Time `json:"created_at"` + WorkspaceId string `json:"workspace_id"` _rawJSON json.RawMessage } -func (u *UnmanagedListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedListResponse +func (u *UserIdentitiesCreateResponseUserIdentity) UnmarshalJSON(data []byte) error { + type unmarshaler UserIdentitiesCreateResponseUserIdentity var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedListResponse(value) + *u = UserIdentitiesCreateResponseUserIdentity(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedListResponse) String() string { +func (u *UserIdentitiesCreateResponseUserIdentity) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2823,52 +5559,24 @@ func (u *UnmanagedListResponse) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedListResponseAccessCodesItem struct { - Type UnmanagedListResponseAccessCodesItemType `json:"type,omitempty"` - AccessCodeId string `json:"access_code_id"` - DeviceId string `json:"device_id"` - Name *string `json:"name,omitempty"` - Code *string `json:"code,omitempty"` - CreatedAt time.Time `json:"created_at"` - Errors interface{} `json:"errors,omitempty"` - Warnings interface{} `json:"warnings,omitempty"` - IsManaged bool `json:"is_managed"` - StartsAt *time.Time `json:"starts_at,omitempty"` - EndsAt *time.Time `json:"ends_at,omitempty"` - status string +type UserIdentitiesGetRequestUserIdentityId struct { + UserIdentityId string `json:"user_identity_id"` _rawJSON json.RawMessage } -func (u *UnmanagedListResponseAccessCodesItem) Status() string { - return u.status -} - -func (u *UnmanagedListResponseAccessCodesItem) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedListResponseAccessCodesItem +func (u *UserIdentitiesGetRequestUserIdentityId) UnmarshalJSON(data []byte) error { + type unmarshaler UserIdentitiesGetRequestUserIdentityId var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedListResponseAccessCodesItem(value) - u.status = "set" + *u = UserIdentitiesGetRequestUserIdentityId(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedListResponseAccessCodesItem) MarshalJSON() ([]byte, error) { - type embed UnmanagedListResponseAccessCodesItem - var marshaler = struct { - embed - Status string `json:"status"` - }{ - embed: embed(*u), - Status: "set", - } - return json.Marshal(marshaler) -} - -func (u *UnmanagedListResponseAccessCodesItem) String() string { +func (u *UserIdentitiesGetRequestUserIdentityId) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2880,46 +5588,24 @@ func (u *UnmanagedListResponseAccessCodesItem) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedListResponseAccessCodesItemType string - -const ( - UnmanagedListResponseAccessCodesItemTypeTimeBound UnmanagedListResponseAccessCodesItemType = "time_bound" - UnmanagedListResponseAccessCodesItemTypeOngoing UnmanagedListResponseAccessCodesItemType = "ongoing" -) - -func NewUnmanagedListResponseAccessCodesItemTypeFromString(s string) (UnmanagedListResponseAccessCodesItemType, error) { - switch s { - case "time_bound": - return UnmanagedListResponseAccessCodesItemTypeTimeBound, nil - case "ongoing": - return UnmanagedListResponseAccessCodesItemTypeOngoing, nil - } - var t UnmanagedListResponseAccessCodesItemType - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (u UnmanagedListResponseAccessCodesItemType) Ptr() *UnmanagedListResponseAccessCodesItemType { - return &u -} - -type UnmanagedUpdateResponse struct { - Ok bool `json:"ok"` +type UserIdentitiesGetRequestUserIdentityKey struct { + UserIdentityKey string `json:"user_identity_key"` _rawJSON json.RawMessage } -func (u *UnmanagedUpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedUpdateResponse +func (u *UserIdentitiesGetRequestUserIdentityKey) UnmarshalJSON(data []byte) error { + type unmarshaler UserIdentitiesGetRequestUserIdentityKey var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedUpdateResponse(value) + *u = UserIdentitiesGetRequestUserIdentityKey(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedUpdateResponse) String() string { +func (u *UserIdentitiesGetRequestUserIdentityKey) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2931,66 +5617,74 @@ func (u *UnmanagedUpdateResponse) String() string { return fmt.Sprintf("%#v", u) } -type Webhook struct { - WebhookId string `json:"webhook_id"` - Url string `json:"url"` - EventTypes []string `json:"event_types,omitempty"` - Secret *string `json:"secret,omitempty"` +type UserIdentitiesGetResponseUserIdentity struct { + UserIdentityId string `json:"user_identity_id"` + UserIdentityKey *string `json:"user_identity_key,omitempty"` + EmailAddress *string `json:"email_address,omitempty"` + PhoneNumber *string `json:"phone_number,omitempty"` + DisplayName string `json:"display_name"` + FullName *string `json:"full_name,omitempty"` + CreatedAt time.Time `json:"created_at"` + WorkspaceId string `json:"workspace_id"` _rawJSON json.RawMessage } -func (w *Webhook) UnmarshalJSON(data []byte) error { - type unmarshaler Webhook +func (u *UserIdentitiesGetResponseUserIdentity) UnmarshalJSON(data []byte) error { + type unmarshaler UserIdentitiesGetResponseUserIdentity var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *w = Webhook(value) - w._rawJSON = json.RawMessage(data) + *u = UserIdentitiesGetResponseUserIdentity(value) + u._rawJSON = json.RawMessage(data) return nil } -func (w *Webhook) String() string { - if len(w._rawJSON) > 0 { - if value, err := core.StringifyJSON(w._rawJSON); err == nil { +func (u *UserIdentitiesGetResponseUserIdentity) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(w); err == nil { + if value, err := core.StringifyJSON(u); err == nil { return value } - return fmt.Sprintf("%#v", w) + return fmt.Sprintf("%#v", u) } -type Workspace struct { - WorkspaceId string `json:"workspace_id"` - Name string `json:"name"` - IsSandbox bool `json:"is_sandbox"` - ConnectPartnerName *string `json:"connect_partner_name,omitempty"` +type UserIdentitiesListResponseUserIdentitiesItem struct { + UserIdentityId string `json:"user_identity_id"` + UserIdentityKey *string `json:"user_identity_key,omitempty"` + EmailAddress *string `json:"email_address,omitempty"` + PhoneNumber *string `json:"phone_number,omitempty"` + DisplayName string `json:"display_name"` + FullName *string `json:"full_name,omitempty"` + CreatedAt time.Time `json:"created_at"` + WorkspaceId string `json:"workspace_id"` _rawJSON json.RawMessage } -func (w *Workspace) UnmarshalJSON(data []byte) error { - type unmarshaler Workspace +func (u *UserIdentitiesListResponseUserIdentitiesItem) UnmarshalJSON(data []byte) error { + type unmarshaler UserIdentitiesListResponseUserIdentitiesItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *w = Workspace(value) - w._rawJSON = json.RawMessage(data) + *u = UserIdentitiesListResponseUserIdentitiesItem(value) + u._rawJSON = json.RawMessage(data) return nil } -func (w *Workspace) String() string { - if len(w._rawJSON) > 0 { - if value, err := core.StringifyJSON(w._rawJSON); err == nil { +func (u *UserIdentitiesListResponseUserIdentitiesItem) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value } } - if value, err := core.StringifyJSON(w); err == nil { + if value, err := core.StringifyJSON(u); err == nil { return value } - return fmt.Sprintf("%#v", w) + return fmt.Sprintf("%#v", u) } diff --git a/useridentities/user_identities.go b/user_identities.go similarity index 81% rename from useridentities/user_identities.go rename to user_identities.go index 4a25ac2..832b609 100644 --- a/useridentities/user_identities.go +++ b/user_identities.go @@ -1,14 +1,52 @@ // This file was auto-generated by Fern from our API Definition. -package useridentities +package api import ( json "encoding/json" fmt "fmt" - seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" ) +type UserIdentitiesAddAcsUserRequest struct { + UserIdentityId string `json:"user_identity_id"` + AcsUserId string `json:"acs_user_id"` +} + +type UserIdentitiesCreateRequest struct { + UserIdentityKey *string `json:"user_identity_key,omitempty"` + EmailAddress *string `json:"email_address,omitempty"` + PhoneNumber *string `json:"phone_number,omitempty"` + FullName *string `json:"full_name,omitempty"` +} + +type UserIdentitiesGrantAccessToDeviceRequest struct { + UserIdentityId string `json:"user_identity_id"` + DeviceId string `json:"device_id"` +} + +type UserIdentitiesListAccessibleDevicesRequest struct { + UserIdentityId string `json:"user_identity_id"` +} + +type UserIdentitiesListAcsSystemsRequest struct { + UserIdentityId string `json:"user_identity_id"` +} + +type UserIdentitiesListAcsUsersRequest struct { + UserIdentityId string `json:"user_identity_id"` +} + +type UserIdentitiesRemoveAcsUserRequest struct { + UserIdentityId string `json:"user_identity_id"` + AcsUserId string `json:"acs_user_id"` +} + +type UserIdentitiesRevokeAccessToDeviceRequest struct { + UserIdentityId string `json:"user_identity_id"` + DeviceId string `json:"device_id"` +} + type UserIdentitiesAddAcsUserResponse struct { Ok bool `json:"ok"` @@ -185,8 +223,8 @@ func (u *UserIdentitiesGrantAccessToDeviceResponse) String() string { } type UserIdentitiesListAccessibleDevicesResponse struct { - AccessibleDevices []*seamapigo.Device `json:"accessible_devices,omitempty"` - Ok bool `json:"ok"` + AccessibleDevices []*Device `json:"accessible_devices,omitempty"` + Ok bool `json:"ok"` _rawJSON json.RawMessage } @@ -214,9 +252,39 @@ func (u *UserIdentitiesListAccessibleDevicesResponse) String() string { return fmt.Sprintf("%#v", u) } +type UserIdentitiesListAcsSystemsResponse struct { + AcsSystems []*AcsSystem `json:"acs_systems,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (u *UserIdentitiesListAcsSystemsResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UserIdentitiesListAcsSystemsResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserIdentitiesListAcsSystemsResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UserIdentitiesListAcsSystemsResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UserIdentitiesListAcsUsersResponse struct { - AcsUsers []*seamapigo.AcsUser `json:"acs_users,omitempty"` - Ok bool `json:"ok"` + AcsUsers []*AcsUser `json:"acs_users,omitempty"` + Ok bool `json:"ok"` _rawJSON json.RawMessage } diff --git a/useridentities/client/client.go b/useridentities/client/client.go index f001624..52262e1 100644 --- a/useridentities/client/client.go +++ b/useridentities/client/client.go @@ -9,7 +9,6 @@ import ( errors "errors" seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" - useridentities "github.com/seamapi/go/useridentities" enrollmentautomations "github.com/seamapi/go/useridentities/enrollmentautomations" io "io" http "net/http" @@ -36,7 +35,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) AddAcsUser(ctx context.Context, request *useridentities.UserIdentitiesAddAcsUserRequest) (*useridentities.UserIdentitiesAddAcsUserResponse, error) { +func (c *Client) AddAcsUser(ctx context.Context, request *seamapigo.UserIdentitiesAddAcsUserRequest) (*seamapigo.UserIdentitiesAddAcsUserResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -69,7 +68,7 @@ func (c *Client) AddAcsUser(ctx context.Context, request *useridentities.UserIde return apiError } - var response *useridentities.UserIdentitiesAddAcsUserResponse + var response *seamapigo.UserIdentitiesAddAcsUserResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -86,7 +85,7 @@ func (c *Client) AddAcsUser(ctx context.Context, request *useridentities.UserIde return response, nil } -func (c *Client) Create(ctx context.Context, request *useridentities.UserIdentitiesCreateRequest) (*useridentities.UserIdentitiesCreateResponseUserIdentity, error) { +func (c *Client) Create(ctx context.Context, request *seamapigo.UserIdentitiesCreateRequest) (*seamapigo.UserIdentitiesCreateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -119,7 +118,7 @@ func (c *Client) Create(ctx context.Context, request *useridentities.UserIdentit return apiError } - var response *useridentities.UserIdentitiesCreateResponse + var response *seamapigo.UserIdentitiesCreateResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -133,10 +132,10 @@ func (c *Client) Create(ctx context.Context, request *useridentities.UserIdentit ); err != nil { return nil, err } - return response.UserIdentity, nil + return response, nil } -func (c *Client) Get(ctx context.Context, request *useridentities.UserIdentitiesGetRequest) (*useridentities.UserIdentitiesGetResponseUserIdentity, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.UserIdentitiesGetRequest) (*seamapigo.UserIdentitiesGetResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -169,7 +168,7 @@ func (c *Client) Get(ctx context.Context, request *useridentities.UserIdentities return apiError } - var response *useridentities.UserIdentitiesGetResponse + var response *seamapigo.UserIdentitiesGetResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -183,10 +182,10 @@ func (c *Client) Get(ctx context.Context, request *useridentities.UserIdentities ); err != nil { return nil, err } - return response.UserIdentity, nil + return response, nil } -func (c *Client) GrantAccessToDevice(ctx context.Context, request *useridentities.UserIdentitiesGrantAccessToDeviceRequest) (*useridentities.UserIdentitiesGrantAccessToDeviceResponse, error) { +func (c *Client) GrantAccessToDevice(ctx context.Context, request *seamapigo.UserIdentitiesGrantAccessToDeviceRequest) (*seamapigo.UserIdentitiesGrantAccessToDeviceResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -219,7 +218,7 @@ func (c *Client) GrantAccessToDevice(ctx context.Context, request *useridentitie return apiError } - var response *useridentities.UserIdentitiesGrantAccessToDeviceResponse + var response *seamapigo.UserIdentitiesGrantAccessToDeviceResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -236,7 +235,7 @@ func (c *Client) GrantAccessToDevice(ctx context.Context, request *useridentitie return response, nil } -func (c *Client) List(ctx context.Context) ([]*useridentities.UserIdentitiesListResponseUserIdentitiesItem, error) { +func (c *Client) List(ctx context.Context) ([]*seamapigo.UserIdentitiesListResponseUserIdentitiesItem, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -269,7 +268,7 @@ func (c *Client) List(ctx context.Context) ([]*useridentities.UserIdentitiesList return apiError } - var response *useridentities.UserIdentitiesListResponse + var response *seamapigo.UserIdentitiesListResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -285,7 +284,7 @@ func (c *Client) List(ctx context.Context) ([]*useridentities.UserIdentitiesList return response.UserIdentities, nil } -func (c *Client) ListAccessibleDevices(ctx context.Context, request *useridentities.UserIdentitiesListAccessibleDevicesRequest) (*useridentities.UserIdentitiesListAccessibleDevicesResponse, error) { +func (c *Client) ListAccessibleDevices(ctx context.Context, request *seamapigo.UserIdentitiesListAccessibleDevicesRequest) (*seamapigo.UserIdentitiesListAccessibleDevicesResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -318,7 +317,57 @@ func (c *Client) ListAccessibleDevices(ctx context.Context, request *useridentit return apiError } - var response *useridentities.UserIdentitiesListAccessibleDevicesResponse + var response *seamapigo.UserIdentitiesListAccessibleDevicesResponse + 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, nil +} + +func (c *Client) ListAcsSystems(ctx context.Context, request *seamapigo.UserIdentitiesListAcsSystemsRequest) (*seamapigo.UserIdentitiesListAcsSystemsResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "user_identities/list_acs_systems" + + 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.UserIdentitiesListAcsSystemsResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -335,7 +384,7 @@ func (c *Client) ListAccessibleDevices(ctx context.Context, request *useridentit return response, nil } -func (c *Client) ListAcsUsers(ctx context.Context, request *useridentities.UserIdentitiesListAcsUsersRequest) (*useridentities.UserIdentitiesListAcsUsersResponse, error) { +func (c *Client) ListAcsUsers(ctx context.Context, request *seamapigo.UserIdentitiesListAcsUsersRequest) (*seamapigo.UserIdentitiesListAcsUsersResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -368,7 +417,7 @@ func (c *Client) ListAcsUsers(ctx context.Context, request *useridentities.UserI return apiError } - var response *useridentities.UserIdentitiesListAcsUsersResponse + var response *seamapigo.UserIdentitiesListAcsUsersResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -385,7 +434,7 @@ func (c *Client) ListAcsUsers(ctx context.Context, request *useridentities.UserI return response, nil } -func (c *Client) RemoveAcsUser(ctx context.Context, request *useridentities.UserIdentitiesRemoveAcsUserRequest) (*useridentities.UserIdentitiesRemoveAcsUserResponse, error) { +func (c *Client) RemoveAcsUser(ctx context.Context, request *seamapigo.UserIdentitiesRemoveAcsUserRequest) (*seamapigo.UserIdentitiesRemoveAcsUserResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -418,7 +467,7 @@ func (c *Client) RemoveAcsUser(ctx context.Context, request *useridentities.User return apiError } - var response *useridentities.UserIdentitiesRemoveAcsUserResponse + var response *seamapigo.UserIdentitiesRemoveAcsUserResponse if err := c.caller.Call( ctx, &core.CallParams{ @@ -435,7 +484,7 @@ func (c *Client) RemoveAcsUser(ctx context.Context, request *useridentities.User return response, nil } -func (c *Client) RevokeAccessToDevice(ctx context.Context, request *useridentities.UserIdentitiesRevokeAccessToDeviceRequest) (*useridentities.UserIdentitiesRevokeAccessToDeviceResponse, error) { +func (c *Client) RevokeAccessToDevice(ctx context.Context, request *seamapigo.UserIdentitiesRevokeAccessToDeviceRequest) (*seamapigo.UserIdentitiesRevokeAccessToDeviceResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -468,7 +517,7 @@ func (c *Client) RevokeAccessToDevice(ctx context.Context, request *useridentiti return apiError } - var response *useridentities.UserIdentitiesRevokeAccessToDeviceResponse + var response *seamapigo.UserIdentitiesRevokeAccessToDeviceResponse if err := c.caller.Call( ctx, &core.CallParams{ diff --git a/useridentities/enrollment_automations.go b/useridentities/enrollment_automations.go index db8f061..ec4526b 100644 --- a/useridentities/enrollment_automations.go +++ b/useridentities/enrollment_automations.go @@ -5,9 +5,14 @@ package useridentities import ( json "encoding/json" fmt "fmt" + seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" ) +type EnrollmentAutomationsGetRequest struct { + EnrollmentAutomationId string `json:"enrollment_automation_id"` +} + type EnrollmentAutomationsLaunchRequest struct { UserIdentityId string `json:"user_identity_id"` CredentialManagerAcsSystemId string `json:"credential_manager_acs_system_id"` @@ -16,6 +21,40 @@ type EnrollmentAutomationsLaunchRequest struct { CredentialManagerAcsUserId *string `json:"credential_manager_acs_user_id,omitempty"` } +type EnrollmentAutomationsListRequest struct { + UserIdentityId string `json:"user_identity_id"` +} + +type EnrollmentAutomationsGetResponse struct { + EnrollmentAutomation *seamapigo.EnrollmentAutomation `json:"enrollment_automation,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (e *EnrollmentAutomationsGetResponse) UnmarshalJSON(data []byte) error { + type unmarshaler EnrollmentAutomationsGetResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = EnrollmentAutomationsGetResponse(value) + e._rawJSON = json.RawMessage(data) + return nil +} + +func (e *EnrollmentAutomationsGetResponse) String() string { + if len(e._rawJSON) > 0 { + if value, err := core.StringifyJSON(e._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + type EnrollmentAutomationsLaunchResponse struct { EnrollmentAutomation *EnrollmentAutomationsLaunchResponseEnrollmentAutomation `json:"enrollment_automation,omitempty"` Ok bool `json:"ok"` @@ -45,3 +84,33 @@ func (e *EnrollmentAutomationsLaunchResponse) String() string { } return fmt.Sprintf("%#v", e) } + +type EnrollmentAutomationsListResponse struct { + EnrollmentAutomations []*seamapigo.EnrollmentAutomation `json:"enrollment_automations,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (e *EnrollmentAutomationsListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler EnrollmentAutomationsListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = EnrollmentAutomationsListResponse(value) + e._rawJSON = json.RawMessage(data) + return nil +} + +func (e *EnrollmentAutomationsListResponse) String() string { + if len(e._rawJSON) > 0 { + if value, err := core.StringifyJSON(e._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} diff --git a/useridentities/enrollmentautomations/client.go b/useridentities/enrollmentautomations/client.go index 319f63a..f4fb092 100644 --- a/useridentities/enrollmentautomations/client.go +++ b/useridentities/enrollmentautomations/client.go @@ -32,6 +32,56 @@ func NewClient(opts ...core.ClientOption) *Client { } } +func (c *Client) Get(ctx context.Context, request *useridentities.EnrollmentAutomationsGetRequest) (*useridentities.EnrollmentAutomationsGetResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "user_identities/enrollment_automations/get" + + 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 *useridentities.EnrollmentAutomationsGetResponse + 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, nil +} + func (c *Client) Launch(ctx context.Context, request *useridentities.EnrollmentAutomationsLaunchRequest) (*useridentities.EnrollmentAutomationsLaunchResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { @@ -81,3 +131,53 @@ func (c *Client) Launch(ctx context.Context, request *useridentities.EnrollmentA } return response, nil } + +func (c *Client) List(ctx context.Context, request *useridentities.EnrollmentAutomationsListRequest) (*useridentities.EnrollmentAutomationsListResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "user_identities/enrollment_automations/list" + + 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 *useridentities.EnrollmentAutomationsListResponse + 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, nil +} diff --git a/useridentities/types.go b/useridentities/types.go index 25683e0..3fc211c 100644 --- a/useridentities/types.go +++ b/useridentities/types.go @@ -9,41 +9,6 @@ import ( time "time" ) -type UserIdentitiesAddAcsUserRequest struct { - UserIdentityId string `json:"user_identity_id"` - AcsUserId string `json:"acs_user_id"` -} - -type UserIdentitiesCreateRequest struct { - UserIdentityKey *string `json:"user_identity_key,omitempty"` - EmailAddress *string `json:"email_address,omitempty"` - FirstName *string `json:"first_name,omitempty"` - LastName *string `json:"last_name,omitempty"` -} - -type UserIdentitiesGrantAccessToDeviceRequest struct { - UserIdentityId string `json:"user_identity_id"` - DeviceId string `json:"device_id"` -} - -type UserIdentitiesListAccessibleDevicesRequest struct { - UserIdentityId string `json:"user_identity_id"` -} - -type UserIdentitiesListAcsUsersRequest struct { - UserIdentityId string `json:"user_identity_id"` -} - -type UserIdentitiesRemoveAcsUserRequest struct { - UserIdentityId string `json:"user_identity_id"` - AcsUserId string `json:"acs_user_id"` -} - -type UserIdentitiesRevokeAccessToDeviceRequest struct { - UserIdentityId string `json:"user_identity_id"` - DeviceId string `json:"device_id"` -} - type EnrollmentAutomationsLaunchResponseEnrollmentAutomation struct { AcsCredentialProvisioningAutomationId string `json:"acs_credential_provisioning_automation_id"` CredentialManagerAcsSystemId string `json:"credential_manager_acs_system_id"` @@ -77,166 +42,3 @@ func (e *EnrollmentAutomationsLaunchResponseEnrollmentAutomation) String() strin } return fmt.Sprintf("%#v", e) } - -type UserIdentitiesCreateResponseUserIdentity struct { - UserIdentityId string `json:"user_identity_id"` - UserIdentityKey *string `json:"user_identity_key,omitempty"` - EmailAddress *string `json:"email_address,omitempty"` - FirstName *string `json:"first_name,omitempty"` - LastName *string `json:"last_name,omitempty"` - CreatedAt time.Time `json:"created_at"` - WorkspaceId string `json:"workspace_id"` - - _rawJSON json.RawMessage -} - -func (u *UserIdentitiesCreateResponseUserIdentity) UnmarshalJSON(data []byte) error { - type unmarshaler UserIdentitiesCreateResponseUserIdentity - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserIdentitiesCreateResponseUserIdentity(value) - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserIdentitiesCreateResponseUserIdentity) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserIdentitiesGetRequestUserIdentityId struct { - UserIdentityId string `json:"user_identity_id"` - - _rawJSON json.RawMessage -} - -func (u *UserIdentitiesGetRequestUserIdentityId) UnmarshalJSON(data []byte) error { - type unmarshaler UserIdentitiesGetRequestUserIdentityId - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserIdentitiesGetRequestUserIdentityId(value) - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserIdentitiesGetRequestUserIdentityId) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserIdentitiesGetRequestUserIdentityKey struct { - UserIdentityKey string `json:"user_identity_key"` - - _rawJSON json.RawMessage -} - -func (u *UserIdentitiesGetRequestUserIdentityKey) UnmarshalJSON(data []byte) error { - type unmarshaler UserIdentitiesGetRequestUserIdentityKey - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserIdentitiesGetRequestUserIdentityKey(value) - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserIdentitiesGetRequestUserIdentityKey) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserIdentitiesGetResponseUserIdentity struct { - UserIdentityId string `json:"user_identity_id"` - UserIdentityKey *string `json:"user_identity_key,omitempty"` - EmailAddress *string `json:"email_address,omitempty"` - FirstName *string `json:"first_name,omitempty"` - LastName *string `json:"last_name,omitempty"` - CreatedAt time.Time `json:"created_at"` - WorkspaceId string `json:"workspace_id"` - - _rawJSON json.RawMessage -} - -func (u *UserIdentitiesGetResponseUserIdentity) UnmarshalJSON(data []byte) error { - type unmarshaler UserIdentitiesGetResponseUserIdentity - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserIdentitiesGetResponseUserIdentity(value) - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserIdentitiesGetResponseUserIdentity) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserIdentitiesListResponseUserIdentitiesItem struct { - UserIdentityId string `json:"user_identity_id"` - UserIdentityKey *string `json:"user_identity_key,omitempty"` - EmailAddress *string `json:"email_address,omitempty"` - FirstName *string `json:"first_name,omitempty"` - LastName *string `json:"last_name,omitempty"` - CreatedAt time.Time `json:"created_at"` - WorkspaceId string `json:"workspace_id"` - - _rawJSON json.RawMessage -} - -func (u *UserIdentitiesListResponseUserIdentitiesItem) UnmarshalJSON(data []byte) error { - type unmarshaler UserIdentitiesListResponseUserIdentitiesItem - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserIdentitiesListResponseUserIdentitiesItem(value) - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserIdentitiesListResponseUserIdentitiesItem) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/webhooks/client.go b/webhooks/client.go index 6d34ed1..39f4653 100644 --- a/webhooks/client.go +++ b/webhooks/client.go @@ -31,7 +31,7 @@ func NewClient(opts ...core.ClientOption) *Client { } } -func (c *Client) Create(ctx context.Context, request *seamapigo.WebhooksCreateRequest) (*seamapigo.WebhooksCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *seamapigo.WebhooksCreateRequest) (*seamapigo.Webhook, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -78,7 +78,7 @@ func (c *Client) Create(ctx context.Context, request *seamapigo.WebhooksCreateRe ); err != nil { return nil, err } - return response, nil + return response.Webhook, nil } func (c *Client) Delete(ctx context.Context, request *seamapigo.WebhooksDeleteRequest) (*seamapigo.WebhooksDeleteResponse, error) { @@ -119,7 +119,7 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.WebhooksDeleteRe ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodDelete, + Method: http.MethodPost, Headers: c.header, Request: request, Response: &response, @@ -131,7 +131,7 @@ func (c *Client) Delete(ctx context.Context, request *seamapigo.WebhooksDeleteRe return response, nil } -func (c *Client) Get(ctx context.Context, request *seamapigo.WebhooksGetRequest) (*seamapigo.WebhooksGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.WebhooksGetRequest) (*seamapigo.Webhook, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -178,10 +178,10 @@ func (c *Client) Get(ctx context.Context, request *seamapigo.WebhooksGetRequest) ); err != nil { return nil, err } - return response, nil + return response.Webhook, nil } -func (c *Client) List(ctx context.Context) (*seamapigo.WebhooksListResponse, error) { +func (c *Client) List(ctx context.Context) ([]*seamapigo.Webhook, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -219,7 +219,7 @@ func (c *Client) List(ctx context.Context) (*seamapigo.WebhooksListResponse, err ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodGet, + Method: http.MethodPost, Headers: c.header, Response: &response, ErrorDecoder: errorDecoder, @@ -227,5 +227,5 @@ func (c *Client) List(ctx context.Context) (*seamapigo.WebhooksListResponse, err ); err != nil { return nil, err } - return response, nil + return response.Webhooks, nil } diff --git a/workspaces.go b/workspaces.go index ddb1386..201f4ea 100644 --- a/workspaces.go +++ b/workspaces.go @@ -8,6 +8,67 @@ import ( core "github.com/seamapi/go/core" ) +type WorkspacesCreateRequest struct { + Name string `json:"name"` + // The name shown inside the connect webview + ConnectPartnerName string `json:"connect_partner_name"` + IsSandbox *bool `json:"is_sandbox,omitempty"` + WebviewPrimaryButtonColor *string `json:"webview_primary_button_color,omitempty"` + WebviewLogoShape *WorkspacesCreateRequestWebviewLogoShape `json:"webview_logo_shape,omitempty"` +} + +type WorkspacesCreateRequestWebviewLogoShape string + +const ( + WorkspacesCreateRequestWebviewLogoShapeCircle WorkspacesCreateRequestWebviewLogoShape = "circle" + WorkspacesCreateRequestWebviewLogoShapeSquare WorkspacesCreateRequestWebviewLogoShape = "square" +) + +func NewWorkspacesCreateRequestWebviewLogoShapeFromString(s string) (WorkspacesCreateRequestWebviewLogoShape, error) { + switch s { + case "circle": + return WorkspacesCreateRequestWebviewLogoShapeCircle, nil + case "square": + return WorkspacesCreateRequestWebviewLogoShapeSquare, nil + } + var t WorkspacesCreateRequestWebviewLogoShape + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (w WorkspacesCreateRequestWebviewLogoShape) Ptr() *WorkspacesCreateRequestWebviewLogoShape { + return &w +} + +type WorkspacesCreateResponse struct { + Workspace *Workspace `json:"workspace,omitempty"` + Ok bool `json:"ok"` + + _rawJSON json.RawMessage +} + +func (w *WorkspacesCreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler WorkspacesCreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WorkspacesCreateResponse(value) + w._rawJSON = json.RawMessage(data) + return nil +} + +func (w *WorkspacesCreateResponse) String() string { + if len(w._rawJSON) > 0 { + if value, err := core.StringifyJSON(w._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} + type WorkspacesGetResponse struct { Workspace *Workspace `json:"workspace,omitempty"` Ok bool `json:"ok"` @@ -69,8 +130,8 @@ func (w *WorkspacesListResponse) String() string { } type WorkspacesResetSandboxResponse struct { - Message string `json:"message"` - Ok bool `json:"ok"` + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` _rawJSON json.RawMessage } diff --git a/workspaces/client.go b/workspaces/client.go index 4a96de7..6c74890 100644 --- a/workspaces/client.go +++ b/workspaces/client.go @@ -31,6 +31,56 @@ func NewClient(opts ...core.ClientOption) *Client { } } +func (c *Client) Create(ctx context.Context, request *seamapigo.WorkspacesCreateRequest) (*seamapigo.WorkspacesCreateResponse, error) { + baseURL := "https://connect.getseam.com" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "workspaces/create" + + 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.WorkspacesCreateResponse + 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, nil +} + func (c *Client) Get(ctx context.Context) (*seamapigo.Workspace, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { @@ -69,7 +119,7 @@ func (c *Client) Get(ctx context.Context) (*seamapigo.Workspace, error) { ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodGet, + Method: http.MethodPost, Headers: c.header, Response: &response, ErrorDecoder: errorDecoder, @@ -118,7 +168,7 @@ func (c *Client) List(ctx context.Context) ([]*seamapigo.Workspace, error) { ctx, &core.CallParams{ URL: endpointURL, - Method: http.MethodGet, + Method: http.MethodPost, Headers: c.header, Response: &response, ErrorDecoder: errorDecoder, @@ -129,7 +179,7 @@ func (c *Client) List(ctx context.Context) ([]*seamapigo.Workspace, error) { return response.Workspaces, nil } -func (c *Client) ResetSandbox(ctx context.Context) (*seamapigo.WorkspacesResetSandboxResponse, error) { +func (c *Client) ResetSandbox(ctx context.Context) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -175,5 +225,5 @@ func (c *Client) ResetSandbox(ctx context.Context) (*seamapigo.WorkspacesResetSa ); err != nil { return nil, err } - return response, nil + return response.ActionAttempt, nil }