Sha256: 8b13c88eca175d7b2f05d72ef2f0b1ead748adde68f1c609d5938dffde9320e1
Contents?: true
Size: 833 Bytes
Versions: 1
Compression:
Stored size: 833 Bytes
Contents
module Powercash21 class Client require 'digest' attr_accessor :secret_key def initialize(secret_key: nil) @secret_key = secret_key || Powercash21.secret_key end def connection @connection ||= begin Faraday.new(:url => 'https://sandbox.powerpay21.com') do |faraday| faraday.request :url_encoded faraday.adapter Faraday.default_adapter end end end def post(url, data = {}) connection.post(url, data) end def get(url, data = {}) connection.get(url, data) end private def format_data(data) sorted_hash = Hash[data.map{|k, v| [k.to_s.downcase, v]}.sort] signature = sorted_hash.map {|kay,val| val}.join("").to_s + @secret_key sorted_hash['signature'] = Digest::SHA1.hexdigest(signature) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
powercash21-0.0.3 | lib/powercash21/client.rb |