seamapi 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +1 -1
- data/lib/seam/client.rb +1 -1
- data/lib/seam/clients/access_codes.rb +21 -1
- data/lib/seam/clients/base_client.rb +4 -0
- data/lib/seam/clients/connected_accounts.rb +18 -2
- data/lib/seam/clients/locks.rb +2 -2
- data/lib/seam/clients/workspaces.rb +5 -6
- data/lib/seam/resources/access_code.rb +3 -1
- data/lib/seam/resources/action_attempt.rb +19 -7
- data/lib/seam/resources/base_resource.rb +19 -1
- data/lib/seam/resources/connect_webview.rb +3 -1
- data/lib/seam/resources/connected_account.rb +3 -1
- data/lib/seam/resources/device.rb +2 -0
- data/lib/seam/version.rb +1 -1
- data/lib/{seam.rb → seamapi.rb} +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2701dd6d8a0491f971b8f0cf731573aae6d646130e9d95d2e1032cf71247e259
|
4
|
+
data.tar.gz: '093249dc1556f023740781aba9689ac65bf278b6eb5228441bc2e6a622cbb8c5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d7de1b232698cad62e72f83de8d5b05224deeadfff5a0e9e0045a2e99e3c3ee19169b042196da729a05acf48ab811cf88db77d68ba485636513410499d56421
|
7
|
+
data.tar.gz: 9ee3ad5a781a7d532eb07c86a25f9e1316c8a11aa5636e565c49dad00b94c809d602c4675376fc22c96f179cd7b96a41076a9377d1f554d6164d2a137dffa262
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/seam/client.rb
CHANGED
@@ -13,7 +13,9 @@ module Seam
|
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
|
-
def list(
|
16
|
+
def list(device_or_id)
|
17
|
+
device_id = device_or_id.is_a?(Seam::Device) ? device_or_id.device_id : device_or_id
|
18
|
+
|
17
19
|
request_seam_object(
|
18
20
|
:get,
|
19
21
|
"/access_codes/list",
|
@@ -47,6 +49,24 @@ module Seam
|
|
47
49
|
action_attempt.wait_until_finished
|
48
50
|
action_attempt
|
49
51
|
end
|
52
|
+
|
53
|
+
def update(access_code_id: nil, name: nil, code: nil, starts_at: nil, ends_at: nil)
|
54
|
+
action_attempt = request_seam_object(
|
55
|
+
:post,
|
56
|
+
"/access_codes/update",
|
57
|
+
Seam::ActionAttempt,
|
58
|
+
"action_attempt",
|
59
|
+
body: {
|
60
|
+
access_code_id: access_code_id,
|
61
|
+
name: name,
|
62
|
+
code: code,
|
63
|
+
starts_at: starts_at,
|
64
|
+
ends_at: ends_at
|
65
|
+
}.compact
|
66
|
+
)
|
67
|
+
action_attempt.wait_until_finished
|
68
|
+
action_attempt
|
69
|
+
end
|
50
70
|
end
|
51
71
|
end
|
52
72
|
end
|
@@ -3,13 +3,29 @@
|
|
3
3
|
module Seam
|
4
4
|
module Clients
|
5
5
|
class ConnectedAccounts < BaseClient
|
6
|
-
def get(
|
6
|
+
def get(connected_account_id_or_params)
|
7
|
+
params = if connected_account_id_or_params.is_a?(String)
|
8
|
+
{ connected_account_id: connected_account_id_or_params }
|
9
|
+
else
|
10
|
+
connected_account_id_or_params
|
11
|
+
end
|
12
|
+
|
7
13
|
request_seam_object(
|
8
14
|
:get,
|
9
15
|
"/connected_accounts/get",
|
10
16
|
Seam::ConnectedAccount,
|
11
17
|
"connected_account",
|
12
|
-
params:
|
18
|
+
params: params
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def list(params = {})
|
23
|
+
request_seam_object(
|
24
|
+
:get,
|
25
|
+
"/connected_accounts/list",
|
26
|
+
Seam::ConnectedAccount,
|
27
|
+
"connected_accounts",
|
28
|
+
params: params
|
13
29
|
)
|
14
30
|
end
|
15
31
|
end
|
data/lib/seam/clients/locks.rb
CHANGED
@@ -40,7 +40,7 @@ module Seam
|
|
40
40
|
:get,
|
41
41
|
"/locks/list",
|
42
42
|
Seam::Device,
|
43
|
-
"
|
43
|
+
"locks",
|
44
44
|
params: params
|
45
45
|
)
|
46
46
|
end
|
@@ -50,7 +50,7 @@ module Seam
|
|
50
50
|
:get,
|
51
51
|
"/locks/get",
|
52
52
|
Seam::Device,
|
53
|
-
"
|
53
|
+
"lock",
|
54
54
|
params: {
|
55
55
|
device_id: device_id(device_or_id)
|
56
56
|
}
|
@@ -23,12 +23,11 @@ module Seam
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
-
def reset_sandbox
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
:post, "/workspaces/reset_sandbox", {}
|
26
|
+
def reset_sandbox(workspace_id)
|
27
|
+
request_seam(
|
28
|
+
:post,
|
29
|
+
"/workspaces/reset_sandbox",
|
30
|
+
params: { workspace_id: workspace_id }
|
32
31
|
)
|
33
32
|
end
|
34
33
|
end
|
@@ -4,17 +4,29 @@ module Seam
|
|
4
4
|
class ActionAttempt < BaseResource
|
5
5
|
attr_accessor :action_attempt_id, :action_type, :status, :result
|
6
6
|
|
7
|
+
SLEEP_TIME = 0.2
|
8
|
+
MAX_ATTEMPTS = 10
|
9
|
+
|
7
10
|
def wait_until_finished
|
8
11
|
while @status == "pending"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
params: { action_attempt_id: @action_attempt_id }
|
13
|
-
)
|
14
|
-
update_from_response(res["action_attempt"])
|
15
|
-
sleep(0.2)
|
12
|
+
update!
|
13
|
+
|
14
|
+
sleep(SLEEP_TIME)
|
16
15
|
end
|
16
|
+
|
17
17
|
self
|
18
18
|
end
|
19
|
+
|
20
|
+
def update!
|
21
|
+
response = @client.request_seam(
|
22
|
+
:get,
|
23
|
+
"/action_attempts/get",
|
24
|
+
params: {
|
25
|
+
action_attempt_id: action_attempt_id
|
26
|
+
}
|
27
|
+
)
|
28
|
+
|
29
|
+
update_from_response(response["action_attempt"])
|
30
|
+
end
|
19
31
|
end
|
20
32
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Seam
|
4
4
|
class BaseResource
|
5
|
-
attr_accessor :data
|
5
|
+
attr_accessor :data, :client
|
6
6
|
|
7
7
|
def initialize(data, client = nil)
|
8
8
|
@data = data
|
@@ -36,5 +36,23 @@ module Seam
|
|
36
36
|
.map { |k| " #{k}=#{send(k).inspect}" }
|
37
37
|
.join("\n") + ">"
|
38
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
|
39
57
|
end
|
40
58
|
end
|
@@ -3,7 +3,9 @@
|
|
3
3
|
module Seam
|
4
4
|
class ConnectWebview < BaseResource
|
5
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,
|
6
|
+
:accepted_providers, :accepted_devices, :any_provider_allowed, :any_device_allowed,
|
7
7
|
:login_successful, :status
|
8
|
+
|
9
|
+
date_accessor :created_at
|
8
10
|
end
|
9
11
|
end
|
data/lib/seam/version.rb
CHANGED
data/lib/{seam.rb → seamapi.rb}
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seamapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abimael Martell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -52,7 +52,6 @@ files:
|
|
52
52
|
- Gemfile.lock
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
|
-
- lib/seam.rb
|
56
55
|
- lib/seam/client.rb
|
57
56
|
- lib/seam/clients/access_codes.rb
|
58
57
|
- lib/seam/clients/action_attempts.rb
|
@@ -72,6 +71,7 @@ files:
|
|
72
71
|
- lib/seam/resources/device.rb
|
73
72
|
- lib/seam/resources/workspace.rb
|
74
73
|
- lib/seam/version.rb
|
74
|
+
- lib/seamapi.rb
|
75
75
|
- seamapi.gemspec
|
76
76
|
- sig/seamapi.rbs
|
77
77
|
homepage: https://github.com/seamapi/ruby
|