seam 2.0.0b5 → 2.0.0.prerelease.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +53 -49
  3. data/README.md +3 -323
  4. data/Rakefile +1 -4
  5. data/lib/seam/client.rb +129 -0
  6. data/lib/seam/clients/access_codes.rb +95 -0
  7. data/lib/seam/clients/access_codes_simulate.rb +17 -0
  8. data/lib/seam/clients/access_codes_unmanaged.rb +57 -0
  9. data/lib/seam/clients/acs.rb +35 -0
  10. data/lib/seam/clients/acs_access_groups.rb +57 -0
  11. data/lib/seam/clients/acs_credential_pools.rb +17 -0
  12. data/lib/seam/clients/acs_credential_provisioning_automations.rb +17 -0
  13. data/lib/seam/clients/acs_credentials.rb +77 -0
  14. data/lib/seam/clients/acs_entrances.rb +47 -0
  15. data/lib/seam/clients/acs_systems.rb +27 -0
  16. data/lib/seam/clients/acs_users.rb +117 -0
  17. data/lib/seam/clients/action_attempts.rb +30 -0
  18. data/lib/seam/clients/base_client.rb +21 -0
  19. data/lib/seam/clients/client_sessions.rb +77 -0
  20. data/lib/seam/clients/connect_webviews.rb +47 -0
  21. data/lib/seam/clients/connected_accounts.rb +47 -0
  22. data/lib/seam/clients/devices.rb +65 -0
  23. data/lib/seam/clients/devices_simulate.rb +17 -0
  24. data/lib/seam/clients/devices_unmanaged.rb +37 -0
  25. data/lib/seam/clients/events.rb +27 -0
  26. data/lib/seam/clients/locks.rb +53 -0
  27. data/lib/seam/clients/networks.rb +27 -0
  28. data/lib/seam/clients/noise_sensors.rb +15 -0
  29. data/lib/seam/clients/noise_sensors_noise_thresholds.rb +57 -0
  30. data/lib/seam/clients/noise_sensors_simulate.rb +17 -0
  31. data/lib/seam/clients/phones.rb +31 -0
  32. data/lib/seam/clients/phones_simulate.rb +17 -0
  33. data/lib/seam/clients/thermostats.rb +106 -0
  34. data/lib/seam/clients/thermostats_climate_setting_schedules.rb +57 -0
  35. data/lib/seam/clients/user_identities.rb +131 -0
  36. data/lib/seam/clients/user_identities_enrollment_automations.rb +47 -0
  37. data/lib/seam/clients/webhooks.rb +57 -0
  38. data/lib/seam/clients/workspaces.rb +50 -0
  39. data/lib/seam/logger.rb +12 -0
  40. data/lib/seam/request.rb +51 -84
  41. data/lib/seam/resources/access_code.rb +12 -0
  42. data/lib/seam/resources/acs_access_group.rb +9 -0
  43. data/lib/seam/resources/acs_credential.rb +12 -0
  44. data/lib/seam/resources/acs_credential_pool.rb +9 -0
  45. data/lib/seam/resources/acs_credential_provisioning_automation.rb +9 -0
  46. data/lib/seam/resources/acs_entrance.rb +9 -0
  47. data/lib/seam/resources/acs_system.rb +9 -0
  48. data/lib/seam/resources/acs_user.rb +9 -0
  49. data/lib/seam/resources/action_attempt.rb +46 -0
  50. data/lib/seam/resources/base_resource.rb +58 -0
  51. data/lib/seam/resources/client_session.rb +9 -0
  52. data/lib/seam/resources/climate_setting_schedule.rb +11 -0
  53. data/lib/seam/resources/connect_webview.rb +9 -0
  54. data/lib/seam/resources/connected_account.rb +12 -0
  55. data/lib/seam/resources/device.rb +12 -0
  56. data/lib/seam/resources/device_provider.rb +7 -0
  57. data/lib/seam/resources/enrollment_automation.rb +9 -0
  58. data/lib/seam/resources/event.rb +9 -0
  59. data/lib/seam/resources/network.rb +9 -0
  60. data/lib/seam/resources/noise_threshold.rb +7 -0
  61. data/lib/seam/resources/phone.rb +12 -0
  62. data/lib/seam/resources/resource_error.rb +9 -0
  63. data/lib/seam/resources/resource_errors_support.rb +9 -0
  64. data/lib/seam/resources/resource_warning.rb +9 -0
  65. data/lib/seam/resources/resource_warnings_support.rb +9 -0
  66. data/lib/seam/resources/service_health.rb +7 -0
  67. data/lib/seam/resources/unmanaged_access_code.rb +12 -0
  68. data/lib/seam/resources/unmanaged_device.rb +12 -0
  69. data/lib/seam/resources/user_identity.rb +9 -0
  70. data/lib/seam/resources/webhook.rb +7 -0
  71. data/lib/seam/resources/workspace.rb +7 -0
  72. data/lib/seam/version.rb +1 -1
  73. data/lib/seam.rb +68 -19
  74. metadata +71 -115
  75. data/lib/seam/auth.rb +0 -118
  76. data/lib/seam/base_resource.rb +0 -65
  77. data/lib/seam/deep_hash_accessor.rb +0 -37
  78. data/lib/seam/default_endpoint.rb +0 -5
  79. data/lib/seam/helpers/action_attempt.rb +0 -47
  80. data/lib/seam/http.rb +0 -52
  81. data/lib/seam/http_multi_workspace.rb +0 -66
  82. data/lib/seam/http_single_workspace.rb +0 -46
  83. data/lib/seam/options.rb +0 -64
  84. data/lib/seam/parse_options.rb +0 -23
  85. data/lib/seam/routes/clients/access_codes.rb +0 -74
  86. data/lib/seam/routes/clients/access_codes_simulate.rb +0 -18
  87. data/lib/seam/routes/clients/access_codes_unmanaged.rb +0 -42
  88. data/lib/seam/routes/clients/acs.rb +0 -44
  89. data/lib/seam/routes/clients/acs_access_groups.rb +0 -48
  90. data/lib/seam/routes/clients/acs_access_groups_unmanaged.rb +0 -24
  91. data/lib/seam/routes/clients/acs_credential_pools.rb +0 -18
  92. data/lib/seam/routes/clients/acs_credential_provisioning_automations.rb +0 -18
  93. data/lib/seam/routes/clients/acs_credentials.rb +0 -60
  94. data/lib/seam/routes/clients/acs_credentials_unmanaged.rb +0 -24
  95. data/lib/seam/routes/clients/acs_encoders.rb +0 -36
  96. data/lib/seam/routes/clients/acs_entrances.rb +0 -36
  97. data/lib/seam/routes/clients/acs_systems.rb +0 -30
  98. data/lib/seam/routes/clients/acs_users.rb +0 -78
  99. data/lib/seam/routes/clients/acs_users_unmanaged.rb +0 -24
  100. data/lib/seam/routes/clients/action_attempts.rb +0 -28
  101. data/lib/seam/routes/clients/client_sessions.rb +0 -54
  102. data/lib/seam/routes/clients/connect_webviews.rb +0 -36
  103. data/lib/seam/routes/clients/connected_accounts.rb +0 -36
  104. data/lib/seam/routes/clients/devices.rb +0 -50
  105. data/lib/seam/routes/clients/devices_simulate.rb +0 -30
  106. data/lib/seam/routes/clients/devices_unmanaged.rb +0 -30
  107. data/lib/seam/routes/clients/events.rb +0 -24
  108. data/lib/seam/routes/clients/index.rb +0 -38
  109. data/lib/seam/routes/clients/locks.rb +0 -42
  110. data/lib/seam/routes/clients/networks.rb +0 -24
  111. data/lib/seam/routes/clients/noise_sensors.rb +0 -26
  112. data/lib/seam/routes/clients/noise_sensors_noise_thresholds.rb +0 -42
  113. data/lib/seam/routes/clients/noise_sensors_simulate.rb +0 -18
  114. data/lib/seam/routes/clients/phones.rb +0 -28
  115. data/lib/seam/routes/clients/phones_simulate.rb +0 -18
  116. data/lib/seam/routes/clients/thermostats.rb +0 -108
  117. data/lib/seam/routes/clients/thermostats_schedules.rb +0 -42
  118. data/lib/seam/routes/clients/user_identities.rb +0 -88
  119. data/lib/seam/routes/clients/user_identities_enrollment_automations.rb +0 -36
  120. data/lib/seam/routes/clients/webhooks.rb +0 -42
  121. data/lib/seam/routes/clients/workspaces.rb +0 -40
  122. data/lib/seam/routes/resources/access_code.rb +0 -14
  123. data/lib/seam/routes/resources/acs_access_group.rb +0 -11
  124. data/lib/seam/routes/resources/acs_credential.rb +0 -14
  125. data/lib/seam/routes/resources/acs_credential_pool.rb +0 -11
  126. data/lib/seam/routes/resources/acs_credential_provisioning_automation.rb +0 -11
  127. data/lib/seam/routes/resources/acs_entrance.rb +0 -13
  128. data/lib/seam/routes/resources/acs_system.rb +0 -14
  129. data/lib/seam/routes/resources/acs_user.rb +0 -14
  130. data/lib/seam/routes/resources/action_attempt.rb +0 -9
  131. data/lib/seam/routes/resources/client_session.rb +0 -11
  132. data/lib/seam/routes/resources/connect_webview.rb +0 -11
  133. data/lib/seam/routes/resources/connected_account.rb +0 -14
  134. data/lib/seam/routes/resources/device.rb +0 -14
  135. data/lib/seam/routes/resources/device_provider.rb +0 -9
  136. data/lib/seam/routes/resources/enrollment_automation.rb +0 -11
  137. data/lib/seam/routes/resources/event.rb +0 -11
  138. data/lib/seam/routes/resources/index.rb +0 -33
  139. data/lib/seam/routes/resources/network.rb +0 -11
  140. data/lib/seam/routes/resources/noise_threshold.rb +0 -9
  141. data/lib/seam/routes/resources/phone.rb +0 -14
  142. data/lib/seam/routes/resources/resource_error.rb +0 -11
  143. data/lib/seam/routes/resources/resource_errors_support.rb +0 -11
  144. data/lib/seam/routes/resources/resource_warning.rb +0 -11
  145. data/lib/seam/routes/resources/resource_warnings_support.rb +0 -11
  146. data/lib/seam/routes/resources/service_health.rb +0 -9
  147. data/lib/seam/routes/resources/thermostat_schedule.rb +0 -13
  148. data/lib/seam/routes/resources/unmanaged_access_code.rb +0 -14
  149. data/lib/seam/routes/resources/unmanaged_device.rb +0 -14
  150. data/lib/seam/routes/resources/user_identity.rb +0 -11
  151. data/lib/seam/routes/resources/webhook.rb +0 -9
  152. data/lib/seam/routes/resources/workspace.rb +0 -9
  153. data/lib/seam/routes/routes.rb +0 -94
  154. data/lib/seam/token.rb +0 -53
  155. data/lib/seam/wait_for_action_attempt.rb +0 -32
  156. data/lib/seam/webhook.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 153a1125c70c291a174d633ade80bd679c7273bc7a822399e28c7d674585467f
