Class: Pagseguro::Charge::ChargeResponse
- Inherits:
-
Object
- Object
- Pagseguro::Charge::ChargeResponse
- Defined in:
- lib/pagseguro/charge/charge_response.rb
Constant Summary collapse
- STATUS_AUTHORIZED =
'AUTHORIZED'.freeze
- STATUS_DECLINED =
'DECLINED'.freeze
- STATUS_PAID =
'PAID'.freeze
- STATUS_CANCELED =
'CANCELED'.freeze
- STATUS_PENDING =
'WAITING'.freeze
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#error_messages ⇒ Object
Returns the value of attribute error_messages.
-
#id ⇒ Object
Returns the value of attribute id.
-
#links ⇒ Object
Returns the value of attribute links.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#payment_response ⇒ Object
Returns the value of attribute payment_response.
-
#reference_id ⇒ Object
Returns the value of attribute reference_id.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #authorized? ⇒ Boolean
- #canceled? ⇒ Boolean
- #captured? ⇒ Boolean
- #declined? ⇒ Boolean
-
#initialize ⇒ ChargeResponse
constructor
A new instance of ChargeResponse.
- #paid? ⇒ Boolean
- #to_json(*options) ⇒ Object
Constructor Details
#initialize ⇒ ChargeResponse
Returns a new instance of ChargeResponse.
22 23 |
# File 'lib/pagseguro/charge/charge_response.rb', line 22 def initialize end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def amount @amount end |
#created_at ⇒ Object
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def description @description end |
#error_messages ⇒ Object
Returns the value of attribute error_messages.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def id @id end |
#links ⇒ Object
Returns the value of attribute links.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def links @links end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def payment_method @payment_method end |
#payment_response ⇒ Object
Returns the value of attribute payment_response.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def payment_response @payment_response end |
#reference_id ⇒ Object
Returns the value of attribute reference_id.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def reference_id @reference_id end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/pagseguro/charge/charge_response.rb', line 5 def status @status end |
Class Method Details
.fill_from_json(data) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# 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. = 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 |
Instance Method Details
#as_json(options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pagseguro/charge/charge_response.rb', line 52 def as_json(={}) { 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: , links: @links } end |
#authorized? ⇒ Boolean
70 71 72 |
# File 'lib/pagseguro/charge/charge_response.rb', line 70 def @status == STATUS_AUTHORIZED end |
#canceled? ⇒ Boolean
82 83 84 |
# File 'lib/pagseguro/charge/charge_response.rb', line 82 def canceled? @status == STATUS_CANCELED end |
#captured? ⇒ Boolean
78 79 80 |
# File 'lib/pagseguro/charge/charge_response.rb', line 78 def captured? @status == STATUS_PAID end |
#declined? ⇒ Boolean
74 75 76 |
# File 'lib/pagseguro/charge/charge_response.rb', line 74 def declined? @status == STATUS_DECLINED end |
#paid? ⇒ Boolean
67 68 69 |
# File 'lib/pagseguro/charge/charge_response.rb', line 67 def paid? @status == STATUS_PAID end |
#to_json(*options) ⇒ Object
25 26 27 28 29 |
# File 'lib/pagseguro/charge/charge_response.rb', line 25 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |