Class: TuffnellsApi::Base
- Inherits:
-
Object
- Object
- TuffnellsApi::Base
- Includes:
- HappyMapper
- Defined in:
- lib/tuffnells_api/base.rb
Instance Attribute Summary collapse
-
#account_code ⇒ Object
readonly
Returns the value of attribute account_code.
Instance Method Summary collapse
- #delivery_status ⇒ Object
-
#initialize(consignment_no) ⇒ Base
constructor
A new instance of Base.
- #pod_image ⇒ Object
- #postcode ⇒ Object
- #signed_by ⇒ Object
- #total_pieces ⇒ Object
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.account_code 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_code ⇒ Object (readonly)
Returns the value of attribute account_code.
10 11 12 |
# File 'lib/tuffnells_api/base.rb', line 10 def account_code @account_code end |
Instance Method Details
#delivery_status ⇒ Object
35 36 37 |
# File 'lib/tuffnells_api/base.rb', line 35 def delivery_status @response.movement_information.movements.last.description end |
#pod_image ⇒ Object
43 44 45 |
# File 'lib/tuffnells_api/base.rb', line 43 def pod_image @response.image_information.images.last.uri end |
#postcode ⇒ Object
27 28 29 |
# File 'lib/tuffnells_api/base.rb', line 27 def postcode @response.delivery_address.postcode end |
#signed_by ⇒ Object
39 40 41 |
# File 'lib/tuffnells_api/base.rb', line 39 def signed_by @response.timed_information.deliveries.last.signature end |
#total_pieces ⇒ Object
31 32 33 |
# File 'lib/tuffnells_api/base.rb', line 31 def total_pieces @response.consignment_information.pieces end |