Sha256: bad19fdf14ade27ca83cf3ff31588f37dee068870980a993aaa62fd0d97b60d8

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'xively-rb'

module XivelyConnector

  class Connection < Xively::Client
    include XivelyConnector::Logging

    format :json

    # Mix in the ability to log
    include XivelyConnector::Logging

    attr_accessor :config

    def initialize(options)
      @logger = options[:logger] || logger
      #@config = options[:config] || Configuration.new
      @logger.debug "XivelyConnector::Connection initialize"
      super(options[:api_key])
    end


    #Set HTTParty params that we need to set after initialize is called
    #These params come from @options within initialize and include the following:
    #:ssl_ca_file - SSL CA File for SSL connections
    #:format - 'json', 'xml', 'html', etc. || Defaults to 'xml'
    #:format_header - :format Header string || Defaults to 'application/xml'
    #:pem_cert - /path/to/a/pem_formatted_certificate.pem for SSL connections
    #:pem_cert_pass - plaintext password, not recommended!
    def set_httparty_options(options={})
      if options[:ssl_ca_file]
        ssl_ca_file opts[:ssl_ca_file]
        if options[:pem_cert_pass]
          pem File.read(options[:pem_cert]), options[:pem_cert_pass]
        else
          pem File.read(options[:pem_cert])
        end
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xively-rb-connector-0.1.3 lib/xively-rb-connector/connection.rb