Sha256: 819218adb909a859a3d21876d775db705395e9d87b73c270fbec23fc276f747f
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require "httparty" require "json" require "surveymonkey/logging" ## # Class encapsulating the HTTParty client used to communicate with the SurveyMonkey API. class Surveymonkey::Client include HTTParty $log.debug("Defined Surveymonkey::Client.") # constants # public methods attr_reader :baseuri, :api_key, :access_token ## # Create a new Surveymonkey::Client object. Requires the following parameters: # * baseuri # * access_token # * api_key def initialize(baseuri, access_token, api_key) begin @baseuri = baseuri @access_token = access_token @api_key = api_key self.class.logger $log, :debug $log.debug(sprintf("%s: setting base_uri to '%s'\n", __method__, @baseuri)) self.class.base_uri @baseuri $log.debug(sprintf("%s: setting headers'\n", __method__)) http_headers = _http_headers(@access_token) self.class.headers http_headers rescue StandardError => e $log.error(sprintf("%s: %s\n", __method__, e.message)) raise end end # private methods private def _http_headers(token) #:nodoc: begin $log.debug(sprintf("%s: constructing http headers with token '%s'\n", __method__, token)) http_headers = { "Content-Type" => "application/json", "Authorization" => sprintf("bearer %s", token), } $log.debug(sprintf("%s: http headers: '%s'\n", __method__, http_headers)) http_headers rescue StandardError => e $log.error(sprintf("%s: %s\n", __method__, e.message)) raise end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
surveymonkey-0.2.1 | lib/surveymonkey/client.rb |