seam 1.1.3 → 2.0.0a2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +4 -2
- data/Gemfile.lock +137 -0
- data/LICENSE.txt +16 -18
- data/README.md +118 -115
- data/Rakefile +23 -0
- data/lib/seam/client.rb +129 -0
- data/lib/seam/clients/access_codes.rb +95 -0
- data/lib/seam/clients/access_codes_simulate.rb +17 -0
- data/lib/seam/clients/access_codes_unmanaged.rb +57 -0
- data/lib/seam/clients/acs.rb +35 -0
- data/lib/seam/clients/acs_access_groups.rb +57 -0
- data/lib/seam/clients/acs_credential_pools.rb +17 -0
- data/lib/seam/clients/acs_credential_provisioning_automations.rb +17 -0
- data/lib/seam/clients/acs_credentials.rb +77 -0
- data/lib/seam/clients/acs_entrances.rb +47 -0
- data/lib/seam/clients/acs_systems.rb +27 -0
- data/lib/seam/clients/acs_users.rb +117 -0
- data/lib/seam/clients/action_attempts.rb +30 -0
- data/lib/seam/clients/base_client.rb +21 -0
- data/lib/seam/clients/client_sessions.rb +77 -0
- data/lib/seam/clients/connect_webviews.rb +47 -0
- data/lib/seam/clients/connected_accounts.rb +47 -0
- data/lib/seam/clients/devices.rb +65 -0
- data/lib/seam/clients/devices_simulate.rb +17 -0
- data/lib/seam/clients/devices_unmanaged.rb +37 -0
- data/lib/seam/clients/events.rb +27 -0
- data/lib/seam/clients/locks.rb +53 -0
- data/lib/seam/clients/networks.rb +27 -0
- data/lib/seam/clients/noise_sensors.rb +15 -0
- data/lib/seam/clients/noise_sensors_noise_thresholds.rb +57 -0
- data/lib/seam/clients/noise_sensors_simulate.rb +17 -0
- data/lib/seam/clients/phones.rb +31 -0
- data/lib/seam/clients/phones_simulate.rb +17 -0
- data/lib/seam/clients/thermostats.rb +106 -0
- data/lib/seam/clients/thermostats_climate_setting_schedules.rb +57 -0
- data/lib/seam/clients/user_identities.rb +131 -0
- data/lib/seam/clients/user_identities_enrollment_automations.rb +47 -0
- data/lib/seam/clients/webhooks.rb +57 -0
- data/lib/seam/clients/workspaces.rb +50 -0
- data/lib/seam/logger.rb +12 -0
- data/lib/seam/lts_version.rb +5 -0
- data/lib/seam/request.rb +73 -0
- data/lib/seam/resources/access_code.rb +12 -0
- data/lib/seam/resources/acs_access_group.rb +9 -0
- data/lib/seam/resources/acs_credential.rb +12 -0
- data/lib/seam/resources/acs_credential_pool.rb +9 -0
- data/lib/seam/resources/acs_credential_provisioning_automation.rb +9 -0
- data/lib/seam/resources/acs_entrance.rb +9 -0
- data/lib/seam/resources/acs_system.rb +9 -0
- data/lib/seam/resources/acs_user.rb +9 -0
- data/lib/seam/resources/action_attempt.rb +46 -0
- data/lib/seam/resources/base_resource.rb +58 -0
- data/lib/seam/resources/client_session.rb +9 -0
- data/lib/seam/resources/climate_setting_schedule.rb +11 -0
- data/lib/seam/resources/connect_webview.rb +9 -0
- data/lib/seam/resources/connected_account.rb +12 -0
- data/lib/seam/resources/device.rb +12 -0
- data/lib/seam/resources/device_provider.rb +7 -0
- data/lib/seam/resources/enrollment_automation.rb +9 -0
- data/lib/seam/resources/event.rb +9 -0
- data/lib/seam/resources/network.rb +9 -0
- data/lib/seam/resources/noise_threshold.rb +7 -0
- data/lib/seam/resources/phone.rb +12 -0
- data/lib/seam/resources/resource_error.rb +9 -0
- data/lib/seam/resources/resource_errors_support.rb +9 -0
- data/lib/seam/resources/resource_warning.rb +9 -0
- data/lib/seam/resources/resource_warnings_support.rb +9 -0
- data/lib/seam/resources/service_health.rb +7 -0
- data/lib/seam/resources/unmanaged_access_code.rb +12 -0
- data/lib/seam/resources/unmanaged_device.rb +12 -0
- data/lib/seam/resources/user_identity.rb +9 -0
- data/lib/seam/resources/webhook.rb +7 -0
- data/lib/seam/resources/workspace.rb +7 -0
- data/lib/seam/version.rb +3 -1
- data/lib/seam.rb +71 -13
- metadata +147 -82
- data/.gitignore +0 -18
- data/lib/seam/effort.rb +0 -86
- data/lib/seam/flow.rb +0 -53
- data/lib/seam/in_memory.rb +0 -13
- data/lib/seam/persistence.rb +0 -43
- data/lib/seam/step.rb +0 -33
- data/lib/seam/wait_worker.rb +0 -30
- data/lib/seam/worker.rb +0 -166
- data/seam.gemspec +0 -30
- data/spec/seam/effort_spec.rb +0 -43
- data/spec/seam/flow_spec.rb +0 -173
- data/spec/seam/step_spec.rb +0 -34
- data/spec/seam/wait_worker_spec.rb +0 -179
- data/spec/seam/worker_spec.rb +0 -973
- data/spec/spec_helper.rb +0 -8
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class ThermostatsClimateSettingSchedules < BaseClient
|
6
|
+
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)
|
7
|
+
request_seam_object(
|
8
|
+
:post,
|
9
|
+
"/thermostats/climate_setting_schedules/create",
|
10
|
+
Seam::ClimateSettingSchedule,
|
11
|
+
"climate_setting_schedule",
|
12
|
+
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
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(climate_setting_schedule_id:)
|
17
|
+
request_seam(
|
18
|
+
:post,
|
19
|
+
"/thermostats/climate_setting_schedules/delete",
|
20
|
+
body: {climate_setting_schedule_id: climate_setting_schedule_id}.compact
|
21
|
+
)
|
22
|
+
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(climate_setting_schedule_id: nil, device_id: nil)
|
27
|
+
request_seam_object(
|
28
|
+
:post,
|
29
|
+
"/thermostats/climate_setting_schedules/get",
|
30
|
+
Seam::ClimateSettingSchedule,
|
31
|
+
"climate_setting_schedule",
|
32
|
+
body: {climate_setting_schedule_id: climate_setting_schedule_id, device_id: device_id}.compact
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def list(device_id:, user_identifier_key: nil)
|
37
|
+
request_seam_object(
|
38
|
+
:post,
|
39
|
+
"/thermostats/climate_setting_schedules/list",
|
40
|
+
Seam::ClimateSettingSchedule,
|
41
|
+
"climate_setting_schedules",
|
42
|
+
body: {device_id: device_id, user_identifier_key: user_identifier_key}.compact
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
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)
|
47
|
+
request_seam(
|
48
|
+
:post,
|
49
|
+
"/thermostats/climate_setting_schedules/update",
|
50
|
+
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
|
51
|
+
)
|
52
|
+
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class UserIdentities < BaseClient
|
6
|
+
def enrollment_automations
|
7
|
+
@enrollment_automations ||= Seam::Clients::UserIdentitiesEnrollmentAutomations.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_acs_user(acs_user_id:, user_identity_id:)
|
11
|
+
request_seam(
|
12
|
+
:post,
|
13
|
+
"/user_identities/add_acs_user",
|
14
|
+
body: {acs_user_id: acs_user_id, user_identity_id: user_identity_id}.compact
|
15
|
+
)
|
16
|
+
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil)
|
21
|
+
request_seam_object(
|
22
|
+
:post,
|
23
|
+
"/user_identities/create",
|
24
|
+
Seam::UserIdentity,
|
25
|
+
"user_identity",
|
26
|
+
body: {email_address: email_address, full_name: full_name, phone_number: phone_number, user_identity_key: user_identity_key}.compact
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(user_identity_id:)
|
31
|
+
request_seam(
|
32
|
+
:post,
|
33
|
+
"/user_identities/delete",
|
34
|
+
body: {user_identity_id: user_identity_id}.compact
|
35
|
+
)
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def get(user_identity_id: nil, user_identity_key: nil)
|
41
|
+
request_seam_object(
|
42
|
+
:post,
|
43
|
+
"/user_identities/get",
|
44
|
+
Seam::UserIdentity,
|
45
|
+
"user_identity",
|
46
|
+
body: {user_identity_id: user_identity_id, user_identity_key: user_identity_key}.compact
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def grant_access_to_device(device_id:, user_identity_id:)
|
51
|
+
request_seam(
|
52
|
+
:post,
|
53
|
+
"/user_identities/grant_access_to_device",
|
54
|
+
body: {device_id: device_id, user_identity_id: user_identity_id}.compact
|
55
|
+
)
|
56
|
+
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def list(credential_manager_acs_system_id: nil)
|
61
|
+
request_seam_object(
|
62
|
+
:post,
|
63
|
+
"/user_identities/list",
|
64
|
+
Seam::UserIdentity,
|
65
|
+
"user_identities",
|
66
|
+
body: {credential_manager_acs_system_id: credential_manager_acs_system_id}.compact
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def list_accessible_devices(user_identity_id:)
|
71
|
+
request_seam_object(
|
72
|
+
:post,
|
73
|
+
"/user_identities/list_accessible_devices",
|
74
|
+
Seam::Device,
|
75
|
+
"devices",
|
76
|
+
body: {user_identity_id: user_identity_id}.compact
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def list_acs_systems(user_identity_id:)
|
81
|
+
request_seam_object(
|
82
|
+
:post,
|
83
|
+
"/user_identities/list_acs_systems",
|
84
|
+
Seam::AcsSystem,
|
85
|
+
"acs_systems",
|
86
|
+
body: {user_identity_id: user_identity_id}.compact
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def list_acs_users(user_identity_id:)
|
91
|
+
request_seam_object(
|
92
|
+
:post,
|
93
|
+
"/user_identities/list_acs_users",
|
94
|
+
Seam::AcsUser,
|
95
|
+
"acs_users",
|
96
|
+
body: {user_identity_id: user_identity_id}.compact
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def remove_acs_user(acs_user_id:, user_identity_id:)
|
101
|
+
request_seam(
|
102
|
+
:post,
|
103
|
+
"/user_identities/remove_acs_user",
|
104
|
+
body: {acs_user_id: acs_user_id, user_identity_id: user_identity_id}.compact
|
105
|
+
)
|
106
|
+
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
def revoke_access_to_device(device_id:, user_identity_id:)
|
111
|
+
request_seam(
|
112
|
+
:post,
|
113
|
+
"/user_identities/revoke_access_to_device",
|
114
|
+
body: {device_id: device_id, user_identity_id: user_identity_id}.compact
|
115
|
+
)
|
116
|
+
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
|
120
|
+
def update(user_identity_id:, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil)
|
121
|
+
request_seam(
|
122
|
+
:post,
|
123
|
+
"/user_identities/update",
|
124
|
+
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
|
125
|
+
)
|
126
|
+
|
127
|
+
nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class UserIdentitiesEnrollmentAutomations < BaseClient
|
6
|
+
def delete(enrollment_automation_id:)
|
7
|
+
request_seam(
|
8
|
+
:post,
|
9
|
+
"/user_identities/enrollment_automations/delete",
|
10
|
+
body: {enrollment_automation_id: enrollment_automation_id}.compact
|
11
|
+
)
|
12
|
+
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(enrollment_automation_id:)
|
17
|
+
request_seam_object(
|
18
|
+
:post,
|
19
|
+
"/user_identities/enrollment_automations/get",
|
20
|
+
Seam::EnrollmentAutomation,
|
21
|
+
"enrollment_automation",
|
22
|
+
body: {enrollment_automation_id: enrollment_automation_id}.compact
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
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)
|
27
|
+
request_seam(
|
28
|
+
:post,
|
29
|
+
"/user_identities/enrollment_automations/launch",
|
30
|
+
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
|
31
|
+
)
|
32
|
+
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def list(user_identity_id:)
|
37
|
+
request_seam_object(
|
38
|
+
:post,
|
39
|
+
"/user_identities/enrollment_automations/list",
|
40
|
+
Seam::EnrollmentAutomation,
|
41
|
+
"enrollment_automations",
|
42
|
+
body: {user_identity_id: user_identity_id}.compact
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class Webhooks < BaseClient
|
6
|
+
def create(url:, event_types: nil)
|
7
|
+
request_seam_object(
|
8
|
+
:post,
|
9
|
+
"/webhooks/create",
|
10
|
+
Seam::Webhook,
|
11
|
+
"webhook",
|
12
|
+
body: {url: url, event_types: event_types}.compact
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(webhook_id:)
|
17
|
+
request_seam(
|
18
|
+
:post,
|
19
|
+
"/webhooks/delete",
|
20
|
+
body: {webhook_id: webhook_id}.compact
|
21
|
+
)
|
22
|
+
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(webhook_id:)
|
27
|
+
request_seam_object(
|
28
|
+
:post,
|
29
|
+
"/webhooks/get",
|
30
|
+
Seam::Webhook,
|
31
|
+
"webhook",
|
32
|
+
body: {webhook_id: webhook_id}.compact
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def list
|
37
|
+
request_seam_object(
|
38
|
+
:post,
|
39
|
+
"/webhooks/list",
|
40
|
+
Seam::Webhook,
|
41
|
+
"webhooks",
|
42
|
+
body: {}.compact
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def update(event_types:, webhook_id:)
|
47
|
+
request_seam(
|
48
|
+
:post,
|
49
|
+
"/webhooks/update",
|
50
|
+
body: {event_types: event_types, webhook_id: webhook_id}.compact
|
51
|
+
)
|
52
|
+
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class Workspaces < BaseClient
|
6
|
+
def create(connect_partner_name:, name:, is_sandbox: nil, webview_logo_shape: nil, webview_primary_button_color: nil)
|
7
|
+
request_seam_object(
|
8
|
+
:post,
|
9
|
+
"/workspaces/create",
|
10
|
+
Seam::Workspace,
|
11
|
+
"workspace",
|
12
|
+
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
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get
|
17
|
+
request_seam_object(
|
18
|
+
:post,
|
19
|
+
"/workspaces/get",
|
20
|
+
Seam::Workspace,
|
21
|
+
"workspace",
|
22
|
+
body: {}.compact
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def list
|
27
|
+
request_seam_object(
|
28
|
+
:post,
|
29
|
+
"/workspaces/list",
|
30
|
+
Seam::Workspace,
|
31
|
+
"workspaces",
|
32
|
+
body: {}.compact
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def reset_sandbox(wait_for_action_attempt: nil)
|
37
|
+
action_attempt = request_seam_object(
|
38
|
+
:post,
|
39
|
+
"/workspaces/reset_sandbox",
|
40
|
+
Seam::ActionAttempt,
|
41
|
+
"action_attempt",
|
42
|
+
body: {}.compact
|
43
|
+
)
|
44
|
+
|
45
|
+
action_attempt.decide_and_wait(wait_for_action_attempt)
|
46
|
+
action_attempt
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/seam/logger.rb
ADDED
data/lib/seam/request.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "http"
|
4
|
+
|
5
|
+
module Seam
|
6
|
+
class Request
|
7
|
+
attr_reader :base_uri, :api_key, :debug
|
8
|
+
|
9
|
+
class Error < StandardError
|
10
|
+
attr_reader :status, :response
|
11
|
+
|
12
|
+
def initialize(message, status, response)
|
13
|
+
super(message)
|
14
|
+
@status = status
|
15
|
+
@response = response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(api_key:, base_uri:, debug: false)
|
20
|
+
@api_key = api_key
|
21
|
+
@base_uri = base_uri
|
22
|
+
@debug = debug
|
23
|
+
end
|
24
|
+
|
25
|
+
def perform(method, uri, config = {})
|
26
|
+
Logger.info("Request: #{method} #{uri} #{config}") if debug
|
27
|
+
|
28
|
+
config[:body] = config[:body].to_json if config[:body]
|
29
|
+
|
30
|
+
response = HTTP.request(
|
31
|
+
method,
|
32
|
+
build_url(uri),
|
33
|
+
{headers: headers}.merge(config)
|
34
|
+
)
|
35
|
+
|
36
|
+
return response.parse if response.status.success?
|
37
|
+
|
38
|
+
handle_error_response(response, method, uri)
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def handle_error_response(response, method, uri)
|
44
|
+
msg = "Api Error #{response.status.code} #{method} #{uri}"
|
45
|
+
code = response.status.code
|
46
|
+
|
47
|
+
if code >= 400 && code < 500 && (err = response.parse["error"])
|
48
|
+
msg = "Api Error #{err["type"]}\nrequest_id: #{err["request_id"]}\n#{err["message"]}"
|
49
|
+
end
|
50
|
+
|
51
|
+
raise Error.new(msg, code, response)
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_url(uri)
|
55
|
+
"#{base_uri}#{uri}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def headers
|
59
|
+
{
|
60
|
+
"User-Agent" => user_agent,
|
61
|
+
"Content-Type" => "application/json",
|
62
|
+
"Authorization" => "Bearer #{api_key}",
|
63
|
+
:"seam-sdk-name" => "seamapi/ruby",
|
64
|
+
:"seam-sdk-version" => Seam::VERSION,
|
65
|
+
:"seam-lts-version" => Seam::LTS_VERSION
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def user_agent
|
70
|
+
"seam-ruby/#{Seam::VERSION}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class AccessCode < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :created_at, :ends_at, :starts_at
|
8
|
+
|
9
|
+
include Seam::ResourceErrorsSupport
|
10
|
+
include Seam::ResourceWarningsSupport
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class AcsAccessGroup < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class AcsCredential < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
|
9
|
+
include Seam::ResourceErrorsSupport
|
10
|
+
include Seam::ResourceWarningsSupport
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class AcsCredentialProvisioningAutomation < BaseResource
|
5
|
+
attr_accessor :acs_credential_provisioning_automation_id, :credential_manager_acs_system_id, :user_identity_id, :workspace_id
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class AcsSystem < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class AcsUser < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ActionAttempt < BaseResource
|
5
|
+
attr_accessor :action_attempt_id, :action_type, :error, :result, :status
|
6
|
+
|
7
|
+
def decide_and_wait(wait_for_action_attempt)
|
8
|
+
wait_decision = wait_for_action_attempt.nil? ? @client.wait_for_action_attempt : wait_for_action_attempt
|
9
|
+
|
10
|
+
if wait_decision == true
|
11
|
+
wait_until_finished
|
12
|
+
elsif wait_decision.is_a?(Hash)
|
13
|
+
wait_until_finished(timeout: wait_decision[:timeout], polling_interval: wait_decision[:polling_interval])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def wait_until_finished(timeout: 5.0, polling_interval: 0.5)
|
18
|
+
time_waiting = 0.0
|
19
|
+
|
20
|
+
while @status == "pending"
|
21
|
+
sleep(polling_interval)
|
22
|
+
time_waiting += polling_interval
|
23
|
+
|
24
|
+
raise "Timed out waiting for action attempt to be finished" if time_waiting > timeout
|
25
|
+
|
26
|
+
update!
|
27
|
+
|
28
|
+
raise "Action Attempt failed: #{error["message"]}" if @status == "failed"
|
29
|
+
end
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def update!
|
35
|
+
response = @client.request_seam(
|
36
|
+
:post,
|
37
|
+
"/action_attempts/get",
|
38
|
+
body: {
|
39
|
+
action_attempt_id: action_attempt_id
|
40
|
+
}
|
41
|
+
)
|
42
|
+
|
43
|
+
update_from_response(response["action_attempt"])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class BaseResource
|
5
|
+
attr_accessor :data, :client
|
6
|
+
|
7
|
+
def initialize(data, client = nil)
|
8
|
+
@data = data
|
9
|
+
@client = client
|
10
|
+
|
11
|
+
@data.each do |key, value|
|
12
|
+
instance_variable_set(:"@#{key}", value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_from_response(data)
|
17
|
+
@data = data
|
18
|
+
@data.each do |key, value|
|
19
|
+
instance_variable_set(:"@#{key}", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.load_from_response(data, client = nil)
|
24
|
+
if data.is_a?(Array)
|
25
|
+
data.map { |d| new(d, client) }
|
26
|
+
else
|
27
|
+
new(data, client)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect
|
32
|
+
"<#{self.class.name}:#{"0x00%x" % (object_id << 1)}\n" + # rubocop:disable Style/StringConcatenation, Style/FormatString
|
33
|
+
instance_variables
|
34
|
+
.map { |k| k.to_s.sub("@", "") }
|
35
|
+
.filter { |k| k != "data" and k != "client" and respond_to? k }
|
36
|
+
.map { |k| " #{k}=#{send(k).inspect}" }
|
37
|
+
.join("\n") + ">"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.date_accessor(*attrs)
|
41
|
+
attrs.each do |attr|
|
42
|
+
define_method(attr) do
|
43
|
+
value = instance_variable_get(:"@#{attr}")
|
44
|
+
|
45
|
+
raise "No value for #{attr} set" if value.nil?
|
46
|
+
|
47
|
+
parse_datetime(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def parse_datetime(value)
|
55
|
+
Time.parse(value)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ClientSession < BaseResource
|
5
|
+
attr_accessor :client_session_id, :connect_webview_ids, :connected_account_ids, :device_count, :token, :user_identifier_key, :user_identity_ids, :workspace_id
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ClimateSettingSchedule < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
|
9
|
+
include Seam::ResourceErrorsSupport
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ConnectWebview < BaseResource
|
5
|
+
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
|
6
|
+
|
7
|
+
date_accessor :authorized_at, :created_at
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ConnectedAccount < BaseResource
|
5
|
+
attr_accessor :account_type, :account_type_display_name, :automatically_manage_new_devices, :connected_account_id, :custom_metadata, :user_identifier
|
6
|
+
|
7
|
+
date_accessor :created_at
|
8
|
+
|
9
|
+
include Seam::ResourceErrorsSupport
|
10
|
+
include Seam::ResourceWarningsSupport
|
11
|
+
end
|
12
|
+
end
|