Class: PostCL::API::Response
- Inherits:
-
Object
- Object
- PostCL::API::Response
- Defined in:
- lib/postcl/api.rb
Instance Method Summary collapse
- #delivered? ⇒ Boolean
- #delivery_date ⇒ Object
- #info ⇒ Object
-
#initialize(stat_dict) ⇒ Response
constructor
A new instance of Response.
- #location(mode) ⇒ Object
- #name(mode) ⇒ Object
- #stat_dict ⇒ Object
- #stat_index ⇒ Object
- #stat_msg ⇒ Object
Constructor Details
#initialize(stat_dict) ⇒ Response
Returns a new instance of Response.
18 19 20 21 |
# File 'lib/postcl/api.rb', line 18 def initialize(stat_dict) @stat_dict = stat_dict @info = stat_dict[:shipments][stat_dict[:barcode].to_sym] end |
Instance Method Details
#delivered? ⇒ Boolean
61 62 63 |
# File 'lib/postcl/api.rb', line 61 def delivered? @info[:delivery][:isDelivered] end |
#delivery_date ⇒ Object
65 66 67 68 |
# File 'lib/postcl/api.rb', line 65 def delivery_date t = Time.parse(@info[:delivery][:deliveryDate]) t.strftime("%A %d %B, om %k:%M") end |
#info ⇒ Object
39 40 41 |
# File 'lib/postcl/api.rb', line 39 def info @info end |
#location(mode) ⇒ Object
43 44 45 46 |
# File 'lib/postcl/api.rb', line 43 def location(mode) nil unless mode == :sender || mode == :receiver format_location(@info[mode]) end |
#name(mode) ⇒ Object
48 49 50 51 |
# File 'lib/postcl/api.rb', line 48 def name(mode) nil unless mode == :sender || mode == :receiver format_name(@info[mode]) end |
#stat_dict ⇒ Object
35 36 37 |
# File 'lib/postcl/api.rb', line 35 def stat_dict @stat_dict end |
#stat_index ⇒ Object
53 54 55 |
# File 'lib/postcl/api.rb', line 53 def stat_index @info[:delivery][:phase][:index] end |
#stat_msg ⇒ Object
57 58 59 |
# File 'lib/postcl/api.rb', line 57 def stat_msg @info[:delivery][:phase][:message] end |