class App42::AppTab::App

Public Class Methods

new(api_key, secret_key, base_url) click to toggle source

this is a constructor that takes

@param apiKey @param secretKey @param baseURL

# 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

Public Instance Methods

create_app(appName, orgName) click to toggle source

Create an app for a particular organization.

@param appName

- Name of the app that has to be created

@param orgName

- Name of the organization whose creating the app

@returns an app created by a particular organization

@throws Exception

# 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