Class: PostCL::API::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/postcl/api.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


61
62
63
# File 'lib/postcl/api.rb', line 61

def delivered?
  @info[:delivery][:isDelivered]
end

#delivery_dateObject



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

#infoObject



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_dictObject



35
36
37
# File 'lib/postcl/api.rb', line 35

def stat_dict
  @stat_dict
end

#stat_indexObject



53
54
55
# File 'lib/postcl/api.rb', line 53

def stat_index
  @info[:delivery][:phase][:index]
end

#stat_msgObject



57
58
59
# File 'lib/postcl/api.rb', line 57

def stat_msg
  @info[:delivery][:phase][:message]
end