Class: ZeusClient::V1::Multiplayer

Inherits:
Object
  • Object
show all
Includes:
HTTParty, ServiceBase
Defined in:
lib/zeus/v1/client/multiplayer.rb

Constant Summary collapse

SUBDOMAIN =
"multiplayer"
LOCAL_PORT =
3006

Instance Attribute Summary

Attributes included from ServiceBase

#environment_id, #project_id, #public_key, #scope, #secret_key, #zeus_auth_key

Instance Method Summary collapse

Methods included from ServiceBase

#create_project_environment, #destroy_project_environment, #get_headers, #get_project_environment, #get_project_environments, included, #initialize

Instance Method Details

#create_document(document) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/zeus/v1/client/multiplayer.rb', line 20

def create_document(document)
    resp = self.class.post("/api/v1/documents", body: {document: document}.to_json, headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Document.new(resp["object"])
    else
        return nil
    end
end

#create_node(node) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/zeus/v1/client/multiplayer.rb', line 65

def create_node(node)
    resp = self.class.post("/api/v1/nodes", body: {node: node}.to_json, headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Node.new(resp["object"])
    else
        return nil
    end
end

#destroy_document(id) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/zeus/v1/client/multiplayer.rb', line 47

def destroy_document(id)
    resp = self.class.delete("/api/v1/documents/#{id}", headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Document.new(resp["object"])
    else
        return nil
    end
end

#destroy_node(id) ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/zeus/v1/client/multiplayer.rb', line 92

def destroy_node(id)
    resp = self.class.delete("/api/v1/nodes/#{id}", headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Node.new(resp["object"])
    else
        return nil
    end
end

#get_document(id) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/zeus/v1/client/multiplayer.rb', line 29

def get_document(id)
    resp = self.class.get("/api/v1/documents/#{id}", headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Document.new(resp["object"])
    else
        return nil
    end
end

#get_node(id) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/zeus/v1/client/multiplayer.rb', line 74

def get_node(id)
    resp = self.class.get("/api/v1/nodes/#{id}", headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Node.new(resp["object"])
    else
        return nil
    end
end

#list_documents(query) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/zeus/v1/client/multiplayer.rb', line 11

def list_documents(query)
    resp = self.class.get("/api/v1/documents", query: query, headers: self.get_headers).parsed_response
    if resp["success"] == true
        return resp["objects"].map {|d| Document.new(d) }
    else
        return nil
    end
end

#list_nodes(query) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/zeus/v1/client/multiplayer.rb', line 56

def list_nodes(query)
    resp = self.class.get("/api/v1/nodes", query: query, headers: self.get_headers).parsed_response
    if resp["success"] == true
        return resp["objects"].map {|d| Node.new(d) }
    else
        return nil
    end
end

#update_document(id, document) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/zeus/v1/client/multiplayer.rb', line 38

def update_document(id, document)
    resp = self.class.put("/api/v1/documents/#{id}", body: {document: document}.to_json, headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Document.new(resp["object"])
    else
        return nil
    end
end

#update_node(id, node) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/zeus/v1/client/multiplayer.rb', line 83

def update_node(id, node)
    resp = self.class.put("/api/v1/nodes/#{id}", body: {node: node}.to_json, headers: self.get_headers).parsed_response
    if resp["success"] == true
        return Node.new(resp["object"])
    else
        return nil
    end
end