Module: NeetoDeploy::CLI::Session

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.require_app_optionObject



12
13
14
# File 'lib/neeto_deploy/cli/session.rb', line 12

def self.require_app_option
  option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
end

Instance Method Details

#common_bodyObject



32
33
34
35
36
37
# File 'lib/neeto_deploy/cli/session.rb', line 32

def common_body
  session_info = JSON.parse(File.read(CLI_SESSION_STORE_FILE_PATH))
  { session_token: session_info["session_token"] }
rescue
  raise Error.new("Unable to retrieve session info. Try logging in again.")
end

#send_delete_request(url, body) ⇒ Object



28
29
30
# File 'lib/neeto_deploy/cli/session.rb', line 28

def send_delete_request(url, body)
  HTTParty.delete(url, { body: common_body.merge(body), format: :json })
end

#send_get_request(url, body) ⇒ Object



16
17
18
# File 'lib/neeto_deploy/cli/session.rb', line 16

def send_get_request(url, body)
  HTTParty.get(url, { body: common_body.merge(body), format: :json })
end

#send_patch_request(url, body) ⇒ Object



24
25
26
# File 'lib/neeto_deploy/cli/session.rb', line 24

def send_patch_request(url, body)
  HTTParty.patch(url, { body: common_body.merge(body), format: :json })
end

#send_post_request(url, body) ⇒ Object



20
21
22
# File 'lib/neeto_deploy/cli/session.rb', line 20

def send_post_request(url, body)
  HTTParty.post(url, { body: common_body.merge(body), format: :json })
end