class ActBlueReporter::Connect
Constants
- ACTBLUE_URI
- HEADER
Private Instance Methods
check_response(response)
click to toggle source
# File lib/act_blue_reporter/connect.rb, line 35 def check_response(response) # response can be nil if the act blue entity id is blank unless response raise_error("No response. Check the ActBlue entity ID.") end # raise an error if parsed_response is nil unless response.parsed_response raise_error("Did not get any data from ActBlue.") end # raise an error if the success code is false unless response.success? raise_error("HTTP response code: #{response.response.code}") end # raise an error if the response is not a hash unless response.is_a? Hash raise_error("Response is a #{response.class}. Expecting hash") end end
make_request(request_uri:, authentication:)
click to toggle source
# File lib/act_blue_reporter/connect.rb, line 16 def make_request(request_uri:, authentication:) response = request_wrapper(request_uri, authentication) # raise an error if anything is wrong with the response check_response(response) # return the parsed data as a hash. return response.parsed_response end
raise_error(message)
click to toggle source
# File lib/act_blue_reporter/connect.rb, line 58 def raise_error(message) raise ActBlueReporter::Exceptions::ConnectionError.new(msg: message) end
request_wrapper(request_uri, authentication)
click to toggle source
# File lib/act_blue_reporter/connect.rb, line 27 def request_wrapper(request_uri, authentication) Timeout.timeout(5) do HTTParty.get("#{ACTBLUE_URI}#{request_uri}", basic_auth: authentication, headers: HEADER) end end