Module: ZeusClient::V1::ServiceBase
- Included in:
- Assets, Auth, Content, Multiplayer, Secrets
- Defined in:
- lib/zeus/v1/client/service_base.rb
Instance Attribute Summary collapse
-
#environment_id ⇒ Object
Returns the value of attribute environment_id.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#zeus_auth_key ⇒ Object
Returns the value of attribute zeus_auth_key.
Class Method Summary collapse
Instance Method Summary collapse
- #create_project_environment(project_environment) ⇒ Object
- #destroy_project_environment(id) ⇒ Object
- #get_headers ⇒ Object
- #get_project_environment(id) ⇒ Object
- #get_project_environments(ids) ⇒ Object
- #initialize(params) ⇒ Object
Instance Attribute Details
#environment_id ⇒ Object
Returns the value of attribute environment_id.
12 13 14 |
# File 'lib/zeus/v1/client/service_base.rb', line 12 def environment_id @environment_id end |
#project_id ⇒ Object
Returns the value of attribute project_id.
12 13 14 |
# File 'lib/zeus/v1/client/service_base.rb', line 12 def project_id @project_id end |
#public_key ⇒ Object
Returns the value of attribute public_key.
12 13 14 |
# File 'lib/zeus/v1/client/service_base.rb', line 12 def public_key @public_key end |
#scope ⇒ Object
Returns the value of attribute scope.
12 13 14 |
# File 'lib/zeus/v1/client/service_base.rb', line 12 def scope @scope end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
12 13 14 |
# File 'lib/zeus/v1/client/service_base.rb', line 12 def secret_key @secret_key end |
#zeus_auth_key ⇒ Object
Returns the value of attribute zeus_auth_key.
12 13 14 |
# File 'lib/zeus/v1/client/service_base.rb', line 12 def zeus_auth_key @zeus_auth_key end |
Class Method Details
.included(klass) ⇒ Object
6 7 8 9 10 |
# File 'lib/zeus/v1/client/service_base.rb', line 6 def self.included(klass) klass.format :json klass.follow_redirects true klass.base_uri ZeusClient::IS_PRODUCTION ? "https://#{klass::SUBDOMAIN}.zeusdev.io" : "http://localhost:#{klass::LOCAL_PORT}" end |
Instance Method Details
#create_project_environment(project_environment) ⇒ Object
51 52 53 |
# File 'lib/zeus/v1/client/service_base.rb', line 51 def create_project_environment(project_environment) self.class.post("/api/v1/project_environments", body: {project_environment: project_environment}.to_json, headers: self.get_headers) end |
#destroy_project_environment(id) ⇒ Object
55 56 57 |
# File 'lib/zeus/v1/client/service_base.rb', line 55 def destroy_project_environment(id) self.class.delete("/api/v1/project_environments/#{id}", body: {}, headers: self.get_headers) end |
#get_headers ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zeus/v1/client/service_base.rb', line 27 def get_headers headers = { 'Content-Type' => 'application/json' } headers["X-ZEUS-AUTH-KEY"] = self.zeus_auth_key if self.zeus_auth_key.present? headers["X-ZEUS-SERVICE-PUBLIC-KEY"] = self.public_key if self.public_key.present? headers["X-ZEUS-SERVICE-SECRET-KEY"] = self.secret_key if self.secret_key.present? headers["X-ZEUS-SCOPE"] = self.scope if self.scope.present? headers["X-ZEUS-ENVIRONMENT-ID"] = self.environment_id if self.environment_id.present? headers end |
#get_project_environment(id) ⇒ Object
47 48 49 |
# File 'lib/zeus/v1/client/service_base.rb', line 47 def get_project_environment(id) self.class.get("/api/v1/project_environments/#{id}", headers: self.get_headers) end |
#get_project_environments(ids) ⇒ Object
43 44 45 |
# File 'lib/zeus/v1/client/service_base.rb', line 43 def get_project_environments(ids) self.class.get("/api/v1/project_environments", query: {ids: ids}, headers: self.get_headers) end |
#initialize(params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zeus/v1/client/service_base.rb', line 14 def initialize(params) if params[:zeus_auth_key] == nil && params[:public_key] == nil && params[:secret_key] == nil throw "Must initialize with public_key and secret_key" end @zeus_auth_key = params[:zeus_auth_key] @public_key = params[:public_key] @secret_key = params[:secret_key] @project_id = params[:project_id] @scope = params[:scope] @environment_id = params[:environment_id] end |