4
- data.tar.gz: b014b0d28966949583b2aff44deb03ed2572145aefdb87ae5a8d4fc82f4976e2
3
+ metadata.gz: 633608dcbbd2c43fd668b46a8a6aa3ee7d23663a81ed92b84885d50dcedae3b4
4
+ data.tar.gz: 1f6c28b4b491077046e4b6d87cf26375871ba3a8a55df2c2c26c47ba52bea88f
5
5
  SHA512:
6
- metadata.gz: b62accc3cb7bc70e25e34199264dc2eccbbbecfc7527be0bb3de40e8f283e23c833872af9b78044eb0de6c51e522ba634dd24be91968f1a40762e6e02040453a
7
- data.tar.gz: 1a25544329a7d4a44b034d5dfa4f866b6b3efd8b819d3933b96099734bd3b6548a4c2e68a2d2c05d7c88cd35bf3c5536b11c8b9d8bc6d793393af7047dd0013e
6
+ metadata.gz: b231444fe73cc6baae32e5ef0af4d9490892bc881f0a56ddc3d6dce6011a18ae80d0805e537a5db1d65bbaf8bd73b498ead3e7391400dd3ce94e70400779b5f5
7
+ data.tar.gz: 38504e2b53afb62af4ba3808dbf0c2345284c45833a07a6dea1774ae2a6a64edb45c1b66ae9ff87eafb12ff2402e148ad89230d78b9b423be046fee4cad796b8
data/Gemfile.lock CHANGED
@@ -1,113 +1,117 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seam (2.0.0b5)
5
- faraday (~> 2.7)
6
- faraday-retry (~> 2.2)
7
- svix (~> 1.30)
4
+ seam (2.0.0.prerelease.1)
5
+ http (~> 5.2)
8
6
 
