Module: ZeusSdk::V1::ServiceBase
- Included in:
- Assets, Auth, Content, Multiplayer, Secrets
- Defined in:
- lib/zeus_sdk/v1/service_base.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#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
- #update_project_environment(id, project_environment) ⇒ Object
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
12 13 14 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 12 def env @env end |
#environment_id ⇒ Object
Returns the value of attribute environment_id.
12 13 14 |
# File 'lib/zeus_sdk/v1/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_sdk/v1/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_sdk/v1/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_sdk/v1/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_sdk/v1/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_sdk/v1/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_sdk/v1/service_base.rb', line 6 def self.included(klass) klass.format :json klass.follow_redirects true klass.base_uri ZeusSdk::IS_PRODUCTION ? "https://#{klass::SUBDOMAIN}.zeusdev.io" : "http://localhost:#{klass::LOCAL_PORT}" end |
Instance Method Details
#create_project_environment(project_environment) ⇒ Object
57 58 59 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 57 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
65 66 67 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 65 def destroy_project_environment(id) self.class.delete("/api/v1/project_environments/#{id}", body: {}, headers: self.get_headers) end |
#get_headers ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 33 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
53 54 55 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 53 def get_project_environment(id) self.class.get("/api/v1/project_environments/#{id}", headers: self.get_headers) end |
#get_project_environments(ids) ⇒ Object
49 50 51 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 49 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 26 27 28 29 30 31 |
# File 'lib/zeus_sdk/v1/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 if params[:env] == "dev" || params[:env] == "development" self.class.base_uri "http://localhost:#{self.class::LOCAL_PORT}" else self.class.base_uri "https://#{self.class::SUBDOMAIN}.zeusdev.io" 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 |
#update_project_environment(id, project_environment) ⇒ Object
61 62 63 |
# File 'lib/zeus_sdk/v1/service_base.rb', line 61 def update_project_environment(id, project_environment) self.class.put("/api/v1/project_environments/#{id}", body: {project_environment: project_environment}.to_json, headers: self.get_headers) end |