Class: RubyPayler::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_payler/connection.rb

Overview

Network connection to Payler

Instance Method Summary collapse

Constructor Details

#initialize(url:, key:, debug: false) ⇒ Connection

Returns a new instance of Connection.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ruby_payler/connection.rb', line 7

def initialize(url:, key:, debug: false)
  @driver = Faraday.new(url: url, params: { key: key }) do |f|
    f.request :url_encoded # form-encode POST params

    f.response :mashify          # 3. mashify parsed JSON
    f.response :json             # 2. parse JSON
    f.response :logger if debug  # 1. log requests to STDOUT

    f.adapter Faraday.default_adapter # make requests with Net::HTTP
  end
end

Instance Method Details

#post(endpoint, params) ⇒ Object



19
20
21
# File 'lib/ruby_payler/connection.rb', line 19

def post(endpoint, params)
  @driver.post(endpoint, params)
end