Class: Keypic::Client
- Inherits:
-
Object
- Object
- Keypic::Client
- Defined in:
- lib/keypic/client.rb
Constant Summary collapse
- @@methods =
{ :new_token => "RequestNewToken", :validate => "RequestValidation", :spam => "ReportSpam", :check_form => "checkFormID" }.freeze
- @@types =
{ :csv => 1, :json => 2, :php => 3, :xml => 4 }.freeze
Instance Attribute Summary collapse
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(method_name, options = {}) ⇒ Client
constructor
A new instance of Client.
- #invoke(options = {}) ⇒ Object
- #method ⇒ Object
- #request ⇒ Object
Constructor Details
#initialize(method_name, options = {}) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 30 |
# File 'lib/keypic/client.rb', line 22 def initialize(method_name, = {}) @method_name = method_name.to_sym @options = { "FormID" => Keypic.configuration.form_id, "ResponseType" => format, "RequestType" => method }.merge() end |
Instance Attribute Details
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
6 7 8 |
# File 'lib/keypic/client.rb', line 6 def last_response @last_response end |
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
6 7 8 |
# File 'lib/keypic/client.rb', line 6 def parsed_response @parsed_response end |
Instance Method Details
#format ⇒ Object
36 37 38 |
# File 'lib/keypic/client.rb', line 36 def format @format ||= @@types[Keypic.configuration.format.to_sym] end |
#invoke(options = {}) ⇒ Object
40 41 42 43 |
# File 'lib/keypic/client.rb', line 40 def invoke( = {}) request.body = @options.merge() parse_response(HTTPI.post(request)) end |
#method ⇒ Object
32 33 34 |
# File 'lib/keypic/client.rb', line 32 def method @method ||= @@methods[@method_name] end |
#request ⇒ Object
45 46 47 |
# File 'lib/keypic/client.rb', line 45 def request @request ||= ::HTTPI::Request.new(:url => Keypic.configuration.endpoint) end |