class Keypic::Client
Attributes
last_response[R]
parsed_response[R]
Public Class Methods
new(method_name, options = {})
click to toggle source
# File lib/keypic/client.rb, line 22 def initialize(method_name, options = {}) @method_name = method_name.to_sym @options = { "FormID" => Keypic.configuration.form_id, "ResponseType" => format, "RequestType" => method }.merge(options) end
Public Instance Methods
format()
click to toggle source
# File lib/keypic/client.rb, line 36 def format @format ||= @@types[Keypic.configuration.format.to_sym] end
invoke(options = {})
click to toggle source
# File lib/keypic/client.rb, line 40 def invoke(options = {}) request.body = @options.merge(options) parse_response(HTTPI.post(request)) end
method()
click to toggle source
# File lib/keypic/client.rb, line 32 def method @method ||= @@methods[@method_name] end
request()
click to toggle source
# File lib/keypic/client.rb, line 45 def request @request ||= ::HTTPI::Request.new(:url => Keypic.configuration.endpoint) end
Protected Instance Methods
parse_response(response)
click to toggle source
# File lib/keypic/client.rb, line 51 def parse_response(response) @last_response = response if response.error? @parsed_response = nil else @parsed_response = ::MultiJson.load(response.body) end @parsed_response end