seamapi 0.0.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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +23 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +87 -0
- data/README.md +41 -0
- data/Rakefile +12 -0
- data/lib/seam/client.rb +63 -0
- data/lib/seam/clients/access_codes.rb +52 -0
- data/lib/seam/clients/action_attempts.rb +17 -0
- data/lib/seam/clients/base_client.rb +17 -0
- data/lib/seam/clients/connect_webviews.rb +37 -0
- data/lib/seam/clients/connected_accounts.rb +17 -0
- data/lib/seam/clients/devices.rb +27 -0
- data/lib/seam/clients/locks.rb +67 -0
- data/lib/seam/clients/workspaces.rb +36 -0
- data/lib/seam/logger.rb +12 -0
- data/lib/seam/request.rb +68 -0
- data/lib/seam/resources/access_code.rb +7 -0
- data/lib/seam/resources/action_attempt.rb +20 -0
- data/lib/seam/resources/base_resource.rb +31 -0
- data/lib/seam/resources/connect_webview.rb +9 -0
- data/lib/seam/resources/connected_account.rb +7 -0
- data/lib/seam/resources/device.rb +7 -0
- data/lib/seam/resources/workspace.rb +7 -0
- data/lib/seam/version.rb +5 -0
- data/lib/seam.rb +24 -0
- data/sig/seamapi.rbs +4 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 173cc34127a115428d6d17298a4766932b8c27384528bbe2127d6afa581f2cae
|
4
|
+
data.tar.gz: 91a107fa9a2e9b88dec0afd88cb1f0cb95ec17496903261738e50d103d656636
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63dbdd58445cc484106ebeae1bd1c0a36638bbe01c66fef315bc79abb04ea50cdffd6cfbeb92d3776849abf1ed01894434bc1f688c23fe1e21cc2f65133fc587
|
7
|
+
data.tar.gz: 5b5a89d6c4ab8944ac322db1f555c59bc4f199c9e440a806d74b79c6169dc6864612f886e67859766fc525bec0b6f6a59759b4c6597db6b00eecb7803de6d2f3
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
NewCops: enable
|
4
|
+
|
5
|
+
Style/StringLiterals:
|
6
|
+
Enabled: true
|
7
|
+
EnforcedStyle: double_quotes
|
8
|
+
|
9
|
+
Style/StringLiteralsInInterpolation:
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: double_quotes
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/BlockLength:
|
20
|
+
IgnoredMethods: ['describe', 'context', 'xdescribe']
|
21
|
+
|
22
|
+
Gemspec/RequireMFA:
|
23
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
seamapi (0.1.0)
|
5
|
+
http (~> 5.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
crack (0.4.5)
|
14
|
+
rexml
|
15
|
+
diff-lcs (1.5.0)
|
16
|
+
domain_name (0.5.20190701)
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
ffi (1.15.5)
|
19
|
+
ffi-compiler (1.0.1)
|
20
|
+
ffi (>= 1.0.0)
|
21
|
+
rake
|
22
|
+
hashdiff (1.0.1)
|
23
|
+
http (5.0.4)
|
24
|
+
addressable (~> 2.8)
|
25
|
+
http-cookie (~> 1.0)
|
26
|
+
http-form_data (~> 2.2)
|
27
|
+
llhttp-ffi (~> 0.4.0)
|
28
|
+
http-cookie (1.0.5)
|
29
|
+
domain_name (~> 0.5)
|
30
|
+
http-form_data (2.3.0)
|
31
|
+
llhttp-ffi (0.4.0)
|
32
|
+
ffi-compiler (~> 1.0)
|
33
|
+
rake (~> 13.0)
|
34
|
+
parallel (1.22.1)
|
35
|
+
parser (3.1.2.0)
|
36
|
+
ast (~> 2.4.1)
|
37
|
+
public_suffix (4.0.7)
|
38
|
+
rainbow (3.1.1)
|
39
|
+
rake (13.0.6)
|
40
|
+
regexp_parser (2.5.0)
|
41
|
+
rexml (3.2.5)
|
42
|
+
rspec (3.11.0)
|
43
|
+
rspec-core (~> 3.11.0)
|
44
|
+
rspec-expectations (~> 3.11.0)
|
45
|
+
rspec-mocks (~> 3.11.0)
|
46
|
+
rspec-core (3.11.0)
|
47
|
+
rspec-support (~> 3.11.0)
|
48
|
+
rspec-expectations (3.11.0)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.11.0)
|
51
|
+
rspec-mocks (3.11.1)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.11.0)
|
54
|
+
rspec-support (3.11.0)
|
55
|
+
rubocop (1.31.0)
|
56
|
+
parallel (~> 1.10)
|
57
|
+
parser (>= 3.1.0.0)
|
58
|
+
rainbow (>= 2.2.2, < 4.0)
|
59
|
+
regexp_parser (>= 1.8, < 3.0)
|
60
|
+
rexml (>= 3.2.5, < 4.0)
|
61
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
62
|
+
ruby-progressbar (~> 1.7)
|
63
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
64
|
+
rubocop-ast (1.18.0)
|
65
|
+
parser (>= 3.1.1.0)
|
66
|
+
ruby-progressbar (1.11.0)
|
67
|
+
unf (0.1.4)
|
68
|
+
unf_ext
|
69
|
+
unf_ext (0.0.8.2)
|
70
|
+
unicode-display_width (2.2.0)
|
71
|
+
webmock (3.0.1)
|
72
|
+
addressable (>= 2.3.6)
|
73
|
+
crack (>= 0.3.2)
|
74
|
+
hashdiff
|
75
|
+
|
76
|
+
PLATFORMS
|
77
|
+
ruby
|
78
|
+
|
79
|
+
DEPENDENCIES
|
80
|
+
rake (~> 13.0)
|
81
|
+
rspec (~> 3.0)
|
82
|
+
rubocop (~> 1.21)
|
83
|
+
seamapi!
|
84
|
+
webmock (~> 3.0.0)
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
2.3.16
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Seam API Ruby Gem
|
2
|
+
|
3
|
+
The Seam Ruby library provides convenient access to the Seam API from applications written
|
4
|
+
in the Ruby language. It includes a pre-defined set of classes for API resources that
|
5
|
+
initialize themselves dynamically from API responses.
|
6
|
+
|
7
|
+
This library also includes:
|
8
|
+
|
9
|
+
- [All Seam Web API Methods](https://docs.seam.co/latest/api-endpoints/overview)
|
10
|
+
- Simplified asynchronous flows, including listening for events or actions to finish
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add the following line to your Gemfile
|
15
|
+
|
16
|
+
gem "seamapi"
|
17
|
+
|
18
|
+
Then execute
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
> To use this sdk, you'll need to generate an API Key on the [Seam Dashboard](https://dashboard.getseam.com)
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
seam = Seam::Client.new(api_key: "MY_API_KEY")
|
28
|
+
|
29
|
+
devices = seam.devices.list
|
30
|
+
|
31
|
+
my_door = devices.first
|
32
|
+
|
33
|
+
seam.locks.unlock(my_door).wait_until_finished
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
To play around with this module interactively in development, first run `bundle`
|
40
|
+
then run `bin/console` to get an interactive console. You can then use a sandbox
|
41
|
+
API key to play with the any new features you're testing!
|
data/Rakefile
ADDED
data/lib/seam/client.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class Client
|
5
|
+
attr_accessor :api_key, :base_uri, :debug
|
6
|
+
|
7
|
+
def initialize(api_key:, base_uri: "https://connect.getseam.com", debug: false)
|
8
|
+
@api_key = api_key
|
9
|
+
@base_uri = base_uri
|
10
|
+
@debug = debug
|
11
|
+
end
|
12
|
+
|
13
|
+
def health
|
14
|
+
request_seam(:get, "/health")
|
15
|
+
end
|
16
|
+
|
17
|
+
def locks
|
18
|
+
@locks ||= Seam::Clients::Locks.new(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def devices
|
22
|
+
@devices ||= Seam::Clients::Devices.new(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
def action_attempts
|
26
|
+
@action_attempts ||= Seam::Clients::ActionAttempts.new(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def access_codes
|
30
|
+
@access_codes ||= Seam::Clients::AccessCodes.new(self)
|
31
|
+
end
|
32
|
+
|
33
|
+
def connect_webviews
|
34
|
+
@connect_webviews ||= Seam::Clients::ConnectWebviews.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
def connected_accounts
|
38
|
+
@connected_accounts ||= Seam::Clients::ConnectedAccounts.new(self)
|
39
|
+
end
|
40
|
+
|
41
|
+
def workspaces
|
42
|
+
@workspaces ||= Seam::Clients::Workspaces.new(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def request_seam_object(method, path, klass, inner_object, config = {})
|
46
|
+
response = request_seam(method, path, config)
|
47
|
+
|
48
|
+
data = response[inner_object]
|
49
|
+
|
50
|
+
klass.load_from_response(data, @client)
|
51
|
+
end
|
52
|
+
|
53
|
+
def request_seam(method, path, config = {})
|
54
|
+
Seam::Request.new(
|
55
|
+
api_key: api_key,
|
56
|
+
base_uri: base_uri,
|
57
|
+
debug: debug
|
58
|
+
).perform(
|
59
|
+
method, path, config
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class AccessCodes < BaseClient
|
6
|
+
def get(access_code_id)
|
7
|
+
request_seam_object(
|
8
|
+
:get,
|
9
|
+
"/access_codes/get",
|
10
|
+
Seam::AccessCode,
|
11
|
+
"access_code",
|
12
|
+
params: { access_code_id: access_code_id }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list(device_id)
|
17
|
+
request_seam_object(
|
18
|
+
:get,
|
19
|
+
"/access_codes/list",
|
20
|
+
Seam::AccessCode,
|
21
|
+
"access_codes",
|
22
|
+
params: { device_id: device_id }
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(device_id: nil, name: nil, code: nil, starts_at: nil, ends_at: nil)
|
27
|
+
action_attempt = request_seam_object(
|
28
|
+
:post,
|
29
|
+
"/access_codes/create",
|
30
|
+
Seam::ActionAttempt,
|
31
|
+
"action_attempt",
|
32
|
+
body: { device_id: device_id, code: code, starts_at: starts_at, ends_at: ends_at, name: name }.compact
|
33
|
+
)
|
34
|
+
action_attempt.wait_until_finished
|
35
|
+
# TODO: check if failed
|
36
|
+
Seam::AccessCode.new(action_attempt.result["access_code"], @client)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(access_code_id)
|
40
|
+
action_attempt = request_seam_object(
|
41
|
+
:post,
|
42
|
+
"/access_codes/delete",
|
43
|
+
Seam::ActionAttempt,
|
44
|
+
"action_attempt",
|
45
|
+
body: { access_code_id: access_code_id }
|
46
|
+
)
|
47
|
+
action_attempt.wait_until_finished
|
48
|
+
action_attempt
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class ActionAttempts < BaseClient
|
6
|
+
def get(action_attempt_id)
|
7
|
+
request_seam_object(
|
8
|
+
:get,
|
9
|
+
"/action_attempts/get",
|
10
|
+
Seam::ActionAttempt,
|
11
|
+
"action_attempt",
|
12
|
+
params: { action_attempt_id: action_attempt_id }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class BaseClient
|
6
|
+
attr_accessor :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def request_seam_object(*attrs)
|
13
|
+
client.request_seam_object(*attrs)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class ConnectWebviews < BaseClient
|
6
|
+
def get(connect_webview_id = nil)
|
7
|
+
request_seam_object(
|
8
|
+
:get,
|
9
|
+
"/connect_webviews/get",
|
10
|
+
Seam::ConnectWebview,
|
11
|
+
"connect_webview",
|
12
|
+
params: { connect_webview_id: connect_webview_id }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list
|
17
|
+
request_seam_object(
|
18
|
+
:get,
|
19
|
+
"/connect_webviews/list",
|
20
|
+
Seam::ConnectWebview,
|
21
|
+
"connect_webviews",
|
22
|
+
params: {}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(accepted_providers: nil)
|
27
|
+
request_seam_object(
|
28
|
+
:post,
|
29
|
+
"/connect_webviews/create",
|
30
|
+
Seam::ConnectWebview,
|
31
|
+
"connect_webview",
|
32
|
+
body: { accepted_providers: accepted_providers }
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class ConnectedAccounts < BaseClient
|
6
|
+
def get(connected_account_id = nil)
|
7
|
+
request_seam_object(
|
8
|
+
:get,
|
9
|
+
"/connected_accounts/get",
|
10
|
+
Seam::ConnectedAccount,
|
11
|
+
"connected_account",
|
12
|
+
params: { connected_account_id: connected_account_id }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class Devices < BaseClient
|
6
|
+
def list(params = {})
|
7
|
+
request_seam_object(
|
8
|
+
:get,
|
9
|
+
"/devices/list",
|
10
|
+
Seam::Device,
|
11
|
+
"devices",
|
12
|
+
params: params
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(device_id)
|
17
|
+
request_seam_object(
|
18
|
+
:get,
|
19
|
+
"/devices/get",
|
20
|
+
Seam::Device,
|
21
|
+
"device",
|
22
|
+
params: { device_id: device_id }
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class Locks < BaseClient
|
6
|
+
# Unlocks a door
|
7
|
+
#
|
8
|
+
# @param [String] device_id
|
9
|
+
# @return [Seam::ActionAttempt]
|
10
|
+
def unlock_door(device_or_id)
|
11
|
+
request_seam_object(
|
12
|
+
:post,
|
13
|
+
"/locks/unlock_door",
|
14
|
+
Seam::ActionAttempt,
|
15
|
+
"action_attempt",
|
16
|
+
body: {
|
17
|
+
device_id: device_id(device_or_id)
|
18
|
+
}
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Locks a door
|
23
|
+
#
|
24
|
+
# @param [String] device_id
|
25
|
+
# @return [Seam::ActionAttempt]
|
26
|
+
def lock_door(device_or_id)
|
27
|
+
request_seam_object(
|
28
|
+
:post,
|
29
|
+
"/locks/lock_door",
|
30
|
+
Seam::ActionAttempt,
|
31
|
+
"action_attempt",
|
32
|
+
body: {
|
33
|
+
device_id: device_id(device_or_id)
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def list(params = {})
|
39
|
+
request_seam_object(
|
40
|
+
:get,
|
41
|
+
"/locks/list",
|
42
|
+
Seam::Device,
|
43
|
+
"devices",
|
44
|
+
params: params
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get(device_or_id)
|
49
|
+
request_seam_object(
|
50
|
+
:get,
|
51
|
+
"/locks/get",
|
52
|
+
Seam::Device,
|
53
|
+
"device",
|
54
|
+
params: {
|
55
|
+
device_id: device_id(device_or_id)
|
56
|
+
}
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
|
62
|
+
def device_id(device_or_id)
|
63
|
+
device_or_id.is_a?(Seam::Device) ? device_or_id.device_id : device_or_id
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
module Clients
|
5
|
+
class Workspaces < BaseClient
|
6
|
+
def get(workspace_id = nil)
|
7
|
+
request_seam_object(
|
8
|
+
:get,
|
9
|
+
"/workspaces/get",
|
10
|
+
Seam::Workspace,
|
11
|
+
"workspace",
|
12
|
+
params: { workspace_id: workspace_id }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list
|
17
|
+
request_seam_object(
|
18
|
+
:get,
|
19
|
+
"/workspaces/list",
|
20
|
+
Seam::Workspace,
|
21
|
+
"workspaces",
|
22
|
+
params: {}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset_sandbox
|
27
|
+
Seam::Request.new(
|
28
|
+
@client.api_key,
|
29
|
+
@client.base_uri
|
30
|
+
).perform(
|
31
|
+
:post, "/workspaces/reset_sandbox", {}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/seam/logger.rb
ADDED
data/lib/seam/request.rb
ADDED
@@ -0,0 +1,68 @@
|
|
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
|
+
def initialize(message, status, response)
|
11
|
+
super(message)
|
12
|
+
@status = status
|
13
|
+
@response = response
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(api_key:, base_uri:, debug: false)
|
18
|
+
@api_key = api_key
|
19
|
+
@base_uri = base_uri
|
20
|
+
@debug = debug
|
21
|
+
end
|
22
|
+
|
23
|
+
def perform(method, uri, config = {})
|
24
|
+
Logger.info("Request: #{method} #{uri} #{config}") if debug
|
25
|
+
|
26
|
+
config[:body] = config[:body].to_json if config[:body]
|
27
|
+
|
28
|
+
response = HTTP.request(
|
29
|
+
method,
|
30
|
+
build_url(uri),
|
31
|
+
{ headers: headers }.merge(config)
|
32
|
+
)
|
33
|
+
|
34
|
+
return response.parse if response.status.success?
|
35
|
+
|
36
|
+
handle_error_response(response, method, uri)
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def handle_error_response(response, method, uri)
|
42
|
+
msg = "Api Error #{response.status.code} #{method} #{uri}"
|
43
|
+
code = response.status.code
|
44
|
+
|
45
|
+
if code == 400 && (err = response.parse["error"])
|
46
|
+
msg = "Api Error #{err["type"]}\nrequest_id: #{err["request_id"]}\n#{err["message"]}"
|
47
|
+
end
|
48
|
+
|
49
|
+
raise Error.new(msg, code, response)
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_url(uri)
|
53
|
+
"#{base_uri}#{uri}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def headers
|
57
|
+
{
|
58
|
+
"User-Agent" => user_agent,
|
59
|
+
"Content-Type" => "application/json",
|
60
|
+
"Authorization" => "Bearer #{api_key}"
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def user_agent
|
65
|
+
"seam-ruby/#{Seam::VERSION}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ActionAttempt < BaseResource
|
5
|
+
attr_accessor :action_attempt_id, :action_type, :status, :result
|
6
|
+
|
7
|
+
def wait_until_finished
|
8
|
+
while @status == "pending"
|
9
|
+
res = Seam::Request.new(@client.api_key, @client.base_uri).perform(
|
10
|
+
:get,
|
11
|
+
"/action_attempts/get",
|
12
|
+
params: { action_attempt_id: @action_attempt_id }
|
13
|
+
)
|
14
|
+
update_from_response(res["action_attempt"])
|
15
|
+
sleep(0.2)
|
16
|
+
end
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class BaseResource
|
5
|
+
attr_accessor :data
|
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
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seam
|
4
|
+
class ConnectWebview < BaseResource
|
5
|
+
attr_accessor :connect_webview_id, :custom_redirect_url, :url, :workspace_id, :device_selection_mode,
|
6
|
+
:accepted_providers, :accepted_devices, :any_provider_allowed, :any_device_allowed, :created_at,
|
7
|
+
:login_successful, :status
|
8
|
+
end
|
9
|
+
end
|
data/lib/seam/version.rb
ADDED
data/lib/seam.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "seam/version"
|
4
|
+
require_relative "seam/request"
|
5
|
+
require_relative "seam/logger"
|
6
|
+
require_relative "seam/client"
|
7
|
+
require_relative "seam/clients/base_client"
|
8
|
+
require_relative "seam/clients/devices"
|
9
|
+
require_relative "seam/clients/locks"
|
10
|
+
require_relative "seam/clients/workspaces"
|
11
|
+
require_relative "seam/clients/connect_webviews"
|
12
|
+
require_relative "seam/clients/connected_accounts"
|
13
|
+
require_relative "seam/clients/access_codes"
|
14
|
+
require_relative "seam/clients/action_attempts"
|
15
|
+
require_relative "seam/resources/base_resource"
|
16
|
+
require_relative "seam/resources/device"
|
17
|
+
require_relative "seam/resources/access_code"
|
18
|
+
require_relative "seam/resources/action_attempt"
|
19
|
+
require_relative "seam/resources/connect_webview"
|
20
|
+
require_relative "seam/resources/connected_account"
|
21
|
+
require_relative "seam/resources/workspace"
|
22
|
+
|
23
|
+
module Seam
|
24
|
+
end
|
data/sig/seamapi.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seamapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Abimael Martell
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: webmock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
description: seamapi is a Ruby gem that provides a simple interface to Seam Connect's
|
42
|
+
API.
|
43
|
+
email:
|
44
|
+
- abi@getseam.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".rspec"
|
50
|
+
- ".rubocop.yml"
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/seam.rb
|
56
|
+
- lib/seam/client.rb
|
57
|
+
- lib/seam/clients/access_codes.rb
|
58
|
+
- lib/seam/clients/action_attempts.rb
|
59
|
+
- lib/seam/clients/base_client.rb
|
60
|
+
- lib/seam/clients/connect_webviews.rb
|
61
|
+
- lib/seam/clients/connected_accounts.rb
|
62
|
+
- lib/seam/clients/devices.rb
|
63
|
+
- lib/seam/clients/locks.rb
|
64
|
+
- lib/seam/clients/workspaces.rb
|
65
|
+
- lib/seam/logger.rb
|
66
|
+
- lib/seam/request.rb
|
67
|
+
- lib/seam/resources/access_code.rb
|
68
|
+
- lib/seam/resources/action_attempt.rb
|
69
|
+
- lib/seam/resources/base_resource.rb
|
70
|
+
- lib/seam/resources/connect_webview.rb
|
71
|
+
- lib/seam/resources/connected_account.rb
|
72
|
+
- lib/seam/resources/device.rb
|
73
|
+
- lib/seam/resources/workspace.rb
|
74
|
+
- lib/seam/version.rb
|
75
|
+
- sig/seamapi.rbs
|
76
|
+
homepage: https://github.com/seamapi/ruby
|
77
|
+
licenses: []
|
78
|
+
metadata:
|
79
|
+
homepage_uri: https://github.com/seamapi/ruby
|
80
|
+
source_code_uri: https://github.com/seamapi/ruby
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.6.0
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Seam API Ruby Library
|
100
|
+
test_files: []
|