Class: PromisePay::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/promise_pay/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
# File 'lib/promise_pay/request.rb', line 6

def initialize(options = {})
  @path     = options.fetch :path
  @user     = options.fetch :user,          PromisePay.api_user
  @password = options.fetch :password,      PromisePay.api_key
  @request  = build_request
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
# File 'lib/promise_pay/request.rb', line 13

def execute
  begin
    response = request.execute
  rescue RestClient::Unauthorized, RestClient::BadRequest => e
    raise RequestError, e.message
  end

  response
end