seamapi 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -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/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 +28 -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
- data/seamapi.gemspec +30 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb9b5fc62548919c49b3e041cd434e724c29174a1daa15ad736185f7eb689a2c
|
4
|
+
data.tar.gz: 3a9177165da484078b1a14f54afc3846da4757809527c188b3453c936eb40d41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4f042c9d1f59f9eed7df5d769f693776f0627f85172515cc59bace00e6b0cbb4253767b6da114221fd66e92c847ab38de511ae4b2d3c5f3364a2d0cd325b729
|
7
|
+
data.tar.gz: 18791847ad1ac03910091bdf4a4525b9ac9cd86515bf0b169ad0d9c41e7d01beca978efe9bf642d5bd3545c9c90cf0e86fd2cfc5d2a042e687a48cd29babe855
|
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
|
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
|
@@ -27,5 +27,32 @@ module Seam
|
|
27
27
|
new(data, client)
|
28
28
|
end
|
29
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
|
30
57
|
end
|
31
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
|
data/seamapi.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/seam/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "seamapi"
|
7
|
+
spec.version = Seam::VERSION
|
8
|
+
spec.authors = ["Abimael Martell"]
|
9
|
+
spec.email = ["abi@getseam.com"]
|
10
|
+
|
11
|
+
spec.summary = "Seam API Ruby Library"
|
12
|
+
spec.description = "seamapi is a Ruby gem that provides a simple interface to Seam Connect's API."
|
13
|
+
spec.homepage = "https://github.com/seamapi/ruby"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/seamapi/ruby"
|
18
|
+
|
19
|
+
spec.files = Dir.chdir(__dir__) do
|
20
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
22
|
+
end
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_dependency "http", "~> 5.0.0"
|
29
|
+
spec.add_development_dependency "webmock", "~> 3.0.0"
|
30
|
+
end
|
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.4
|
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-07-
|
11
|
+
date: 2022-07-26 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,8 @@ 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
|
+
- seamapi.gemspec
|
75
76
|
- sig/seamapi.rbs
|
76
77
|
homepage: https://github.com/seamapi/ruby
|
77
78
|
licenses: []
|