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
12
13
# 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 }
  @method   = options.fetch(:method)    { :get }
  @payload  = options.fetch(:payload)   { nil }
  @request  = build_request
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/promise_pay/request.rb', line 15

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

  response
end