9
7
  GEM
10
8
  remote: https://rubygems.org/
11
9
  specs:
12
- addressable (2.8.7)
13
- public_suffix (>= 2.0.2, < 7.0)
10
+ addressable (2.8.6)
11
+ public_suffix (>= 2.0.2, < 6.0)
14
12
  ansi (1.5.0)
15
13
  ast (2.4.2)
16
- bigdecimal (3.1.8)
14
+ base64 (0.2.0)
15
+ bigdecimal (3.1.7)
17
16
  crack (1.0.0)
18
17
  bigdecimal
19
18
  rexml
20
19
  diff-lcs (1.5.1)
21
- docile (1.4.1)
22
- faraday (2.12.0)
23
- faraday-net_http (>= 2.0, < 3.4)
24
- json
25
- logger
26
- faraday-net_http (3.3.0)
27
- net-http
28
- faraday-retry (2.2.1)
29
- faraday (~> 2.0)
20
+ docile (1.4.0)
21
+ domain_name (0.6.20240107)
22
+ ffi (1.16.3)
23
+ ffi-compiler (1.3.2)
24
+ ffi (>= 1.15.5)
25
+ rake
30
26
  gem-release (2.2.2)
31
- hashdiff (1.1.2)
32
- json (2.8.1)
27
+ hashdiff (1.1.0)
28
+ http (5.2.0)
29
+ addressable (~> 2.8)
30
+ base64 (~> 0.1)
31
+ http-cookie (~> 1.0)
32
+ http-form_data (~> 2.2)
33
+ llhttp-ffi (~> 0.5.0)
34
+ http-cookie (1.0.5)
35
+ domain_name (~> 0.5)
36
+ http-form_data (2.3.0)
37
+ json (2.7.2)
33
38
  language_server-protocol (3.17.0.3)
