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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3bb7a5a7828d18d2b54017d76ed325d0e7e25c482de942eca0330da40f7e1105
|
4
|
+
data.tar.gz: 8a86ca467008bb6f8d2b76394f9f773a938f072a384a29dc78dc16e430917bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 138e121c4bc2482ca27d3a74df486effb52d749de8e1af57fa95ec20600c109e7b2779794e2724fbe8436192ce3a40481e693857ca19b99a320ca96fe4623fe6
|
7
|
+
data.tar.gz: 4ae84ca5a842777f890f5df0cbff9252fa22d9658f7d03422abcb992a1412e1a272a538019c0f436290bb0064dea0344292690a919a4aa305ec7b3d84e96a30b
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
seam (2.0.0a2)
|
5
|
+
http (~> 5.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.6)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
|
+
ansi (1.5.0)
|
13
|
+
ast (2.4.2)
|
14
|
+
base64 (0.2.0)
|
15
|
+
bigdecimal (3.1.7)
|
16
|
+
crack (1.0.0)
|
17
|
+
bigdecimal
|
18
|
+
rexml
|
19
|
+
diff-lcs (1.5.1)
|
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
|
26
|
+
gem-release (2.2.2)
|
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)
|
38
|
+
language_server-protocol (3.17.0.3)
|
39
|
+
lint_roller (1.1.0)
|
40
|
+
llhttp-ffi (0.5.0)
|
41
|
+
ffi-compiler (~> 1.0)
|
42
|
+
rake (~> 13.0)
|
43
|
+
multi_json (1.15.0)
|
44
|
+
parallel (1.24.0)
|
45
|
+
parse_gemspec (1.0.0)
|
46
|
+
parse_gemspec-cli (1.0.0)
|
47
|
+
multi_json
|
48
|
+
parse_gemspec
|
49
|
+
thor
|
50
|
+
parser (3.3.0.5)
|
51
|
+
ast (~> 2.4.1)
|
52
|
+
racc
|
53
|
+
public_suffix (5.0.5)
|
54
|
+
racc (1.7.3)
|
55
|
+
rainbow (3.1.1)
|
56
|
+
rake (13.2.1)
|
57
|
+
regexp_parser (2.9.0)
|
58
|
+
rexml (3.2.6)
|
59
|
+
rspec (3.13.0)
|
60
|
+
rspec-core (~> 3.13.0)
|
61
|
+
rspec-expectations (~> 3.13.0)
|
62
|
+
rspec-mocks (~> 3.13.0)
|
63
|
+
rspec-core (3.13.0)
|
64
|
+
rspec-support (~> 3.13.0)
|
65
|
+
rspec-expectations (3.13.0)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.13.0)
|
68
|
+
rspec-mocks (3.13.0)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.13.0)
|
71
|
+
rspec-support (3.13.1)
|
72
|
+
rubocop (1.62.1)
|
73
|
+
json (~> 2.3)
|
74
|
+
language_server-protocol (>= 3.17.0)
|
75
|
+
parallel (~> 1.10)
|
76
|
+
parser (>= 3.3.0.2)
|
77
|
+
rainbow (>= 2.2.2, < 4.0)
|
78
|
+
regexp_parser (>= 1.8, < 3.0)
|
79
|
+
rexml (>= 3.2.5, < 4.0)
|
80
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
81
|
+
ruby-progressbar (~> 1.7)
|
82
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
83
|
+
rubocop-ast (1.31.2)
|
84
|
+
parser (>= 3.3.0.4)
|
85
|
+
rubocop-performance (1.20.2)
|
86
|
+
rubocop (>= 1.48.1, < 2.0)
|
87
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
88
|
+
ruby-progressbar (1.13.0)
|
89
|
+
simplecov (0.22.0)
|
90
|
+
docile (~> 1.1)
|
91
|
+
simplecov-html (~> 0.11)
|
92
|
+
simplecov_json_formatter (~> 0.1)
|
93
|
+
simplecov-console (0.9.1)
|
94
|
+
ansi
|
95
|
+
simplecov
|
96
|
+
terminal-table
|
97
|
+
simplecov-html (0.12.3)
|
98
|
+
simplecov_json_formatter (0.1.4)
|
99
|
+
standard (1.35.1)
|
100
|
+
language_server-protocol (~> 3.17.0.2)
|
101
|
+
lint_roller (~> 1.0)
|
102
|
+
rubocop (~> 1.62.0)
|
103
|
+
standard-custom (~> 1.0.0)
|
104
|
+
standard-performance (~> 1.3)
|
105
|
+
standard-custom (1.0.2)
|
106
|
+
lint_roller (~> 1.0)
|
107
|
+
rubocop (~> 1.50)
|
108
|
+
standard-performance (1.3.1)
|
109
|
+
lint_roller (~> 1.1)
|
110
|
+
rubocop-performance (~> 1.20.2)
|
111
|
+
terminal-table (3.0.2)
|
112
|
+
unicode-display_width (>= 1.1.1, < 3)
|
113
|
+
thor (1.3.1)
|
114
|
+
unicode-display_width (2.5.0)
|
115
|
+
webmock (3.0.1)
|
116
|
+
addressable (>= 2.3.6)
|
117
|
+
crack (>= 0.3.2)
|
118
|
+
hashdiff
|
119
|
+
|
120
|
+
PLATFORMS
|
121
|
+
ruby
|
122
|
+
x86_64-linux
|
123
|
+
|
124
|
+
DEPENDENCIES
|
125
|
+
bundler (~> 2.0)
|
126
|
+
gem-release (~> 2.2)
|
127
|
+
parse_gemspec-cli (~> 1.0)
|
128
|
+
rake (~> 13.0)
|
129
|
+
rspec (~> 3.0)
|
130
|
+
seam!
|
131
|
+
simplecov (~> 0.21)
|
132
|
+
simplecov-console (~> 0.9)
|
133
|
+
standard (~> 1.3)
|
134
|
+
webmock (~> 3.0.0)
|
135
|
+
|
136
|
+
BUNDLED WITH
|
137
|
+
2.4.19
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2021-2024 Seam Labs, Inc.
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,166 +1,169 @@
|
|
1
|
-
# Seam
|
1
|
+
# Seam Ruby SDK
|
2
2
|
|
3
|
-
|
3
|
+
[![RubyGems.org](https://img.shields.io/gem/v/seam)](https://rubygems.org/gems/seam)
|
4
|
+
[![GitHub Actions](https://github.com/seamapi/ruby-next/actions/workflows/check.yml/badge.svg)](https://github.com/seamapi/ruby-next/actions/workflows/check.yml)
|
4
5
|
|
5
|
-
|
6
|
+
SDK for the Seam API written in Ruby.
|
6
7
|
|
7
|
-
|
8
|
+
## Description
|
8
9
|
|
9
|
-
|
10
|
+
TODO
|
10
11
|
|
11
|
-
|
12
|
-
It provides a way to define the process, break it up into separate components, and then send entities through the process.
|
13
|
-
|
14
|
-
####Define a workflow####
|
12
|
+
## Installation
|
15
13
|
|
16
|
-
|
14
|
+
Add this as a dependency to your project using [Bundler] with
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
flow.wait_for_order_to_be_shipped wait_up_to: 7.days
|
22
|
-
flow.send_shipping_email email_template: 'shipping_7'
|
23
|
-
flow.mark_order_as_fulfilled
|
24
|
-
````
|
16
|
+
```
|
17
|
+
$ bundle add seam
|
18
|
+
```
|
25
19
|
|
26
|
-
|
20
|
+
[bundler]: https://bundler.io/
|
27
21
|
|
28
|
-
|
22
|
+
## Development and Testing
|
29
23
|
|
30
|
-
|
31
|
-
flow.wait_for_order_to_be_shipped wait_up_to: 7.days
|
32
|
-
````
|
24
|
+
### Quickstart
|
33
25
|
|
34
|
-
|
26
|
+
```
|
27
|
+
$ git clone https://github.com/seamapi/ruby-next.git
|
28
|
+
$ cd ruby-next
|
29
|
+
$ bundle install
|
30
|
+
```
|
35
31
|
|
36
|
-
|
32
|
+
Run the command below
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
```
|
35
|
+
$ bundle exec rake
|
36
|
+
```
|
41
37
|
|
42
|
-
|
38
|
+
Open an interactive ruby console with
|
43
39
|
|
44
|
-
|
40
|
+
```
|
41
|
+
$ bundle exec rake
|
42
|
+
```
|
45
43
|
|
46
|
-
|
44
|
+
Primary development tasks are defined as [rake] tasks in the `Rakefile`
|
45
|
+
and available via `rake`.
|
46
|
+
View them with
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
@history=[],
|
52
|
-
@complete=false,
|
53
|
-
@id="1ecc4cbe-16af-45f6-8532-7f37493ec11c",
|
54
|
-
@created_at=2013-08-20 22:58:07 -0500,
|
55
|
-
@next_execute_at=2013-08-20 22:58:07 -0500,
|
56
|
-
@next_step="send_order_to_warehouse",
|
57
|
-
@flow={"steps"=>[{"name"=>"send_order_to_warehouse", "type"=>"do", "arguments"=>{}}, {"name"=>"wait_for_order_to_be_shipped", "type"=>"do", "arguments"=>{}}, {"name"=>"send_shipping_email", "type"=>"do", "arguments"=>{}}, {"name"=>"mark_order_as_fulfilled", "type"=>"do", "arguments"=>{}}]},
|
58
|
-
@data={"order_id"=>"1234"}>
|
59
|
-
````
|
48
|
+
```
|
49
|
+
$ bundle exec rake -T
|
50
|
+
```
|
60
51
|
|
61
|
-
|
52
|
+
[rake]: https://ruby.github.io/rake/
|
62
53
|
|
63
|
-
|
54
|
+
### Source code
|
64
55
|
|
65
|
-
|
56
|
+
The [source code] is hosted on GitHub.
|
57
|
+
Clone the project with
|
66
58
|
|
67
|
-
|
68
|
-
|
69
|
-
|
59
|
+
```
|
60
|
+
$ git clone git@github.com:seamapi/ruby-next.git
|
61
|
+
```
|
70
62
|
|
71
|
-
|
63
|
+
[source code]: https://github.com/seamapi/ruby-next
|
72
64
|
|
73
|
-
|
74
|
-
class SendOrderToWarehouseWorker < Seam::Worker
|
75
|
-
def process
|
76
|
-
# the current workflow instance is available as "effort"
|
77
|
-
order = Order.find effort.data['order_id']
|
78
|
-
warehouse_service.send order
|
65
|
+
### Requirements
|
79
66
|
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
83
|
-
````
|
67
|
+
You will need [Ruby] with [Bundler] and [Node.js] with [npm].
|
84
68
|
|
85
|
-
|
69
|
+
Be sure that all commands run under the correct Ruby version, e.g.,
|
70
|
+
if using [rbenv], install the correct version with
|
86
71
|
|
87
|
-
|
72
|
+
```
|
73
|
+
$ rbenv install
|
74
|
+
$ npm install
|
75
|
+
```
|
88
76
|
|
89
|
-
|
90
|
-
SendOrderToWarehouse.execute_all
|
91
|
-
````
|
77
|
+
Install the development dependencies with
|
92
78
|
|
93
|
-
|
79
|
+
```
|
80
|
+
$ bundle install
|
81
|
+
```
|
94
82
|
|
95
|
-
|
83
|
+
[bundler]: https://bundler.io/
|
84
|
+
[Node.js]: https://nodejs.org/
|
85
|
+
[npm]: https://www.npmjs.com/
|
86
|
+
[ruby]: https://www.ruby-lang.org/
|
87
|
+
[rbenv]: https://github.com/rbenv/rbenv
|
96
88
|
|
97
|
-
|
89
|
+
### Publishing
|
98
90
|
|
99
|
-
|
100
|
-
class WaitForOrderToBeShippedWorker < Seam::Worker
|
101
|
-
def process
|
102
|
-
effort.data["shipping_status"] = # some method that returns the shipping status
|
103
|
-
unless effort.data["shipping_status"] == "shipped"
|
104
|
-
try_again_in 4.hours
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
````
|
91
|
+
New versions are created with [gem release].
|
109
92
|
|
110
|
-
|
93
|
+
#### Automatic
|
111
94
|
|
112
|
-
|
95
|
+
New versions are released automatically with [semantic-release]
|
96
|
+
as long as commits follow the [Angular Commit Message Conventions].
|
113
97
|
|
114
|
-
|
115
|
-
|
116
|
-
def process
|
117
|
-
effort.data["shipping_status"] = # some method that returns the shipping status
|
118
|
-
if effort.data["shipping_status"] == "cancelled"
|
119
|
-
eject # no need to continue!
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
````
|
98
|
+
[Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format
|
99
|
+
[semantic-release]: https://semantic-release.gitbook.io/
|
124
100
|
|
125
|
-
####
|
101
|
+
#### Manual
|
126
102
|
|
127
|
-
|
103
|
+
Publish a new version by triggering a [version workflow_dispatch on GitHub Actions].
|
104
|
+
The `version` input will be passed to the `--version` option of `gem bump`.
|
128
105
|
|
129
|
-
|
106
|
+
This may be done on the web or using the [GitHub CLI] with
|
130
107
|
|
131
|
-
|
132
|
-
|
133
|
-
|
108
|
+
```
|
109
|
+
$ gh workflow run version.yml --raw-field version=<version>
|
110
|
+
```
|
134
111
|
|
135
|
-
|
112
|
+
[gem release]: https://github.com/svenfuchs/gem-release
|
113
|
+
[GitHub CLI]: https://cli.github.com/
|
114
|
+
[version workflow_dispatch on GitHub Actions]: https://github.com/seamapi/ruby-next/actions?query=workflow%3Aversion
|
136
115
|
|
137
|
-
|
116
|
+
## GitHub Actions
|
138
117
|
|
139
|
-
|
140
|
-
flow = Seam::Flow.new
|
141
|
-
flow.send_order_to_warehouse
|
142
|
-
flow.wait 2.days
|
143
|
-
flow.check_if_the_order_has_been_fulfilled
|
144
|
-
````
|
118
|
+
_GitHub Actions should already be configured: this section is for reference only._
|
145
119
|
|
146
|
-
|
120
|
+
The following repository secrets must be set on [GitHub Actions]:
|
147
121
|
|
148
|
-
|
122
|
+
- `RUBYGEMS_API_KEY`: RubyGems.org token for publishing gems.
|
149
123
|
|
150
|
-
|
124
|
+
These must be set manually.
|
151
125
|
|
152
|
-
|
126
|
+
### Secrets for Optional GitHub Actions
|
153
127
|
|
154
|
-
|
128
|
+
The version, format, generate, and semantic-release GitHub actions
|
129
|
+
require a user with write access to the repository.
|
130
|
+
Set these additional secrets to enable the action:
|
155
131
|
|
156
|
-
|
132
|
+
- `GH_TOKEN`: A personal access token for the user.
|
133
|
+
- `GIT_USER_NAME`: The GitHub user's real name.
|
134
|
+
- `GIT_USER_EMAIL`: The GitHub user's email.
|
135
|
+
- `GPG_PRIVATE_KEY`: The GitHub user's [GPG private key].
|
136
|
+
- `GPG_PASSPHRASE`: The GitHub user's GPG passphrase.
|
157
137
|
|
158
|
-
|
138
|
+
[github actions]: https://github.com/features/actions
|
139
|
+
[gpg private key]: https://github.com/marketplace/actions/import-gpg#prerequisites
|
159
140
|
|
160
141
|
## Contributing
|
161
142
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
143
|
+
Please submit and comment on bug reports and feature requests.
|
144
|
+
|
145
|
+
To submit a patch:
|
146
|
+
|
147
|
+
1. Fork it (https://github.com/seamapi/ruby-next/fork).
|
148
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
149
|
+
3. Make changes.
|
150
|
+
4. Commit your changes (`git commit -am 'Add some feature'`).
|
151
|
+
5. Push to the branch (`git push origin my-new-feature`).
|
152
|
+
6. Create a new Pull Request.
|
153
|
+
|
154
|
+
## License
|
155
|
+
|
156
|
+
This Ruby gem is licensed under the MIT license.
|
157
|
+
|
158
|
+
## Warranty
|
159
|
+
|
160
|
+
This software is provided by the copyright holders and contributors "as is" and
|
161
|
+
any express or implied warranties, including, but not limited to, the implied
|
162
|
+
warranties of merchantability and fitness for a particular purpose are
|
163
|
+
disclaimed. In no event shall the copyright holder or contributors be liable for
|
164
|
+
any direct, indirect, incidental, special, exemplary, or consequential damages
|
165
|
+
(including, but not limited to, procurement of substitute goods or services;
|
166
|
+
loss of use, data, or profits; or business interruption) however caused and on
|
167
|
+
any theory of liability, whether in contract, strict liability, or tort
|
168
|
+
(including negligence or otherwise) arising in any way out of the use of this
|
169
|
+
software, even if advised of the possibility of such damage.
|
data/Rakefile
CHANGED
@@ -1 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "standard/rake"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.rspec_opts = "--pattern spec/**/*_spec.rb"
|
9
|
+
end
|
10
|
+
|
11
|
+
task default: %i[lint test]
|
12
|
+
|
13
|
+
task test: "spec"
|
14
|
+
task lint: "standard"
|
15
|
+
task format: "standard:fix"
|
16
|
+
|
17
|
+
desc "Open an interactive ruby console"
|
18
|
+
task :console do
|
19
|
+
require "irb"
|
20
|
+
require "bundler/setup"
|
21
|
+
require "seam"
|
22
|
+
ARGV.clear
|
23
|
+
IRB.start
|
24
|
+
end
|
data/lib/seam/client.rb
ADDED
@@ -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
|