Class: Oja::Response
- Inherits:
-
Object
- Object
- Oja::Response
- Defined in:
- lib/oja/response.rb
Constant Summary collapse
- STATUS =
{ 0 => :active, 21000 => :bad_json, 21002 => :malformed, 21003 => :authentication_error, 21004 => :authentication_failed, 21005 => :service_unavailable, 21006 => :inactive, 21007 => :sandbox_receipt_in_production, 21008 => :production_receipt_in_sandbox }
- HUMANIZED_STATUS =
{ 0 => 'Active', 21000 => 'Bad JSON', 21002 => 'Malformed', 21003 => 'Authentication Error', 21004 => 'Authentication Failed', 21005 => 'Service Unavailable', 21006 => 'Inactive', 21007 => 'Sandbox Receipt in Production', 21008 => 'Production Receipt in Sandbox' }
Instance Attribute Summary collapse
-
#receipt_data ⇒ Object
readonly
Returns the value of attribute receipt_data.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
Instance Method Summary collapse
- #data=(data) ⇒ Object
- #humanized_status ⇒ Object
-
#initialize(data) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
Constructor Details
#initialize(data) ⇒ Response
Returns a new instance of Response.
29 30 31 |
# File 'lib/oja/response.rb', line 29 def initialize(data) self.data = data end |
Instance Attribute Details
#receipt_data ⇒ Object (readonly)
Returns the value of attribute receipt_data.
27 28 29 |
# File 'lib/oja/response.rb', line 27 def receipt_data @receipt_data end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
27 28 29 |
# File 'lib/oja/response.rb', line 27 def status_code @status_code end |
Class Method Details
.status_code(needle) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/oja/response.rb', line 52 def self.status_code(needle) needle = needle.to_sym STATUS.each do |status_code, status| return status_code if needle == status end; nil end |
Instance Method Details
#data=(data) ⇒ Object
33 34 35 36 |
# File 'lib/oja/response.rb', line 33 def data=(data) @status_code = data['status'].to_i @receipt_data = data['receipt'] end |
#humanized_status ⇒ Object
42 43 44 |
# File 'lib/oja/response.rb', line 42 def humanized_status HUMANIZED_STATUS[status_code] end |
#status ⇒ Object
38 39 40 |
# File 'lib/oja/response.rb', line 38 def status STATUS[status_code] end |