34
39
  lint_roller (1.1.0)
35
- logger (1.6.1)
40
+ llhttp-ffi (0.5.0)
41
+ ffi-compiler (~> 1.0)
42
+ rake (~> 13.0)
36
43
  multi_json (1.15.0)
37
- net-http (0.5.0)
38
- uri
39
- parallel (1.26.3)
44
+ parallel (1.24.0)
40
45
  parse_gemspec (1.0.0)
41
46
  parse_gemspec-cli (1.0.0)
42
47
  multi_json
43
48
  parse_gemspec
44
49
  thor
45
- parser (3.3.6.0)
50
+ parser (3.3.0.5)
46
51
  ast (~> 2.4.1)
47
52
  racc
48
- public_suffix (6.0.1)
49
- racc (1.8.1)
53
+ public_suffix (5.0.5)
54
+ racc (1.7.3)
50
55
  rainbow (3.1.1)
51
56
  rake (13.2.1)
52
- regexp_parser (2.9.2)
53
- rexml (3.3.9)
57
+ regexp_parser (2.9.0)
58
+ rexml (3.2.6)
54
59
  rspec (3.13.0)
55
60
  rspec-core (~> 3.13.0)
56
61
  rspec-expectations (~> 3.13.0)
57
62
  rspec-mocks (~> 3.13.0)
58
- rspec-core (3.13.2)
63
+ rspec-core (3.13.0)
59
64
  rspec-support (~> 3.13.0)
60
- rspec-expectations (3.13.3)
65
+ rspec-expectations (3.13.0)
61
66
  diff-lcs (>= 1.2.0, < 2.0)
62
67
  rspec-support (~> 3.13.0)
63
- rspec-mocks (3.13.2)
68
+ rspec-mocks (3.13.0)
64
69
  diff-lcs (>= 1.2.0, < 2.0)
65
70
  rspec-support (~> 3.13.0)
66
71
  rspec-support (3.13.1)
67
- rubocop (1.66.1)
72
+ rubocop (1.62.1)
68
73
  json (~> 2.3)
69
74
  language_server-protocol (>= 3.17.0)
70
75
  parallel (~> 1.10)
71
76
  parser (>= 3.3.0.2)
72
77
  rainbow (>= 2.2.2, < 4.0)
73
- regexp_parser (>= 2.4, < 3.0)
74
- rubocop-ast (>= 1.32.2, < 2.0)
78
+ regexp_parser (>= 1.8, < 3.0)
79
+ rexml (>= 3.2.5, < 4.0)
80
+ rubocop-ast (>= 1.31.1, < 2.0)
75
81
  ruby-progressbar (~> 1.7)
76
82
  unicode-display_width (>= 2.4.0, < 3.0)
77
- rubocop-ast (1.35.0)
78
- parser (>= 3.3.1.0)
79
- rubocop-performance (1.22.1)
83
+ rubocop-ast (1.31.2)
84
+ parser (>= 3.3.0.4)
85
+ rubocop-performance (1.20.2)
80
86
  rubocop (>= 1.48.1, < 2.0)
81
- rubocop-ast (>= 1.31.1, < 2.0)
87
+ rubocop-ast (>= 1.30.0, < 2.0)
82
88
  ruby-progressbar (1.13.0)
83
89
  simplecov (0.22.0)
84
90
  docile (~> 1.1)
85
91
  simplecov-html (~> 0.11)
86
92
  simplecov_json_formatter (~> 0.1)
87
- simplecov-console (0.9.2)
93
+ simplecov-console (0.9.1)
88
94
  ansi
89
95
  simplecov
90
96
  terminal-table
