Module: Surveygizmo::Default

Defined in:
lib/surveygizmo/default.rb

Constant Summary collapse

ENDPOINT =
'https://restapi.surveygizmo.com/v2/'
USER_AGENT =
"Surveygizmo Ruby Gem #{Surveygizmo::VERSION}"
CONNECTION_OPTIONS =
{
  :headers => { 
    :accept => 'application/json', 
    :user_agent => USER_AGENT },
  :ssl => { :verify => false }
}
MIDDLEWARE =
Faraday::Builder.new(
  &Proc.new do |builder|
    # Convert request params to "www-form-urlencoded"
    builder.use Faraday::Request::UrlEncoded

    # Converts parsed response bodies to a Surveygizmo::Response
    builder.use Surveygizmo::Response::ParseSurveygizmoResponse

    # Raise Errors on Failed Requests from Surveygizmo with Surveygizmo::Error
    builder.use Surveygizmo::Response::RaiseErrorOnFailedRequest, Surveygizmo::Error

    # Parse JSON response bodies using MultiJson
    builder.use Faraday::Response::ParseJson

    # Set Faraday's HTTP adapter
    builder.adapter(:net_http)
  end
)

Class Method Summary collapse

Class Method Details

.connection_optionsObject



57
58
59
# File 'lib/surveygizmo/default.rb', line 57

def connection_options
  CONNECTION_OPTIONS
end

.endpointObject



49
50
51
# File 'lib/surveygizmo/default.rb', line 49

def endpoint
  ENDPOINT
end

.middlewareObject



61
62
63
# File 'lib/surveygizmo/default.rb', line 61

def middleware
  MIDDLEWARE
end

.optionsObject



37
38
39
# File 'lib/surveygizmo/default.rb', line 37

def options
  Hash[Surveygizmo::Configurable.keys.map{|key| [key, send(key)]}]
end

.passwordObject



45
46
47
# File 'lib/surveygizmo/default.rb', line 45

def password
  ENV['SURVEYGIZMO_PASSWORD']
end

.user_agentObject



53
54
55
# File 'lib/surveygizmo/default.rb', line 53

def user_agent
  USER_AGENT
end

.usernameObject



41
42
43
# File 'lib/surveygizmo/default.rb', line 41

def username
  ENV['SURVEYGIZMO_USERNAME']
end