Class: Endicia::LabelResponse
- Inherits:
-
Object
- Object
- Endicia::LabelResponse
- Defined in:
- lib/endicia_ruby/label_response.rb
Instance Attribute Summary collapse
-
#cost_center ⇒ Object
Returns the value of attribute cost_center.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#final_postage ⇒ Object
Returns the value of attribute final_postage.
-
#image ⇒ Object
Returns the value of attribute image.
-
#pic ⇒ Object
Returns the value of attribute pic.
-
#postage_balance ⇒ Object
Returns the value of attribute postage_balance.
-
#postmark_date ⇒ Object
Returns the value of attribute postmark_date.
-
#reference_id ⇒ Object
Returns the value of attribute reference_id.
-
#reference_id2 ⇒ Object
Returns the value of attribute reference_id2.
-
#reference_id3 ⇒ Object
Returns the value of attribute reference_id3.
-
#reference_id4 ⇒ Object
Returns the value of attribute reference_id4.
-
#request_body ⇒ Object
Returns the value of attribute request_body.
-
#request_url ⇒ Object
Returns the value of attribute request_url.
-
#requester_id ⇒ Object
Returns the value of attribute requester_id.
-
#response_body ⇒ Object
Returns the value of attribute response_body.
-
#status ⇒ Object
Returns the value of attribute status.
-
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
-
#transaction_date_time ⇒ Object
Returns the value of attribute transaction_date_time.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
Instance Method Summary collapse
-
#critical_error? ⇒ Boolean
True if this is an error and it’s a “critical” one, meaning the ability to generate further labels could be impeded by the information received back.
-
#initialize(result) ⇒ LabelResponse
constructor
A new instance of LabelResponse.
-
#label_generated? ⇒ Boolean
True if this result represents a successful label response.
Constructor Details
#initialize(result) ⇒ LabelResponse
Returns a new instance of LabelResponse.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/endicia_ruby/label_response.rb', line 24 def initialize(result) self.response_body = filter_response_body(result.body.dup) data = result["LabelRequestResponse"] || {} data.each do |k, v| if k == 'Base64LabelImage' k = "image" elsif k == 'Label' # when customs form is included in xml, Endicia returns the image in a different format k = "image" v = v["Image"]["__content__"] end setter = :"#{k.tableize.singularize}=" send(setter, v) if !k['xmlns'] && respond_to?(setter) end end |
Instance Attribute Details
#cost_center ⇒ Object
Returns the value of attribute cost_center.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def cost_center @cost_center end |
#error_message ⇒ Object
Returns the value of attribute error_message.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def @error_message end |
#final_postage ⇒ Object
Returns the value of attribute final_postage.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def final_postage @final_postage end |
#image ⇒ Object
Returns the value of attribute image.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def image @image end |
#pic ⇒ Object
Returns the value of attribute pic.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def pic @pic end |
#postage_balance ⇒ Object
Returns the value of attribute postage_balance.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def postage_balance @postage_balance end |
#postmark_date ⇒ Object
Returns the value of attribute postmark_date.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def postmark_date @postmark_date end |
#reference_id ⇒ Object
Returns the value of attribute reference_id.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def reference_id @reference_id end |
#reference_id2 ⇒ Object
Returns the value of attribute reference_id2.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def reference_id2 @reference_id2 end |
#reference_id3 ⇒ Object
Returns the value of attribute reference_id3.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def reference_id3 @reference_id3 end |
#reference_id4 ⇒ Object
Returns the value of attribute reference_id4.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def reference_id4 @reference_id4 end |
#request_body ⇒ Object
Returns the value of attribute request_body.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def request_body @request_body end |
#request_url ⇒ Object
Returns the value of attribute request_url.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def request_url @request_url end |
#requester_id ⇒ Object
Returns the value of attribute requester_id.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def requester_id @requester_id end |
#response_body ⇒ Object
Returns the value of attribute response_body.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def response_body @response_body end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def status @status end |
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def tracking_number @tracking_number end |
#transaction_date_time ⇒ Object
Returns the value of attribute transaction_date_time.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def transaction_date_time @transaction_date_time end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
5 6 7 |
# File 'lib/endicia_ruby/label_response.rb', line 5 def transaction_id @transaction_id end |
Instance Method Details
#critical_error? ⇒ Boolean
True if this is an error and it’s a “critical” one, meaning the ability to generate further labels could be impeded by the information received back
47 48 49 |
# File 'lib/endicia_ruby/label_response.rb', line 47 def critical_error? CRITICAL_ERROR_CODES.include?(status.to_i) end |
#label_generated? ⇒ Boolean
True if this result represents a successful label response
41 42 43 |
# File 'lib/endicia_ruby/label_response.rb', line 41 def label_generated? status && status.to_i == 0 end |