91
- simplecov-html (0.13.1)
97
+ simplecov-html (0.12.3)
92
98
  simplecov_json_formatter (0.1.4)
93
- standard (1.41.1)
99
+ standard (1.35.1)
94
100
  language_server-protocol (~> 3.17.0.2)
95
101
  lint_roller (~> 1.0)
96
- rubocop (~> 1.66.0)
102
+ rubocop (~> 1.62.0)
97
103
  standard-custom (~> 1.0.0)
98
- standard-performance (~> 1.5)
104
+ standard-performance (~> 1.3)
99
105
  standard-custom (1.0.2)
100
106
  lint_roller (~> 1.0)
101
107
  rubocop (~> 1.50)
102
- standard-performance (1.5.0)
108
+ standard-performance (1.3.1)
103
109
  lint_roller (~> 1.1)
104
- rubocop-performance (~> 1.22.0)
105
- svix (1.40.0)
110
+ rubocop-performance (~> 1.20.2)
106
111
  terminal-table (3.0.2)
107
112
  unicode-display_width (>= 1.1.1, < 3)
108
- thor (1.3.2)
109
- unicode-display_width (2.6.0)
110
- uri (1.0.1)
113
+ thor (1.3.1)
114
+ unicode-display_width (2.5.0)
111
115
  webmock (3.0.1)
112
116
  addressable (>= 2.3.6)
113
117
  crack (>= 0.3.2)
@@ -130,4 +134,4 @@ DEPENDENCIES
130
134
  webmock (~> 3.0.0)
131
135
 
132
136
  BUNDLED WITH
133
- 2.5.16
137
+ 2.4.19
data/README.md CHANGED
@@ -7,337 +7,17 @@ SDK for the Seam API written in Ruby.
7
7
 
8
8
  ## Description
9
9
 
