Class: Surveymonkey::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/surveymonkey/client.rb

Overview

Class encapsulating the HTTParty client used to communicate with the SurveyMonkey API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(baseuri, access_token, api_key) ⇒ Client

Create a new Surveymonkey::Client object. Requires the following parameters:

  • baseuri

  • access_token

  • api_key



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/surveymonkey/client.rb', line 25

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'", __method__, @baseuri))
    self.class.base_uri @baseuri

    http_headers = _http_headers(@access_token)
    self.class.headers http_headers

  rescue StandardError => e
    $log.error(sprintf("%s: %s", __method__, e.message))
    raise e
  end
end

Instance Attribute Details

#access_tokenObject (readonly)

public methods



17
18
19
# File 'lib/surveymonkey/client.rb', line 17

def access_token
  @access_token
end

#api_keyObject (readonly)

public methods



17
18
19
# File 'lib/surveymonkey/client.rb', line 17

def api_key
  @api_key
end

#baseuriObject (readonly)

public methods



17
18
19
# File 'lib/surveymonkey/client.rb', line 17

def baseuri
  @baseuri
end

Instance Method Details

#to_sObject

Stringify a Surveymonkey::Client object



48
49
50
# File 'lib/surveymonkey/client.rb', line 48

def to_s
  self.baseuri
end