module PureCloud

PureCloud Platform API

With the PureCloud Platform API, you can control all aspects of your PureCloud environment. With the APIs you can access the system configuration, manage conversations and more.

OpenAPI spec version: v2 Contact: DeveloperEvangelists@genesys.com Generated by: github.com/swagger-api/swagger-codegen.git

License: UNLICENSED help.mypurecloud.com/articles/terms-and-conditions/

Terms of Service: help.mypurecloud.com/articles/terms-and-conditions/

PureCloud Platform API

With the PureCloud Platform API, you can control all aspects of your PureCloud environment. With the APIs you can access the system configuration, manage conversations and more.

OpenAPI spec version: v2 Contact: DeveloperEvangelists@genesys.com Generated by: github.com/swagger-api/swagger-codegen.git

License: UNLICENSED help.mypurecloud.com/articles/terms-and-conditions/

Terms of Service: help.mypurecloud.com/articles/terms-and-conditions/

Constants

VERSION

Public Class Methods

authenticate_with_client_credentials(client_id, client_secret, environment = nil) click to toggle source

Authenticates to PureCloud using the client credientals OAuth grant.

@param client_id OAuth client id @param client_secret OAuth client secret @param environment PureCloud environment (mypurecloud.com, mypurecloud.ie, mypurecloud.com.au, etc)

# File lib/purecloudplatformclientv2.rb, line 2239
def authenticate_with_client_credentials(client_id, client_secret, environment = nil)
  environment ||= "mypurecloud.com"
  self.configure.host = 'api.' + environment;

  basic = Base64.strict_encode64("#{client_id}:#{client_secret}")

  tokenData = JSON.parse RestClient.post("https://login.#{environment}/token",
                          {:grant_type => 'client_credentials'},
                          :Authorization => "Basic " + basic,
                          'content-type'=> 'application/x-www-form-urlencoded',
                          :accept => :json)
  self.configure.access_token = tokenData["access_token"]
end
configure() { |default| ... } click to toggle source

Customize default settings for the SDK using block.

PureCloud.configure do |config|
  config.username = "xxx"
  config.password = "xxx"
end

If no block given, return the default Configuration object.

# File lib/purecloudplatformclientv2.rb, line 2219
def configure
  if block_given?
    yield(Configuration.default)
  else
    Configuration.default
  end
end
get_access_token_from_auth_code(auth_code, client_id, client_secret, redirect_uri, environment = nil) click to toggle source

Retrieves an Access token given an authorization code (authorization code grant)

@param auth_code Authorization code from the OAuth redirec @param client_id OAuth client id @param client_secret OAuth client secret @param client_secret OAuth redirect URI @param environment (Optional) PureCloud environment (mypurecloud.com, mypurecloud.ie, mypurecloud.com.au, etc)

# File lib/purecloudplatformclientv2.rb, line 2260
def get_access_token_from_auth_code(auth_code, client_id, client_secret, redirect_uri, environment = nil)
  environment ||= "mypurecloud.com"

  tokenFormData = {
    "grant_type" => "authorization_code",
    "code" => auth_code,
    "redirect_uri" => redirect_uri
  }

  tokenResponse =JSON.parse RestClient.post "https://#{client_id}:#{client_secret}@login.#{environment}/token", tokenFormData

  return tokenResponse['access_token'];
end