Module: Flexpay::AmazonFPSRequest
- Included in:
- CobrandingAPI::V2009_01_09::RecipientToken, CobrandingAPI::V2009_01_09::RecurringPipeline, FpsAPI::V2008_09_17::CancelSubscriptionAndRefund, FpsAPI::V2008_09_17::Pay, FpsAPI::V2008_09_17::VerifySignature, SimplePayAPI::V2009_04_17::SubscriptionButton
- Defined in:
- lib/flexpay/request.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(mod) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/flexpay/request.rb', line 10 def self.included(mod) mod.class_eval do @param_list @response_parameters attr_accessor :access_key attr_accessor :secret_key attr_accessor :endpoint def self.required_parameters(*params) @param_list = params params.each do |p| attr_accessor p.to_sym end end def self.response_parameters(params) @response_parameters = {} params.each do |k,v| @response_parameters[k] = v end end def self.get_required_parameters @param_list end def self.get_response_parameters @response_parameters end end end |
Instance Method Details
#generate_url(signed_request = true) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/flexpay/request.rb', line 44 def generate_url(signed_request=true) params = generate_parameters params = sign_parameters(params) if signed_request == true "#{@endpoint}?#{build_query_string(params)}" end |
#go!(signed = true) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/flexpay/request.rb', line 51 def go!(signed=true) url = generate_url(signed) RestClient.log = Logger.new(STDOUT) result = {} begin RestClient.log.info url response = RestClient.get url rescue Exception => e result["Exception"] = e result["Response"] = e.response return result end if response.respond_to?(:body) doc = Hpricot.XML(response.body) else doc = Hpricot.XML(response) end self.class.get_response_parameters.each do |k,v| result[k] = eval("(doc#{v}).innerHTML") end result end |