From 12465c210a59cc03f773f8bb33f79bd443430ced Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <84702959+andrii-balitskyi@users.noreply.github.com> Date: Mon, 6 May 2024 15:09:05 +0200 Subject: [PATCH] Enable SDK generation (#10) * Enable and modify generate script * ci: Generate code * Add http and webmock deps * Update rspec config * Add specs * ci: Generate code --------- Co-authored-by: Seam Bot --- .rspec | 2 +- Gemfile.lock | 34 +++- Rakefile | 2 +- generate-routes.js | 33 ++-- lib/seam.rb | 70 ++++++- lib/seam/client.rb | 129 +++++++++++++ lib/seam/clients/access_codes.rb | 95 ++++++++++ lib/seam/clients/access_codes_simulate.rb | 17 ++ lib/seam/clients/access_codes_unmanaged.rb | 57 ++++++ lib/seam/clients/acs.rb | 35 ++++ lib/seam/clients/acs_access_groups.rb | 57 ++++++ lib/seam/clients/acs_credential_pools.rb | 17 ++ ...acs_credential_provisioning_automations.rb | 17 ++ lib/seam/clients/acs_credentials.rb | 77 ++++++++ lib/seam/clients/acs_entrances.rb | 47 +++++ lib/seam/clients/acs_systems.rb | 27 +++ lib/seam/clients/acs_users.rb | 117 ++++++++++++ lib/seam/clients/action_attempts.rb | 30 +++ lib/seam/clients/base_client.rb | 21 +++ lib/seam/clients/client_sessions.rb | 77 ++++++++ lib/seam/clients/connect_webviews.rb | 47 +++++ lib/seam/clients/connected_accounts.rb | 47 +++++ lib/seam/clients/devices.rb | 65 +++++++ lib/seam/clients/devices_simulate.rb | 17 ++ lib/seam/clients/devices_unmanaged.rb | 37 ++++ lib/seam/clients/events.rb | 27 +++ lib/seam/clients/locks.rb | 53 ++++++ lib/seam/clients/networks.rb | 27 +++ lib/seam/clients/noise_sensors.rb | 15 ++ .../clients/noise_sensors_noise_thresholds.rb | 57 ++++++ lib/seam/clients/noise_sensors_simulate.rb | 17 ++ lib/seam/clients/phones.rb | 31 ++++ lib/seam/clients/phones_simulate.rb | 17 ++ lib/seam/clients/thermostats.rb | 106 +++++++++++ .../thermostats_climate_setting_schedules.rb | 57 ++++++ lib/seam/clients/user_identities.rb | 131 ++++++++++++++ .../user_identities_enrollment_automations.rb | 47 +++++ lib/seam/clients/webhooks.rb | 57 ++++++ lib/seam/clients/workspaces.rb | 50 +++++ lib/seam/logger.rb | 12 ++ lib/seam/lts_version.rb | 5 + lib/seam/request.rb | 73 ++++++++ lib/seam/resources/access_code.rb | 12 ++ lib/seam/resources/acs_access_group.rb | 9 + lib/seam/resources/acs_credential.rb | 12 ++ lib/seam/resources/acs_credential_pool.rb | 9 + .../acs_credential_provisioning_automation.rb | 9 + lib/seam/resources/acs_entrance.rb | 9 + lib/seam/resources/acs_system.rb | 9 + lib/seam/resources/acs_user.rb | 9 + lib/seam/resources/action_attempt.rb | 46 +++++ lib/seam/resources/base_resource.rb | 58 ++++++ lib/seam/resources/client_session.rb | 9 + .../resources/climate_setting_schedule.rb | 11 ++ lib/seam/resources/connect_webview.rb | 9 + lib/seam/resources/connected_account.rb | 12 ++ lib/seam/resources/device.rb | 12 ++ lib/seam/resources/device_provider.rb | 7 + lib/seam/resources/enrollment_automation.rb | 9 + lib/seam/resources/event.rb | 9 + lib/seam/resources/network.rb | 9 + lib/seam/resources/noise_threshold.rb | 7 + lib/seam/resources/phone.rb | 12 ++ lib/seam/resources/resource_error.rb | 9 + lib/seam/resources/resource_errors_support.rb | 9 + lib/seam/resources/resource_warning.rb | 9 + .../resources/resource_warnings_support.rb | 9 + lib/seam/resources/service_health.rb | 7 + lib/seam/resources/unmanaged_access_code.rb | 12 ++ lib/seam/resources/unmanaged_device.rb | 12 ++ lib/seam/resources/user_identity.rb | 9 + lib/seam/resources/webhook.rb | 7 + lib/seam/resources/workspace.rb | 7 + lib/seam/todo.rb | 9 - lib/seam/todo_spec.rb | 11 -- seam.gemspec | 3 + spec/.DS_Store | Bin 0 -> 6148 bytes spec/clients/access_codes_spec.rb | 171 ++++++++++++++++++ spec/clients/action_attempts_spec.rb | 22 +++ spec/clients/connect_webviews_spec.rb | 76 ++++++++ spec/clients/connected_accounts_spec.rb | 81 +++++++++ spec/clients/devices_spec.rb | 154 ++++++++++++++++ spec/clients/events_spec.rb | 36 ++++ spec/clients/locks_spec.rb | 85 +++++++++ spec/clients/unmanaged_access_codes_spec.rb | 92 ++++++++++ spec/clients/unmanaged_devices_spec.rb | 75 ++++++++ spec/clients/workspaces_spec.rb | 56 ++++++ spec/request_spec.rb | 53 ++++++ spec/resources/action_attempt_spec.rb | 62 +++++++ spec/resources/base_resource_spec.rb | 19 ++ spec/spec_helper.rb | 5 + spec/support/helpers.rb | 11 ++ 92 files changed, 3319 insertions(+), 36 deletions(-) create mode 100644 lib/seam/client.rb create mode 100644 lib/seam/clients/access_codes.rb create mode 100644 lib/seam/clients/access_codes_simulate.rb create mode 100644 lib/seam/clients/access_codes_unmanaged.rb create mode 100644 lib/seam/clients/acs.rb create mode 100644 lib/seam/clients/acs_access_groups.rb create mode 100644 lib/seam/clients/acs_credential_pools.rb create mode 100644 lib/seam/clients/acs_credential_provisioning_automations.rb create mode 100644 lib/seam/clients/acs_credentials.rb create mode 100644 lib/seam/clients/acs_entrances.rb create mode 100644 lib/seam/clients/acs_systems.rb create mode 100644 lib/seam/clients/acs_users.rb create mode 100644 lib/seam/clients/action_attempts.rb create mode 100644 lib/seam/clients/base_client.rb create mode 100644 lib/seam/clients/client_sessions.rb create mode 100644 lib/seam/clients/connect_webviews.rb create mode 100644 lib/seam/clients/connected_accounts.rb create mode 100644 lib/seam/clients/devices.rb create mode 100644 lib/seam/clients/devices_simulate.rb create mode 100644 lib/seam/clients/devices_unmanaged.rb create mode 100644 lib/seam/clients/events.rb create mode 100644 lib/seam/clients/locks.rb create mode 100644 lib/seam/clients/networks.rb create mode 100644 lib/seam/clients/noise_sensors.rb create mode 100644 lib/seam/clients/noise_sensors_noise_thresholds.rb create mode 100644 lib/seam/clients/noise_sensors_simulate.rb create mode 100644 lib/seam/clients/phones.rb create mode 100644 lib/seam/clients/phones_simulate.rb create mode 100644 lib/seam/clients/thermostats.rb create mode 100644 lib/seam/clients/thermostats_climate_setting_schedules.rb create mode 100644 lib/seam/clients/user_identities.rb create mode 100644 lib/seam/clients/user_identities_enrollment_automations.rb create mode 100644 lib/seam/clients/webhooks.rb create mode 100644 lib/seam/clients/workspaces.rb create mode 100644 lib/seam/logger.rb create mode 100644 lib/seam/lts_version.rb create mode 100644 lib/seam/request.rb create mode 100644 lib/seam/resources/access_code.rb create mode 100644 lib/seam/resources/acs_access_group.rb create mode 100644 lib/seam/resources/acs_credential.rb create mode 100644 lib/seam/resources/acs_credential_pool.rb create mode 100644 lib/seam/resources/acs_credential_provisioning_automation.rb create mode 100644 lib/seam/resources/acs_entrance.rb create mode 100644 lib/seam/resources/acs_system.rb create mode 100644 lib/seam/resources/acs_user.rb create mode 100644 lib/seam/resources/action_attempt.rb create mode 100644 lib/seam/resources/base_resource.rb create mode 100644 lib/seam/resources/client_session.rb create mode 100644 lib/seam/resources/climate_setting_schedule.rb create mode 100644 lib/seam/resources/connect_webview.rb create mode 100644 lib/seam/resources/connected_account.rb create mode 100644 lib/seam/resources/device.rb create mode 100644 lib/seam/resources/device_provider.rb create mode 100644 lib/seam/resources/enrollment_automation.rb create mode 100644 lib/seam/resources/event.rb create mode 100644 lib/seam/resources/network.rb create mode 100644 lib/seam/resources/noise_threshold.rb create mode 100644 lib/seam/resources/phone.rb create mode 100644 lib/seam/resources/resource_error.rb create mode 100644 lib/seam/resources/resource_errors_support.rb create mode 100644 lib/seam/resources/resource_warning.rb create mode 100644 lib/seam/resources/resource_warnings_support.rb create mode 100644 lib/seam/resources/service_health.rb create mode 100644 lib/seam/resources/unmanaged_access_code.rb create mode 100644 lib/seam/resources/unmanaged_device.rb create mode 100644 lib/seam/resources/user_identity.rb create mode 100644 lib/seam/resources/webhook.rb create mode 100644 lib/seam/resources/workspace.rb delete mode 100644 lib/seam/todo.rb delete mode 100644 lib/seam/todo_spec.rb create mode 100644 spec/.DS_Store create mode 100644 spec/clients/access_codes_spec.rb create mode 100644 spec/clients/action_attempts_spec.rb create mode 100644 spec/clients/connect_webviews_spec.rb create mode 100644 spec/clients/connected_accounts_spec.rb create mode 100644 spec/clients/devices_spec.rb create mode 100644 spec/clients/events_spec.rb create mode 100644 spec/clients/locks_spec.rb create mode 100644 spec/clients/unmanaged_access_codes_spec.rb create mode 100644 spec/clients/unmanaged_devices_spec.rb create mode 100644 spec/clients/workspaces_spec.rb create mode 100644 spec/request_spec.rb create mode 100644 spec/resources/action_attempt_spec.rb create mode 100644 spec/resources/base_resource_spec.rb create mode 100644 spec/support/helpers.rb diff --git a/.rspec b/.rspec index d895d29..956a69d 100644 --- a/.rspec +++ b/.rspec @@ -1,4 +1,4 @@ --format documentation --color --require spec_helper ---pattern "{spec,lib}/**/*_spec.rb" +--pattern "spec/**/*_spec.rb" diff --git a/Gemfile.lock b/Gemfile.lock index 9ee0886..8129e56 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,18 +2,44 @@ PATH remote: . specs: seam (2.0.0a1) + http (~> 5.2) GEM remote: https://rubygems.org/ specs: + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) ansi (1.5.0) ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.7) + crack (1.0.0) + bigdecimal + rexml diff-lcs (1.5.1) docile (1.4.0) + domain_name (0.6.20240107) + ffi (1.16.3) + ffi-compiler (1.3.2) + ffi (>= 1.15.5) + rake gem-release (2.2.2) + hashdiff (1.1.0) + http (5.2.0) + addressable (~> 2.8) + base64 (~> 0.1) + http-cookie (~> 1.0) + http-form_data (~> 2.2) + llhttp-ffi (~> 0.5.0) + http-cookie (1.0.5) + domain_name (~> 0.5) + http-form_data (2.3.0) json (2.7.2) language_server-protocol (3.17.0.3) lint_roller (1.1.0) + llhttp-ffi (0.5.0) + ffi-compiler (~> 1.0) + rake (~> 13.0) multi_json (1.15.0) parallel (1.24.0) parse_gemspec (1.0.0) @@ -24,6 +50,7 @@ GEM parser (3.3.0.5) ast (~> 2.4.1) racc + public_suffix (5.0.5) racc (1.7.3) rainbow (3.1.1) rake (13.2.1) @@ -85,6 +112,10 @@ GEM unicode-display_width (>= 1.1.1, < 3) thor (1.3.1) unicode-display_width (2.5.0) + webmock (3.0.1) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff PLATFORMS ruby @@ -100,6 +131,7 @@ DEPENDENCIES simplecov (~> 0.21) simplecov-console (~> 0.9) standard (~> 1.3) + webmock (~> 3.0.0) BUNDLED WITH - 2.5.7 + 2.4.19 diff --git a/Rakefile b/Rakefile index 193f713..eb16385 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ require "rspec/core/rake_task" require "standard/rake" RSpec::Core::RakeTask.new(:spec) do |t| - t.rspec_opts = "--pattern {spec,lib}/**/*_spec.rb" + t.rspec_opts = "--pattern spec/**/*_spec.rb" end task default: %i[lint test] diff --git a/generate-routes.js b/generate-routes.js index 4fc7e67..7cd78b8 100644 --- a/generate-routes.js +++ b/generate-routes.js @@ -1,4 +1,4 @@ -import { dirname, posix, resolve } from 'node:path' +import { dirname, posix } from 'node:path' import { fileURLToPath } from 'node:url' import { @@ -8,22 +8,33 @@ import { import { openapi } from '@seamapi/types/connect' import { deleteAsync } from 'del' -const libNameParts = ['lib', 'seam'] -const libPrefix = posix.join(...libNameParts) -const libVersionPath = posix.join(libPrefix, 'version.rb') - const rootPath = dirname(fileURLToPath(import.meta.url)) +const libName = 'lib' +const libPath = posix.join(rootPath, libName) +const seamName = 'seam' +const seamPath = posix.join(libPath, seamName) +const libVersionPath = posix.join(seamPath, 'version.rb') +const libVersionRelativePath = posix.join(libName, seamName, 'version.rb') + +const pathsToDelete = [ + `${libPath}/**/*`, + `!${libPath}/seam/`, + `!${libVersionPath}`, +] -// TODO: Enable later -// await deleteAsync([`${libPrefix}/**`, `!${libVersionPath}`]) +await deleteAsync(pathsToDelete) const fileSystem = await generateSdk({ openApiSpecObject: openapi, }) const files = Object.entries(fileSystem) - .filter(([fileName]) => fileName.startsWith(`${libPrefix}/`)) - .filter(([fileName]) => !fileName.startsWith(`${libPrefix}/version.rb`)) + .filter(([fileName]) => fileName.startsWith(`${libName}/`)) + .filter(([fileName]) => !fileName.startsWith(libVersionRelativePath)) + .map(([fileName, fileContent]) => + fileName.startsWith('lib/seamapi.rb') + ? ['lib/seam.rb', fileContent] + : [fileName, fileContent], + ) -// TODO: Enable later -// writeFs(rootPath, Object.fromEntries(files)) +writeFs(rootPath, Object.fromEntries(files)) diff --git a/lib/seam.rb b/lib/seam.rb index 7cf8749..aa3af1f 100644 --- a/lib/seam.rb +++ b/lib/seam.rb @@ -1,8 +1,74 @@ # frozen_string_literal: true require_relative "seam/version" -require_relative "seam/todo" +require_relative "seam/lts_version" +require_relative "seam/request" +require_relative "seam/logger" +require_relative "seam/client" +require_relative "seam/clients/base_client" +require_relative "seam/resources/base_resource" +require_relative "seam/resources/resource_error" +require_relative "seam/resources/resource_warning" +require_relative "seam/resources/resource_errors_support" +require_relative "seam/resources/resource_warnings_support" +require_relative "seam/resources/access_code" +require_relative "seam/resources/acs_access_group" +require_relative "seam/resources/acs_credential" +require_relative "seam/resources/acs_credential_pool" +require_relative "seam/resources/acs_credential_provisioning_automation" +require_relative "seam/resources/acs_entrance" +require_relative "seam/resources/acs_system" +require_relative "seam/resources/acs_user" +require_relative "seam/resources/action_attempt" +require_relative "seam/resources/client_session" +require_relative "seam/resources/climate_setting_schedule" +require_relative "seam/resources/connect_webview" +require_relative "seam/resources/connected_account" +require_relative "seam/resources/device" +require_relative "seam/resources/device_provider" +require_relative "seam/resources/enrollment_automation" +require_relative "seam/resources/event" +require_relative "seam/resources/network" +require_relative "seam/resources/noise_threshold" +require_relative "seam/resources/phone" +require_relative "seam/resources/service_health" +require_relative "seam/resources/unmanaged_access_code" +require_relative "seam/resources/unmanaged_device" +require_relative "seam/resources/user_identity" +require_relative "seam/resources/webhook" +require_relative "seam/resources/workspace" +require_relative "seam/clients/access_codes" +require_relative "seam/clients/access_codes_simulate" +require_relative "seam/clients/access_codes_unmanaged" +require_relative "seam/clients/acs_access_groups" +require_relative "seam/clients/acs" +require_relative "seam/clients/acs_credential_pools" +require_relative "seam/clients/acs_credential_provisioning_automations" +require_relative "seam/clients/acs_credentials" +require_relative "seam/clients/acs_entrances" +require_relative "seam/clients/acs_systems" +require_relative "seam/clients/acs_users" +require_relative "seam/clients/action_attempts" +require_relative "seam/clients/client_sessions" +require_relative "seam/clients/connect_webviews" +require_relative "seam/clients/connected_accounts" +require_relative "seam/clients/devices" +require_relative "seam/clients/devices_simulate" +require_relative "seam/clients/devices_unmanaged" +require_relative "seam/clients/events" +require_relative "seam/clients/locks" +require_relative "seam/clients/networks" +require_relative "seam/clients/noise_sensors_noise_thresholds" +require_relative "seam/clients/noise_sensors" +require_relative "seam/clients/noise_sensors_simulate" +require_relative "seam/clients/phones" +require_relative "seam/clients/phones_simulate" +require_relative "seam/clients/thermostats_climate_setting_schedules" +require_relative "seam/clients/thermostats" +require_relative "seam/clients/user_identities" +require_relative "seam/clients/user_identities_enrollment_automations" +require_relative "seam/clients/webhooks" +require_relative "seam/clients/workspaces" module Seam - # TODO end diff --git a/lib/seam/client.rb b/lib/seam/client.rb new file mode 100644 index 0000000..5c37231 --- /dev/null +++ b/lib/seam/client.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true + +module Seam + class Client + attr_accessor :api_key, :base_uri, :debug, :wait_for_action_attempt + + def self.lts_version + Seam::LTS_VERSION + end + + def initialize(api_key: nil, base_uri: nil, wait_for_action_attempt: false, debug: false) + @api_key = api_key || ENV["SEAM_API_KEY"] + @base_uri = base_uri || ENV["SEAM_API_URL"] || ENV["SEAM_ENDPOINT"] || "https://connect.getseam.com" + @debug = debug + @wait_for_action_attempt = wait_for_action_attempt + + raise ArgumentError, "SEAM_API_KEY not found in environment, and api_key not provided" if @api_key.to_s.empty? + + if ENV["SEAM_API_URL"] + warn "Using the SEAM_API_URL environment variable is deprecated. " \ + "Support will be removed in a later major version. Use SEAM_ENDPOINT instead." + end + end + + def lts_version + Seam::LTS_VERSION + end + + def access_codes + @access_codes ||= Seam::Clients::AccessCodes.new(self) + end + + def acs + @acs ||= Seam::Clients::Acs.new(self) + end + + def action_attempts + @action_attempts ||= Seam::Clients::ActionAttempts.new(self) + end + + def client_sessions + @client_sessions ||= Seam::Clients::ClientSessions.new(self) + end + + def connect_webviews + @connect_webviews ||= Seam::Clients::ConnectWebviews.new(self) + end + + def connected_accounts + @connected_accounts ||= Seam::Clients::ConnectedAccounts.new(self) + end + + def devices + @devices ||= Seam::Clients::Devices.new(self) + end + + def events + @events ||= Seam::Clients::Events.new(self) + end + + def locks + @locks ||= Seam::Clients::Locks.new(self) + end + + def networks + @networks ||= Seam::Clients::Networks.new(self) + end + + def noise_sensors + @noise_sensors ||= Seam::Clients::NoiseSensors.new(self) + end + + def phones + @phones ||= Seam::Clients::Phones.new(self) + end + + def thermostats + @thermostats ||= Seam::Clients::Thermostats.new(self) + end + + def user_identities + @user_identities ||= Seam::Clients::UserIdentities.new(self) + end + + def webhooks + @webhooks ||= Seam::Clients::Webhooks.new(self) + end + + def workspaces + @workspaces ||= Seam::Clients::Workspaces.new(self) + end + + def health + request_seam(:get, "/health") + end + + # @deprecated Please use {#devices.unmanaged} instead. + def unmanaged_devices + warn "[DEPRECATION] 'unmanaged_devices' is deprecated. Please use 'devices.unmanaged' instead." + + @unmanaged_devices ||= Seam::Clients::DevicesUnmanaged.new(self) + end + + # @deprecated Please use {#access_codes.unmanaged} instead. + def unmanaged_access_codes + warn "[DEPRECATION] 'unmanaged_access_codes' is deprecated. Please use 'access_codes.unmanaged' instead." + + @unmanaged_access_codes ||= Seam::Clients::AccessCodesUnmanaged.new(self) + end + + def request_seam_object(method, path, klass, inner_object, config = {}) + response = request_seam(method, path, config) + + data = response[inner_object] + + klass.load_from_response(data, self) + end + + def request_seam(method, path, config = {}) + Seam::Request.new( + api_key: api_key, + base_uri: base_uri, + debug: debug + ).perform( + method, path, config + ) + end + end +end diff --git a/lib/seam/clients/access_codes.rb b/lib/seam/clients/access_codes.rb new file mode 100644 index 0000000..ceb50d6 --- /dev/null +++ b/lib/seam/clients/access_codes.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AccessCodes < BaseClient + def simulate + @simulate ||= Seam::Clients::AccessCodesSimulate.new(self) + end + + def unmanaged + @unmanaged ||= Seam::Clients::AccessCodesUnmanaged.new(self) + end + + def create(device_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, common_code_key: nil, ends_at: nil, is_external_modification_allowed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, starts_at: nil, sync: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) + request_seam_object( + :post, + "/access_codes/create", + Seam::AccessCode, + "access_code", + body: {device_id: device_id, allow_external_modification: allow_external_modification, attempt_for_offline_device: attempt_for_offline_device, code: code, common_code_key: common_code_key, ends_at: ends_at, is_external_modification_allowed: is_external_modification_allowed, is_offline_access_code: is_offline_access_code, is_one_time_use: is_one_time_use, max_time_rounding: max_time_rounding, name: name, prefer_native_scheduling: prefer_native_scheduling, starts_at: starts_at, sync: sync, use_backup_access_code_pool: use_backup_access_code_pool, use_offline_access_code: use_offline_access_code}.compact + ) + end + + def create_multiple(device_ids:, allow_external_modification: nil, attempt_for_offline_device: nil, behavior_when_code_cannot_be_shared: nil, code: nil, ends_at: nil, is_external_modification_allowed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) + request_seam_object( + :post, + "/access_codes/create_multiple", + Seam::AccessCode, + "access_codes", + body: {device_ids: device_ids, allow_external_modification: allow_external_modification, attempt_for_offline_device: attempt_for_offline_device, behavior_when_code_cannot_be_shared: behavior_when_code_cannot_be_shared, code: code, ends_at: ends_at, is_external_modification_allowed: is_external_modification_allowed, is_offline_access_code: is_offline_access_code, is_one_time_use: is_one_time_use, max_time_rounding: max_time_rounding, name: name, prefer_native_scheduling: prefer_native_scheduling, preferred_code_length: preferred_code_length, starts_at: starts_at, use_backup_access_code_pool: use_backup_access_code_pool, use_offline_access_code: use_offline_access_code}.compact + ) + end + + def delete(access_code_id:, device_id: nil, sync: nil) + request_seam( + :post, + "/access_codes/delete", + body: {access_code_id: access_code_id, device_id: device_id, sync: sync}.compact + ) + + nil + end + + def generate_code(device_id:) + request_seam_object( + :post, + "/access_codes/generate_code", + Seam::AccessCode, + "generated_code", + body: {device_id: device_id}.compact + ) + end + + def get(access_code_id: nil, code: nil, device_id: nil) + request_seam_object( + :post, + "/access_codes/get", + Seam::AccessCode, + "access_code", + body: {access_code_id: access_code_id, code: code, device_id: device_id}.compact + ) + end + + def list(access_code_ids: nil, device_id: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/access_codes/list", + Seam::AccessCode, + "access_codes", + body: {access_code_ids: access_code_ids, device_id: device_id, user_identifier_key: user_identifier_key}.compact + ) + end + + def pull_backup_access_code(access_code_id:) + request_seam_object( + :post, + "/access_codes/pull_backup_access_code", + Seam::AccessCode, + "backup_access_code", + body: {access_code_id: access_code_id}.compact + ) + end + + def update(access_code_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, device_id: nil, ends_at: nil, is_external_modification_allowed: nil, is_managed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, starts_at: nil, sync: nil, type: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) + request_seam( + :post, + "/access_codes/update", + body: {access_code_id: access_code_id, allow_external_modification: allow_external_modification, attempt_for_offline_device: attempt_for_offline_device, code: code, device_id: device_id, ends_at: ends_at, is_external_modification_allowed: is_external_modification_allowed, is_managed: is_managed, is_offline_access_code: is_offline_access_code, is_one_time_use: is_one_time_use, max_time_rounding: max_time_rounding, name: name, prefer_native_scheduling: prefer_native_scheduling, starts_at: starts_at, sync: sync, type: type, use_backup_access_code_pool: use_backup_access_code_pool, use_offline_access_code: use_offline_access_code}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/access_codes_simulate.rb b/lib/seam/clients/access_codes_simulate.rb new file mode 100644 index 0000000..01bae3a --- /dev/null +++ b/lib/seam/clients/access_codes_simulate.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AccessCodesSimulate < BaseClient + def create_unmanaged_access_code(code:, device_id:, name:) + request_seam_object( + :post, + "/access_codes/simulate/create_unmanaged_access_code", + Seam::UnmanagedAccessCode, + "access_code", + body: {code: code, device_id: device_id, name: name}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/access_codes_unmanaged.rb b/lib/seam/clients/access_codes_unmanaged.rb new file mode 100644 index 0000000..f0f4f54 --- /dev/null +++ b/lib/seam/clients/access_codes_unmanaged.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AccessCodesUnmanaged < BaseClient + def convert_to_managed(access_code_id:, allow_external_modification: nil, force: nil, is_external_modification_allowed: nil, sync: nil) + request_seam( + :post, + "/access_codes/unmanaged/convert_to_managed", + body: {access_code_id: access_code_id, allow_external_modification: allow_external_modification, force: force, is_external_modification_allowed: is_external_modification_allowed, sync: sync}.compact + ) + + nil + end + + def delete(access_code_id:, sync: nil) + request_seam( + :post, + "/access_codes/unmanaged/delete", + body: {access_code_id: access_code_id, sync: sync}.compact + ) + + nil + end + + def get(access_code_id: nil, code: nil, device_id: nil) + request_seam_object( + :post, + "/access_codes/unmanaged/get", + Seam::UnmanagedAccessCode, + "access_code", + body: {access_code_id: access_code_id, code: code, device_id: device_id}.compact + ) + end + + def list(device_id:, user_identifier_key: nil) + request_seam_object( + :post, + "/access_codes/unmanaged/list", + Seam::UnmanagedAccessCode, + "access_codes", + body: {device_id: device_id, user_identifier_key: user_identifier_key}.compact + ) + end + + def update(access_code_id:, is_managed:, allow_external_modification: nil, force: nil, is_external_modification_allowed: nil) + request_seam( + :post, + "/access_codes/unmanaged/update", + body: {access_code_id: access_code_id, is_managed: is_managed, allow_external_modification: allow_external_modification, force: force, is_external_modification_allowed: is_external_modification_allowed}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/acs.rb b/lib/seam/clients/acs.rb new file mode 100644 index 0000000..7190275 --- /dev/null +++ b/lib/seam/clients/acs.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Acs < BaseClient + def access_groups + @access_groups ||= Seam::Clients::AcsAccessGroups.new(self) + end + + def credential_pools + @credential_pools ||= Seam::Clients::AcsCredentialPools.new(self) + end + + def credential_provisioning_automations + @credential_provisioning_automations ||= Seam::Clients::AcsCredentialProvisioningAutomations.new(self) + end + + def credentials + @credentials ||= Seam::Clients::AcsCredentials.new(self) + end + + def entrances + @entrances ||= Seam::Clients::AcsEntrances.new(self) + end + + def systems + @systems ||= Seam::Clients::AcsSystems.new(self) + end + + def users + @users ||= Seam::Clients::AcsUsers.new(self) + end + end + end +end diff --git a/lib/seam/clients/acs_access_groups.rb b/lib/seam/clients/acs_access_groups.rb new file mode 100644 index 0000000..e5792b7 --- /dev/null +++ b/lib/seam/clients/acs_access_groups.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsAccessGroups < BaseClient + def add_user(acs_access_group_id:, acs_user_id:) + request_seam( + :post, + "/acs/access_groups/add_user", + body: {acs_access_group_id: acs_access_group_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + + def get(acs_access_group_id:) + request_seam_object( + :post, + "/acs/access_groups/get", + Seam::AcsAccessGroup, + "acs_access_group", + body: {acs_access_group_id: acs_access_group_id}.compact + ) + end + + def list(acs_system_id: nil, acs_user_id: nil) + request_seam_object( + :post, + "/acs/access_groups/list", + Seam::AcsAccessGroup, + "acs_access_groups", + body: {acs_system_id: acs_system_id, acs_user_id: acs_user_id}.compact + ) + end + + def list_users(acs_access_group_id:) + request_seam_object( + :post, + "/acs/access_groups/list_users", + Seam::AcsUser, + "acs_users", + body: {acs_access_group_id: acs_access_group_id}.compact + ) + end + + def remove_user(acs_access_group_id:, acs_user_id:) + request_seam( + :post, + "/acs/access_groups/remove_user", + body: {acs_access_group_id: acs_access_group_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/acs_credential_pools.rb b/lib/seam/clients/acs_credential_pools.rb new file mode 100644 index 0000000..dbede9e --- /dev/null +++ b/lib/seam/clients/acs_credential_pools.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsCredentialPools < BaseClient + def list(acs_system_id:) + request_seam_object( + :post, + "/acs/credential_pools/list", + Seam::AcsCredentialPool, + "acs_credential_pools", + body: {acs_system_id: acs_system_id}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/acs_credential_provisioning_automations.rb b/lib/seam/clients/acs_credential_provisioning_automations.rb new file mode 100644 index 0000000..c77f4f3 --- /dev/null +++ b/lib/seam/clients/acs_credential_provisioning_automations.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsCredentialProvisioningAutomations < BaseClient + def launch(credential_manager_acs_system_id:, user_identity_id:, acs_credential_pool_id: nil, create_credential_manager_user: nil, credential_manager_acs_user_id: nil) + request_seam_object( + :post, + "/acs/credential_provisioning_automations/launch", + Seam::AcsCredentialProvisioningAutomation, + "acs_credential_provisioning_automation", + body: {credential_manager_acs_system_id: credential_manager_acs_system_id, user_identity_id: user_identity_id, acs_credential_pool_id: acs_credential_pool_id, create_credential_manager_user: create_credential_manager_user, credential_manager_acs_user_id: credential_manager_acs_user_id}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/acs_credentials.rb b/lib/seam/clients/acs_credentials.rb new file mode 100644 index 0000000..0e9e174 --- /dev/null +++ b/lib/seam/clients/acs_credentials.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsCredentials < BaseClient + def assign(acs_credential_id:, acs_user_id:) + request_seam( + :post, + "/acs/credentials/assign", + body: {acs_credential_id: acs_credential_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + + def create(access_method:, acs_user_id:, allowed_acs_entrance_ids: nil, code: nil, credential_manager_acs_system_id: nil, ends_at: nil, is_multi_phone_sync_credential: nil, starts_at: nil, visionline_metadata: nil) + request_seam_object( + :post, + "/acs/credentials/create", + Seam::AcsCredential, + "acs_credential", + body: {access_method: access_method, acs_user_id: acs_user_id, allowed_acs_entrance_ids: allowed_acs_entrance_ids, code: code, credential_manager_acs_system_id: credential_manager_acs_system_id, ends_at: ends_at, is_multi_phone_sync_credential: is_multi_phone_sync_credential, starts_at: starts_at, visionline_metadata: visionline_metadata}.compact + ) + end + + def delete(acs_credential_id:) + request_seam( + :post, + "/acs/credentials/delete", + body: {acs_credential_id: acs_credential_id}.compact + ) + + nil + end + + def get(acs_credential_id:) + request_seam_object( + :post, + "/acs/credentials/get", + Seam::AcsCredential, + "acs_credential", + body: {acs_credential_id: acs_credential_id}.compact + ) + end + + def list(acs_user_id: nil, acs_system_id: nil, user_identity_id: nil, is_multi_phone_sync_credential: nil) + request_seam_object( + :post, + "/acs/credentials/list", + Seam::AcsCredential, + "acs_credentials", + body: {acs_user_id: acs_user_id, acs_system_id: acs_system_id, user_identity_id: user_identity_id, is_multi_phone_sync_credential: is_multi_phone_sync_credential}.compact + ) + end + + def unassign(acs_credential_id:, acs_user_id:) + request_seam( + :post, + "/acs/credentials/unassign", + body: {acs_credential_id: acs_credential_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + + def update(acs_credential_id:, code:) + request_seam( + :post, + "/acs/credentials/update", + body: {acs_credential_id: acs_credential_id, code: code}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/acs_entrances.rb b/lib/seam/clients/acs_entrances.rb new file mode 100644 index 0000000..c32b7e9 --- /dev/null +++ b/lib/seam/clients/acs_entrances.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsEntrances < BaseClient + def get(acs_entrance_id:) + request_seam_object( + :post, + "/acs/entrances/get", + Seam::AcsEntrance, + "acs_entrance", + body: {acs_entrance_id: acs_entrance_id}.compact + ) + end + + def grant_access(acs_entrance_id:, acs_user_id:) + request_seam( + :post, + "/acs/entrances/grant_access", + body: {acs_entrance_id: acs_entrance_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + + def list(acs_credential_id: nil, acs_system_id: nil) + request_seam_object( + :post, + "/acs/entrances/list", + Seam::AcsEntrance, + "acs_entrances", + body: {acs_credential_id: acs_credential_id, acs_system_id: acs_system_id}.compact + ) + end + + def list_credentials_with_access(acs_entrance_id:, include_if: nil) + request_seam_object( + :post, + "/acs/entrances/list_credentials_with_access", + Seam::AcsCredential, + "acs_credentials", + body: {acs_entrance_id: acs_entrance_id, include_if: include_if}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/acs_systems.rb b/lib/seam/clients/acs_systems.rb new file mode 100644 index 0000000..8f199d1 --- /dev/null +++ b/lib/seam/clients/acs_systems.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsSystems < BaseClient + def get(acs_system_id:) + request_seam_object( + :post, + "/acs/systems/get", + Seam::AcsSystem, + "acs_system", + body: {acs_system_id: acs_system_id}.compact + ) + end + + def list(connected_account_id: nil) + request_seam_object( + :post, + "/acs/systems/list", + Seam::AcsSystem, + "acs_systems", + body: {connected_account_id: connected_account_id}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/acs_users.rb b/lib/seam/clients/acs_users.rb new file mode 100644 index 0000000..8dce675 --- /dev/null +++ b/lib/seam/clients/acs_users.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true + +module Seam + module Clients + class AcsUsers < BaseClient + def add_to_access_group(acs_access_group_id:, acs_user_id:) + request_seam( + :post, + "/acs/users/add_to_access_group", + body: {acs_access_group_id: acs_access_group_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + + def create(acs_system_id:, access_schedule: nil, acs_access_group_ids: nil, email: nil, email_address: nil, full_name: nil, phone_number: nil, user_identity_id: nil) + request_seam_object( + :post, + "/acs/users/create", + Seam::AcsUser, + "acs_user", + body: {acs_system_id: acs_system_id, access_schedule: access_schedule, acs_access_group_ids: acs_access_group_ids, email: email, email_address: email_address, full_name: full_name, phone_number: phone_number, user_identity_id: user_identity_id}.compact + ) + end + + def delete(acs_user_id:) + request_seam( + :post, + "/acs/users/delete", + body: {acs_user_id: acs_user_id}.compact + ) + + nil + end + + def get(acs_user_id:) + request_seam_object( + :post, + "/acs/users/get", + Seam::AcsUser, + "acs_user", + body: {acs_user_id: acs_user_id}.compact + ) + end + + def list(acs_system_id: nil, user_identity_email_address: nil, user_identity_id: nil, user_identity_phone_number: nil) + request_seam_object( + :post, + "/acs/users/list", + Seam::AcsUser, + "acs_users", + body: {acs_system_id: acs_system_id, user_identity_email_address: user_identity_email_address, user_identity_id: user_identity_id, user_identity_phone_number: user_identity_phone_number}.compact + ) + end + + def list_accessible_entrances(acs_user_id:) + request_seam_object( + :post, + "/acs/users/list_accessible_entrances", + Seam::AcsEntrance, + "acs_entrances", + body: {acs_user_id: acs_user_id}.compact + ) + end + + def remove_from_access_group(acs_access_group_id:, acs_user_id:) + request_seam( + :post, + "/acs/users/remove_from_access_group", + body: {acs_access_group_id: acs_access_group_id, acs_user_id: acs_user_id}.compact + ) + + nil + end + + def revoke_access_to_all_entrances(acs_user_id:) + request_seam( + :post, + "/acs/users/revoke_access_to_all_entrances", + body: {acs_user_id: acs_user_id}.compact + ) + + nil + end + + def suspend(acs_user_id:) + request_seam( + :post, + "/acs/users/suspend", + body: {acs_user_id: acs_user_id}.compact + ) + + nil + end + + def unsuspend(acs_user_id:) + request_seam( + :post, + "/acs/users/unsuspend", + body: {acs_user_id: acs_user_id}.compact + ) + + nil + end + + def update(acs_user_id:, access_schedule: nil, email: nil, email_address: nil, full_name: nil, hid_acs_system_id: nil, phone_number: nil) + request_seam( + :post, + "/acs/users/update", + body: {acs_user_id: acs_user_id, access_schedule: access_schedule, email: email, email_address: email_address, full_name: full_name, hid_acs_system_id: hid_acs_system_id, phone_number: phone_number}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/action_attempts.rb b/lib/seam/clients/action_attempts.rb new file mode 100644 index 0000000..099cff7 --- /dev/null +++ b/lib/seam/clients/action_attempts.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Seam + module Clients + class ActionAttempts < BaseClient + def get(action_attempt_id:, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/action_attempts/get", + Seam::ActionAttempt, + "action_attempt", + body: {action_attempt_id: action_attempt_id}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def list(action_attempt_ids:) + request_seam_object( + :post, + "/action_attempts/list", + Seam::ActionAttempt, + "action_attempts", + body: {action_attempt_ids: action_attempt_ids}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/base_client.rb b/lib/seam/clients/base_client.rb new file mode 100644 index 0000000..f51733c --- /dev/null +++ b/lib/seam/clients/base_client.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Seam + module Clients + class BaseClient + attr_accessor :client + + def initialize(client) + @client = client + end + + def request_seam_object(*attrs) + client.request_seam_object(*attrs) + end + + def request_seam(*attrs) + client.request_seam(*attrs) + end + end + end +end diff --git a/lib/seam/clients/client_sessions.rb b/lib/seam/clients/client_sessions.rb new file mode 100644 index 0000000..10a0fb6 --- /dev/null +++ b/lib/seam/clients/client_sessions.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Seam + module Clients + class ClientSessions < BaseClient + def create(connect_webview_ids: nil, connected_account_ids: nil, expires_at: nil, user_identifier_key: nil, user_identity_ids: nil) + request_seam_object( + :post, + "/client_sessions/create", + Seam::ClientSession, + "client_session", + body: {connect_webview_ids: connect_webview_ids, connected_account_ids: connected_account_ids, expires_at: expires_at, user_identifier_key: user_identifier_key, user_identity_ids: user_identity_ids}.compact + ) + end + + def delete(client_session_id:) + request_seam( + :post, + "/client_sessions/delete", + body: {client_session_id: client_session_id}.compact + ) + + nil + end + + def get(client_session_id: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/client_sessions/get", + Seam::ClientSession, + "client_session", + body: {client_session_id: client_session_id, user_identifier_key: user_identifier_key}.compact + ) + end + + def get_or_create(connect_webview_ids: nil, connected_account_ids: nil, expires_at: nil, user_identifier_key: nil, user_identity_ids: nil) + request_seam_object( + :post, + "/client_sessions/get_or_create", + Seam::ClientSession, + "client_session", + body: {connect_webview_ids: connect_webview_ids, connected_account_ids: connected_account_ids, expires_at: expires_at, user_identifier_key: user_identifier_key, user_identity_ids: user_identity_ids}.compact + ) + end + + def grant_access(client_session_id: nil, connect_webview_ids: nil, connected_account_ids: nil, user_identifier_key: nil, user_identity_ids: nil) + request_seam( + :post, + "/client_sessions/grant_access", + body: {client_session_id: client_session_id, connect_webview_ids: connect_webview_ids, connected_account_ids: connected_account_ids, user_identifier_key: user_identifier_key, user_identity_ids: user_identity_ids}.compact + ) + + nil + end + + def list(client_session_id: nil, connect_webview_id: nil, user_identifier_key: nil, user_identity_id: nil, without_user_identifier_key: nil) + request_seam_object( + :post, + "/client_sessions/list", + Seam::ClientSession, + "client_sessions", + body: {client_session_id: client_session_id, connect_webview_id: connect_webview_id, user_identifier_key: user_identifier_key, user_identity_id: user_identity_id, without_user_identifier_key: without_user_identifier_key}.compact + ) + end + + def revoke(client_session_id:) + request_seam( + :post, + "/client_sessions/revoke", + body: {client_session_id: client_session_id}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/connect_webviews.rb b/lib/seam/clients/connect_webviews.rb new file mode 100644 index 0000000..f7d28cb --- /dev/null +++ b/lib/seam/clients/connect_webviews.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Seam + module Clients + class ConnectWebviews < BaseClient + def create(accepted_providers: nil, automatically_manage_new_devices: nil, custom_metadata: nil, custom_redirect_failure_url: nil, custom_redirect_url: nil, device_selection_mode: nil, provider_category: nil, wait_for_device_creation: nil) + request_seam_object( + :post, + "/connect_webviews/create", + Seam::ConnectWebview, + "connect_webview", + body: {accepted_providers: accepted_providers, automatically_manage_new_devices: automatically_manage_new_devices, custom_metadata: custom_metadata, custom_redirect_failure_url: custom_redirect_failure_url, custom_redirect_url: custom_redirect_url, device_selection_mode: device_selection_mode, provider_category: provider_category, wait_for_device_creation: wait_for_device_creation}.compact + ) + end + + def delete(connect_webview_id:) + request_seam( + :post, + "/connect_webviews/delete", + body: {connect_webview_id: connect_webview_id}.compact + ) + + nil + end + + def get(connect_webview_id:) + request_seam_object( + :post, + "/connect_webviews/get", + Seam::ConnectWebview, + "connect_webview", + body: {connect_webview_id: connect_webview_id}.compact + ) + end + + def list(custom_metadata_has: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/connect_webviews/list", + Seam::ConnectWebview, + "connect_webviews", + body: {custom_metadata_has: custom_metadata_has, user_identifier_key: user_identifier_key}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/connected_accounts.rb b/lib/seam/clients/connected_accounts.rb new file mode 100644 index 0000000..2967496 --- /dev/null +++ b/lib/seam/clients/connected_accounts.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Seam + module Clients + class ConnectedAccounts < BaseClient + def delete(connected_account_id:, sync: nil) + request_seam( + :post, + "/connected_accounts/delete", + body: {connected_account_id: connected_account_id, sync: sync}.compact + ) + + nil + end + + def get(connected_account_id: nil, email: nil) + request_seam_object( + :post, + "/connected_accounts/get", + Seam::ConnectedAccount, + "connected_account", + body: {connected_account_id: connected_account_id, email: email}.compact + ) + end + + def list(custom_metadata_has: nil) + request_seam_object( + :post, + "/connected_accounts/list", + Seam::ConnectedAccount, + "connected_accounts", + body: {custom_metadata_has: custom_metadata_has}.compact + ) + end + + def update(connected_account_id:, automatically_manage_new_devices: nil, custom_metadata: nil) + request_seam_object( + :post, + "/connected_accounts/update", + Seam::ConnectedAccount, + "connected_account", + body: {connected_account_id: connected_account_id, automatically_manage_new_devices: automatically_manage_new_devices, custom_metadata: custom_metadata}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/devices.rb b/lib/seam/clients/devices.rb new file mode 100644 index 0000000..f505d68 --- /dev/null +++ b/lib/seam/clients/devices.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Devices < BaseClient + def simulate + @simulate ||= Seam::Clients::DevicesSimulate.new(self) + end + + def unmanaged + @unmanaged ||= Seam::Clients::DevicesUnmanaged.new(self) + end + + def delete(device_id:) + request_seam( + :post, + "/devices/delete", + body: {device_id: device_id}.compact + ) + + nil + end + + def get(device_id: nil, name: nil) + request_seam_object( + :post, + "/devices/get", + Seam::Device, + "device", + body: {device_id: device_id, name: name}.compact + ) + end + + def list(connect_webview_id: nil, connected_account_id: nil, connected_account_ids: nil, created_before: nil, custom_metadata_has: nil, device_ids: nil, device_types: nil, exclude_if: nil, include_if: nil, limit: nil, manufacturer: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/devices/list", + Seam::Device, + "devices", + body: {connect_webview_id: connect_webview_id, connected_account_id: connected_account_id, connected_account_ids: connected_account_ids, created_before: created_before, custom_metadata_has: custom_metadata_has, device_ids: device_ids, device_types: device_types, exclude_if: exclude_if, include_if: include_if, limit: limit, manufacturer: manufacturer, user_identifier_key: user_identifier_key}.compact + ) + end + + def list_device_providers(provider_category: nil) + request_seam_object( + :post, + "/devices/list_device_providers", + Seam::DeviceProvider, + "device_providers", + body: {provider_category: provider_category}.compact + ) + end + + def update(device_id:, custom_metadata: nil, is_managed: nil, name: nil, properties: nil) + request_seam( + :post, + "/devices/update", + body: {device_id: device_id, custom_metadata: custom_metadata, is_managed: is_managed, name: name, properties: properties}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/devices_simulate.rb b/lib/seam/clients/devices_simulate.rb new file mode 100644 index 0000000..71884b7 --- /dev/null +++ b/lib/seam/clients/devices_simulate.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seam + module Clients + class DevicesSimulate < BaseClient + def remove(device_id:) + request_seam( + :post, + "/devices/simulate/remove", + body: {device_id: device_id}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/devices_unmanaged.rb b/lib/seam/clients/devices_unmanaged.rb new file mode 100644 index 0000000..ffb8d51 --- /dev/null +++ b/lib/seam/clients/devices_unmanaged.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Seam + module Clients + class DevicesUnmanaged < BaseClient + def get(device_id: nil, name: nil) + request_seam_object( + :post, + "/devices/unmanaged/get", + Seam::UnmanagedDevice, + "device", + body: {device_id: device_id, name: name}.compact + ) + end + + def list(connect_webview_id: nil, connected_account_id: nil, connected_account_ids: nil, created_before: nil, custom_metadata_has: nil, device_ids: nil, device_types: nil, exclude_if: nil, include_if: nil, limit: nil, manufacturer: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/devices/unmanaged/list", + Seam::UnmanagedDevice, + "devices", + body: {connect_webview_id: connect_webview_id, connected_account_id: connected_account_id, connected_account_ids: connected_account_ids, created_before: created_before, custom_metadata_has: custom_metadata_has, device_ids: device_ids, device_types: device_types, exclude_if: exclude_if, include_if: include_if, limit: limit, manufacturer: manufacturer, user_identifier_key: user_identifier_key}.compact + ) + end + + def update(device_id:, is_managed:) + request_seam( + :post, + "/devices/unmanaged/update", + body: {device_id: device_id, is_managed: is_managed}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/events.rb b/lib/seam/clients/events.rb new file mode 100644 index 0000000..93fd773 --- /dev/null +++ b/lib/seam/clients/events.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Events < BaseClient + def get(device_id: nil, event_id: nil, event_type: nil) + request_seam_object( + :post, + "/events/get", + Seam::Event, + "event", + body: {device_id: device_id, event_id: event_id, event_type: event_type}.compact + ) + end + + def list(access_code_id: nil, access_code_ids: nil, between: nil, connected_account_id: nil, device_id: nil, device_ids: nil, event_type: nil, event_types: nil, limit: nil, since: nil) + request_seam_object( + :post, + "/events/list", + Seam::Event, + "events", + body: {access_code_id: access_code_id, access_code_ids: access_code_ids, between: between, connected_account_id: connected_account_id, device_id: device_id, device_ids: device_ids, event_type: event_type, event_types: event_types, limit: limit, since: since}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/locks.rb b/lib/seam/clients/locks.rb new file mode 100644 index 0000000..52c2817 --- /dev/null +++ b/lib/seam/clients/locks.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Locks < BaseClient + def get(device_id: nil, name: nil) + request_seam_object( + :post, + "/locks/get", + Seam::Device, + "device", + body: {device_id: device_id, name: name}.compact + ) + end + + def list(connect_webview_id: nil, connected_account_id: nil, connected_account_ids: nil, created_before: nil, custom_metadata_has: nil, device_ids: nil, device_types: nil, exclude_if: nil, include_if: nil, limit: nil, manufacturer: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/locks/list", + Seam::Device, + "devices", + body: {connect_webview_id: connect_webview_id, connected_account_id: connected_account_id, connected_account_ids: connected_account_ids, created_before: created_before, custom_metadata_has: custom_metadata_has, device_ids: device_ids, device_types: device_types, exclude_if: exclude_if, include_if: include_if, limit: limit, manufacturer: manufacturer, user_identifier_key: user_identifier_key}.compact + ) + end + + def lock_door(device_id:, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/locks/lock_door", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def unlock_door(device_id:, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/locks/unlock_door", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + end + end +end diff --git a/lib/seam/clients/networks.rb b/lib/seam/clients/networks.rb new file mode 100644 index 0000000..df41258 --- /dev/null +++ b/lib/seam/clients/networks.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Networks < BaseClient + def get(network_id:) + request_seam_object( + :post, + "/networks/get", + Seam::Network, + "network", + body: {network_id: network_id}.compact + ) + end + + def list + request_seam_object( + :post, + "/networks/list", + Seam::Network, + "networks", + body: {}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/noise_sensors.rb b/lib/seam/clients/noise_sensors.rb new file mode 100644 index 0000000..ed2ea3d --- /dev/null +++ b/lib/seam/clients/noise_sensors.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Seam + module Clients + class NoiseSensors < BaseClient + def noise_thresholds + @noise_thresholds ||= Seam::Clients::NoiseSensorsNoiseThresholds.new(self) + end + + def simulate + @simulate ||= Seam::Clients::NoiseSensorsSimulate.new(self) + end + end + end +end diff --git a/lib/seam/clients/noise_sensors_noise_thresholds.rb b/lib/seam/clients/noise_sensors_noise_thresholds.rb new file mode 100644 index 0000000..3ef7b8a --- /dev/null +++ b/lib/seam/clients/noise_sensors_noise_thresholds.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Seam + module Clients + class NoiseSensorsNoiseThresholds < BaseClient + def create(device_id:, ends_daily_at:, starts_daily_at:, name: nil, noise_threshold_decibels: nil, noise_threshold_nrs: nil, sync: nil) + request_seam_object( + :post, + "/noise_sensors/noise_thresholds/create", + Seam::NoiseThreshold, + "noise_threshold", + body: {device_id: device_id, ends_daily_at: ends_daily_at, starts_daily_at: starts_daily_at, name: name, noise_threshold_decibels: noise_threshold_decibels, noise_threshold_nrs: noise_threshold_nrs, sync: sync}.compact + ) + end + + def delete(device_id:, noise_threshold_id:, sync: nil) + request_seam( + :post, + "/noise_sensors/noise_thresholds/delete", + body: {device_id: device_id, noise_threshold_id: noise_threshold_id, sync: sync}.compact + ) + + nil + end + + def get(noise_threshold_id:) + request_seam_object( + :post, + "/noise_sensors/noise_thresholds/get", + Seam::NoiseThreshold, + "noise_threshold", + body: {noise_threshold_id: noise_threshold_id}.compact + ) + end + + def list(device_id:, is_programmed: nil) + request_seam_object( + :post, + "/noise_sensors/noise_thresholds/list", + Seam::NoiseThreshold, + "noise_thresholds", + body: {device_id: device_id, is_programmed: is_programmed}.compact + ) + end + + def update(device_id:, noise_threshold_id:, ends_daily_at: nil, name: nil, noise_threshold_decibels: nil, noise_threshold_nrs: nil, starts_daily_at: nil, sync: nil) + request_seam( + :post, + "/noise_sensors/noise_thresholds/update", + body: {device_id: device_id, noise_threshold_id: noise_threshold_id, ends_daily_at: ends_daily_at, name: name, noise_threshold_decibels: noise_threshold_decibels, noise_threshold_nrs: noise_threshold_nrs, starts_daily_at: starts_daily_at, sync: sync}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/noise_sensors_simulate.rb b/lib/seam/clients/noise_sensors_simulate.rb new file mode 100644 index 0000000..a992a73 --- /dev/null +++ b/lib/seam/clients/noise_sensors_simulate.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seam + module Clients + class NoiseSensorsSimulate < BaseClient + def trigger_noise_threshold(device_id:) + request_seam( + :post, + "/noise_sensors/simulate/trigger_noise_threshold", + body: {device_id: device_id}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/phones.rb b/lib/seam/clients/phones.rb new file mode 100644 index 0000000..d95e717 --- /dev/null +++ b/lib/seam/clients/phones.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Phones < BaseClient + def simulate + @simulate ||= Seam::Clients::PhonesSimulate.new(self) + end + + def deactivate(device_id:) + request_seam( + :post, + "/phones/deactivate", + body: {device_id: device_id}.compact + ) + + nil + end + + def list(owner_user_identity_id: nil) + request_seam_object( + :post, + "/phones/list", + Seam::Phone, + "phones", + body: {owner_user_identity_id: owner_user_identity_id}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/phones_simulate.rb b/lib/seam/clients/phones_simulate.rb new file mode 100644 index 0000000..91696b7 --- /dev/null +++ b/lib/seam/clients/phones_simulate.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seam + module Clients + class PhonesSimulate < BaseClient + def create_sandbox_phone(user_identity_id:, assa_abloy_metadata: nil, custom_sdk_installation_id: nil, phone_metadata: nil) + request_seam_object( + :post, + "/phones/simulate/create_sandbox_phone", + Seam::Phone, + "phone", + body: {user_identity_id: user_identity_id, assa_abloy_metadata: assa_abloy_metadata, custom_sdk_installation_id: custom_sdk_installation_id, phone_metadata: phone_metadata}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/thermostats.rb b/lib/seam/clients/thermostats.rb new file mode 100644 index 0000000..99ffd73 --- /dev/null +++ b/lib/seam/clients/thermostats.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Thermostats < BaseClient + def climate_setting_schedules + @climate_setting_schedules ||= Seam::Clients::ThermostatsClimateSettingSchedules.new(self) + end + + def cool(device_id:, cooling_set_point_celsius: nil, cooling_set_point_fahrenheit: nil, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/thermostats/cool", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, cooling_set_point_celsius: cooling_set_point_celsius, cooling_set_point_fahrenheit: cooling_set_point_fahrenheit, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def get(device_id: nil, name: nil) + request_seam_object( + :post, + "/thermostats/get", + Seam::Device, + "thermostat", + body: {device_id: device_id, name: name}.compact + ) + end + + def heat(device_id:, heating_set_point_celsius: nil, heating_set_point_fahrenheit: nil, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/thermostats/heat", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, heating_set_point_celsius: heating_set_point_celsius, heating_set_point_fahrenheit: heating_set_point_fahrenheit, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def heat_cool(device_id:, cooling_set_point_celsius: nil, cooling_set_point_fahrenheit: nil, heating_set_point_celsius: nil, heating_set_point_fahrenheit: nil, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/thermostats/heat_cool", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, cooling_set_point_celsius: cooling_set_point_celsius, cooling_set_point_fahrenheit: cooling_set_point_fahrenheit, heating_set_point_celsius: heating_set_point_celsius, heating_set_point_fahrenheit: heating_set_point_fahrenheit, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def list(connect_webview_id: nil, connected_account_id: nil, connected_account_ids: nil, created_before: nil, custom_metadata_has: nil, device_ids: nil, device_types: nil, exclude_if: nil, include_if: nil, limit: nil, manufacturer: nil, user_identifier_key: nil) + request_seam_object( + :post, + "/thermostats/list", + Seam::Device, + "thermostats", + body: {connect_webview_id: connect_webview_id, connected_account_id: connected_account_id, connected_account_ids: connected_account_ids, created_before: created_before, custom_metadata_has: custom_metadata_has, device_ids: device_ids, device_types: device_types, exclude_if: exclude_if, include_if: include_if, limit: limit, manufacturer: manufacturer, user_identifier_key: user_identifier_key}.compact + ) + end + + def off(device_id:, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/thermostats/off", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def set_fan_mode(device_id:, fan_mode: nil, fan_mode_setting: nil, sync: nil, wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/thermostats/set_fan_mode", + Seam::ActionAttempt, + "action_attempt", + body: {device_id: device_id, fan_mode: fan_mode, fan_mode_setting: fan_mode_setting, sync: sync}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + + def update(default_climate_setting:, device_id:) + request_seam( + :post, + "/thermostats/update", + body: {default_climate_setting: default_climate_setting, device_id: device_id}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/thermostats_climate_setting_schedules.rb b/lib/seam/clients/thermostats_climate_setting_schedules.rb new file mode 100644 index 0000000..1fd1ee5 --- /dev/null +++ b/lib/seam/clients/thermostats_climate_setting_schedules.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Seam + module Clients + class ThermostatsClimateSettingSchedules < BaseClient + def create(device_id:, schedule_ends_at:, schedule_starts_at:, automatic_cooling_enabled: nil, automatic_heating_enabled: nil, cooling_set_point_celsius: nil, cooling_set_point_fahrenheit: nil, heating_set_point_celsius: nil, heating_set_point_fahrenheit: nil, hvac_mode_setting: nil, manual_override_allowed: nil, name: nil, schedule_type: nil) + request_seam_object( + :post, + "/thermostats/climate_setting_schedules/create", + Seam::ClimateSettingSchedule, + "climate_setting_schedule", + body: {device_id: device_id, schedule_ends_at: schedule_ends_at, schedule_starts_at: schedule_starts_at, automatic_cooling_enabled: automatic_cooling_enabled, automatic_heating_enabled: automatic_heating_enabled, cooling_set_point_celsius: cooling_set_point_celsius, cooling_set_point_fahrenheit: cooling_set_point_fahrenheit, heating_set_point_celsius: heating_set_point_celsius, heating_set_point_fahrenheit: heating_set_point_fahrenheit, hvac_mode_setting: hvac_mode_setting, manual_override_allowed: manual_override_allowed, name: name, schedule_type: schedule_type}.compact + ) + end + + def delete(climate_setting_schedule_id:) + request_seam( + :post, + "/thermostats/climate_setting_schedules/delete", + body: {climate_setting_schedule_id: climate_setting_schedule_id}.compact + ) + + nil + end + + def get(climate_setting_schedule_id: nil, device_id: nil) + request_seam_object( + :post, + "/thermostats/climate_setting_schedules/get", + Seam::ClimateSettingSchedule, + "climate_setting_schedule", + body: {climate_setting_schedule_id: climate_setting_schedule_id, device_id: device_id}.compact + ) + end + + def list(device_id:, user_identifier_key: nil) + request_seam_object( + :post, + "/thermostats/climate_setting_schedules/list", + Seam::ClimateSettingSchedule, + "climate_setting_schedules", + body: {device_id: device_id, user_identifier_key: user_identifier_key}.compact + ) + end + + def update(climate_setting_schedule_id:, automatic_cooling_enabled: nil, automatic_heating_enabled: nil, cooling_set_point_celsius: nil, cooling_set_point_fahrenheit: nil, heating_set_point_celsius: nil, heating_set_point_fahrenheit: nil, hvac_mode_setting: nil, manual_override_allowed: nil, name: nil, schedule_ends_at: nil, schedule_starts_at: nil, schedule_type: nil) + request_seam( + :post, + "/thermostats/climate_setting_schedules/update", + body: {climate_setting_schedule_id: climate_setting_schedule_id, automatic_cooling_enabled: automatic_cooling_enabled, automatic_heating_enabled: automatic_heating_enabled, cooling_set_point_celsius: cooling_set_point_celsius, cooling_set_point_fahrenheit: cooling_set_point_fahrenheit, heating_set_point_celsius: heating_set_point_celsius, heating_set_point_fahrenheit: heating_set_point_fahrenheit, hvac_mode_setting: hvac_mode_setting, manual_override_allowed: manual_override_allowed, name: name, schedule_ends_at: schedule_ends_at, schedule_starts_at: schedule_starts_at, schedule_type: schedule_type}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/user_identities.rb b/lib/seam/clients/user_identities.rb new file mode 100644 index 0000000..0194e6f --- /dev/null +++ b/lib/seam/clients/user_identities.rb @@ -0,0 +1,131 @@ +# frozen_string_literal: true + +module Seam + module Clients + class UserIdentities < BaseClient + def enrollment_automations + @enrollment_automations ||= Seam::Clients::UserIdentitiesEnrollmentAutomations.new(self) + end + + def add_acs_user(acs_user_id:, user_identity_id:) + request_seam( + :post, + "/user_identities/add_acs_user", + body: {acs_user_id: acs_user_id, user_identity_id: user_identity_id}.compact + ) + + nil + end + + def create(email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) + request_seam_object( + :post, + "/user_identities/create", + Seam::UserIdentity, + "user_identity", + body: {email_address: email_address, full_name: full_name, phone_number: phone_number, user_identity_key: user_identity_key}.compact + ) + end + + def delete(user_identity_id:) + request_seam( + :post, + "/user_identities/delete", + body: {user_identity_id: user_identity_id}.compact + ) + + nil + end + + def get(user_identity_id: nil, user_identity_key: nil) + request_seam_object( + :post, + "/user_identities/get", + Seam::UserIdentity, + "user_identity", + body: {user_identity_id: user_identity_id, user_identity_key: user_identity_key}.compact + ) + end + + def grant_access_to_device(device_id:, user_identity_id:) + request_seam( + :post, + "/user_identities/grant_access_to_device", + body: {device_id: device_id, user_identity_id: user_identity_id}.compact + ) + + nil + end + + def list(credential_manager_acs_system_id: nil) + request_seam_object( + :post, + "/user_identities/list", + Seam::UserIdentity, + "user_identities", + body: {credential_manager_acs_system_id: credential_manager_acs_system_id}.compact + ) + end + + def list_accessible_devices(user_identity_id:) + request_seam_object( + :post, + "/user_identities/list_accessible_devices", + Seam::Device, + "devices", + body: {user_identity_id: user_identity_id}.compact + ) + end + + def list_acs_systems(user_identity_id:) + request_seam_object( + :post, + "/user_identities/list_acs_systems", + Seam::AcsSystem, + "acs_systems", + body: {user_identity_id: user_identity_id}.compact + ) + end + + def list_acs_users(user_identity_id:) + request_seam_object( + :post, + "/user_identities/list_acs_users", + Seam::AcsUser, + "acs_users", + body: {user_identity_id: user_identity_id}.compact + ) + end + + def remove_acs_user(acs_user_id:, user_identity_id:) + request_seam( + :post, + "/user_identities/remove_acs_user", + body: {acs_user_id: acs_user_id, user_identity_id: user_identity_id}.compact + ) + + nil + end + + def revoke_access_to_device(device_id:, user_identity_id:) + request_seam( + :post, + "/user_identities/revoke_access_to_device", + body: {device_id: device_id, user_identity_id: user_identity_id}.compact + ) + + nil + end + + def update(user_identity_id:, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) + request_seam( + :post, + "/user_identities/update", + body: {user_identity_id: user_identity_id, email_address: email_address, full_name: full_name, phone_number: phone_number, user_identity_key: user_identity_key}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/user_identities_enrollment_automations.rb b/lib/seam/clients/user_identities_enrollment_automations.rb new file mode 100644 index 0000000..038422c --- /dev/null +++ b/lib/seam/clients/user_identities_enrollment_automations.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Seam + module Clients + class UserIdentitiesEnrollmentAutomations < BaseClient + def delete(enrollment_automation_id:) + request_seam( + :post, + "/user_identities/enrollment_automations/delete", + body: {enrollment_automation_id: enrollment_automation_id}.compact + ) + + nil + end + + def get(enrollment_automation_id:) + request_seam_object( + :post, + "/user_identities/enrollment_automations/get", + Seam::EnrollmentAutomation, + "enrollment_automation", + body: {enrollment_automation_id: enrollment_automation_id}.compact + ) + end + + def launch(credential_manager_acs_system_id:, user_identity_id:, acs_credential_pool_id: nil, create_credential_manager_user: nil, credential_manager_acs_user_id: nil) + request_seam( + :post, + "/user_identities/enrollment_automations/launch", + body: {credential_manager_acs_system_id: credential_manager_acs_system_id, user_identity_id: user_identity_id, acs_credential_pool_id: acs_credential_pool_id, create_credential_manager_user: create_credential_manager_user, credential_manager_acs_user_id: credential_manager_acs_user_id}.compact + ) + + nil + end + + def list(user_identity_id:) + request_seam_object( + :post, + "/user_identities/enrollment_automations/list", + Seam::EnrollmentAutomation, + "enrollment_automations", + body: {user_identity_id: user_identity_id}.compact + ) + end + end + end +end diff --git a/lib/seam/clients/webhooks.rb b/lib/seam/clients/webhooks.rb new file mode 100644 index 0000000..4bb585e --- /dev/null +++ b/lib/seam/clients/webhooks.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Webhooks < BaseClient + def create(url:, event_types: nil) + request_seam_object( + :post, + "/webhooks/create", + Seam::Webhook, + "webhook", + body: {url: url, event_types: event_types}.compact + ) + end + + def delete(webhook_id:) + request_seam( + :post, + "/webhooks/delete", + body: {webhook_id: webhook_id}.compact + ) + + nil + end + + def get(webhook_id:) + request_seam_object( + :post, + "/webhooks/get", + Seam::Webhook, + "webhook", + body: {webhook_id: webhook_id}.compact + ) + end + + def list + request_seam_object( + :post, + "/webhooks/list", + Seam::Webhook, + "webhooks", + body: {}.compact + ) + end + + def update(event_types:, webhook_id:) + request_seam( + :post, + "/webhooks/update", + body: {event_types: event_types, webhook_id: webhook_id}.compact + ) + + nil + end + end + end +end diff --git a/lib/seam/clients/workspaces.rb b/lib/seam/clients/workspaces.rb new file mode 100644 index 0000000..c5028d0 --- /dev/null +++ b/lib/seam/clients/workspaces.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Seam + module Clients + class Workspaces < BaseClient + def create(connect_partner_name:, name:, is_sandbox: nil, webview_logo_shape: nil, webview_primary_button_color: nil) + request_seam_object( + :post, + "/workspaces/create", + Seam::Workspace, + "workspace", + body: {connect_partner_name: connect_partner_name, name: name, is_sandbox: is_sandbox, webview_logo_shape: webview_logo_shape, webview_primary_button_color: webview_primary_button_color}.compact + ) + end + + def get + request_seam_object( + :post, + "/workspaces/get", + Seam::Workspace, + "workspace", + body: {}.compact + ) + end + + def list + request_seam_object( + :post, + "/workspaces/list", + Seam::Workspace, + "workspaces", + body: {}.compact + ) + end + + def reset_sandbox(wait_for_action_attempt: nil) + action_attempt = request_seam_object( + :post, + "/workspaces/reset_sandbox", + Seam::ActionAttempt, + "action_attempt", + body: {}.compact + ) + + action_attempt.decide_and_wait(wait_for_action_attempt) + action_attempt + end + end + end +end diff --git a/lib/seam/logger.rb b/lib/seam/logger.rb new file mode 100644 index 0000000..3c585c7 --- /dev/null +++ b/lib/seam/logger.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require "logger" + +module Seam + class Logger + def self.info(message) + logger = ::Logger.new($stdout) + logger.info(message) + end + end +end diff --git a/lib/seam/lts_version.rb b/lib/seam/lts_version.rb new file mode 100644 index 0000000..65daf42 --- /dev/null +++ b/lib/seam/lts_version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Seam + LTS_VERSION = "1.0.0" +end diff --git a/lib/seam/request.rb b/lib/seam/request.rb new file mode 100644 index 0000000..46d9d62 --- /dev/null +++ b/lib/seam/request.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require "http" + +module Seam + class Request + attr_reader :base_uri, :api_key, :debug + + class Error < StandardError + attr_reader :status, :response + + def initialize(message, status, response) + super(message) + @status = status + @response = response + end + end + + def initialize(api_key:, base_uri:, debug: false) + @api_key = api_key + @base_uri = base_uri + @debug = debug + end + + def perform(method, uri, config = {}) + Logger.info("Request: #{method} #{uri} #{config}") if debug + + config[:body] = config[:body].to_json if config[:body] + + response = HTTP.request( + method, + build_url(uri), + {headers: headers}.merge(config) + ) + + return response.parse if response.status.success? + + handle_error_response(response, method, uri) + end + + protected + + def handle_error_response(response, method, uri) + msg = "Api Error #{response.status.code} #{method} #{uri}" + code = response.status.code + + if code >= 400 && code < 500 && (err = response.parse["error"]) + msg = "Api Error #{err["type"]}\nrequest_id: #{err["request_id"]}\n#{err["message"]}" + end + + raise Error.new(msg, code, response) + end + + def build_url(uri) + "#{base_uri}#{uri}" + end + + def headers + { + "User-Agent" => user_agent, + "Content-Type" => "application/json", + "Authorization" => "Bearer #{api_key}", + :"seam-sdk-name" => "seamapi/ruby", + :"seam-sdk-version" => Seam::VERSION, + :"seam-lts-version" => Seam::LTS_VERSION + } + end + + def user_agent + "seam-ruby/#{Seam::VERSION}" + end + end +end diff --git a/lib/seam/resources/access_code.rb b/lib/seam/resources/access_code.rb new file mode 100644 index 0000000..1f5ef01 --- /dev/null +++ b/lib/seam/resources/access_code.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class AccessCode < BaseResource + attr_accessor :access_code_id, :code, :common_code_key, :device_id, :is_backup, :is_backup_access_code_available, :is_external_modification_allowed, :is_managed, :is_offline_access_code, :is_one_time_use, :is_scheduled_on_device, :is_waiting_for_code_assignment, :name, :pulled_backup_access_code_id, :status, :type + + date_accessor :created_at, :ends_at, :starts_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/acs_access_group.rb b/lib/seam/resources/acs_access_group.rb new file mode 100644 index 0000000..1d7a63a --- /dev/null +++ b/lib/seam/resources/acs_access_group.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class AcsAccessGroup < BaseResource + attr_accessor :access_group_type, :access_group_type_display_name, :acs_access_group_id, :acs_system_id, :external_type, :external_type_display_name, :name, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/acs_credential.rb b/lib/seam/resources/acs_credential.rb new file mode 100644 index 0000000..a119f70 --- /dev/null +++ b/lib/seam/resources/acs_credential.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class AcsCredential < BaseResource + attr_accessor :access_method, :acs_credential_id, :acs_credential_pool_id, :acs_system_id, :acs_user_id, :code, :display_name, :ends_at, :external_type, :external_type_display_name, :is_multi_phone_sync_credential, :parent_acs_credential_id, :starts_at, :visionline_metadata, :workspace_id + + date_accessor :created_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/acs_credential_pool.rb b/lib/seam/resources/acs_credential_pool.rb new file mode 100644 index 0000000..b7e6816 --- /dev/null +++ b/lib/seam/resources/acs_credential_pool.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class AcsCredentialPool < BaseResource + attr_accessor :acs_credential_pool_id, :acs_system_id, :display_name, :external_type, :external_type_display_name, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/acs_credential_provisioning_automation.rb b/lib/seam/resources/acs_credential_provisioning_automation.rb new file mode 100644 index 0000000..43e0d5b --- /dev/null +++ b/lib/seam/resources/acs_credential_provisioning_automation.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class AcsCredentialProvisioningAutomation < BaseResource + attr_accessor :acs_credential_provisioning_automation_id, :credential_manager_acs_system_id, :user_identity_id, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/acs_entrance.rb b/lib/seam/resources/acs_entrance.rb new file mode 100644 index 0000000..2ca01c9 --- /dev/null +++ b/lib/seam/resources/acs_entrance.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class AcsEntrance < BaseResource + attr_accessor :acs_entrance_id, :acs_system_id, :display_name, :latch_metadata, :visionline_metadata + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/acs_system.rb b/lib/seam/resources/acs_system.rb new file mode 100644 index 0000000..35b5251 --- /dev/null +++ b/lib/seam/resources/acs_system.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class AcsSystem < BaseResource + attr_accessor :acs_system_id, :can_add_acs_users_to_acs_access_groups, :can_automate_enrollment, :can_create_acs_access_groups, :can_remove_acs_users_from_acs_access_groups, :connected_account_ids, :external_type, :external_type_display_name, :image_alt_text, :image_url, :name, :system_type, :system_type_display_name, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/acs_user.rb b/lib/seam/resources/acs_user.rb new file mode 100644 index 0000000..8b7c40d --- /dev/null +++ b/lib/seam/resources/acs_user.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class AcsUser < BaseResource + attr_accessor :access_schedule, :acs_system_id, :acs_user_id, :display_name, :email, :email_address, :external_type, :external_type_display_name, :full_name, :hid_acs_system_id, :is_suspended, :phone_number, :user_identity_email_address, :user_identity_full_name, :user_identity_id, :user_identity_phone_number, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/action_attempt.rb b/lib/seam/resources/action_attempt.rb new file mode 100644 index 0000000..d20c56e --- /dev/null +++ b/lib/seam/resources/action_attempt.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Seam + class ActionAttempt < BaseResource + attr_accessor :action_attempt_id, :action_type, :error, :result, :status + + def decide_and_wait(wait_for_action_attempt) + wait_decision = wait_for_action_attempt.nil? ? @client.wait_for_action_attempt : wait_for_action_attempt + + if wait_decision == true + wait_until_finished + elsif wait_decision.is_a?(Hash) + wait_until_finished(timeout: wait_decision[:timeout], polling_interval: wait_decision[:polling_interval]) + end + end + + def wait_until_finished(timeout: 5.0, polling_interval: 0.5) + time_waiting = 0.0 + + while @status == "pending" + sleep(polling_interval) + time_waiting += polling_interval + + raise "Timed out waiting for action attempt to be finished" if time_waiting > timeout + + update! + + raise "Action Attempt failed: #{error["message"]}" if @status == "failed" + end + + self + end + + def update! + response = @client.request_seam( + :post, + "/action_attempts/get", + body: { + action_attempt_id: action_attempt_id + } + ) + + update_from_response(response["action_attempt"]) + end + end +end diff --git a/lib/seam/resources/base_resource.rb b/lib/seam/resources/base_resource.rb new file mode 100644 index 0000000..2a6fcad --- /dev/null +++ b/lib/seam/resources/base_resource.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +module Seam + class BaseResource + attr_accessor :data, :client + + def initialize(data, client = nil) + @data = data + @client = client + + @data.each do |key, value| + instance_variable_set(:"@#{key}", value) + end + end + + def update_from_response(data) + @data = data + @data.each do |key, value| + instance_variable_set(:"@#{key}", value) + end + end + + def self.load_from_response(data, client = nil) + if data.is_a?(Array) + data.map { |d| new(d, client) } + else + new(data, client) + end + end + + def inspect + "<#{self.class.name}:#{"0x00%x" % (object_id << 1)}\n" + # rubocop:disable Style/StringConcatenation, Style/FormatString + instance_variables + .map { |k| k.to_s.sub("@", "") } + .filter { |k| k != "data" and k != "client" and respond_to? k } + .map { |k| " #{k}=#{send(k).inspect}" } + .join("\n") + ">" + end + + def self.date_accessor(*attrs) + attrs.each do |attr| + define_method(attr) do + value = instance_variable_get(:"@#{attr}") + + raise "No value for #{attr} set" if value.nil? + + parse_datetime(value) + end + end + end + + protected + + def parse_datetime(value) + Time.parse(value) + end + end +end diff --git a/lib/seam/resources/client_session.rb b/lib/seam/resources/client_session.rb new file mode 100644 index 0000000..a4b09b3 --- /dev/null +++ b/lib/seam/resources/client_session.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class ClientSession < BaseResource + attr_accessor :client_session_id, :connect_webview_ids, :connected_account_ids, :device_count, :token, :user_identifier_key, :user_identity_ids, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/climate_setting_schedule.rb b/lib/seam/resources/climate_setting_schedule.rb new file mode 100644 index 0000000..7f1530b --- /dev/null +++ b/lib/seam/resources/climate_setting_schedule.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Seam + class ClimateSettingSchedule < BaseResource + attr_accessor :automatic_cooling_enabled, :automatic_heating_enabled, :climate_setting_schedule_id, :cooling_set_point_celsius, :cooling_set_point_fahrenheit, :device_id, :heating_set_point_celsius, :heating_set_point_fahrenheit, :hvac_mode_setting, :manual_override_allowed, :name, :schedule_ends_at, :schedule_starts_at, :schedule_type + + date_accessor :created_at + + include Seam::ResourceErrorsSupport + end +end diff --git a/lib/seam/resources/connect_webview.rb b/lib/seam/resources/connect_webview.rb new file mode 100644 index 0000000..b9e06d3 --- /dev/null +++ b/lib/seam/resources/connect_webview.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class ConnectWebview < BaseResource + attr_accessor :accepted_devices, :accepted_providers, :any_device_allowed, :any_provider_allowed, :automatically_manage_new_devices, :connect_webview_id, :connected_account_id, :custom_metadata, :custom_redirect_failure_url, :custom_redirect_url, :device_selection_mode, :login_successful, :selected_provider, :status, :url, :wait_for_device_creation, :workspace_id + + date_accessor :authorized_at, :created_at + end +end diff --git a/lib/seam/resources/connected_account.rb b/lib/seam/resources/connected_account.rb new file mode 100644 index 0000000..e4d1f86 --- /dev/null +++ b/lib/seam/resources/connected_account.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class ConnectedAccount < BaseResource + attr_accessor :account_type, :account_type_display_name, :automatically_manage_new_devices, :connected_account_id, :custom_metadata, :user_identifier + + date_accessor :created_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/device.rb b/lib/seam/resources/device.rb new file mode 100644 index 0000000..4a09ab4 --- /dev/null +++ b/lib/seam/resources/device.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class Device < BaseResource + attr_accessor :can_program_offline_access_codes, :can_program_online_access_codes, :can_remotely_lock, :can_remotely_unlock, :can_simulate_removal, :capabilities_supported, :connected_account_id, :custom_metadata, :device_id, :device_type, :display_name, :is_managed, :location, :nickname, :properties, :workspace_id + + date_accessor :created_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/device_provider.rb b/lib/seam/resources/device_provider.rb new file mode 100644 index 0000000..18832d8 --- /dev/null +++ b/lib/seam/resources/device_provider.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Seam + class DeviceProvider < BaseResource + attr_accessor :device_provider_name, :display_name, :image_url, :provider_categories + end +end diff --git a/lib/seam/resources/enrollment_automation.rb b/lib/seam/resources/enrollment_automation.rb new file mode 100644 index 0000000..3fba969 --- /dev/null +++ b/lib/seam/resources/enrollment_automation.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class EnrollmentAutomation < BaseResource + attr_accessor :credential_manager_acs_system_id, :enrollment_automation_id, :user_identity_id, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/event.rb b/lib/seam/resources/event.rb new file mode 100644 index 0000000..02dbc99 --- /dev/null +++ b/lib/seam/resources/event.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class Event < BaseResource + attr_accessor :action_attempt_id, :device_id, :event_id, :event_type, :workspace_id + + date_accessor :created_at, :occurred_at + end +end diff --git a/lib/seam/resources/network.rb b/lib/seam/resources/network.rb new file mode 100644 index 0000000..343a602 --- /dev/null +++ b/lib/seam/resources/network.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class Network < BaseResource + attr_accessor :display_name, :network_id, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/noise_threshold.rb b/lib/seam/resources/noise_threshold.rb new file mode 100644 index 0000000..8a8ad13 --- /dev/null +++ b/lib/seam/resources/noise_threshold.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Seam + class NoiseThreshold < BaseResource + attr_accessor :device_id, :ends_daily_at, :name, :noise_threshold_decibels, :noise_threshold_id, :noise_threshold_nrs, :starts_daily_at + end +end diff --git a/lib/seam/resources/phone.rb b/lib/seam/resources/phone.rb new file mode 100644 index 0000000..4d447bc --- /dev/null +++ b/lib/seam/resources/phone.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class Phone < BaseResource + attr_accessor :can_program_offline_access_codes, :can_program_online_access_codes, :can_remotely_lock, :can_remotely_unlock, :can_simulate_removal, :capabilities_supported, :custom_metadata, :device_id, :device_type, :display_name, :is_managed, :location, :nickname, :properties, :workspace_id + + date_accessor :created_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/resource_error.rb b/lib/seam/resources/resource_error.rb new file mode 100644 index 0000000..412927b --- /dev/null +++ b/lib/seam/resources/resource_error.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class ResourceError < BaseResource + attr_accessor :error_code, :message + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/resource_errors_support.rb b/lib/seam/resources/resource_errors_support.rb new file mode 100644 index 0000000..cfd89cb --- /dev/null +++ b/lib/seam/resources/resource_errors_support.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + module ResourceErrorsSupport + def errors + @errors_converted ||= @errors.is_a?(Array) ? Seam::ResourceError.load_from_response(@errors) : [] + end + end +end diff --git a/lib/seam/resources/resource_warning.rb b/lib/seam/resources/resource_warning.rb new file mode 100644 index 0000000..e822cab --- /dev/null +++ b/lib/seam/resources/resource_warning.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class ResourceWarning < BaseResource + attr_accessor :warning_code, :message + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/resource_warnings_support.rb b/lib/seam/resources/resource_warnings_support.rb new file mode 100644 index 0000000..765eb78 --- /dev/null +++ b/lib/seam/resources/resource_warnings_support.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + module ResourceWarningsSupport + def warnings + @warnings_converted ||= @warnings.is_a?(Array) ? Seam::ResourceWarning.load_from_response(@warnings) : [] + end + end +end diff --git a/lib/seam/resources/service_health.rb b/lib/seam/resources/service_health.rb new file mode 100644 index 0000000..b0480e9 --- /dev/null +++ b/lib/seam/resources/service_health.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Seam + class ServiceHealth < BaseResource + attr_accessor :description, :service, :status + end +end diff --git a/lib/seam/resources/unmanaged_access_code.rb b/lib/seam/resources/unmanaged_access_code.rb new file mode 100644 index 0000000..be46405 --- /dev/null +++ b/lib/seam/resources/unmanaged_access_code.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class UnmanagedAccessCode < BaseResource + attr_accessor :access_code_id, :code, :device_id, :is_managed, :name, :status, :type + + date_accessor :created_at, :ends_at, :starts_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/unmanaged_device.rb b/lib/seam/resources/unmanaged_device.rb new file mode 100644 index 0000000..becd041 --- /dev/null +++ b/lib/seam/resources/unmanaged_device.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Seam + class UnmanagedDevice < BaseResource + attr_accessor :can_program_offline_access_codes, :can_program_online_access_codes, :can_remotely_lock, :can_remotely_unlock, :can_simulate_removal, :capabilities_supported, :connected_account_id, :device_id, :device_type, :is_managed, :properties, :workspace_id + + date_accessor :created_at + + include Seam::ResourceErrorsSupport + include Seam::ResourceWarningsSupport + end +end diff --git a/lib/seam/resources/user_identity.rb b/lib/seam/resources/user_identity.rb new file mode 100644 index 0000000..0424719 --- /dev/null +++ b/lib/seam/resources/user_identity.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seam + class UserIdentity < BaseResource + attr_accessor :display_name, :email_address, :full_name, :phone_number, :user_identity_id, :user_identity_key, :workspace_id + + date_accessor :created_at + end +end diff --git a/lib/seam/resources/webhook.rb b/lib/seam/resources/webhook.rb new file mode 100644 index 0000000..86fc582 --- /dev/null +++ b/lib/seam/resources/webhook.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Seam + class Webhook < BaseResource + attr_accessor :event_types, :secret, :url, :webhook_id + end +end diff --git a/lib/seam/resources/workspace.rb b/lib/seam/resources/workspace.rb new file mode 100644 index 0000000..324d9ad --- /dev/null +++ b/lib/seam/resources/workspace.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Seam + class Workspace < BaseResource + attr_accessor :connect_partner_name, :is_sandbox, :name, :workspace_id + end +end diff --git a/lib/seam/todo.rb b/lib/seam/todo.rb deleted file mode 100644 index 570801b..0000000 --- a/lib/seam/todo.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module Seam - class Todo - def todo - "TODO" - end - end -end diff --git a/lib/seam/todo_spec.rb b/lib/seam/todo_spec.rb deleted file mode 100644 index bd7553c..0000000 --- a/lib/seam/todo_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Seam::Todo do - subject(:todo) { Seam::Todo.new } - - describe ".todo" do - it "returns todo" do - expect(todo.todo).to be "TODO" - end - end -end diff --git a/seam.gemspec b/seam.gemspec index 983751c..72c28bc 100644 --- a/seam.gemspec +++ b/seam.gemspec @@ -26,6 +26,8 @@ Gem::Specification.new do |spec| spec.files = Dir["lib/**/*.rb"].reject { |f| f.end_with?("_spec.rb") } spec.files += Dir["[A-Z]*"] + spec.add_dependency "http", "~> 5.2" + spec.add_development_dependency "bundler", "~> 2.0" spec.add_development_dependency "gem-release", "~> 2.2" spec.add_development_dependency "parse_gemspec-cli", "~> 1.0" @@ -34,4 +36,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "simplecov", "~> 0.21" spec.add_development_dependency "simplecov-console", "~> 0.9" spec.add_development_dependency "standard", "~> 1.3" + spec.add_development_dependency "webmock", "~> 3.0.0" end diff --git a/spec/.DS_Store b/spec/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6738c08cf64661dc02288d6882944c4b2ef6630f GIT binary patch literal 6148 zcmeHK%Sr=55UkdKfn0L*IKSW@3?Y6&ejs2(gs_6I^Pc>!d|Ij>1jELQ;6CCsP>xE-t(qT1xSUuTlLa}%{?{85K>xqg|Knk2I zaGl$w_y2qP5A**yNjoVZ1^$%+Hd}AjE51_o*2&9xuWj@#-D?hXH?D)i5bc;4?U);H e$G1_Gb "application/json"}.merge(headers)) + end +end