10
- [Seam](https://seam.co) makes it easy to integrate IoT devices with your applications.
11
- This is an official SDK for the Seam API.
12
- Please refer to the official [Seam Docs](https://docs.seam.co/latest/) to get started.
13
-
14
- Parts of this SDK are generated from always up-to-date type information
15
- provided by [@seamapi/types](https://github.com/seamapi/types/).
16
- This ensures all API methods, request shapes, and response shapes are
17
- accurate and fully typed.
18
-
19
- <!-- toc -->
20
-
21
- - [Installation](#installation)
22
- - [Usage](#usage)
23
- - [Examples](#examples)
24
- - [List devices](#list-devices)
25
- - [Unlock a door](#unlock-a-door)
26
- - [Authentication Method](#authentication-method)
27
- - [API Key](#api-key)
28
- - [Personal Access Token](#personal-access-token)
29
- - [Action Attempts](#action-attempts)
30
- - [Interacting with Multiple Workspaces](#interacting-with-multiple-workspaces)
31
- - [Webhooks](#webhooks)
32
- - [Advanced Usage](#advanced-usage)
33
- - [Additional Options](#additional-options)
34
- - [Setting the endpoint](#setting-the-endpoint)
35
- - [Configuring the Faraday Client](#configuring-the-faraday-client)
36
- - [Using the Faraday Client](#using-the-faraday-client)
37
- - [Overriding the Client](#overriding-the-client)
38
- - [Development and Testing](#development-and-testing)
39
- - [Quickstart](#quickstart)
40
- - [Source code](#source-code)
41
- - [Requirements](#requirements)
42
- - [Publishing](#publishing)
43
- - [Automatic](#automatic)
44
- - [Manual](#manual)
45
- - [GitHub Actions](#github-actions)
46
- - [Secrets for Optional GitHub Actions](#secrets-for-optional-github-actions)
47
- - [Contributing](#contributing)
48
- - [License](#license)
49
- - [Warranty](#warranty)
50
-
51
- <!-- tocstop -->
10
+ TODO
52
11
 
53
12
  ## Installation
54
13
 
55
- Add this as a dependency to your project using [Bundler] with:
14
+ Add this as a dependency to your project using [Bundler] with
56
15
 
57
16
  ```
58
17
  $ bundle add seam
59
18
  ```
60
19
 
61
- [Bundler]: https://bundler.io/
62
-
63
- ## Usage
64
-
65
- ### Examples
66
-
67
- > [!NOTE]
68
- > These examples assume `SEAM_API_KEY` is set in your environment.
69
-
70
- #### List devices
71
-
72
- ```ruby
73
- require "seam"
74
-
75
- seam = Seam.new
76
- devices = seam.devices.list
77
- ```
78
-
79
- #### Unlock a door
80
-
81
- ```ruby
82
- require "seam"
83
-
84
- seam = Seam.new
85
- lock = seam.locks.get(name: "Front Door")
86
- seam.locks.unlock_door(device_id: lock.device_id)
87
- ```
88
-
89
- ### Authentication Method
90
-
91
- The SDK supports API key and personal access token authentication mechanisms.
92
- Authentication may be configured by passing the corresponding options directly to the `Seam` constructor, or with the more ergonomic static factory methods.
93
-
94
- #### API Key
95
-
96
- An API key is scoped to a single workspace and should only be used on the server.
97
- Obtain one from the Seam Console.
98
-
99
- ```ruby
100
- # Set the `SEAM_API_KEY` environment variable
101
- seam = Seam.new
102
-
103
- # Pass as a keyword argument to the constructor
104
- seam = Seam.new(api_key: "your-api-key")
105
-
106
- # Use the factory method
107
- seam = Seam.from_api_key("your-api-key")
108
- ```
109
-
110
- #### Personal Access Token
111
-
112
- A Personal Access Token is scoped to a Seam Console user.
113
- Obtain one from the Seam Console.
114
- A workspace ID must be provided when using this method and all requests will be scoped to that workspace.
115
-
116
- ```ruby
117
- # Pass as an option to the constructor
118
- seam = Seam.new(
119
- personal_access_token: "your-personal-access-token",
120
- workspace_id: "your-workspace-id"
121
- )
122
-
123
- # Use the factory method
124
- seam = Seam.from_personal_access_token(
125
- "your-personal-access-token",
126
- "your-workspace-id"
127
- )
128
- ```
129
-
130
- ### Action Attempts
131
-
132
- Some asynchronous operations, e.g., unlocking a door, return an
133
- [action attempt](https://docs.seam.co/latest/core-concepts/action-attempts).
134
- Seam tracks the progress of the requested operation and updates the action attempt
135
- when it succeeds or fails.
136
-
137
- To make working with action attempts more convenient for applications,
138
- this library provides the `wait_for_action_attempt` option and enables it by default.
139
-
140
- When the `wait_for_action_attempt` option is enabled, the SDK:
141
-
142
- - Polls the action attempt up to the `timeout`
143
- at the `polling_interval` (both in seconds).
144
- - Resolves with a fresh copy of the successful action attempt.
145
- - Raises a `Seam::ActionAttemptFailedError` if the action attempt is unsuccessful.
146
- - Raises a `Seam::ActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
147
- - Both errors expose an `action_attempt` property.
148
-
149
- If you already have an action attempt ID
150
- and want to wait for it to resolve, simply use:
151
-
152
- ```ruby
153
- seam.action_attempts.get(action_attempt_id: action_attempt_id)
154
- ```
155
-
156
- Or, to get the current state of an action attempt by ID without waiting:
157
-
158
- ```ruby
159
- seam.action_attempts.get(
160
- action_attempt_id: action_attempt_id,
161
- wait_for_action_attempt: false
162
- )
163
- ```
164
-
165
- To disable this behavior, set the default option for the client:
166
-
167
- ```ruby
168
- seam = Seam.new(
169
- api_key: "your-api-key",
170
- wait_for_action_attempt: false
171
- )
172
-
173
- seam.locks.unlock_door(device_id: device_id)
174
- ```
175
-
176
- or the behavior may be configured per-request:
177
-
178
- ```ruby
179
- seam.locks.unlock_door(
180
- device_id: device_id,
181
- wait_for_action_attempt: false
182
- )
183
- ```
184
-
185
- The `polling_interval` and `timeout` may be configured for the client or per-request.
186
- For example:
187
-
188
- ```ruby
189
- require "seam"
190
-
191
- seam = Seam.new("your-api-key")
192
-
193
- locks = seam.locks.list
194
-
195
- if locks.empty?
196
- raise "No locks in this workspace"
197
- end
198
-
199
- lock = locks.first
200
-
201
- begin
202
- seam.locks.unlock_door(
203
- device_id: lock.device_id,
204
- wait_for_action_attempt: {
205
- timeout: 5.0,
206
- polling_interval: 1.0
207
- }
208
- )
209
-
210
- puts "Door unlocked"
211
- rescue Seam::ActionAttemptFailedError
212
- puts "Could not unlock the door"
213
- rescue Seam::ActionAttemptTimeoutError
214
- puts "Door took too long to unlock"
215
- end
216
- ```
217
-
218
- ### Interacting with Multiple Workspaces
219
-
220
- Some Seam API endpoints interact with multiple workspaces. The `Seam::Http::SeamMultiWorkspace` client is not bound to a specific workspace and may use those endpoints with a personal access token authentication method.
221
-
222
- A Personal Access Token is scoped to a Seam Console user. Obtain one from the Seam Console.
223
-
224
- ```ruby
225
- # Pass as an option to the constructor
226
- seam = Seam::Http::SeamMultiWorkspace.new(personal_access_token: "your-personal-access-token")
227
-
228
- # Use the factory method
229
- seam = Seam::Http::SeamMultiWorkspace.from_personal_access_token("your-personal-access-token")
230
-
231
- # List workspaces authorized for this Personal Access Token
232
- workspaces = seam.workspaces.list
233
- ```
234
-
235
- ### Webhooks
236
-
237
- The Seam API implements webhooks using [Svix](https://www.svix.com).This SDK exports a thin wrapper `Seam::Webhook` around the svix package.
238
- Use it to parse and validate Seam webhook events.
239
-
240
- > [!TIP]
241
- > This example is for [Sinatra](https://sinatrarb.com/), see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how).
242
-
243
- ```ruby
244
- require "sinatra"
245
- require "seam"
246
-
247
- webhook = Seam::Webhook.new(ENV["SEAM_WEBHOOK_SECRET"])
248
-
249
- post "/webhook" do
250
- begin
251
- headers = {
252
- "svix-id" => request.env["HTTP_SVIX_ID"],
253
- "svix-signature" => request.env["HTTP_SVIX_SIGNATURE"],
254
- "svix-timestamp" => request.env["HTTP_SVIX_TIMESTAMP"]
255
- }
256
- data = webhook.verify(request.body.read, headers)
257
- rescue Seam::WebhookVerificationError
258
- halt 400, "Bad Request"
259
- end
260
-
261
- begin
262
- store_event(data)
263
- rescue
264
- halt 500, "Internal Server Error"
265
- end
266
-
267
- 204
268
- end
269
-
270
- def store_event(data)
271
- puts data
272
- end
273
- ```
274
-
275
- ### Advanced Usage
276
-
277
- #### Additional Options
278
-
279
- In addition to the various authentication options,
280
- the constructor takes some advanced options that affect behavior.
281
-
282
- ```ruby
283
- seam = Seam.new(
284
- api_key: "your-api-key",
285
- endpoint: "https://example.com",
286
- faraday_options: {},
287
- faraday_retry_options: {}
288
- )
289
- ```
290
-
291
- When using the static factory methods,
292
- these options may be passed in as keyword arguments.
293
-
294
- ```ruby
295
- seam = Seam.from_api_key("some-api-key",
296
- endpoint: "https://example.com",
297
- faraday_options: {},
298
- faraday_retry_options: {})
299
- ```
300
-
301
- #### Setting the endpoint
302
-
303
- Some contexts may need to override the API endpoint,
304
- e.g., testing or proxy setups. This option corresponds to the [Faraday](https://lostisland.github.io/faraday/#/) `url` setting.
305
-
306
- Either pass the `endpoint` option, or set the `SEAM_ENDPOINT` environment variable.
307
-
308
- #### Configuring the Faraday Client
309
-
310
- The Faraday client and retry behavior may be configured with custom initiation options
311
- via [`faraday_option`][faraday_option] and [`faraday_retry_option`][faraday_retry_option].
312
-
313
- [faraday_option]: https://lostisland.github.io/faraday/#/customization/connection-options?id=connection-options
314
- [faraday_retry_option]: https://github.com/lostisland/faraday-retry
315
-
316
- #### Using the Faraday Client
317
-
318
- The Faraday client is exposed and may be used or configured directly:
319
-
320
- ```ruby
321
- require "seam"
322
- require "faraday"
323
-
324
- class MyMiddleware < Faraday::Middleware
325
- def on_complete(env)
326
- puts env.response.inspect
327
- end
328
- end
329
-
330
- seam = Seam.new
331
-
332
- seam.client.builder.use MyMiddleware
333
-
334
- devices = seam.client.get("/devices/list").body["devices"]
335
- ```
336
-
337
- #### Overriding the Client
338
-
339
- A Faraday compatible client may be provided to create a `Seam` instance.
340
- This API is used internally and is not directly supported.
20
+ [bundler]: https://bundler.io/
341
21
 
342
22
  ## Development and Testing
343
23
 
data/Rakefile CHANGED
@@ -5,10 +5,7 @@ require "rspec/core/rake_task"
5
5
  require "standard/rake"
6
6
 
7
7
  RSpec::Core::RakeTask.new(:spec) do |t|
8
- t.pattern = [
9
- "spec/**/*_spec.rb",
10
- "lib/seam/*_spec.rb"
11
- ]
8
+ t.rspec_opts = "--pattern spec/**/*_spec.rb"
12
9
  end
13
10
 
14
11
  task default: %i[lint test]
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Seam
4
+ class Client
5
+ attr_accessor :api_key, :base_uri, :debug, :wait_for_action_attempt
6
+
7
+ def self.lts_version
8
+ Seam::LTS_VERSION
9
+ end
10
+
11
+ def initialize(api_key: nil, base_uri: nil, wait_for_action_attempt: false, debug: false)
12
+ @api_key = api_key || ENV["SEAM_API_KEY"]
13
+ @base_uri = base_uri || ENV["SEAM_API_URL"] || ENV["SEAM_ENDPOINT"] || "https://connect.getseam.com"
14
+ @debug = debug
15
+ @wait_for_action_attempt = wait_for_action_attempt
16
+
17
+ raise ArgumentError, "SEAM_API_KEY not found in environment, and api_key not provided" if @api_key.to_s.empty?
18
+
19
+ if ENV["SEAM_API_URL"]
20
+ warn "Using the SEAM_API_URL environment variable is deprecated. " \
21
+ "Support will be removed in a later major version. Use SEAM_ENDPOINT instead."
22
+ end
23
+ end
24
+
25
+ def lts_version
26
+ Seam::LTS_VERSION
27
+ end
28
+
29
+ def access_codes
30
+ @access_codes ||= Seam::Clients::AccessCodes.new(self)
31
+ end
32
+
33
+ def acs
34
+ @acs ||= Seam::Clients::Acs.new(self)
35
+ end
36
+
37
+ def action_attempts
38
+ @action_attempts ||= Seam::Clients::ActionAttempts.new(self)
39
+ end
40
+
41
+ def client_sessions
42
+ @client_sessions ||= Seam::Clients::ClientSessions.new(self)
43
+ end
44
+
45
+ def connect_webviews
46
+ @connect_webviews ||= Seam::Clients::ConnectWebviews.new(self)
47
+ end
48
+
49
+ def connected_accounts
50
+ @connected_accounts ||= Seam::Clients::ConnectedAccounts.new(self)
51
+ end
52
+
53
+ def devices
54
+ @devices ||= Seam::Clients::Devices.new(self)
55
+ end
56
+
57
+ def events
58
+ @events ||= Seam::Clients::Events.new(self)
59
+ end
60
+
61
+ def locks
62
+ @locks ||= Seam::Clients::Locks.new(self)
63
+ end
64
+
65
+ def networks
66
+ @networks ||= Seam::Clients::Networks.new(self)
67
+ end
68
+
69
+ def noise_sensors
70
+ @noise_sensors ||= Seam::Clients::NoiseSensors.new(self)
71
+ end
72
+
73
+ def phones
74
+ @phones ||= Seam::Clients::Phones.new(self)
75
+ end
76
+
77
+ def thermostats
78
+ @thermostats ||= Seam::Clients::Thermostats.new(self)
79
+ end
80
+
81
+ def user_identities
82
+ @user_identities ||= Seam::Clients::UserIdentities.new(self)
83
+ end
84
+
85
+ def webhooks
86
+ @webhooks ||= Seam::Clients::Webhooks.new(self)
87
+ end
88
+
89
+ def workspaces
90
+ @workspaces ||= Seam::Clients::Workspaces.new(self)
91
+ end
92
+
93
+ def health
94
+ request_seam(:get, "/health")
95
+ end
96
+
97
+ # @deprecated Please use {#devices.unmanaged} instead.
98
+ def unmanaged_devices
99
+ warn "[DEPRECATION] 'unmanaged_devices' is deprecated. Please use 'devices.unmanaged' instead."
100
+
101
+ @unmanaged_devices ||= Seam::Clients::DevicesUnmanaged.new(self)
102
+ end
103
+
104
+ # @deprecated Please use {#access_codes.unmanaged} instead.
105
+ def unmanaged_access_codes
106
+ warn "[DEPRECATION] 'unmanaged_access_codes' is deprecated. Please use 'access_codes.unmanaged' instead."
107
+
108
+ @unmanaged_access_codes ||= Seam::Clients::AccessCodesUnmanaged.new(self)
109
+ end
110
+
111
+ def request_seam_object(method, path, klass, inner_object, config = {})
112
+ response = request_seam(method, path, config)
113
+
114
+ data = response[inner_object]
115
+
116
+ klass.load_from_response(data, self)
117
+ end
118
+
119
+ def request_seam(method, path, config = {})
120
+ Seam::Request.new(
121
+ api_key: api_key,
122
+ base_uri: base_uri,
123
+ debug: debug
124
+ ).perform(
125
+ method, path, config
126
+ )
127
+ end
128
+ end
129
+ end