Class: PagSeguro::PaymentRequest::Response

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pagseguro/payment_request/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



9
10
11
# File 'lib/pagseguro/payment_request/response.rb', line 9

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/pagseguro/payment_request/response.rb', line 7

def response
  @response
end

Instance Method Details

#api_versionObject

Default PagSeguro API version for payments



30
31
32
# File 'lib/pagseguro/payment_request/response.rb', line 30

def api_version
  'v2'
end

#codeObject



21
22
23
# File 'lib/pagseguro/payment_request/response.rb', line 21

def code
  @code ||= response.data.css("checkout > code").text if success?
end

#created_atObject



25
26
27
# File 'lib/pagseguro/payment_request/response.rb', line 25

def created_at
  @created_at ||= Time.parse(response.data.css("checkout > date").text) if success?
end

#errorsObject



13
14
15
# File 'lib/pagseguro/payment_request/response.rb', line 13

def errors
  @errors ||= Errors.new(response)
end

#urlObject



17
18
19
# File 'lib/pagseguro/payment_request/response.rb', line 17

def url
  PagSeguro.site_url("#{api_version}/checkout/payment.html?code=#{code}") if code
end