Class: TuffnellsApi::Base

Inherits:
Object
  • Object
show all
Includes:
HappyMapper
Defined in:
lib/tuffnells_api/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(consignment_no) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tuffnells_api/base.rb', line 12

def initialize consignment_no
  @consignment_no = consignment_no
  @account_code = TuffnellsApi.configuration.
  read_timeout = TuffnellsApi.configuration.read_timeout || 5

  proxy = TuffnellsApi.configuration.proxy

  request = Nokogiri::XML(open(base_uri,
    proxy_http_basic_authentication: proxy,
    read_timeout: read_timeout
  ))

  @response = TuffnellsApi::TrackingRecord.parse(request, single: true)
end

Instance Attribute Details

#account_codeObject (readonly)

Returns the value of attribute account_code.



10
11
12
# File 'lib/tuffnells_api/base.rb', line 10

def 
  @account_code
end

Instance Method Details

#delivery_statusObject



35
36
37
# File 'lib/tuffnells_api/base.rb', line 35

def delivery_status
  @response.movement_information.movements.last.description
end

#pod_imageObject



43
44
45
# File 'lib/tuffnells_api/base.rb', line 43

def pod_image
  @response.image_information.images.last.uri
end

#postcodeObject



27
28
29
# File 'lib/tuffnells_api/base.rb', line 27

def postcode
  @response.delivery_address.postcode
end

#signed_byObject



39
40
41
# File 'lib/tuffnells_api/base.rb', line 39

def signed_by
  @response.timed_information.deliveries.last.signature
end

#total_piecesObject



31
32
33
# File 'lib/tuffnells_api/base.rb', line 31

def total_pieces
  @response.consignment_information.pieces
end