Class: Agent
- Inherits:
-
Object
- Object
- Agent
- Defined in:
- lib/lazerpay/agent.rb
Class Method Summary collapse
Class Method Details
.get(endpoint, payload) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lazerpay/agent.rb', line 18 def self.get endpoint, payload sk = payload[:secret_key]; pk = payload[:public_key]; rp = payload[:route_parameter]; qp = payload[:query_parameter]; url = rp.nil? ? "#{API::BASE_URL}#{endpoint}" : "#{API::BASE_URL}#{endpoint}/#{rp}" url = qp.nil? ? "#{API::BASE_URL}#{endpoint}" : "#{API::BASE_URL}#{endpoint}?#{qp}" if rp.nil? puts url response = HTTParty.get(url, :headers => { "Authorization"=> "Bearer #{sk}", "X-api-key" => pk, "content-type" => "application/json"}) return response end |
.post(endpoint, payload) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/lazerpay/agent.rb', line 5 def self.post endpoint, payload sk = payload[:secret_key]; pk = payload[:public_key]; data = payload[:data]; response = HTTParty.post("#{API::BASE_URL}#{endpoint}", :body => data.to_json, :headers => { "Authorization"=> "Bearer #{sk}", "X-api-key" => pk, "content-type" => "application/json"}) return response end |