From 652fa3039516004c5fb7359fac76b1b9c55915f3 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 20:13:39 +0000 Subject: [PATCH] Release v0.2.0 --- .github/workflows/ci.yml | 11 + LICENSE | 21 - README.md | 47 + access_code.go | 28 - access_code_status.go | 65 - access_code_type.go | 47 - access_codes.go | 147 ++ access_codes_create_multiple_request.go | 16 - ...est_behavior_when_code_cannot_be_shared.go | 47 - access_codes_create_multiple_response.go | 8 - access_codes_create_request.go | 17 - access_codes_create_response.go | 9 - access_codes_delete_request.go | 10 - access_codes_delete_response.go | 8 - access_codes_get_request.go | 10 - access_codes_get_response.go | 8 - access_codes_list_request.go | 9 - access_codes_list_response.go | 8 - ...s_codes_pull_backup_access_code_request.go | 8 - ..._codes_pull_backup_access_code_response.go | 8 - access_codes_update_request.go | 18 - access_codes_update_request_type.go | 47 - access_codes_update_response.go | 8 - .../client/client.go | 220 ++- ...ged_access_code_request.go => simulate.go} | 1 - .../client.go} | 39 +- accesscodes/unmanaged.go | 30 + .../client.go} | 123 +- .../unmanaged_convert_to_managed_request.go | 10 - accesscodes/unmanaged_delete_request.go | 9 - accesscodes/unmanaged_get_request.go | 10 - accesscodes/unmanaged_list_request.go | 8 - accesscodes/unmanaged_update_request.go | 10 - action_attempt.go | 111 -- action_attempt_error.go | 10 - action_attempt_error_error.go | 8 - action_attempt_pending.go | 10 - action_attempt_success.go | 10 - action_attempts.go | 21 + action_attempts_get_request.go | 8 - action_attempts_get_response.go | 8 - action_attempts_list_request.go | 8 - action_attempts_list_response.go | 8 - .../client.go | 68 +- august_device_metadata.go | 13 - bad_request_error.go | 27 - client.go | 121 -- client/client.go | 66 + client/client_test.go | 47 + client/options.go | 39 + client_options.go | 41 - client_session.go | 18 - client_sessions.go | 43 + client_sessions_create_request.go | 10 - client_sessions_create_response.go | 8 - client_sessions_delete_request.go | 8 - client_sessions_delete_response.go | 7 - client_sessions_get_request.go | 9 - client_sessions_get_response.go | 8 - client_sessions_list_request.go | 10 - client_sessions_list_response.go | 8 - .../client.go | 86 +- climate_setting_schedule.go | 53 - climate_setting_schedule_hvac_mode_setting.go | 59 - ...edules_create_request_hvac_mode_setting.go | 59 - climate_setting_schedules_create_response.go | 8 - climate_setting_schedules_delete_response.go | 7 - climate_setting_schedules_get_response.go | 8 - climate_setting_schedules_list_response.go | 8 - ...edules_update_request_hvac_mode_setting.go | 59 - climate_setting_schedules_update_response.go | 8 - connect_webview.go | 22 - connect_webview_device_selection_mode.go | 53 - connect_webview_status.go | 53 - connect_webviews.go | 285 ++++ connect_webviews_create_request.go | 13 - ..._create_request_accepted_providers_item.go | 197 --- ...ws_create_request_custom_metadata_value.go | 97 -- ...ws_create_request_device_selection_mode.go | 53 - ...bviews_create_request_provider_category.go | 53 - connect_webviews_create_response.go | 8 - connect_webviews_delete_request.go | 8 - connect_webviews_delete_response.go | 7 - connect_webviews_get_request.go | 8 - connect_webviews_get_response.go | 8 - connect_webviews_list_response.go | 8 - connect_webviews_view_request.go | 9 - connected_account.go | 17 - connected_account_custom_metadata_value.go | 97 -- connected_account_user_identifier.go | 11 - ...ts_get_request.go => connected_accounts.go | 24 +- connected_accounts_delete_request.go | 8 - connected_accounts_delete_response.go | 7 - ...counts_get_request_connected_account_id.go | 7 - connected_accounts_get_request_email.go | 7 - connected_accounts_get_response.go | 8 - connected_accounts_list_response.go | 8 - .../client.go | 69 +- .../client.go | 97 +- core/client_option.go | 16 +- core/core.go | 35 +- core/core_test.go | 217 +++ current_climate_setting.go | 14 - device.go | 21 - device_capabilities_supported_item.go | 65 - device_errors_item.go | 8 - device_properties.go | 13 - device_properties_model.go | 7 - device_type.go | 185 -- device_warnings_item.go | 8 - devices.go | 93 + devices_client.go => devices/client/client.go | 160 +- ...unmanaged_list_request.go => unmanaged.go} | 12 +- .../client.go} | 60 +- devices/unmanaged_update_request.go | 9 - devices_delete_request.go | 8 - devices_delete_response.go | 7 - devices_get_request.go | 9 - devices_get_response.go | 8 - devices_list_device_providers_request.go | 8 - ...ice_providers_request_provider_category.go | 47 - devices_list_device_providers_response.go | 8 - ...roviders_response_device_providers_item.go | 10 - ...providers_item_provider_categories_item.go | 47 - devices_list_request.go | 20 - devices_list_response.go | 8 - devices_update_request.go | 12 - devices_update_request_location.go | 6 - devices_update_request_properties.go | 7 - devices_update_response.go | 7 - environments.go | 2 +- errors.go | 54 + event.go | 16 - events.go | 320 ++++ events_client.go => events/client.go | 68 +- events_get_request.go | 10 - events_get_response.go | 9 - events_list_request.go | 16 - events_list_request_between_item.go | 66 - events_list_request_event_type.go | 227 --- events_list_request_event_types_item.go | 227 --- events_list_response.go | 9 - go.mod | 4 +- go.sum | 11 + health_get_health_response.go => health.go | 10 + health_client.go => health/client/client.go | 81 +- ..._by_service_name_request.go => service.go} | 1 - .../{service_client.go => service/client.go} | 39 +- health_get_service_health_request.go | 8 - health_get_service_health_response.go | 9 - hvac_mode_setting.go | 59 - locks.go | 56 + locks_client.go => locks/client.go | 118 +- locks_get_request.go | 9 - locks_get_response.go | 9 - locks_list_request.go | 20 - locks_list_response.go | 9 - locks_lock_door_request.go | 9 - locks_lock_door_response.go | 8 - locks_unlock_door_request.go | 9 - locks_unlock_door_response.go | 8 - manufacturer.go | 191 --- noise_threshold.go | 13 - noise_thresholds_create_response.go | 8 - noise_thresholds_delete_response.go | 8 - noise_thresholds_get_response.go | 8 - noise_thresholds_list_response.go | 8 - noise_thresholds_update_response.go | 8 - noisesensors/client.go | 43 - noisesensors/client/client.go | 33 + noisesensors/noise_thresholds.go | 38 + .../noise_thresholds_create_request.go | 14 - .../noise_thresholds_delete_request.go | 10 - noisesensors/noise_thresholds_get_request.go | 8 - noisesensors/noise_thresholds_list_request.go | 8 - .../noise_thresholds_update_request.go | 15 - .../client.go} | 133 +- ...noise_threshold_request.go => simulate.go} | 1 - .../client.go} | 39 +- nuki_device_metadata.go | 7 - schlage_device_metadata.go | 11 - service_by_service_name_response.go | 9 - service_health.go | 9 - service_health_status.go | 53 - ...e_create_unmanaged_access_code_response.go | 8 - ...anaged_access_code_response_access_code.go | 88 - ...ccess_code_response_access_code_ongoing.go | 44 - ...response_access_code_ongoing_created_at.go | 66 - ...ss_code_response_access_code_time_bound.go | 44 - ...ponse_access_code_time_bound_created_at.go | 66 - simulate_trigger_noise_threshold_response.go | 7 - supported_capabililty.go | 65 - thermostats.go | 65 + .../client/client.go | 135 +- thermostats/climate_setting_schedules.go | 52 + ...limate_setting_schedules_create_request.go | 24 - ...limate_setting_schedules_delete_request.go | 8 - .../climate_setting_schedules_get_request.go | 9 - .../climate_setting_schedules_list_request.go | 8 - ...limate_setting_schedules_update_request.go | 24 - .../client.go} | 83 +- thermostats_get_request.go | 9 - thermostats_get_response.go | 8 - thermostats_heat_request.go | 11 - thermostats_heat_response.go | 7 - thermostats_list_request.go | 20 - thermostats_list_response.go | 8 - thermostats_update_request.go | 9 - ..._update_request_default_climate_setting.go | 14 - thermostats_update_response.go | 7 - types.go | 1490 +++++++++++++++++ unauthorized_error.go | 27 - unmanaged_convert_to_managed_response.go | 7 - unmanaged_delete_response.go | 8 - unmanaged_device.go | 20 - unmanaged_device_errors_item.go | 8 - unmanaged_device_properties.go | 12 - unmanaged_device_properties_model.go | 7 - unmanaged_device_warnings_item.go | 8 - unmanaged_get_response.go | 8 - unmanaged_get_response_access_code.go | 50 - unmanaged_get_response_access_code_type.go | 47 - unmanaged_list_response.go | 8 - unmanaged_list_response_access_codes_item.go | 50 - ...ed_list_response_access_codes_item_type.go | 47 - unmanaged_update_response.go | 7 - webhook.go | 10 - webhooks.go | 35 + webhooks_client.go => webhooks/client.go | 110 +- webhooks_create_request.go | 9 - webhooks_create_response.go | 8 - webhooks_delete_request.go | 8 - webhooks_delete_response.go | 7 - webhooks_get_request.go | 8 - webhooks_get_response.go | 8 - webhooks_list_response.go | 8 - workspace.go | 10 - workspaces.go | 18 + workspaces_client.go => workspaces/client.go | 91 +- workspaces_get_response.go | 8 - workspaces_list_response.go | 8 - workspaces_reset_sandbox_response.go | 8 - 242 files changed, 4131 insertions(+), 5642 deletions(-) delete mode 100644 LICENSE create mode 100644 README.md delete mode 100644 access_code.go delete mode 100644 access_code_status.go delete mode 100644 access_code_type.go create mode 100644 access_codes.go delete mode 100644 access_codes_create_multiple_request.go delete mode 100644 access_codes_create_multiple_request_behavior_when_code_cannot_be_shared.go delete mode 100644 access_codes_create_multiple_response.go delete mode 100644 access_codes_create_request.go delete mode 100644 access_codes_create_response.go delete mode 100644 access_codes_delete_request.go delete mode 100644 access_codes_delete_response.go delete mode 100644 access_codes_get_request.go delete mode 100644 access_codes_get_response.go delete mode 100644 access_codes_list_request.go delete mode 100644 access_codes_list_response.go delete mode 100644 access_codes_pull_backup_access_code_request.go delete mode 100644 access_codes_pull_backup_access_code_response.go delete mode 100644 access_codes_update_request.go delete mode 100644 access_codes_update_request_type.go delete mode 100644 access_codes_update_response.go rename access_codes_client.go => accesscodes/client/client.go (56%) rename accesscodes/{simulate_create_unmanaged_access_code_request.go => simulate.go} (67%) rename accesscodes/{simulate_client.go => simulate/client.go} (65%) create mode 100644 accesscodes/unmanaged.go rename accesscodes/{unmanaged_client.go => unmanaged/client.go} (66%) delete mode 100644 accesscodes/unmanaged_convert_to_managed_request.go delete mode 100644 accesscodes/unmanaged_delete_request.go delete mode 100644 accesscodes/unmanaged_get_request.go delete mode 100644 accesscodes/unmanaged_list_request.go delete mode 100644 accesscodes/unmanaged_update_request.go delete mode 100644 action_attempt.go delete mode 100644 action_attempt_error.go delete mode 100644 action_attempt_error_error.go delete mode 100644 action_attempt_pending.go delete mode 100644 action_attempt_success.go create mode 100644 action_attempts.go delete mode 100644 action_attempts_get_request.go delete mode 100644 action_attempts_get_response.go delete mode 100644 action_attempts_list_request.go delete mode 100644 action_attempts_list_response.go rename action_attempts_client.go => actionattempts/client.go (62%) delete mode 100644 august_device_metadata.go delete mode 100644 bad_request_error.go delete mode 100644 client.go create mode 100644 client/client.go create mode 100644 client/client_test.go create mode 100644 client/options.go delete mode 100644 client_options.go delete mode 100644 client_session.go create mode 100644 client_sessions.go delete mode 100644 client_sessions_create_request.go delete mode 100644 client_sessions_create_response.go delete mode 100644 client_sessions_delete_request.go delete mode 100644 client_sessions_delete_response.go delete mode 100644 client_sessions_get_request.go delete mode 100644 client_sessions_get_response.go delete mode 100644 client_sessions_list_request.go delete mode 100644 client_sessions_list_response.go rename client_sessions_client.go => clientsessions/client.go (66%) delete mode 100644 climate_setting_schedule.go delete mode 100644 climate_setting_schedule_hvac_mode_setting.go delete mode 100644 climate_setting_schedules_create_request_hvac_mode_setting.go delete mode 100644 climate_setting_schedules_create_response.go delete mode 100644 climate_setting_schedules_delete_response.go delete mode 100644 climate_setting_schedules_get_response.go delete mode 100644 climate_setting_schedules_list_response.go delete mode 100644 climate_setting_schedules_update_request_hvac_mode_setting.go delete mode 100644 climate_setting_schedules_update_response.go delete mode 100644 connect_webview.go delete mode 100644 connect_webview_device_selection_mode.go delete mode 100644 connect_webview_status.go create mode 100644 connect_webviews.go delete mode 100644 connect_webviews_create_request.go delete mode 100644 connect_webviews_create_request_accepted_providers_item.go delete mode 100644 connect_webviews_create_request_custom_metadata_value.go delete mode 100644 connect_webviews_create_request_device_selection_mode.go delete mode 100644 connect_webviews_create_request_provider_category.go delete mode 100644 connect_webviews_create_response.go delete mode 100644 connect_webviews_delete_request.go delete mode 100644 connect_webviews_delete_response.go delete mode 100644 connect_webviews_get_request.go delete mode 100644 connect_webviews_get_response.go delete mode 100644 connect_webviews_list_response.go delete mode 100644 connect_webviews_view_request.go delete mode 100644 connected_account.go delete mode 100644 connected_account_custom_metadata_value.go delete mode 100644 connected_account_user_identifier.go rename connected_accounts_get_request.go => connected_accounts.go (76%) delete mode 100644 connected_accounts_delete_request.go delete mode 100644 connected_accounts_delete_response.go delete mode 100644 connected_accounts_get_request_connected_account_id.go delete mode 100644 connected_accounts_get_request_email.go delete mode 100644 connected_accounts_get_response.go delete mode 100644 connected_accounts_list_response.go rename connected_accounts_client.go => connectedaccounts/client.go (67%) rename connect_webviews_client.go => connectwebviews/client.go (70%) create mode 100644 core/core_test.go delete mode 100644 current_climate_setting.go delete mode 100644 device.go delete mode 100644 device_capabilities_supported_item.go delete mode 100644 device_errors_item.go delete mode 100644 device_properties.go delete mode 100644 device_properties_model.go delete mode 100644 device_type.go delete mode 100644 device_warnings_item.go create mode 100644 devices.go rename devices_client.go => devices/client/client.go (58%) rename devices/{unmanaged_list_request.go => unmanaged.go} (69%) rename devices/{unmanaged_client.go => unmanaged/client.go} (67%) delete mode 100644 devices/unmanaged_update_request.go delete mode 100644 devices_delete_request.go delete mode 100644 devices_delete_response.go delete mode 100644 devices_get_request.go delete mode 100644 devices_get_response.go delete mode 100644 devices_list_device_providers_request.go delete mode 100644 devices_list_device_providers_request_provider_category.go delete mode 100644 devices_list_device_providers_response.go delete mode 100644 devices_list_device_providers_response_device_providers_item.go delete mode 100644 devices_list_device_providers_response_device_providers_item_provider_categories_item.go delete mode 100644 devices_list_request.go delete mode 100644 devices_list_response.go delete mode 100644 devices_update_request.go delete mode 100644 devices_update_request_location.go delete mode 100644 devices_update_request_properties.go delete mode 100644 devices_update_response.go create mode 100644 errors.go delete mode 100644 event.go create mode 100644 events.go rename events_client.go => events/client.go (65%) delete mode 100644 events_get_request.go delete mode 100644 events_get_response.go delete mode 100644 events_list_request.go delete mode 100644 events_list_request_between_item.go delete mode 100644 events_list_request_event_type.go delete mode 100644 events_list_request_event_types_item.go delete mode 100644 events_list_response.go rename health_get_health_response.go => health.go (76%) rename health_client.go => health/client/client.go (56%) rename health/{service_by_service_name_request.go => service.go} (65%) rename health/{service_client.go => service/client.go} (69%) delete mode 100644 health_get_service_health_request.go delete mode 100644 health_get_service_health_response.go delete mode 100644 hvac_mode_setting.go create mode 100644 locks.go rename locks_client.go => locks/client.go (64%) delete mode 100644 locks_get_request.go delete mode 100644 locks_get_response.go delete mode 100644 locks_list_request.go delete mode 100644 locks_list_response.go delete mode 100644 locks_lock_door_request.go delete mode 100644 locks_lock_door_response.go delete mode 100644 locks_unlock_door_request.go delete mode 100644 locks_unlock_door_response.go delete mode 100644 manufacturer.go delete mode 100644 noise_threshold.go delete mode 100644 noise_thresholds_create_response.go delete mode 100644 noise_thresholds_delete_response.go delete mode 100644 noise_thresholds_get_response.go delete mode 100644 noise_thresholds_list_response.go delete mode 100644 noise_thresholds_update_response.go delete mode 100644 noisesensors/client.go create mode 100644 noisesensors/client/client.go create mode 100644 noisesensors/noise_thresholds.go delete mode 100644 noisesensors/noise_thresholds_create_request.go delete mode 100644 noisesensors/noise_thresholds_delete_request.go delete mode 100644 noisesensors/noise_thresholds_get_request.go delete mode 100644 noisesensors/noise_thresholds_list_request.go delete mode 100644 noisesensors/noise_thresholds_update_request.go rename noisesensors/{noise_thresholds_client.go => noisethresholds/client.go} (64%) rename noisesensors/{simulate_trigger_noise_threshold_request.go => simulate.go} (62%) rename noisesensors/{simulate_client.go => simulate/client.go} (66%) delete mode 100644 nuki_device_metadata.go delete mode 100644 schlage_device_metadata.go delete mode 100644 service_by_service_name_response.go delete mode 100644 service_health.go delete mode 100644 service_health_status.go delete mode 100644 simulate_create_unmanaged_access_code_response.go delete mode 100644 simulate_create_unmanaged_access_code_response_access_code.go delete mode 100644 simulate_create_unmanaged_access_code_response_access_code_ongoing.go delete mode 100644 simulate_create_unmanaged_access_code_response_access_code_ongoing_created_at.go delete mode 100644 simulate_create_unmanaged_access_code_response_access_code_time_bound.go delete mode 100644 simulate_create_unmanaged_access_code_response_access_code_time_bound_created_at.go delete mode 100644 simulate_trigger_noise_threshold_response.go delete mode 100644 supported_capabililty.go create mode 100644 thermostats.go rename thermostats_client.go => thermostats/client/client.go (55%) create mode 100644 thermostats/climate_setting_schedules.go delete mode 100644 thermostats/climate_setting_schedules_create_request.go delete mode 100644 thermostats/climate_setting_schedules_delete_request.go delete mode 100644 thermostats/climate_setting_schedules_get_request.go delete mode 100644 thermostats/climate_setting_schedules_list_request.go delete mode 100644 thermostats/climate_setting_schedules_update_request.go rename thermostats/{climate_setting_schedules_client.go => climatesettingschedules/client.go} (68%) delete mode 100644 thermostats_get_request.go delete mode 100644 thermostats_get_response.go delete mode 100644 thermostats_heat_request.go delete mode 100644 thermostats_heat_response.go delete mode 100644 thermostats_list_request.go delete mode 100644 thermostats_list_response.go delete mode 100644 thermostats_update_request.go delete mode 100644 thermostats_update_request_default_climate_setting.go delete mode 100644 thermostats_update_response.go create mode 100644 types.go delete mode 100644 unauthorized_error.go delete mode 100644 unmanaged_convert_to_managed_response.go delete mode 100644 unmanaged_delete_response.go delete mode 100644 unmanaged_device.go delete mode 100644 unmanaged_device_errors_item.go delete mode 100644 unmanaged_device_properties.go delete mode 100644 unmanaged_device_properties_model.go delete mode 100644 unmanaged_device_warnings_item.go delete mode 100644 unmanaged_get_response.go delete mode 100644 unmanaged_get_response_access_code.go delete mode 100644 unmanaged_get_response_access_code_type.go delete mode 100644 unmanaged_list_response.go delete mode 100644 unmanaged_list_response_access_codes_item.go delete mode 100644 unmanaged_list_response_access_codes_item_type.go delete mode 100644 unmanaged_update_response.go delete mode 100644 webhook.go create mode 100644 webhooks.go rename webhooks_client.go => webhooks/client.go (66%) delete mode 100644 webhooks_create_request.go delete mode 100644 webhooks_create_response.go delete mode 100644 webhooks_delete_request.go delete mode 100644 webhooks_delete_response.go delete mode 100644 webhooks_get_request.go delete mode 100644 webhooks_get_response.go delete mode 100644 webhooks_list_response.go delete mode 100644 workspace.go create mode 100644 workspaces.go rename workspaces_client.go => workspaces/client.go (67%) delete mode 100644 workspaces_get_response.go delete mode 100644 workspaces_list_response.go delete mode 100644 workspaces_reset_sandbox_response.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa105d4..d4c0a5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,3 +14,14 @@ jobs: - name: Compile run: go build ./... + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Test + run: go test ./... diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a09c223..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Fern - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f28dd7f --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ + +# Seam Go Library + +[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern) + +The Seam Go library provides convenient access to the Seam API from Go. + + + +# Installation + +Run the following command to use the Seam Go library in your module: +```sh +go get github.com/seamapi/go +``` + + + +# Usage + +```go +import goclient "github.com/seamapi/go/client" + +client := goclient.NewClient(goclient.WithAuthApiKey("")) +``` + + + +# Beta Status + +This SDK is in beta, and there may be breaking changes between versions without a major +version update. Therefore, we recommend pinning the package version to a specific version. +This way, you can install the same version each time without breaking changes. + + + +# Contributing + +While we value open-source contributions to this SDK, this library is generated programmatically. +Additions made directly to this library would have to be moved over to our generation code, +otherwise they would be overwritten upon the next generated release. Feel free to open a PR as + a proof of concept, but know that we will not be able to merge it as-is. We suggest opening +an issue first to discuss with us! + +On the other hand, contributions to the README are always very welcome! + + diff --git a/access_code.go b/access_code.go deleted file mode 100644 index e86d044..0000000 --- a/access_code.go +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -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 *any `json:"errors,omitempty"` - Warnings *any `json:"warnings,omitempty"` - IsManaged string `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"` -} diff --git a/access_code_status.go b/access_code_status.go deleted file mode 100644 index 277314f..0000000 --- a/access_code_status.go +++ /dev/null @@ -1,65 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type AccessCodeStatus uint8 - -const ( - AccessCodeStatusSetting AccessCodeStatus = iota + 1 - AccessCodeStatusSet - AccessCodeStatusUnset - AccessCodeStatusRemoving - AccessCodeStatusUnknown -) - -func (a AccessCodeStatus) String() string { - switch a { - default: - return strconv.Itoa(int(a)) - case AccessCodeStatusSetting: - return "setting" - case AccessCodeStatusSet: - return "set" - case AccessCodeStatusUnset: - return "unset" - case AccessCodeStatusRemoving: - return "removing" - case AccessCodeStatusUnknown: - return "unknown" - } -} - -func (a AccessCodeStatus) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", a.String())), nil -} - -func (a *AccessCodeStatus) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "setting": - value := AccessCodeStatusSetting - *a = value - case "set": - value := AccessCodeStatusSet - *a = value - case "unset": - value := AccessCodeStatusUnset - *a = value - case "removing": - value := AccessCodeStatusRemoving - *a = value - case "unknown": - value := AccessCodeStatusUnknown - *a = value - } - return nil -} diff --git a/access_code_type.go b/access_code_type.go deleted file mode 100644 index 778b73d..0000000 --- a/access_code_type.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type AccessCodeType uint8 - -const ( - AccessCodeTypeTimeBound AccessCodeType = iota + 1 - AccessCodeTypeOngoing -) - -func (a AccessCodeType) String() string { - switch a { - default: - return strconv.Itoa(int(a)) - case AccessCodeTypeTimeBound: - return "time_bound" - case AccessCodeTypeOngoing: - return "ongoing" - } -} - -func (a AccessCodeType) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", a.String())), nil -} - -func (a *AccessCodeType) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "time_bound": - value := AccessCodeTypeTimeBound - *a = value - case "ongoing": - value := AccessCodeTypeOngoing - *a = value - } - return nil -} diff --git a/access_codes.go b/access_codes.go new file mode 100644 index 0000000..e13ba8c --- /dev/null +++ b/access_codes.go @@ -0,0 +1,147 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + fmt "fmt" +) + +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"` +} + +type AccessCodesCreateMultipleRequest struct { + DeviceIds []string `json:"device_ids,omitempty"` + BehaviorWhenCodeCannotBeShared *AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared `json:"behavior_when_code_cannot_be_shared,omitempty"` + Name *string `json:"name,omitempty"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` + Code *string `json:"code,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"` +} + +type AccessCodesDeleteRequest struct { + DeviceId *string `json:"device_id,omitempty"` + AccessCodeId string `json:"access_code_id"` + Sync *bool `json:"sync,omitempty"` +} + +type AccessCodesGetRequest struct { + DeviceId *string `json:"device_id,omitempty"` + AccessCodeId *string `json:"access_code_id,omitempty"` + Code *string `json:"code,omitempty"` +} + +type AccessCodesListRequest struct { + DeviceId string `json:"device_id"` + AccessCodeIds []string `json:"access_code_ids,omitempty"` +} + +type AccessCodesPullBackupAccessCodeRequest struct { + AccessCodeId string `json:"access_code_id"` +} + +type AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared string + +const ( + AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedThrow AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared = "throw" + AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedCreateRandomCode AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared = "create_random_code" +) + +func NewAccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedFromString(s string) (AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared, error) { + switch s { + case "throw": + return AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedThrow, nil + case "create_random_code": + return AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedCreateRandomCode, nil + } + var t AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (a AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared) Ptr() *AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared { + return &a +} + +type AccessCodesCreateMultipleResponse struct { + AccessCodes []*AccessCode `json:"access_codes,omitempty"` + Ok bool `json:"ok"` +} + +type AccessCodesCreateResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + AccessCode *AccessCode `json:"access_code,omitempty"` + Ok bool `json:"ok"` +} + +type AccessCodesDeleteResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type AccessCodesGetResponse struct { + AccessCode *AccessCode `json:"access_code,omitempty"` + Ok bool `json:"ok"` +} + +type AccessCodesListResponse struct { + AccessCodes []*AccessCode `json:"access_codes,omitempty"` + Ok bool `json:"ok"` +} + +type AccessCodesPullBackupAccessCodeResponse struct { + BackupAccessCode *AccessCode `json:"backup_access_code,omitempty"` + Ok bool `json:"ok"` +} + +type AccessCodesUpdateRequestType string + +const ( + AccessCodesUpdateRequestTypeOngoing AccessCodesUpdateRequestType = "ongoing" + AccessCodesUpdateRequestTypeTimeBound AccessCodesUpdateRequestType = "time_bound" +) + +func NewAccessCodesUpdateRequestTypeFromString(s string) (AccessCodesUpdateRequestType, error) { + switch s { + case "ongoing": + return AccessCodesUpdateRequestTypeOngoing, nil + case "time_bound": + return AccessCodesUpdateRequestTypeTimeBound, nil + } + var t AccessCodesUpdateRequestType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (a AccessCodesUpdateRequestType) Ptr() *AccessCodesUpdateRequestType { + return &a +} + +type AccessCodesUpdateResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +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"` +} diff --git a/access_codes_create_multiple_request.go b/access_codes_create_multiple_request.go deleted file mode 100644 index 1ca38f8..0000000 --- a/access_codes_create_multiple_request.go +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesCreateMultipleRequest is an in-lined request used by the CreateMultiple endpoint. -type AccessCodesCreateMultipleRequest struct { - DeviceIds []string `json:"device_ids,omitempty"` - BehaviorWhenCodeCannotBeShared *AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared `json:"behavior_when_code_cannot_be_shared,omitempty"` - Name *string `json:"name,omitempty"` - StartsAt *string `json:"starts_at,omitempty"` - EndsAt *string `json:"ends_at,omitempty"` - Code *string `json:"code,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"` -} diff --git a/access_codes_create_multiple_request_behavior_when_code_cannot_be_shared.go b/access_codes_create_multiple_request_behavior_when_code_cannot_be_shared.go deleted file mode 100644 index 3065c2c..0000000 --- a/access_codes_create_multiple_request_behavior_when_code_cannot_be_shared.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared uint8 - -const ( - AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedThrow AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared = iota + 1 - AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedCreateRandomCode -) - -func (a AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared) String() string { - switch a { - default: - return strconv.Itoa(int(a)) - case AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedThrow: - return "throw" - case AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedCreateRandomCode: - return "create_random_code" - } -} - -func (a AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", a.String())), nil -} - -func (a *AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeShared) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "throw": - value := AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedThrow - *a = value - case "create_random_code": - value := AccessCodesCreateMultipleRequestBehaviorWhenCodeCannotBeSharedCreateRandomCode - *a = value - } - return nil -} diff --git a/access_codes_create_multiple_response.go b/access_codes_create_multiple_response.go deleted file mode 100644 index 8deaae5..0000000 --- a/access_codes_create_multiple_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesCreateMultipleResponse struct { - AccessCodes []*AccessCode `json:"access_codes,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_create_request.go b/access_codes_create_request.go deleted file mode 100644 index 7e7a1c2..0000000 --- a/access_codes_create_request.go +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesCreateRequest is an in-lined request used by the Create endpoint. -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"` -} diff --git a/access_codes_create_response.go b/access_codes_create_response.go deleted file mode 100644 index daeb030..0000000 --- a/access_codes_create_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesCreateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - AccessCode *AccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_delete_request.go b/access_codes_delete_request.go deleted file mode 100644 index 21115db..0000000 --- a/access_codes_delete_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesDeleteRequest is an in-lined request used by the Delete endpoint. -type AccessCodesDeleteRequest struct { - DeviceId *string `json:"device_id,omitempty"` - AccessCodeId string `json:"access_code_id"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/access_codes_delete_response.go b/access_codes_delete_response.go deleted file mode 100644 index 642b61d..0000000 --- a/access_codes_delete_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesDeleteResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_get_request.go b/access_codes_get_request.go deleted file mode 100644 index 6a6a481..0000000 --- a/access_codes_get_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesGetRequest is an in-lined request used by the Get endpoint. -type AccessCodesGetRequest struct { - DeviceId *string `json:"device_id,omitempty"` - AccessCodeId *string `json:"access_code_id,omitempty"` - Code *string `json:"code,omitempty"` -} diff --git a/access_codes_get_response.go b/access_codes_get_response.go deleted file mode 100644 index 7103d4c..0000000 --- a/access_codes_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesGetResponse struct { - AccessCode *AccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_list_request.go b/access_codes_list_request.go deleted file mode 100644 index 8815a46..0000000 --- a/access_codes_list_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesListRequest is an in-lined request used by the List endpoint. -type AccessCodesListRequest struct { - DeviceId string `json:"device_id"` - AccessCodeIds *[]string `json:"access_code_ids,omitempty"` -} diff --git a/access_codes_list_response.go b/access_codes_list_response.go deleted file mode 100644 index 61b9344..0000000 --- a/access_codes_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesListResponse struct { - AccessCodes []*AccessCode `json:"access_codes,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_pull_backup_access_code_request.go b/access_codes_pull_backup_access_code_request.go deleted file mode 100644 index 532bbf1..0000000 --- a/access_codes_pull_backup_access_code_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesPullBackupAccessCodeRequest is an in-lined request used by the PullBackupAccessCode endpoint. -type AccessCodesPullBackupAccessCodeRequest struct { - AccessCodeId string `json:"access_code_id"` -} diff --git a/access_codes_pull_backup_access_code_response.go b/access_codes_pull_backup_access_code_response.go deleted file mode 100644 index 6f57b01..0000000 --- a/access_codes_pull_backup_access_code_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesPullBackupAccessCodeResponse struct { - BackupAccessCode *AccessCode `json:"backup_access_code,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_update_request.go b/access_codes_update_request.go deleted file mode 100644 index 3e57664..0000000 --- a/access_codes_update_request.go +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// AccessCodesUpdateRequest is an in-lined request used by the Update endpoint. -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"` -} diff --git a/access_codes_update_request_type.go b/access_codes_update_request_type.go deleted file mode 100644 index e884329..0000000 --- a/access_codes_update_request_type.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type AccessCodesUpdateRequestType uint8 - -const ( - AccessCodesUpdateRequestTypeOngoing AccessCodesUpdateRequestType = iota + 1 - AccessCodesUpdateRequestTypeTimeBound -) - -func (a AccessCodesUpdateRequestType) String() string { - switch a { - default: - return strconv.Itoa(int(a)) - case AccessCodesUpdateRequestTypeOngoing: - return "ongoing" - case AccessCodesUpdateRequestTypeTimeBound: - return "time_bound" - } -} - -func (a AccessCodesUpdateRequestType) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", a.String())), nil -} - -func (a *AccessCodesUpdateRequestType) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "ongoing": - value := AccessCodesUpdateRequestTypeOngoing - *a = value - case "time_bound": - value := AccessCodesUpdateRequestTypeTimeBound - *a = value - } - return nil -} diff --git a/access_codes_update_response.go b/access_codes_update_response.go deleted file mode 100644 index b87d9d5..0000000 --- a/access_codes_update_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type AccessCodesUpdateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/access_codes_client.go b/accesscodes/client/client.go similarity index 56% rename from access_codes_client.go rename to accesscodes/client/client.go index de731a1..53b57a3 100644 --- a/access_codes_client.go +++ b/accesscodes/client/client.go @@ -1,55 +1,47 @@ // This file was auto-generated by Fern from our API Definition. -package api +package client import ( bytes "bytes" context "context" json "encoding/json" errors "errors" + seamapigo "github.com/seamapi/go" + simulate "github.com/seamapi/go/accesscodes/simulate" + unmanaged "github.com/seamapi/go/accesscodes/unmanaged" core "github.com/seamapi/go/core" io "io" http "net/http" ) -type AccessCodesClient interface { - Create(ctx context.Context, request *AccessCodesCreateRequest) (*AccessCodesCreateResponse, error) - CreateMultiple(ctx context.Context, request *AccessCodesCreateMultipleRequest) (*AccessCodesCreateMultipleResponse, error) - Delete(ctx context.Context, request *AccessCodesDeleteRequest) (*AccessCodesDeleteResponse, error) - Get(ctx context.Context, request *AccessCodesGetRequest) (*AccessCodesGetResponse, error) - List(ctx context.Context, request *AccessCodesListRequest) (*AccessCodesListResponse, error) - PullBackupAccessCode(ctx context.Context, request *AccessCodesPullBackupAccessCodeRequest) (*AccessCodesPullBackupAccessCodeResponse, error) - Update(ctx context.Context, request *AccessCodesUpdateRequest) (*AccessCodesUpdateResponse, error) - Simulate() SimulateClient - Unmanaged() UnmanagedClient +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header + + Simulate *simulate.Client + Unmanaged *unmanaged.Client } -func NewAccessCodesClient(opts ...core.ClientOption) AccessCodesClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &accessCodesClient{ - baseURL: options.BaseURL, - httpClient: options.HTTPClient, - header: options.ToHeader(), - simulateClient: NewSimulateClient(opts...), - unmanagedClient: NewUnmanagedClient(opts...), + return &Client{ + baseURL: options.BaseURL, + httpClient: options.HTTPClient, + header: options.ToHeader(), + Simulate: simulate.NewClient(opts...), + Unmanaged: unmanaged.NewClient(opts...), } } -type accessCodesClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header - simulateClient SimulateClient - unmanagedClient UnmanagedClient -} - -func (a *accessCodesClient) Create(ctx context.Context, request *AccessCodesCreateRequest) (*AccessCodesCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *seamapigo.AccessCodesCreateRequest) (*seamapigo.AccessCode, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/create" @@ -62,44 +54,44 @@ func (a *accessCodesClient) Create(ctx context.Context, request *AccessCodesCrea decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesCreateResponse + var response *seamapigo.AccessCodesCreateResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.AccessCode, nil } -func (a *accessCodesClient) CreateMultiple(ctx context.Context, request *AccessCodesCreateMultipleRequest) (*AccessCodesCreateMultipleResponse, error) { +func (c *Client) CreateMultiple(ctx context.Context, request *seamapigo.AccessCodesCreateMultipleRequest) ([]*seamapigo.AccessCode, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/create_multiple" @@ -112,44 +104,44 @@ func (a *accessCodesClient) CreateMultiple(ctx context.Context, request *AccessC decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesCreateMultipleResponse + var response *seamapigo.AccessCodesCreateMultipleResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.AccessCodes, nil } -func (a *accessCodesClient) Delete(ctx context.Context, request *AccessCodesDeleteRequest) (*AccessCodesDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.AccessCodesDeleteRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/delete" @@ -162,44 +154,44 @@ func (a *accessCodesClient) Delete(ctx context.Context, request *AccessCodesDele decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesDeleteResponse + var response *seamapigo.AccessCodesDeleteResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodDelete, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } -func (a *accessCodesClient) Get(ctx context.Context, request *AccessCodesGetRequest) (*AccessCodesGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.AccessCodesGetRequest) (*seamapigo.AccessCode, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/get" @@ -212,44 +204,44 @@ func (a *accessCodesClient) Get(ctx context.Context, request *AccessCodesGetRequ decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesGetResponse + var response *seamapigo.AccessCodesGetResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.AccessCode, nil } -func (a *accessCodesClient) List(ctx context.Context, request *AccessCodesListRequest) (*AccessCodesListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.AccessCodesListRequest) ([]*seamapigo.AccessCode, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/list" @@ -262,44 +254,44 @@ func (a *accessCodesClient) List(ctx context.Context, request *AccessCodesListRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesListResponse + var response *seamapigo.AccessCodesListResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.AccessCodes, nil } -func (a *accessCodesClient) PullBackupAccessCode(ctx context.Context, request *AccessCodesPullBackupAccessCodeRequest) (*AccessCodesPullBackupAccessCodeResponse, error) { +func (c *Client) PullBackupAccessCode(ctx context.Context, request *seamapigo.AccessCodesPullBackupAccessCodeRequest) (*seamapigo.AccessCode, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/pull_backup_access_code" @@ -312,44 +304,44 @@ func (a *accessCodesClient) PullBackupAccessCode(ctx context.Context, request *A decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesPullBackupAccessCodeResponse + var response *seamapigo.AccessCodesPullBackupAccessCodeResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.BackupAccessCode, nil } -func (a *accessCodesClient) Update(ctx context.Context, request *AccessCodesUpdateRequest) (*AccessCodesUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *seamapigo.AccessCodesUpdateRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/update" @@ -362,44 +354,36 @@ func (a *accessCodesClient) Update(ctx context.Context, request *AccessCodesUpda decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *AccessCodesUpdateResponse + var response *seamapigo.AccessCodesUpdateResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil -} - -func (a *accessCodesClient) Simulate() SimulateClient { - return a.simulateClient -} - -func (a *accessCodesClient) Unmanaged() UnmanagedClient { - return a.unmanagedClient + return response.ActionAttempt, nil } diff --git a/accesscodes/simulate_create_unmanaged_access_code_request.go b/accesscodes/simulate.go similarity index 67% rename from accesscodes/simulate_create_unmanaged_access_code_request.go rename to accesscodes/simulate.go index d83aa26..78dd7d9 100644 --- a/accesscodes/simulate_create_unmanaged_access_code_request.go +++ b/accesscodes/simulate.go @@ -2,7 +2,6 @@ package accesscodes -// SimulateCreateUnmanagedAccessCodeRequest is an in-lined request used by the CreateUnmanagedAccessCode endpoint. type SimulateCreateUnmanagedAccessCodeRequest struct { DeviceId string `json:"device_id"` Name string `json:"name"` diff --git a/accesscodes/simulate_client.go b/accesscodes/simulate/client.go similarity index 65% rename from accesscodes/simulate_client.go rename to accesscodes/simulate/client.go index 8c71f09..15cfa51 100644 --- a/accesscodes/simulate_client.go +++ b/accesscodes/simulate/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package accesscodes +package simulate import ( bytes "bytes" @@ -8,37 +8,34 @@ import ( json "encoding/json" errors "errors" seamapigo "github.com/seamapi/go" + accesscodes "github.com/seamapi/go/accesscodes" core "github.com/seamapi/go/core" io "io" http "net/http" ) -type SimulateClient interface { - CreateUnmanagedAccessCode(ctx context.Context, request *SimulateCreateUnmanagedAccessCodeRequest) (*seamapigo.SimulateCreateUnmanagedAccessCodeResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewSimulateClient(opts ...core.ClientOption) SimulateClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &simulateClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type simulateClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (s *simulateClient) CreateUnmanagedAccessCode(ctx context.Context, request *SimulateCreateUnmanagedAccessCodeRequest) (*seamapigo.SimulateCreateUnmanagedAccessCodeResponse, error) { +func (c *Client) CreateUnmanagedAccessCode(ctx context.Context, request *accesscodes.SimulateCreateUnmanagedAccessCodeRequest) (*seamapigo.SimulateCreateUnmanagedAccessCodeResponse, error) { baseURL := "https://connect.getseam.com" - if s.baseURL != "" { - baseURL = s.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/simulate/create_unmanaged_access_code" @@ -51,17 +48,17 @@ func (s *simulateClient) CreateUnmanagedAccessCode(ctx context.Context, request decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -71,16 +68,16 @@ func (s *simulateClient) CreateUnmanagedAccessCode(ctx context.Context, request var response *seamapigo.SimulateCreateUnmanagedAccessCodeResponse if err := core.DoRequest( ctx, - s.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - s.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/accesscodes/unmanaged.go b/accesscodes/unmanaged.go new file mode 100644 index 0000000..8815100 --- /dev/null +++ b/accesscodes/unmanaged.go @@ -0,0 +1,30 @@ +// This file was auto-generated by Fern from our API Definition. + +package accesscodes + +type UnmanagedConvertToManagedRequest struct { + AccessCodeId string `json:"access_code_id"` + Force *bool `json:"force,omitempty"` + Sync *bool `json:"sync,omitempty"` +} + +type UnmanagedDeleteRequest struct { + AccessCodeId string `json:"access_code_id"` + Sync *bool `json:"sync,omitempty"` +} + +type UnmanagedGetRequest struct { + DeviceId *string `json:"device_id,omitempty"` + AccessCodeId *string `json:"access_code_id,omitempty"` + Code *string `json:"code,omitempty"` +} + +type UnmanagedListRequest struct { + DeviceId string `json:"device_id"` +} + +type UnmanagedUpdateRequest struct { + AccessCodeId string `json:"access_code_id"` + IsManaged bool `json:"is_managed"` + Force *bool `json:"force,omitempty"` +} diff --git a/accesscodes/unmanaged_client.go b/accesscodes/unmanaged/client.go similarity index 66% rename from accesscodes/unmanaged_client.go rename to accesscodes/unmanaged/client.go index ef26c38..03e29a6 100644 --- a/accesscodes/unmanaged_client.go +++ b/accesscodes/unmanaged/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package accesscodes +package unmanaged import ( bytes "bytes" @@ -8,41 +8,34 @@ import ( json "encoding/json" errors "errors" seamapigo "github.com/seamapi/go" + accesscodes "github.com/seamapi/go/accesscodes" core "github.com/seamapi/go/core" io "io" http "net/http" ) -type UnmanagedClient interface { - ConvertToManaged(ctx context.Context, request *UnmanagedConvertToManagedRequest) (*seamapigo.UnmanagedConvertToManagedResponse, error) - Delete(ctx context.Context, request *UnmanagedDeleteRequest) (*seamapigo.UnmanagedDeleteResponse, error) - Get(ctx context.Context, request *UnmanagedGetRequest) (*seamapigo.UnmanagedGetResponse, error) - List(ctx context.Context, request *UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) - Update(ctx context.Context, request *UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewUnmanagedClient(opts ...core.ClientOption) UnmanagedClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &unmanagedClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type unmanagedClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (u *unmanagedClient) ConvertToManaged(ctx context.Context, request *UnmanagedConvertToManagedRequest) (*seamapigo.UnmanagedConvertToManagedResponse, error) { +func (c *Client) ConvertToManaged(ctx context.Context, request *accesscodes.UnmanagedConvertToManagedRequest) (*seamapigo.UnmanagedConvertToManagedResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/unmanaged/convert_to_managed" @@ -55,17 +48,17 @@ func (u *unmanagedClient) ConvertToManaged(ctx context.Context, request *Unmanag decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -75,24 +68,24 @@ func (u *unmanagedClient) ConvertToManaged(ctx context.Context, request *Unmanag var response *seamapigo.UnmanagedConvertToManagedResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (u *unmanagedClient) Delete(ctx context.Context, request *UnmanagedDeleteRequest) (*seamapigo.UnmanagedDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *accesscodes.UnmanagedDeleteRequest) (*seamapigo.UnmanagedDeleteResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/unmanaged/delete" @@ -105,17 +98,17 @@ func (u *unmanagedClient) Delete(ctx context.Context, request *UnmanagedDeleteRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -125,24 +118,24 @@ func (u *unmanagedClient) Delete(ctx context.Context, request *UnmanagedDeleteRe var response *seamapigo.UnmanagedDeleteResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodDelete, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (u *unmanagedClient) Get(ctx context.Context, request *UnmanagedGetRequest) (*seamapigo.UnmanagedGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *accesscodes.UnmanagedGetRequest) (*seamapigo.UnmanagedGetResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/unmanaged/get" @@ -155,17 +148,17 @@ func (u *unmanagedClient) Get(ctx context.Context, request *UnmanagedGetRequest) decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -175,24 +168,24 @@ func (u *unmanagedClient) Get(ctx context.Context, request *UnmanagedGetRequest) var response *seamapigo.UnmanagedGetResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (u *unmanagedClient) List(ctx context.Context, request *UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) { +func (c *Client) List(ctx context.Context, request *accesscodes.UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/unmanaged/list" @@ -205,17 +198,17 @@ func (u *unmanagedClient) List(ctx context.Context, request *UnmanagedListReques decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -225,24 +218,24 @@ func (u *unmanagedClient) List(ctx context.Context, request *UnmanagedListReques var response *seamapigo.UnmanagedListResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (u *unmanagedClient) Update(ctx context.Context, request *UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *accesscodes.UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "access_codes/unmanaged/update" @@ -255,17 +248,17 @@ func (u *unmanagedClient) Update(ctx context.Context, request *UnmanagedUpdateRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -275,16 +268,16 @@ func (u *unmanagedClient) Update(ctx context.Context, request *UnmanagedUpdateRe var response *seamapigo.UnmanagedUpdateResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/accesscodes/unmanaged_convert_to_managed_request.go b/accesscodes/unmanaged_convert_to_managed_request.go deleted file mode 100644 index 2462054..0000000 --- a/accesscodes/unmanaged_convert_to_managed_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package accesscodes - -// UnmanagedConvertToManagedRequest is an in-lined request used by the ConvertToManaged endpoint. -type UnmanagedConvertToManagedRequest struct { - AccessCodeId string `json:"access_code_id"` - Force *bool `json:"force,omitempty"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/accesscodes/unmanaged_delete_request.go b/accesscodes/unmanaged_delete_request.go deleted file mode 100644 index c6692de..0000000 --- a/accesscodes/unmanaged_delete_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package accesscodes - -// UnmanagedDeleteRequest is an in-lined request used by the Delete endpoint. -type UnmanagedDeleteRequest struct { - AccessCodeId string `json:"access_code_id"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/accesscodes/unmanaged_get_request.go b/accesscodes/unmanaged_get_request.go deleted file mode 100644 index a908cc5..0000000 --- a/accesscodes/unmanaged_get_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package accesscodes - -// UnmanagedGetRequest is an in-lined request used by the Get endpoint. -type UnmanagedGetRequest struct { - DeviceId *string `json:"device_id,omitempty"` - AccessCodeId *string `json:"access_code_id,omitempty"` - Code *string `json:"code,omitempty"` -} diff --git a/accesscodes/unmanaged_list_request.go b/accesscodes/unmanaged_list_request.go deleted file mode 100644 index d275897..0000000 --- a/accesscodes/unmanaged_list_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package accesscodes - -// UnmanagedListRequest is an in-lined request used by the List endpoint. -type UnmanagedListRequest struct { - DeviceId string `json:"device_id"` -} diff --git a/accesscodes/unmanaged_update_request.go b/accesscodes/unmanaged_update_request.go deleted file mode 100644 index 7cadff2..0000000 --- a/accesscodes/unmanaged_update_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package accesscodes - -// UnmanagedUpdateRequest is an in-lined request used by the Update endpoint. -type UnmanagedUpdateRequest struct { - AccessCodeId string `json:"access_code_id"` - IsManaged bool `json:"is_managed"` - Force *bool `json:"force,omitempty"` -} diff --git a/action_attempt.go b/action_attempt.go deleted file mode 100644 index f07aab3..0000000 --- a/action_attempt.go +++ /dev/null @@ -1,111 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" -) - -type ActionAttempt struct { - Status string - Success *ActionAttemptSuccess - Pending *ActionAttemptPending - Error *ActionAttemptError -} - -func NewActionAttemptFromSuccess(value *ActionAttemptSuccess) *ActionAttempt { - return &ActionAttempt{Status: "success", Success: value} -} - -func NewActionAttemptFromPending(value *ActionAttemptPending) *ActionAttempt { - return &ActionAttempt{Status: "pending", Pending: value} -} - -func NewActionAttemptFromError(value *ActionAttemptError) *ActionAttempt { - return &ActionAttempt{Status: "error", Error: value} -} - -func (a *ActionAttempt) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Status string `json:"status"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - a.Status = unmarshaler.Status - switch unmarshaler.Status { - case "success": - value := new(ActionAttemptSuccess) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Success = value - case "pending": - value := new(ActionAttemptPending) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Pending = value - case "error": - value := new(ActionAttemptError) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Error = value - } - return nil -} - -func (a ActionAttempt) MarshalJSON() ([]byte, error) { - switch a.Status { - default: - return nil, fmt.Errorf("invalid type %s in %T", a.Status, a) - case "success": - var marshaler = struct { - Status string `json:"status"` - *ActionAttemptSuccess - }{ - Status: a.Status, - ActionAttemptSuccess: a.Success, - } - return json.Marshal(marshaler) - case "pending": - var marshaler = struct { - Status string `json:"status"` - *ActionAttemptPending - }{ - Status: a.Status, - ActionAttemptPending: a.Pending, - } - return json.Marshal(marshaler) - case "error": - var marshaler = struct { - Status string `json:"status"` - *ActionAttemptError - }{ - Status: a.Status, - ActionAttemptError: a.Error, - } - return json.Marshal(marshaler) - } -} - -type ActionAttemptVisitor interface { - VisitSuccess(*ActionAttemptSuccess) error - VisitPending(*ActionAttemptPending) error - VisitError(*ActionAttemptError) error -} - -func (a *ActionAttempt) Accept(v ActionAttemptVisitor) error { - switch a.Status { - default: - return fmt.Errorf("invalid type %s in %T", a.Status, a) - case "success": - return v.VisitSuccess(a.Success) - case "pending": - return v.VisitPending(a.Pending) - case "error": - return v.VisitError(a.Error) - } -} diff --git a/action_attempt_error.go b/action_attempt_error.go deleted file mode 100644 index bd3f3df..0000000 --- a/action_attempt_error.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ActionAttemptError struct { - ActionType string `json:"action_type"` - ActionAttemptId string `json:"action_attempt_id"` - Result *string `json:"result,omitempty"` - Error *ActionAttemptErrorError `json:"error,omitempty"` -} diff --git a/action_attempt_error_error.go b/action_attempt_error_error.go deleted file mode 100644 index 08bee5f..0000000 --- a/action_attempt_error_error.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ActionAttemptErrorError struct { - Type string `json:"type"` - Message string `json:"message"` -} diff --git a/action_attempt_pending.go b/action_attempt_pending.go deleted file mode 100644 index 2b5983e..0000000 --- a/action_attempt_pending.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ActionAttemptPending struct { - ActionType string `json:"action_type"` - ActionAttemptId string `json:"action_attempt_id"` - Result *string `json:"result,omitempty"` - Error *string `json:"error,omitempty"` -} diff --git a/action_attempt_success.go b/action_attempt_success.go deleted file mode 100644 index c8c5840..0000000 --- a/action_attempt_success.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ActionAttemptSuccess struct { - ActionType string `json:"action_type"` - ActionAttemptId string `json:"action_attempt_id"` - Result *any `json:"result,omitempty"` - Error *string `json:"error,omitempty"` -} diff --git a/action_attempts.go b/action_attempts.go new file mode 100644 index 0000000..156a38a --- /dev/null +++ b/action_attempts.go @@ -0,0 +1,21 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +type ActionAttemptsGetRequest struct { + ActionAttemptId string `json:"action_attempt_id"` +} + +type ActionAttemptsListRequest struct { + ActionAttemptIds []string `json:"action_attempt_ids,omitempty"` +} + +type ActionAttemptsGetResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type ActionAttemptsListResponse struct { + ActionAttempts []*ActionAttempt `json:"action_attempts,omitempty"` + Ok bool `json:"ok"` +} diff --git a/action_attempts_get_request.go b/action_attempts_get_request.go deleted file mode 100644 index 0d54179..0000000 --- a/action_attempts_get_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ActionAttemptsGetRequest is an in-lined request used by the Get endpoint. -type ActionAttemptsGetRequest struct { - ActionAttemptId string `json:"action_attempt_id"` -} diff --git a/action_attempts_get_response.go b/action_attempts_get_response.go deleted file mode 100644 index e07eb1a..0000000 --- a/action_attempts_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ActionAttemptsGetResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/action_attempts_list_request.go b/action_attempts_list_request.go deleted file mode 100644 index 16bdea3..0000000 --- a/action_attempts_list_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ActionAttemptsListRequest is an in-lined request used by the List endpoint. -type ActionAttemptsListRequest struct { - ActionAttemptIds []string `json:"action_attempt_ids,omitempty"` -} diff --git a/action_attempts_list_response.go b/action_attempts_list_response.go deleted file mode 100644 index 1af9414..0000000 --- a/action_attempts_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ActionAttemptsListResponse struct { - ActionAttempts []*ActionAttempt `json:"action_attempts,omitempty"` - Ok bool `json:"ok"` -} diff --git a/action_attempts_client.go b/actionattempts/client.go similarity index 62% rename from action_attempts_client.go rename to actionattempts/client.go index 0024e10..cd2d4d9 100644 --- a/action_attempts_client.go +++ b/actionattempts/client.go @@ -1,44 +1,40 @@ // This file was auto-generated by Fern from our API Definition. -package api +package actionattempts 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 ActionAttemptsClient interface { - Get(ctx context.Context, request *ActionAttemptsGetRequest) (*ActionAttemptsGetResponse, error) - List(ctx context.Context, request *ActionAttemptsListRequest) (*ActionAttemptsListResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewActionAttemptsClient(opts ...core.ClientOption) ActionAttemptsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &actionAttemptsClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type actionAttemptsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (a *actionAttemptsClient) Get(ctx context.Context, request *ActionAttemptsGetRequest) (*ActionAttemptsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.ActionAttemptsGetRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "action_attempts/get" @@ -51,44 +47,44 @@ func (a *actionAttemptsClient) Get(ctx context.Context, request *ActionAttemptsG decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ActionAttemptsGetResponse + var response *seamapigo.ActionAttemptsGetResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } -func (a *actionAttemptsClient) List(ctx context.Context, request *ActionAttemptsListRequest) (*ActionAttemptsListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.ActionAttemptsListRequest) ([]*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if a.baseURL != "" { - baseURL = a.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "action_attempts/list" @@ -101,36 +97,36 @@ func (a *actionAttemptsClient) List(ctx context.Context, request *ActionAttempts decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ActionAttemptsListResponse + var response *seamapigo.ActionAttemptsListResponse if err := core.DoRequest( ctx, - a.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - a.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempts, nil } diff --git a/august_device_metadata.go b/august_device_metadata.go deleted file mode 100644 index d7892f7..0000000 --- a/august_device_metadata.go +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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"` -} diff --git a/bad_request_error.go b/bad_request_error.go deleted file mode 100644 index 35d2a9a..0000000 --- a/bad_request_error.go +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - core "github.com/seamapi/go/core" -) - -type BadRequestError struct { - *core.APIError - Body any -} - -func (b *BadRequestError) UnmarshalJSON(data []byte) error { - var body any - if err := json.Unmarshal(data, &body); err != nil { - return err - } - b.StatusCode = 400 - b.Body = body - return nil -} - -func (b *BadRequestError) MarshalJSON() ([]byte, error) { - return json.Marshal(b.Body) -} diff --git a/client.go b/client.go deleted file mode 100644 index 698e54d..0000000 --- a/client.go +++ /dev/null @@ -1,121 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - core "github.com/seamapi/go/core" - noisesensors "github.com/seamapi/go/noisesensors" - http "net/http" -) - -type Client interface { - AccessCodes() AccessCodesClient - ActionAttempts() ActionAttemptsClient - ClientSessions() ClientSessionsClient - ConnectedAccounts() ConnectedAccountsClient - ConnectWebviews() ConnectWebviewsClient - Devices() DevicesClient - Events() EventsClient - Health() HealthClient - Locks() LocksClient - NoiseSensors() noisesensors.Client - Thermostats() ThermostatsClient - Webhooks() WebhooksClient - Workspaces() WorkspacesClient -} - -func NewClient(opts ...core.ClientOption) Client { - options := core.NewClientOptions() - for _, opt := range opts { - opt(options) - } - return &client{ - baseURL: options.BaseURL, - httpClient: options.HTTPClient, - header: options.ToHeader(), - accessCodesClient: NewAccessCodesClient(opts...), - actionAttemptsClient: NewActionAttemptsClient(opts...), - clientSessionsClient: NewClientSessionsClient(opts...), - connectedAccountsClient: NewConnectedAccountsClient(opts...), - connectWebviewsClient: NewConnectWebviewsClient(opts...), - devicesClient: NewDevicesClient(opts...), - eventsClient: NewEventsClient(opts...), - healthClient: NewHealthClient(opts...), - locksClient: NewLocksClient(opts...), - noiseSensorsClient: noisesensors.NewClient(opts...), - thermostatsClient: NewThermostatsClient(opts...), - webhooksClient: NewWebhooksClient(opts...), - workspacesClient: NewWorkspacesClient(opts...), - } -} - -type client struct { - baseURL string - httpClient core.HTTPClient - header http.Header - accessCodesClient AccessCodesClient - actionAttemptsClient ActionAttemptsClient - clientSessionsClient ClientSessionsClient - connectedAccountsClient ConnectedAccountsClient - connectWebviewsClient ConnectWebviewsClient - devicesClient DevicesClient - eventsClient EventsClient - healthClient HealthClient - locksClient LocksClient - noiseSensorsClient noisesensors.Client - thermostatsClient ThermostatsClient - webhooksClient WebhooksClient - workspacesClient WorkspacesClient -} - -func (c *client) AccessCodes() AccessCodesClient { - return c.accessCodesClient -} - -func (c *client) ActionAttempts() ActionAttemptsClient { - return c.actionAttemptsClient -} - -func (c *client) ClientSessions() ClientSessionsClient { - return c.clientSessionsClient -} - -func (c *client) ConnectedAccounts() ConnectedAccountsClient { - return c.connectedAccountsClient -} - -func (c *client) ConnectWebviews() ConnectWebviewsClient { - return c.connectWebviewsClient -} - -func (c *client) Devices() DevicesClient { - return c.devicesClient -} - -func (c *client) Events() EventsClient { - return c.eventsClient -} - -func (c *client) Health() HealthClient { - return c.healthClient -} - -func (c *client) Locks() LocksClient { - return c.locksClient -} - -func (c *client) NoiseSensors() noisesensors.Client { - return c.noiseSensorsClient -} - -func (c *client) Thermostats() ThermostatsClient { - return c.thermostatsClient -} - -func (c *client) Webhooks() WebhooksClient { - return c.webhooksClient -} - -func (c *client) Workspaces() WorkspacesClient { - return c.workspacesClient -} diff --git a/client/client.go b/client/client.go new file mode 100644 index 0000000..4320234 --- /dev/null +++ b/client/client.go @@ -0,0 +1,66 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + accesscodesclient "github.com/seamapi/go/accesscodes/client" + actionattempts "github.com/seamapi/go/actionattempts" + clientsessions "github.com/seamapi/go/clientsessions" + connectedaccounts "github.com/seamapi/go/connectedaccounts" + connectwebviews "github.com/seamapi/go/connectwebviews" + core "github.com/seamapi/go/core" + devicesclient "github.com/seamapi/go/devices/client" + events "github.com/seamapi/go/events" + healthclient "github.com/seamapi/go/health/client" + locks "github.com/seamapi/go/locks" + noisesensorsclient "github.com/seamapi/go/noisesensors/client" + thermostatsclient "github.com/seamapi/go/thermostats/client" + webhooks "github.com/seamapi/go/webhooks" + workspaces "github.com/seamapi/go/workspaces" + http "net/http" +) + +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header + + AccessCodes *accesscodesclient.Client + ActionAttempts *actionattempts.Client + ClientSessions *clientsessions.Client + ConnectedAccounts *connectedaccounts.Client + ConnectWebviews *connectwebviews.Client + Devices *devicesclient.Client + Events *events.Client + Health *healthclient.Client + Locks *locks.Client + NoiseSensors *noisesensorsclient.Client + Thermostats *thermostatsclient.Client + Webhooks *webhooks.Client + Workspaces *workspaces.Client +} + +func NewClient(opts ...core.ClientOption) *Client { + options := core.NewClientOptions() + for _, opt := range opts { + opt(options) + } + return &Client{ + baseURL: options.BaseURL, + httpClient: options.HTTPClient, + header: options.ToHeader(), + AccessCodes: accesscodesclient.NewClient(opts...), + ActionAttempts: actionattempts.NewClient(opts...), + ClientSessions: clientsessions.NewClient(opts...), + ConnectedAccounts: connectedaccounts.NewClient(opts...), + ConnectWebviews: connectwebviews.NewClient(opts...), + Devices: devicesclient.NewClient(opts...), + Events: events.NewClient(opts...), + Health: healthclient.NewClient(opts...), + Locks: locks.NewClient(opts...), + NoiseSensors: noisesensorsclient.NewClient(opts...), + Thermostats: thermostatsclient.NewClient(opts...), + Webhooks: webhooks.NewClient(opts...), + Workspaces: workspaces.NewClient(opts...), + } +} diff --git a/client/client_test.go b/client/client_test.go new file mode 100644 index 0000000..42e870c --- /dev/null +++ b/client/client_test.go @@ -0,0 +1,47 @@ +package client + +import ( + "net/http" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestNewClient(t *testing.T) { + t.Run("default", func(t *testing.T) { + c := NewClient() + assert.Empty(t, c.baseURL) + assert.Equal(t, http.DefaultClient, c.httpClient) + }) + + t.Run("base url", func(t *testing.T) { + c := NewClient( + WithBaseURL("test.co"), + ) + assert.Equal(t, "test.co", c.baseURL) + assert.Equal(t, http.DefaultClient, c.httpClient) + }) + + t.Run("http client", func(t *testing.T) { + httpClient := &http.Client{ + Timeout: 5 * time.Second, + } + c := NewClient( + WithHTTPClient(httpClient), + ) + assert.Empty(t, c.baseURL) + assert.Equal(t, httpClient, c.httpClient) + }) + + t.Run("http header", func(t *testing.T) { + header := make(http.Header) + header.Set("X-API-Tenancy", "test") + c := NewClient( + WithHTTPHeader(header), + ) + assert.Empty(t, c.baseURL) + assert.Equal(t, http.DefaultClient, c.httpClient) + assert.Equal(t, "test", c.header.Get("X-API-Tenancy")) + }) +} diff --git a/client/options.go b/client/options.go new file mode 100644 index 0000000..f3a82d5 --- /dev/null +++ b/client/options.go @@ -0,0 +1,39 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + core "github.com/seamapi/go/core" + http "net/http" +) + +// WithBaseURL sets the client's base URL, overriding the +// default environment, if any. +func WithBaseURL(baseURL string) core.ClientOption { + return func(opts *core.ClientOptions) { + opts.BaseURL = baseURL + } +} + +// WithHTTPClient uses the given HTTPClient to issue all HTTP requests. +func WithHTTPClient(httpClient core.HTTPClient) core.ClientOption { + return func(opts *core.ClientOptions) { + opts.HTTPClient = httpClient + } +} + +// WithHTTPHeader adds the given http.Header to all requests +// issued by the client. +func WithHTTPHeader(httpHeader http.Header) core.ClientOption { + return func(opts *core.ClientOptions) { + // Clone the headers so they can't be modified after the option call. + opts.HTTPHeader = httpHeader.Clone() + } +} + +// WithAuthApiKey sets the 'Authorization: Bearer ' header on every request. +func WithAuthApiKey(apiKey string) core.ClientOption { + return func(opts *core.ClientOptions) { + opts.ApiKey = apiKey + } +} diff --git a/client_options.go b/client_options.go deleted file mode 100644 index f0e4f23..0000000 --- a/client_options.go +++ /dev/null @@ -1,41 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - core "github.com/seamapi/go/core" - http "net/http" -) - -// ClientWithBaseURL sets the client's base URL, overriding the -// default environment, if any. -func ClientWithBaseURL(baseURL string) core.ClientOption { - return func(opts *core.ClientOptions) { - opts.BaseURL = baseURL - } -} - -// ClientWithHTTPClient uses the given HTTPClient to issue all HTTP requests. -func ClientWithHTTPClient(httpClient core.HTTPClient) core.ClientOption { - return func(opts *core.ClientOptions) { - opts.HTTPClient = httpClient - } -} - -// ClientWithHTTPHeader adds the given http.Header to all requests -// issued by the client. The given headers are added to the final set -// after the standard headers (e.g. Content-Type), but before the -// endpoint-specific headers. -func ClientWithHTTPHeader(httpHeader http.Header) core.ClientOption { - return func(opts *core.ClientOptions) { - // Clone the headers so they can't be modified after the option call. - opts.HTTPHeader = httpHeader.Clone() - } -} - -// ClientWithAuthBearer sets the 'Authorization: Bearer ' header on every request. -func ClientWithAuthBearer(bearer string) core.ClientOption { - return func(opts *core.ClientOptions) { - opts.Bearer = bearer - } -} diff --git a/client_session.go b/client_session.go deleted file mode 100644 index 0873baf..0000000 --- a/client_session.go +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -type ClientSession struct { - ClientSessionId string `json:"client_session_id"` - UserIdentifierKey *string `json:"user_identifier_key,omitempty"` - CreatedAt time.Time `json:"created_at"` - Token string `json:"token"` - DeviceCount float64 `json:"device_count"` - ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` - ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` - WorkspaceId string `json:"workspace_id"` -} diff --git a/client_sessions.go b/client_sessions.go new file mode 100644 index 0000000..f7ab987 --- /dev/null +++ b/client_sessions.go @@ -0,0 +1,43 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +type ClientSessionsCreateRequest struct { + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` + ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` +} + +type ClientSessionsDeleteRequest struct { + ClientSessionId string `json:"client_session_id"` +} + +type ClientSessionsGetRequest struct { + ClientSessionId *string `json:"client_session_id,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` +} + +type ClientSessionsListRequest struct { + ClientSessionId *string `json:"client_session_id,omitempty"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + WithoutUserIdentifierKey *bool `json:"without_user_identifier_key,omitempty"` +} + +type ClientSessionsCreateResponse struct { + ClientSession *ClientSession `json:"client_session,omitempty"` + Ok bool `json:"ok"` +} + +type ClientSessionsDeleteResponse struct { + Ok bool `json:"ok"` +} + +type ClientSessionsGetResponse struct { + ClientSession *ClientSession `json:"client_session,omitempty"` + Ok bool `json:"ok"` +} + +type ClientSessionsListResponse struct { + ClientSessions []*ClientSession `json:"client_sessions,omitempty"` + Ok bool `json:"ok"` +} diff --git a/client_sessions_create_request.go b/client_sessions_create_request.go deleted file mode 100644 index fd51b55..0000000 --- a/client_sessions_create_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ClientSessionsCreateRequest is an in-lined request used by the Create endpoint. -type ClientSessionsCreateRequest struct { - UserIdentifierKey *string `json:"user_identifier_key,omitempty"` - ConnectWebviewIds *[]string `json:"connect_webview_ids,omitempty"` - ConnectedAccountIds *[]string `json:"connected_account_ids,omitempty"` -} diff --git a/client_sessions_create_response.go b/client_sessions_create_response.go deleted file mode 100644 index b2c9230..0000000 --- a/client_sessions_create_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClientSessionsCreateResponse struct { - ClientSession *ClientSession `json:"client_session,omitempty"` - Ok bool `json:"ok"` -} diff --git a/client_sessions_delete_request.go b/client_sessions_delete_request.go deleted file mode 100644 index 0d00399..0000000 --- a/client_sessions_delete_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ClientSessionsDeleteRequest is an in-lined request used by the Delete endpoint. -type ClientSessionsDeleteRequest struct { - ClientSessionId string `json:"client_session_id"` -} diff --git a/client_sessions_delete_response.go b/client_sessions_delete_response.go deleted file mode 100644 index dc70be5..0000000 --- a/client_sessions_delete_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClientSessionsDeleteResponse struct { - Ok bool `json:"ok"` -} diff --git a/client_sessions_get_request.go b/client_sessions_get_request.go deleted file mode 100644 index 7834779..0000000 --- a/client_sessions_get_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ClientSessionsGetRequest is an in-lined request used by the Get endpoint. -type ClientSessionsGetRequest struct { - ClientSessionId *string `json:"client_session_id,omitempty"` - UserIdentifierKey *string `json:"user_identifier_key,omitempty"` -} diff --git a/client_sessions_get_response.go b/client_sessions_get_response.go deleted file mode 100644 index d35178a..0000000 --- a/client_sessions_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClientSessionsGetResponse struct { - ClientSession *ClientSession `json:"client_session,omitempty"` - Ok bool `json:"ok"` -} diff --git a/client_sessions_list_request.go b/client_sessions_list_request.go deleted file mode 100644 index 8fad8b6..0000000 --- a/client_sessions_list_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ClientSessionsListRequest is an in-lined request used by the List endpoint. -type ClientSessionsListRequest struct { - ClientSessionId *string `json:"client_session_id,omitempty"` - UserIdentifierKey *string `json:"user_identifier_key,omitempty"` - WithoutUserIdentifierKey *bool `json:"without_user_identifier_key,omitempty"` -} diff --git a/client_sessions_list_response.go b/client_sessions_list_response.go deleted file mode 100644 index c659bb2..0000000 --- a/client_sessions_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClientSessionsListResponse struct { - ClientSessions []*ClientSession `json:"client_sessions,omitempty"` - Ok bool `json:"ok"` -} diff --git a/client_sessions_client.go b/clientsessions/client.go similarity index 66% rename from client_sessions_client.go rename to clientsessions/client.go index 29b9816..64fbe13 100644 --- a/client_sessions_client.go +++ b/clientsessions/client.go @@ -1,43 +1,37 @@ // This file was auto-generated by Fern from our API Definition. -package api +package clientsessions 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 ClientSessionsClient interface { - Create(ctx context.Context, request *ClientSessionsCreateRequest) (*ClientSessionsCreateResponse, error) - Delete(ctx context.Context, request *ClientSessionsDeleteRequest) (*ClientSessionsDeleteResponse, error) - Get(ctx context.Context, request *ClientSessionsGetRequest) (*ClientSessionsGetResponse, error) - List(ctx context.Context, request *ClientSessionsListRequest) (*ClientSessionsListResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewClientSessionsClient(opts ...core.ClientOption) ClientSessionsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &clientSessionsClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type clientSessionsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (c *clientSessionsClient) Create(ctx context.Context, request *ClientSessionsCreateRequest) (*ClientSessionsCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *seamapigo.ClientSessionsCreateRequest) (*seamapigo.ClientSession, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -53,24 +47,24 @@ func (c *clientSessionsClient) Create(ctx context.Context, request *ClientSessio decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ClientSessionsCreateResponse + var response *seamapigo.ClientSessionsCreateResponse if err := core.DoRequest( ctx, c.httpClient, @@ -82,12 +76,12 @@ func (c *clientSessionsClient) Create(ctx context.Context, request *ClientSessio c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ClientSession, nil } -func (c *clientSessionsClient) Delete(ctx context.Context, request *ClientSessionsDeleteRequest) (*ClientSessionsDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.ClientSessionsDeleteRequest) (bool, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -103,24 +97,24 @@ func (c *clientSessionsClient) Delete(ctx context.Context, request *ClientSessio decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ClientSessionsDeleteResponse + var response *seamapigo.ClientSessionsDeleteResponse if err := core.DoRequest( ctx, c.httpClient, @@ -132,12 +126,12 @@ func (c *clientSessionsClient) Delete(ctx context.Context, request *ClientSessio c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil + return response.Ok, nil } -func (c *clientSessionsClient) Get(ctx context.Context, request *ClientSessionsGetRequest) (*ClientSessionsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.ClientSessionsGetRequest) (*seamapigo.ClientSession, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -153,24 +147,24 @@ func (c *clientSessionsClient) Get(ctx context.Context, request *ClientSessionsG decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ClientSessionsGetResponse + var response *seamapigo.ClientSessionsGetResponse if err := core.DoRequest( ctx, c.httpClient, @@ -182,12 +176,12 @@ func (c *clientSessionsClient) Get(ctx context.Context, request *ClientSessionsG c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ClientSession, nil } -func (c *clientSessionsClient) List(ctx context.Context, request *ClientSessionsListRequest) (*ClientSessionsListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.ClientSessionsListRequest) ([]*seamapigo.ClientSession, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -203,24 +197,24 @@ func (c *clientSessionsClient) List(ctx context.Context, request *ClientSessions decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ClientSessionsListResponse + var response *seamapigo.ClientSessionsListResponse if err := core.DoRequest( ctx, c.httpClient, @@ -232,7 +226,7 @@ func (c *clientSessionsClient) List(ctx context.Context, request *ClientSessions c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ClientSessions, nil } diff --git a/climate_setting_schedule.go b/climate_setting_schedule.go deleted file mode 100644 index 12255c0..0000000 --- a/climate_setting_schedule.go +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - time "time" -) - -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 *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 -} - -func (c *ClimateSettingSchedule) ScheduleType() string { - return c.scheduleType -} - -func (c *ClimateSettingSchedule) UnmarshalJSON(data []byte) error { - type unmarshaler ClimateSettingSchedule - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ClimateSettingSchedule(value) - c.scheduleType = "time_bound" - return nil -} - -func (c *ClimateSettingSchedule) MarshalJSON() ([]byte, error) { - type embed ClimateSettingSchedule - var marshaler = struct { - embed - ScheduleType string `json:"schedule_type"` - }{ - embed: embed(*c), - ScheduleType: "time_bound", - } - return json.Marshal(marshaler) -} diff --git a/climate_setting_schedule_hvac_mode_setting.go b/climate_setting_schedule_hvac_mode_setting.go deleted file mode 100644 index 09c1fcf..0000000 --- a/climate_setting_schedule_hvac_mode_setting.go +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ClimateSettingScheduleHvacModeSetting uint8 - -const ( - ClimateSettingScheduleHvacModeSettingOff ClimateSettingScheduleHvacModeSetting = iota + 1 - ClimateSettingScheduleHvacModeSettingHeat - ClimateSettingScheduleHvacModeSettingCool - ClimateSettingScheduleHvacModeSettingHeatcool -) - -func (c ClimateSettingScheduleHvacModeSetting) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ClimateSettingScheduleHvacModeSettingOff: - return "off" - case ClimateSettingScheduleHvacModeSettingHeat: - return "heat" - case ClimateSettingScheduleHvacModeSettingCool: - return "cool" - case ClimateSettingScheduleHvacModeSettingHeatcool: - return "heatcool" - } -} - -func (c ClimateSettingScheduleHvacModeSetting) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ClimateSettingScheduleHvacModeSetting) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "off": - value := ClimateSettingScheduleHvacModeSettingOff - *c = value - case "heat": - value := ClimateSettingScheduleHvacModeSettingHeat - *c = value - case "cool": - value := ClimateSettingScheduleHvacModeSettingCool - *c = value - case "heatcool": - value := ClimateSettingScheduleHvacModeSettingHeatcool - *c = value - } - return nil -} diff --git a/climate_setting_schedules_create_request_hvac_mode_setting.go b/climate_setting_schedules_create_request_hvac_mode_setting.go deleted file mode 100644 index 65b8ff7..0000000 --- a/climate_setting_schedules_create_request_hvac_mode_setting.go +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ClimateSettingSchedulesCreateRequestHvacModeSetting uint8 - -const ( - ClimateSettingSchedulesCreateRequestHvacModeSettingOff ClimateSettingSchedulesCreateRequestHvacModeSetting = iota + 1 - ClimateSettingSchedulesCreateRequestHvacModeSettingHeat - ClimateSettingSchedulesCreateRequestHvacModeSettingCool - ClimateSettingSchedulesCreateRequestHvacModeSettingHeatcool -) - -func (c ClimateSettingSchedulesCreateRequestHvacModeSetting) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ClimateSettingSchedulesCreateRequestHvacModeSettingOff: - return "off" - case ClimateSettingSchedulesCreateRequestHvacModeSettingHeat: - return "heat" - case ClimateSettingSchedulesCreateRequestHvacModeSettingCool: - return "cool" - case ClimateSettingSchedulesCreateRequestHvacModeSettingHeatcool: - return "heatcool" - } -} - -func (c ClimateSettingSchedulesCreateRequestHvacModeSetting) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ClimateSettingSchedulesCreateRequestHvacModeSetting) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "off": - value := ClimateSettingSchedulesCreateRequestHvacModeSettingOff - *c = value - case "heat": - value := ClimateSettingSchedulesCreateRequestHvacModeSettingHeat - *c = value - case "cool": - value := ClimateSettingSchedulesCreateRequestHvacModeSettingCool - *c = value - case "heatcool": - value := ClimateSettingSchedulesCreateRequestHvacModeSettingHeatcool - *c = value - } - return nil -} diff --git a/climate_setting_schedules_create_response.go b/climate_setting_schedules_create_response.go deleted file mode 100644 index 0fe4be8..0000000 --- a/climate_setting_schedules_create_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClimateSettingSchedulesCreateResponse struct { - ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` - Ok bool `json:"ok"` -} diff --git a/climate_setting_schedules_delete_response.go b/climate_setting_schedules_delete_response.go deleted file mode 100644 index 6064f99..0000000 --- a/climate_setting_schedules_delete_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClimateSettingSchedulesDeleteResponse struct { - Ok bool `json:"ok"` -} diff --git a/climate_setting_schedules_get_response.go b/climate_setting_schedules_get_response.go deleted file mode 100644 index a31173a..0000000 --- a/climate_setting_schedules_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClimateSettingSchedulesGetResponse struct { - ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` - Ok bool `json:"ok"` -} diff --git a/climate_setting_schedules_list_response.go b/climate_setting_schedules_list_response.go deleted file mode 100644 index 2d70f32..0000000 --- a/climate_setting_schedules_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClimateSettingSchedulesListResponse struct { - ClimateSettingSchedules []*ClimateSettingSchedule `json:"climate_setting_schedules,omitempty"` - Ok bool `json:"ok"` -} diff --git a/climate_setting_schedules_update_request_hvac_mode_setting.go b/climate_setting_schedules_update_request_hvac_mode_setting.go deleted file mode 100644 index bebcc4d..0000000 --- a/climate_setting_schedules_update_request_hvac_mode_setting.go +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ClimateSettingSchedulesUpdateRequestHvacModeSetting uint8 - -const ( - ClimateSettingSchedulesUpdateRequestHvacModeSettingOff ClimateSettingSchedulesUpdateRequestHvacModeSetting = iota + 1 - ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat - ClimateSettingSchedulesUpdateRequestHvacModeSettingCool - ClimateSettingSchedulesUpdateRequestHvacModeSettingHeatcool -) - -func (c ClimateSettingSchedulesUpdateRequestHvacModeSetting) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ClimateSettingSchedulesUpdateRequestHvacModeSettingOff: - return "off" - case ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat: - return "heat" - case ClimateSettingSchedulesUpdateRequestHvacModeSettingCool: - return "cool" - case ClimateSettingSchedulesUpdateRequestHvacModeSettingHeatcool: - return "heatcool" - } -} - -func (c ClimateSettingSchedulesUpdateRequestHvacModeSetting) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ClimateSettingSchedulesUpdateRequestHvacModeSetting) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "off": - value := ClimateSettingSchedulesUpdateRequestHvacModeSettingOff - *c = value - case "heat": - value := ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat - *c = value - case "cool": - value := ClimateSettingSchedulesUpdateRequestHvacModeSettingCool - *c = value - case "heatcool": - value := ClimateSettingSchedulesUpdateRequestHvacModeSettingHeatcool - *c = value - } - return nil -} diff --git a/climate_setting_schedules_update_response.go b/climate_setting_schedules_update_response.go deleted file mode 100644 index e2a2ce0..0000000 --- a/climate_setting_schedules_update_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ClimateSettingSchedulesUpdateResponse struct { - ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` - Ok bool `json:"ok"` -} diff --git a/connect_webview.go b/connect_webview.go deleted file mode 100644 index b9bbea9..0000000 --- a/connect_webview.go +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -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"` -} diff --git a/connect_webview_device_selection_mode.go b/connect_webview_device_selection_mode.go deleted file mode 100644 index 017471b..0000000 --- a/connect_webview_device_selection_mode.go +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ConnectWebviewDeviceSelectionMode uint8 - -const ( - ConnectWebviewDeviceSelectionModeNone ConnectWebviewDeviceSelectionMode = iota + 1 - ConnectWebviewDeviceSelectionModeSingle - ConnectWebviewDeviceSelectionModeMultiple -) - -func (c ConnectWebviewDeviceSelectionMode) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ConnectWebviewDeviceSelectionModeNone: - return "none" - case ConnectWebviewDeviceSelectionModeSingle: - return "single" - case ConnectWebviewDeviceSelectionModeMultiple: - return "multiple" - } -} - -func (c ConnectWebviewDeviceSelectionMode) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ConnectWebviewDeviceSelectionMode) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "none": - value := ConnectWebviewDeviceSelectionModeNone - *c = value - case "single": - value := ConnectWebviewDeviceSelectionModeSingle - *c = value - case "multiple": - value := ConnectWebviewDeviceSelectionModeMultiple - *c = value - } - return nil -} diff --git a/connect_webview_status.go b/connect_webview_status.go deleted file mode 100644 index 22d587c..0000000 --- a/connect_webview_status.go +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ConnectWebviewStatus uint8 - -const ( - ConnectWebviewStatusPending ConnectWebviewStatus = iota + 1 - ConnectWebviewStatusFailed - ConnectWebviewStatusAuthorized -) - -func (c ConnectWebviewStatus) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ConnectWebviewStatusPending: - return "pending" - case ConnectWebviewStatusFailed: - return "failed" - case ConnectWebviewStatusAuthorized: - return "authorized" - } -} - -func (c ConnectWebviewStatus) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ConnectWebviewStatus) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "pending": - value := ConnectWebviewStatusPending - *c = value - case "failed": - value := ConnectWebviewStatusFailed - *c = value - case "authorized": - value := ConnectWebviewStatusAuthorized - *c = value - } - return nil -} diff --git a/connect_webviews.go b/connect_webviews.go new file mode 100644 index 0000000..9d62ff0 --- /dev/null +++ b/connect_webviews.go @@ -0,0 +1,285 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" +) + +type ConnectWebviewsCreateRequest struct { + 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"` +} + +type ConnectWebviewsDeleteRequest struct { + ConnectWebviewId string `json:"connect_webview_id"` +} + +type ConnectWebviewsGetRequest struct { + ConnectWebviewId string `json:"connect_webview_id"` +} + +type ConnectWebviewsCreateRequestAcceptedProvidersItem string + +const ( + 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" + ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess ConnectWebviewsCreateRequestAcceptedProvidersItem = "yale_access" +) + +func NewConnectWebviewsCreateRequestAcceptedProvidersItemFromString(s string) (ConnectWebviewsCreateRequestAcceptedProvidersItem, error) { + switch s { + case "akuvox": + return ConnectWebviewsCreateRequestAcceptedProvidersItemAkuvox, nil + case "august": + return ConnectWebviewsCreateRequestAcceptedProvidersItemAugust, nil + case "avigilon_alta": + return ConnectWebviewsCreateRequestAcceptedProvidersItemAvigilonAlta, nil + case "brivo": + return ConnectWebviewsCreateRequestAcceptedProvidersItemBrivo, nil + case "butterflymx": + return ConnectWebviewsCreateRequestAcceptedProvidersItemButterflymx, nil + case "schlage": + return ConnectWebviewsCreateRequestAcceptedProvidersItemSchlage, nil + case "smartthings": + return ConnectWebviewsCreateRequestAcceptedProvidersItemSmartthings, nil + case "yale": + return ConnectWebviewsCreateRequestAcceptedProvidersItemYale, nil + case "genie": + return ConnectWebviewsCreateRequestAcceptedProvidersItemGenie, nil + case "doorking": + return ConnectWebviewsCreateRequestAcceptedProvidersItemDoorking, nil + case "salto": + return ConnectWebviewsCreateRequestAcceptedProvidersItemSalto, nil + case "lockly": + return ConnectWebviewsCreateRequestAcceptedProvidersItemLockly, nil + case "ttlock": + return ConnectWebviewsCreateRequestAcceptedProvidersItemTtlock, nil + case "linear": + return ConnectWebviewsCreateRequestAcceptedProvidersItemLinear, nil + case "noiseaware": + return ConnectWebviewsCreateRequestAcceptedProvidersItemNoiseaware, nil + case "nuki": + return ConnectWebviewsCreateRequestAcceptedProvidersItemNuki, nil + case "seam_relay_admin": + return ConnectWebviewsCreateRequestAcceptedProvidersItemSeamRelayAdmin, nil + case "igloo": + return ConnectWebviewsCreateRequestAcceptedProvidersItemIgloo, nil + case "kwikset": + return ConnectWebviewsCreateRequestAcceptedProvidersItemKwikset, nil + case "minut": + return ConnectWebviewsCreateRequestAcceptedProvidersItemMinut, nil + case "my_2n": + return ConnectWebviewsCreateRequestAcceptedProvidersItemMy2N, nil + case "controlbyweb": + return ConnectWebviewsCreateRequestAcceptedProvidersItemControlbyweb, nil + case "nest": + return ConnectWebviewsCreateRequestAcceptedProvidersItemNest, nil + case "igloohome": + return ConnectWebviewsCreateRequestAcceptedProvidersItemIgloohome, nil + case "ecobee": + return ConnectWebviewsCreateRequestAcceptedProvidersItemEcobee, nil + case "hubitat": + return ConnectWebviewsCreateRequestAcceptedProvidersItemHubitat, nil + case "yale_access": + return ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess, nil + } + var t ConnectWebviewsCreateRequestAcceptedProvidersItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ConnectWebviewsCreateRequestAcceptedProvidersItem) Ptr() *ConnectWebviewsCreateRequestAcceptedProvidersItem { + return &c +} + +type ConnectWebviewsCreateRequestCustomMetadataValue struct { + typeName string + String string + Double float64 + StringOptional *string + Boolean bool +} + +func NewConnectWebviewsCreateRequestCustomMetadataValueFromString(value string) *ConnectWebviewsCreateRequestCustomMetadataValue { + return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "string", String: value} +} + +func NewConnectWebviewsCreateRequestCustomMetadataValueFromDouble(value float64) *ConnectWebviewsCreateRequestCustomMetadataValue { + return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "double", Double: value} +} + +func NewConnectWebviewsCreateRequestCustomMetadataValueFromStringOptional(value *string) *ConnectWebviewsCreateRequestCustomMetadataValue { + return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "stringOptional", StringOptional: 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 valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + c.typeName = "double" + c.Double = valueDouble + return nil + } + var valueStringOptional *string + if err := json.Unmarshal(data, &valueStringOptional); err == nil { + c.typeName = "stringOptional" + c.StringOptional = valueStringOptional + 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 "double": + return json.Marshal(c.Double) + case "stringOptional": + return json.Marshal(c.StringOptional) + case "boolean": + return json.Marshal(c.Boolean) + } +} + +type ConnectWebviewsCreateRequestCustomMetadataValueVisitor interface { + VisitString(string) error + VisitDouble(float64) error + VisitStringOptional(*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 "double": + return visitor.VisitDouble(c.Double) + case "stringOptional": + return visitor.VisitStringOptional(c.StringOptional) + 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 { + ConnectWebview *ConnectWebview `json:"connect_webview,omitempty"` + Ok bool `json:"ok"` +} + +type ConnectWebviewsDeleteResponse struct { + Ok bool `json:"ok"` +} + +type ConnectWebviewsGetResponse struct { + ConnectWebview *ConnectWebview `json:"connect_webview,omitempty"` + Ok bool `json:"ok"` +} + +type ConnectWebviewsListResponse struct { + ConnectWebviews []*ConnectWebview `json:"connect_webviews,omitempty"` + Ok bool `json:"ok"` +} + +type ConnectWebviewsViewRequest struct { + ConnectWebviewId string `json:"-"` + AuthToken string `json:"-"` +} diff --git a/connect_webviews_create_request.go b/connect_webviews_create_request.go deleted file mode 100644 index 8099806..0000000 --- a/connect_webviews_create_request.go +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ConnectWebviewsCreateRequest is an in-lined request used by the Create endpoint. -type ConnectWebviewsCreateRequest struct { - 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"` -} diff --git a/connect_webviews_create_request_accepted_providers_item.go b/connect_webviews_create_request_accepted_providers_item.go deleted file mode 100644 index fd09f01..0000000 --- a/connect_webviews_create_request_accepted_providers_item.go +++ /dev/null @@ -1,197 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ConnectWebviewsCreateRequestAcceptedProvidersItem uint8 - -const ( - ConnectWebviewsCreateRequestAcceptedProvidersItemAkuvox ConnectWebviewsCreateRequestAcceptedProvidersItem = iota + 1 - ConnectWebviewsCreateRequestAcceptedProvidersItemAugust - ConnectWebviewsCreateRequestAcceptedProvidersItemAvigilonAlta - ConnectWebviewsCreateRequestAcceptedProvidersItemBrivo - ConnectWebviewsCreateRequestAcceptedProvidersItemButterflymx - ConnectWebviewsCreateRequestAcceptedProvidersItemSchlage - ConnectWebviewsCreateRequestAcceptedProvidersItemSmartthings - ConnectWebviewsCreateRequestAcceptedProvidersItemYale - ConnectWebviewsCreateRequestAcceptedProvidersItemGenie - ConnectWebviewsCreateRequestAcceptedProvidersItemDoorking - ConnectWebviewsCreateRequestAcceptedProvidersItemSalto - ConnectWebviewsCreateRequestAcceptedProvidersItemLockly - ConnectWebviewsCreateRequestAcceptedProvidersItemTtlock - ConnectWebviewsCreateRequestAcceptedProvidersItemLinear - ConnectWebviewsCreateRequestAcceptedProvidersItemNoiseaware - ConnectWebviewsCreateRequestAcceptedProvidersItemNuki - ConnectWebviewsCreateRequestAcceptedProvidersItemSeamRelayAdmin - ConnectWebviewsCreateRequestAcceptedProvidersItemIgloo - ConnectWebviewsCreateRequestAcceptedProvidersItemKwikset - ConnectWebviewsCreateRequestAcceptedProvidersItemMinut - ConnectWebviewsCreateRequestAcceptedProvidersItemMy2N - ConnectWebviewsCreateRequestAcceptedProvidersItemControlbyweb - ConnectWebviewsCreateRequestAcceptedProvidersItemNest - ConnectWebviewsCreateRequestAcceptedProvidersItemIgloohome - ConnectWebviewsCreateRequestAcceptedProvidersItemEcobee - ConnectWebviewsCreateRequestAcceptedProvidersItemHubitat - ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess -) - -func (c ConnectWebviewsCreateRequestAcceptedProvidersItem) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ConnectWebviewsCreateRequestAcceptedProvidersItemAkuvox: - return "akuvox" - case ConnectWebviewsCreateRequestAcceptedProvidersItemAugust: - return "august" - case ConnectWebviewsCreateRequestAcceptedProvidersItemAvigilonAlta: - return "avigilon_alta" - case ConnectWebviewsCreateRequestAcceptedProvidersItemBrivo: - return "brivo" - case ConnectWebviewsCreateRequestAcceptedProvidersItemButterflymx: - return "butterflymx" - case ConnectWebviewsCreateRequestAcceptedProvidersItemSchlage: - return "schlage" - case ConnectWebviewsCreateRequestAcceptedProvidersItemSmartthings: - return "smartthings" - case ConnectWebviewsCreateRequestAcceptedProvidersItemYale: - return "yale" - case ConnectWebviewsCreateRequestAcceptedProvidersItemGenie: - return "genie" - case ConnectWebviewsCreateRequestAcceptedProvidersItemDoorking: - return "doorking" - case ConnectWebviewsCreateRequestAcceptedProvidersItemSalto: - return "salto" - case ConnectWebviewsCreateRequestAcceptedProvidersItemLockly: - return "lockly" - case ConnectWebviewsCreateRequestAcceptedProvidersItemTtlock: - return "ttlock" - case ConnectWebviewsCreateRequestAcceptedProvidersItemLinear: - return "linear" - case ConnectWebviewsCreateRequestAcceptedProvidersItemNoiseaware: - return "noiseaware" - case ConnectWebviewsCreateRequestAcceptedProvidersItemNuki: - return "nuki" - case ConnectWebviewsCreateRequestAcceptedProvidersItemSeamRelayAdmin: - return "seam_relay_admin" - case ConnectWebviewsCreateRequestAcceptedProvidersItemIgloo: - return "igloo" - case ConnectWebviewsCreateRequestAcceptedProvidersItemKwikset: - return "kwikset" - case ConnectWebviewsCreateRequestAcceptedProvidersItemMinut: - return "minut" - case ConnectWebviewsCreateRequestAcceptedProvidersItemMy2N: - return "my_2n" - case ConnectWebviewsCreateRequestAcceptedProvidersItemControlbyweb: - return "controlbyweb" - case ConnectWebviewsCreateRequestAcceptedProvidersItemNest: - return "nest" - case ConnectWebviewsCreateRequestAcceptedProvidersItemIgloohome: - return "igloohome" - case ConnectWebviewsCreateRequestAcceptedProvidersItemEcobee: - return "ecobee" - case ConnectWebviewsCreateRequestAcceptedProvidersItemHubitat: - return "hubitat" - case ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess: - return "yale_access" - } -} - -func (c ConnectWebviewsCreateRequestAcceptedProvidersItem) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ConnectWebviewsCreateRequestAcceptedProvidersItem) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "akuvox": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemAkuvox - *c = value - case "august": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemAugust - *c = value - case "avigilon_alta": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemAvigilonAlta - *c = value - case "brivo": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemBrivo - *c = value - case "butterflymx": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemButterflymx - *c = value - case "schlage": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemSchlage - *c = value - case "smartthings": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemSmartthings - *c = value - case "yale": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemYale - *c = value - case "genie": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemGenie - *c = value - case "doorking": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemDoorking - *c = value - case "salto": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemSalto - *c = value - case "lockly": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemLockly - *c = value - case "ttlock": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemTtlock - *c = value - case "linear": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemLinear - *c = value - case "noiseaware": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemNoiseaware - *c = value - case "nuki": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemNuki - *c = value - case "seam_relay_admin": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemSeamRelayAdmin - *c = value - case "igloo": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemIgloo - *c = value - case "kwikset": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemKwikset - *c = value - case "minut": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemMinut - *c = value - case "my_2n": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemMy2N - *c = value - case "controlbyweb": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemControlbyweb - *c = value - case "nest": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemNest - *c = value - case "igloohome": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemIgloohome - *c = value - case "ecobee": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemEcobee - *c = value - case "hubitat": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemHubitat - *c = value - case "yale_access": - value := ConnectWebviewsCreateRequestAcceptedProvidersItemYaleAccess - *c = value - } - return nil -} diff --git a/connect_webviews_create_request_custom_metadata_value.go b/connect_webviews_create_request_custom_metadata_value.go deleted file mode 100644 index ccbab4c..0000000 --- a/connect_webviews_create_request_custom_metadata_value.go +++ /dev/null @@ -1,97 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" -) - -type ConnectWebviewsCreateRequestCustomMetadataValue struct { - typeName string - String string - Double float64 - StringOptional *string - Boolean bool -} - -func NewConnectWebviewsCreateRequestCustomMetadataValueFromString(value string) *ConnectWebviewsCreateRequestCustomMetadataValue { - return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "string", String: value} -} - -func NewConnectWebviewsCreateRequestCustomMetadataValueFromDouble(value float64) *ConnectWebviewsCreateRequestCustomMetadataValue { - return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "double", Double: value} -} - -func NewConnectWebviewsCreateRequestCustomMetadataValueFromStringOptional(value *string) *ConnectWebviewsCreateRequestCustomMetadataValue { - return &ConnectWebviewsCreateRequestCustomMetadataValue{typeName: "stringOptional", StringOptional: 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 valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - c.typeName = "double" - c.Double = valueDouble - return nil - } - var valueStringOptional *string - if err := json.Unmarshal(data, &valueStringOptional); err == nil { - c.typeName = "stringOptional" - c.StringOptional = valueStringOptional - 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 "double": - return json.Marshal(c.Double) - case "stringOptional": - return json.Marshal(c.StringOptional) - case "boolean": - return json.Marshal(c.Boolean) - } -} - -type ConnectWebviewsCreateRequestCustomMetadataValueVisitor interface { - VisitString(string) error - VisitDouble(float64) error - VisitStringOptional(*string) error - VisitBoolean(bool) error -} - -func (c *ConnectWebviewsCreateRequestCustomMetadataValue) Accept(v ConnectWebviewsCreateRequestCustomMetadataValueVisitor) error { - switch c.typeName { - default: - return fmt.Errorf("invalid type %s in %T", c.typeName, c) - case "string": - return v.VisitString(c.String) - case "double": - return v.VisitDouble(c.Double) - case "stringOptional": - return v.VisitStringOptional(c.StringOptional) - case "boolean": - return v.VisitBoolean(c.Boolean) - } -} diff --git a/connect_webviews_create_request_device_selection_mode.go b/connect_webviews_create_request_device_selection_mode.go deleted file mode 100644 index 9e7c162..0000000 --- a/connect_webviews_create_request_device_selection_mode.go +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ConnectWebviewsCreateRequestDeviceSelectionMode uint8 - -const ( - ConnectWebviewsCreateRequestDeviceSelectionModeNone ConnectWebviewsCreateRequestDeviceSelectionMode = iota + 1 - ConnectWebviewsCreateRequestDeviceSelectionModeSingle - ConnectWebviewsCreateRequestDeviceSelectionModeMultiple -) - -func (c ConnectWebviewsCreateRequestDeviceSelectionMode) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ConnectWebviewsCreateRequestDeviceSelectionModeNone: - return "none" - case ConnectWebviewsCreateRequestDeviceSelectionModeSingle: - return "single" - case ConnectWebviewsCreateRequestDeviceSelectionModeMultiple: - return "multiple" - } -} - -func (c ConnectWebviewsCreateRequestDeviceSelectionMode) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ConnectWebviewsCreateRequestDeviceSelectionMode) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "none": - value := ConnectWebviewsCreateRequestDeviceSelectionModeNone - *c = value - case "single": - value := ConnectWebviewsCreateRequestDeviceSelectionModeSingle - *c = value - case "multiple": - value := ConnectWebviewsCreateRequestDeviceSelectionModeMultiple - *c = value - } - return nil -} diff --git a/connect_webviews_create_request_provider_category.go b/connect_webviews_create_request_provider_category.go deleted file mode 100644 index d142333..0000000 --- a/connect_webviews_create_request_provider_category.go +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ConnectWebviewsCreateRequestProviderCategory uint8 - -const ( - ConnectWebviewsCreateRequestProviderCategoryStable ConnectWebviewsCreateRequestProviderCategory = iota + 1 - ConnectWebviewsCreateRequestProviderCategoryConsumerSmartlocks - ConnectWebviewsCreateRequestProviderCategoryInternalBeta -) - -func (c ConnectWebviewsCreateRequestProviderCategory) String() string { - switch c { - default: - return strconv.Itoa(int(c)) - case ConnectWebviewsCreateRequestProviderCategoryStable: - return "stable" - case ConnectWebviewsCreateRequestProviderCategoryConsumerSmartlocks: - return "consumer_smartlocks" - case ConnectWebviewsCreateRequestProviderCategoryInternalBeta: - return "internal_beta" - } -} - -func (c ConnectWebviewsCreateRequestProviderCategory) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", c.String())), nil -} - -func (c *ConnectWebviewsCreateRequestProviderCategory) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "stable": - value := ConnectWebviewsCreateRequestProviderCategoryStable - *c = value - case "consumer_smartlocks": - value := ConnectWebviewsCreateRequestProviderCategoryConsumerSmartlocks - *c = value - case "internal_beta": - value := ConnectWebviewsCreateRequestProviderCategoryInternalBeta - *c = value - } - return nil -} diff --git a/connect_webviews_create_response.go b/connect_webviews_create_response.go deleted file mode 100644 index 1e29369..0000000 --- a/connect_webviews_create_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectWebviewsCreateResponse struct { - ConnectWebview *ConnectWebview `json:"connect_webview,omitempty"` - Ok bool `json:"ok"` -} diff --git a/connect_webviews_delete_request.go b/connect_webviews_delete_request.go deleted file mode 100644 index 5cb9f02..0000000 --- a/connect_webviews_delete_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ConnectWebviewsDeleteRequest is an in-lined request used by the Delete endpoint. -type ConnectWebviewsDeleteRequest struct { - ConnectWebviewId string `json:"connect_webview_id"` -} diff --git a/connect_webviews_delete_response.go b/connect_webviews_delete_response.go deleted file mode 100644 index ad96a16..0000000 --- a/connect_webviews_delete_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectWebviewsDeleteResponse struct { - Ok bool `json:"ok"` -} diff --git a/connect_webviews_get_request.go b/connect_webviews_get_request.go deleted file mode 100644 index 63d7e1f..0000000 --- a/connect_webviews_get_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ConnectWebviewsGetRequest is an in-lined request used by the Get endpoint. -type ConnectWebviewsGetRequest struct { - ConnectWebviewId string `json:"connect_webview_id"` -} diff --git a/connect_webviews_get_response.go b/connect_webviews_get_response.go deleted file mode 100644 index 7048478..0000000 --- a/connect_webviews_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectWebviewsGetResponse struct { - ConnectWebview *ConnectWebview `json:"connect_webview,omitempty"` - Ok bool `json:"ok"` -} diff --git a/connect_webviews_list_response.go b/connect_webviews_list_response.go deleted file mode 100644 index 3c6b9c8..0000000 --- a/connect_webviews_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectWebviewsListResponse struct { - ConnectWebviews []*ConnectWebview `json:"connect_webviews,omitempty"` - Ok bool `json:"ok"` -} diff --git a/connect_webviews_view_request.go b/connect_webviews_view_request.go deleted file mode 100644 index 02a7712..0000000 --- a/connect_webviews_view_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ConnectWebviewsViewRequest is an in-lined request used by the View endpoint. -type ConnectWebviewsViewRequest struct { - ConnectWebviewId string `json:"-"` - AuthToken string `json:"-"` -} diff --git a/connected_account.go b/connected_account.go deleted file mode 100644 index d3f3cba..0000000 --- a/connected_account.go +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -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 *any `json:"errors,omitempty"` - Warnings *any `json:"warnings,omitempty"` - CustomMetadata *map[string]*ConnectedAccountCustomMetadataValue `json:"custom_metadata,omitempty"` -} diff --git a/connected_account_custom_metadata_value.go b/connected_account_custom_metadata_value.go deleted file mode 100644 index 2b318fd..0000000 --- a/connected_account_custom_metadata_value.go +++ /dev/null @@ -1,97 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" -) - -type ConnectedAccountCustomMetadataValue struct { - typeName string - String string - Double float64 - Boolean bool - StringOptional *string -} - -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 { - c.typeName = "string" - 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) -} - -func (c ConnectedAccountCustomMetadataValue) 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 "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(v ConnectedAccountCustomMetadataValueVisitor) error { - switch c.typeName { - default: - return fmt.Errorf("invalid type %s in %T", c.typeName, c) - case "string": - return v.VisitString(c.String) - case "double": - return v.VisitDouble(c.Double) - case "boolean": - return v.VisitBoolean(c.Boolean) - case "stringOptional": - return v.VisitStringOptional(c.StringOptional) - } -} diff --git a/connected_account_user_identifier.go b/connected_account_user_identifier.go deleted file mode 100644 index c9ef911..0000000 --- a/connected_account_user_identifier.go +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectedAccountUserIdentifier struct { - Username *string `json:"username,omitempty"` - ApiUrl *string `json:"api_url,omitempty"` - Email *string `json:"email,omitempty"` - Phone *string `json:"phone,omitempty"` - Exclusive *bool `json:"exclusive,omitempty"` -} diff --git a/connected_accounts_get_request.go b/connected_accounts.go similarity index 76% rename from connected_accounts_get_request.go rename to connected_accounts.go index ed9b349..cdbc728 100644 --- a/connected_accounts_get_request.go +++ b/connected_accounts.go @@ -7,6 +7,14 @@ import ( fmt "fmt" ) +type ConnectedAccountsDeleteRequest struct { + ConnectedAccountId string `json:"connected_account_id"` +} + +type ConnectedAccountsDeleteResponse struct { + Ok bool `json:"ok"` +} + type ConnectedAccountsGetRequest struct { typeName string ConnectedAccountsGetRequestConnectedAccountId *ConnectedAccountsGetRequestConnectedAccountId @@ -53,13 +61,23 @@ type ConnectedAccountsGetRequestVisitor interface { VisitConnectedAccountsGetRequestEmail(*ConnectedAccountsGetRequestEmail) error } -func (c *ConnectedAccountsGetRequest) Accept(v ConnectedAccountsGetRequestVisitor) error { +func (c *ConnectedAccountsGetRequest) Accept(visitor ConnectedAccountsGetRequestVisitor) error { switch c.typeName { default: return fmt.Errorf("invalid type %s in %T", c.typeName, c) case "connectedAccountsGetRequestConnectedAccountId": - return v.VisitConnectedAccountsGetRequestConnectedAccountId(c.ConnectedAccountsGetRequestConnectedAccountId) + return visitor.VisitConnectedAccountsGetRequestConnectedAccountId(c.ConnectedAccountsGetRequestConnectedAccountId) case "connectedAccountsGetRequestEmail": - return v.VisitConnectedAccountsGetRequestEmail(c.ConnectedAccountsGetRequestEmail) + return visitor.VisitConnectedAccountsGetRequestEmail(c.ConnectedAccountsGetRequestEmail) } } + +type ConnectedAccountsGetResponse struct { + ConnectedAccount *ConnectedAccount `json:"connected_account,omitempty"` + Ok bool `json:"ok"` +} + +type ConnectedAccountsListResponse struct { + ConnectedAccounts []*ConnectedAccount `json:"connected_accounts,omitempty"` + Ok bool `json:"ok"` +} diff --git a/connected_accounts_delete_request.go b/connected_accounts_delete_request.go deleted file mode 100644 index e958018..0000000 --- a/connected_accounts_delete_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ConnectedAccountsDeleteRequest is an in-lined request used by the Delete endpoint. -type ConnectedAccountsDeleteRequest struct { - ConnectedAccountId string `json:"connected_account_id"` -} diff --git a/connected_accounts_delete_response.go b/connected_accounts_delete_response.go deleted file mode 100644 index 2d7b8ba..0000000 --- a/connected_accounts_delete_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectedAccountsDeleteResponse struct { - Ok bool `json:"ok"` -} diff --git a/connected_accounts_get_request_connected_account_id.go b/connected_accounts_get_request_connected_account_id.go deleted file mode 100644 index c572f3a..0000000 --- a/connected_accounts_get_request_connected_account_id.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectedAccountsGetRequestConnectedAccountId struct { - ConnectedAccountId string `json:"connected_account_id"` -} diff --git a/connected_accounts_get_request_email.go b/connected_accounts_get_request_email.go deleted file mode 100644 index 4fa9357..0000000 --- a/connected_accounts_get_request_email.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectedAccountsGetRequestEmail struct { - Email string `json:"email"` -} diff --git a/connected_accounts_get_response.go b/connected_accounts_get_response.go deleted file mode 100644 index 9aae909..0000000 --- a/connected_accounts_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectedAccountsGetResponse struct { - ConnectedAccount *ConnectedAccount `json:"connected_account,omitempty"` - Ok bool `json:"ok"` -} diff --git a/connected_accounts_list_response.go b/connected_accounts_list_response.go deleted file mode 100644 index be8b54d..0000000 --- a/connected_accounts_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ConnectedAccountsListResponse struct { - ConnectedAccounts []*ConnectedAccount `json:"connected_accounts,omitempty"` - Ok bool `json:"ok"` -} diff --git a/connected_accounts_client.go b/connectedaccounts/client.go similarity index 67% rename from connected_accounts_client.go rename to connectedaccounts/client.go index 27d9fff..81dcd2f 100644 --- a/connected_accounts_client.go +++ b/connectedaccounts/client.go @@ -1,42 +1,37 @@ // This file was auto-generated by Fern from our API Definition. -package api +package connectedaccounts 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 ConnectedAccountsClient interface { - Delete(ctx context.Context, request *ConnectedAccountsDeleteRequest) (*ConnectedAccountsDeleteResponse, error) - Get(ctx context.Context, request *ConnectedAccountsGetRequest) (*ConnectedAccountsGetResponse, error) - List(ctx context.Context) (*ConnectedAccountsListResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewConnectedAccountsClient(opts ...core.ClientOption) ConnectedAccountsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &connectedAccountsClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type connectedAccountsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (c *connectedAccountsClient) Delete(ctx context.Context, request *ConnectedAccountsDeleteRequest) (*ConnectedAccountsDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectedAccountsDeleteRequest) (bool, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -52,24 +47,24 @@ func (c *connectedAccountsClient) Delete(ctx context.Context, request *Connected decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectedAccountsDeleteResponse + var response *seamapigo.ConnectedAccountsDeleteResponse if err := core.DoRequest( ctx, c.httpClient, @@ -81,12 +76,12 @@ func (c *connectedAccountsClient) Delete(ctx context.Context, request *Connected c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil + return response.Ok, nil } -func (c *connectedAccountsClient) Get(ctx context.Context, request *ConnectedAccountsGetRequest) (*ConnectedAccountsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.ConnectedAccountsGetRequest) (*seamapigo.ConnectedAccount, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -102,24 +97,24 @@ func (c *connectedAccountsClient) Get(ctx context.Context, request *ConnectedAcc decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectedAccountsGetResponse + var response *seamapigo.ConnectedAccountsGetResponse if err := core.DoRequest( ctx, c.httpClient, @@ -131,12 +126,12 @@ func (c *connectedAccountsClient) Get(ctx context.Context, request *ConnectedAcc c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ConnectedAccount, nil } -func (c *connectedAccountsClient) List(ctx context.Context) (*ConnectedAccountsListResponse, error) { +func (c *Client) List(ctx context.Context) ([]*seamapigo.ConnectedAccount, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -152,24 +147,24 @@ func (c *connectedAccountsClient) List(ctx context.Context) (*ConnectedAccountsL decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectedAccountsListResponse + var response *seamapigo.ConnectedAccountsListResponse if err := core.DoRequest( ctx, c.httpClient, @@ -181,7 +176,7 @@ func (c *connectedAccountsClient) List(ctx context.Context) (*ConnectedAccountsL c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ConnectedAccounts, nil } diff --git a/connect_webviews_client.go b/connectwebviews/client.go similarity index 70% rename from connect_webviews_client.go rename to connectwebviews/client.go index 808df14..b294edc 100644 --- a/connect_webviews_client.go +++ b/connectwebviews/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package api +package connectwebviews import ( bytes "bytes" @@ -8,39 +8,32 @@ import ( json "encoding/json" errors "errors" fmt "fmt" + seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" io "io" http "net/http" url "net/url" ) -type ConnectWebviewsClient interface { - Create(ctx context.Context, request *ConnectWebviewsCreateRequest) (*ConnectWebviewsCreateResponse, error) - Delete(ctx context.Context, request *ConnectWebviewsDeleteRequest) (*ConnectWebviewsDeleteResponse, error) - Get(ctx context.Context, request *ConnectWebviewsGetRequest) (*ConnectWebviewsGetResponse, error) - List(ctx context.Context) (*ConnectWebviewsListResponse, error) - View(ctx context.Context, request *ConnectWebviewsViewRequest) error +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewConnectWebviewsClient(opts ...core.ClientOption) ConnectWebviewsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &connectWebviewsClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type connectWebviewsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (c *connectWebviewsClient) Create(ctx context.Context, request *ConnectWebviewsCreateRequest) (*ConnectWebviewsCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *seamapigo.ConnectWebviewsCreateRequest) (*seamapigo.ConnectWebview, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -56,24 +49,24 @@ func (c *connectWebviewsClient) Create(ctx context.Context, request *ConnectWebv decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectWebviewsCreateResponse + var response *seamapigo.ConnectWebviewsCreateResponse if err := core.DoRequest( ctx, c.httpClient, @@ -85,12 +78,12 @@ func (c *connectWebviewsClient) Create(ctx context.Context, request *ConnectWebv c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ConnectWebview, nil } -func (c *connectWebviewsClient) Delete(ctx context.Context, request *ConnectWebviewsDeleteRequest) (*ConnectWebviewsDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.ConnectWebviewsDeleteRequest) (bool, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -106,24 +99,24 @@ func (c *connectWebviewsClient) Delete(ctx context.Context, request *ConnectWebv decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectWebviewsDeleteResponse + var response *seamapigo.ConnectWebviewsDeleteResponse if err := core.DoRequest( ctx, c.httpClient, @@ -135,12 +128,12 @@ func (c *connectWebviewsClient) Delete(ctx context.Context, request *ConnectWebv c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil + return response.Ok, nil } -func (c *connectWebviewsClient) Get(ctx context.Context, request *ConnectWebviewsGetRequest) (*ConnectWebviewsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.ConnectWebviewsGetRequest) (*seamapigo.ConnectWebview, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -156,24 +149,24 @@ func (c *connectWebviewsClient) Get(ctx context.Context, request *ConnectWebview decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectWebviewsGetResponse + var response *seamapigo.ConnectWebviewsGetResponse if err := core.DoRequest( ctx, c.httpClient, @@ -185,12 +178,12 @@ func (c *connectWebviewsClient) Get(ctx context.Context, request *ConnectWebview c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ConnectWebview, nil } -func (c *connectWebviewsClient) List(ctx context.Context) (*ConnectWebviewsListResponse, error) { +func (c *Client) List(ctx context.Context) (*seamapigo.ConnectWebviewsListResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -206,24 +199,24 @@ func (c *connectWebviewsClient) List(ctx context.Context) (*ConnectWebviewsListR decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ConnectWebviewsListResponse + var response *seamapigo.ConnectWebviewsListResponse if err := core.DoRequest( ctx, c.httpClient, @@ -235,12 +228,12 @@ func (c *connectWebviewsClient) List(ctx context.Context) (*ConnectWebviewsListR c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (c *connectWebviewsClient) View(ctx context.Context, request *ConnectWebviewsViewRequest) error { +func (c *Client) View(ctx context.Context, request *seamapigo.ConnectWebviewsViewRequest) error { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -263,17 +256,17 @@ func (c *connectWebviewsClient) View(ctx context.Context, request *ConnectWebvie decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -285,7 +278,7 @@ func (c *connectWebviewsClient) View(ctx context.Context, request *ConnectWebvie c.httpClient, endpointURL, http.MethodGet, - request, + nil, nil, false, c.header, diff --git a/core/client_option.go b/core/client_option.go index 485cf93..ec3a02d 100644 --- a/core/client_option.go +++ b/core/client_option.go @@ -16,7 +16,7 @@ type ClientOptions struct { BaseURL string HTTPClient HTTPClient HTTPHeader http.Header - Bearer string + ApiKey string } // NewClientOptions returns a new *ClientOptions value. @@ -32,9 +32,17 @@ func NewClientOptions() *ClientOptions { // ToHeader maps the configured client options into a http.Header issued // on every request. func (c *ClientOptions) ToHeader() http.Header { - header := c.HTTPHeader.Clone() - if c.Bearer != "" { - header.Set("Authorization", "Bearer "+c.Bearer) + header := c.cloneHeader() + if c.ApiKey != "" { + header.Set("Authorization", "Bearer "+c.ApiKey) } return header } + +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", "0.2.0") + return headers +} diff --git a/core/core.go b/core/core.go index 6f7e370..745c568 100644 --- a/core/core.go +++ b/core/core.go @@ -14,29 +14,8 @@ const ( // contentType specifies the JSON Content-Type header value. contentType = "application/json" contentTypeHeader = "Content-Type" - - // fernLanguage specifies the value of the X-Fern-Language header. - fernLanguage = "go" - fernLanguageHeader = "X-Fern-Language" - - // fernSDKName specifies the name of this Fern SDK. - fernSDKName = "fern-go-sdk" - fernSDKNameHeader = "X-Fern-SDK-Name" - - // fernSDKVersion specifies the version of this Fern SDK. - fernSDKVersion = "0.0.1" - fernSDKVersionHeader = "X-Fern-SDK-Version" ) -// fernHeaders specifies all of the standard Fern headers in -// a set so that they're easier to access and reference. -var fernHeaders = map[string]string{ - contentTypeHeader: contentType, - fernLanguageHeader: fernLanguage, - fernSDKNameHeader: fernSDKName, - fernSDKVersionHeader: fernSDKVersion, -} - // HTTPClient is an interface for a subset of the *http.Client. type HTTPClient interface { Do(*http.Request) (*http.Response, error) @@ -81,17 +60,21 @@ func (a *APIError) Error() string { return fmt.Sprintf("%d: %s", a.StatusCode, a.err.Error()) } +// ErrorDecoder decodes *http.Response errors and returns a +// typed API error (e.g. *APIError). +type ErrorDecoder func(statusCode int, body io.Reader) error + // DoRequest issues a JSON request to the given url. func DoRequest( ctx context.Context, client HTTPClient, url string, method string, - request any, - response any, + request interface{}, + response interface{}, responseIsOptional bool, endpointHeaders http.Header, - errorDecoder func(int, io.Reader) error, + errorDecoder ErrorDecoder, ) error { var requestBody io.Reader if request != nil { @@ -188,9 +171,7 @@ func newRequest( return nil, err } req = req.WithContext(ctx) - for name, value := range fernHeaders { - req.Header.Set(name, value) - } + req.Header.Set(contentTypeHeader, contentType) for name, values := range endpointHeaders { req.Header[name] = values } diff --git a/core/core_test.go b/core/core_test.go new file mode 100644 index 0000000..e76344f --- /dev/null +++ b/core/core_test.go @@ -0,0 +1,217 @@ +package core + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/http/httptest" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestCase represents a single test case. +type TestCase struct { + description string + + // Server-side assertions. + giveMethod string + giveResponseIsOptional bool + giveHeader http.Header + giveErrorDecoder ErrorDecoder + giveRequest *Request + + // Client-side assertions. + wantResponse *Response + wantError error +} + +// Request a simple request body. +type Request struct { + Id string `json:"id"` +} + +// Response a simple response body. +type Response struct { + Id string `json:"id"` +} + +// NotFoundError represents a 404. +type NotFoundError struct { + *APIError + + Message string `json:"message"` +} + +func TestDoRequest(t *testing.T) { + tests := []*TestCase{ + { + description: "GET success", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + }, + }, + { + description: "GET not found", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: &Request{ + Id: strconv.Itoa(http.StatusNotFound), + }, + giveErrorDecoder: newTestErrorDecoder(t), + wantError: &NotFoundError{ + APIError: NewAPIError( + http.StatusNotFound, + errors.New(`{"message":"ID \"404\" not found"}`), + ), + }, + }, + { + description: "POST optional response", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + giveResponseIsOptional: true, + }, + { + description: "POST API error", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: &Request{ + Id: strconv.Itoa(http.StatusInternalServerError), + }, + wantError: NewAPIError( + http.StatusInternalServerError, + errors.New("failed to process request"), + ), + }, + } + for _, test := range tests { + t.Run(test.description, func(t *testing.T) { + var ( + server = newTestServer(t, test) + client = server.Client() + ) + var response *Response + err := DoRequest( + context.Background(), + client, + server.URL, + test.giveMethod, + test.giveRequest, + &response, + test.giveResponseIsOptional, + test.giveHeader, + test.giveErrorDecoder, + ) + if test.wantError != nil { + assert.EqualError(t, err, test.wantError.Error()) + return + } + require.NoError(t, err) + assert.Equal(t, test.wantResponse, response) + }) + } +} + +// newTestServer returns a new *httptest.Server configured with the +// given test parameters. +func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { + return httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, tc.giveMethod, r.Method) + assert.Equal(t, contentType, r.Header.Get(contentTypeHeader)) + for header, value := range tc.giveHeader { + assert.Equal(t, value, r.Header.Values(header)) + } + + bytes, err := io.ReadAll(r.Body) + require.NoError(t, err) + + request := new(Request) + require.NoError(t, json.Unmarshal(bytes, request)) + + switch request.Id { + case strconv.Itoa(http.StatusNotFound): + notFoundError := &NotFoundError{ + APIError: &APIError{ + StatusCode: http.StatusNotFound, + }, + Message: fmt.Sprintf("ID %q not found", request.Id), + } + bytes, err = json.Marshal(notFoundError) + require.NoError(t, err) + + w.WriteHeader(http.StatusNotFound) + _, err = w.Write(bytes) + require.NoError(t, err) + return + + case strconv.Itoa(http.StatusInternalServerError): + w.WriteHeader(http.StatusInternalServerError) + _, err = w.Write([]byte("failed to process request")) + require.NoError(t, err) + return + } + + if tc.giveResponseIsOptional { + w.WriteHeader(http.StatusOK) + return + } + + response := &Response{ + Id: request.Id, + } + bytes, err = json.Marshal(response) + require.NoError(t, err) + + _, err = w.Write(bytes) + require.NoError(t, err) + }, + ), + ) +} + +// newTestErrorDecoder returns an error decoder suitable for tests. +func newTestErrorDecoder(t *testing.T) func(int, io.Reader) error { + return func(statusCode int, body io.Reader) error { + raw, err := io.ReadAll(body) + require.NoError(t, err) + + var ( + apiError = NewAPIError(statusCode, errors.New(string(raw))) + decoder = json.NewDecoder(bytes.NewReader(raw)) + ) + switch statusCode { + case 404: + value := new(NotFoundError) + value.APIError = apiError + require.NoError(t, decoder.Decode(value)) + + return value + } + return apiError + } +} diff --git a/current_climate_setting.go b/current_climate_setting.go deleted file mode 100644 index eab8aab..0000000 --- a/current_climate_setting.go +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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"` -} diff --git a/device.go b/device.go deleted file mode 100644 index 03bb40b..0000000 --- a/device.go +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -type Device struct { - DeviceId string `json:"device_id"` - DeviceType DeviceType `json:"device_type,omitempty"` - CapabilitiesSupported []DeviceCapabilitiesSupportedItem `json:"capabilities_supported,omitempty"` - Properties *DeviceProperties `json:"properties,omitempty"` - Location *any `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 string `json:"is_managed"` -} diff --git a/device_capabilities_supported_item.go b/device_capabilities_supported_item.go deleted file mode 100644 index b5d4f93..0000000 --- a/device_capabilities_supported_item.go +++ /dev/null @@ -1,65 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type DeviceCapabilitiesSupportedItem uint8 - -const ( - DeviceCapabilitiesSupportedItemAccessCode DeviceCapabilitiesSupportedItem = iota + 1 - DeviceCapabilitiesSupportedItemLock - DeviceCapabilitiesSupportedItemNoiseDetection - DeviceCapabilitiesSupportedItemThermostat - DeviceCapabilitiesSupportedItemBattery -) - -func (d DeviceCapabilitiesSupportedItem) String() string { - switch d { - default: - return strconv.Itoa(int(d)) - case DeviceCapabilitiesSupportedItemAccessCode: - return "access_code" - case DeviceCapabilitiesSupportedItemLock: - return "lock" - case DeviceCapabilitiesSupportedItemNoiseDetection: - return "noise_detection" - case DeviceCapabilitiesSupportedItemThermostat: - return "thermostat" - case DeviceCapabilitiesSupportedItemBattery: - return "battery" - } -} - -func (d DeviceCapabilitiesSupportedItem) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", d.String())), nil -} - -func (d *DeviceCapabilitiesSupportedItem) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "access_code": - value := DeviceCapabilitiesSupportedItemAccessCode - *d = value - case "lock": - value := DeviceCapabilitiesSupportedItemLock - *d = value - case "noise_detection": - value := DeviceCapabilitiesSupportedItemNoiseDetection - *d = value - case "thermostat": - value := DeviceCapabilitiesSupportedItemThermostat - *d = value - case "battery": - value := DeviceCapabilitiesSupportedItemBattery - *d = value - } - return nil -} diff --git a/device_errors_item.go b/device_errors_item.go deleted file mode 100644 index 00eaea4..0000000 --- a/device_errors_item.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DeviceErrorsItem struct { - ErrorCode string `json:"error_code"` - Message string `json:"message"` -} diff --git a/device_properties.go b/device_properties.go deleted file mode 100644 index d11e86b..0000000 --- a/device_properties.go +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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 any `json:"smartthings_metadata,omitempty"` - CurrentClimateSetting *CurrentClimateSetting `json:"current_climate_setting,omitempty"` -} diff --git a/device_properties_model.go b/device_properties_model.go deleted file mode 100644 index 40501b9..0000000 --- a/device_properties_model.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicePropertiesModel struct { - DisplayName string `json:"display_name"` -} diff --git a/device_type.go b/device_type.go deleted file mode 100644 index 87eac2f..0000000 --- a/device_type.go +++ /dev/null @@ -1,185 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type DeviceType uint8 - -const ( - DeviceTypeAkuvoxLock DeviceType = iota + 1 - DeviceTypeAugustLock - DeviceTypeBrivoAccessPoint - DeviceTypeButterflymxPanel - DeviceTypeDoorkingLock - DeviceTypeGenieDoor - DeviceTypeIglooLock - DeviceTypeLinearLock - DeviceTypeLocklyLock - DeviceTypeKwiksetLock - DeviceTypeNukiLock - DeviceTypeSaltoLock - DeviceTypeSchlageLock - DeviceTypeSeamRelay - DeviceTypeSmartthingsLock - DeviceTypeYaleLock - DeviceTypeTwoNIntercom - DeviceTypeControlbywebDevice - DeviceTypeTtlockLock - DeviceTypeIgloohomeLock - DeviceTypeHubitatLock - DeviceTypeNoiseawareActivityZone - DeviceTypeMinutSensor - DeviceTypeEcobeeThermostat - DeviceTypeNestThermostat -) - -func (d DeviceType) String() string { - switch d { - default: - return strconv.Itoa(int(d)) - case DeviceTypeAkuvoxLock: - return "akuvox_lock" - case DeviceTypeAugustLock: - return "august_lock" - case DeviceTypeBrivoAccessPoint: - return "brivo_access_point" - case DeviceTypeButterflymxPanel: - return "butterflymx_panel" - case DeviceTypeDoorkingLock: - return "doorking_lock" - case DeviceTypeGenieDoor: - return "genie_door" - case DeviceTypeIglooLock: - return "igloo_lock" - case DeviceTypeLinearLock: - return "linear_lock" - case DeviceTypeLocklyLock: - return "lockly_lock" - case DeviceTypeKwiksetLock: - return "kwikset_lock" - case DeviceTypeNukiLock: - return "nuki_lock" - case DeviceTypeSaltoLock: - return "salto_lock" - case DeviceTypeSchlageLock: - return "schlage_lock" - case DeviceTypeSeamRelay: - return "seam_relay" - case DeviceTypeSmartthingsLock: - return "smartthings_lock" - case DeviceTypeYaleLock: - return "yale_lock" - case DeviceTypeTwoNIntercom: - return "two_n_intercom" - case DeviceTypeControlbywebDevice: - return "controlbyweb_device" - case DeviceTypeTtlockLock: - return "ttlock_lock" - case DeviceTypeIgloohomeLock: - return "igloohome_lock" - case DeviceTypeHubitatLock: - return "hubitat_lock" - case DeviceTypeNoiseawareActivityZone: - return "noiseaware_activity_zone" - case DeviceTypeMinutSensor: - return "minut_sensor" - case DeviceTypeEcobeeThermostat: - return "ecobee_thermostat" - case DeviceTypeNestThermostat: - return "nest_thermostat" - } -} - -func (d DeviceType) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", d.String())), nil -} - -func (d *DeviceType) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "akuvox_lock": - value := DeviceTypeAkuvoxLock - *d = value - case "august_lock": - value := DeviceTypeAugustLock - *d = value - case "brivo_access_point": - value := DeviceTypeBrivoAccessPoint - *d = value - case "butterflymx_panel": - value := DeviceTypeButterflymxPanel - *d = value - case "doorking_lock": - value := DeviceTypeDoorkingLock - *d = value - case "genie_door": - value := DeviceTypeGenieDoor - *d = value - case "igloo_lock": - value := DeviceTypeIglooLock - *d = value - case "linear_lock": - value := DeviceTypeLinearLock - *d = value - case "lockly_lock": - value := DeviceTypeLocklyLock - *d = value - case "kwikset_lock": - value := DeviceTypeKwiksetLock - *d = value - case "nuki_lock": - value := DeviceTypeNukiLock - *d = value - case "salto_lock": - value := DeviceTypeSaltoLock - *d = value - case "schlage_lock": - value := DeviceTypeSchlageLock - *d = value - case "seam_relay": - value := DeviceTypeSeamRelay - *d = value - case "smartthings_lock": - value := DeviceTypeSmartthingsLock - *d = value - case "yale_lock": - value := DeviceTypeYaleLock - *d = value - case "two_n_intercom": - value := DeviceTypeTwoNIntercom - *d = value - case "controlbyweb_device": - value := DeviceTypeControlbywebDevice - *d = value - case "ttlock_lock": - value := DeviceTypeTtlockLock - *d = value - case "igloohome_lock": - value := DeviceTypeIgloohomeLock - *d = value - case "hubitat_lock": - value := DeviceTypeHubitatLock - *d = value - case "noiseaware_activity_zone": - value := DeviceTypeNoiseawareActivityZone - *d = value - case "minut_sensor": - value := DeviceTypeMinutSensor - *d = value - case "ecobee_thermostat": - value := DeviceTypeEcobeeThermostat - *d = value - case "nest_thermostat": - value := DeviceTypeNestThermostat - *d = value - } - return nil -} diff --git a/device_warnings_item.go b/device_warnings_item.go deleted file mode 100644 index 7a04b6a..0000000 --- a/device_warnings_item.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DeviceWarningsItem struct { - WarningCode string `json:"warning_code"` - Message string `json:"message"` -} diff --git a/devices.go b/devices.go new file mode 100644 index 0000000..edb8eeb --- /dev/null +++ b/devices.go @@ -0,0 +1,93 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + fmt "fmt" + time "time" +) + +type DevicesDeleteRequest struct { + DeviceId string `json:"device_id"` +} + +type DevicesGetRequest struct { + DeviceId *string `json:"device_id,omitempty"` + Name *string `json:"name,omitempty"` +} + +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"` +} + +type DevicesListDeviceProvidersRequest struct { + ProviderCategory *DevicesListDeviceProvidersRequestProviderCategory `json:"provider_category,omitempty"` +} + +type DevicesDeleteResponse struct { + Ok bool `json:"ok"` +} + +type DevicesGetResponse struct { + Device *Device `json:"device,omitempty"` + Ok bool `json:"ok"` +} + +type DevicesListDeviceProvidersRequestProviderCategory string + +const ( + DevicesListDeviceProvidersRequestProviderCategoryStable DevicesListDeviceProvidersRequestProviderCategory = "stable" + DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks DevicesListDeviceProvidersRequestProviderCategory = "consumer_smartlocks" +) + +func NewDevicesListDeviceProvidersRequestProviderCategoryFromString(s string) (DevicesListDeviceProvidersRequestProviderCategory, error) { + switch s { + case "stable": + return DevicesListDeviceProvidersRequestProviderCategoryStable, nil + case "consumer_smartlocks": + return DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks, nil + } + var t DevicesListDeviceProvidersRequestProviderCategory + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DevicesListDeviceProvidersRequestProviderCategory) Ptr() *DevicesListDeviceProvidersRequestProviderCategory { + return &d +} + +type DevicesListDeviceProvidersResponse struct { + DeviceProviders []*DevicesListDeviceProvidersResponseDeviceProvidersItem `json:"device_providers,omitempty"` + Ok bool `json:"ok"` +} + +type DevicesListResponse struct { + Devices []*Device `json:"devices,omitempty"` + Ok bool `json:"ok"` +} + +type DevicesUpdateRequestLocation struct { +} + +type DevicesUpdateRequestProperties struct { + Name *string `json:"name,omitempty"` +} + +type DevicesUpdateResponse struct { + Ok bool `json:"ok"` +} + +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.go b/devices/client/client.go similarity index 58% rename from devices_client.go rename to devices/client/client.go index 84fa0e4..5581e21 100644 --- a/devices_client.go +++ b/devices/client/client.go @@ -1,50 +1,44 @@ // This file was auto-generated by Fern from our API Definition. -package api +package client import ( bytes "bytes" context "context" json "encoding/json" errors "errors" + seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + unmanaged "github.com/seamapi/go/devices/unmanaged" io "io" http "net/http" ) -type DevicesClient interface { - Delete(ctx context.Context, request *DevicesDeleteRequest) (*DevicesDeleteResponse, error) - Get(ctx context.Context, request *DevicesGetRequest) (*DevicesGetResponse, error) - List(ctx context.Context, request *DevicesListRequest) (*DevicesListResponse, error) - ListDeviceProviders(ctx context.Context, request *DevicesListDeviceProvidersRequest) (*DevicesListDeviceProvidersResponse, error) - Update(ctx context.Context, request *DevicesUpdateRequest) (*DevicesUpdateResponse, error) - Unmanaged() UnmanagedClient +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header + + Unmanaged *unmanaged.Client } -func NewDevicesClient(opts ...core.ClientOption) DevicesClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &devicesClient{ - baseURL: options.BaseURL, - httpClient: options.HTTPClient, - header: options.ToHeader(), - unmanagedClient: NewUnmanagedClient(opts...), + return &Client{ + baseURL: options.BaseURL, + httpClient: options.HTTPClient, + header: options.ToHeader(), + Unmanaged: unmanaged.NewClient(opts...), } } -type devicesClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header - unmanagedClient UnmanagedClient -} - -func (d *devicesClient) Delete(ctx context.Context, request *DevicesDeleteRequest) (*DevicesDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.DevicesDeleteRequest) (bool, error) { baseURL := "https://connect.getseam.com" - if d.baseURL != "" { - baseURL = d.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/delete" @@ -57,44 +51,44 @@ func (d *devicesClient) Delete(ctx context.Context, request *DevicesDeleteReques decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *DevicesDeleteResponse + var response *seamapigo.DevicesDeleteResponse if err := core.DoRequest( ctx, - d.httpClient, + c.httpClient, endpointURL, http.MethodDelete, request, &response, false, - d.header, + c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil + return response.Ok, nil } -func (d *devicesClient) Get(ctx context.Context, request *DevicesGetRequest) (*DevicesGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.DevicesGetRequest) (*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" - if d.baseURL != "" { - baseURL = d.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/get" @@ -107,44 +101,44 @@ func (d *devicesClient) Get(ctx context.Context, request *DevicesGetRequest) (*D decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *DevicesGetResponse + var response *seamapigo.DevicesGetResponse if err := core.DoRequest( ctx, - d.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - d.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Device, nil } -func (d *devicesClient) List(ctx context.Context, request *DevicesListRequest) (*DevicesListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.DevicesListRequest) ([]*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" - if d.baseURL != "" { - baseURL = d.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/list" @@ -157,44 +151,44 @@ func (d *devicesClient) List(ctx context.Context, request *DevicesListRequest) ( decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *DevicesListResponse + var response *seamapigo.DevicesListResponse if err := core.DoRequest( ctx, - d.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - d.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Devices, nil } -func (d *devicesClient) ListDeviceProviders(ctx context.Context, request *DevicesListDeviceProvidersRequest) (*DevicesListDeviceProvidersResponse, error) { +func (c *Client) ListDeviceProviders(ctx context.Context, request *seamapigo.DevicesListDeviceProvidersRequest) ([]*seamapigo.DevicesListDeviceProvidersResponseDeviceProvidersItem, error) { baseURL := "https://connect.getseam.com" - if d.baseURL != "" { - baseURL = d.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/list_device_providers" @@ -207,44 +201,44 @@ func (d *devicesClient) ListDeviceProviders(ctx context.Context, request *Device decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *DevicesListDeviceProvidersResponse + var response *seamapigo.DevicesListDeviceProvidersResponse if err := core.DoRequest( ctx, - d.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - d.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.DeviceProviders, nil } -func (d *devicesClient) Update(ctx context.Context, request *DevicesUpdateRequest) (*DevicesUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *seamapigo.DevicesUpdateRequest) (bool, error) { baseURL := "https://connect.getseam.com" - if d.baseURL != "" { - baseURL = d.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/update" @@ -257,40 +251,36 @@ func (d *devicesClient) Update(ctx context.Context, request *DevicesUpdateReques decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *DevicesUpdateResponse + var response *seamapigo.DevicesUpdateResponse if err := core.DoRequest( ctx, - d.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - d.header, + c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil -} - -func (d *devicesClient) Unmanaged() UnmanagedClient { - return d.unmanagedClient + return response.Ok, nil } diff --git a/devices/unmanaged_list_request.go b/devices/unmanaged.go similarity index 69% rename from devices/unmanaged_list_request.go rename to devices/unmanaged.go index 1a32d10..2edfaab 100644 --- a/devices/unmanaged_list_request.go +++ b/devices/unmanaged.go @@ -7,15 +7,19 @@ import ( time "time" ) -// UnmanagedListRequest is an in-lined request used by the List endpoint. type UnmanagedListRequest struct { ConnectedAccountId *string `json:"connected_account_id,omitempty"` - ConnectedAccountIds *[]string `json:"connected_account_ids,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"` + DeviceTypes []seamapigo.DeviceType `json:"device_types,omitempty"` Manufacturer *seamapigo.Manufacturer `json:"manufacturer,omitempty"` - DeviceIds *[]string `json:"device_ids,omitempty"` + DeviceIds []string `json:"device_ids,omitempty"` Limit *float64 `json:"limit,omitempty"` CreatedBefore *time.Time `json:"created_before,omitempty"` } + +type UnmanagedUpdateRequest struct { + DeviceId string `json:"device_id"` + IsManaged string `json:"is_managed"` +} diff --git a/devices/unmanaged_client.go b/devices/unmanaged/client.go similarity index 67% rename from devices/unmanaged_client.go rename to devices/unmanaged/client.go index 9475d70..bb9b839 100644 --- a/devices/unmanaged_client.go +++ b/devices/unmanaged/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package devices +package unmanaged import ( bytes "bytes" @@ -9,37 +9,33 @@ import ( errors "errors" seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + devices "github.com/seamapi/go/devices" io "io" http "net/http" ) -type UnmanagedClient interface { - List(ctx context.Context, request *UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) - Update(ctx context.Context, request *UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewUnmanagedClient(opts ...core.ClientOption) UnmanagedClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &unmanagedClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type unmanagedClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (u *unmanagedClient) List(ctx context.Context, request *UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) { +func (c *Client) List(ctx context.Context, request *devices.UnmanagedListRequest) (*seamapigo.UnmanagedListResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/unmanaged/list" @@ -52,17 +48,17 @@ func (u *unmanagedClient) List(ctx context.Context, request *UnmanagedListReques decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -72,24 +68,24 @@ func (u *unmanagedClient) List(ctx context.Context, request *UnmanagedListReques var response *seamapigo.UnmanagedListResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (u *unmanagedClient) Update(ctx context.Context, request *UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *devices.UnmanagedUpdateRequest) (*seamapigo.UnmanagedUpdateResponse, error) { baseURL := "https://connect.getseam.com" - if u.baseURL != "" { - baseURL = u.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "devices/unmanaged/update" @@ -102,17 +98,17 @@ func (u *unmanagedClient) Update(ctx context.Context, request *UnmanagedUpdateRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -122,16 +118,16 @@ func (u *unmanagedClient) Update(ctx context.Context, request *UnmanagedUpdateRe var response *seamapigo.UnmanagedUpdateResponse if err := core.DoRequest( ctx, - u.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - u.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/devices/unmanaged_update_request.go b/devices/unmanaged_update_request.go deleted file mode 100644 index 1dbda61..0000000 --- a/devices/unmanaged_update_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package devices - -// UnmanagedUpdateRequest is an in-lined request used by the Update endpoint. -type UnmanagedUpdateRequest struct { - DeviceId string `json:"device_id"` - IsManaged string `json:"is_managed"` -} diff --git a/devices_delete_request.go b/devices_delete_request.go deleted file mode 100644 index 414e3fc..0000000 --- a/devices_delete_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// DevicesDeleteRequest is an in-lined request used by the Delete endpoint. -type DevicesDeleteRequest struct { - DeviceId string `json:"device_id"` -} diff --git a/devices_delete_response.go b/devices_delete_response.go deleted file mode 100644 index c6aeae8..0000000 --- a/devices_delete_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesDeleteResponse struct { - Ok bool `json:"ok"` -} diff --git a/devices_get_request.go b/devices_get_request.go deleted file mode 100644 index 78d56cb..0000000 --- a/devices_get_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// DevicesGetRequest is an in-lined request used by the Get endpoint. -type DevicesGetRequest struct { - DeviceId *string `json:"device_id,omitempty"` - Name *string `json:"name,omitempty"` -} diff --git a/devices_get_response.go b/devices_get_response.go deleted file mode 100644 index 682e7d6..0000000 --- a/devices_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesGetResponse struct { - Device *Device `json:"device,omitempty"` - Ok bool `json:"ok"` -} diff --git a/devices_list_device_providers_request.go b/devices_list_device_providers_request.go deleted file mode 100644 index 0695e79..0000000 --- a/devices_list_device_providers_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// DevicesListDeviceProvidersRequest is an in-lined request used by the ListDeviceProviders endpoint. -type DevicesListDeviceProvidersRequest struct { - ProviderCategory *DevicesListDeviceProvidersRequestProviderCategory `json:"provider_category,omitempty"` -} diff --git a/devices_list_device_providers_request_provider_category.go b/devices_list_device_providers_request_provider_category.go deleted file mode 100644 index 411ceb3..0000000 --- a/devices_list_device_providers_request_provider_category.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type DevicesListDeviceProvidersRequestProviderCategory uint8 - -const ( - DevicesListDeviceProvidersRequestProviderCategoryStable DevicesListDeviceProvidersRequestProviderCategory = iota + 1 - DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks -) - -func (d DevicesListDeviceProvidersRequestProviderCategory) String() string { - switch d { - default: - return strconv.Itoa(int(d)) - case DevicesListDeviceProvidersRequestProviderCategoryStable: - return "stable" - case DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks: - return "consumer_smartlocks" - } -} - -func (d DevicesListDeviceProvidersRequestProviderCategory) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", d.String())), nil -} - -func (d *DevicesListDeviceProvidersRequestProviderCategory) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "stable": - value := DevicesListDeviceProvidersRequestProviderCategoryStable - *d = value - case "consumer_smartlocks": - value := DevicesListDeviceProvidersRequestProviderCategoryConsumerSmartlocks - *d = value - } - return nil -} diff --git a/devices_list_device_providers_response.go b/devices_list_device_providers_response.go deleted file mode 100644 index e0743b6..0000000 --- a/devices_list_device_providers_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesListDeviceProvidersResponse struct { - DeviceProviders []*DevicesListDeviceProvidersResponseDeviceProvidersItem `json:"device_providers,omitempty"` - Ok bool `json:"ok"` -} diff --git a/devices_list_device_providers_response_device_providers_item.go b/devices_list_device_providers_response_device_providers_item.go deleted file mode 100644 index 539fe52..0000000 --- a/devices_list_device_providers_response_device_providers_item.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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"` -} diff --git a/devices_list_device_providers_response_device_providers_item_provider_categories_item.go b/devices_list_device_providers_response_device_providers_item_provider_categories_item.go deleted file mode 100644 index 6e33f90..0000000 --- a/devices_list_device_providers_response_device_providers_item_provider_categories_item.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem uint8 - -const ( - DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = iota + 1 - DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks -) - -func (d DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem) String() string { - switch d { - default: - return strconv.Itoa(int(d)) - case DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable: - return "stable" - case DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks: - return "consumer_smartlocks" - } -} - -func (d DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", d.String())), nil -} - -func (d *DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "stable": - value := DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable - *d = value - case "consumer_smartlocks": - value := DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks - *d = value - } - return nil -} diff --git a/devices_list_request.go b/devices_list_request.go deleted file mode 100644 index 2f65a97..0000000 --- a/devices_list_request.go +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -// DevicesListRequest is an in-lined request used by the List endpoint. -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"` -} diff --git a/devices_list_response.go b/devices_list_response.go deleted file mode 100644 index 3bd14e1..0000000 --- a/devices_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesListResponse struct { - Devices []*Device `json:"devices,omitempty"` - Ok bool `json:"ok"` -} diff --git a/devices_update_request.go b/devices_update_request.go deleted file mode 100644 index b18197a..0000000 --- a/devices_update_request.go +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// DevicesUpdateRequest is an in-lined request used by the Update endpoint. -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_update_request_location.go b/devices_update_request_location.go deleted file mode 100644 index ba00712..0000000 --- a/devices_update_request_location.go +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesUpdateRequestLocation struct { -} diff --git a/devices_update_request_properties.go b/devices_update_request_properties.go deleted file mode 100644 index c75ea93..0000000 --- a/devices_update_request_properties.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesUpdateRequestProperties struct { - Name *string `json:"name,omitempty"` -} diff --git a/devices_update_response.go b/devices_update_response.go deleted file mode 100644 index f1dec1c..0000000 --- a/devices_update_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type DevicesUpdateResponse struct { - Ok bool `json:"ok"` -} diff --git a/environments.go b/environments.go index 52e3770..1ffc580 100644 --- a/environments.go +++ b/environments.go @@ -3,7 +3,7 @@ package api // Environments defines all of the API environments. -// These values can be used with the ClientWithBaseURL +// These values can be used with the WithBaseURL // ClientOption to override the client's default environment, // if any. var Environments = struct { diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..26ee4dd --- /dev/null +++ b/errors.go @@ -0,0 +1,54 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + core "github.com/seamapi/go/core" +) + +type BadRequestError struct { + *core.APIError + Body interface{} +} + +func (b *BadRequestError) UnmarshalJSON(data []byte) error { + var body interface{} + if err := json.Unmarshal(data, &body); err != nil { + return err + } + b.StatusCode = 400 + b.Body = body + return nil +} + +func (b *BadRequestError) MarshalJSON() ([]byte, error) { + return json.Marshal(b.Body) +} + +func (b *BadRequestError) Unwrap() error { + return b.APIError +} + +type UnauthorizedError struct { + *core.APIError + Body interface{} +} + +func (u *UnauthorizedError) UnmarshalJSON(data []byte) error { + var body interface{} + if err := json.Unmarshal(data, &body); err != nil { + return err + } + u.StatusCode = 401 + u.Body = body + return nil +} + +func (u *UnauthorizedError) MarshalJSON() ([]byte, error) { + return json.Marshal(u.Body) +} + +func (u *UnauthorizedError) Unwrap() error { + return u.APIError +} diff --git a/event.go b/event.go deleted file mode 100644 index 5b817c3..0000000 --- a/event.go +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -type Event struct { - EventId string `json:"event_id"` - DeviceId *string `json:"device_id,omitempty"` - EventType string `json:"event_type"` - WorkspaceId string `json:"workspace_id"` - CreatedAt time.Time `json:"created_at"` - OccurredAt time.Time `json:"occurred_at"` -} diff --git a/events.go b/events.go new file mode 100644 index 0000000..4649ced --- /dev/null +++ b/events.go @@ -0,0 +1,320 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + time "time" +) + +type EventsGetRequest struct { + EventId *string `json:"event_id,omitempty"` + EventType *string `json:"event_type,omitempty"` + DeviceId *string `json:"device_id,omitempty"` +} + +type EventsListRequest struct { + Since *string `json:"since,omitempty"` + Between []*EventsListRequestBetweenItem `json:"between,omitempty"` + DeviceId *string `json:"device_id,omitempty"` + DeviceIds []string `json:"device_ids,omitempty"` + AccessCodeId *string `json:"access_code_id,omitempty"` + AccessCodeIds []string `json:"access_code_ids,omitempty"` + EventType *EventsListRequestEventType `json:"event_type,omitempty"` + EventTypes []EventsListRequestEventTypesItem `json:"event_types,omitempty"` + ConnectedAccountId *string `json:"connected_account_id,omitempty"` +} + +type EventsGetResponse struct { + Event *Event `json:"event,omitempty"` + Message *string `json:"message,omitempty"` + Ok bool `json:"ok"` +} + +type EventsListRequestBetweenItem struct { + typeName string + String string + DateTime time.Time +} + +func NewEventsListRequestBetweenItemFromString(value string) *EventsListRequestBetweenItem { + return &EventsListRequestBetweenItem{typeName: "string", String: value} +} + +func NewEventsListRequestBetweenItemFromDateTime(value time.Time) *EventsListRequestBetweenItem { + return &EventsListRequestBetweenItem{typeName: "dateTime", DateTime: value} +} + +func (e *EventsListRequestBetweenItem) UnmarshalJSON(data []byte) error { + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + e.typeName = "string" + e.String = valueString + return nil + } + var valueDateTime time.Time + if err := json.Unmarshal(data, &valueDateTime); err == nil { + e.typeName = "dateTime" + e.DateTime = valueDateTime + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, e) +} + +func (e EventsListRequestBetweenItem) MarshalJSON() ([]byte, error) { + switch e.typeName { + default: + return nil, fmt.Errorf("invalid type %s in %T", e.typeName, e) + case "string": + return json.Marshal(e.String) + case "dateTime": + return json.Marshal(e.DateTime) + } +} + +type EventsListRequestBetweenItemVisitor interface { + VisitString(string) error + VisitDateTime(time.Time) error +} + +func (e *EventsListRequestBetweenItem) Accept(visitor EventsListRequestBetweenItemVisitor) error { + switch e.typeName { + default: + return fmt.Errorf("invalid type %s in %T", e.typeName, e) + case "string": + return visitor.VisitString(e.String) + case "dateTime": + return visitor.VisitDateTime(e.DateTime) + } +} + +type EventsListRequestEventType string + +const ( + EventsListRequestEventTypeDeviceConnected EventsListRequestEventType = "device.connected" + EventsListRequestEventTypeDeviceUnmanagedConnected EventsListRequestEventType = "device.unmanaged.connected" + EventsListRequestEventTypeDeviceDisconnected EventsListRequestEventType = "device.disconnected" + EventsListRequestEventTypeDeviceUnmanagedDisconnected EventsListRequestEventType = "device.unmanaged.disconnected" + EventsListRequestEventTypeDeviceConvertedToUnmanaged EventsListRequestEventType = "device.converted_to_unmanaged" + EventsListRequestEventTypeDeviceUnmanagedConvertedToManaged EventsListRequestEventType = "device.unmanaged.converted_to_managed" + EventsListRequestEventTypeDeviceRemoved EventsListRequestEventType = "device.removed" + EventsListRequestEventTypeDeviceTampered EventsListRequestEventType = "device.tampered" + EventsListRequestEventTypeDeviceLowBattery EventsListRequestEventType = "device.low_battery" + EventsListRequestEventTypeDeviceBatteryStatusChanged EventsListRequestEventType = "device.battery_status_changed" + EventsListRequestEventTypeAccessCodeCreated EventsListRequestEventType = "access_code.created" + EventsListRequestEventTypeAccessCodeChanged EventsListRequestEventType = "access_code.changed" + EventsListRequestEventTypeAccessCodeScheduledOnDevice EventsListRequestEventType = "access_code.scheduled_on_device" + EventsListRequestEventTypeAccessCodeSetOnDevice EventsListRequestEventType = "access_code.set_on_device" + EventsListRequestEventTypeAccessCodeDeleted EventsListRequestEventType = "access_code.deleted" + EventsListRequestEventTypeAccessCodeRemovedFromDevice EventsListRequestEventType = "access_code.removed_from_device" + EventsListRequestEventTypeAccessCodeFailedToSetOnDevice EventsListRequestEventType = "access_code.failed_to_set_on_device" + 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" + EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged EventsListRequestEventType = "access_code.unmanaged.converted_to_managed" + EventsListRequestEventTypeAccessCodeUnmanagedFailedToConvertToManaged EventsListRequestEventType = "access_code.unmanaged.failed_to_convert_to_managed" + EventsListRequestEventTypeAccessCodeUnmanagedCreated EventsListRequestEventType = "access_code.unmanaged.created" + EventsListRequestEventTypeAccessCodeUnmanagedRemoved EventsListRequestEventType = "access_code.unmanaged.removed" + EventsListRequestEventTypeLockLocked EventsListRequestEventType = "lock.locked" + EventsListRequestEventTypeLockUnlocked EventsListRequestEventType = "lock.unlocked" + EventsListRequestEventTypeConnectedAccountConnected EventsListRequestEventType = "connected_account.connected" + EventsListRequestEventTypeConnectedAccountCreated EventsListRequestEventType = "connected_account.created" + EventsListRequestEventTypeConnectedAccountDisconnected EventsListRequestEventType = "connected_account.disconnected" + EventsListRequestEventTypeConnectedAccountCompletedFirstSync EventsListRequestEventType = "connected_account.completed_first_sync" + EventsListRequestEventTypeNoiseSensorNoiseThresholdTriggered EventsListRequestEventType = "noise_sensor.noise_threshold_triggered" + EventsListRequestEventTypeAccessCodeBackupAccessCodePulled EventsListRequestEventType = "access_code.backup_access_code_pulled" +) + +func NewEventsListRequestEventTypeFromString(s string) (EventsListRequestEventType, error) { + switch s { + case "device.connected": + return EventsListRequestEventTypeDeviceConnected, nil + case "device.unmanaged.connected": + return EventsListRequestEventTypeDeviceUnmanagedConnected, nil + case "device.disconnected": + return EventsListRequestEventTypeDeviceDisconnected, nil + case "device.unmanaged.disconnected": + return EventsListRequestEventTypeDeviceUnmanagedDisconnected, nil + case "device.converted_to_unmanaged": + return EventsListRequestEventTypeDeviceConvertedToUnmanaged, nil + case "device.unmanaged.converted_to_managed": + return EventsListRequestEventTypeDeviceUnmanagedConvertedToManaged, nil + case "device.removed": + return EventsListRequestEventTypeDeviceRemoved, nil + case "device.tampered": + return EventsListRequestEventTypeDeviceTampered, nil + case "device.low_battery": + return EventsListRequestEventTypeDeviceLowBattery, nil + case "device.battery_status_changed": + return EventsListRequestEventTypeDeviceBatteryStatusChanged, nil + case "access_code.created": + return EventsListRequestEventTypeAccessCodeCreated, nil + case "access_code.changed": + return EventsListRequestEventTypeAccessCodeChanged, nil + case "access_code.scheduled_on_device": + return EventsListRequestEventTypeAccessCodeScheduledOnDevice, nil + case "access_code.set_on_device": + return EventsListRequestEventTypeAccessCodeSetOnDevice, nil + case "access_code.deleted": + return EventsListRequestEventTypeAccessCodeDeleted, nil + case "access_code.removed_from_device": + return EventsListRequestEventTypeAccessCodeRemovedFromDevice, nil + case "access_code.failed_to_set_on_device": + return EventsListRequestEventTypeAccessCodeFailedToSetOnDevice, nil + case "access_code.delay_in_setting_on_device": + return EventsListRequestEventTypeAccessCodeDelayInSettingOnDevice, nil + case "access_code.failed_to_remove_from_device": + return EventsListRequestEventTypeAccessCodeFailedToRemoveFromDevice, nil + case "access_code.delay_in_removing_from_device": + return EventsListRequestEventTypeAccessCodeDelayInRemovingFromDevice, nil + case "access_code.unmanaged.converted_to_managed": + return EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged, nil + case "access_code.unmanaged.failed_to_convert_to_managed": + return EventsListRequestEventTypeAccessCodeUnmanagedFailedToConvertToManaged, nil + case "access_code.unmanaged.created": + return EventsListRequestEventTypeAccessCodeUnmanagedCreated, nil + case "access_code.unmanaged.removed": + return EventsListRequestEventTypeAccessCodeUnmanagedRemoved, nil + case "lock.locked": + return EventsListRequestEventTypeLockLocked, nil + case "lock.unlocked": + return EventsListRequestEventTypeLockUnlocked, nil + case "connected_account.connected": + return EventsListRequestEventTypeConnectedAccountConnected, nil + case "connected_account.created": + return EventsListRequestEventTypeConnectedAccountCreated, nil + case "connected_account.disconnected": + return EventsListRequestEventTypeConnectedAccountDisconnected, nil + case "connected_account.completed_first_sync": + return EventsListRequestEventTypeConnectedAccountCompletedFirstSync, nil + case "noise_sensor.noise_threshold_triggered": + return EventsListRequestEventTypeNoiseSensorNoiseThresholdTriggered, nil + case "access_code.backup_access_code_pulled": + return EventsListRequestEventTypeAccessCodeBackupAccessCodePulled, nil + } + var t EventsListRequestEventType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (e EventsListRequestEventType) Ptr() *EventsListRequestEventType { + return &e +} + +type EventsListRequestEventTypesItem string + +const ( + EventsListRequestEventTypesItemDeviceConnected EventsListRequestEventTypesItem = "device.connected" + EventsListRequestEventTypesItemDeviceUnmanagedConnected EventsListRequestEventTypesItem = "device.unmanaged.connected" + EventsListRequestEventTypesItemDeviceDisconnected EventsListRequestEventTypesItem = "device.disconnected" + EventsListRequestEventTypesItemDeviceUnmanagedDisconnected EventsListRequestEventTypesItem = "device.unmanaged.disconnected" + EventsListRequestEventTypesItemDeviceConvertedToUnmanaged EventsListRequestEventTypesItem = "device.converted_to_unmanaged" + EventsListRequestEventTypesItemDeviceUnmanagedConvertedToManaged EventsListRequestEventTypesItem = "device.unmanaged.converted_to_managed" + EventsListRequestEventTypesItemDeviceRemoved EventsListRequestEventTypesItem = "device.removed" + EventsListRequestEventTypesItemDeviceTampered EventsListRequestEventTypesItem = "device.tampered" + EventsListRequestEventTypesItemDeviceLowBattery EventsListRequestEventTypesItem = "device.low_battery" + EventsListRequestEventTypesItemDeviceBatteryStatusChanged EventsListRequestEventTypesItem = "device.battery_status_changed" + EventsListRequestEventTypesItemAccessCodeCreated EventsListRequestEventTypesItem = "access_code.created" + EventsListRequestEventTypesItemAccessCodeChanged EventsListRequestEventTypesItem = "access_code.changed" + EventsListRequestEventTypesItemAccessCodeScheduledOnDevice EventsListRequestEventTypesItem = "access_code.scheduled_on_device" + EventsListRequestEventTypesItemAccessCodeSetOnDevice EventsListRequestEventTypesItem = "access_code.set_on_device" + EventsListRequestEventTypesItemAccessCodeDeleted EventsListRequestEventTypesItem = "access_code.deleted" + EventsListRequestEventTypesItemAccessCodeRemovedFromDevice EventsListRequestEventTypesItem = "access_code.removed_from_device" + EventsListRequestEventTypesItemAccessCodeFailedToSetOnDevice EventsListRequestEventTypesItem = "access_code.failed_to_set_on_device" + 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" + EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged EventsListRequestEventTypesItem = "access_code.unmanaged.converted_to_managed" + EventsListRequestEventTypesItemAccessCodeUnmanagedFailedToConvertToManaged EventsListRequestEventTypesItem = "access_code.unmanaged.failed_to_convert_to_managed" + EventsListRequestEventTypesItemAccessCodeUnmanagedCreated EventsListRequestEventTypesItem = "access_code.unmanaged.created" + EventsListRequestEventTypesItemAccessCodeUnmanagedRemoved EventsListRequestEventTypesItem = "access_code.unmanaged.removed" + EventsListRequestEventTypesItemLockLocked EventsListRequestEventTypesItem = "lock.locked" + EventsListRequestEventTypesItemLockUnlocked EventsListRequestEventTypesItem = "lock.unlocked" + EventsListRequestEventTypesItemConnectedAccountConnected EventsListRequestEventTypesItem = "connected_account.connected" + EventsListRequestEventTypesItemConnectedAccountCreated EventsListRequestEventTypesItem = "connected_account.created" + EventsListRequestEventTypesItemConnectedAccountDisconnected EventsListRequestEventTypesItem = "connected_account.disconnected" + EventsListRequestEventTypesItemConnectedAccountCompletedFirstSync EventsListRequestEventTypesItem = "connected_account.completed_first_sync" + EventsListRequestEventTypesItemNoiseSensorNoiseThresholdTriggered EventsListRequestEventTypesItem = "noise_sensor.noise_threshold_triggered" + EventsListRequestEventTypesItemAccessCodeBackupAccessCodePulled EventsListRequestEventTypesItem = "access_code.backup_access_code_pulled" +) + +func NewEventsListRequestEventTypesItemFromString(s string) (EventsListRequestEventTypesItem, error) { + switch s { + case "device.connected": + return EventsListRequestEventTypesItemDeviceConnected, nil + case "device.unmanaged.connected": + return EventsListRequestEventTypesItemDeviceUnmanagedConnected, nil + case "device.disconnected": + return EventsListRequestEventTypesItemDeviceDisconnected, nil + case "device.unmanaged.disconnected": + return EventsListRequestEventTypesItemDeviceUnmanagedDisconnected, nil + case "device.converted_to_unmanaged": + return EventsListRequestEventTypesItemDeviceConvertedToUnmanaged, nil + case "device.unmanaged.converted_to_managed": + return EventsListRequestEventTypesItemDeviceUnmanagedConvertedToManaged, nil + case "device.removed": + return EventsListRequestEventTypesItemDeviceRemoved, nil + case "device.tampered": + return EventsListRequestEventTypesItemDeviceTampered, nil + case "device.low_battery": + return EventsListRequestEventTypesItemDeviceLowBattery, nil + case "device.battery_status_changed": + return EventsListRequestEventTypesItemDeviceBatteryStatusChanged, nil + case "access_code.created": + return EventsListRequestEventTypesItemAccessCodeCreated, nil + case "access_code.changed": + return EventsListRequestEventTypesItemAccessCodeChanged, nil + case "access_code.scheduled_on_device": + return EventsListRequestEventTypesItemAccessCodeScheduledOnDevice, nil + case "access_code.set_on_device": + return EventsListRequestEventTypesItemAccessCodeSetOnDevice, nil + case "access_code.deleted": + return EventsListRequestEventTypesItemAccessCodeDeleted, nil + case "access_code.removed_from_device": + return EventsListRequestEventTypesItemAccessCodeRemovedFromDevice, nil + case "access_code.failed_to_set_on_device": + return EventsListRequestEventTypesItemAccessCodeFailedToSetOnDevice, nil + case "access_code.delay_in_setting_on_device": + return EventsListRequestEventTypesItemAccessCodeDelayInSettingOnDevice, nil + case "access_code.failed_to_remove_from_device": + return EventsListRequestEventTypesItemAccessCodeFailedToRemoveFromDevice, nil + case "access_code.delay_in_removing_from_device": + return EventsListRequestEventTypesItemAccessCodeDelayInRemovingFromDevice, nil + case "access_code.unmanaged.converted_to_managed": + return EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged, nil + case "access_code.unmanaged.failed_to_convert_to_managed": + return EventsListRequestEventTypesItemAccessCodeUnmanagedFailedToConvertToManaged, nil + case "access_code.unmanaged.created": + return EventsListRequestEventTypesItemAccessCodeUnmanagedCreated, nil + case "access_code.unmanaged.removed": + return EventsListRequestEventTypesItemAccessCodeUnmanagedRemoved, nil + case "lock.locked": + return EventsListRequestEventTypesItemLockLocked, nil + case "lock.unlocked": + return EventsListRequestEventTypesItemLockUnlocked, nil + case "connected_account.connected": + return EventsListRequestEventTypesItemConnectedAccountConnected, nil + case "connected_account.created": + return EventsListRequestEventTypesItemConnectedAccountCreated, nil + case "connected_account.disconnected": + return EventsListRequestEventTypesItemConnectedAccountDisconnected, nil + case "connected_account.completed_first_sync": + return EventsListRequestEventTypesItemConnectedAccountCompletedFirstSync, nil + case "noise_sensor.noise_threshold_triggered": + return EventsListRequestEventTypesItemNoiseSensorNoiseThresholdTriggered, nil + case "access_code.backup_access_code_pulled": + return EventsListRequestEventTypesItemAccessCodeBackupAccessCodePulled, nil + } + var t EventsListRequestEventTypesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (e EventsListRequestEventTypesItem) Ptr() *EventsListRequestEventTypesItem { + return &e +} + +type EventsListResponse struct { + Events []*Event `json:"events,omitempty"` + Message *string `json:"message,omitempty"` + Ok bool `json:"ok"` +} diff --git a/events_client.go b/events/client.go similarity index 65% rename from events_client.go rename to events/client.go index 1958c32..e480f36 100644 --- a/events_client.go +++ b/events/client.go @@ -1,44 +1,40 @@ // This file was auto-generated by Fern from our API Definition. -package api +package events 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 EventsClient interface { - Get(ctx context.Context, request *EventsGetRequest) (*EventsGetResponse, error) - List(ctx context.Context, request *EventsListRequest) (*EventsListResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewEventsClient(opts ...core.ClientOption) EventsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &eventsClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type eventsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (e *eventsClient) Get(ctx context.Context, request *EventsGetRequest) (*EventsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.EventsGetRequest) (*seamapigo.Event, error) { baseURL := "https://connect.getseam.com" - if e.baseURL != "" { - baseURL = e.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "events/get" @@ -51,44 +47,44 @@ func (e *eventsClient) Get(ctx context.Context, request *EventsGetRequest) (*Eve decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *EventsGetResponse + var response *seamapigo.EventsGetResponse if err := core.DoRequest( ctx, - e.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - e.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Event, nil } -func (e *eventsClient) List(ctx context.Context, request *EventsListRequest) (*EventsListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.EventsListRequest) ([]*seamapigo.Event, error) { baseURL := "https://connect.getseam.com" - if e.baseURL != "" { - baseURL = e.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "events/list" @@ -101,36 +97,36 @@ func (e *eventsClient) List(ctx context.Context, request *EventsListRequest) (*E decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *EventsListResponse + var response *seamapigo.EventsListResponse if err := core.DoRequest( ctx, - e.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - e.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Events, nil } diff --git a/events_get_request.go b/events_get_request.go deleted file mode 100644 index f70e7cc..0000000 --- a/events_get_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// EventsGetRequest is an in-lined request used by the Get endpoint. -type EventsGetRequest struct { - EventId *string `json:"event_id,omitempty"` - EventType *string `json:"event_type,omitempty"` - DeviceId *string `json:"device_id,omitempty"` -} diff --git a/events_get_response.go b/events_get_response.go deleted file mode 100644 index 1644396..0000000 --- a/events_get_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type EventsGetResponse struct { - Event *Event `json:"event,omitempty"` - Message *string `json:"message,omitempty"` - Ok bool `json:"ok"` -} diff --git a/events_list_request.go b/events_list_request.go deleted file mode 100644 index 23f5953..0000000 --- a/events_list_request.go +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// EventsListRequest is an in-lined request used by the List endpoint. -type EventsListRequest struct { - Since *string `json:"since,omitempty"` - Between *[]*EventsListRequestBetweenItem `json:"between,omitempty"` - DeviceId *string `json:"device_id,omitempty"` - DeviceIds *[]string `json:"device_ids,omitempty"` - AccessCodeId *string `json:"access_code_id,omitempty"` - AccessCodeIds *[]string `json:"access_code_ids,omitempty"` - EventType *EventsListRequestEventType `json:"event_type,omitempty"` - EventTypes *[]EventsListRequestEventTypesItem `json:"event_types,omitempty"` - ConnectedAccountId *string `json:"connected_account_id,omitempty"` -} diff --git a/events_list_request_between_item.go b/events_list_request_between_item.go deleted file mode 100644 index d6763e6..0000000 --- a/events_list_request_between_item.go +++ /dev/null @@ -1,66 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - time "time" -) - -type EventsListRequestBetweenItem struct { - typeName string - String string - DateTime time.Time -} - -func NewEventsListRequestBetweenItemFromString(value string) *EventsListRequestBetweenItem { - return &EventsListRequestBetweenItem{typeName: "string", String: value} -} - -func NewEventsListRequestBetweenItemFromDateTime(value time.Time) *EventsListRequestBetweenItem { - return &EventsListRequestBetweenItem{typeName: "dateTime", DateTime: value} -} - -func (e *EventsListRequestBetweenItem) UnmarshalJSON(data []byte) error { - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - e.typeName = "string" - e.String = valueString - return nil - } - var valueDateTime time.Time - if err := json.Unmarshal(data, &valueDateTime); err == nil { - e.typeName = "dateTime" - e.DateTime = valueDateTime - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, e) -} - -func (e EventsListRequestBetweenItem) MarshalJSON() ([]byte, error) { - switch e.typeName { - default: - return nil, fmt.Errorf("invalid type %s in %T", e.typeName, e) - case "string": - return json.Marshal(e.String) - case "dateTime": - return json.Marshal(e.DateTime) - } -} - -type EventsListRequestBetweenItemVisitor interface { - VisitString(string) error - VisitDateTime(time.Time) error -} - -func (e *EventsListRequestBetweenItem) Accept(v EventsListRequestBetweenItemVisitor) error { - switch e.typeName { - default: - return fmt.Errorf("invalid type %s in %T", e.typeName, e) - case "string": - return v.VisitString(e.String) - case "dateTime": - return v.VisitDateTime(e.DateTime) - } -} diff --git a/events_list_request_event_type.go b/events_list_request_event_type.go deleted file mode 100644 index 6537e47..0000000 --- a/events_list_request_event_type.go +++ /dev/null @@ -1,227 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type EventsListRequestEventType uint8 - -const ( - EventsListRequestEventTypeDeviceConnected EventsListRequestEventType = iota + 1 - EventsListRequestEventTypeDeviceUnmanagedConnected - EventsListRequestEventTypeDeviceDisconnected - EventsListRequestEventTypeDeviceUnmanagedDisconnected - EventsListRequestEventTypeDeviceConvertedToUnmanaged - EventsListRequestEventTypeDeviceUnmanagedConvertedToManaged - EventsListRequestEventTypeDeviceRemoved - EventsListRequestEventTypeDeviceTampered - EventsListRequestEventTypeDeviceLowBattery - EventsListRequestEventTypeDeviceBatteryStatusChanged - EventsListRequestEventTypeAccessCodeCreated - EventsListRequestEventTypeAccessCodeChanged - EventsListRequestEventTypeAccessCodeScheduledOnDevice - EventsListRequestEventTypeAccessCodeSetOnDevice - EventsListRequestEventTypeAccessCodeDeleted - EventsListRequestEventTypeAccessCodeRemovedFromDevice - EventsListRequestEventTypeAccessCodeFailedToSetOnDevice - EventsListRequestEventTypeAccessCodeDelayInSettingOnDevice - EventsListRequestEventTypeAccessCodeFailedToRemoveFromDevice - EventsListRequestEventTypeAccessCodeDelayInRemovingFromDevice - EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged - EventsListRequestEventTypeAccessCodeUnmanagedFailedToConvertToManaged - EventsListRequestEventTypeAccessCodeUnmanagedCreated - EventsListRequestEventTypeAccessCodeUnmanagedRemoved - EventsListRequestEventTypeLockLocked - EventsListRequestEventTypeLockUnlocked - EventsListRequestEventTypeConnectedAccountConnected - EventsListRequestEventTypeConnectedAccountCreated - EventsListRequestEventTypeConnectedAccountDisconnected - EventsListRequestEventTypeConnectedAccountCompletedFirstSync - EventsListRequestEventTypeNoiseSensorNoiseThresholdTriggered - EventsListRequestEventTypeAccessCodeBackupAccessCodePulled -) - -func (e EventsListRequestEventType) String() string { - switch e { - default: - return strconv.Itoa(int(e)) - case EventsListRequestEventTypeDeviceConnected: - return "device.connected" - case EventsListRequestEventTypeDeviceUnmanagedConnected: - return "device.unmanaged.connected" - case EventsListRequestEventTypeDeviceDisconnected: - return "device.disconnected" - case EventsListRequestEventTypeDeviceUnmanagedDisconnected: - return "device.unmanaged.disconnected" - case EventsListRequestEventTypeDeviceConvertedToUnmanaged: - return "device.converted_to_unmanaged" - case EventsListRequestEventTypeDeviceUnmanagedConvertedToManaged: - return "device.unmanaged.converted_to_managed" - case EventsListRequestEventTypeDeviceRemoved: - return "device.removed" - case EventsListRequestEventTypeDeviceTampered: - return "device.tampered" - case EventsListRequestEventTypeDeviceLowBattery: - return "device.low_battery" - case EventsListRequestEventTypeDeviceBatteryStatusChanged: - return "device.battery_status_changed" - case EventsListRequestEventTypeAccessCodeCreated: - return "access_code.created" - case EventsListRequestEventTypeAccessCodeChanged: - return "access_code.changed" - case EventsListRequestEventTypeAccessCodeScheduledOnDevice: - return "access_code.scheduled_on_device" - case EventsListRequestEventTypeAccessCodeSetOnDevice: - return "access_code.set_on_device" - case EventsListRequestEventTypeAccessCodeDeleted: - return "access_code.deleted" - case EventsListRequestEventTypeAccessCodeRemovedFromDevice: - return "access_code.removed_from_device" - case EventsListRequestEventTypeAccessCodeFailedToSetOnDevice: - return "access_code.failed_to_set_on_device" - case EventsListRequestEventTypeAccessCodeDelayInSettingOnDevice: - return "access_code.delay_in_setting_on_device" - case EventsListRequestEventTypeAccessCodeFailedToRemoveFromDevice: - return "access_code.failed_to_remove_from_device" - case EventsListRequestEventTypeAccessCodeDelayInRemovingFromDevice: - return "access_code.delay_in_removing_from_device" - case EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged: - return "access_code.unmanaged.converted_to_managed" - case EventsListRequestEventTypeAccessCodeUnmanagedFailedToConvertToManaged: - return "access_code.unmanaged.failed_to_convert_to_managed" - case EventsListRequestEventTypeAccessCodeUnmanagedCreated: - return "access_code.unmanaged.created" - case EventsListRequestEventTypeAccessCodeUnmanagedRemoved: - return "access_code.unmanaged.removed" - case EventsListRequestEventTypeLockLocked: - return "lock.locked" - case EventsListRequestEventTypeLockUnlocked: - return "lock.unlocked" - case EventsListRequestEventTypeConnectedAccountConnected: - return "connected_account.connected" - case EventsListRequestEventTypeConnectedAccountCreated: - return "connected_account.created" - case EventsListRequestEventTypeConnectedAccountDisconnected: - return "connected_account.disconnected" - case EventsListRequestEventTypeConnectedAccountCompletedFirstSync: - return "connected_account.completed_first_sync" - case EventsListRequestEventTypeNoiseSensorNoiseThresholdTriggered: - return "noise_sensor.noise_threshold_triggered" - case EventsListRequestEventTypeAccessCodeBackupAccessCodePulled: - return "access_code.backup_access_code_pulled" - } -} - -func (e EventsListRequestEventType) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", e.String())), nil -} - -func (e *EventsListRequestEventType) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "device.connected": - value := EventsListRequestEventTypeDeviceConnected - *e = value - case "device.unmanaged.connected": - value := EventsListRequestEventTypeDeviceUnmanagedConnected - *e = value - case "device.disconnected": - value := EventsListRequestEventTypeDeviceDisconnected - *e = value - case "device.unmanaged.disconnected": - value := EventsListRequestEventTypeDeviceUnmanagedDisconnected - *e = value - case "device.converted_to_unmanaged": - value := EventsListRequestEventTypeDeviceConvertedToUnmanaged - *e = value - case "device.unmanaged.converted_to_managed": - value := EventsListRequestEventTypeDeviceUnmanagedConvertedToManaged - *e = value - case "device.removed": - value := EventsListRequestEventTypeDeviceRemoved - *e = value - case "device.tampered": - value := EventsListRequestEventTypeDeviceTampered - *e = value - case "device.low_battery": - value := EventsListRequestEventTypeDeviceLowBattery - *e = value - case "device.battery_status_changed": - value := EventsListRequestEventTypeDeviceBatteryStatusChanged - *e = value - case "access_code.created": - value := EventsListRequestEventTypeAccessCodeCreated - *e = value - case "access_code.changed": - value := EventsListRequestEventTypeAccessCodeChanged - *e = value - case "access_code.scheduled_on_device": - value := EventsListRequestEventTypeAccessCodeScheduledOnDevice - *e = value - case "access_code.set_on_device": - value := EventsListRequestEventTypeAccessCodeSetOnDevice - *e = value - case "access_code.deleted": - value := EventsListRequestEventTypeAccessCodeDeleted - *e = value - case "access_code.removed_from_device": - value := EventsListRequestEventTypeAccessCodeRemovedFromDevice - *e = value - case "access_code.failed_to_set_on_device": - value := EventsListRequestEventTypeAccessCodeFailedToSetOnDevice - *e = value - case "access_code.delay_in_setting_on_device": - value := EventsListRequestEventTypeAccessCodeDelayInSettingOnDevice - *e = value - case "access_code.failed_to_remove_from_device": - value := EventsListRequestEventTypeAccessCodeFailedToRemoveFromDevice - *e = value - case "access_code.delay_in_removing_from_device": - value := EventsListRequestEventTypeAccessCodeDelayInRemovingFromDevice - *e = value - case "access_code.unmanaged.converted_to_managed": - value := EventsListRequestEventTypeAccessCodeUnmanagedConvertedToManaged - *e = value - case "access_code.unmanaged.failed_to_convert_to_managed": - value := EventsListRequestEventTypeAccessCodeUnmanagedFailedToConvertToManaged - *e = value - case "access_code.unmanaged.created": - value := EventsListRequestEventTypeAccessCodeUnmanagedCreated - *e = value - case "access_code.unmanaged.removed": - value := EventsListRequestEventTypeAccessCodeUnmanagedRemoved - *e = value - case "lock.locked": - value := EventsListRequestEventTypeLockLocked - *e = value - case "lock.unlocked": - value := EventsListRequestEventTypeLockUnlocked - *e = value - case "connected_account.connected": - value := EventsListRequestEventTypeConnectedAccountConnected - *e = value - case "connected_account.created": - value := EventsListRequestEventTypeConnectedAccountCreated - *e = value - case "connected_account.disconnected": - value := EventsListRequestEventTypeConnectedAccountDisconnected - *e = value - case "connected_account.completed_first_sync": - value := EventsListRequestEventTypeConnectedAccountCompletedFirstSync - *e = value - case "noise_sensor.noise_threshold_triggered": - value := EventsListRequestEventTypeNoiseSensorNoiseThresholdTriggered - *e = value - case "access_code.backup_access_code_pulled": - value := EventsListRequestEventTypeAccessCodeBackupAccessCodePulled - *e = value - } - return nil -} diff --git a/events_list_request_event_types_item.go b/events_list_request_event_types_item.go deleted file mode 100644 index adebd48..0000000 --- a/events_list_request_event_types_item.go +++ /dev/null @@ -1,227 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type EventsListRequestEventTypesItem uint8 - -const ( - EventsListRequestEventTypesItemDeviceConnected EventsListRequestEventTypesItem = iota + 1 - EventsListRequestEventTypesItemDeviceUnmanagedConnected - EventsListRequestEventTypesItemDeviceDisconnected - EventsListRequestEventTypesItemDeviceUnmanagedDisconnected - EventsListRequestEventTypesItemDeviceConvertedToUnmanaged - EventsListRequestEventTypesItemDeviceUnmanagedConvertedToManaged - EventsListRequestEventTypesItemDeviceRemoved - EventsListRequestEventTypesItemDeviceTampered - EventsListRequestEventTypesItemDeviceLowBattery - EventsListRequestEventTypesItemDeviceBatteryStatusChanged - EventsListRequestEventTypesItemAccessCodeCreated - EventsListRequestEventTypesItemAccessCodeChanged - EventsListRequestEventTypesItemAccessCodeScheduledOnDevice - EventsListRequestEventTypesItemAccessCodeSetOnDevice - EventsListRequestEventTypesItemAccessCodeDeleted - EventsListRequestEventTypesItemAccessCodeRemovedFromDevice - EventsListRequestEventTypesItemAccessCodeFailedToSetOnDevice - EventsListRequestEventTypesItemAccessCodeDelayInSettingOnDevice - EventsListRequestEventTypesItemAccessCodeFailedToRemoveFromDevice - EventsListRequestEventTypesItemAccessCodeDelayInRemovingFromDevice - EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged - EventsListRequestEventTypesItemAccessCodeUnmanagedFailedToConvertToManaged - EventsListRequestEventTypesItemAccessCodeUnmanagedCreated - EventsListRequestEventTypesItemAccessCodeUnmanagedRemoved - EventsListRequestEventTypesItemLockLocked - EventsListRequestEventTypesItemLockUnlocked - EventsListRequestEventTypesItemConnectedAccountConnected - EventsListRequestEventTypesItemConnectedAccountCreated - EventsListRequestEventTypesItemConnectedAccountDisconnected - EventsListRequestEventTypesItemConnectedAccountCompletedFirstSync - EventsListRequestEventTypesItemNoiseSensorNoiseThresholdTriggered - EventsListRequestEventTypesItemAccessCodeBackupAccessCodePulled -) - -func (e EventsListRequestEventTypesItem) String() string { - switch e { - default: - return strconv.Itoa(int(e)) - case EventsListRequestEventTypesItemDeviceConnected: - return "device.connected" - case EventsListRequestEventTypesItemDeviceUnmanagedConnected: - return "device.unmanaged.connected" - case EventsListRequestEventTypesItemDeviceDisconnected: - return "device.disconnected" - case EventsListRequestEventTypesItemDeviceUnmanagedDisconnected: - return "device.unmanaged.disconnected" - case EventsListRequestEventTypesItemDeviceConvertedToUnmanaged: - return "device.converted_to_unmanaged" - case EventsListRequestEventTypesItemDeviceUnmanagedConvertedToManaged: - return "device.unmanaged.converted_to_managed" - case EventsListRequestEventTypesItemDeviceRemoved: - return "device.removed" - case EventsListRequestEventTypesItemDeviceTampered: - return "device.tampered" - case EventsListRequestEventTypesItemDeviceLowBattery: - return "device.low_battery" - case EventsListRequestEventTypesItemDeviceBatteryStatusChanged: - return "device.battery_status_changed" - case EventsListRequestEventTypesItemAccessCodeCreated: - return "access_code.created" - case EventsListRequestEventTypesItemAccessCodeChanged: - return "access_code.changed" - case EventsListRequestEventTypesItemAccessCodeScheduledOnDevice: - return "access_code.scheduled_on_device" - case EventsListRequestEventTypesItemAccessCodeSetOnDevice: - return "access_code.set_on_device" - case EventsListRequestEventTypesItemAccessCodeDeleted: - return "access_code.deleted" - case EventsListRequestEventTypesItemAccessCodeRemovedFromDevice: - return "access_code.removed_from_device" - case EventsListRequestEventTypesItemAccessCodeFailedToSetOnDevice: - return "access_code.failed_to_set_on_device" - case EventsListRequestEventTypesItemAccessCodeDelayInSettingOnDevice: - return "access_code.delay_in_setting_on_device" - case EventsListRequestEventTypesItemAccessCodeFailedToRemoveFromDevice: - return "access_code.failed_to_remove_from_device" - case EventsListRequestEventTypesItemAccessCodeDelayInRemovingFromDevice: - return "access_code.delay_in_removing_from_device" - case EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged: - return "access_code.unmanaged.converted_to_managed" - case EventsListRequestEventTypesItemAccessCodeUnmanagedFailedToConvertToManaged: - return "access_code.unmanaged.failed_to_convert_to_managed" - case EventsListRequestEventTypesItemAccessCodeUnmanagedCreated: - return "access_code.unmanaged.created" - case EventsListRequestEventTypesItemAccessCodeUnmanagedRemoved: - return "access_code.unmanaged.removed" - case EventsListRequestEventTypesItemLockLocked: - return "lock.locked" - case EventsListRequestEventTypesItemLockUnlocked: - return "lock.unlocked" - case EventsListRequestEventTypesItemConnectedAccountConnected: - return "connected_account.connected" - case EventsListRequestEventTypesItemConnectedAccountCreated: - return "connected_account.created" - case EventsListRequestEventTypesItemConnectedAccountDisconnected: - return "connected_account.disconnected" - case EventsListRequestEventTypesItemConnectedAccountCompletedFirstSync: - return "connected_account.completed_first_sync" - case EventsListRequestEventTypesItemNoiseSensorNoiseThresholdTriggered: - return "noise_sensor.noise_threshold_triggered" - case EventsListRequestEventTypesItemAccessCodeBackupAccessCodePulled: - return "access_code.backup_access_code_pulled" - } -} - -func (e EventsListRequestEventTypesItem) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", e.String())), nil -} - -func (e *EventsListRequestEventTypesItem) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "device.connected": - value := EventsListRequestEventTypesItemDeviceConnected - *e = value - case "device.unmanaged.connected": - value := EventsListRequestEventTypesItemDeviceUnmanagedConnected - *e = value - case "device.disconnected": - value := EventsListRequestEventTypesItemDeviceDisconnected - *e = value - case "device.unmanaged.disconnected": - value := EventsListRequestEventTypesItemDeviceUnmanagedDisconnected - *e = value - case "device.converted_to_unmanaged": - value := EventsListRequestEventTypesItemDeviceConvertedToUnmanaged - *e = value - case "device.unmanaged.converted_to_managed": - value := EventsListRequestEventTypesItemDeviceUnmanagedConvertedToManaged - *e = value - case "device.removed": - value := EventsListRequestEventTypesItemDeviceRemoved - *e = value - case "device.tampered": - value := EventsListRequestEventTypesItemDeviceTampered - *e = value - case "device.low_battery": - value := EventsListRequestEventTypesItemDeviceLowBattery - *e = value - case "device.battery_status_changed": - value := EventsListRequestEventTypesItemDeviceBatteryStatusChanged - *e = value - case "access_code.created": - value := EventsListRequestEventTypesItemAccessCodeCreated - *e = value - case "access_code.changed": - value := EventsListRequestEventTypesItemAccessCodeChanged - *e = value - case "access_code.scheduled_on_device": - value := EventsListRequestEventTypesItemAccessCodeScheduledOnDevice - *e = value - case "access_code.set_on_device": - value := EventsListRequestEventTypesItemAccessCodeSetOnDevice - *e = value - case "access_code.deleted": - value := EventsListRequestEventTypesItemAccessCodeDeleted - *e = value - case "access_code.removed_from_device": - value := EventsListRequestEventTypesItemAccessCodeRemovedFromDevice - *e = value - case "access_code.failed_to_set_on_device": - value := EventsListRequestEventTypesItemAccessCodeFailedToSetOnDevice - *e = value - case "access_code.delay_in_setting_on_device": - value := EventsListRequestEventTypesItemAccessCodeDelayInSettingOnDevice - *e = value - case "access_code.failed_to_remove_from_device": - value := EventsListRequestEventTypesItemAccessCodeFailedToRemoveFromDevice - *e = value - case "access_code.delay_in_removing_from_device": - value := EventsListRequestEventTypesItemAccessCodeDelayInRemovingFromDevice - *e = value - case "access_code.unmanaged.converted_to_managed": - value := EventsListRequestEventTypesItemAccessCodeUnmanagedConvertedToManaged - *e = value - case "access_code.unmanaged.failed_to_convert_to_managed": - value := EventsListRequestEventTypesItemAccessCodeUnmanagedFailedToConvertToManaged - *e = value - case "access_code.unmanaged.created": - value := EventsListRequestEventTypesItemAccessCodeUnmanagedCreated - *e = value - case "access_code.unmanaged.removed": - value := EventsListRequestEventTypesItemAccessCodeUnmanagedRemoved - *e = value - case "lock.locked": - value := EventsListRequestEventTypesItemLockLocked - *e = value - case "lock.unlocked": - value := EventsListRequestEventTypesItemLockUnlocked - *e = value - case "connected_account.connected": - value := EventsListRequestEventTypesItemConnectedAccountConnected - *e = value - case "connected_account.created": - value := EventsListRequestEventTypesItemConnectedAccountCreated - *e = value - case "connected_account.disconnected": - value := EventsListRequestEventTypesItemConnectedAccountDisconnected - *e = value - case "connected_account.completed_first_sync": - value := EventsListRequestEventTypesItemConnectedAccountCompletedFirstSync - *e = value - case "noise_sensor.noise_threshold_triggered": - value := EventsListRequestEventTypesItemNoiseSensorNoiseThresholdTriggered - *e = value - case "access_code.backup_access_code_pulled": - value := EventsListRequestEventTypesItemAccessCodeBackupAccessCodePulled - *e = value - } - return nil -} diff --git a/events_list_response.go b/events_list_response.go deleted file mode 100644 index 1ff0125..0000000 --- a/events_list_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type EventsListResponse struct { - Events *[]*Event `json:"events,omitempty"` - Message *string `json:"message,omitempty"` - Ok bool `json:"ok"` -} diff --git a/go.mod b/go.mod index 9ec4345..c43c80b 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/seamapi/go -go 1.19 +go 1.13 + +require github.com/stretchr/testify v1.7.0 diff --git a/go.sum b/go.sum index e69de29..acb88a4 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,11 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/health_get_health_response.go b/health.go similarity index 76% rename from health_get_health_response.go rename to health.go index a9f6ca1..b73c87a 100644 --- a/health_get_health_response.go +++ b/health.go @@ -6,6 +6,10 @@ import ( json "encoding/json" ) +type HealthGetServiceHealthRequest struct { + Service string `json:"service"` +} + type HealthGetHealthResponse struct { Ok bool `json:"ok"` LastServiceEvaluationAt *string `json:"last_service_evaluation_at,omitempty"` @@ -39,3 +43,9 @@ func (h *HealthGetHealthResponse) MarshalJSON() ([]byte, error) { } return json.Marshal(marshaler) } + +type HealthGetServiceHealthResponse struct { + Ok bool `json:"ok"` + LastServiceEvaluationAt string `json:"last_service_evaluation_at"` + ServiceHealth *ServiceHealth `json:"service_health,omitempty"` +} diff --git a/health_client.go b/health/client/client.go similarity index 56% rename from health_client.go rename to health/client/client.go index e734066..fb1214c 100644 --- a/health_client.go +++ b/health/client/client.go @@ -1,47 +1,44 @@ // This file was auto-generated by Fern from our API Definition. -package api +package client import ( bytes "bytes" context "context" json "encoding/json" errors "errors" + seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + service "github.com/seamapi/go/health/service" io "io" http "net/http" ) -type HealthClient interface { - GetHealth(ctx context.Context) (*HealthGetHealthResponse, error) - GetServiceHealth(ctx context.Context, request *HealthGetServiceHealthRequest) (*HealthGetServiceHealthResponse, error) - Service() ServiceClient +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header + + Service *service.Client } -func NewHealthClient(opts ...core.ClientOption) HealthClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &healthClient{ - baseURL: options.BaseURL, - httpClient: options.HTTPClient, - header: options.ToHeader(), - serviceClient: NewServiceClient(opts...), + return &Client{ + baseURL: options.BaseURL, + httpClient: options.HTTPClient, + header: options.ToHeader(), + Service: service.NewClient(opts...), } } -type healthClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header - serviceClient ServiceClient -} - -func (h *healthClient) GetHealth(ctx context.Context) (*HealthGetHealthResponse, error) { +func (c *Client) GetHealth(ctx context.Context) (*seamapigo.HealthGetHealthResponse, error) { baseURL := "https://connect.getseam.com" - if h.baseURL != "" { - baseURL = h.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "health/get_health" @@ -54,44 +51,44 @@ func (h *healthClient) GetHealth(ctx context.Context) (*HealthGetHealthResponse, decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *HealthGetHealthResponse + var response *seamapigo.HealthGetHealthResponse if err := core.DoRequest( ctx, - h.httpClient, + c.httpClient, endpointURL, http.MethodGet, nil, &response, false, - h.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (h *healthClient) GetServiceHealth(ctx context.Context, request *HealthGetServiceHealthRequest) (*HealthGetServiceHealthResponse, error) { +func (c *Client) GetServiceHealth(ctx context.Context, request *seamapigo.HealthGetServiceHealthRequest) (*seamapigo.HealthGetServiceHealthResponse, error) { baseURL := "https://connect.getseam.com" - if h.baseURL != "" { - baseURL = h.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "health/get_service_health" @@ -104,40 +101,36 @@ func (h *healthClient) GetServiceHealth(ctx context.Context, request *HealthGetS decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *HealthGetServiceHealthResponse + var response *seamapigo.HealthGetServiceHealthResponse if err := core.DoRequest( ctx, - h.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - h.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } - -func (h *healthClient) Service() ServiceClient { - return h.serviceClient -} diff --git a/health/service_by_service_name_request.go b/health/service.go similarity index 65% rename from health/service_by_service_name_request.go rename to health/service.go index 5fe1637..7fc86c9 100644 --- a/health/service_by_service_name_request.go +++ b/health/service.go @@ -2,7 +2,6 @@ package health -// ServiceByServiceNameRequest is an in-lined request used by the ByServiceName endpoint. type ServiceByServiceNameRequest struct { ServiceName string `json:"service_name"` } diff --git a/health/service_client.go b/health/service/client.go similarity index 69% rename from health/service_client.go rename to health/service/client.go index 0bd0f2f..c351c4b 100644 --- a/health/service_client.go +++ b/health/service/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package health +package service import ( bytes "bytes" @@ -9,36 +9,33 @@ import ( errors "errors" seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + health "github.com/seamapi/go/health" io "io" http "net/http" ) -type ServiceClient interface { - ByServiceName(ctx context.Context, request *ServiceByServiceNameRequest) (*seamapigo.ServiceByServiceNameResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewServiceClient(opts ...core.ClientOption) ServiceClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &serviceClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type serviceClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (s *serviceClient) ByServiceName(ctx context.Context, request *ServiceByServiceNameRequest) (*seamapigo.ServiceByServiceNameResponse, error) { +func (c *Client) ByServiceName(ctx context.Context, request *health.ServiceByServiceNameRequest) (*seamapigo.ServiceByServiceNameResponse, error) { baseURL := "https://connect.getseam.com" - if s.baseURL != "" { - baseURL = s.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "health/service/[service_name]" @@ -51,17 +48,17 @@ func (s *serviceClient) ByServiceName(ctx context.Context, request *ServiceBySer decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -71,16 +68,16 @@ func (s *serviceClient) ByServiceName(ctx context.Context, request *ServiceBySer var response *seamapigo.ServiceByServiceNameResponse if err := core.DoRequest( ctx, - s.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - s.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/health_get_service_health_request.go b/health_get_service_health_request.go deleted file mode 100644 index 9a55de8..0000000 --- a/health_get_service_health_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// HealthGetServiceHealthRequest is an in-lined request used by the GetServiceHealth endpoint. -type HealthGetServiceHealthRequest struct { - Service string `json:"service"` -} diff --git a/health_get_service_health_response.go b/health_get_service_health_response.go deleted file mode 100644 index 54414eb..0000000 --- a/health_get_service_health_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type HealthGetServiceHealthResponse struct { - Ok bool `json:"ok"` - LastServiceEvaluationAt string `json:"last_service_evaluation_at"` - ServiceHealth *ServiceHealth `json:"service_health,omitempty"` -} diff --git a/hvac_mode_setting.go b/hvac_mode_setting.go deleted file mode 100644 index 3360720..0000000 --- a/hvac_mode_setting.go +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type HvacModeSetting uint8 - -const ( - HvacModeSettingOff HvacModeSetting = iota + 1 - HvacModeSettingHeat - HvacModeSettingCool - HvacModeSettingHeatcool -) - -func (h HvacModeSetting) String() string { - switch h { - default: - return strconv.Itoa(int(h)) - case HvacModeSettingOff: - return "off" - case HvacModeSettingHeat: - return "heat" - case HvacModeSettingCool: - return "cool" - case HvacModeSettingHeatcool: - return "heatcool" - } -} - -func (h HvacModeSetting) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", h.String())), nil -} - -func (h *HvacModeSetting) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "off": - value := HvacModeSettingOff - *h = value - case "heat": - value := HvacModeSettingHeat - *h = value - case "cool": - value := HvacModeSettingCool - *h = value - case "heatcool": - value := HvacModeSettingHeatcool - *h = value - } - return nil -} diff --git a/locks.go b/locks.go new file mode 100644 index 0000000..2b67235 --- /dev/null +++ b/locks.go @@ -0,0 +1,56 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + time "time" +) + +type LocksGetRequest struct { + DeviceId *string `json:"device_id,omitempty"` + Name *string `json:"name,omitempty"` +} + +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"` +} + +type LocksLockDoorRequest struct { + DeviceId string `json:"device_id"` + Sync *bool `json:"sync,omitempty"` +} + +type LocksGetResponse struct { + Lock interface{} `json:"lock,omitempty"` + Device *Device `json:"device,omitempty"` + Ok bool `json:"ok"` +} + +type LocksListResponse struct { + Locks interface{} `json:"locks,omitempty"` + Devices []*Device `json:"devices,omitempty"` + Ok bool `json:"ok"` +} + +type LocksLockDoorResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type LocksUnlockDoorResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type LocksUnlockDoorRequest struct { + DeviceId string `json:"device_id"` + Sync *bool `json:"sync,omitempty"` +} diff --git a/locks_client.go b/locks/client.go similarity index 64% rename from locks_client.go rename to locks/client.go index 35b2ac5..fa5cb1f 100644 --- a/locks_client.go +++ b/locks/client.go @@ -1,46 +1,40 @@ // This file was auto-generated by Fern from our API Definition. -package api +package locks 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 LocksClient interface { - Get(ctx context.Context, request *LocksGetRequest) (*LocksGetResponse, error) - List(ctx context.Context, request *LocksListRequest) (*LocksListResponse, error) - LockDoor(ctx context.Context, request *LocksLockDoorRequest) (*LocksLockDoorResponse, error) - UnlockDoor(ctx context.Context, request *LocksUnlockDoorRequest) (*LocksUnlockDoorResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewLocksClient(opts ...core.ClientOption) LocksClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &locksClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type locksClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (l *locksClient) Get(ctx context.Context, request *LocksGetRequest) (*LocksGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.LocksGetRequest) (*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" - if l.baseURL != "" { - baseURL = l.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "locks/get" @@ -53,44 +47,44 @@ func (l *locksClient) Get(ctx context.Context, request *LocksGetRequest) (*Locks decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *LocksGetResponse + var response *seamapigo.LocksGetResponse if err := core.DoRequest( ctx, - l.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - l.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Device, nil } -func (l *locksClient) List(ctx context.Context, request *LocksListRequest) (*LocksListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.LocksListRequest) ([]*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" - if l.baseURL != "" { - baseURL = l.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "locks/list" @@ -103,44 +97,44 @@ func (l *locksClient) List(ctx context.Context, request *LocksListRequest) (*Loc decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *LocksListResponse + var response *seamapigo.LocksListResponse if err := core.DoRequest( ctx, - l.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - l.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Devices, nil } -func (l *locksClient) LockDoor(ctx context.Context, request *LocksLockDoorRequest) (*LocksLockDoorResponse, error) { +func (c *Client) LockDoor(ctx context.Context, request *seamapigo.LocksLockDoorRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if l.baseURL != "" { - baseURL = l.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "locks/lock_door" @@ -153,44 +147,44 @@ func (l *locksClient) LockDoor(ctx context.Context, request *LocksLockDoorReques decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *LocksLockDoorResponse + var response *seamapigo.LocksLockDoorResponse if err := core.DoRequest( ctx, - l.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - l.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } -func (l *locksClient) UnlockDoor(ctx context.Context, request *LocksUnlockDoorRequest) (*LocksUnlockDoorResponse, error) { +func (c *Client) UnlockDoor(ctx context.Context, request *seamapigo.LocksUnlockDoorRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if l.baseURL != "" { - baseURL = l.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "locks/unlock_door" @@ -203,36 +197,36 @@ func (l *locksClient) UnlockDoor(ctx context.Context, request *LocksUnlockDoorRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *LocksUnlockDoorResponse + var response *seamapigo.LocksUnlockDoorResponse if err := core.DoRequest( ctx, - l.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - l.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } diff --git a/locks_get_request.go b/locks_get_request.go deleted file mode 100644 index 85a6226..0000000 --- a/locks_get_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// LocksGetRequest is an in-lined request used by the Get endpoint. -type LocksGetRequest struct { - DeviceId *string `json:"device_id,omitempty"` - Name *string `json:"name,omitempty"` -} diff --git a/locks_get_response.go b/locks_get_response.go deleted file mode 100644 index 572c352..0000000 --- a/locks_get_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type LocksGetResponse struct { - Lock *any `json:"lock,omitempty"` - Device *Device `json:"device,omitempty"` - Ok bool `json:"ok"` -} diff --git a/locks_list_request.go b/locks_list_request.go deleted file mode 100644 index 53dcded..0000000 --- a/locks_list_request.go +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -// LocksListRequest is an in-lined request used by the List endpoint. -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"` -} diff --git a/locks_list_response.go b/locks_list_response.go deleted file mode 100644 index 7f6ef39..0000000 --- a/locks_list_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type LocksListResponse struct { - Locks *any `json:"locks,omitempty"` - Devices []*Device `json:"devices,omitempty"` - Ok bool `json:"ok"` -} diff --git a/locks_lock_door_request.go b/locks_lock_door_request.go deleted file mode 100644 index b6cc610..0000000 --- a/locks_lock_door_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// LocksLockDoorRequest is an in-lined request used by the LockDoor endpoint. -type LocksLockDoorRequest struct { - DeviceId string `json:"device_id"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/locks_lock_door_response.go b/locks_lock_door_response.go deleted file mode 100644 index c804f35..0000000 --- a/locks_lock_door_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type LocksLockDoorResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/locks_unlock_door_request.go b/locks_unlock_door_request.go deleted file mode 100644 index 0d6e4eb..0000000 --- a/locks_unlock_door_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// LocksUnlockDoorRequest is an in-lined request used by the UnlockDoor endpoint. -type LocksUnlockDoorRequest struct { - DeviceId string `json:"device_id"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/locks_unlock_door_response.go b/locks_unlock_door_response.go deleted file mode 100644 index fa5e609..0000000 --- a/locks_unlock_door_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type LocksUnlockDoorResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/manufacturer.go b/manufacturer.go deleted file mode 100644 index 24985c4..0000000 --- a/manufacturer.go +++ /dev/null @@ -1,191 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type Manufacturer uint8 - -const ( - ManufacturerAkuvox Manufacturer = iota + 1 - ManufacturerAugust - ManufacturerBrivo - ManufacturerButterflymx - ManufacturerDoorking - ManufacturerGenie - ManufacturerIgloo - ManufacturerKeywe - ManufacturerKwikset - ManufacturerLinear - ManufacturerLockly - ManufacturerNuki - ManufacturerPhilia - ManufacturerSalto - ManufacturerSamsung - ManufacturerSchlage - ManufacturerSeam - ManufacturerUnknown - ManufacturerYale - ManufacturerMinut - ManufacturerTwoN - ManufacturerTtlock - ManufacturerNest - ManufacturerIgloohome - ManufacturerEcobee - ManufacturerHubitat -) - -func (m Manufacturer) String() string { - switch m { - default: - return strconv.Itoa(int(m)) - case ManufacturerAkuvox: - return "akuvox" - case ManufacturerAugust: - return "august" - case ManufacturerBrivo: - return "brivo" - case ManufacturerButterflymx: - return "butterflymx" - case ManufacturerDoorking: - return "doorking" - case ManufacturerGenie: - return "genie" - case ManufacturerIgloo: - return "igloo" - case ManufacturerKeywe: - return "keywe" - case ManufacturerKwikset: - return "kwikset" - case ManufacturerLinear: - return "linear" - case ManufacturerLockly: - return "lockly" - case ManufacturerNuki: - return "nuki" - case ManufacturerPhilia: - return "philia" - case ManufacturerSalto: - return "salto" - case ManufacturerSamsung: - return "samsung" - case ManufacturerSchlage: - return "schlage" - case ManufacturerSeam: - return "seam" - case ManufacturerUnknown: - return "unknown" - case ManufacturerYale: - return "yale" - case ManufacturerMinut: - return "minut" - case ManufacturerTwoN: - return "two_n" - case ManufacturerTtlock: - return "ttlock" - case ManufacturerNest: - return "nest" - case ManufacturerIgloohome: - return "igloohome" - case ManufacturerEcobee: - return "ecobee" - case ManufacturerHubitat: - return "hubitat" - } -} - -func (m Manufacturer) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", m.String())), nil -} - -func (m *Manufacturer) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "akuvox": - value := ManufacturerAkuvox - *m = value - case "august": - value := ManufacturerAugust - *m = value - case "brivo": - value := ManufacturerBrivo - *m = value - case "butterflymx": - value := ManufacturerButterflymx - *m = value - case "doorking": - value := ManufacturerDoorking - *m = value - case "genie": - value := ManufacturerGenie - *m = value - case "igloo": - value := ManufacturerIgloo - *m = value - case "keywe": - value := ManufacturerKeywe - *m = value - case "kwikset": - value := ManufacturerKwikset - *m = value - case "linear": - value := ManufacturerLinear - *m = value - case "lockly": - value := ManufacturerLockly - *m = value - case "nuki": - value := ManufacturerNuki - *m = value - case "philia": - value := ManufacturerPhilia - *m = value - case "salto": - value := ManufacturerSalto - *m = value - case "samsung": - value := ManufacturerSamsung - *m = value - case "schlage": - value := ManufacturerSchlage - *m = value - case "seam": - value := ManufacturerSeam - *m = value - case "unknown": - value := ManufacturerUnknown - *m = value - case "yale": - value := ManufacturerYale - *m = value - case "minut": - value := ManufacturerMinut - *m = value - case "two_n": - value := ManufacturerTwoN - *m = value - case "ttlock": - value := ManufacturerTtlock - *m = value - case "nest": - value := ManufacturerNest - *m = value - case "igloohome": - value := ManufacturerIgloohome - *m = value - case "ecobee": - value := ManufacturerEcobee - *m = value - case "hubitat": - value := ManufacturerHubitat - *m = value - } - return nil -} diff --git a/noise_threshold.go b/noise_threshold.go deleted file mode 100644 index 6259182..0000000 --- a/noise_threshold.go +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NoiseThreshold struct { - NoiseThresholdId string `json:"noise_threshold_id"` - DeviceId string `json:"device_id"` - Name string `json:"name"` - NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` - StartsDailyAt string `json:"starts_daily_at"` - EndsDailyAt string `json:"ends_daily_at"` - NoiseThresholdDecibels float64 `json:"noise_threshold_decibels"` -} diff --git a/noise_thresholds_create_response.go b/noise_thresholds_create_response.go deleted file mode 100644 index d8b3788..0000000 --- a/noise_thresholds_create_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NoiseThresholdsCreateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/noise_thresholds_delete_response.go b/noise_thresholds_delete_response.go deleted file mode 100644 index fd4b3f7..0000000 --- a/noise_thresholds_delete_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NoiseThresholdsDeleteResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/noise_thresholds_get_response.go b/noise_thresholds_get_response.go deleted file mode 100644 index 820324b..0000000 --- a/noise_thresholds_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NoiseThresholdsGetResponse struct { - NoiseThreshold *NoiseThreshold `json:"noise_threshold,omitempty"` - Ok bool `json:"ok"` -} diff --git a/noise_thresholds_list_response.go b/noise_thresholds_list_response.go deleted file mode 100644 index 72cb606..0000000 --- a/noise_thresholds_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NoiseThresholdsListResponse struct { - NoiseThresholds []*NoiseThreshold `json:"noise_thresholds,omitempty"` - Ok bool `json:"ok"` -} diff --git a/noise_thresholds_update_response.go b/noise_thresholds_update_response.go deleted file mode 100644 index 88e6bef..0000000 --- a/noise_thresholds_update_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NoiseThresholdsUpdateResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/noisesensors/client.go b/noisesensors/client.go deleted file mode 100644 index 429a88e..0000000 --- a/noisesensors/client.go +++ /dev/null @@ -1,43 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package noisesensors - -import ( - core "github.com/seamapi/go/core" - http "net/http" -) - -type Client interface { - NoiseThresholds() NoiseThresholdsClient - Simulate() SimulateClient -} - -func NewClient(opts ...core.ClientOption) Client { - options := core.NewClientOptions() - for _, opt := range opts { - opt(options) - } - return &client{ - baseURL: options.BaseURL, - httpClient: options.HTTPClient, - header: options.ToHeader(), - noiseThresholdsClient: NewNoiseThresholdsClient(opts...), - simulateClient: NewSimulateClient(opts...), - } -} - -type client struct { - baseURL string - httpClient core.HTTPClient - header http.Header - noiseThresholdsClient NoiseThresholdsClient - simulateClient SimulateClient -} - -func (c *client) NoiseThresholds() NoiseThresholdsClient { - return c.noiseThresholdsClient -} - -func (c *client) Simulate() SimulateClient { - return c.simulateClient -} diff --git a/noisesensors/client/client.go b/noisesensors/client/client.go new file mode 100644 index 0000000..c3b17ba --- /dev/null +++ b/noisesensors/client/client.go @@ -0,0 +1,33 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + core "github.com/seamapi/go/core" + noisethresholds "github.com/seamapi/go/noisesensors/noisethresholds" + simulate "github.com/seamapi/go/noisesensors/simulate" + http "net/http" +) + +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header + + NoiseThresholds *noisethresholds.Client + Simulate *simulate.Client +} + +func NewClient(opts ...core.ClientOption) *Client { + options := core.NewClientOptions() + for _, opt := range opts { + opt(options) + } + return &Client{ + baseURL: options.BaseURL, + httpClient: options.HTTPClient, + header: options.ToHeader(), + NoiseThresholds: noisethresholds.NewClient(opts...), + Simulate: simulate.NewClient(opts...), + } +} diff --git a/noisesensors/noise_thresholds.go b/noisesensors/noise_thresholds.go new file mode 100644 index 0000000..61a43c6 --- /dev/null +++ b/noisesensors/noise_thresholds.go @@ -0,0 +1,38 @@ +// This file was auto-generated by Fern from our API Definition. + +package noisesensors + +type NoiseThresholdsCreateRequest struct { + DeviceId string `json:"device_id"` + Sync *bool `json:"sync,omitempty"` + Name *string `json:"name,omitempty"` + StartsDailyAt string `json:"starts_daily_at"` + EndsDailyAt string `json:"ends_daily_at"` + NoiseThresholdDecibels *float64 `json:"noise_threshold_decibels,omitempty"` + NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` +} + +type NoiseThresholdsDeleteRequest struct { + NoiseThresholdId string `json:"noise_threshold_id"` + DeviceId string `json:"device_id"` + Sync *bool `json:"sync,omitempty"` +} + +type NoiseThresholdsGetRequest struct { + NoiseThresholdId string `json:"noise_threshold_id"` +} + +type NoiseThresholdsListRequest struct { + DeviceId string `json:"device_id"` +} + +type NoiseThresholdsUpdateRequest struct { + NoiseThresholdId string `json:"noise_threshold_id"` + DeviceId string `json:"device_id"` + Sync *bool `json:"sync,omitempty"` + Name *string `json:"name,omitempty"` + StartsDailyAt *string `json:"starts_daily_at,omitempty"` + EndsDailyAt *string `json:"ends_daily_at,omitempty"` + NoiseThresholdDecibels *float64 `json:"noise_threshold_decibels,omitempty"` + NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` +} diff --git a/noisesensors/noise_thresholds_create_request.go b/noisesensors/noise_thresholds_create_request.go deleted file mode 100644 index 9147797..0000000 --- a/noisesensors/noise_thresholds_create_request.go +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package noisesensors - -// NoiseThresholdsCreateRequest is an in-lined request used by the Create endpoint. -type NoiseThresholdsCreateRequest struct { - DeviceId string `json:"device_id"` - Sync *bool `json:"sync,omitempty"` - Name *string `json:"name,omitempty"` - StartsDailyAt string `json:"starts_daily_at"` - EndsDailyAt string `json:"ends_daily_at"` - NoiseThresholdDecibels *float64 `json:"noise_threshold_decibels,omitempty"` - NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` -} diff --git a/noisesensors/noise_thresholds_delete_request.go b/noisesensors/noise_thresholds_delete_request.go deleted file mode 100644 index 6aef0c8..0000000 --- a/noisesensors/noise_thresholds_delete_request.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package noisesensors - -// NoiseThresholdsDeleteRequest is an in-lined request used by the Delete endpoint. -type NoiseThresholdsDeleteRequest struct { - NoiseThresholdId string `json:"noise_threshold_id"` - DeviceId string `json:"device_id"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/noisesensors/noise_thresholds_get_request.go b/noisesensors/noise_thresholds_get_request.go deleted file mode 100644 index 5007f87..0000000 --- a/noisesensors/noise_thresholds_get_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package noisesensors - -// NoiseThresholdsGetRequest is an in-lined request used by the Get endpoint. -type NoiseThresholdsGetRequest struct { - NoiseThresholdId string `json:"noise_threshold_id"` -} diff --git a/noisesensors/noise_thresholds_list_request.go b/noisesensors/noise_thresholds_list_request.go deleted file mode 100644 index 7a64787..0000000 --- a/noisesensors/noise_thresholds_list_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package noisesensors - -// NoiseThresholdsListRequest is an in-lined request used by the List endpoint. -type NoiseThresholdsListRequest struct { - DeviceId string `json:"device_id"` -} diff --git a/noisesensors/noise_thresholds_update_request.go b/noisesensors/noise_thresholds_update_request.go deleted file mode 100644 index 74c145f..0000000 --- a/noisesensors/noise_thresholds_update_request.go +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package noisesensors - -// NoiseThresholdsUpdateRequest is an in-lined request used by the Update endpoint. -type NoiseThresholdsUpdateRequest struct { - NoiseThresholdId string `json:"noise_threshold_id"` - DeviceId string `json:"device_id"` - Sync *bool `json:"sync,omitempty"` - Name *string `json:"name,omitempty"` - StartsDailyAt *string `json:"starts_daily_at,omitempty"` - EndsDailyAt *string `json:"ends_daily_at,omitempty"` - NoiseThresholdDecibels *float64 `json:"noise_threshold_decibels,omitempty"` - NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` -} diff --git a/noisesensors/noise_thresholds_client.go b/noisesensors/noisethresholds/client.go similarity index 64% rename from noisesensors/noise_thresholds_client.go rename to noisesensors/noisethresholds/client.go index 5df4fbb..517c2c5 100644 --- a/noisesensors/noise_thresholds_client.go +++ b/noisesensors/noisethresholds/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package noisesensors +package noisethresholds import ( bytes "bytes" @@ -9,40 +9,33 @@ import ( errors "errors" seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + noisesensors "github.com/seamapi/go/noisesensors" io "io" http "net/http" ) -type NoiseThresholdsClient interface { - Create(ctx context.Context, request *NoiseThresholdsCreateRequest) (*seamapigo.NoiseThresholdsCreateResponse, error) - Delete(ctx context.Context, request *NoiseThresholdsDeleteRequest) (*seamapigo.NoiseThresholdsDeleteResponse, error) - Get(ctx context.Context, request *NoiseThresholdsGetRequest) (*seamapigo.NoiseThresholdsGetResponse, error) - List(ctx context.Context, request *NoiseThresholdsListRequest) (*seamapigo.NoiseThresholdsListResponse, error) - Update(ctx context.Context, request *NoiseThresholdsUpdateRequest) (*seamapigo.NoiseThresholdsUpdateResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewNoiseThresholdsClient(opts ...core.ClientOption) NoiseThresholdsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &noiseThresholdsClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type noiseThresholdsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (n *noiseThresholdsClient) Create(ctx context.Context, request *NoiseThresholdsCreateRequest) (*seamapigo.NoiseThresholdsCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *noisesensors.NoiseThresholdsCreateRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if n.baseURL != "" { - baseURL = n.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "noise_sensors/noise_thresholds/create" @@ -55,17 +48,17 @@ func (n *noiseThresholdsClient) Create(ctx context.Context, request *NoiseThresh decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -75,24 +68,24 @@ func (n *noiseThresholdsClient) Create(ctx context.Context, request *NoiseThresh var response *seamapigo.NoiseThresholdsCreateResponse if err := core.DoRequest( ctx, - n.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - n.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } -func (n *noiseThresholdsClient) Delete(ctx context.Context, request *NoiseThresholdsDeleteRequest) (*seamapigo.NoiseThresholdsDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *noisesensors.NoiseThresholdsDeleteRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if n.baseURL != "" { - baseURL = n.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "noise_sensors/noise_thresholds/delete" @@ -105,17 +98,17 @@ func (n *noiseThresholdsClient) Delete(ctx context.Context, request *NoiseThresh decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -125,24 +118,24 @@ func (n *noiseThresholdsClient) Delete(ctx context.Context, request *NoiseThresh var response *seamapigo.NoiseThresholdsDeleteResponse if err := core.DoRequest( ctx, - n.httpClient, + c.httpClient, endpointURL, http.MethodDelete, request, &response, false, - n.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } -func (n *noiseThresholdsClient) Get(ctx context.Context, request *NoiseThresholdsGetRequest) (*seamapigo.NoiseThresholdsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *noisesensors.NoiseThresholdsGetRequest) (*seamapigo.NoiseThreshold, error) { baseURL := "https://connect.getseam.com" - if n.baseURL != "" { - baseURL = n.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "noise_sensors/noise_thresholds/get" @@ -155,17 +148,17 @@ func (n *noiseThresholdsClient) Get(ctx context.Context, request *NoiseThreshold decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -175,24 +168,24 @@ func (n *noiseThresholdsClient) Get(ctx context.Context, request *NoiseThreshold var response *seamapigo.NoiseThresholdsGetResponse if err := core.DoRequest( ctx, - n.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - n.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.NoiseThreshold, nil } -func (n *noiseThresholdsClient) List(ctx context.Context, request *NoiseThresholdsListRequest) (*seamapigo.NoiseThresholdsListResponse, error) { +func (c *Client) List(ctx context.Context, request *noisesensors.NoiseThresholdsListRequest) ([]*seamapigo.NoiseThreshold, error) { baseURL := "https://connect.getseam.com" - if n.baseURL != "" { - baseURL = n.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "noise_sensors/noise_thresholds/list" @@ -205,17 +198,17 @@ func (n *noiseThresholdsClient) List(ctx context.Context, request *NoiseThreshol decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -225,24 +218,24 @@ func (n *noiseThresholdsClient) List(ctx context.Context, request *NoiseThreshol var response *seamapigo.NoiseThresholdsListResponse if err := core.DoRequest( ctx, - n.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - n.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.NoiseThresholds, nil } -func (n *noiseThresholdsClient) Update(ctx context.Context, request *NoiseThresholdsUpdateRequest) (*seamapigo.NoiseThresholdsUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *noisesensors.NoiseThresholdsUpdateRequest) (*seamapigo.ActionAttempt, error) { baseURL := "https://connect.getseam.com" - if n.baseURL != "" { - baseURL = n.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "noise_sensors/noise_thresholds/update" @@ -255,17 +248,17 @@ func (n *noiseThresholdsClient) Update(ctx context.Context, request *NoiseThresh decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -275,16 +268,16 @@ func (n *noiseThresholdsClient) Update(ctx context.Context, request *NoiseThresh var response *seamapigo.NoiseThresholdsUpdateResponse if err := core.DoRequest( ctx, - n.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - n.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.ActionAttempt, nil } diff --git a/noisesensors/simulate_trigger_noise_threshold_request.go b/noisesensors/simulate.go similarity index 62% rename from noisesensors/simulate_trigger_noise_threshold_request.go rename to noisesensors/simulate.go index ae9230f..8aef28e 100644 --- a/noisesensors/simulate_trigger_noise_threshold_request.go +++ b/noisesensors/simulate.go @@ -2,7 +2,6 @@ package noisesensors -// SimulateTriggerNoiseThresholdRequest is an in-lined request used by the TriggerNoiseThreshold endpoint. type SimulateTriggerNoiseThresholdRequest struct { DeviceId string `json:"device_id"` } diff --git a/noisesensors/simulate_client.go b/noisesensors/simulate/client.go similarity index 66% rename from noisesensors/simulate_client.go rename to noisesensors/simulate/client.go index d9afebe..ecb78d2 100644 --- a/noisesensors/simulate_client.go +++ b/noisesensors/simulate/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package noisesensors +package simulate import ( bytes "bytes" @@ -9,36 +9,33 @@ import ( errors "errors" seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + noisesensors "github.com/seamapi/go/noisesensors" io "io" http "net/http" ) -type SimulateClient interface { - TriggerNoiseThreshold(ctx context.Context, request *SimulateTriggerNoiseThresholdRequest) (*seamapigo.SimulateTriggerNoiseThresholdResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewSimulateClient(opts ...core.ClientOption) SimulateClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &simulateClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type simulateClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (s *simulateClient) TriggerNoiseThreshold(ctx context.Context, request *SimulateTriggerNoiseThresholdRequest) (*seamapigo.SimulateTriggerNoiseThresholdResponse, error) { +func (c *Client) TriggerNoiseThreshold(ctx context.Context, request *noisesensors.SimulateTriggerNoiseThresholdRequest) (*seamapigo.SimulateTriggerNoiseThresholdResponse, error) { baseURL := "https://connect.getseam.com" - if s.baseURL != "" { - baseURL = s.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "noise_sensors/simulate/trigger_noise_threshold" @@ -51,17 +48,17 @@ func (s *simulateClient) TriggerNoiseThreshold(ctx context.Context, request *Sim decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -71,16 +68,16 @@ func (s *simulateClient) TriggerNoiseThreshold(ctx context.Context, request *Sim var response *seamapigo.SimulateTriggerNoiseThresholdResponse if err := core.DoRequest( ctx, - s.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - s.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/nuki_device_metadata.go b/nuki_device_metadata.go deleted file mode 100644 index 813ed57..0000000 --- a/nuki_device_metadata.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type NukiDeviceMetadata struct { - KeypadBatteryCritical *bool `json:"keypad_battery_critical,omitempty"` -} diff --git a/schlage_device_metadata.go b/schlage_device_metadata.go deleted file mode 100644 index c0ffae8..0000000 --- a/schlage_device_metadata.go +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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"` -} diff --git a/service_by_service_name_response.go b/service_by_service_name_response.go deleted file mode 100644 index fa1ab45..0000000 --- a/service_by_service_name_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ServiceByServiceNameResponse struct { - Ok bool `json:"ok"` - LastServiceEvaluationAt string `json:"last_service_evaluation_at"` - ServiceHealth *ServiceHealth `json:"service_health,omitempty"` -} diff --git a/service_health.go b/service_health.go deleted file mode 100644 index 027f36c..0000000 --- a/service_health.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ServiceHealth struct { - Service string `json:"service"` - Status ServiceHealthStatus `json:"status,omitempty"` - Description string `json:"description"` -} diff --git a/service_health_status.go b/service_health_status.go deleted file mode 100644 index deeedfa..0000000 --- a/service_health_status.go +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type ServiceHealthStatus uint8 - -const ( - ServiceHealthStatusHealthy ServiceHealthStatus = iota + 1 - ServiceHealthStatusDegraded - ServiceHealthStatusDown -) - -func (s ServiceHealthStatus) String() string { - switch s { - default: - return strconv.Itoa(int(s)) - case ServiceHealthStatusHealthy: - return "healthy" - case ServiceHealthStatusDegraded: - return "degraded" - case ServiceHealthStatusDown: - return "down" - } -} - -func (s ServiceHealthStatus) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", s.String())), nil -} - -func (s *ServiceHealthStatus) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "healthy": - value := ServiceHealthStatusHealthy - *s = value - case "degraded": - value := ServiceHealthStatusDegraded - *s = value - case "down": - value := ServiceHealthStatusDown - *s = value - } - return nil -} diff --git a/simulate_create_unmanaged_access_code_response.go b/simulate_create_unmanaged_access_code_response.go deleted file mode 100644 index cf32048..0000000 --- a/simulate_create_unmanaged_access_code_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type SimulateCreateUnmanagedAccessCodeResponse struct { - AccessCode *SimulateCreateUnmanagedAccessCodeResponseAccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` -} diff --git a/simulate_create_unmanaged_access_code_response_access_code.go b/simulate_create_unmanaged_access_code_response_access_code.go deleted file mode 100644 index 73852ac..0000000 --- a/simulate_create_unmanaged_access_code_response_access_code.go +++ /dev/null @@ -1,88 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" -) - -type SimulateCreateUnmanagedAccessCodeResponseAccessCode struct { - Type string - Ongoing *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing - TimeBound *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeFromOngoing(value *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) *SimulateCreateUnmanagedAccessCodeResponseAccessCode { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCode{Type: "ongoing", Ongoing: value} -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeFromTimeBound(value *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) *SimulateCreateUnmanagedAccessCodeResponseAccessCode { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCode{Type: "time_bound", TimeBound: value} -} - -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 - 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) - 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) - } -} - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeVisitor interface { - VisitOngoing(*SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) error - VisitTimeBound(*SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) error -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCode) Accept(v SimulateCreateUnmanagedAccessCodeResponseAccessCodeVisitor) error { - switch s.Type { - default: - return fmt.Errorf("invalid type %s in %T", s.Type, s) - case "ongoing": - return v.VisitOngoing(s.Ongoing) - case "time_bound": - return v.VisitTimeBound(s.TimeBound) - } -} diff --git a/simulate_create_unmanaged_access_code_response_access_code_ongoing.go b/simulate_create_unmanaged_access_code_response_access_code_ongoing.go deleted file mode 100644 index 2e44a1e..0000000 --- a/simulate_create_unmanaged_access_code_response_access_code_ongoing.go +++ /dev/null @@ -1,44 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" -) - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing struct { - AccessCodeId string `json:"access_code_id"` - Code *string `json:"code,omitempty"` - CreatedAt *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt `json:"created_at,omitempty"` - IsManaged string `json:"is_managed"` - StartsAt *string `json:"starts_at,omitempty"` - EndsAt *string `json:"ends_at,omitempty"` - status string -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) Status() string { - return s.status -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing(value) - s.status = "set" - 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) -} diff --git a/simulate_create_unmanaged_access_code_response_access_code_ongoing_created_at.go b/simulate_create_unmanaged_access_code_response_access_code_ongoing_created_at.go deleted file mode 100644 index a6809a7..0000000 --- a/simulate_create_unmanaged_access_code_response_access_code_ongoing_created_at.go +++ /dev/null @@ -1,66 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - time "time" -) - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt struct { - typeName string - String string - DateTime time.Time -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromString(value string) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "string", String: value} -} - -func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromDateTime(value time.Time) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { - return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "dateTime", DateTime: value} -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) UnmarshalJSON(data []byte) error { - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - s.typeName = "string" - s.String = valueString - return nil - } - var valueDateTime time.Time - if err := json.Unmarshal(data, &valueDateTime); err == nil { - s.typeName = "dateTime" - s.DateTime = valueDateTime - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, s) -} - -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) - } -} - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor interface { - VisitString(string) error - VisitDateTime(time.Time) error -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) Accept(v SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor) error { - switch s.typeName { - default: - return fmt.Errorf("invalid type %s in %T", s.typeName, s) - case "string": - return v.VisitString(s.String) - case "dateTime": - return v.VisitDateTime(s.DateTime) - } -} diff --git a/simulate_create_unmanaged_access_code_response_access_code_time_bound.go b/simulate_create_unmanaged_access_code_response_access_code_time_bound.go deleted file mode 100644 index 2c4c777..0000000 --- a/simulate_create_unmanaged_access_code_response_access_code_time_bound.go +++ /dev/null @@ -1,44 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" -) - -type SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound struct { - AccessCodeId string `json:"access_code_id"` - Code *string `json:"code,omitempty"` - CreatedAt *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt `json:"created_at,omitempty"` - IsManaged string `json:"is_managed"` - StartsAt *string `json:"starts_at,omitempty"` - EndsAt *string `json:"ends_at,omitempty"` - status string -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) Status() string { - return s.status -} - -func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) UnmarshalJSON(data []byte) error { - type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound(value) - s.status = "set" - 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) -} diff --git a/simulate_create_unmanaged_access_code_response_access_code_time_bound_created_at.go b/simulate_create_unmanaged_access_code_response_access_code_time_bound_created_at.go deleted file mode 100644 index f4704ca..0000000 --- a/simulate_create_unmanaged_access_code_response_access_code_time_bound_created_at.go +++ /dev/null @@ -1,66 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - time "time" -) - -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(v SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAtVisitor) error { - switch s.typeName { - default: - return fmt.Errorf("invalid type %s in %T", s.typeName, s) - case "string": - return v.VisitString(s.String) - case "dateTime": - return v.VisitDateTime(s.DateTime) - } -} diff --git a/simulate_trigger_noise_threshold_response.go b/simulate_trigger_noise_threshold_response.go deleted file mode 100644 index 53658a2..0000000 --- a/simulate_trigger_noise_threshold_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type SimulateTriggerNoiseThresholdResponse struct { - Ok bool `json:"ok"` -} diff --git a/supported_capabililty.go b/supported_capabililty.go deleted file mode 100644 index 511ce6d..0000000 --- a/supported_capabililty.go +++ /dev/null @@ -1,65 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type SupportedCapabililty uint8 - -const ( - SupportedCapabililtyAccessCode SupportedCapabililty = iota + 1 - SupportedCapabililtyLock - SupportedCapabililtyNoiseDetection - SupportedCapabililtyThermostat - SupportedCapabililtyBattery -) - -func (s SupportedCapabililty) String() string { - switch s { - default: - return strconv.Itoa(int(s)) - case SupportedCapabililtyAccessCode: - return "access_code" - case SupportedCapabililtyLock: - return "lock" - case SupportedCapabililtyNoiseDetection: - return "noise_detection" - case SupportedCapabililtyThermostat: - return "thermostat" - case SupportedCapabililtyBattery: - return "battery" - } -} - -func (s SupportedCapabililty) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", s.String())), nil -} - -func (s *SupportedCapabililty) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "access_code": - value := SupportedCapabililtyAccessCode - *s = value - case "lock": - value := SupportedCapabililtyLock - *s = value - case "noise_detection": - value := SupportedCapabililtyNoiseDetection - *s = value - case "thermostat": - value := SupportedCapabililtyThermostat - *s = value - case "battery": - value := SupportedCapabililtyBattery - *s = value - } - return nil -} diff --git a/thermostats.go b/thermostats.go new file mode 100644 index 0000000..e6e167b --- /dev/null +++ b/thermostats.go @@ -0,0 +1,65 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + time "time" +) + +type ThermostatsGetRequest struct { + DeviceId *string `json:"device_id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type ThermostatsHeatRequest struct { + DeviceId string `json:"device_id"` + HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` + HeatingSetPointFahrenheit *float64 `json:"heating_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"` +} + +type ThermostatsGetResponse struct { + Thermostat *Device `json:"thermostat,omitempty"` + Ok bool `json:"ok"` +} + +type ThermostatsHeatResponse struct { + Ok bool `json:"ok"` +} + +type ThermostatsListResponse struct { + Thermostats []*Device `json:"thermostats,omitempty"` + Ok bool `json:"ok"` +} + +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"` +} + +type ThermostatsUpdateResponse struct { + Ok bool `json:"ok"` +} + +type ThermostatsUpdateRequest struct { + DeviceId string `json:"device_id"` + DefaultClimateSetting *ThermostatsUpdateRequestDefaultClimateSetting `json:"default_climate_setting,omitempty"` +} diff --git a/thermostats_client.go b/thermostats/client/client.go similarity index 55% rename from thermostats_client.go rename to thermostats/client/client.go index f301a2a..daf09ee 100644 --- a/thermostats_client.go +++ b/thermostats/client/client.go @@ -1,49 +1,44 @@ // This file was auto-generated by Fern from our API Definition. -package api +package client import ( bytes "bytes" context "context" json "encoding/json" errors "errors" + seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + climatesettingschedules "github.com/seamapi/go/thermostats/climatesettingschedules" io "io" http "net/http" ) -type ThermostatsClient interface { - Get(ctx context.Context, request *ThermostatsGetRequest) (*ThermostatsGetResponse, error) - Heat(ctx context.Context, request *ThermostatsHeatRequest) (*ThermostatsHeatResponse, error) - List(ctx context.Context, request *ThermostatsListRequest) (*ThermostatsListResponse, error) - Update(ctx context.Context, request *ThermostatsUpdateRequest) (*ThermostatsUpdateResponse, error) - ClimateSettingSchedules() ClimateSettingSchedulesClient +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header + + ClimateSettingSchedules *climatesettingschedules.Client } -func NewThermostatsClient(opts ...core.ClientOption) ThermostatsClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &thermostatsClient{ - baseURL: options.BaseURL, - httpClient: options.HTTPClient, - header: options.ToHeader(), - climateSettingSchedulesClient: NewClimateSettingSchedulesClient(opts...), + return &Client{ + baseURL: options.BaseURL, + httpClient: options.HTTPClient, + header: options.ToHeader(), + ClimateSettingSchedules: climatesettingschedules.NewClient(opts...), } } -type thermostatsClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header - climateSettingSchedulesClient ClimateSettingSchedulesClient -} - -func (t *thermostatsClient) Get(ctx context.Context, request *ThermostatsGetRequest) (*ThermostatsGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.ThermostatsGetRequest) (*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" - if t.baseURL != "" { - baseURL = t.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "thermostats/get" @@ -56,44 +51,44 @@ func (t *thermostatsClient) Get(ctx context.Context, request *ThermostatsGetRequ decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ThermostatsGetResponse + var response *seamapigo.ThermostatsGetResponse if err := core.DoRequest( ctx, - t.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - t.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Thermostat, nil } -func (t *thermostatsClient) Heat(ctx context.Context, request *ThermostatsHeatRequest) (*ThermostatsHeatResponse, error) { +func (c *Client) Heat(ctx context.Context, request *seamapigo.ThermostatsHeatRequest) (bool, error) { baseURL := "https://connect.getseam.com" - if t.baseURL != "" { - baseURL = t.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "thermostats/heat" @@ -106,44 +101,44 @@ func (t *thermostatsClient) Heat(ctx context.Context, request *ThermostatsHeatRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ThermostatsHeatResponse + var response *seamapigo.ThermostatsHeatResponse if err := core.DoRequest( ctx, - t.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - t.header, + c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil + return response.Ok, nil } -func (t *thermostatsClient) List(ctx context.Context, request *ThermostatsListRequest) (*ThermostatsListResponse, error) { +func (c *Client) List(ctx context.Context, request *seamapigo.ThermostatsListRequest) ([]*seamapigo.Device, error) { baseURL := "https://connect.getseam.com" - if t.baseURL != "" { - baseURL = t.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "thermostats/list" @@ -156,44 +151,44 @@ func (t *thermostatsClient) List(ctx context.Context, request *ThermostatsListRe decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ThermostatsListResponse + var response *seamapigo.ThermostatsListResponse if err := core.DoRequest( ctx, - t.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - t.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Thermostats, nil } -func (t *thermostatsClient) Update(ctx context.Context, request *ThermostatsUpdateRequest) (*ThermostatsUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *seamapigo.ThermostatsUpdateRequest) (bool, error) { baseURL := "https://connect.getseam.com" - if t.baseURL != "" { - baseURL = t.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "thermostats/update" @@ -206,40 +201,36 @@ func (t *thermostatsClient) Update(ctx context.Context, request *ThermostatsUpda decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *ThermostatsUpdateResponse + var response *seamapigo.ThermostatsUpdateResponse if err := core.DoRequest( ctx, - t.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - t.header, + c.header, errorDecoder, ); err != nil { - return response, err + return false, err } - return response, nil -} - -func (t *thermostatsClient) ClimateSettingSchedules() ClimateSettingSchedulesClient { - return t.climateSettingSchedulesClient + return response.Ok, nil } diff --git a/thermostats/climate_setting_schedules.go b/thermostats/climate_setting_schedules.go new file mode 100644 index 0000000..cc86bb6 --- /dev/null +++ b/thermostats/climate_setting_schedules.go @@ -0,0 +1,52 @@ +// This file was auto-generated by Fern from our API Definition. + +package thermostats + +import ( + seamapigo "github.com/seamapi/go" +) + +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.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 { + ClimateSettingScheduleId string `json:"climate_setting_schedule_id"` +} + +type ClimateSettingSchedulesGetRequest struct { + ClimateSettingScheduleId *string `json:"climate_setting_schedule_id,omitempty"` + DeviceId *string `json:"device_id,omitempty"` +} + +type ClimateSettingSchedulesListRequest struct { + DeviceId string `json:"device_id"` +} + +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.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/climate_setting_schedules_create_request.go b/thermostats/climate_setting_schedules_create_request.go deleted file mode 100644 index 29ebea2..0000000 --- a/thermostats/climate_setting_schedules_create_request.go +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package thermostats - -import ( - seamapigo "github.com/seamapi/go" -) - -// ClimateSettingSchedulesCreateRequest is an in-lined request used by the Create endpoint. -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.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"` -} diff --git a/thermostats/climate_setting_schedules_delete_request.go b/thermostats/climate_setting_schedules_delete_request.go deleted file mode 100644 index 3705ef4..0000000 --- a/thermostats/climate_setting_schedules_delete_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package thermostats - -// ClimateSettingSchedulesDeleteRequest is an in-lined request used by the Delete endpoint. -type ClimateSettingSchedulesDeleteRequest struct { - ClimateSettingScheduleId string `json:"climate_setting_schedule_id"` -} diff --git a/thermostats/climate_setting_schedules_get_request.go b/thermostats/climate_setting_schedules_get_request.go deleted file mode 100644 index be04832..0000000 --- a/thermostats/climate_setting_schedules_get_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package thermostats - -// ClimateSettingSchedulesGetRequest is an in-lined request used by the Get endpoint. -type ClimateSettingSchedulesGetRequest struct { - ClimateSettingScheduleId *string `json:"climate_setting_schedule_id,omitempty"` - DeviceId *string `json:"device_id,omitempty"` -} diff --git a/thermostats/climate_setting_schedules_list_request.go b/thermostats/climate_setting_schedules_list_request.go deleted file mode 100644 index 822a25f..0000000 --- a/thermostats/climate_setting_schedules_list_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package thermostats - -// ClimateSettingSchedulesListRequest is an in-lined request used by the List endpoint. -type ClimateSettingSchedulesListRequest struct { - DeviceId string `json:"device_id"` -} diff --git a/thermostats/climate_setting_schedules_update_request.go b/thermostats/climate_setting_schedules_update_request.go deleted file mode 100644 index 3b73ced..0000000 --- a/thermostats/climate_setting_schedules_update_request.go +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package thermostats - -import ( - seamapigo "github.com/seamapi/go" -) - -// ClimateSettingSchedulesUpdateRequest is an in-lined request used by the Update endpoint. -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.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/climate_setting_schedules_client.go b/thermostats/climatesettingschedules/client.go similarity index 68% rename from thermostats/climate_setting_schedules_client.go rename to thermostats/climatesettingschedules/client.go index 25c195d..2b25028 100644 --- a/thermostats/climate_setting_schedules_client.go +++ b/thermostats/climatesettingschedules/client.go @@ -1,6 +1,6 @@ // This file was auto-generated by Fern from our API Definition. -package thermostats +package climatesettingschedules import ( bytes "bytes" @@ -9,37 +9,30 @@ import ( errors "errors" seamapigo "github.com/seamapi/go" core "github.com/seamapi/go/core" + thermostats "github.com/seamapi/go/thermostats" io "io" http "net/http" ) -type ClimateSettingSchedulesClient interface { - Create(ctx context.Context, request *ClimateSettingSchedulesCreateRequest) (*seamapigo.ClimateSettingSchedulesCreateResponse, error) - Delete(ctx context.Context, request *ClimateSettingSchedulesDeleteRequest) (*seamapigo.ClimateSettingSchedulesDeleteResponse, error) - Get(ctx context.Context, request *ClimateSettingSchedulesGetRequest) (*seamapigo.ClimateSettingSchedulesGetResponse, error) - List(ctx context.Context, request *ClimateSettingSchedulesListRequest) (*seamapigo.ClimateSettingSchedulesListResponse, error) - Update(ctx context.Context, request *ClimateSettingSchedulesUpdateRequest) (*seamapigo.ClimateSettingSchedulesUpdateResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewClimateSettingSchedulesClient(opts ...core.ClientOption) ClimateSettingSchedulesClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &climateSettingSchedulesClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type climateSettingSchedulesClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (c *climateSettingSchedulesClient) Create(ctx context.Context, request *ClimateSettingSchedulesCreateRequest) (*seamapigo.ClimateSettingSchedulesCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *thermostats.ClimateSettingSchedulesCreateRequest) (*seamapigo.ClimateSettingSchedulesCreateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -55,17 +48,17 @@ func (c *climateSettingSchedulesClient) Create(ctx context.Context, request *Cli decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -84,12 +77,12 @@ func (c *climateSettingSchedulesClient) Create(ctx context.Context, request *Cli c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (c *climateSettingSchedulesClient) Delete(ctx context.Context, request *ClimateSettingSchedulesDeleteRequest) (*seamapigo.ClimateSettingSchedulesDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *thermostats.ClimateSettingSchedulesDeleteRequest) (*seamapigo.ClimateSettingSchedulesDeleteResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -105,17 +98,17 @@ func (c *climateSettingSchedulesClient) Delete(ctx context.Context, request *Cli decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -134,12 +127,12 @@ func (c *climateSettingSchedulesClient) Delete(ctx context.Context, request *Cli c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (c *climateSettingSchedulesClient) Get(ctx context.Context, request *ClimateSettingSchedulesGetRequest) (*seamapigo.ClimateSettingSchedulesGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *thermostats.ClimateSettingSchedulesGetRequest) (*seamapigo.ClimateSettingSchedulesGetResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -155,17 +148,17 @@ func (c *climateSettingSchedulesClient) Get(ctx context.Context, request *Climat decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -184,12 +177,12 @@ func (c *climateSettingSchedulesClient) Get(ctx context.Context, request *Climat c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (c *climateSettingSchedulesClient) List(ctx context.Context, request *ClimateSettingSchedulesListRequest) (*seamapigo.ClimateSettingSchedulesListResponse, error) { +func (c *Client) List(ctx context.Context, request *thermostats.ClimateSettingSchedulesListRequest) (*seamapigo.ClimateSettingSchedulesListResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -205,17 +198,17 @@ func (c *climateSettingSchedulesClient) List(ctx context.Context, request *Clima decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -234,12 +227,12 @@ func (c *climateSettingSchedulesClient) List(ctx context.Context, request *Clima c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (c *climateSettingSchedulesClient) Update(ctx context.Context, request *ClimateSettingSchedulesUpdateRequest) (*seamapigo.ClimateSettingSchedulesUpdateResponse, error) { +func (c *Client) Update(ctx context.Context, request *thermostats.ClimateSettingSchedulesUpdateRequest) (*seamapigo.ClimateSettingSchedulesUpdateResponse, error) { baseURL := "https://connect.getseam.com" if c.baseURL != "" { baseURL = c.baseURL @@ -255,17 +248,17 @@ func (c *climateSettingSchedulesClient) Update(ctx context.Context, request *Cli decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } @@ -284,7 +277,7 @@ func (c *climateSettingSchedulesClient) Update(ctx context.Context, request *Cli c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/thermostats_get_request.go b/thermostats_get_request.go deleted file mode 100644 index c884dc4..0000000 --- a/thermostats_get_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ThermostatsGetRequest is an in-lined request used by the Get endpoint. -type ThermostatsGetRequest struct { - DeviceId *string `json:"device_id,omitempty"` - Name *string `json:"name,omitempty"` -} diff --git a/thermostats_get_response.go b/thermostats_get_response.go deleted file mode 100644 index 8d185c7..0000000 --- a/thermostats_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ThermostatsGetResponse struct { - Thermostat *Device `json:"thermostat,omitempty"` - Ok bool `json:"ok"` -} diff --git a/thermostats_heat_request.go b/thermostats_heat_request.go deleted file mode 100644 index 3598158..0000000 --- a/thermostats_heat_request.go +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ThermostatsHeatRequest is an in-lined request used by the Heat endpoint. -type ThermostatsHeatRequest struct { - DeviceId string `json:"device_id"` - HeatingSetPointCelsius *float64 `json:"heating_set_point_celsius,omitempty"` - HeatingSetPointFahrenheit *float64 `json:"heating_set_point_fahrenheit,omitempty"` - Sync *bool `json:"sync,omitempty"` -} diff --git a/thermostats_heat_response.go b/thermostats_heat_response.go deleted file mode 100644 index dda5817..0000000 --- a/thermostats_heat_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ThermostatsHeatResponse struct { - Ok bool `json:"ok"` -} diff --git a/thermostats_list_request.go b/thermostats_list_request.go deleted file mode 100644 index 7a549be..0000000 --- a/thermostats_list_request.go +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -// ThermostatsListRequest is an in-lined request used by the List endpoint. -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"` -} diff --git a/thermostats_list_response.go b/thermostats_list_response.go deleted file mode 100644 index 0238d26..0000000 --- a/thermostats_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ThermostatsListResponse struct { - Thermostats []*Device `json:"thermostats,omitempty"` - Ok bool `json:"ok"` -} diff --git a/thermostats_update_request.go b/thermostats_update_request.go deleted file mode 100644 index 4083f83..0000000 --- a/thermostats_update_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// ThermostatsUpdateRequest is an in-lined request used by the Update endpoint. -type ThermostatsUpdateRequest struct { - DeviceId string `json:"device_id"` - DefaultClimateSetting *ThermostatsUpdateRequestDefaultClimateSetting `json:"default_climate_setting,omitempty"` -} diff --git a/thermostats_update_request_default_climate_setting.go b/thermostats_update_request_default_climate_setting.go deleted file mode 100644 index d07215b..0000000 --- a/thermostats_update_request_default_climate_setting.go +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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"` -} diff --git a/thermostats_update_response.go b/thermostats_update_response.go deleted file mode 100644 index 6ec6da4..0000000 --- a/thermostats_update_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type ThermostatsUpdateResponse struct { - Ok bool `json:"ok"` -} diff --git a/types.go b/types.go new file mode 100644 index 0000000..09133a2 --- /dev/null +++ b/types.go @@ -0,0 +1,1490 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + time "time" +) + +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 string `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"` +} + +type AccessCodeStatus string + +const ( + AccessCodeStatusSetting AccessCodeStatus = "setting" + AccessCodeStatusSet AccessCodeStatus = "set" + AccessCodeStatusUnset AccessCodeStatus = "unset" + AccessCodeStatusRemoving AccessCodeStatus = "removing" + AccessCodeStatusUnknown AccessCodeStatus = "unknown" +) + +func NewAccessCodeStatusFromString(s string) (AccessCodeStatus, error) { + switch s { + case "setting": + return AccessCodeStatusSetting, nil + case "set": + return AccessCodeStatusSet, nil + case "unset": + return AccessCodeStatusUnset, nil + case "removing": + return AccessCodeStatusRemoving, nil + case "unknown": + return AccessCodeStatusUnknown, nil + } + var t AccessCodeStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (a AccessCodeStatus) Ptr() *AccessCodeStatus { + return &a +} + +type AccessCodeType string + +const ( + AccessCodeTypeTimeBound AccessCodeType = "time_bound" + AccessCodeTypeOngoing AccessCodeType = "ongoing" +) + +func NewAccessCodeTypeFromString(s string) (AccessCodeType, error) { + switch s { + case "time_bound": + return AccessCodeTypeTimeBound, nil + case "ongoing": + return AccessCodeTypeOngoing, nil + } + var t AccessCodeType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (a AccessCodeType) Ptr() *AccessCodeType { + return &a +} + +type ActionAttempt struct { + Status string + Success *ActionAttemptSuccess + Pending *ActionAttemptPending + Error *ActionAttemptError +} + +func NewActionAttemptFromSuccess(value *ActionAttemptSuccess) *ActionAttempt { + return &ActionAttempt{Status: "success", Success: value} +} + +func NewActionAttemptFromPending(value *ActionAttemptPending) *ActionAttempt { + return &ActionAttempt{Status: "pending", Pending: value} +} + +func NewActionAttemptFromError(value *ActionAttemptError) *ActionAttempt { + return &ActionAttempt{Status: "error", Error: value} +} + +func (a *ActionAttempt) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Status string `json:"status"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + a.Status = unmarshaler.Status + switch unmarshaler.Status { + case "success": + value := new(ActionAttemptSuccess) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Success = value + case "pending": + value := new(ActionAttemptPending) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Pending = value + case "error": + value := new(ActionAttemptError) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Error = value + } + return nil +} + +func (a ActionAttempt) MarshalJSON() ([]byte, error) { + switch a.Status { + default: + return nil, fmt.Errorf("invalid type %s in %T", a.Status, a) + case "success": + var marshaler = struct { + Status string `json:"status"` + *ActionAttemptSuccess + }{ + Status: a.Status, + ActionAttemptSuccess: a.Success, + } + return json.Marshal(marshaler) + case "pending": + var marshaler = struct { + Status string `json:"status"` + *ActionAttemptPending + }{ + Status: a.Status, + ActionAttemptPending: a.Pending, + } + return json.Marshal(marshaler) + case "error": + var marshaler = struct { + Status string `json:"status"` + *ActionAttemptError + }{ + Status: a.Status, + ActionAttemptError: a.Error, + } + return json.Marshal(marshaler) + } +} + +type ActionAttemptVisitor interface { + VisitSuccess(*ActionAttemptSuccess) error + VisitPending(*ActionAttemptPending) error + VisitError(*ActionAttemptError) error +} + +func (a *ActionAttempt) Accept(visitor ActionAttemptVisitor) error { + switch a.Status { + default: + return fmt.Errorf("invalid type %s in %T", a.Status, a) + case "success": + return visitor.VisitSuccess(a.Success) + case "pending": + return visitor.VisitPending(a.Pending) + case "error": + return visitor.VisitError(a.Error) + } +} + +type ActionAttemptError struct { + ActionType string `json:"action_type"` + ActionAttemptId string `json:"action_attempt_id"` + Result *string `json:"result,omitempty"` + Error *ActionAttemptErrorError `json:"error,omitempty"` +} + +type ActionAttemptErrorError struct { + Type string `json:"type"` + Message string `json:"message"` +} + +type ActionAttemptPending struct { + ActionType string `json:"action_type"` + ActionAttemptId string `json:"action_attempt_id"` + Result *string `json:"result,omitempty"` + Error *string `json:"error,omitempty"` +} + +type ActionAttemptSuccess struct { + ActionType string `json:"action_type"` + ActionAttemptId string `json:"action_attempt_id"` + Result interface{} `json:"result,omitempty"` + Error *string `json:"error,omitempty"` +} + +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"` +} + +type ClientSession struct { + ClientSessionId string `json:"client_session_id"` + UserIdentifierKey *string `json:"user_identifier_key,omitempty"` + CreatedAt time.Time `json:"created_at"` + Token string `json:"token"` + DeviceCount float64 `json:"device_count"` + ConnectedAccountIds []string `json:"connected_account_ids,omitempty"` + ConnectWebviewIds []string `json:"connect_webview_ids,omitempty"` + WorkspaceId string `json:"workspace_id"` +} + +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 *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 +} + +func (c *ClimateSettingSchedule) ScheduleType() string { + return c.scheduleType +} + +func (c *ClimateSettingSchedule) UnmarshalJSON(data []byte) error { + type unmarshaler ClimateSettingSchedule + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ClimateSettingSchedule(value) + c.scheduleType = "time_bound" + return nil +} + +func (c *ClimateSettingSchedule) MarshalJSON() ([]byte, error) { + type embed ClimateSettingSchedule + var marshaler = struct { + embed + ScheduleType string `json:"schedule_type"` + }{ + embed: embed(*c), + ScheduleType: "time_bound", + } + return json.Marshal(marshaler) +} + +type ClimateSettingScheduleHvacModeSetting string + +const ( + ClimateSettingScheduleHvacModeSettingOff ClimateSettingScheduleHvacModeSetting = "off" + ClimateSettingScheduleHvacModeSettingHeat ClimateSettingScheduleHvacModeSetting = "heat" + ClimateSettingScheduleHvacModeSettingCool ClimateSettingScheduleHvacModeSetting = "cool" + ClimateSettingScheduleHvacModeSettingHeatcool ClimateSettingScheduleHvacModeSetting = "heatcool" +) + +func NewClimateSettingScheduleHvacModeSettingFromString(s string) (ClimateSettingScheduleHvacModeSetting, error) { + switch s { + case "off": + return ClimateSettingScheduleHvacModeSettingOff, nil + case "heat": + return ClimateSettingScheduleHvacModeSettingHeat, nil + case "cool": + return ClimateSettingScheduleHvacModeSettingCool, nil + case "heatcool": + return ClimateSettingScheduleHvacModeSettingHeatcool, nil + } + var t ClimateSettingScheduleHvacModeSetting + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ClimateSettingScheduleHvacModeSetting) Ptr() *ClimateSettingScheduleHvacModeSetting { + return &c +} + +type ClimateSettingSchedulesCreateRequestHvacModeSetting string + +const ( + ClimateSettingSchedulesCreateRequestHvacModeSettingOff ClimateSettingSchedulesCreateRequestHvacModeSetting = "off" + ClimateSettingSchedulesCreateRequestHvacModeSettingHeat ClimateSettingSchedulesCreateRequestHvacModeSetting = "heat" + ClimateSettingSchedulesCreateRequestHvacModeSettingCool ClimateSettingSchedulesCreateRequestHvacModeSetting = "cool" + ClimateSettingSchedulesCreateRequestHvacModeSettingHeatcool ClimateSettingSchedulesCreateRequestHvacModeSetting = "heatcool" +) + +func NewClimateSettingSchedulesCreateRequestHvacModeSettingFromString(s string) (ClimateSettingSchedulesCreateRequestHvacModeSetting, error) { + switch s { + case "off": + return ClimateSettingSchedulesCreateRequestHvacModeSettingOff, nil + case "heat": + return ClimateSettingSchedulesCreateRequestHvacModeSettingHeat, nil + case "cool": + return ClimateSettingSchedulesCreateRequestHvacModeSettingCool, nil + case "heatcool": + 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 *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` + Ok bool `json:"ok"` +} + +type ClimateSettingSchedulesDeleteResponse struct { + Ok bool `json:"ok"` +} + +type ClimateSettingSchedulesGetResponse struct { + ClimateSettingSchedule *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` + Ok bool `json:"ok"` +} + +type ClimateSettingSchedulesListResponse struct { + ClimateSettingSchedules []*ClimateSettingSchedule `json:"climate_setting_schedules,omitempty"` + Ok bool `json:"ok"` +} + +type ClimateSettingSchedulesUpdateRequestHvacModeSetting string + +const ( + ClimateSettingSchedulesUpdateRequestHvacModeSettingOff ClimateSettingSchedulesUpdateRequestHvacModeSetting = "off" + ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat ClimateSettingSchedulesUpdateRequestHvacModeSetting = "heat" + ClimateSettingSchedulesUpdateRequestHvacModeSettingCool ClimateSettingSchedulesUpdateRequestHvacModeSetting = "cool" + ClimateSettingSchedulesUpdateRequestHvacModeSettingHeatcool ClimateSettingSchedulesUpdateRequestHvacModeSetting = "heatcool" +) + +func NewClimateSettingSchedulesUpdateRequestHvacModeSettingFromString(s string) (ClimateSettingSchedulesUpdateRequestHvacModeSetting, error) { + switch s { + case "off": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingOff, nil + case "heat": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingHeat, nil + case "cool": + return ClimateSettingSchedulesUpdateRequestHvacModeSettingCool, nil + case "heatcool": + 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 *ClimateSettingSchedule `json:"climate_setting_schedule,omitempty"` + 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"` +} + +type ConnectWebviewDeviceSelectionMode string + +const ( + ConnectWebviewDeviceSelectionModeNone ConnectWebviewDeviceSelectionMode = "none" + ConnectWebviewDeviceSelectionModeSingle ConnectWebviewDeviceSelectionMode = "single" + ConnectWebviewDeviceSelectionModeMultiple ConnectWebviewDeviceSelectionMode = "multiple" +) + +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 ConnectWebviewDeviceSelectionMode) Ptr() *ConnectWebviewDeviceSelectionMode { + return &c +} + +type ConnectWebviewStatus string + +const ( + ConnectWebviewStatusPending ConnectWebviewStatus = "pending" + ConnectWebviewStatusFailed ConnectWebviewStatus = "failed" + ConnectWebviewStatusAuthorized ConnectWebviewStatus = "authorized" +) + +func NewConnectWebviewStatusFromString(s string) (ConnectWebviewStatus, error) { + switch s { + case "pending": + return ConnectWebviewStatusPending, nil + case "failed": + return ConnectWebviewStatusFailed, nil + case "authorized": + return ConnectWebviewStatusAuthorized, nil + } + var t ConnectWebviewStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (c ConnectWebviewStatus) Ptr() *ConnectWebviewStatus { + return &c +} + +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"` +} + +type ConnectedAccountCustomMetadataValue struct { + typeName string + String string + Double float64 + Boolean bool + StringOptional *string +} + +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 { + c.typeName = "string" + 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) +} + +func (c ConnectedAccountCustomMetadataValue) 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 "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 { + switch c.typeName { + default: + 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) + } +} + +type ConnectedAccountUserIdentifier struct { + Username *string `json:"username,omitempty"` + ApiUrl *string `json:"api_url,omitempty"` + Email *string `json:"email,omitempty"` + Phone *string `json:"phone,omitempty"` + Exclusive *bool `json:"exclusive,omitempty"` +} + +type ConnectedAccountsGetRequestConnectedAccountId struct { + ConnectedAccountId string `json:"connected_account_id"` +} + +type ConnectedAccountsGetRequestEmail struct { + Email string `json:"email"` +} + +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"` +} + +type Device struct { + DeviceId string `json:"device_id"` + DeviceType DeviceType `json:"device_type,omitempty"` + CapabilitiesSupported []DeviceCapabilitiesSupportedItem `json:"capabilities_supported,omitempty"` + Properties *DeviceProperties `json:"properties,omitempty"` + Location interface{} `json:"location,omitempty"` + ConnectedAccountId string `json:"connected_account_id"` + WorkspaceId string `json:"workspace_id"` + Errors []*DeviceErrorsItem `json:"errors,omitempty"` + Warnings []*DeviceWarningsItem `json:"warnings,omitempty"` + CreatedAt time.Time `json:"created_at"` + IsManaged string `json:"is_managed"` +} + +type DeviceCapabilitiesSupportedItem string + +const ( + DeviceCapabilitiesSupportedItemAccessCode DeviceCapabilitiesSupportedItem = "access_code" + DeviceCapabilitiesSupportedItemLock DeviceCapabilitiesSupportedItem = "lock" + DeviceCapabilitiesSupportedItemNoiseDetection DeviceCapabilitiesSupportedItem = "noise_detection" + DeviceCapabilitiesSupportedItemThermostat DeviceCapabilitiesSupportedItem = "thermostat" + DeviceCapabilitiesSupportedItemBattery DeviceCapabilitiesSupportedItem = "battery" +) + +func NewDeviceCapabilitiesSupportedItemFromString(s string) (DeviceCapabilitiesSupportedItem, error) { + switch s { + case "access_code": + return DeviceCapabilitiesSupportedItemAccessCode, nil + case "lock": + return DeviceCapabilitiesSupportedItemLock, nil + case "noise_detection": + return DeviceCapabilitiesSupportedItemNoiseDetection, nil + case "thermostat": + return DeviceCapabilitiesSupportedItemThermostat, nil + case "battery": + return DeviceCapabilitiesSupportedItemBattery, nil + } + var t DeviceCapabilitiesSupportedItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DeviceCapabilitiesSupportedItem) Ptr() *DeviceCapabilitiesSupportedItem { + return &d +} + +type DeviceErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` +} + +type DeviceProperties struct { + Online bool `json:"online"` + Name string `json:"name"` + Model *DevicePropertiesModel `json:"model,omitempty"` + AugustMetadata *AugustDeviceMetadata `json:"august_metadata,omitempty"` + SchlageMetadata *SchlageDeviceMetadata `json:"schlage_metadata,omitempty"` + SmartthingsMetadata interface{} `json:"smartthings_metadata,omitempty"` + CurrentClimateSetting *CurrentClimateSetting `json:"current_climate_setting,omitempty"` +} + +type DevicePropertiesModel struct { + DisplayName string `json:"display_name"` +} + +type DeviceType string + +const ( + DeviceTypeAkuvoxLock DeviceType = "akuvox_lock" + DeviceTypeAugustLock DeviceType = "august_lock" + DeviceTypeBrivoAccessPoint DeviceType = "brivo_access_point" + DeviceTypeButterflymxPanel DeviceType = "butterflymx_panel" + DeviceTypeDoorkingLock DeviceType = "doorking_lock" + DeviceTypeGenieDoor DeviceType = "genie_door" + DeviceTypeIglooLock DeviceType = "igloo_lock" + DeviceTypeLinearLock DeviceType = "linear_lock" + DeviceTypeLocklyLock DeviceType = "lockly_lock" + DeviceTypeKwiksetLock DeviceType = "kwikset_lock" + DeviceTypeNukiLock DeviceType = "nuki_lock" + DeviceTypeSaltoLock DeviceType = "salto_lock" + DeviceTypeSchlageLock DeviceType = "schlage_lock" + DeviceTypeSeamRelay DeviceType = "seam_relay" + DeviceTypeSmartthingsLock DeviceType = "smartthings_lock" + DeviceTypeYaleLock DeviceType = "yale_lock" + DeviceTypeTwoNIntercom DeviceType = "two_n_intercom" + DeviceTypeControlbywebDevice DeviceType = "controlbyweb_device" + DeviceTypeTtlockLock DeviceType = "ttlock_lock" + DeviceTypeIgloohomeLock DeviceType = "igloohome_lock" + DeviceTypeHubitatLock DeviceType = "hubitat_lock" + DeviceTypeNoiseawareActivityZone DeviceType = "noiseaware_activity_zone" + DeviceTypeMinutSensor DeviceType = "minut_sensor" + DeviceTypeEcobeeThermostat DeviceType = "ecobee_thermostat" + DeviceTypeNestThermostat DeviceType = "nest_thermostat" +) + +func NewDeviceTypeFromString(s string) (DeviceType, error) { + switch s { + case "akuvox_lock": + return DeviceTypeAkuvoxLock, nil + case "august_lock": + return DeviceTypeAugustLock, nil + case "brivo_access_point": + return DeviceTypeBrivoAccessPoint, nil + case "butterflymx_panel": + return DeviceTypeButterflymxPanel, nil + case "doorking_lock": + return DeviceTypeDoorkingLock, nil + case "genie_door": + return DeviceTypeGenieDoor, nil + case "igloo_lock": + return DeviceTypeIglooLock, nil + case "linear_lock": + return DeviceTypeLinearLock, nil + case "lockly_lock": + return DeviceTypeLocklyLock, nil + case "kwikset_lock": + return DeviceTypeKwiksetLock, nil + case "nuki_lock": + return DeviceTypeNukiLock, nil + case "salto_lock": + return DeviceTypeSaltoLock, nil + case "schlage_lock": + return DeviceTypeSchlageLock, nil + case "seam_relay": + return DeviceTypeSeamRelay, nil + case "smartthings_lock": + return DeviceTypeSmartthingsLock, nil + case "yale_lock": + return DeviceTypeYaleLock, nil + case "two_n_intercom": + return DeviceTypeTwoNIntercom, nil + case "controlbyweb_device": + return DeviceTypeControlbywebDevice, nil + case "ttlock_lock": + return DeviceTypeTtlockLock, nil + case "igloohome_lock": + return DeviceTypeIgloohomeLock, nil + case "hubitat_lock": + return DeviceTypeHubitatLock, nil + case "noiseaware_activity_zone": + return DeviceTypeNoiseawareActivityZone, nil + case "minut_sensor": + return DeviceTypeMinutSensor, nil + case "ecobee_thermostat": + return DeviceTypeEcobeeThermostat, nil + case "nest_thermostat": + return DeviceTypeNestThermostat, nil + } + var t DeviceType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DeviceType) Ptr() *DeviceType { + return &d +} + +type DeviceWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` +} + +type 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 DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem string + +const ( + DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = "stable" + DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem = "consumer_smartlocks" +) + +func NewDevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemFromString(s string) (DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem, error) { + switch s { + case "stable": + return DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemStable, nil + case "consumer_smartlocks": + return DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItemConsumerSmartlocks, nil + } + var t DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (d DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem) Ptr() *DevicesListDeviceProvidersResponseDeviceProvidersItemProviderCategoriesItem { + return &d +} + +type Event struct { + EventId string `json:"event_id"` + DeviceId *string `json:"device_id,omitempty"` + EventType string `json:"event_type"` + WorkspaceId string `json:"workspace_id"` + CreatedAt time.Time `json:"created_at"` + OccurredAt time.Time `json:"occurred_at"` +} + +type HvacModeSetting string + +const ( + HvacModeSettingOff HvacModeSetting = "off" + HvacModeSettingHeat HvacModeSetting = "heat" + HvacModeSettingCool HvacModeSetting = "cool" + HvacModeSettingHeatcool HvacModeSetting = "heatcool" +) + +func NewHvacModeSettingFromString(s string) (HvacModeSetting, error) { + switch s { + case "off": + return HvacModeSettingOff, nil + case "heat": + return HvacModeSettingHeat, nil + case "cool": + return HvacModeSettingCool, nil + case "heatcool": + 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"` + Name string `json:"name"` + NoiseThresholdNrs *float64 `json:"noise_threshold_nrs,omitempty"` + StartsDailyAt string `json:"starts_daily_at"` + EndsDailyAt string `json:"ends_daily_at"` + NoiseThresholdDecibels float64 `json:"noise_threshold_decibels"` +} + +type NoiseThresholdsCreateResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type NoiseThresholdsDeleteResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type NoiseThresholdsGetResponse struct { + NoiseThreshold *NoiseThreshold `json:"noise_threshold,omitempty"` + Ok bool `json:"ok"` +} + +type NoiseThresholdsListResponse struct { + NoiseThresholds []*NoiseThreshold `json:"noise_thresholds,omitempty"` + Ok bool `json:"ok"` +} + +type NoiseThresholdsUpdateResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +type NukiDeviceMetadata struct { + KeypadBatteryCritical *bool `json:"keypad_battery_critical,omitempty"` +} + +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 ServiceByServiceNameResponse struct { + Ok bool `json:"ok"` + LastServiceEvaluationAt string `json:"last_service_evaluation_at"` + ServiceHealth *ServiceHealth `json:"service_health,omitempty"` +} + +type ServiceHealth struct { + Service string `json:"service"` + Status ServiceHealthStatus `json:"status,omitempty"` + Description string `json:"description"` +} + +type ServiceHealthStatus string + +const ( + ServiceHealthStatusHealthy ServiceHealthStatus = "healthy" + ServiceHealthStatusDegraded ServiceHealthStatus = "degraded" + ServiceHealthStatusDown ServiceHealthStatus = "down" +) + +func NewServiceHealthStatusFromString(s string) (ServiceHealthStatus, error) { + switch s { + case "healthy": + return ServiceHealthStatusHealthy, nil + case "degraded": + return ServiceHealthStatusDegraded, nil + case "down": + return ServiceHealthStatusDown, nil + } + var t ServiceHealthStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (s ServiceHealthStatus) Ptr() *ServiceHealthStatus { + return &s +} + +type SimulateCreateUnmanagedAccessCodeResponse struct { + AccessCode *SimulateCreateUnmanagedAccessCodeResponseAccessCode `json:"access_code,omitempty"` + Ok bool `json:"ok"` +} + +type SimulateCreateUnmanagedAccessCodeResponseAccessCode struct { + Type string + Ongoing *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing + TimeBound *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound +} + +func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeFromOngoing(value *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) *SimulateCreateUnmanagedAccessCodeResponseAccessCode { + return &SimulateCreateUnmanagedAccessCodeResponseAccessCode{Type: "ongoing", Ongoing: value} +} + +func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeFromTimeBound(value *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) *SimulateCreateUnmanagedAccessCodeResponseAccessCode { + return &SimulateCreateUnmanagedAccessCodeResponseAccessCode{Type: "time_bound", TimeBound: value} +} + +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 + 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) + 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) + } +} + +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) + } +} + +type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing struct { + AccessCodeId string `json:"access_code_id"` + Code *string `json:"code,omitempty"` + CreatedAt *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt `json:"created_at,omitempty"` + IsManaged string `json:"is_managed"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` + status string +} + +func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) Status() string { + return s.status +} + +func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing) UnmarshalJSON(data []byte) error { + type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoing(value) + s.status = "set" + 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) +} + +type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt struct { + typeName string + String string + DateTime time.Time +} + +func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromString(value string) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { + return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "string", String: value} +} + +func NewSimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtFromDateTime(value time.Time) *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt { + return &SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt{typeName: "dateTime", DateTime: value} +} + +func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) UnmarshalJSON(data []byte) error { + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + s.typeName = "string" + s.String = valueString + return nil + } + var valueDateTime time.Time + if err := json.Unmarshal(data, &valueDateTime); err == nil { + s.typeName = "dateTime" + s.DateTime = valueDateTime + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, s) +} + +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) + } +} + +type SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor interface { + VisitString(string) error + VisitDateTime(time.Time) error +} + +func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAt) Accept(visitor SimulateCreateUnmanagedAccessCodeResponseAccessCodeOngoingCreatedAtVisitor) error { + switch s.typeName { + default: + return fmt.Errorf("invalid type %s in %T", s.typeName, s) + case "string": + return visitor.VisitString(s.String) + case "dateTime": + return visitor.VisitDateTime(s.DateTime) + } +} + +type SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound struct { + AccessCodeId string `json:"access_code_id"` + Code *string `json:"code,omitempty"` + CreatedAt *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBoundCreatedAt `json:"created_at,omitempty"` + IsManaged string `json:"is_managed"` + StartsAt *string `json:"starts_at,omitempty"` + EndsAt *string `json:"ends_at,omitempty"` + status string +} + +func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) Status() string { + return s.status +} + +func (s *SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound) UnmarshalJSON(data []byte) error { + type unmarshaler SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SimulateCreateUnmanagedAccessCodeResponseAccessCodeTimeBound(value) + s.status = "set" + 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) +} + +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) + } +} + +type SimulateTriggerNoiseThresholdResponse struct { + Ok bool `json:"ok"` +} + +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 +} + +type UnmanagedConvertToManagedResponse struct { + Ok bool `json:"ok"` +} + +type UnmanagedDeleteResponse struct { + ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` + Ok bool `json:"ok"` +} + +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 string `json:"is_managed"` + Properties *UnmanagedDeviceProperties `json:"properties,omitempty"` +} + +type UnmanagedDeviceErrorsItem struct { + ErrorCode string `json:"error_code"` + Message string `json:"message"` +} + +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 UnmanagedDevicePropertiesModel struct { + DisplayName string `json:"display_name"` +} + +type UnmanagedDeviceWarningsItem struct { + WarningCode string `json:"warning_code"` + Message string `json:"message"` +} + +type UnmanagedGetResponse struct { + AccessCode *UnmanagedGetResponseAccessCode `json:"access_code,omitempty"` + Ok bool `json:"ok"` +} + +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 string `json:"is_managed"` + StartsAt *time.Time `json:"starts_at,omitempty"` + EndsAt *time.Time `json:"ends_at,omitempty"` + status string +} + +func (u *UnmanagedGetResponseAccessCode) Status() string { + return u.status +} + +func (u *UnmanagedGetResponseAccessCode) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedGetResponseAccessCode + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedGetResponseAccessCode(value) + u.status = "set" + 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) +} + +type UnmanagedGetResponseAccessCodeType string + +const ( + UnmanagedGetResponseAccessCodeTypeTimeBound UnmanagedGetResponseAccessCodeType = "time_bound" + UnmanagedGetResponseAccessCodeTypeOngoing UnmanagedGetResponseAccessCodeType = "ongoing" +) + +func NewUnmanagedGetResponseAccessCodeTypeFromString(s string) (UnmanagedGetResponseAccessCodeType, error) { + switch s { + case "time_bound": + return UnmanagedGetResponseAccessCodeTypeTimeBound, nil + case "ongoing": + return UnmanagedGetResponseAccessCodeTypeOngoing, nil + } + var t UnmanagedGetResponseAccessCodeType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (u UnmanagedGetResponseAccessCodeType) Ptr() *UnmanagedGetResponseAccessCodeType { + return &u +} + +type UnmanagedListResponse struct { + Devices []*UnmanagedDevice `json:"devices,omitempty"` + Ok bool `json:"ok"` +} + +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 string `json:"is_managed"` + StartsAt *time.Time `json:"starts_at,omitempty"` + EndsAt *time.Time `json:"ends_at,omitempty"` + status string +} + +func (u *UnmanagedListResponseAccessCodesItem) Status() string { + return u.status +} + +func (u *UnmanagedListResponseAccessCodesItem) UnmarshalJSON(data []byte) error { + type unmarshaler UnmanagedListResponseAccessCodesItem + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UnmanagedListResponseAccessCodesItem(value) + u.status = "set" + 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) +} + +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 Webhook struct { + WebhookId string `json:"webhook_id"` + Url string `json:"url"` + EventTypes []string `json:"event_types,omitempty"` + Secret *string `json:"secret,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"` +} diff --git a/unauthorized_error.go b/unauthorized_error.go deleted file mode 100644 index ba36c8f..0000000 --- a/unauthorized_error.go +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - core "github.com/seamapi/go/core" -) - -type UnauthorizedError struct { - *core.APIError - Body any -} - -func (u *UnauthorizedError) UnmarshalJSON(data []byte) error { - var body any - if err := json.Unmarshal(data, &body); err != nil { - return err - } - u.StatusCode = 401 - u.Body = body - return nil -} - -func (u *UnauthorizedError) MarshalJSON() ([]byte, error) { - return json.Marshal(u.Body) -} diff --git a/unmanaged_convert_to_managed_response.go b/unmanaged_convert_to_managed_response.go deleted file mode 100644 index 2d1f73a..0000000 --- a/unmanaged_convert_to_managed_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedConvertToManagedResponse struct { - Ok bool `json:"ok"` -} diff --git a/unmanaged_delete_response.go b/unmanaged_delete_response.go deleted file mode 100644 index 4be4d33..0000000 --- a/unmanaged_delete_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedDeleteResponse struct { - ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"` - Ok bool `json:"ok"` -} diff --git a/unmanaged_device.go b/unmanaged_device.go deleted file mode 100644 index 9ca150c..0000000 --- a/unmanaged_device.go +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - time "time" -) - -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 string `json:"is_managed"` - Properties *UnmanagedDeviceProperties `json:"properties,omitempty"` -} diff --git a/unmanaged_device_errors_item.go b/unmanaged_device_errors_item.go deleted file mode 100644 index fab9b77..0000000 --- a/unmanaged_device_errors_item.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedDeviceErrorsItem struct { - ErrorCode string `json:"error_code"` - Message string `json:"message"` -} diff --git a/unmanaged_device_properties.go b/unmanaged_device_properties.go deleted file mode 100644 index c5cbd04..0000000 --- a/unmanaged_device_properties.go +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -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"` -} diff --git a/unmanaged_device_properties_model.go b/unmanaged_device_properties_model.go deleted file mode 100644 index 9b881b9..0000000 --- a/unmanaged_device_properties_model.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedDevicePropertiesModel struct { - DisplayName string `json:"display_name"` -} diff --git a/unmanaged_device_warnings_item.go b/unmanaged_device_warnings_item.go deleted file mode 100644 index 50fca6f..0000000 --- a/unmanaged_device_warnings_item.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedDeviceWarningsItem struct { - WarningCode string `json:"warning_code"` - Message string `json:"message"` -} diff --git a/unmanaged_get_response.go b/unmanaged_get_response.go deleted file mode 100644 index ed71c7b..0000000 --- a/unmanaged_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedGetResponse struct { - AccessCode *UnmanagedGetResponseAccessCode `json:"access_code,omitempty"` - Ok bool `json:"ok"` -} diff --git a/unmanaged_get_response_access_code.go b/unmanaged_get_response_access_code.go deleted file mode 100644 index f123d85..0000000 --- a/unmanaged_get_response_access_code.go +++ /dev/null @@ -1,50 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - time "time" -) - -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 *any `json:"errors,omitempty"` - Warnings *any `json:"warnings,omitempty"` - IsManaged string `json:"is_managed"` - StartsAt *time.Time `json:"starts_at,omitempty"` - EndsAt *time.Time `json:"ends_at,omitempty"` - status string -} - -func (u *UnmanagedGetResponseAccessCode) Status() string { - return u.status -} - -func (u *UnmanagedGetResponseAccessCode) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedGetResponseAccessCode - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UnmanagedGetResponseAccessCode(value) - u.status = "set" - 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) -} diff --git a/unmanaged_get_response_access_code_type.go b/unmanaged_get_response_access_code_type.go deleted file mode 100644 index 0f71c46..0000000 --- a/unmanaged_get_response_access_code_type.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type UnmanagedGetResponseAccessCodeType uint8 - -const ( - UnmanagedGetResponseAccessCodeTypeTimeBound UnmanagedGetResponseAccessCodeType = iota + 1 - UnmanagedGetResponseAccessCodeTypeOngoing -) - -func (u UnmanagedGetResponseAccessCodeType) String() string { - switch u { - default: - return strconv.Itoa(int(u)) - case UnmanagedGetResponseAccessCodeTypeTimeBound: - return "time_bound" - case UnmanagedGetResponseAccessCodeTypeOngoing: - return "ongoing" - } -} - -func (u UnmanagedGetResponseAccessCodeType) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", u.String())), nil -} - -func (u *UnmanagedGetResponseAccessCodeType) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "time_bound": - value := UnmanagedGetResponseAccessCodeTypeTimeBound - *u = value - case "ongoing": - value := UnmanagedGetResponseAccessCodeTypeOngoing - *u = value - } - return nil -} diff --git a/unmanaged_list_response.go b/unmanaged_list_response.go deleted file mode 100644 index 48fd878..0000000 --- a/unmanaged_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedListResponse struct { - Devices []*UnmanagedDevice `json:"devices,omitempty"` - Ok bool `json:"ok"` -} diff --git a/unmanaged_list_response_access_codes_item.go b/unmanaged_list_response_access_codes_item.go deleted file mode 100644 index 1ace9fe..0000000 --- a/unmanaged_list_response_access_codes_item.go +++ /dev/null @@ -1,50 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - time "time" -) - -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 *any `json:"errors,omitempty"` - Warnings *any `json:"warnings,omitempty"` - IsManaged string `json:"is_managed"` - StartsAt *time.Time `json:"starts_at,omitempty"` - EndsAt *time.Time `json:"ends_at,omitempty"` - status string -} - -func (u *UnmanagedListResponseAccessCodesItem) Status() string { - return u.status -} - -func (u *UnmanagedListResponseAccessCodesItem) UnmarshalJSON(data []byte) error { - type unmarshaler UnmanagedListResponseAccessCodesItem - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UnmanagedListResponseAccessCodesItem(value) - u.status = "set" - 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) -} diff --git a/unmanaged_list_response_access_codes_item_type.go b/unmanaged_list_response_access_codes_item_type.go deleted file mode 100644 index 3646a78..0000000 --- a/unmanaged_list_response_access_codes_item_type.go +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - strconv "strconv" -) - -type UnmanagedListResponseAccessCodesItemType uint8 - -const ( - UnmanagedListResponseAccessCodesItemTypeTimeBound UnmanagedListResponseAccessCodesItemType = iota + 1 - UnmanagedListResponseAccessCodesItemTypeOngoing -) - -func (u UnmanagedListResponseAccessCodesItemType) String() string { - switch u { - default: - return strconv.Itoa(int(u)) - case UnmanagedListResponseAccessCodesItemTypeTimeBound: - return "time_bound" - case UnmanagedListResponseAccessCodesItemTypeOngoing: - return "ongoing" - } -} - -func (u UnmanagedListResponseAccessCodesItemType) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%q", u.String())), nil -} - -func (u *UnmanagedListResponseAccessCodesItemType) UnmarshalJSON(data []byte) error { - var raw string - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - switch raw { - case "time_bound": - value := UnmanagedListResponseAccessCodesItemTypeTimeBound - *u = value - case "ongoing": - value := UnmanagedListResponseAccessCodesItemTypeOngoing - *u = value - } - return nil -} diff --git a/unmanaged_update_response.go b/unmanaged_update_response.go deleted file mode 100644 index 5fdfd46..0000000 --- a/unmanaged_update_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type UnmanagedUpdateResponse struct { - Ok bool `json:"ok"` -} diff --git a/webhook.go b/webhook.go deleted file mode 100644 index d150027..0000000 --- a/webhook.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type Webhook struct { - WebhookId string `json:"webhook_id"` - Url string `json:"url"` - EventTypes *[]string `json:"event_types,omitempty"` - Secret *string `json:"secret,omitempty"` -} diff --git a/webhooks.go b/webhooks.go new file mode 100644 index 0000000..1aa2d86 --- /dev/null +++ b/webhooks.go @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +type WebhooksCreateRequest struct { + Url string `json:"url"` + EventTypes []string `json:"event_types,omitempty"` +} + +type WebhooksDeleteRequest struct { + WebhookId string `json:"webhook_id"` +} + +type WebhooksGetRequest struct { + WebhookId string `json:"webhook_id"` +} + +type WebhooksCreateResponse struct { + Webhook *Webhook `json:"webhook,omitempty"` + Ok bool `json:"ok"` +} + +type WebhooksDeleteResponse struct { + Ok bool `json:"ok"` +} + +type WebhooksGetResponse struct { + Webhook *Webhook `json:"webhook,omitempty"` + Ok bool `json:"ok"` +} + +type WebhooksListResponse struct { + Webhooks []*Webhook `json:"webhooks,omitempty"` + Ok bool `json:"ok"` +} diff --git a/webhooks_client.go b/webhooks/client.go similarity index 66% rename from webhooks_client.go rename to webhooks/client.go index 3acde40..d603532 100644 --- a/webhooks_client.go +++ b/webhooks/client.go @@ -1,46 +1,40 @@ // This file was auto-generated by Fern from our API Definition. -package api +package webhooks 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 WebhooksClient interface { - Create(ctx context.Context, request *WebhooksCreateRequest) (*WebhooksCreateResponse, error) - Delete(ctx context.Context, request *WebhooksDeleteRequest) (*WebhooksDeleteResponse, error) - Get(ctx context.Context, request *WebhooksGetRequest) (*WebhooksGetResponse, error) - List(ctx context.Context) (*WebhooksListResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewWebhooksClient(opts ...core.ClientOption) WebhooksClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &webhooksClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type webhooksClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (w *webhooksClient) Create(ctx context.Context, request *WebhooksCreateRequest) (*WebhooksCreateResponse, error) { +func (c *Client) Create(ctx context.Context, request *seamapigo.WebhooksCreateRequest) (*seamapigo.WebhooksCreateResponse, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "webhooks/create" @@ -53,44 +47,44 @@ func (w *webhooksClient) Create(ctx context.Context, request *WebhooksCreateRequ decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WebhooksCreateResponse + var response *seamapigo.WebhooksCreateResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (w *webhooksClient) Delete(ctx context.Context, request *WebhooksDeleteRequest) (*WebhooksDeleteResponse, error) { +func (c *Client) Delete(ctx context.Context, request *seamapigo.WebhooksDeleteRequest) (*seamapigo.WebhooksDeleteResponse, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "webhooks/delete" @@ -103,44 +97,44 @@ func (w *webhooksClient) Delete(ctx context.Context, request *WebhooksDeleteRequ decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WebhooksDeleteResponse + var response *seamapigo.WebhooksDeleteResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodDelete, request, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (w *webhooksClient) Get(ctx context.Context, request *WebhooksGetRequest) (*WebhooksGetResponse, error) { +func (c *Client) Get(ctx context.Context, request *seamapigo.WebhooksGetRequest) (*seamapigo.WebhooksGetResponse, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "webhooks/get" @@ -153,44 +147,44 @@ func (w *webhooksClient) Get(ctx context.Context, request *WebhooksGetRequest) ( decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WebhooksGetResponse + var response *seamapigo.WebhooksGetResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodPost, request, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } -func (w *webhooksClient) List(ctx context.Context) (*WebhooksListResponse, error) { +func (c *Client) List(ctx context.Context) (*seamapigo.WebhooksListResponse, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "webhooks/list" @@ -203,36 +197,36 @@ func (w *webhooksClient) List(ctx context.Context) (*WebhooksListResponse, error decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WebhooksListResponse + var response *seamapigo.WebhooksListResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodGet, nil, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/webhooks_create_request.go b/webhooks_create_request.go deleted file mode 100644 index d3f8280..0000000 --- a/webhooks_create_request.go +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// WebhooksCreateRequest is an in-lined request used by the Create endpoint. -type WebhooksCreateRequest struct { - Url string `json:"url"` - EventTypes *[]string `json:"event_types,omitempty"` -} diff --git a/webhooks_create_response.go b/webhooks_create_response.go deleted file mode 100644 index ab6f1bf..0000000 --- a/webhooks_create_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WebhooksCreateResponse struct { - Webhook *Webhook `json:"webhook,omitempty"` - Ok bool `json:"ok"` -} diff --git a/webhooks_delete_request.go b/webhooks_delete_request.go deleted file mode 100644 index 3b65322..0000000 --- a/webhooks_delete_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// WebhooksDeleteRequest is an in-lined request used by the Delete endpoint. -type WebhooksDeleteRequest struct { - WebhookId string `json:"webhook_id"` -} diff --git a/webhooks_delete_response.go b/webhooks_delete_response.go deleted file mode 100644 index 4d442fe..0000000 --- a/webhooks_delete_response.go +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WebhooksDeleteResponse struct { - Ok bool `json:"ok"` -} diff --git a/webhooks_get_request.go b/webhooks_get_request.go deleted file mode 100644 index 2ddff35..0000000 --- a/webhooks_get_request.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -// WebhooksGetRequest is an in-lined request used by the Get endpoint. -type WebhooksGetRequest struct { - WebhookId string `json:"webhook_id"` -} diff --git a/webhooks_get_response.go b/webhooks_get_response.go deleted file mode 100644 index ff692c5..0000000 --- a/webhooks_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WebhooksGetResponse struct { - Webhook *Webhook `json:"webhook,omitempty"` - Ok bool `json:"ok"` -} diff --git a/webhooks_list_response.go b/webhooks_list_response.go deleted file mode 100644 index 8c53d06..0000000 --- a/webhooks_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WebhooksListResponse struct { - Webhooks []*Webhook `json:"webhooks,omitempty"` - Ok bool `json:"ok"` -} diff --git a/workspace.go b/workspace.go deleted file mode 100644 index afdb62f..0000000 --- a/workspace.go +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type Workspace struct { - WorkspaceId string `json:"workspace_id"` - Name string `json:"name"` - IsSandbox bool `json:"is_sandbox"` - ConnectPartnerName *string `json:"connect_partner_name,omitempty"` -} diff --git a/workspaces.go b/workspaces.go new file mode 100644 index 0000000..e61ae16 --- /dev/null +++ b/workspaces.go @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +type WorkspacesGetResponse struct { + Workspace *Workspace `json:"workspace,omitempty"` + Ok bool `json:"ok"` +} + +type WorkspacesListResponse struct { + Workspaces []*Workspace `json:"workspaces,omitempty"` + Ok bool `json:"ok"` +} + +type WorkspacesResetSandboxResponse struct { + Message string `json:"message"` + Ok bool `json:"ok"` +} diff --git a/workspaces_client.go b/workspaces/client.go similarity index 67% rename from workspaces_client.go rename to workspaces/client.go index 75203ea..bd9fae2 100644 --- a/workspaces_client.go +++ b/workspaces/client.go @@ -1,45 +1,40 @@ // This file was auto-generated by Fern from our API Definition. -package api +package workspaces 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 WorkspacesClient interface { - Get(ctx context.Context) (*WorkspacesGetResponse, error) - List(ctx context.Context) (*WorkspacesListResponse, error) - ResetSandbox(ctx context.Context) (*WorkspacesResetSandboxResponse, error) +type Client struct { + baseURL string + httpClient core.HTTPClient + header http.Header } -func NewWorkspacesClient(opts ...core.ClientOption) WorkspacesClient { +func NewClient(opts ...core.ClientOption) *Client { options := core.NewClientOptions() for _, opt := range opts { opt(options) } - return &workspacesClient{ + return &Client{ baseURL: options.BaseURL, httpClient: options.HTTPClient, header: options.ToHeader(), } } -type workspacesClient struct { - baseURL string - httpClient core.HTTPClient - header http.Header -} - -func (w *workspacesClient) Get(ctx context.Context) (*WorkspacesGetResponse, error) { +func (c *Client) Get(ctx context.Context) (*seamapigo.Workspace, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "workspaces/get" @@ -52,44 +47,44 @@ func (w *workspacesClient) Get(ctx context.Context) (*WorkspacesGetResponse, err decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WorkspacesGetResponse + var response *seamapigo.WorkspacesGetResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodGet, nil, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Workspace, nil } -func (w *workspacesClient) List(ctx context.Context) (*WorkspacesListResponse, error) { +func (c *Client) List(ctx context.Context) ([]*seamapigo.Workspace, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "workspaces/list" @@ -102,44 +97,44 @@ func (w *workspacesClient) List(ctx context.Context) (*WorkspacesListResponse, e decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WorkspacesListResponse + var response *seamapigo.WorkspacesListResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodGet, nil, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } - return response, nil + return response.Workspaces, nil } -func (w *workspacesClient) ResetSandbox(ctx context.Context) (*WorkspacesResetSandboxResponse, error) { +func (c *Client) ResetSandbox(ctx context.Context) (*seamapigo.WorkspacesResetSandboxResponse, error) { baseURL := "https://connect.getseam.com" - if w.baseURL != "" { - baseURL = w.baseURL + if c.baseURL != "" { + baseURL = c.baseURL } endpointURL := baseURL + "/" + "workspaces/reset_sandbox" @@ -152,36 +147,36 @@ func (w *workspacesClient) ResetSandbox(ctx context.Context) (*WorkspacesResetSa decoder := json.NewDecoder(bytes.NewReader(raw)) switch statusCode { case 400: - value := new(BadRequestError) + value := new(seamapigo.BadRequestError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value case 401: - value := new(UnauthorizedError) + value := new(seamapigo.UnauthorizedError) value.APIError = apiError if err := decoder.Decode(value); err != nil { - return err + return apiError } return value } return apiError } - var response *WorkspacesResetSandboxResponse + var response *seamapigo.WorkspacesResetSandboxResponse if err := core.DoRequest( ctx, - w.httpClient, + c.httpClient, endpointURL, http.MethodPost, nil, &response, false, - w.header, + c.header, errorDecoder, ); err != nil { - return response, err + return nil, err } return response, nil } diff --git a/workspaces_get_response.go b/workspaces_get_response.go deleted file mode 100644 index d5dfa22..0000000 --- a/workspaces_get_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WorkspacesGetResponse struct { - Workspace *Workspace `json:"workspace,omitempty"` - Ok bool `json:"ok"` -} diff --git a/workspaces_list_response.go b/workspaces_list_response.go deleted file mode 100644 index 3b633ec..0000000 --- a/workspaces_list_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WorkspacesListResponse struct { - Workspaces []*Workspace `json:"workspaces,omitempty"` - Ok bool `json:"ok"` -} diff --git a/workspaces_reset_sandbox_response.go b/workspaces_reset_sandbox_response.go deleted file mode 100644 index a2d8e96..0000000 --- a/workspaces_reset_sandbox_response.go +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -type WorkspacesResetSandboxResponse struct { - Message string `json:"message"` - Ok bool `json:"ok"` -}