From 2957115693fff146c4c51560d7430ea4c21b14a7 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:20:14 +0000 Subject: [PATCH 1/2] 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 | 10 +- client/options.go | 15 +- client_sessions.go | 119 +- clientsessions/client.go | 158 +- connect_webviews.go | 395 +-- connected_accounts.go | 36 + connectedaccounts/client.go | 58 +- connectwebviews/client.go | 13 +- core/client_option.go | 22 +- devices.go | 380 ++- devices/client/client.go | 16 +- devices/unmanaged.go | 449 +++- devices/unmanaged/client.go | 60 +- events.go | 72 + health/service.go | 38 + health/service/client.go | 4 +- locks.go | 362 ++- 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 | 534 +++- thermostats/client/client.go | 162 +- thermostats/climate_setting_schedules.go | 263 +- thermostats/climatesettingschedules/client.go | 30 +- types.go | 2383 ++++++++--------- .../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, 5795 insertions(+), 1939 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..5ed5d95 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,omitempty"` + 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..a6a9c1e 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,7 +29,6 @@ type Client struct { caller *core.Caller header http.Header - UserIdentities *useridentitiesclient.Client AccessCodes *accesscodesclient.Client Acs *acsclient.Client ActionAttempts *actionattempts.Client @@ -38,8 +39,11 @@ type Client struct { Events *events.Client Health *healthclient.Client Locks *locks.Client + Networks *networks.Client NoiseSensors *noisesensorsclient.Client + Phones *phonesclient.Client Thermostats *thermostatsclient.Client + UserIdentities *useridentitiesclient.Client Webhooks *webhooks.Client Workspaces *workspaces.Client } @@ -53,7 +57,6 @@ 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...), @@ -64,8 +67,11 @@ func NewClient(opts ...core.ClientOption) *Client { Events: events.NewClient(opts...), Health: healthclient.NewClient(opts...), Locks: locks.NewClient(opts...), + Networks: networks.NewClient(opts...), NoiseSensors: noisesensorsclient.NewClient(opts...), + Phones: phonesclient.NewClient(opts...), Thermostats: thermostatsclient.NewClient(opts...), + UserIdentities: useridentitiesclient.NewClient(opts...), Webhooks: webhooks.NewClient(opts...), Workspaces: workspaces.NewClient(opts...), } diff --git a/client/options.go b/client/options.go index 0a20c3d..e468d90 100644 --- a/client/options.go +++ b/client/options.go @@ -31,16 +31,23 @@ func WithHTTPHeader(httpHeader http.Header) core.ClientOption { } } -// WithApiKey sets the 'Authorization: Bearer ' header on every request. +// WithApiKey sets the apiKey auth header on every request. func WithApiKey(apiKey string) core.ClientOption { return func(opts *core.ClientOptions) { opts.ApiKey = apiKey } } -// WithSeamWorkspace sets the seamWorkspace header on every request. -func WithSeamWorkspace(seamWorkspace *string) core.ClientOption { +// WithSeamClientSessionToken sets the seamClientSessionToken header on every request. +func WithSeamClientSessionToken(seamClientSessionToken string) core.ClientOption { return func(opts *core.ClientOptions) { - opts.SeamWorkspace = seamWorkspace + 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..225b9d4 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 []ConnectWebviewsCreateRequestAcceptedProvidersItem `json:"accepted_providers,omitempty"` + ProviderCategory *ConnectWebviewsCreateRequestProviderCategory `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,101 +27,239 @@ type ConnectWebviewsGetRequest struct { ConnectWebviewId string `json:"connect_webview_id"` } -type AcceptedProvider string +type ConnectWebviewsListRequest struct { + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + +type ConnectWebviewsCreateRequestAcceptedProvidersItem 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" + ConnectWebviewsCreateRequestAcceptedProvidersItemAkuvox ConnectWebviewsCreateRequestAcceptedProvidersItem = "akuvox" + ConnectWebviewsCreateRequestAcceptedProvidersItemAugust ConnectWebviewsCreateRequestAcceptedProvidersItem = "august" + ConnectWebviewsCreateRequestAcceptedProvidersItemAvigilonAlta ConnectWebviewsCreateRequestAcceptedProvidersItem = "avigilon_alta" + ConnectWebviewsCreateRequestAcceptedProvidersItemBrivo ConnectWebviewsCreateRequestAcceptedProvidersItem = "brivo" + ConnectWebviewsCreateRequestAcceptedProvidersItemButterflymx ConnectWebviewsCreateRequestAcceptedProvidersItem = "butterflymx" + ConnectWebviewsCreateRequestAcceptedProvidersItemSchlage ConnectWebviewsCreateRequestAcceptedProvidersItem = "schlage" + ConnectWebviewsCreateRequestAcceptedProvidersItemSmartthings ConnectWebviewsCreateRequestAcceptedProvidersItem = "smartthings" + ConnectWebviewsCreateRequestAcceptedProvidersItemYale ConnectWebviewsCreateRequestAcceptedProvidersItem = "yale" + ConnectWebviewsCreateRequestAcceptedProvidersItemGenie ConnectWebviewsCreateRequestAcceptedProvidersItem = "genie" + ConnectWebviewsCreateRequestAcceptedProvidersItemDoorking ConnectWebviewsCreateRequestAcceptedProvidersItem = "doorking" + ConnectWebviewsCreateRequestAcceptedProvidersItemSalto ConnectWebviewsCreateRequestAcceptedProvidersItem = "salto" + ConnectWebviewsCreateRequestAcceptedProvidersItemLockly ConnectWebviewsCreateRequestAcceptedProvidersItem = "lockly" + ConnectWebviewsCreateRequestAcceptedProvidersItemTtlock ConnectWebviewsCreateRequestAcceptedProvidersItem = "ttlock" + ConnectWebviewsCreateRequestAcceptedProvidersItemLinear ConnectWebviewsCreateRequestAcceptedProvidersItem = "linear" + ConnectWebviewsCreateRequestAcceptedProvidersItemNoiseaware ConnectWebviewsCreateRequestAcceptedProvidersItem = "noiseaware" + ConnectWebviewsCreateRequestAcceptedProvidersItemNuki ConnectWebviewsCreateRequestAcceptedProvidersItem = "nuki" + ConnectWebviewsCreateRequestAcceptedProvidersItemSeamRelayAdmin ConnectWebviewsCreateRequestAcceptedProvidersItem = "seam_relay_admin" + ConnectWebviewsCreateRequestAcceptedProvidersItemIgloo ConnectWebviewsCreateRequestAcceptedProvidersItem = "igloo" + ConnectWebviewsCreateRequestAcceptedProvidersItemKwikset ConnectWebviewsCreateRequestAcceptedProvidersItem = "kwikset" + ConnectWebviewsCreateRequestAcceptedProvidersItemMinut ConnectWebviewsCreateRequestAcceptedProvidersItem = "minut" + ConnectWebviewsCreateRequestAcceptedProvidersItemMy2N ConnectWebviewsCreateRequestAcceptedProvidersItem = "my_2n" + ConnectWebviewsCreateRequestAcceptedProvidersItemControlbyweb ConnectWebviewsCreateRequestAcceptedProvidersItem = "controlbyweb" + ConnectWebviewsCreateRequestAcceptedProvidersItemNest ConnectWebviewsCreateRequestAcceptedProvidersItem = "nest" + ConnectWebviewsCreateRequestAcceptedProvidersItemIgloohome ConnectWebviewsCreateRequestAcceptedProvidersItem = "igloohome" + ConnectWebviewsCreateRequestAcceptedProvidersItemEcobee ConnectWebviewsCreateRequestAcceptedProvidersItem = "ecobee" + ConnectWebviewsCreateRequestAcceptedProvidersItemHubitat ConnectWebviewsCreateRequestAcceptedProvidersItem = "hubitat" + ConnectWebviewsCreateRequestAcceptedProvidersItemFourSuites ConnectWebviewsCreateRequestAcceptedProvidersItem = "four_suites" + ConnectWebviewsCreateRequestAcceptedProvidersItemDormakabaOracode ConnectWebviewsCreateRequestAcceptedProvidersItem = "dormakaba_oracode" + ConnectWebviewsCreateRequestAcceptedProvidersItemPti ConnectWebviewsCreateRequestAcceptedProvidersItem = "pti" + ConnectWebviewsCreateRequestAcceptedProvidersItemWyze ConnectWebviewsCreateRequestAcceptedProvidersItem = "wyze" + ConnectWebviewsCreateRequestAcceptedProvidersItemSeamPassport ConnectWebviewsCreateRequestAcceptedProvidersItem = "seam_passport" + ConnectWebviewsCreateRequestAcceptedProvidersItemVisionline ConnectWebviewsCreateRequestAcceptedProvidersItem = "visionline" + ConnectWebviewsCreateRequestAcceptedProvidersItemAssaAbloyCredentialService ConnectWebviewsCreateRequestAcceptedProvidersItem = "assa_abloy_credential_service" + ConnectWebviewsCreateRequestAcceptedProvidersItemSeamBridge ConnectWebviewsCreateRequestAcceptedProvidersItem = "seam_bridge" + ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess ConnectWebviewsCreateRequestAcceptedProvidersItem = "yale_access" + ConnectWebviewsCreateRequestAcceptedProvidersItemHidCm ConnectWebviewsCreateRequestAcceptedProvidersItem = "hid_cm" ) -func NewAcceptedProviderFromString(s string) (AcceptedProvider, error) { +func NewConnectWebviewsCreateRequestAcceptedProvidersItemFromString(s string) (ConnectWebviewsCreateRequestAcceptedProvidersItem, error) { switch s { case "akuvox": - return AcceptedProviderAkuvox, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemAkuvox, nil case "august": - return AcceptedProviderAugust, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemAugust, nil case "avigilon_alta": - return AcceptedProviderAvigilonAlta, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemAvigilonAlta, nil case "brivo": - return AcceptedProviderBrivo, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemBrivo, nil case "butterflymx": - return AcceptedProviderButterflymx, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemButterflymx, nil case "schlage": - return AcceptedProviderSchlage, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemSchlage, nil case "smartthings": - return AcceptedProviderSmartthings, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemSmartthings, nil case "yale": - return AcceptedProviderYale, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemYale, nil case "genie": - return AcceptedProviderGenie, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemGenie, nil case "doorking": - return AcceptedProviderDoorking, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemDoorking, nil case "salto": - return AcceptedProviderSalto, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemSalto, nil case "lockly": - return AcceptedProviderLockly, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemLockly, nil case "ttlock": - return AcceptedProviderTtlock, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemTtlock, nil case "linear": - return AcceptedProviderLinear, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemLinear, nil case "noiseaware": - return AcceptedProviderNoiseaware, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemNoiseaware, nil case "nuki": - return AcceptedProviderNuki, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemNuki, nil case "seam_relay_admin": - return AcceptedProviderSeamRelayAdmin, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemSeamRelayAdmin, nil case "igloo": - return AcceptedProviderIgloo, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemIgloo, nil case "kwikset": - return AcceptedProviderKwikset, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemKwikset, nil case "minut": - return AcceptedProviderMinut, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemMinut, nil case "my_2n": - return AcceptedProviderMy2N, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemMy2N, nil case "controlbyweb": - return AcceptedProviderControlbyweb, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemControlbyweb, nil case "nest": - return AcceptedProviderNest, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemNest, nil case "igloohome": - return AcceptedProviderIgloohome, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemIgloohome, nil case "ecobee": - return AcceptedProviderEcobee, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemEcobee, nil case "hubitat": - return AcceptedProviderHubitat, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemHubitat, nil + case "four_suites": + return ConnectWebviewsCreateRequestAcceptedProvidersItemFourSuites, nil + case "dormakaba_oracode": + return ConnectWebviewsCreateRequestAcceptedProvidersItemDormakabaOracode, nil + case "pti": + return ConnectWebviewsCreateRequestAcceptedProvidersItemPti, nil + case "wyze": + return ConnectWebviewsCreateRequestAcceptedProvidersItemWyze, nil + case "seam_passport": + return ConnectWebviewsCreateRequestAcceptedProvidersItemSeamPassport, nil + case "visionline": + return ConnectWebviewsCreateRequestAcceptedProvidersItemVisionline, nil + case "assa_abloy_credential_service": + return ConnectWebviewsCreateRequestAcceptedProvidersItemAssaAbloyCredentialService, nil + case "seam_bridge": + return ConnectWebviewsCreateRequestAcceptedProvidersItemSeamBridge, nil case "yale_access": - return AcceptedProviderYaleAccess, nil + return ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess, nil + case "hid_cm": + return ConnectWebviewsCreateRequestAcceptedProvidersItemHidCm, nil } - var t AcceptedProvider + var t ConnectWebviewsCreateRequestAcceptedProvidersItem return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (a AcceptedProvider) Ptr() *AcceptedProvider { - return &a +func (c ConnectWebviewsCreateRequestAcceptedProvidersItem) Ptr() *ConnectWebviewsCreateRequestAcceptedProvidersItem { + return &c +} + +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 ConnectWebviewsCreateRequestProviderCategory string + +const ( + ConnectWebviewsCreateRequestProviderCategoryStable ConnectWebviewsCreateRequestProviderCategory = "stable" + ConnectWebviewsCreateRequestProviderCategoryConsumerSmartlocks ConnectWebviewsCreateRequestProviderCategory = "consumer_smartlocks" + ConnectWebviewsCreateRequestProviderCategoryInternalBeta ConnectWebviewsCreateRequestProviderCategory = "internal_beta" +) + +func NewConnectWebviewsCreateRequestProviderCategoryFromString(s string) (ConnectWebviewsCreateRequestProviderCategory, error) { + switch s { + case "stable": + return ConnectWebviewsCreateRequestProviderCategoryStable, nil + case "consumer_smartlocks": + return ConnectWebviewsCreateRequestProviderCategoryConsumerSmartlocks, nil + case "internal_beta": + return ConnectWebviewsCreateRequestProviderCategoryInternalBeta, nil + } + var t ConnectWebviewsCreateRequestProviderCategory + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ConnectWebviewsCreateRequestProviderCategory) Ptr() *ConnectWebviewsCreateRequestProviderCategory { + return &c } type ConnectWebviewsCreateResponse struct { @@ -243,129 +381,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..4310047 100644 --- a/core/client_option.go +++ b/core/client_option.go @@ -14,11 +14,12 @@ 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 + SeamClientSessionToken string + ClientSessionToken string } // NewClientOptions returns a new *ClientOptions value. @@ -35,12 +36,9 @@ func NewClientOptions() *ClientOptions { // on every request. func (c *ClientOptions) ToHeader() http.Header { header := c.cloneHeader() - 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.ApiKey)) + 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 +46,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.2.3") return headers } diff --git a/devices.go b/devices.go index 06c4579..400fc3a 100644 --- a/devices.go +++ b/devices.go @@ -19,15 +19,17 @@ type DevicesGetRequest struct { } type DevicesListRequest struct { - ConnectedAccountId *string `json:"connected_account_id,omitempty"` - ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` - ConnectWebviewId *string `json:"connect_webview_id,omitempty"` - DeviceType *DeviceType `json:"device_type,omitempty"` - DeviceTypes []DeviceType `json:"device_types,omitempty"` - Manufacturer *Manufacturer `json:"manufacturer,omitempty"` - DeviceIds []string `json:"device_ids,omitempty"` - Limit *float64 `json:"limit,omitempty"` - CreatedBefore *time.Time `json:"created_before,omitempty"` + // 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"` + DeviceType *DevicesListRequestDeviceType `json:"device_type,omitempty"` + DeviceTypes []DevicesListRequestDeviceTypesItem `json:"device_types,omitempty"` + Manufacturer *DevicesListRequestManufacturer `json:"manufacturer,omitempty"` + 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 { @@ -116,8 +118,8 @@ func (d DevicesListDeviceProvidersRequestProviderCategory) Ptr() *DevicesListDev } 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 } @@ -145,52 +147,355 @@ func (d *DevicesListDeviceProvidersResponse) String() string { return fmt.Sprintf("%#v", d) } -type DevicesListResponse struct { - Devices []*Device `json:"devices,omitempty"` - Ok bool `json:"ok"` +type DevicesListRequestDeviceType string - _rawJSON json.RawMessage -} +const ( + DevicesListRequestDeviceTypeAkuvoxLock DevicesListRequestDeviceType = "akuvox_lock" + DevicesListRequestDeviceTypeAugustLock DevicesListRequestDeviceType = "august_lock" + DevicesListRequestDeviceTypeBrivoAccessPoint DevicesListRequestDeviceType = "brivo_access_point" + DevicesListRequestDeviceTypeButterflymxPanel DevicesListRequestDeviceType = "butterflymx_panel" + DevicesListRequestDeviceTypeAvigilonAltaEntry DevicesListRequestDeviceType = "avigilon_alta_entry" + DevicesListRequestDeviceTypeDoorkingLock DevicesListRequestDeviceType = "doorking_lock" + DevicesListRequestDeviceTypeGenieDoor DevicesListRequestDeviceType = "genie_door" + DevicesListRequestDeviceTypeIglooLock DevicesListRequestDeviceType = "igloo_lock" + DevicesListRequestDeviceTypeLinearLock DevicesListRequestDeviceType = "linear_lock" + DevicesListRequestDeviceTypeLocklyLock DevicesListRequestDeviceType = "lockly_lock" + DevicesListRequestDeviceTypeKwiksetLock DevicesListRequestDeviceType = "kwikset_lock" + DevicesListRequestDeviceTypeNukiLock DevicesListRequestDeviceType = "nuki_lock" + DevicesListRequestDeviceTypeSaltoLock DevicesListRequestDeviceType = "salto_lock" + DevicesListRequestDeviceTypeSchlageLock DevicesListRequestDeviceType = "schlage_lock" + DevicesListRequestDeviceTypeSeamRelay DevicesListRequestDeviceType = "seam_relay" + DevicesListRequestDeviceTypeSmartthingsLock DevicesListRequestDeviceType = "smartthings_lock" + DevicesListRequestDeviceTypeWyzeLock DevicesListRequestDeviceType = "wyze_lock" + DevicesListRequestDeviceTypeYaleLock DevicesListRequestDeviceType = "yale_lock" + DevicesListRequestDeviceTypeTwoNIntercom DevicesListRequestDeviceType = "two_n_intercom" + DevicesListRequestDeviceTypeControlbywebDevice DevicesListRequestDeviceType = "controlbyweb_device" + DevicesListRequestDeviceTypeTtlockLock DevicesListRequestDeviceType = "ttlock_lock" + DevicesListRequestDeviceTypeIgloohomeLock DevicesListRequestDeviceType = "igloohome_lock" + DevicesListRequestDeviceTypeHubitatLock DevicesListRequestDeviceType = "hubitat_lock" + DevicesListRequestDeviceTypeFourSuitesDoor DevicesListRequestDeviceType = "four_suites_door" + DevicesListRequestDeviceTypeDormakabaOracodeDoor DevicesListRequestDeviceType = "dormakaba_oracode_door" + DevicesListRequestDeviceTypeNoiseawareActivityZone DevicesListRequestDeviceType = "noiseaware_activity_zone" + DevicesListRequestDeviceTypeMinutSensor DevicesListRequestDeviceType = "minut_sensor" + DevicesListRequestDeviceTypeEcobeeThermostat DevicesListRequestDeviceType = "ecobee_thermostat" + DevicesListRequestDeviceTypeNestThermostat DevicesListRequestDeviceType = "nest_thermostat" + DevicesListRequestDeviceTypeIosPhone DevicesListRequestDeviceType = "ios_phone" + DevicesListRequestDeviceTypeAndroidPhone DevicesListRequestDeviceType = "android_phone" +) -func (d *DevicesListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DevicesListResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err +func NewDevicesListRequestDeviceTypeFromString(s string) (DevicesListRequestDeviceType, error) { + switch s { + case "akuvox_lock": + return DevicesListRequestDeviceTypeAkuvoxLock, nil + case "august_lock": + return DevicesListRequestDeviceTypeAugustLock, nil + case "brivo_access_point": + return DevicesListRequestDeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return DevicesListRequestDeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return DevicesListRequestDeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return DevicesListRequestDeviceTypeDoorkingLock, nil + case "genie_door": + return DevicesListRequestDeviceTypeGenieDoor, nil + case "igloo_lock": + return DevicesListRequestDeviceTypeIglooLock, nil + case "linear_lock": + return DevicesListRequestDeviceTypeLinearLock, nil + case "lockly_lock": + return DevicesListRequestDeviceTypeLocklyLock, nil + case "kwikset_lock": + return DevicesListRequestDeviceTypeKwiksetLock, nil + case "nuki_lock": + return DevicesListRequestDeviceTypeNukiLock, nil + case "salto_lock": + return DevicesListRequestDeviceTypeSaltoLock, nil + case "schlage_lock": + return DevicesListRequestDeviceTypeSchlageLock, nil + case "seam_relay": + return DevicesListRequestDeviceTypeSeamRelay, nil + case "smartthings_lock": + return DevicesListRequestDeviceTypeSmartthingsLock, nil + case "wyze_lock": + return DevicesListRequestDeviceTypeWyzeLock, nil + case "yale_lock": + return DevicesListRequestDeviceTypeYaleLock, nil + case "two_n_intercom": + return DevicesListRequestDeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return DevicesListRequestDeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return DevicesListRequestDeviceTypeTtlockLock, nil + case "igloohome_lock": + return DevicesListRequestDeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return DevicesListRequestDeviceTypeHubitatLock, nil + case "four_suites_door": + return DevicesListRequestDeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return DevicesListRequestDeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return DevicesListRequestDeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return DevicesListRequestDeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return DevicesListRequestDeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return DevicesListRequestDeviceTypeNestThermostat, nil + case "ios_phone": + return DevicesListRequestDeviceTypeIosPhone, nil + case "android_phone": + return DevicesListRequestDeviceTypeAndroidPhone, nil } - *d = DevicesListResponse(value) - d._rawJSON = json.RawMessage(data) - return nil + var t DevicesListRequestDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (d *DevicesListResponse) String() string { - if len(d._rawJSON) > 0 { - if value, err := core.StringifyJSON(d._rawJSON); err == nil { - return value - } +func (d DevicesListRequestDeviceType) Ptr() *DevicesListRequestDeviceType { + return &d +} + +type DevicesListRequestDeviceTypesItem string + +const ( + DevicesListRequestDeviceTypesItemAkuvoxLock DevicesListRequestDeviceTypesItem = "akuvox_lock" + DevicesListRequestDeviceTypesItemAugustLock DevicesListRequestDeviceTypesItem = "august_lock" + DevicesListRequestDeviceTypesItemBrivoAccessPoint DevicesListRequestDeviceTypesItem = "brivo_access_point" + DevicesListRequestDeviceTypesItemButterflymxPanel DevicesListRequestDeviceTypesItem = "butterflymx_panel" + DevicesListRequestDeviceTypesItemAvigilonAltaEntry DevicesListRequestDeviceTypesItem = "avigilon_alta_entry" + DevicesListRequestDeviceTypesItemDoorkingLock DevicesListRequestDeviceTypesItem = "doorking_lock" + DevicesListRequestDeviceTypesItemGenieDoor DevicesListRequestDeviceTypesItem = "genie_door" + DevicesListRequestDeviceTypesItemIglooLock DevicesListRequestDeviceTypesItem = "igloo_lock" + DevicesListRequestDeviceTypesItemLinearLock DevicesListRequestDeviceTypesItem = "linear_lock" + DevicesListRequestDeviceTypesItemLocklyLock DevicesListRequestDeviceTypesItem = "lockly_lock" + DevicesListRequestDeviceTypesItemKwiksetLock DevicesListRequestDeviceTypesItem = "kwikset_lock" + DevicesListRequestDeviceTypesItemNukiLock DevicesListRequestDeviceTypesItem = "nuki_lock" + DevicesListRequestDeviceTypesItemSaltoLock DevicesListRequestDeviceTypesItem = "salto_lock" + DevicesListRequestDeviceTypesItemSchlageLock DevicesListRequestDeviceTypesItem = "schlage_lock" + DevicesListRequestDeviceTypesItemSeamRelay DevicesListRequestDeviceTypesItem = "seam_relay" + DevicesListRequestDeviceTypesItemSmartthingsLock DevicesListRequestDeviceTypesItem = "smartthings_lock" + DevicesListRequestDeviceTypesItemWyzeLock DevicesListRequestDeviceTypesItem = "wyze_lock" + DevicesListRequestDeviceTypesItemYaleLock DevicesListRequestDeviceTypesItem = "yale_lock" + DevicesListRequestDeviceTypesItemTwoNIntercom DevicesListRequestDeviceTypesItem = "two_n_intercom" + DevicesListRequestDeviceTypesItemControlbywebDevice DevicesListRequestDeviceTypesItem = "controlbyweb_device" + DevicesListRequestDeviceTypesItemTtlockLock DevicesListRequestDeviceTypesItem = "ttlock_lock" + DevicesListRequestDeviceTypesItemIgloohomeLock DevicesListRequestDeviceTypesItem = "igloohome_lock" + DevicesListRequestDeviceTypesItemHubitatLock DevicesListRequestDeviceTypesItem = "hubitat_lock" + DevicesListRequestDeviceTypesItemFourSuitesDoor DevicesListRequestDeviceTypesItem = "four_suites_door" + DevicesListRequestDeviceTypesItemDormakabaOracodeDoor DevicesListRequestDeviceTypesItem = "dormakaba_oracode_door" + DevicesListRequestDeviceTypesItemNoiseawareActivityZone DevicesListRequestDeviceTypesItem = "noiseaware_activity_zone" + DevicesListRequestDeviceTypesItemMinutSensor DevicesListRequestDeviceTypesItem = "minut_sensor" + DevicesListRequestDeviceTypesItemEcobeeThermostat DevicesListRequestDeviceTypesItem = "ecobee_thermostat" + DevicesListRequestDeviceTypesItemNestThermostat DevicesListRequestDeviceTypesItem = "nest_thermostat" + DevicesListRequestDeviceTypesItemIosPhone DevicesListRequestDeviceTypesItem = "ios_phone" + DevicesListRequestDeviceTypesItemAndroidPhone DevicesListRequestDeviceTypesItem = "android_phone" +) + +func NewDevicesListRequestDeviceTypesItemFromString(s string) (DevicesListRequestDeviceTypesItem, error) { + switch s { + case "akuvox_lock": + return DevicesListRequestDeviceTypesItemAkuvoxLock, nil + case "august_lock": + return DevicesListRequestDeviceTypesItemAugustLock, nil + case "brivo_access_point": + return DevicesListRequestDeviceTypesItemBrivoAccessPoint, nil + case "butterflymx_panel": + return DevicesListRequestDeviceTypesItemButterflymxPanel, nil + case "avigilon_alta_entry": + return DevicesListRequestDeviceTypesItemAvigilonAltaEntry, nil + case "doorking_lock": + return DevicesListRequestDeviceTypesItemDoorkingLock, nil + case "genie_door": + return DevicesListRequestDeviceTypesItemGenieDoor, nil + case "igloo_lock": + return DevicesListRequestDeviceTypesItemIglooLock, nil + case "linear_lock": + return DevicesListRequestDeviceTypesItemLinearLock, nil + case "lockly_lock": + return DevicesListRequestDeviceTypesItemLocklyLock, nil + case "kwikset_lock": + return DevicesListRequestDeviceTypesItemKwiksetLock, nil + case "nuki_lock": + return DevicesListRequestDeviceTypesItemNukiLock, nil + case "salto_lock": + return DevicesListRequestDeviceTypesItemSaltoLock, nil + case "schlage_lock": + return DevicesListRequestDeviceTypesItemSchlageLock, nil + case "seam_relay": + return DevicesListRequestDeviceTypesItemSeamRelay, nil + case "smartthings_lock": + return DevicesListRequestDeviceTypesItemSmartthingsLock, nil + case "wyze_lock": + return DevicesListRequestDeviceTypesItemWyzeLock, nil + case "yale_lock": + return DevicesListRequestDeviceTypesItemYaleLock, nil + case "two_n_intercom": + return DevicesListRequestDeviceTypesItemTwoNIntercom, nil + case "controlbyweb_device": + return DevicesListRequestDeviceTypesItemControlbywebDevice, nil + case "ttlock_lock": + return DevicesListRequestDeviceTypesItemTtlockLock, nil + case "igloohome_lock": + return DevicesListRequestDeviceTypesItemIgloohomeLock, nil + case "hubitat_lock": + return DevicesListRequestDeviceTypesItemHubitatLock, nil + case "four_suites_door": + return DevicesListRequestDeviceTypesItemFourSuitesDoor, nil + case "dormakaba_oracode_door": + return DevicesListRequestDeviceTypesItemDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return DevicesListRequestDeviceTypesItemNoiseawareActivityZone, nil + case "minut_sensor": + return DevicesListRequestDeviceTypesItemMinutSensor, nil + case "ecobee_thermostat": + return DevicesListRequestDeviceTypesItemEcobeeThermostat, nil + case "nest_thermostat": + return DevicesListRequestDeviceTypesItemNestThermostat, nil + case "ios_phone": + return DevicesListRequestDeviceTypesItemIosPhone, nil + case "android_phone": + return DevicesListRequestDeviceTypesItemAndroidPhone, nil } - if value, err := core.StringifyJSON(d); err == nil { - return value + var t DevicesListRequestDeviceTypesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DevicesListRequestDeviceTypesItem) Ptr() *DevicesListRequestDeviceTypesItem { + return &d +} + +type DevicesListRequestManufacturer string + +const ( + DevicesListRequestManufacturerAkuvox DevicesListRequestManufacturer = "akuvox" + DevicesListRequestManufacturerAugust DevicesListRequestManufacturer = "august" + DevicesListRequestManufacturerAvigilonAlta DevicesListRequestManufacturer = "avigilon_alta" + DevicesListRequestManufacturerBrivo DevicesListRequestManufacturer = "brivo" + DevicesListRequestManufacturerButterflymx DevicesListRequestManufacturer = "butterflymx" + DevicesListRequestManufacturerDoorking DevicesListRequestManufacturer = "doorking" + DevicesListRequestManufacturerFourSuites DevicesListRequestManufacturer = "four_suites" + DevicesListRequestManufacturerGenie DevicesListRequestManufacturer = "genie" + DevicesListRequestManufacturerIgloo DevicesListRequestManufacturer = "igloo" + DevicesListRequestManufacturerKeywe DevicesListRequestManufacturer = "keywe" + DevicesListRequestManufacturerKwikset DevicesListRequestManufacturer = "kwikset" + DevicesListRequestManufacturerLinear DevicesListRequestManufacturer = "linear" + DevicesListRequestManufacturerLockly DevicesListRequestManufacturer = "lockly" + DevicesListRequestManufacturerNuki DevicesListRequestManufacturer = "nuki" + DevicesListRequestManufacturerPhilia DevicesListRequestManufacturer = "philia" + DevicesListRequestManufacturerSalto DevicesListRequestManufacturer = "salto" + DevicesListRequestManufacturerSamsung DevicesListRequestManufacturer = "samsung" + DevicesListRequestManufacturerSchlage DevicesListRequestManufacturer = "schlage" + DevicesListRequestManufacturerSeam DevicesListRequestManufacturer = "seam" + DevicesListRequestManufacturerUnknown DevicesListRequestManufacturer = "unknown" + DevicesListRequestManufacturerWyze DevicesListRequestManufacturer = "wyze" + DevicesListRequestManufacturerYale DevicesListRequestManufacturer = "yale" + DevicesListRequestManufacturerMinut DevicesListRequestManufacturer = "minut" + DevicesListRequestManufacturerTwoN DevicesListRequestManufacturer = "two_n" + DevicesListRequestManufacturerTtlock DevicesListRequestManufacturer = "ttlock" + DevicesListRequestManufacturerNest DevicesListRequestManufacturer = "nest" + DevicesListRequestManufacturerIgloohome DevicesListRequestManufacturer = "igloohome" + DevicesListRequestManufacturerEcobee DevicesListRequestManufacturer = "ecobee" + DevicesListRequestManufacturerHubitat DevicesListRequestManufacturer = "hubitat" + DevicesListRequestManufacturerControlbyweb DevicesListRequestManufacturer = "controlbyweb" + DevicesListRequestManufacturerSmartthings DevicesListRequestManufacturer = "smartthings" + DevicesListRequestManufacturerDormakabaOracode DevicesListRequestManufacturer = "dormakaba_oracode" +) + +func NewDevicesListRequestManufacturerFromString(s string) (DevicesListRequestManufacturer, error) { + switch s { + case "akuvox": + return DevicesListRequestManufacturerAkuvox, nil + case "august": + return DevicesListRequestManufacturerAugust, nil + case "avigilon_alta": + return DevicesListRequestManufacturerAvigilonAlta, nil + case "brivo": + return DevicesListRequestManufacturerBrivo, nil + case "butterflymx": + return DevicesListRequestManufacturerButterflymx, nil + case "doorking": + return DevicesListRequestManufacturerDoorking, nil + case "four_suites": + return DevicesListRequestManufacturerFourSuites, nil + case "genie": + return DevicesListRequestManufacturerGenie, nil + case "igloo": + return DevicesListRequestManufacturerIgloo, nil + case "keywe": + return DevicesListRequestManufacturerKeywe, nil + case "kwikset": + return DevicesListRequestManufacturerKwikset, nil + case "linear": + return DevicesListRequestManufacturerLinear, nil + case "lockly": + return DevicesListRequestManufacturerLockly, nil + case "nuki": + return DevicesListRequestManufacturerNuki, nil + case "philia": + return DevicesListRequestManufacturerPhilia, nil + case "salto": + return DevicesListRequestManufacturerSalto, nil + case "samsung": + return DevicesListRequestManufacturerSamsung, nil + case "schlage": + return DevicesListRequestManufacturerSchlage, nil + case "seam": + return DevicesListRequestManufacturerSeam, nil + case "unknown": + return DevicesListRequestManufacturerUnknown, nil + case "wyze": + return DevicesListRequestManufacturerWyze, nil + case "yale": + return DevicesListRequestManufacturerYale, nil + case "minut": + return DevicesListRequestManufacturerMinut, nil + case "two_n": + return DevicesListRequestManufacturerTwoN, nil + case "ttlock": + return DevicesListRequestManufacturerTtlock, nil + case "nest": + return DevicesListRequestManufacturerNest, nil + case "igloohome": + return DevicesListRequestManufacturerIgloohome, nil + case "ecobee": + return DevicesListRequestManufacturerEcobee, nil + case "hubitat": + return DevicesListRequestManufacturerHubitat, nil + case "controlbyweb": + return DevicesListRequestManufacturerControlbyweb, nil + case "smartthings": + return DevicesListRequestManufacturerSmartthings, nil + case "dormakaba_oracode": + return DevicesListRequestManufacturerDormakabaOracode, nil } - return fmt.Sprintf("%#v", d) + var t DevicesListRequestManufacturer + return "", fmt.Errorf("%s is not a valid %T", s, t) } -type DevicesUpdateRequestLocation struct { +func (d DevicesListRequestManufacturer) Ptr() *DevicesListRequestManufacturer { + return &d +} + +type DevicesListResponse struct { + Devices []*Device `json:"devices,omitempty"` + Ok bool `json:"ok"` + _rawJSON json.RawMessage } -func (d *DevicesUpdateRequestLocation) UnmarshalJSON(data []byte) error { - type unmarshaler DevicesUpdateRequestLocation +func (d *DevicesListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DevicesListResponse var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DevicesUpdateRequestLocation(value) + *d = DevicesListResponse(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DevicesUpdateRequestLocation) String() string { +func (d *DevicesListResponse) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -264,6 +569,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..3b9bbaa 100644 --- a/devices/unmanaged.go +++ b/devices/unmanaged.go @@ -3,23 +3,452 @@ 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 { - ConnectedAccountId *string `json:"connected_account_id,omitempty"` - ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` - ConnectWebviewId *string `json:"connect_webview_id,omitempty"` - DeviceType *seamapigo.DeviceType `json:"device_type,omitempty"` - DeviceTypes []seamapigo.DeviceType `json:"device_types,omitempty"` - Manufacturer *seamapigo.Manufacturer `json:"manufacturer,omitempty"` - DeviceIds []string `json:"device_ids,omitempty"` - Limit *float64 `json:"limit,omitempty"` - CreatedBefore *time.Time `json:"created_before,omitempty"` + // 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"` + DeviceType *UnmanagedListRequestDeviceType `json:"device_type,omitempty"` + DeviceTypes []UnmanagedListRequestDeviceTypesItem `json:"device_types,omitempty"` + Manufacturer *UnmanagedListRequestManufacturer `json:"manufacturer,omitempty"` + 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 UnmanagedListRequestDeviceType string + +const ( + UnmanagedListRequestDeviceTypeAkuvoxLock UnmanagedListRequestDeviceType = "akuvox_lock" + UnmanagedListRequestDeviceTypeAugustLock UnmanagedListRequestDeviceType = "august_lock" + UnmanagedListRequestDeviceTypeBrivoAccessPoint UnmanagedListRequestDeviceType = "brivo_access_point" + UnmanagedListRequestDeviceTypeButterflymxPanel UnmanagedListRequestDeviceType = "butterflymx_panel" + UnmanagedListRequestDeviceTypeAvigilonAltaEntry UnmanagedListRequestDeviceType = "avigilon_alta_entry" + UnmanagedListRequestDeviceTypeDoorkingLock UnmanagedListRequestDeviceType = "doorking_lock" + UnmanagedListRequestDeviceTypeGenieDoor UnmanagedListRequestDeviceType = "genie_door" + UnmanagedListRequestDeviceTypeIglooLock UnmanagedListRequestDeviceType = "igloo_lock" + UnmanagedListRequestDeviceTypeLinearLock UnmanagedListRequestDeviceType = "linear_lock" + UnmanagedListRequestDeviceTypeLocklyLock UnmanagedListRequestDeviceType = "lockly_lock" + UnmanagedListRequestDeviceTypeKwiksetLock UnmanagedListRequestDeviceType = "kwikset_lock" + UnmanagedListRequestDeviceTypeNukiLock UnmanagedListRequestDeviceType = "nuki_lock" + UnmanagedListRequestDeviceTypeSaltoLock UnmanagedListRequestDeviceType = "salto_lock" + UnmanagedListRequestDeviceTypeSchlageLock UnmanagedListRequestDeviceType = "schlage_lock" + UnmanagedListRequestDeviceTypeSeamRelay UnmanagedListRequestDeviceType = "seam_relay" + UnmanagedListRequestDeviceTypeSmartthingsLock UnmanagedListRequestDeviceType = "smartthings_lock" + UnmanagedListRequestDeviceTypeWyzeLock UnmanagedListRequestDeviceType = "wyze_lock" + UnmanagedListRequestDeviceTypeYaleLock UnmanagedListRequestDeviceType = "yale_lock" + UnmanagedListRequestDeviceTypeTwoNIntercom UnmanagedListRequestDeviceType = "two_n_intercom" + UnmanagedListRequestDeviceTypeControlbywebDevice UnmanagedListRequestDeviceType = "controlbyweb_device" + UnmanagedListRequestDeviceTypeTtlockLock UnmanagedListRequestDeviceType = "ttlock_lock" + UnmanagedListRequestDeviceTypeIgloohomeLock UnmanagedListRequestDeviceType = "igloohome_lock" + UnmanagedListRequestDeviceTypeHubitatLock UnmanagedListRequestDeviceType = "hubitat_lock" + UnmanagedListRequestDeviceTypeFourSuitesDoor UnmanagedListRequestDeviceType = "four_suites_door" + UnmanagedListRequestDeviceTypeDormakabaOracodeDoor UnmanagedListRequestDeviceType = "dormakaba_oracode_door" + UnmanagedListRequestDeviceTypeNoiseawareActivityZone UnmanagedListRequestDeviceType = "noiseaware_activity_zone" + UnmanagedListRequestDeviceTypeMinutSensor UnmanagedListRequestDeviceType = "minut_sensor" + UnmanagedListRequestDeviceTypeEcobeeThermostat UnmanagedListRequestDeviceType = "ecobee_thermostat" + UnmanagedListRequestDeviceTypeNestThermostat UnmanagedListRequestDeviceType = "nest_thermostat" + UnmanagedListRequestDeviceTypeIosPhone UnmanagedListRequestDeviceType = "ios_phone" + UnmanagedListRequestDeviceTypeAndroidPhone UnmanagedListRequestDeviceType = "android_phone" +) + +func NewUnmanagedListRequestDeviceTypeFromString(s string) (UnmanagedListRequestDeviceType, error) { + switch s { + case "akuvox_lock": + return UnmanagedListRequestDeviceTypeAkuvoxLock, nil + case "august_lock": + return UnmanagedListRequestDeviceTypeAugustLock, nil + case "brivo_access_point": + return UnmanagedListRequestDeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return UnmanagedListRequestDeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return UnmanagedListRequestDeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return UnmanagedListRequestDeviceTypeDoorkingLock, nil + case "genie_door": + return UnmanagedListRequestDeviceTypeGenieDoor, nil + case "igloo_lock": + return UnmanagedListRequestDeviceTypeIglooLock, nil + case "linear_lock": + return UnmanagedListRequestDeviceTypeLinearLock, nil + case "lockly_lock": + return UnmanagedListRequestDeviceTypeLocklyLock, nil + case "kwikset_lock": + return UnmanagedListRequestDeviceTypeKwiksetLock, nil + case "nuki_lock": + return UnmanagedListRequestDeviceTypeNukiLock, nil + case "salto_lock": + return UnmanagedListRequestDeviceTypeSaltoLock, nil + case "schlage_lock": + return UnmanagedListRequestDeviceTypeSchlageLock, nil + case "seam_relay": + return UnmanagedListRequestDeviceTypeSeamRelay, nil + case "smartthings_lock": + return UnmanagedListRequestDeviceTypeSmartthingsLock, nil + case "wyze_lock": + return UnmanagedListRequestDeviceTypeWyzeLock, nil + case "yale_lock": + return UnmanagedListRequestDeviceTypeYaleLock, nil + case "two_n_intercom": + return UnmanagedListRequestDeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return UnmanagedListRequestDeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return UnmanagedListRequestDeviceTypeTtlockLock, nil + case "igloohome_lock": + return UnmanagedListRequestDeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return UnmanagedListRequestDeviceTypeHubitatLock, nil + case "four_suites_door": + return UnmanagedListRequestDeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return UnmanagedListRequestDeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return UnmanagedListRequestDeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return UnmanagedListRequestDeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return UnmanagedListRequestDeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return UnmanagedListRequestDeviceTypeNestThermostat, nil + case "ios_phone": + return UnmanagedListRequestDeviceTypeIosPhone, nil + case "android_phone": + return UnmanagedListRequestDeviceTypeAndroidPhone, nil + } + var t UnmanagedListRequestDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (u UnmanagedListRequestDeviceType) Ptr() *UnmanagedListRequestDeviceType { + return &u +} + +type UnmanagedListRequestDeviceTypesItem string + +const ( + UnmanagedListRequestDeviceTypesItemAkuvoxLock UnmanagedListRequestDeviceTypesItem = "akuvox_lock" + UnmanagedListRequestDeviceTypesItemAugustLock UnmanagedListRequestDeviceTypesItem = "august_lock" + UnmanagedListRequestDeviceTypesItemBrivoAccessPoint UnmanagedListRequestDeviceTypesItem = "brivo_access_point" + UnmanagedListRequestDeviceTypesItemButterflymxPanel UnmanagedListRequestDeviceTypesItem = "butterflymx_panel" + UnmanagedListRequestDeviceTypesItemAvigilonAltaEntry UnmanagedListRequestDeviceTypesItem = "avigilon_alta_entry" + UnmanagedListRequestDeviceTypesItemDoorkingLock UnmanagedListRequestDeviceTypesItem = "doorking_lock" + UnmanagedListRequestDeviceTypesItemGenieDoor UnmanagedListRequestDeviceTypesItem = "genie_door" + UnmanagedListRequestDeviceTypesItemIglooLock UnmanagedListRequestDeviceTypesItem = "igloo_lock" + UnmanagedListRequestDeviceTypesItemLinearLock UnmanagedListRequestDeviceTypesItem = "linear_lock" + UnmanagedListRequestDeviceTypesItemLocklyLock UnmanagedListRequestDeviceTypesItem = "lockly_lock" + UnmanagedListRequestDeviceTypesItemKwiksetLock UnmanagedListRequestDeviceTypesItem = "kwikset_lock" + UnmanagedListRequestDeviceTypesItemNukiLock UnmanagedListRequestDeviceTypesItem = "nuki_lock" + UnmanagedListRequestDeviceTypesItemSaltoLock UnmanagedListRequestDeviceTypesItem = "salto_lock" + UnmanagedListRequestDeviceTypesItemSchlageLock UnmanagedListRequestDeviceTypesItem = "schlage_lock" + UnmanagedListRequestDeviceTypesItemSeamRelay UnmanagedListRequestDeviceTypesItem = "seam_relay" + UnmanagedListRequestDeviceTypesItemSmartthingsLock UnmanagedListRequestDeviceTypesItem = "smartthings_lock" + UnmanagedListRequestDeviceTypesItemWyzeLock UnmanagedListRequestDeviceTypesItem = "wyze_lock" + UnmanagedListRequestDeviceTypesItemYaleLock UnmanagedListRequestDeviceTypesItem = "yale_lock" + UnmanagedListRequestDeviceTypesItemTwoNIntercom UnmanagedListRequestDeviceTypesItem = "two_n_intercom" + UnmanagedListRequestDeviceTypesItemControlbywebDevice UnmanagedListRequestDeviceTypesItem = "controlbyweb_device" + UnmanagedListRequestDeviceTypesItemTtlockLock UnmanagedListRequestDeviceTypesItem = "ttlock_lock" + UnmanagedListRequestDeviceTypesItemIgloohomeLock UnmanagedListRequestDeviceTypesItem = "igloohome_lock" + UnmanagedListRequestDeviceTypesItemHubitatLock UnmanagedListRequestDeviceTypesItem = "hubitat_lock" + UnmanagedListRequestDeviceTypesItemFourSuitesDoor UnmanagedListRequestDeviceTypesItem = "four_suites_door" + UnmanagedListRequestDeviceTypesItemDormakabaOracodeDoor UnmanagedListRequestDeviceTypesItem = "dormakaba_oracode_door" + UnmanagedListRequestDeviceTypesItemNoiseawareActivityZone UnmanagedListRequestDeviceTypesItem = "noiseaware_activity_zone" + UnmanagedListRequestDeviceTypesItemMinutSensor UnmanagedListRequestDeviceTypesItem = "minut_sensor" + UnmanagedListRequestDeviceTypesItemEcobeeThermostat UnmanagedListRequestDeviceTypesItem = "ecobee_thermostat" + UnmanagedListRequestDeviceTypesItemNestThermostat UnmanagedListRequestDeviceTypesItem = "nest_thermostat" + UnmanagedListRequestDeviceTypesItemIosPhone UnmanagedListRequestDeviceTypesItem = "ios_phone" + UnmanagedListRequestDeviceTypesItemAndroidPhone UnmanagedListRequestDeviceTypesItem = "android_phone" +) + +func NewUnmanagedListRequestDeviceTypesItemFromString(s string) (UnmanagedListRequestDeviceTypesItem, error) { + switch s { + case "akuvox_lock": + return UnmanagedListRequestDeviceTypesItemAkuvoxLock, nil + case "august_lock": + return UnmanagedListRequestDeviceTypesItemAugustLock, nil + case "brivo_access_point": + return UnmanagedListRequestDeviceTypesItemBrivoAccessPoint, nil + case "butterflymx_panel": + return UnmanagedListRequestDeviceTypesItemButterflymxPanel, nil + case "avigilon_alta_entry": + return UnmanagedListRequestDeviceTypesItemAvigilonAltaEntry, nil + case "doorking_lock": + return UnmanagedListRequestDeviceTypesItemDoorkingLock, nil + case "genie_door": + return UnmanagedListRequestDeviceTypesItemGenieDoor, nil + case "igloo_lock": + return UnmanagedListRequestDeviceTypesItemIglooLock, nil + case "linear_lock": + return UnmanagedListRequestDeviceTypesItemLinearLock, nil + case "lockly_lock": + return UnmanagedListRequestDeviceTypesItemLocklyLock, nil + case "kwikset_lock": + return UnmanagedListRequestDeviceTypesItemKwiksetLock, nil + case "nuki_lock": + return UnmanagedListRequestDeviceTypesItemNukiLock, nil + case "salto_lock": + return UnmanagedListRequestDeviceTypesItemSaltoLock, nil + case "schlage_lock": + return UnmanagedListRequestDeviceTypesItemSchlageLock, nil + case "seam_relay": + return UnmanagedListRequestDeviceTypesItemSeamRelay, nil + case "smartthings_lock": + return UnmanagedListRequestDeviceTypesItemSmartthingsLock, nil + case "wyze_lock": + return UnmanagedListRequestDeviceTypesItemWyzeLock, nil + case "yale_lock": + return UnmanagedListRequestDeviceTypesItemYaleLock, nil + case "two_n_intercom": + return UnmanagedListRequestDeviceTypesItemTwoNIntercom, nil + case "controlbyweb_device": + return UnmanagedListRequestDeviceTypesItemControlbywebDevice, nil + case "ttlock_lock": + return UnmanagedListRequestDeviceTypesItemTtlockLock, nil + case "igloohome_lock": + return UnmanagedListRequestDeviceTypesItemIgloohomeLock, nil + case "hubitat_lock": + return UnmanagedListRequestDeviceTypesItemHubitatLock, nil + case "four_suites_door": + return UnmanagedListRequestDeviceTypesItemFourSuitesDoor, nil + case "dormakaba_oracode_door": + return UnmanagedListRequestDeviceTypesItemDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return UnmanagedListRequestDeviceTypesItemNoiseawareActivityZone, nil + case "minut_sensor": + return UnmanagedListRequestDeviceTypesItemMinutSensor, nil + case "ecobee_thermostat": + return UnmanagedListRequestDeviceTypesItemEcobeeThermostat, nil + case "nest_thermostat": + return UnmanagedListRequestDeviceTypesItemNestThermostat, nil + case "ios_phone": + return UnmanagedListRequestDeviceTypesItemIosPhone, nil + case "android_phone": + return UnmanagedListRequestDeviceTypesItemAndroidPhone, nil + } + var t UnmanagedListRequestDeviceTypesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (u UnmanagedListRequestDeviceTypesItem) Ptr() *UnmanagedListRequestDeviceTypesItem { + return &u +} + +type UnmanagedListRequestManufacturer string + +const ( + UnmanagedListRequestManufacturerAkuvox UnmanagedListRequestManufacturer = "akuvox" + UnmanagedListRequestManufacturerAugust UnmanagedListRequestManufacturer = "august" + UnmanagedListRequestManufacturerAvigilonAlta UnmanagedListRequestManufacturer = "avigilon_alta" + UnmanagedListRequestManufacturerBrivo UnmanagedListRequestManufacturer = "brivo" + UnmanagedListRequestManufacturerButterflymx UnmanagedListRequestManufacturer = "butterflymx" + UnmanagedListRequestManufacturerDoorking UnmanagedListRequestManufacturer = "doorking" + UnmanagedListRequestManufacturerFourSuites UnmanagedListRequestManufacturer = "four_suites" + UnmanagedListRequestManufacturerGenie UnmanagedListRequestManufacturer = "genie" + UnmanagedListRequestManufacturerIgloo UnmanagedListRequestManufacturer = "igloo" + UnmanagedListRequestManufacturerKeywe UnmanagedListRequestManufacturer = "keywe" + UnmanagedListRequestManufacturerKwikset UnmanagedListRequestManufacturer = "kwikset" + UnmanagedListRequestManufacturerLinear UnmanagedListRequestManufacturer = "linear" + UnmanagedListRequestManufacturerLockly UnmanagedListRequestManufacturer = "lockly" + UnmanagedListRequestManufacturerNuki UnmanagedListRequestManufacturer = "nuki" + UnmanagedListRequestManufacturerPhilia UnmanagedListRequestManufacturer = "philia" + UnmanagedListRequestManufacturerSalto UnmanagedListRequestManufacturer = "salto" + UnmanagedListRequestManufacturerSamsung UnmanagedListRequestManufacturer = "samsung" + UnmanagedListRequestManufacturerSchlage UnmanagedListRequestManufacturer = "schlage" + UnmanagedListRequestManufacturerSeam UnmanagedListRequestManufacturer = "seam" + UnmanagedListRequestManufacturerUnknown UnmanagedListRequestManufacturer = "unknown" + UnmanagedListRequestManufacturerWyze UnmanagedListRequestManufacturer = "wyze" + UnmanagedListRequestManufacturerYale UnmanagedListRequestManufacturer = "yale" + UnmanagedListRequestManufacturerMinut UnmanagedListRequestManufacturer = "minut" + UnmanagedListRequestManufacturerTwoN UnmanagedListRequestManufacturer = "two_n" + UnmanagedListRequestManufacturerTtlock UnmanagedListRequestManufacturer = "ttlock" + UnmanagedListRequestManufacturerNest UnmanagedListRequestManufacturer = "nest" + UnmanagedListRequestManufacturerIgloohome UnmanagedListRequestManufacturer = "igloohome" + UnmanagedListRequestManufacturerEcobee UnmanagedListRequestManufacturer = "ecobee" + UnmanagedListRequestManufacturerHubitat UnmanagedListRequestManufacturer = "hubitat" + UnmanagedListRequestManufacturerControlbyweb UnmanagedListRequestManufacturer = "controlbyweb" + UnmanagedListRequestManufacturerSmartthings UnmanagedListRequestManufacturer = "smartthings" + UnmanagedListRequestManufacturerDormakabaOracode UnmanagedListRequestManufacturer = "dormakaba_oracode" +) + +func NewUnmanagedListRequestManufacturerFromString(s string) (UnmanagedListRequestManufacturer, error) { + switch s { + case "akuvox": + return UnmanagedListRequestManufacturerAkuvox, nil + case "august": + return UnmanagedListRequestManufacturerAugust, nil + case "avigilon_alta": + return UnmanagedListRequestManufacturerAvigilonAlta, nil + case "brivo": + return UnmanagedListRequestManufacturerBrivo, nil + case "butterflymx": + return UnmanagedListRequestManufacturerButterflymx, nil + case "doorking": + return UnmanagedListRequestManufacturerDoorking, nil + case "four_suites": + return UnmanagedListRequestManufacturerFourSuites, nil + case "genie": + return UnmanagedListRequestManufacturerGenie, nil + case "igloo": + return UnmanagedListRequestManufacturerIgloo, nil + case "keywe": + return UnmanagedListRequestManufacturerKeywe, nil + case "kwikset": + return UnmanagedListRequestManufacturerKwikset, nil + case "linear": + return UnmanagedListRequestManufacturerLinear, nil + case "lockly": + return UnmanagedListRequestManufacturerLockly, nil + case "nuki": + return UnmanagedListRequestManufacturerNuki, nil + case "philia": + return UnmanagedListRequestManufacturerPhilia, nil + case "salto": + return UnmanagedListRequestManufacturerSalto, nil + case "samsung": + return UnmanagedListRequestManufacturerSamsung, nil + case "schlage": + return UnmanagedListRequestManufacturerSchlage, nil + case "seam": + return UnmanagedListRequestManufacturerSeam, nil + case "unknown": + return UnmanagedListRequestManufacturerUnknown, nil + case "wyze": + return UnmanagedListRequestManufacturerWyze, nil + case "yale": + return UnmanagedListRequestManufacturerYale, nil + case "minut": + return UnmanagedListRequestManufacturerMinut, nil + case "two_n": + return UnmanagedListRequestManufacturerTwoN, nil + case "ttlock": + return UnmanagedListRequestManufacturerTtlock, nil + case "nest": + return UnmanagedListRequestManufacturerNest, nil + case "igloohome": + return UnmanagedListRequestManufacturerIgloohome, nil + case "ecobee": + return UnmanagedListRequestManufacturerEcobee, nil + case "hubitat": + return UnmanagedListRequestManufacturerHubitat, nil + case "controlbyweb": + return UnmanagedListRequestManufacturerControlbyweb, nil + case "smartthings": + return UnmanagedListRequestManufacturerSmartthings, nil + case "dormakaba_oracode": + return UnmanagedListRequestManufacturerDormakabaOracode, nil + } + var t UnmanagedListRequestManufacturer + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (u UnmanagedListRequestManufacturer) Ptr() *UnmanagedListRequestManufacturer { + return &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..9cd1ae3 100644 --- a/locks.go +++ b/locks.go @@ -15,15 +15,17 @@ type LocksGetRequest struct { } type LocksListRequest struct { - ConnectedAccountId *string `json:"connected_account_id,omitempty"` - ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` - ConnectWebviewId *string `json:"connect_webview_id,omitempty"` - DeviceType *DeviceType `json:"device_type,omitempty"` - DeviceTypes []DeviceType `json:"device_types,omitempty"` - Manufacturer *Manufacturer `json:"manufacturer,omitempty"` - DeviceIds []string `json:"device_ids,omitempty"` - Limit *float64 `json:"limit,omitempty"` - CreatedBefore *time.Time `json:"created_before,omitempty"` + // 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"` + DeviceType *LocksListRequestDeviceType `json:"device_type,omitempty"` + DeviceTypes []LocksListRequestDeviceTypesItem `json:"device_types,omitempty"` + Manufacturer *LocksListRequestManufacturer `json:"manufacturer,omitempty"` + 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 } @@ -62,10 +64,340 @@ func (l *LocksGetResponse) String() string { return fmt.Sprintf("%#v", l) } +type LocksListRequestDeviceType string + +const ( + LocksListRequestDeviceTypeAkuvoxLock LocksListRequestDeviceType = "akuvox_lock" + LocksListRequestDeviceTypeAugustLock LocksListRequestDeviceType = "august_lock" + LocksListRequestDeviceTypeBrivoAccessPoint LocksListRequestDeviceType = "brivo_access_point" + LocksListRequestDeviceTypeButterflymxPanel LocksListRequestDeviceType = "butterflymx_panel" + LocksListRequestDeviceTypeAvigilonAltaEntry LocksListRequestDeviceType = "avigilon_alta_entry" + LocksListRequestDeviceTypeDoorkingLock LocksListRequestDeviceType = "doorking_lock" + LocksListRequestDeviceTypeGenieDoor LocksListRequestDeviceType = "genie_door" + LocksListRequestDeviceTypeIglooLock LocksListRequestDeviceType = "igloo_lock" + LocksListRequestDeviceTypeLinearLock LocksListRequestDeviceType = "linear_lock" + LocksListRequestDeviceTypeLocklyLock LocksListRequestDeviceType = "lockly_lock" + LocksListRequestDeviceTypeKwiksetLock LocksListRequestDeviceType = "kwikset_lock" + LocksListRequestDeviceTypeNukiLock LocksListRequestDeviceType = "nuki_lock" + LocksListRequestDeviceTypeSaltoLock LocksListRequestDeviceType = "salto_lock" + LocksListRequestDeviceTypeSchlageLock LocksListRequestDeviceType = "schlage_lock" + LocksListRequestDeviceTypeSeamRelay LocksListRequestDeviceType = "seam_relay" + LocksListRequestDeviceTypeSmartthingsLock LocksListRequestDeviceType = "smartthings_lock" + LocksListRequestDeviceTypeWyzeLock LocksListRequestDeviceType = "wyze_lock" + LocksListRequestDeviceTypeYaleLock LocksListRequestDeviceType = "yale_lock" + LocksListRequestDeviceTypeTwoNIntercom LocksListRequestDeviceType = "two_n_intercom" + LocksListRequestDeviceTypeControlbywebDevice LocksListRequestDeviceType = "controlbyweb_device" + LocksListRequestDeviceTypeTtlockLock LocksListRequestDeviceType = "ttlock_lock" + LocksListRequestDeviceTypeIgloohomeLock LocksListRequestDeviceType = "igloohome_lock" + LocksListRequestDeviceTypeHubitatLock LocksListRequestDeviceType = "hubitat_lock" + LocksListRequestDeviceTypeFourSuitesDoor LocksListRequestDeviceType = "four_suites_door" + LocksListRequestDeviceTypeDormakabaOracodeDoor LocksListRequestDeviceType = "dormakaba_oracode_door" + LocksListRequestDeviceTypeNoiseawareActivityZone LocksListRequestDeviceType = "noiseaware_activity_zone" + LocksListRequestDeviceTypeMinutSensor LocksListRequestDeviceType = "minut_sensor" + LocksListRequestDeviceTypeEcobeeThermostat LocksListRequestDeviceType = "ecobee_thermostat" + LocksListRequestDeviceTypeNestThermostat LocksListRequestDeviceType = "nest_thermostat" + LocksListRequestDeviceTypeIosPhone LocksListRequestDeviceType = "ios_phone" + LocksListRequestDeviceTypeAndroidPhone LocksListRequestDeviceType = "android_phone" +) + +func NewLocksListRequestDeviceTypeFromString(s string) (LocksListRequestDeviceType, error) { + switch s { + case "akuvox_lock": + return LocksListRequestDeviceTypeAkuvoxLock, nil + case "august_lock": + return LocksListRequestDeviceTypeAugustLock, nil + case "brivo_access_point": + return LocksListRequestDeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return LocksListRequestDeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return LocksListRequestDeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return LocksListRequestDeviceTypeDoorkingLock, nil + case "genie_door": + return LocksListRequestDeviceTypeGenieDoor, nil + case "igloo_lock": + return LocksListRequestDeviceTypeIglooLock, nil + case "linear_lock": + return LocksListRequestDeviceTypeLinearLock, nil + case "lockly_lock": + return LocksListRequestDeviceTypeLocklyLock, nil + case "kwikset_lock": + return LocksListRequestDeviceTypeKwiksetLock, nil + case "nuki_lock": + return LocksListRequestDeviceTypeNukiLock, nil + case "salto_lock": + return LocksListRequestDeviceTypeSaltoLock, nil + case "schlage_lock": + return LocksListRequestDeviceTypeSchlageLock, nil + case "seam_relay": + return LocksListRequestDeviceTypeSeamRelay, nil + case "smartthings_lock": + return LocksListRequestDeviceTypeSmartthingsLock, nil + case "wyze_lock": + return LocksListRequestDeviceTypeWyzeLock, nil + case "yale_lock": + return LocksListRequestDeviceTypeYaleLock, nil + case "two_n_intercom": + return LocksListRequestDeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return LocksListRequestDeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return LocksListRequestDeviceTypeTtlockLock, nil + case "igloohome_lock": + return LocksListRequestDeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return LocksListRequestDeviceTypeHubitatLock, nil + case "four_suites_door": + return LocksListRequestDeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return LocksListRequestDeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return LocksListRequestDeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return LocksListRequestDeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return LocksListRequestDeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return LocksListRequestDeviceTypeNestThermostat, nil + case "ios_phone": + return LocksListRequestDeviceTypeIosPhone, nil + case "android_phone": + return LocksListRequestDeviceTypeAndroidPhone, nil + } + var t LocksListRequestDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (l LocksListRequestDeviceType) Ptr() *LocksListRequestDeviceType { + return &l +} + +type LocksListRequestDeviceTypesItem string + +const ( + LocksListRequestDeviceTypesItemAkuvoxLock LocksListRequestDeviceTypesItem = "akuvox_lock" + LocksListRequestDeviceTypesItemAugustLock LocksListRequestDeviceTypesItem = "august_lock" + LocksListRequestDeviceTypesItemBrivoAccessPoint LocksListRequestDeviceTypesItem = "brivo_access_point" + LocksListRequestDeviceTypesItemButterflymxPanel LocksListRequestDeviceTypesItem = "butterflymx_panel" + LocksListRequestDeviceTypesItemAvigilonAltaEntry LocksListRequestDeviceTypesItem = "avigilon_alta_entry" + LocksListRequestDeviceTypesItemDoorkingLock LocksListRequestDeviceTypesItem = "doorking_lock" + LocksListRequestDeviceTypesItemGenieDoor LocksListRequestDeviceTypesItem = "genie_door" + LocksListRequestDeviceTypesItemIglooLock LocksListRequestDeviceTypesItem = "igloo_lock" + LocksListRequestDeviceTypesItemLinearLock LocksListRequestDeviceTypesItem = "linear_lock" + LocksListRequestDeviceTypesItemLocklyLock LocksListRequestDeviceTypesItem = "lockly_lock" + LocksListRequestDeviceTypesItemKwiksetLock LocksListRequestDeviceTypesItem = "kwikset_lock" + LocksListRequestDeviceTypesItemNukiLock LocksListRequestDeviceTypesItem = "nuki_lock" + LocksListRequestDeviceTypesItemSaltoLock LocksListRequestDeviceTypesItem = "salto_lock" + LocksListRequestDeviceTypesItemSchlageLock LocksListRequestDeviceTypesItem = "schlage_lock" + LocksListRequestDeviceTypesItemSeamRelay LocksListRequestDeviceTypesItem = "seam_relay" + LocksListRequestDeviceTypesItemSmartthingsLock LocksListRequestDeviceTypesItem = "smartthings_lock" + LocksListRequestDeviceTypesItemWyzeLock LocksListRequestDeviceTypesItem = "wyze_lock" + LocksListRequestDeviceTypesItemYaleLock LocksListRequestDeviceTypesItem = "yale_lock" + LocksListRequestDeviceTypesItemTwoNIntercom LocksListRequestDeviceTypesItem = "two_n_intercom" + LocksListRequestDeviceTypesItemControlbywebDevice LocksListRequestDeviceTypesItem = "controlbyweb_device" + LocksListRequestDeviceTypesItemTtlockLock LocksListRequestDeviceTypesItem = "ttlock_lock" + LocksListRequestDeviceTypesItemIgloohomeLock LocksListRequestDeviceTypesItem = "igloohome_lock" + LocksListRequestDeviceTypesItemHubitatLock LocksListRequestDeviceTypesItem = "hubitat_lock" + LocksListRequestDeviceTypesItemFourSuitesDoor LocksListRequestDeviceTypesItem = "four_suites_door" + LocksListRequestDeviceTypesItemDormakabaOracodeDoor LocksListRequestDeviceTypesItem = "dormakaba_oracode_door" + LocksListRequestDeviceTypesItemNoiseawareActivityZone LocksListRequestDeviceTypesItem = "noiseaware_activity_zone" + LocksListRequestDeviceTypesItemMinutSensor LocksListRequestDeviceTypesItem = "minut_sensor" + LocksListRequestDeviceTypesItemEcobeeThermostat LocksListRequestDeviceTypesItem = "ecobee_thermostat" + LocksListRequestDeviceTypesItemNestThermostat LocksListRequestDeviceTypesItem = "nest_thermostat" + LocksListRequestDeviceTypesItemIosPhone LocksListRequestDeviceTypesItem = "ios_phone" + LocksListRequestDeviceTypesItemAndroidPhone LocksListRequestDeviceTypesItem = "android_phone" +) + +func NewLocksListRequestDeviceTypesItemFromString(s string) (LocksListRequestDeviceTypesItem, error) { + switch s { + case "akuvox_lock": + return LocksListRequestDeviceTypesItemAkuvoxLock, nil + case "august_lock": + return LocksListRequestDeviceTypesItemAugustLock, nil + case "brivo_access_point": + return LocksListRequestDeviceTypesItemBrivoAccessPoint, nil + case "butterflymx_panel": + return LocksListRequestDeviceTypesItemButterflymxPanel, nil + case "avigilon_alta_entry": + return LocksListRequestDeviceTypesItemAvigilonAltaEntry, nil + case "doorking_lock": + return LocksListRequestDeviceTypesItemDoorkingLock, nil + case "genie_door": + return LocksListRequestDeviceTypesItemGenieDoor, nil + case "igloo_lock": + return LocksListRequestDeviceTypesItemIglooLock, nil + case "linear_lock": + return LocksListRequestDeviceTypesItemLinearLock, nil + case "lockly_lock": + return LocksListRequestDeviceTypesItemLocklyLock, nil + case "kwikset_lock": + return LocksListRequestDeviceTypesItemKwiksetLock, nil + case "nuki_lock": + return LocksListRequestDeviceTypesItemNukiLock, nil + case "salto_lock": + return LocksListRequestDeviceTypesItemSaltoLock, nil + case "schlage_lock": + return LocksListRequestDeviceTypesItemSchlageLock, nil + case "seam_relay": + return LocksListRequestDeviceTypesItemSeamRelay, nil + case "smartthings_lock": + return LocksListRequestDeviceTypesItemSmartthingsLock, nil + case "wyze_lock": + return LocksListRequestDeviceTypesItemWyzeLock, nil + case "yale_lock": + return LocksListRequestDeviceTypesItemYaleLock, nil + case "two_n_intercom": + return LocksListRequestDeviceTypesItemTwoNIntercom, nil + case "controlbyweb_device": + return LocksListRequestDeviceTypesItemControlbywebDevice, nil + case "ttlock_lock": + return LocksListRequestDeviceTypesItemTtlockLock, nil + case "igloohome_lock": + return LocksListRequestDeviceTypesItemIgloohomeLock, nil + case "hubitat_lock": + return LocksListRequestDeviceTypesItemHubitatLock, nil + case "four_suites_door": + return LocksListRequestDeviceTypesItemFourSuitesDoor, nil + case "dormakaba_oracode_door": + return LocksListRequestDeviceTypesItemDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return LocksListRequestDeviceTypesItemNoiseawareActivityZone, nil + case "minut_sensor": + return LocksListRequestDeviceTypesItemMinutSensor, nil + case "ecobee_thermostat": + return LocksListRequestDeviceTypesItemEcobeeThermostat, nil + case "nest_thermostat": + return LocksListRequestDeviceTypesItemNestThermostat, nil + case "ios_phone": + return LocksListRequestDeviceTypesItemIosPhone, nil + case "android_phone": + return LocksListRequestDeviceTypesItemAndroidPhone, nil + } + var t LocksListRequestDeviceTypesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (l LocksListRequestDeviceTypesItem) Ptr() *LocksListRequestDeviceTypesItem { + return &l +} + +type LocksListRequestManufacturer string + +const ( + LocksListRequestManufacturerAkuvox LocksListRequestManufacturer = "akuvox" + LocksListRequestManufacturerAugust LocksListRequestManufacturer = "august" + LocksListRequestManufacturerAvigilonAlta LocksListRequestManufacturer = "avigilon_alta" + LocksListRequestManufacturerBrivo LocksListRequestManufacturer = "brivo" + LocksListRequestManufacturerButterflymx LocksListRequestManufacturer = "butterflymx" + LocksListRequestManufacturerDoorking LocksListRequestManufacturer = "doorking" + LocksListRequestManufacturerFourSuites LocksListRequestManufacturer = "four_suites" + LocksListRequestManufacturerGenie LocksListRequestManufacturer = "genie" + LocksListRequestManufacturerIgloo LocksListRequestManufacturer = "igloo" + LocksListRequestManufacturerKeywe LocksListRequestManufacturer = "keywe" + LocksListRequestManufacturerKwikset LocksListRequestManufacturer = "kwikset" + LocksListRequestManufacturerLinear LocksListRequestManufacturer = "linear" + LocksListRequestManufacturerLockly LocksListRequestManufacturer = "lockly" + LocksListRequestManufacturerNuki LocksListRequestManufacturer = "nuki" + LocksListRequestManufacturerPhilia LocksListRequestManufacturer = "philia" + LocksListRequestManufacturerSalto LocksListRequestManufacturer = "salto" + LocksListRequestManufacturerSamsung LocksListRequestManufacturer = "samsung" + LocksListRequestManufacturerSchlage LocksListRequestManufacturer = "schlage" + LocksListRequestManufacturerSeam LocksListRequestManufacturer = "seam" + LocksListRequestManufacturerUnknown LocksListRequestManufacturer = "unknown" + LocksListRequestManufacturerWyze LocksListRequestManufacturer = "wyze" + LocksListRequestManufacturerYale LocksListRequestManufacturer = "yale" + LocksListRequestManufacturerMinut LocksListRequestManufacturer = "minut" + LocksListRequestManufacturerTwoN LocksListRequestManufacturer = "two_n" + LocksListRequestManufacturerTtlock LocksListRequestManufacturer = "ttlock" + LocksListRequestManufacturerNest LocksListRequestManufacturer = "nest" + LocksListRequestManufacturerIgloohome LocksListRequestManufacturer = "igloohome" + LocksListRequestManufacturerEcobee LocksListRequestManufacturer = "ecobee" + LocksListRequestManufacturerHubitat LocksListRequestManufacturer = "hubitat" + LocksListRequestManufacturerControlbyweb LocksListRequestManufacturer = "controlbyweb" + LocksListRequestManufacturerSmartthings LocksListRequestManufacturer = "smartthings" + LocksListRequestManufacturerDormakabaOracode LocksListRequestManufacturer = "dormakaba_oracode" +) + +func NewLocksListRequestManufacturerFromString(s string) (LocksListRequestManufacturer, error) { + switch s { + case "akuvox": + return LocksListRequestManufacturerAkuvox, nil + case "august": + return LocksListRequestManufacturerAugust, nil + case "avigilon_alta": + return LocksListRequestManufacturerAvigilonAlta, nil + case "brivo": + return LocksListRequestManufacturerBrivo, nil + case "butterflymx": + return LocksListRequestManufacturerButterflymx, nil + case "doorking": + return LocksListRequestManufacturerDoorking, nil + case "four_suites": + return LocksListRequestManufacturerFourSuites, nil + case "genie": + return LocksListRequestManufacturerGenie, nil + case "igloo": + return LocksListRequestManufacturerIgloo, nil + case "keywe": + return LocksListRequestManufacturerKeywe, nil + case "kwikset": + return LocksListRequestManufacturerKwikset, nil + case "linear": + return LocksListRequestManufacturerLinear, nil + case "lockly": + return LocksListRequestManufacturerLockly, nil + case "nuki": + return LocksListRequestManufacturerNuki, nil + case "philia": + return LocksListRequestManufacturerPhilia, nil + case "salto": + return LocksListRequestManufacturerSalto, nil + case "samsung": + return LocksListRequestManufacturerSamsung, nil + case "schlage": + return LocksListRequestManufacturerSchlage, nil + case "seam": + return LocksListRequestManufacturerSeam, nil + case "unknown": + return LocksListRequestManufacturerUnknown, nil + case "wyze": + return LocksListRequestManufacturerWyze, nil + case "yale": + return LocksListRequestManufacturerYale, nil + case "minut": + return LocksListRequestManufacturerMinut, nil + case "two_n": + return LocksListRequestManufacturerTwoN, nil + case "ttlock": + return LocksListRequestManufacturerTtlock, nil + case "nest": + return LocksListRequestManufacturerNest, nil + case "igloohome": + return LocksListRequestManufacturerIgloohome, nil + case "ecobee": + return LocksListRequestManufacturerEcobee, nil + case "hubitat": + return LocksListRequestManufacturerHubitat, nil + case "controlbyweb": + return LocksListRequestManufacturerControlbyweb, nil + case "smartthings": + return LocksListRequestManufacturerSmartthings, nil + case "dormakaba_oracode": + return LocksListRequestManufacturerDormakabaOracode, nil + } + var t LocksListRequestManufacturer + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (l LocksListRequestManufacturer) Ptr() *LocksListRequestManufacturer { + return &l +} + 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..af6ec94 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,45 +28,68 @@ 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 { - ConnectedAccountId *string `json:"connected_account_id,omitempty"` - ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` - ConnectWebviewId *string `json:"connect_webview_id,omitempty"` - DeviceType *DeviceType `json:"device_type,omitempty"` - DeviceTypes []DeviceType `json:"device_types,omitempty"` - Manufacturer *Manufacturer `json:"manufacturer,omitempty"` - DeviceIds []string `json:"device_ids,omitempty"` - Limit *float64 `json:"limit,omitempty"` - CreatedBefore *time.Time `json:"created_before,omitempty"` + // 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"` + DeviceType *ThermostatsListRequestDeviceType `json:"device_type,omitempty"` + DeviceTypes []ThermostatsListRequestDeviceTypesItem `json:"device_types,omitempty"` + Manufacturer *ThermostatsListRequestManufacturer `json:"manufacturer,omitempty"` + 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"` @@ -121,6 +180,336 @@ func (t *ThermostatsHeatResponse) String() string { return fmt.Sprintf("%#v", t) } +type ThermostatsListRequestDeviceType string + +const ( + ThermostatsListRequestDeviceTypeAkuvoxLock ThermostatsListRequestDeviceType = "akuvox_lock" + ThermostatsListRequestDeviceTypeAugustLock ThermostatsListRequestDeviceType = "august_lock" + ThermostatsListRequestDeviceTypeBrivoAccessPoint ThermostatsListRequestDeviceType = "brivo_access_point" + ThermostatsListRequestDeviceTypeButterflymxPanel ThermostatsListRequestDeviceType = "butterflymx_panel" + ThermostatsListRequestDeviceTypeAvigilonAltaEntry ThermostatsListRequestDeviceType = "avigilon_alta_entry" + ThermostatsListRequestDeviceTypeDoorkingLock ThermostatsListRequestDeviceType = "doorking_lock" + ThermostatsListRequestDeviceTypeGenieDoor ThermostatsListRequestDeviceType = "genie_door" + ThermostatsListRequestDeviceTypeIglooLock ThermostatsListRequestDeviceType = "igloo_lock" + ThermostatsListRequestDeviceTypeLinearLock ThermostatsListRequestDeviceType = "linear_lock" + ThermostatsListRequestDeviceTypeLocklyLock ThermostatsListRequestDeviceType = "lockly_lock" + ThermostatsListRequestDeviceTypeKwiksetLock ThermostatsListRequestDeviceType = "kwikset_lock" + ThermostatsListRequestDeviceTypeNukiLock ThermostatsListRequestDeviceType = "nuki_lock" + ThermostatsListRequestDeviceTypeSaltoLock ThermostatsListRequestDeviceType = "salto_lock" + ThermostatsListRequestDeviceTypeSchlageLock ThermostatsListRequestDeviceType = "schlage_lock" + ThermostatsListRequestDeviceTypeSeamRelay ThermostatsListRequestDeviceType = "seam_relay" + ThermostatsListRequestDeviceTypeSmartthingsLock ThermostatsListRequestDeviceType = "smartthings_lock" + ThermostatsListRequestDeviceTypeWyzeLock ThermostatsListRequestDeviceType = "wyze_lock" + ThermostatsListRequestDeviceTypeYaleLock ThermostatsListRequestDeviceType = "yale_lock" + ThermostatsListRequestDeviceTypeTwoNIntercom ThermostatsListRequestDeviceType = "two_n_intercom" + ThermostatsListRequestDeviceTypeControlbywebDevice ThermostatsListRequestDeviceType = "controlbyweb_device" + ThermostatsListRequestDeviceTypeTtlockLock ThermostatsListRequestDeviceType = "ttlock_lock" + ThermostatsListRequestDeviceTypeIgloohomeLock ThermostatsListRequestDeviceType = "igloohome_lock" + ThermostatsListRequestDeviceTypeHubitatLock ThermostatsListRequestDeviceType = "hubitat_lock" + ThermostatsListRequestDeviceTypeFourSuitesDoor ThermostatsListRequestDeviceType = "four_suites_door" + ThermostatsListRequestDeviceTypeDormakabaOracodeDoor ThermostatsListRequestDeviceType = "dormakaba_oracode_door" + ThermostatsListRequestDeviceTypeNoiseawareActivityZone ThermostatsListRequestDeviceType = "noiseaware_activity_zone" + ThermostatsListRequestDeviceTypeMinutSensor ThermostatsListRequestDeviceType = "minut_sensor" + ThermostatsListRequestDeviceTypeEcobeeThermostat ThermostatsListRequestDeviceType = "ecobee_thermostat" + ThermostatsListRequestDeviceTypeNestThermostat ThermostatsListRequestDeviceType = "nest_thermostat" + ThermostatsListRequestDeviceTypeIosPhone ThermostatsListRequestDeviceType = "ios_phone" + ThermostatsListRequestDeviceTypeAndroidPhone ThermostatsListRequestDeviceType = "android_phone" +) + +func NewThermostatsListRequestDeviceTypeFromString(s string) (ThermostatsListRequestDeviceType, error) { + switch s { + case "akuvox_lock": + return ThermostatsListRequestDeviceTypeAkuvoxLock, nil + case "august_lock": + return ThermostatsListRequestDeviceTypeAugustLock, nil + case "brivo_access_point": + return ThermostatsListRequestDeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return ThermostatsListRequestDeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return ThermostatsListRequestDeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return ThermostatsListRequestDeviceTypeDoorkingLock, nil + case "genie_door": + return ThermostatsListRequestDeviceTypeGenieDoor, nil + case "igloo_lock": + return ThermostatsListRequestDeviceTypeIglooLock, nil + case "linear_lock": + return ThermostatsListRequestDeviceTypeLinearLock, nil + case "lockly_lock": + return ThermostatsListRequestDeviceTypeLocklyLock, nil + case "kwikset_lock": + return ThermostatsListRequestDeviceTypeKwiksetLock, nil + case "nuki_lock": + return ThermostatsListRequestDeviceTypeNukiLock, nil + case "salto_lock": + return ThermostatsListRequestDeviceTypeSaltoLock, nil + case "schlage_lock": + return ThermostatsListRequestDeviceTypeSchlageLock, nil + case "seam_relay": + return ThermostatsListRequestDeviceTypeSeamRelay, nil + case "smartthings_lock": + return ThermostatsListRequestDeviceTypeSmartthingsLock, nil + case "wyze_lock": + return ThermostatsListRequestDeviceTypeWyzeLock, nil + case "yale_lock": + return ThermostatsListRequestDeviceTypeYaleLock, nil + case "two_n_intercom": + return ThermostatsListRequestDeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return ThermostatsListRequestDeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return ThermostatsListRequestDeviceTypeTtlockLock, nil + case "igloohome_lock": + return ThermostatsListRequestDeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return ThermostatsListRequestDeviceTypeHubitatLock, nil + case "four_suites_door": + return ThermostatsListRequestDeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return ThermostatsListRequestDeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return ThermostatsListRequestDeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return ThermostatsListRequestDeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return ThermostatsListRequestDeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return ThermostatsListRequestDeviceTypeNestThermostat, nil + case "ios_phone": + return ThermostatsListRequestDeviceTypeIosPhone, nil + case "android_phone": + return ThermostatsListRequestDeviceTypeAndroidPhone, nil + } + var t ThermostatsListRequestDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (t ThermostatsListRequestDeviceType) Ptr() *ThermostatsListRequestDeviceType { + return &t +} + +type ThermostatsListRequestDeviceTypesItem string + +const ( + ThermostatsListRequestDeviceTypesItemAkuvoxLock ThermostatsListRequestDeviceTypesItem = "akuvox_lock" + ThermostatsListRequestDeviceTypesItemAugustLock ThermostatsListRequestDeviceTypesItem = "august_lock" + ThermostatsListRequestDeviceTypesItemBrivoAccessPoint ThermostatsListRequestDeviceTypesItem = "brivo_access_point" + ThermostatsListRequestDeviceTypesItemButterflymxPanel ThermostatsListRequestDeviceTypesItem = "butterflymx_panel" + ThermostatsListRequestDeviceTypesItemAvigilonAltaEntry ThermostatsListRequestDeviceTypesItem = "avigilon_alta_entry" + ThermostatsListRequestDeviceTypesItemDoorkingLock ThermostatsListRequestDeviceTypesItem = "doorking_lock" + ThermostatsListRequestDeviceTypesItemGenieDoor ThermostatsListRequestDeviceTypesItem = "genie_door" + ThermostatsListRequestDeviceTypesItemIglooLock ThermostatsListRequestDeviceTypesItem = "igloo_lock" + ThermostatsListRequestDeviceTypesItemLinearLock ThermostatsListRequestDeviceTypesItem = "linear_lock" + ThermostatsListRequestDeviceTypesItemLocklyLock ThermostatsListRequestDeviceTypesItem = "lockly_lock" + ThermostatsListRequestDeviceTypesItemKwiksetLock ThermostatsListRequestDeviceTypesItem = "kwikset_lock" + ThermostatsListRequestDeviceTypesItemNukiLock ThermostatsListRequestDeviceTypesItem = "nuki_lock" + ThermostatsListRequestDeviceTypesItemSaltoLock ThermostatsListRequestDeviceTypesItem = "salto_lock" + ThermostatsListRequestDeviceTypesItemSchlageLock ThermostatsListRequestDeviceTypesItem = "schlage_lock" + ThermostatsListRequestDeviceTypesItemSeamRelay ThermostatsListRequestDeviceTypesItem = "seam_relay" + ThermostatsListRequestDeviceTypesItemSmartthingsLock ThermostatsListRequestDeviceTypesItem = "smartthings_lock" + ThermostatsListRequestDeviceTypesItemWyzeLock ThermostatsListRequestDeviceTypesItem = "wyze_lock" + ThermostatsListRequestDeviceTypesItemYaleLock ThermostatsListRequestDeviceTypesItem = "yale_lock" + ThermostatsListRequestDeviceTypesItemTwoNIntercom ThermostatsListRequestDeviceTypesItem = "two_n_intercom" + ThermostatsListRequestDeviceTypesItemControlbywebDevice ThermostatsListRequestDeviceTypesItem = "controlbyweb_device" + ThermostatsListRequestDeviceTypesItemTtlockLock ThermostatsListRequestDeviceTypesItem = "ttlock_lock" + ThermostatsListRequestDeviceTypesItemIgloohomeLock ThermostatsListRequestDeviceTypesItem = "igloohome_lock" + ThermostatsListRequestDeviceTypesItemHubitatLock ThermostatsListRequestDeviceTypesItem = "hubitat_lock" + ThermostatsListRequestDeviceTypesItemFourSuitesDoor ThermostatsListRequestDeviceTypesItem = "four_suites_door" + ThermostatsListRequestDeviceTypesItemDormakabaOracodeDoor ThermostatsListRequestDeviceTypesItem = "dormakaba_oracode_door" + ThermostatsListRequestDeviceTypesItemNoiseawareActivityZone ThermostatsListRequestDeviceTypesItem = "noiseaware_activity_zone" + ThermostatsListRequestDeviceTypesItemMinutSensor ThermostatsListRequestDeviceTypesItem = "minut_sensor" + ThermostatsListRequestDeviceTypesItemEcobeeThermostat ThermostatsListRequestDeviceTypesItem = "ecobee_thermostat" + ThermostatsListRequestDeviceTypesItemNestThermostat ThermostatsListRequestDeviceTypesItem = "nest_thermostat" + ThermostatsListRequestDeviceTypesItemIosPhone ThermostatsListRequestDeviceTypesItem = "ios_phone" + ThermostatsListRequestDeviceTypesItemAndroidPhone ThermostatsListRequestDeviceTypesItem = "android_phone" +) + +func NewThermostatsListRequestDeviceTypesItemFromString(s string) (ThermostatsListRequestDeviceTypesItem, error) { + switch s { + case "akuvox_lock": + return ThermostatsListRequestDeviceTypesItemAkuvoxLock, nil + case "august_lock": + return ThermostatsListRequestDeviceTypesItemAugustLock, nil + case "brivo_access_point": + return ThermostatsListRequestDeviceTypesItemBrivoAccessPoint, nil + case "butterflymx_panel": + return ThermostatsListRequestDeviceTypesItemButterflymxPanel, nil + case "avigilon_alta_entry": + return ThermostatsListRequestDeviceTypesItemAvigilonAltaEntry, nil + case "doorking_lock": + return ThermostatsListRequestDeviceTypesItemDoorkingLock, nil + case "genie_door": + return ThermostatsListRequestDeviceTypesItemGenieDoor, nil + case "igloo_lock": + return ThermostatsListRequestDeviceTypesItemIglooLock, nil + case "linear_lock": + return ThermostatsListRequestDeviceTypesItemLinearLock, nil + case "lockly_lock": + return ThermostatsListRequestDeviceTypesItemLocklyLock, nil + case "kwikset_lock": + return ThermostatsListRequestDeviceTypesItemKwiksetLock, nil + case "nuki_lock": + return ThermostatsListRequestDeviceTypesItemNukiLock, nil + case "salto_lock": + return ThermostatsListRequestDeviceTypesItemSaltoLock, nil + case "schlage_lock": + return ThermostatsListRequestDeviceTypesItemSchlageLock, nil + case "seam_relay": + return ThermostatsListRequestDeviceTypesItemSeamRelay, nil + case "smartthings_lock": + return ThermostatsListRequestDeviceTypesItemSmartthingsLock, nil + case "wyze_lock": + return ThermostatsListRequestDeviceTypesItemWyzeLock, nil + case "yale_lock": + return ThermostatsListRequestDeviceTypesItemYaleLock, nil + case "two_n_intercom": + return ThermostatsListRequestDeviceTypesItemTwoNIntercom, nil + case "controlbyweb_device": + return ThermostatsListRequestDeviceTypesItemControlbywebDevice, nil + case "ttlock_lock": + return ThermostatsListRequestDeviceTypesItemTtlockLock, nil + case "igloohome_lock": + return ThermostatsListRequestDeviceTypesItemIgloohomeLock, nil + case "hubitat_lock": + return ThermostatsListRequestDeviceTypesItemHubitatLock, nil + case "four_suites_door": + return ThermostatsListRequestDeviceTypesItemFourSuitesDoor, nil + case "dormakaba_oracode_door": + return ThermostatsListRequestDeviceTypesItemDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return ThermostatsListRequestDeviceTypesItemNoiseawareActivityZone, nil + case "minut_sensor": + return ThermostatsListRequestDeviceTypesItemMinutSensor, nil + case "ecobee_thermostat": + return ThermostatsListRequestDeviceTypesItemEcobeeThermostat, nil + case "nest_thermostat": + return ThermostatsListRequestDeviceTypesItemNestThermostat, nil + case "ios_phone": + return ThermostatsListRequestDeviceTypesItemIosPhone, nil + case "android_phone": + return ThermostatsListRequestDeviceTypesItemAndroidPhone, nil + } + var t ThermostatsListRequestDeviceTypesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (t ThermostatsListRequestDeviceTypesItem) Ptr() *ThermostatsListRequestDeviceTypesItem { + return &t +} + +type ThermostatsListRequestManufacturer string + +const ( + ThermostatsListRequestManufacturerAkuvox ThermostatsListRequestManufacturer = "akuvox" + ThermostatsListRequestManufacturerAugust ThermostatsListRequestManufacturer = "august" + ThermostatsListRequestManufacturerAvigilonAlta ThermostatsListRequestManufacturer = "avigilon_alta" + ThermostatsListRequestManufacturerBrivo ThermostatsListRequestManufacturer = "brivo" + ThermostatsListRequestManufacturerButterflymx ThermostatsListRequestManufacturer = "butterflymx" + ThermostatsListRequestManufacturerDoorking ThermostatsListRequestManufacturer = "doorking" + ThermostatsListRequestManufacturerFourSuites ThermostatsListRequestManufacturer = "four_suites" + ThermostatsListRequestManufacturerGenie ThermostatsListRequestManufacturer = "genie" + ThermostatsListRequestManufacturerIgloo ThermostatsListRequestManufacturer = "igloo" + ThermostatsListRequestManufacturerKeywe ThermostatsListRequestManufacturer = "keywe" + ThermostatsListRequestManufacturerKwikset ThermostatsListRequestManufacturer = "kwikset" + ThermostatsListRequestManufacturerLinear ThermostatsListRequestManufacturer = "linear" + ThermostatsListRequestManufacturerLockly ThermostatsListRequestManufacturer = "lockly" + ThermostatsListRequestManufacturerNuki ThermostatsListRequestManufacturer = "nuki" + ThermostatsListRequestManufacturerPhilia ThermostatsListRequestManufacturer = "philia" + ThermostatsListRequestManufacturerSalto ThermostatsListRequestManufacturer = "salto" + ThermostatsListRequestManufacturerSamsung ThermostatsListRequestManufacturer = "samsung" + ThermostatsListRequestManufacturerSchlage ThermostatsListRequestManufacturer = "schlage" + ThermostatsListRequestManufacturerSeam ThermostatsListRequestManufacturer = "seam" + ThermostatsListRequestManufacturerUnknown ThermostatsListRequestManufacturer = "unknown" + ThermostatsListRequestManufacturerWyze ThermostatsListRequestManufacturer = "wyze" + ThermostatsListRequestManufacturerYale ThermostatsListRequestManufacturer = "yale" + ThermostatsListRequestManufacturerMinut ThermostatsListRequestManufacturer = "minut" + ThermostatsListRequestManufacturerTwoN ThermostatsListRequestManufacturer = "two_n" + ThermostatsListRequestManufacturerTtlock ThermostatsListRequestManufacturer = "ttlock" + ThermostatsListRequestManufacturerNest ThermostatsListRequestManufacturer = "nest" + ThermostatsListRequestManufacturerIgloohome ThermostatsListRequestManufacturer = "igloohome" + ThermostatsListRequestManufacturerEcobee ThermostatsListRequestManufacturer = "ecobee" + ThermostatsListRequestManufacturerHubitat ThermostatsListRequestManufacturer = "hubitat" + ThermostatsListRequestManufacturerControlbyweb ThermostatsListRequestManufacturer = "controlbyweb" + ThermostatsListRequestManufacturerSmartthings ThermostatsListRequestManufacturer = "smartthings" + ThermostatsListRequestManufacturerDormakabaOracode ThermostatsListRequestManufacturer = "dormakaba_oracode" +) + +func NewThermostatsListRequestManufacturerFromString(s string) (ThermostatsListRequestManufacturer, error) { + switch s { + case "akuvox": + return ThermostatsListRequestManufacturerAkuvox, nil + case "august": + return ThermostatsListRequestManufacturerAugust, nil + case "avigilon_alta": + return ThermostatsListRequestManufacturerAvigilonAlta, nil + case "brivo": + return ThermostatsListRequestManufacturerBrivo, nil + case "butterflymx": + return ThermostatsListRequestManufacturerButterflymx, nil + case "doorking": + return ThermostatsListRequestManufacturerDoorking, nil + case "four_suites": + return ThermostatsListRequestManufacturerFourSuites, nil + case "genie": + return ThermostatsListRequestManufacturerGenie, nil + case "igloo": + return ThermostatsListRequestManufacturerIgloo, nil + case "keywe": + return ThermostatsListRequestManufacturerKeywe, nil + case "kwikset": + return ThermostatsListRequestManufacturerKwikset, nil + case "linear": + return ThermostatsListRequestManufacturerLinear, nil + case "lockly": + return ThermostatsListRequestManufacturerLockly, nil + case "nuki": + return ThermostatsListRequestManufacturerNuki, nil + case "philia": + return ThermostatsListRequestManufacturerPhilia, nil + case "salto": + return ThermostatsListRequestManufacturerSalto, nil + case "samsung": + return ThermostatsListRequestManufacturerSamsung, nil + case "schlage": + return ThermostatsListRequestManufacturerSchlage, nil + case "seam": + return ThermostatsListRequestManufacturerSeam, nil + case "unknown": + return ThermostatsListRequestManufacturerUnknown, nil + case "wyze": + return ThermostatsListRequestManufacturerWyze, nil + case "yale": + return ThermostatsListRequestManufacturerYale, nil + case "minut": + return ThermostatsListRequestManufacturerMinut, nil + case "two_n": + return ThermostatsListRequestManufacturerTwoN, nil + case "ttlock": + return ThermostatsListRequestManufacturerTtlock, nil + case "nest": + return ThermostatsListRequestManufacturerNest, nil + case "igloohome": + return ThermostatsListRequestManufacturerIgloohome, nil + case "ecobee": + return ThermostatsListRequestManufacturerEcobee, nil + case "hubitat": + return ThermostatsListRequestManufacturerHubitat, nil + case "controlbyweb": + return ThermostatsListRequestManufacturerControlbyweb, nil + case "smartthings": + return ThermostatsListRequestManufacturerSmartthings, nil + case "dormakaba_oracode": + return ThermostatsListRequestManufacturerDormakabaOracode, nil + } + var t ThermostatsListRequestManufacturer + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (t ThermostatsListRequestManufacturer) Ptr() *ThermostatsListRequestManufacturer { + return &t +} + type ThermostatsListResponse struct { Thermostats []*Device `json:"thermostats,omitempty"` Ok bool `json:"ok"` @@ -151,6 +540,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 +643,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..b087bfc 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,112 +1082,29 @@ func (c *ConnectedAccountUserIdentifier) String() string { return fmt.Sprintf("%#v", c) } -type ConnectedAccountsGetRequestConnectedAccountId struct { - ConnectedAccountId string `json:"connected_account_id"` - - _rawJSON json.RawMessage -} - -func (c *ConnectedAccountsGetRequestConnectedAccountId) UnmarshalJSON(data []byte) error { - type unmarshaler ConnectedAccountsGetRequestConnectedAccountId - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ConnectedAccountsGetRequestConnectedAccountId(value) - c._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 { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type ConnectedAccountsGetRequestEmail struct { - Email string `json:"email"` - - _rawJSON json.RawMessage -} - -func (c *ConnectedAccountsGetRequestEmail) UnmarshalJSON(data []byte) error { - type unmarshaler ConnectedAccountsGetRequestEmail - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ConnectedAccountsGetRequestEmail(value) - c._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 { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -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"` - - _rawJSON json.RawMessage -} - -func (c *CurrentClimateSetting) UnmarshalJSON(data []byte) error { - type unmarshaler CurrentClimateSetting - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = CurrentClimateSetting(value) - c._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 { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - type Device struct { - DeviceId string `json:"device_id"` - DeviceType DeviceType `json:"device_type,omitempty"` + // Unique identifier for the device. + DeviceId string `json:"device_id"` + // Type of the device. + DeviceType DeviceDeviceType `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 *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. + 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 } @@ -1294,6 +1140,7 @@ const ( DeviceCapabilitiesSupportedItemNoiseDetection DeviceCapabilitiesSupportedItem = "noise_detection" DeviceCapabilitiesSupportedItemThermostat DeviceCapabilitiesSupportedItem = "thermostat" DeviceCapabilitiesSupportedItemBattery DeviceCapabilitiesSupportedItem = "battery" + DeviceCapabilitiesSupportedItemPhone DeviceCapabilitiesSupportedItem = "phone" ) func NewDeviceCapabilitiesSupportedItemFromString(s string) (DeviceCapabilitiesSupportedItem, error) { @@ -1308,6 +1155,8 @@ func NewDeviceCapabilitiesSupportedItemFromString(s string) (DeviceCapabilitiesS 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) @@ -1317,8 +1166,118 @@ func (d DeviceCapabilitiesSupportedItem) Ptr() *DeviceCapabilitiesSupportedItem return &d } -type DeviceErrorsItem struct { - ErrorCode string `json:"error_code"` +// Type of the device. +type DeviceDeviceType string + +const ( + DeviceDeviceTypeAkuvoxLock DeviceDeviceType = "akuvox_lock" + DeviceDeviceTypeAugustLock DeviceDeviceType = "august_lock" + DeviceDeviceTypeBrivoAccessPoint DeviceDeviceType = "brivo_access_point" + DeviceDeviceTypeButterflymxPanel DeviceDeviceType = "butterflymx_panel" + DeviceDeviceTypeAvigilonAltaEntry DeviceDeviceType = "avigilon_alta_entry" + DeviceDeviceTypeDoorkingLock DeviceDeviceType = "doorking_lock" + DeviceDeviceTypeGenieDoor DeviceDeviceType = "genie_door" + DeviceDeviceTypeIglooLock DeviceDeviceType = "igloo_lock" + DeviceDeviceTypeLinearLock DeviceDeviceType = "linear_lock" + DeviceDeviceTypeLocklyLock DeviceDeviceType = "lockly_lock" + DeviceDeviceTypeKwiksetLock DeviceDeviceType = "kwikset_lock" + DeviceDeviceTypeNukiLock DeviceDeviceType = "nuki_lock" + DeviceDeviceTypeSaltoLock DeviceDeviceType = "salto_lock" + DeviceDeviceTypeSchlageLock DeviceDeviceType = "schlage_lock" + DeviceDeviceTypeSeamRelay DeviceDeviceType = "seam_relay" + DeviceDeviceTypeSmartthingsLock DeviceDeviceType = "smartthings_lock" + DeviceDeviceTypeWyzeLock DeviceDeviceType = "wyze_lock" + DeviceDeviceTypeYaleLock DeviceDeviceType = "yale_lock" + DeviceDeviceTypeTwoNIntercom DeviceDeviceType = "two_n_intercom" + DeviceDeviceTypeControlbywebDevice DeviceDeviceType = "controlbyweb_device" + DeviceDeviceTypeTtlockLock DeviceDeviceType = "ttlock_lock" + DeviceDeviceTypeIgloohomeLock DeviceDeviceType = "igloohome_lock" + DeviceDeviceTypeHubitatLock DeviceDeviceType = "hubitat_lock" + DeviceDeviceTypeFourSuitesDoor DeviceDeviceType = "four_suites_door" + DeviceDeviceTypeDormakabaOracodeDoor DeviceDeviceType = "dormakaba_oracode_door" + DeviceDeviceTypeNoiseawareActivityZone DeviceDeviceType = "noiseaware_activity_zone" + DeviceDeviceTypeMinutSensor DeviceDeviceType = "minut_sensor" + DeviceDeviceTypeEcobeeThermostat DeviceDeviceType = "ecobee_thermostat" + DeviceDeviceTypeNestThermostat DeviceDeviceType = "nest_thermostat" + DeviceDeviceTypeIosPhone DeviceDeviceType = "ios_phone" + DeviceDeviceTypeAndroidPhone DeviceDeviceType = "android_phone" +) + +func NewDeviceDeviceTypeFromString(s string) (DeviceDeviceType, error) { + switch s { + case "akuvox_lock": + return DeviceDeviceTypeAkuvoxLock, nil + case "august_lock": + return DeviceDeviceTypeAugustLock, nil + case "brivo_access_point": + return DeviceDeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return DeviceDeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return DeviceDeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return DeviceDeviceTypeDoorkingLock, nil + case "genie_door": + return DeviceDeviceTypeGenieDoor, nil + case "igloo_lock": + return DeviceDeviceTypeIglooLock, nil + case "linear_lock": + return DeviceDeviceTypeLinearLock, nil + case "lockly_lock": + return DeviceDeviceTypeLocklyLock, nil + case "kwikset_lock": + return DeviceDeviceTypeKwiksetLock, nil + case "nuki_lock": + return DeviceDeviceTypeNukiLock, nil + case "salto_lock": + return DeviceDeviceTypeSaltoLock, nil + case "schlage_lock": + return DeviceDeviceTypeSchlageLock, nil + case "seam_relay": + return DeviceDeviceTypeSeamRelay, nil + case "smartthings_lock": + return DeviceDeviceTypeSmartthingsLock, nil + case "wyze_lock": + return DeviceDeviceTypeWyzeLock, nil + case "yale_lock": + return DeviceDeviceTypeYaleLock, nil + case "two_n_intercom": + return DeviceDeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return DeviceDeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return DeviceDeviceTypeTtlockLock, nil + case "igloohome_lock": + return DeviceDeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return DeviceDeviceTypeHubitatLock, nil + case "four_suites_door": + return DeviceDeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return DeviceDeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return DeviceDeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return DeviceDeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return DeviceDeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return DeviceDeviceTypeNestThermostat, nil + case "ios_phone": + return DeviceDeviceTypeIosPhone, nil + case "android_phone": + return DeviceDeviceTypeAndroidPhone, nil + } + var t DeviceDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DeviceDeviceType) Ptr() *DeviceDeviceType { + return &d +} + +type DeviceErrorsItem struct { + ErrorCode string `json:"error_code"` Message string `json:"message"` _rawJSON json.RawMessage @@ -1347,30 +1306,28 @@ 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"` +// 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 (d *DeviceProperties) UnmarshalJSON(data []byte) error { - type unmarshaler DeviceProperties +func (d *DeviceLocation) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceLocation var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DeviceProperties(value) + *d = DeviceLocation(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DeviceProperties) String() string { +func (d *DeviceLocation) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1382,24 +1339,25 @@ func (d *DeviceProperties) String() string { return fmt.Sprintf("%#v", d) } -type DevicePropertiesModel struct { - DisplayName string `json:"display_name"` +// Properties of the device. +type DeviceProperties struct { + AssaAbloyCredentialServiceMetadata *DevicePropertiesAssaAbloyCredentialServiceMetadata `json:"assa_abloy_credential_service_metadata,omitempty"` _rawJSON json.RawMessage } -func (d *DevicePropertiesModel) UnmarshalJSON(data []byte) error { - type unmarshaler DevicePropertiesModel +func (d *DeviceProperties) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceProperties var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DevicePropertiesModel(value) + *d = DeviceProperties(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DevicePropertiesModel) String() string { +func (d *DeviceProperties) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1411,116 +1369,55 @@ func (d *DevicePropertiesModel) String() string { return fmt.Sprintf("%#v", d) } -type DeviceType string +type DevicePropertiesAssaAbloyCredentialServiceMetadata struct { + HasActiveEndpoint bool `json:"has_active_endpoint"` + Endpoints []*DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem `json:"endpoints,omitempty"` -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" -) + _rawJSON json.RawMessage +} -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 +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesAssaAbloyCredentialServiceMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err } - var t DeviceType - return "", fmt.Errorf("%s is not a valid %T", s, t) + *d = DevicePropertiesAssaAbloyCredentialServiceMetadata(value) + d._rawJSON = json.RawMessage(data) + return nil } -func (d DeviceType) Ptr() *DeviceType { - return &d +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadata) 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 DeviceWarningsItem struct { - WarningCode string `json:"warning_code"` - Message string `json:"message"` +type DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem struct { + EndpointId string `json:"endpoint_id"` + IsActive bool `json:"is_active"` _rawJSON json.RawMessage } -func (d *DeviceWarningsItem) UnmarshalJSON(data []byte) error { - type unmarshaler DeviceWarningsItem +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) UnmarshalJSON(data []byte) error { + type unmarshaler DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DeviceWarningsItem(value) + *d = DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DeviceWarningsItem) String() string { +func (d *DevicePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1532,27 +1429,27 @@ 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"` +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 *DevicesListDeviceProvidersResponseDeviceProvidersItem) UnmarshalJSON(data []byte) error { - type unmarshaler DevicesListDeviceProvidersResponseDeviceProvidersItem +func (d *DeviceProvider) UnmarshalJSON(data []byte) error { + type unmarshaler DeviceProvider var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *d = DevicesListDeviceProvidersResponseDeviceProvidersItem(value) + *d = DeviceProvider(value) d._rawJSON = json.RawMessage(data) return nil } -func (d *DevicesListDeviceProvidersResponseDeviceProvidersItem) String() string { +func (d *DeviceProvider) String() string { if len(d._rawJSON) > 0 { if value, err := core.StringifyJSON(d._rawJSON); err == nil { return value @@ -1564,28 +1461,91 @@ func (d *DevicesListDeviceProvidersResponseDeviceProvidersItem) String() string return fmt.Sprintf("%#v", d) } -type DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem string +type DeviceProviderProviderCategoriesItem string const ( - DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = "stable" - DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = "consumer_smartlocks" + DeviceProviderProviderCategoriesItemStable DeviceProviderProviderCategoriesItem = "stable" + DeviceProviderProviderCategoriesItemConsumerSmartlocks DeviceProviderProviderCategoriesItem = "consumer_smartlocks" ) -func NewDevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemFromString(s string) (DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem, error) { +func NewDeviceProviderProviderCategoriesItemFromString(s string) (DeviceProviderProviderCategoriesItem, error) { switch s { case "stable": - return DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable, nil + return DeviceProviderProviderCategoriesItemStable, nil case "consumer_smartlocks": - return DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks, nil + return DeviceProviderProviderCategoriesItemConsumerSmartlocks, nil } - var t DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem + var t DeviceProviderProviderCategoriesItem return "", fmt.Errorf("%s is not a valid %T", s, t) } -func (d DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem) Ptr() *DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem { +func (d DeviceProviderProviderCategoriesItem) Ptr() *DeviceProviderProviderCategoriesItem { 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"` @@ -1620,128 +1580,6 @@ func (e *Event) String() string { return fmt.Sprintf("%#v", e) } -type HvacModeSetting string - -const ( - HvacModeSettingOff HvacModeSetting = "off" - HvacModeSettingHeat HvacModeSetting = "heat" - HvacModeSettingCool HvacModeSetting = "cool" - HvacModeSettingHeatCool HvacModeSetting = "heat_cool" -) - -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 - } - var t HvacModeSetting - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (h HvacModeSetting) Ptr() *HvacModeSetting { - return &h -} - -type Manufacturer string - -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 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": - return ManufacturerSeam, nil - case "unknown": - return ManufacturerUnknown, nil - case "yale": - return ManufacturerYale, nil - case "minut": - return ManufacturerMinut, nil - case "two_n": - return ManufacturerTwoN, nil - case "ttlock": - return ManufacturerTtlock, nil - case "nest": - return ManufacturerNest, nil - case "igloohome": - return ManufacturerIgloohome, nil - case "ecobee": - return ManufacturerEcobee, nil - case "hubitat": - return ManufacturerHubitat, 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"` @@ -1777,254 +1615,358 @@ func (n *NoiseThreshold) String() string { return fmt.Sprintf("%#v", n) } -type NoiseThresholdsCreateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` +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 (n *NoiseThresholdsCreateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsCreateResponse +func (p *Phone) UnmarshalJSON(data []byte) error { + type unmarshaler Phone var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsCreateResponse(value) - n._rawJSON = json.RawMessage(data) + *p = Phone(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 *Phone) 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 PhoneAssaAbloyCredentialServiceMetadata struct { + HasActiveEndpoint bool `json:"has_active_endpoint"` + Endpoints []*PhoneAssaAbloyCredentialServiceMetadataEndpointsItem `json:"endpoints,omitempty"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsDeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsDeleteResponse +func (p *PhoneAssaAbloyCredentialServiceMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneAssaAbloyCredentialServiceMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsDeleteResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhoneAssaAbloyCredentialServiceMetadata(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 *PhoneAssaAbloyCredentialServiceMetadata) 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 PhoneAssaAbloyCredentialServiceMetadataEndpointsItem struct { + EndpointId string `json:"endpoint_id"` + IsActive bool `json:"is_active"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsGetResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsGetResponse +func (p *PhoneAssaAbloyCredentialServiceMetadataEndpointsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneAssaAbloyCredentialServiceMetadataEndpointsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsGetResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhoneAssaAbloyCredentialServiceMetadataEndpointsItem(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 *PhoneAssaAbloyCredentialServiceMetadataEndpointsItem) 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 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 NoiseThresholdsListResponse struct { - NoiseThresholds []*NoiseThreshold `json:"noise_thresholds,omitempty"` - Ok bool `json:"ok"` +type PhoneErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` _rawJSON json.RawMessage } -func (n *NoiseThresholdsListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsListResponse +func (p *PhoneErrorsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneErrorsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsListResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhoneErrorsItem(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 *PhoneErrorsItem) 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"` +// 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 (n *NoiseThresholdsUpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler NoiseThresholdsUpdateResponse +func (p *PhoneLocation) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneLocation var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NoiseThresholdsUpdateResponse(value) - n._rawJSON = json.RawMessage(data) + *p = PhoneLocation(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 *PhoneLocation) 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"` +// Properties of the device. +type PhoneProperties struct { + AssaAbloyCredentialServiceMetadata *PhonePropertiesAssaAbloyCredentialServiceMetadata `json:"assa_abloy_credential_service_metadata,omitempty"` _rawJSON json.RawMessage } -func (n *NukiDeviceMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler NukiDeviceMetadata +func (p *PhoneProperties) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneProperties var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *n = NukiDeviceMetadata(value) - n._rawJSON = json.RawMessage(data) + *p = PhoneProperties(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 *PhoneProperties) 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 PhonePropertiesAssaAbloyCredentialServiceMetadata struct { + HasActiveEndpoint bool `json:"has_active_endpoint"` + Endpoints []*PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem `json:"endpoints,omitempty"` _rawJSON json.RawMessage } -func (s *SchlageDeviceMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler SchlageDeviceMetadata +func (p *PhonePropertiesAssaAbloyCredentialServiceMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesAssaAbloyCredentialServiceMetadata var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SchlageDeviceMetadata(value) - s._rawJSON = json.RawMessage(data) + *p = PhonePropertiesAssaAbloyCredentialServiceMetadata(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 *PhonePropertiesAssaAbloyCredentialServiceMetadata) 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 PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem struct { + EndpointId string `json:"endpoint_id"` + IsActive bool `json:"is_active"` _rawJSON json.RawMessage } -func (s *ServiceByServiceNameResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ServiceByServiceNameResponse +func (p *PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = ServiceByServiceNameResponse(value) - s._rawJSON = json.RawMessage(data) + *p = PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem(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 *PhonePropertiesAssaAbloyCredentialServiceMetadataEndpointsItem) 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 ServiceHealth struct { - Service string `json:"service"` - Status ServiceHealthStatus `json:"status,omitempty"` - Description string `json:"description"` - +type PhoneWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` + + _rawJSON json.RawMessage +} + +func (p *PhoneWarningsItem) UnmarshalJSON(data []byte) error { + type unmarshaler PhoneWarningsItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PhoneWarningsItem(value) + p._rawJSON = json.RawMessage(data) + return 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(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type ServiceHealth struct { + Service string `json:"service"` + Status ServiceHealthStatus `json:"status,omitempty"` + Description string `json:"description"` + _rawJSON json.RawMessage } @@ -2076,412 +2018,381 @@ 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 UnmanagedDeviceDeviceType `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"` _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 + return fmt.Sprintf("%#v", u) } -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromString(value string) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "string", String: value} -} +type UnmanagedDeviceCapabilitiesSupportedItem string -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromDateTime(value time.Time) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "dateTime", DateTime: value} -} +const ( + UnmanagedDeviceCapabilitiesSupportedItemAccessCode UnmanagedDeviceCapabilitiesSupportedItem = "access_code" + UnmanagedDeviceCapabilitiesSupportedItemLock UnmanagedDeviceCapabilitiesSupportedItem = "lock" + UnmanagedDeviceCapabilitiesSupportedItemNoiseDetection UnmanagedDeviceCapabilitiesSupportedItem = "noise_detection" + UnmanagedDeviceCapabilitiesSupportedItemThermostat UnmanagedDeviceCapabilitiesSupportedItem = "thermostat" + UnmanagedDeviceCapabilitiesSupportedItemBattery UnmanagedDeviceCapabilitiesSupportedItem = "battery" + UnmanagedDeviceCapabilitiesSupportedItemPhone UnmanagedDeviceCapabilitiesSupportedItem = "phone" +) -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 +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 } - return fmt.Errorf("%s cannot be deserialized as a %T", data, s) + var t UnmanagedDeviceCapabilitiesSupportedItem + return "", fmt.Errorf("%s is not a valid %T", s, t) } -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 (u UnmanagedDeviceCapabilitiesSupportedItem) Ptr() *UnmanagedDeviceCapabilitiesSupportedItem { + return &u } -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor interface { - VisitString(string) error - VisitDateTime(time.Time) error -} +// Type of the device. +type UnmanagedDeviceDeviceType string -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) +const ( + UnmanagedDeviceDeviceTypeAkuvoxLock UnmanagedDeviceDeviceType = "akuvox_lock" + UnmanagedDeviceDeviceTypeAugustLock UnmanagedDeviceDeviceType = "august_lock" + UnmanagedDeviceDeviceTypeBrivoAccessPoint UnmanagedDeviceDeviceType = "brivo_access_point" + UnmanagedDeviceDeviceTypeButterflymxPanel UnmanagedDeviceDeviceType = "butterflymx_panel" + UnmanagedDeviceDeviceTypeAvigilonAltaEntry UnmanagedDeviceDeviceType = "avigilon_alta_entry" + UnmanagedDeviceDeviceTypeDoorkingLock UnmanagedDeviceDeviceType = "doorking_lock" + UnmanagedDeviceDeviceTypeGenieDoor UnmanagedDeviceDeviceType = "genie_door" + UnmanagedDeviceDeviceTypeIglooLock UnmanagedDeviceDeviceType = "igloo_lock" + UnmanagedDeviceDeviceTypeLinearLock UnmanagedDeviceDeviceType = "linear_lock" + UnmanagedDeviceDeviceTypeLocklyLock UnmanagedDeviceDeviceType = "lockly_lock" + UnmanagedDeviceDeviceTypeKwiksetLock UnmanagedDeviceDeviceType = "kwikset_lock" + UnmanagedDeviceDeviceTypeNukiLock UnmanagedDeviceDeviceType = "nuki_lock" + UnmanagedDeviceDeviceTypeSaltoLock UnmanagedDeviceDeviceType = "salto_lock" + UnmanagedDeviceDeviceTypeSchlageLock UnmanagedDeviceDeviceType = "schlage_lock" + UnmanagedDeviceDeviceTypeSeamRelay UnmanagedDeviceDeviceType = "seam_relay" + UnmanagedDeviceDeviceTypeSmartthingsLock UnmanagedDeviceDeviceType = "smartthings_lock" + UnmanagedDeviceDeviceTypeWyzeLock UnmanagedDeviceDeviceType = "wyze_lock" + UnmanagedDeviceDeviceTypeYaleLock UnmanagedDeviceDeviceType = "yale_lock" + UnmanagedDeviceDeviceTypeTwoNIntercom UnmanagedDeviceDeviceType = "two_n_intercom" + UnmanagedDeviceDeviceTypeControlbywebDevice UnmanagedDeviceDeviceType = "controlbyweb_device" + UnmanagedDeviceDeviceTypeTtlockLock UnmanagedDeviceDeviceType = "ttlock_lock" + UnmanagedDeviceDeviceTypeIgloohomeLock UnmanagedDeviceDeviceType = "igloohome_lock" + UnmanagedDeviceDeviceTypeHubitatLock UnmanagedDeviceDeviceType = "hubitat_lock" + UnmanagedDeviceDeviceTypeFourSuitesDoor UnmanagedDeviceDeviceType = "four_suites_door" + UnmanagedDeviceDeviceTypeDormakabaOracodeDoor UnmanagedDeviceDeviceType = "dormakaba_oracode_door" + UnmanagedDeviceDeviceTypeNoiseawareActivityZone UnmanagedDeviceDeviceType = "noiseaware_activity_zone" + UnmanagedDeviceDeviceTypeMinutSensor UnmanagedDeviceDeviceType = "minut_sensor" + UnmanagedDeviceDeviceTypeEcobeeThermostat UnmanagedDeviceDeviceType = "ecobee_thermostat" + UnmanagedDeviceDeviceTypeNestThermostat UnmanagedDeviceDeviceType = "nest_thermostat" + UnmanagedDeviceDeviceTypeIosPhone UnmanagedDeviceDeviceType = "ios_phone" + UnmanagedDeviceDeviceTypeAndroidPhone UnmanagedDeviceDeviceType = "android_phone" +) + +func NewUnmanagedDeviceDeviceTypeFromString(s string) (UnmanagedDeviceDeviceType, error) { + switch s { + case "akuvox_lock": + return UnmanagedDeviceDeviceTypeAkuvoxLock, nil + case "august_lock": + return UnmanagedDeviceDeviceTypeAugustLock, nil + case "brivo_access_point": + return UnmanagedDeviceDeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return UnmanagedDeviceDeviceTypeButterflymxPanel, nil + case "avigilon_alta_entry": + return UnmanagedDeviceDeviceTypeAvigilonAltaEntry, nil + case "doorking_lock": + return UnmanagedDeviceDeviceTypeDoorkingLock, nil + case "genie_door": + return UnmanagedDeviceDeviceTypeGenieDoor, nil + case "igloo_lock": + return UnmanagedDeviceDeviceTypeIglooLock, nil + case "linear_lock": + return UnmanagedDeviceDeviceTypeLinearLock, nil + case "lockly_lock": + return UnmanagedDeviceDeviceTypeLocklyLock, nil + case "kwikset_lock": + return UnmanagedDeviceDeviceTypeKwiksetLock, nil + case "nuki_lock": + return UnmanagedDeviceDeviceTypeNukiLock, nil + case "salto_lock": + return UnmanagedDeviceDeviceTypeSaltoLock, nil + case "schlage_lock": + return UnmanagedDeviceDeviceTypeSchlageLock, nil + case "seam_relay": + return UnmanagedDeviceDeviceTypeSeamRelay, nil + case "smartthings_lock": + return UnmanagedDeviceDeviceTypeSmartthingsLock, nil + case "wyze_lock": + return UnmanagedDeviceDeviceTypeWyzeLock, nil + case "yale_lock": + return UnmanagedDeviceDeviceTypeYaleLock, nil + case "two_n_intercom": + return UnmanagedDeviceDeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return UnmanagedDeviceDeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return UnmanagedDeviceDeviceTypeTtlockLock, nil + case "igloohome_lock": + return UnmanagedDeviceDeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return UnmanagedDeviceDeviceTypeHubitatLock, nil + case "four_suites_door": + return UnmanagedDeviceDeviceTypeFourSuitesDoor, nil + case "dormakaba_oracode_door": + return UnmanagedDeviceDeviceTypeDormakabaOracodeDoor, nil + case "noiseaware_activity_zone": + return UnmanagedDeviceDeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return UnmanagedDeviceDeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return UnmanagedDeviceDeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return UnmanagedDeviceDeviceTypeNestThermostat, nil + case "ios_phone": + return UnmanagedDeviceDeviceTypeIosPhone, nil + case "android_phone": + return UnmanagedDeviceDeviceTypeAndroidPhone, nil } + var t UnmanagedDeviceDeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) } -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 - - _rawJSON json.RawMessage +func (u UnmanagedDeviceDeviceType) Ptr() *UnmanagedDeviceDeviceType { + return &u } -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) Status() string { - return s.status +type UnmanagedDeviceErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` + + _rawJSON json.RawMessage } -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound +func (u *UnmanagedDeviceErrorsItem) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceErrorsItem 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 = UnmanagedDeviceErrorsItem(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 *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 { + 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 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 (s *SimulateTriggerNoiseThresholdResponse) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateTriggerNoiseThresholdResponse +func (u *UnmanagedDeviceProperties) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceProperties var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SimulateTriggerNoiseThresholdResponse(value) - s._rawJSON = json.RawMessage(data) + *u = UnmanagedDeviceProperties(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 *UnmanagedDeviceProperties) 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 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 + return fmt.Sprintf("%#v", u) } -type UnmanagedConvertToManagedResponse struct { - 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 *UnmanagedConvertToManagedResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedConvertToManagedResponse +func (u *UnmanagedDevicePropertiesBattery) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDevicePropertiesBattery var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedConvertToManagedResponse(value) + *u = UnmanagedDevicePropertiesBattery(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedConvertToManagedResponse) String() string { +func (u *UnmanagedDevicePropertiesBattery) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2493,25 +2404,61 @@ func (u *UnmanagedConvertToManagedResponse) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedDeleteResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` +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 *UnmanagedDeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeleteResponse +func (u *UnmanagedDevicePropertiesModel) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDevicePropertiesModel var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeleteResponse(value) + *u = UnmanagedDevicePropertiesModel(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDeleteResponse) String() string { +func (u *UnmanagedDevicePropertiesModel) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2523,33 +2470,25 @@ 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 UnmanagedDeviceWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` _rawJSON json.RawMessage } -func (u *UnmanagedDevice) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDevice +func (u *UnmanagedDeviceWarningsItem) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedDeviceWarningsItem var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDevice(value) + *u = UnmanagedDeviceWarningsItem(value) u._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDevice) String() string { +func (u *UnmanagedDeviceWarningsItem) String() string { if len(u._rawJSON) > 0 { if value, err := core.StringifyJSON(u._rawJSON); err == nil { return value @@ -2561,257 +2500,245 @@ func (u *UnmanagedDevice) String() string { return fmt.Sprintf("%#v", u) } -type UnmanagedDeviceErrorsItem struct { - ErrorCode string `json:"error_code"` - Message string `json:"message"` +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 *UnmanagedDeviceErrorsItem) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeviceErrorsItem +func (w *Webhook) UnmarshalJSON(data []byte) error { + type unmarshaler Webhook var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeviceErrorsItem(value) - u._rawJSON = json.RawMessage(data) + *w = Webhook(value) + w._rawJSON = json.RawMessage(data) return nil } -func (u *UnmanagedDeviceErrorsItem) 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 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 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 *UnmanagedDeviceProperties) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeviceProperties +func (w *Workspace) UnmarshalJSON(data []byte) error { + type unmarshaler Workspace var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeviceProperties(value) - u._rawJSON = json.RawMessage(data) + *w = Workspace(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 *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 UnmanagedDevicePropertiesModel struct { - DisplayName string `json:"display_name"` +type ConnectedAccountsGetRequestConnectedAccountId struct { + ConnectedAccountId string `json:"connected_account_id"` _rawJSON json.RawMessage } -func (u *UnmanagedDevicePropertiesModel) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDevicePropertiesModel +func (c *ConnectedAccountsGetRequestConnectedAccountId) UnmarshalJSON(data []byte) error { + type unmarshaler ConnectedAccountsGetRequestConnectedAccountId var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDevicePropertiesModel(value) - u._rawJSON = json.RawMessage(data) + *c = ConnectedAccountsGetRequestConnectedAccountId(value) + c._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 (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 UnmanagedDeviceWarningsItem struct { - WarningCode string `json:"warning_code"` - Message string `json:"message"` +type ConnectedAccountsGetRequestEmail struct { + Email string `json:"email"` _rawJSON json.RawMessage } -func (u *UnmanagedDeviceWarningsItem) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedDeviceWarningsItem +func (c *ConnectedAccountsGetRequestEmail) UnmarshalJSON(data []byte) error { + type unmarshaler ConnectedAccountsGetRequestEmail var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedDeviceWarningsItem(value) - u._rawJSON = json.RawMessage(data) + *c = ConnectedAccountsGetRequestEmail(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 *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 UnmanagedGetResponse struct { - AccessCode *UnmanagedGetResponseAccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` +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 *UnmanagedGetResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedGetResponse +func (n *NetworksGetResponseNetwork) UnmarshalJSON(data []byte) error { + type unmarshaler NetworksGetResponseNetwork var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *u = UnmanagedGetResponse(value) - u._rawJSON = json.RawMessage(data) + *n = NetworksGetResponseNetwork(value) + n._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 (n *NetworksGetResponseNetwork) 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 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 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 (u *UnmanagedGetResponseAccessCode) Status() string { - return u.status -} - -func (u *UnmanagedGetResponseAccessCode) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedGetResponseAccessCode +func (n *NetworksListResponseNetworksItem) UnmarshalJSON(data []byte) error { + type unmarshaler NetworksListResponseNetworksItem 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 = NetworksListResponseNetworksItem(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", - } - return json.Marshal(marshaler) -} - -func (u *UnmanagedGetResponseAccessCode) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == 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 +2750,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 +2779,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 +2808,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 } From 5bdcccdf5c73fa5253470e97296c52b5f0b7963f Mon Sep 17 00:00:00 2001 From: dsinghvi Date: Fri, 12 Jan 2024 14:22:50 -0500 Subject: [PATCH 2/2] fix compile --- webhooks/get_by_id.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webhooks/get_by_id.go b/webhooks/get_by_id.go index 14484da..b911bb8 100644 --- a/webhooks/get_by_id.go +++ b/webhooks/get_by_id.go @@ -6,7 +6,7 @@ import ( seamapigo "github.com/seamapi/go" ) -func (c *Client) GetById(ctx context.Context, webhookId string) (*seamapigo.WebhooksGetResponse, error) { +func (c *Client) GetById(ctx context.Context, webhookId string) (*seamapigo.Webhook, error) { return c.Get( ctx, &seamapigo.WebhooksGetRequest{