-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspaces.rb
More file actions
72 lines (51 loc) · 2.62 KB
/
spaces.rb
File metadata and controls
72 lines (51 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# frozen_string_literal: true
module Seam
module Clients
class Spaces
def initialize(client:, defaults:)
@client = client
@defaults = defaults
end
def add_acs_entrances(acs_entrance_ids:, space_id:)
@client.post("/spaces/add_acs_entrances", {acs_entrance_ids: acs_entrance_ids, space_id: space_id}.compact)
nil
end
def add_devices(device_ids:, space_id:)
@client.post("/spaces/add_devices", {device_ids: device_ids, space_id: space_id}.compact)
nil
end
def create(name:, acs_entrance_ids: nil, customer_key: nil, device_ids: nil, space_key: nil)
res = @client.post("/spaces/create", {name: name, acs_entrance_ids: acs_entrance_ids, customer_key: customer_key, device_ids: device_ids, space_key: space_key}.compact)
Seam::Resources::Space.load_from_response(res.body["space"])
end
def delete(space_id:)
@client.post("/spaces/delete", {space_id: space_id}.compact)
nil
end
def get(space_id: nil, space_key: nil)
res = @client.post("/spaces/get", {space_id: space_id, space_key: space_key}.compact)
Seam::Resources::Space.load_from_response(res.body["space"])
end
def get_related(exclude: nil, include: nil, space_ids: nil, space_keys: nil)
res = @client.post("/spaces/get_related", {exclude: exclude, include: include, space_ids: space_ids, space_keys: space_keys}.compact)
Seam::Resources::Batch.load_from_response(res.body["batch"])
end
def list(customer_key: nil, limit: nil, page_cursor: nil, search: nil, space_key: nil)
res = @client.post("/spaces/list", {customer_key: customer_key, limit: limit, page_cursor: page_cursor, search: search, space_key: space_key}.compact)
Seam::Resources::Space.load_from_response(res.body["spaces"])
end
def remove_acs_entrances(acs_entrance_ids:, space_id:)
@client.post("/spaces/remove_acs_entrances", {acs_entrance_ids: acs_entrance_ids, space_id: space_id}.compact)
nil
end
def remove_devices(device_ids:, space_id:)
@client.post("/spaces/remove_devices", {device_ids: device_ids, space_id: space_id}.compact)
nil
end
def update(acs_entrance_ids: nil, customer_key: nil, device_ids: nil, name: nil, space_id: nil, space_key: nil)
res = @client.post("/spaces/update", {acs_entrance_ids: acs_entrance_ids, customer_key: customer_key, device_ids: device_ids, name: name, space_id: space_id, space_key: space_key}.compact)
Seam::Resources::Space.load_from_response(res.body["space"])
end
end
end
end