class Xeroizer::PartnerApplication

Public Class Methods

new(consumer_key, consumer_secret, path_to_private_key, options = {}) click to toggle source

Partner applications allow for public AccessToken's received via the stanard OAuth authentication process to be renewed up until the session's expiry. The default session expiry for Xero is 365 days and the default AccessToken expiry is 30 minutes.

@param [String] consumer_key consumer key/token from application developer (found at api.xero.com for your application). @param [String] consumer_secret consumer secret from application developer (found at api.xero.com for your application). @param [String] path_to_private_key application's private key for message signing (uploaded to api.xero.com) @param [Hash] options other options to pass to the GenericApplication constructor @return [PartnerApplication] instance of PrivateApplication

Calls superclass method Xeroizer::GenericApplication::new
# File lib/xeroizer/partner_application.rb, line 18
def initialize(consumer_key, consumer_secret, path_to_private_key, options = {})
  default_options = {
    :xero_url         => 'https://api.xero.com/api.xro/2.0',
    :site             => 'https://api.xero.com',
    :authorize_url    => 'https://api.xero.com/oauth/Authorize',
    :signature_method => 'RSA-SHA1'
  }
  options = default_options.merge(options).merge(
    :private_key_file => path_to_private_key
  )
  super(consumer_key, consumer_secret, options)

  # Load up an existing token if passed the token/key.
  if options[:access_token] && options[:access_key]
    authorize_from_access(options[:access_token], options[:access_key])
  end

  # Save the session_handle if passed in so we can renew the token.
  if options[:session_handle]
    client.session_handle = options[:session_handle]
  end
end

Private Instance Methods

read_certificate(cert) click to toggle source
# File lib/xeroizer/partner_application.rb, line 43
def read_certificate(cert)
  if File.exists?(cert)
    File.read(cert)
  else
    cert
  end
end