Class: App42::AppTab::App

Inherits:
Object
  • Object
show all
Defined in:
lib/appTab/App.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key, secret_key, base_url) ⇒ App

this is a constructor that takes

Parameters:

  • apiKey
  • secretKey
  • baseURL


55
56
57
58
59
60
61
62
# File 'lib/appTab/App.rb', line 55

def initialize(api_key, secret_key, base_url)
  puts "create app->initialize"
  @api_key = api_key
  @secret_key = secret_key
  @base_url = base_url
  @resource = "app"
  @version = "1.0"
end

Instance Method Details

#create_app(appName, orgName) ⇒ Object

Create an app for a particular organization.

Parameters:

  • appName
    • Name of the app that has to be created

  • orgName
    • Name of the organization whose creating the app



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/appTab/App.rb', line 77

def create_app(appName, orgName)
  puts "createApp Called "
  puts "Base url #{@base_url}"
  util = Util.new
  connection = App42::Connection::RESTConnection.new(@base_url)
  body = {'app42' => {"app"=> {
    "name" => appName,
    "organizationName" => orgName
    }}}.to_json
  puts "Body #{body}"
  query_params = Hash.new
  params = {
    'apiKey'=> @api_key,
    'version' => @version,
    'timeStamp' => util.get_timestamp_utc,
  }
  query_params = params.clone
  params.store("body", body)
  puts params
  puts query_params
  signature = util.sign(@secret_key, params)
  resource_url = "#{@version}/#{@resource}"
  response = connection.post(signature, resource_url, query_params, body)
  return response
end