class Pagseguro::Charge::ChargeResponse
Constants
- STATUS_AUTHORIZED
- STATUS_CANCELED
- STATUS_DECLINED
- STATUS_PAID
- STATUS_PENDING
Attributes
amount[RW]
created_at[RW]
description[RW]
error_messages[RW]
id[RW]
links[RW]
payment_method[RW]
payment_response[RW]
reference_id[RW]
status[RW]
Public Class Methods
fill_from_json(data)
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 31 def self.fill_from_json(data) return if data.nil? charge_response = new charge_response.reference_id = data["reference_id"] charge_response.id = data["id"] charge_response.status = data["status"] charge_response.amount = Amount.fill_from_json(data["amount"]) charge_response.created_at = data["created_at"] charge_response.description = data["description"] charge_response.payment_response = PaymentResponse.fill_from_json(data["payment_response"]) charge_response.payment_method = PaymentMethod.fill_from_json(data["payment_method"]) charge_response.error_messages = data["error_messages"].map{|a| ErrorMessage.fill_from_json(a)} unless data["error_messages"].blank? charge_response.links = data["links"].map{|a| Link.fill_from_json(a)} unless data["links"].blank? charge_response end
new()
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 22 def initialize end
Public Instance Methods
as_json(options={})
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 52 def as_json(options={}) { id: @id, reference_id: @reference_id, status: @status, amount: @amount, created_at: @created_at, description: @description, payment_response: @payment_response, payment_method: @payment_method, error_messages: @error_messages, links: @links } end
canceled?()
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 82 def canceled? @status == STATUS_CANCELED end
captured?()
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 78 def captured? @status == STATUS_PAID end
declined?()
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 74 def declined? @status == STATUS_DECLINED end
paid?()
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 67 def paid? @status == STATUS_PAID end
to_json(*options)
click to toggle source
# File lib/pagseguro/charge/charge_response.rb, line 25 def to_json(*options) hash = as_json(*options) hash.reject! {|k,v| v.nil?} hash.to_json(*options) end