Class: Swiftner::API::Space
Overview
Represents a Space service responsible for finding, creating, and deleting spaces. Inherits from the Service class. Provides methods for interacting with spaces.
Instance Attribute Summary
Attributes inherited from Service
#client, #details, #id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Service
build, client, #initialize, map_collection, validate_required
Class Method Details
.create(attributes) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/swiftner/API/space.rb', line 19
def self.create(attributes)
validate_required(attributes, :name, :description)
response = client.post(
"/space/create",
body: attributes.to_json,
headers: { "Content-Type" => "application/json" }
)
build(response.parsed_response)
end
|
.find(space_id) ⇒ Object
14
15
16
17
|
# File 'lib/swiftner/API/space.rb', line 14
def self.find(space_id)
response = client.get("/space/get/#{space_id}")
build(response.parsed_response)
end
|
.find_spaces ⇒ Object
9
10
11
12
|
# File 'lib/swiftner/API/space.rb', line 9
def self.find_spaces
response = client.get("/space/get-spaces")
map_collection(response)
end
|
Instance Method Details
#delete ⇒ Object
45
46
47
|
# File 'lib/swiftner/API/space.rb', line 45
def delete
client.delete("/space/delete/#{id}")
end
|
#update(attributes) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/swiftner/API/space.rb', line 31
def update(attributes)
attributes = attributes.transform_keys(&:to_s)
@details = @details.merge(attributes)
self.class.validate_required(@details, :name, :description)
client.put(
"/space/update/#{id}",
body: @details.to_json,
headers: { "Content-Type" => "application/json" }
)
self
end
|