Class: Yext::Api::Utils::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/yext/api/utils/configuration.rb

Overview

A configuration class for global configurations for interfacing with the Yext API.

The class is a Singleton class to simplify accessing the configuration.

Documentation for how the various configurations are used within Yext can be found here:

http://developer.yext.com/docs/administrative-api/#section/Policies-and-Conventions

Initialization:

Some values within the

The configurations:

account_id

*required*
default: "me"
The ID of the account which you are interfacing with.

If the default value of "me" is used, the account_id will default to the account which owns the
api_key.

api_key

*required*
The API key for the Yext Application which is being used to submit the request through.

api_version

The version of the Yext API that the request would like to use for any given API call.

If left as nil, the gem will try to use the most up-to-date known version of all APIs whenever
possible, and future updates will adjust the defaults for each call to the most recent known
version of the API.

To keep your application stable, you should set this value to a static known value (such as
the date the project using the Yext API first started development).

The Yext API will accept a default of "20161012" to use the initially released v2 API.

validation_level

The validation level to use for a request.  Yext defaults this to "strict".  You can set this to
"lenient" to allow more lenient error and warning handling on your requests.

Validation should be a value from Yext::Api::Enumerations::Validation

yext_username

The username of a Yext User that the call is being made on the behalf of.  This will affect the
logging of who made a change.

yext_user_id

The id of a Yext User that the call is being made on the behalf of.  This will affect the
logging of who made a change.

sandbox

Boolean that indicates if the gem should use the production or sandbox URL.

default_callback_processor

The default class to be used to process webhook messages that are called.
The code will warn about any missing webhook messages in a default processor.

set_callback_processor(callback_function_name, processor)

The class to be used to process webhook messages for a specific callback.
If the method callback_function_name is not a public instance method for processor, an error
will be raised.

The processor class must be able to be instanciated with the following arguments:
  * meta              - a hash of metadata for the webhook
  * object            - a Spyke::Base object that represents the object that ws updated or changed
                        to cause the hook event.
  * language_profiles - (optional) An array of objects.

The functions that can be called for the webhooks are:
  * add_request_changed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



86
87
88
# File 'lib/yext/api/utils/configuration.rb', line 86

def initialize
  read_from_environment_variables
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



78
79
80
# File 'lib/yext/api/utils/configuration.rb', line 78

def 
  @account_id
end

#api_keyObject

Returns the value of attribute api_key.



78
79
80
# File 'lib/yext/api/utils/configuration.rb', line 78

def api_key
  @api_key
end

#api_versionObject

Returns the value of attribute api_version.



78
79
80
# File 'lib/yext/api/utils/configuration.rb', line 78

def api_version
  @api_version
end

#sandboxObject

Returns the value of attribute sandbox.



78
79
80
# File 'lib/yext/api/utils/configuration.rb', line 78

def sandbox
  @sandbox
end

#validation_levelObject

Returns the value of attribute validation_level.



84
85
86
# File 'lib/yext/api/utils/configuration.rb', line 84

def validation_level
  @validation_level
end

#yext_user_idObject

Returns the value of attribute yext_user_id.



78
79
80
# File 'lib/yext/api/utils/configuration.rb', line 78

def yext_user_id
  @yext_user_id
end

#yext_usernameObject

Returns the value of attribute yext_username.



78
79
80
# File 'lib/yext/api/utils/configuration.rb', line 78

def yext_username
  @yext_username
end

Instance Method Details

#default_callback_processorObject



111
112
113
# File 'lib/yext/api/utils/configuration.rb', line 111

def default_callback_processor
  callback_processors[:default]
end

#default_callback_processor=(value) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/yext/api/utils/configuration.rb', line 103

def default_callback_processor=(value)
  callback_names.each do |callback_name|
    verify_method(value, callback_name)
  end

  callback_processors[:default] = value
end

#get_callback_processor(callback_function_name) ⇒ Object



127
128
129
130
131
# File 'lib/yext/api/utils/configuration.rb', line 127

def get_callback_processor(callback_function_name)
  callback_function_name = callback_function_name.downcase.to_sym

  callback_processors.fetch(callback_function_name, callback_processors[:default])
end

#param_account_idObject



99
100
101
# File 'lib/yext/api/utils/configuration.rb', line 99

def 
   || "me"
end

#set_callback_processor(callback_function_name, processor) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/yext/api/utils/configuration.rb', line 115

def set_callback_processor(callback_function_name, processor)
  callback_function_name = callback_function_name.downcase.to_sym

  validate_arguments(callback_function_name, processor)

  if processor.present?
    callback_processors[callback_function_name.downcase.to_sym] = processor
  else
    callback_processors.delete(callback_function_name.downcase.to_sym)
  end
end