Module: Postini

Defined in:
lib/postini.rb,
lib/postini/endpoints.rb,
lib/postini/exceptions.rb,
lib/postini/configuration_check.rb,
lib/postini/automated_batch_service.rb,
lib/postini/endpoint_resolver_service.rb

Overview

Configuration

This module just provides access to configuration details used by the rest of the gem.

Current configuration values are:

  • api_key

  • system_number

  • username

  • password

The api_key is your unique API keys obtained from Postini via their Early Access program.

Postini.api_key = "your48characterkey"

The system_number can be any known system number (known to your account). The gem uses the Postini Endpoint Resolver service, but in some cases needs a known system to work from. Refer to the “Locating Your System” section of the Early Access documentation for more information.

Postini.system_number = 8

The username parameter is required if:

  1. Your org is using POP authentication, and thus needs the admin user’s

authentication details, not the end-user’s.

  1. You omit the optional username and password string for the request

Postini.username = '[email protected]'

The password parameter is require if:

  1. Your org is using POP authentication, and thus needs the admin

user’s authentication details, not the end-users’s.

  1. You can omit the optional username and password arguments for a

specific request.

Postini.password = 'secret'

All of the above configurations can either be preloaded from a yaml file or environment variables. Create a yaml file with the following structure:

api_key:
system_number:
username:
password:

And call Postini.configure!(‘/path/to/file.yml’) to load the values. Alternatively you can set the following environment variables and call Postini.configure! without a path.

POSTINI_API_KEY
POSTINI_SYSTEM_NUMBER
POSTINI_USERNAME
POSTINI_PASSWORD

Debugging

Lots to debug when an API is classified as “Early access”, here are different controls for setting the debugging verbosity

  • logger = Ruby-logger compatibe logger

  • debug = true/false - Enable more verbose logging

Specify a ‘Logger’ compatible logging facility in order to use the debug features of the gem. All the other settings increase the verbosity to varying degrees, and allow you to access some soap4r internals as well.

Defined Under Namespace

Modules: ConfigurationCheck Classes: AdminBlockException, AuthenticationException, AutomatedBatchService, BatchException, DuplicateAddress, EndpointResolverService, Endpoints, Error, InternalException, InvalidValueException, MalformedKeyException, MissingElementException, NoSuchKeyException, NotConfigured, RemoteException, StatusException, UnknownDomain, UnknownInternalException

Constant Summary collapse

VERSION =
"0.2.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



89
90
91
# File 'lib/postini.rb', line 89

def api_key
  @api_key
end

.debugObject

Returns the value of attribute debug.



89
90
91
# File 'lib/postini.rb', line 89

def debug
  @debug
end

.loggerObject

Returns the value of attribute logger.



89
90
91
# File 'lib/postini.rb', line 89

def logger
  @logger
end

.passwordObject

Returns the value of attribute password.



89
90
91
# File 'lib/postini.rb', line 89

def password
  @password
end

.system_numberObject

Returns the value of attribute system_number.



89
90
91
# File 'lib/postini.rb', line 89

def system_number
  @system_number
end

.usernameObject

Returns the value of attribute username.



89
90
91
# File 'lib/postini.rb', line 89

def username
  @username
end

Class Method Details

.configure!(yaml = nil) ⇒ Object

Configure the library from yaml configuration file or environment variables



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/postini.rb', line 100

def configure!( yaml = nil )
  data = if yaml
           YAML.load_file( yaml )
         else
           {
             'api_key' => ENV['POSTINI_API_KEY'],
             'system_number' => ENV['POSTINI_SYSTEM_NUMBER'],
             'username' => ENV['POSTINI_USERNAME'],
             'password' => ENV['POSTINI_PASSWORD']
           }
         end

  data.each do |k,v|
    self.send( "#{k}=", v )
  end

  # Cope with trans-continental links
  Handsoap.timeout = 300
end

.configured?Boolean

:nodoc:

Returns:

  • (Boolean)


91
92
93
94
95
96
# File 'lib/postini.rb', line 91

def configured? #:nodoc:
  !self.api_key.nil? &&
  !self.system_number.nil? &&
  !self.username.nil? &&
  !self.password.nil?
end