Class: Powercash21::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/powercash21/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret_key: nil) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/powercash21/client.rb', line 6

def initialize(secret_key: nil)
  @secret_key = secret_key || Powercash21.secret_key
end

Instance Attribute Details

#secret_keyObject

Returns the value of attribute secret_key.



4
5
6
# File 'lib/powercash21/client.rb', line 4

def secret_key
  @secret_key
end

Instance Method Details

#connectionObject



10
11
12
13
14
15
16
17
# File 'lib/powercash21/client.rb', line 10

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

#get(url, data = {}) ⇒ Object



23
24
25
# File 'lib/powercash21/client.rb', line 23

def get(url, data = {})
  connection.get(url, data)
end

#post(url, data = {}) ⇒ Object



19
20
21
# File 'lib/powercash21/client.rb', line 19

def post(url, data = {})
  connection.post(url, data)
end