module SisRuby::GetHelper
Public Instance Methods
create_headers(specify_content_type, auth_token = nil)
click to toggle source
Creates the header for a request.
# File lib/sis_ruby/get_helper.rb, line 9 def create_headers(specify_content_type, auth_token = nil) headers = { 'Accept' => 'application/json' } if auth_token headers['x-auth-token'] = auth_token end if specify_content_type headers['Content-Type'] = 'application/json' end headers end
typhoeus_get(query)
click to toggle source
Returns a Typhoeus response.
# File lib/sis_ruby/get_helper.rb, line 35 def typhoeus_get(query) # TODO: Simplify w/Typhoeus.get ? Typhoeus::Request.new(url, params: query, headers: get_headers(true) ).run end
validate_response_success(response)
click to toggle source
Raises an error on response failure.
# File lib/sis_ruby/get_helper.rb, line 27 def validate_response_success(response) unless response.code.between?(200, 299) raise BadResponseError.new(response) end end