Permalink
Browse files

Fetch tracking/postage paid

  • Loading branch information...
1 parent 1fd36b6 commit eb7ba09178935f5ff385e30c2147cc13f0a0d36a @robacarp robacarp committed Apr 3, 2013
Showing with 28 additions and 2 deletions.
  1. +28 −2 Shipping/Endicia/Label.php
View
@@ -75,6 +75,8 @@ public function label(){
$this->parse_response();
$this->check_status();
$this->fetchLabels();
+ $this->fetchTracking();
+ $this->fetchPostageAmount();
return $this->response;
}
@@ -114,7 +116,7 @@ public function labelXML(){
return $b->string(true);
}
- private function labelSize(){
+ public function labelSize(){
if ($this->to->isDomestic())
return '4x6';
elseif ( count($this->items) <= 5 )
@@ -123,7 +125,7 @@ private function labelSize(){
return '';
}
- private function imageFormat(){
+ public function imageFormat(){
$labelSize = $this->labelSize();
return $labelSize == '4x6' || $labelSize == '4x6c' ? 'ZPLII' : 'PDF' ;
}
@@ -289,7 +291,31 @@ public function fetchLabels(){
$this->label = base64_decode( $data );
+ }
+
+ public function fetchTracking(){
+ if ($this->response === null || $this->sxml === null)
+ throw new \LogicException('fetchTracking requires a parsed and valid label response before quotes can be assembled');
+
+ if ( isset($this->sxml->TrackingNumber) ) {
+ $this->tracking_number = $this->sxml->TrackingNumber;
+ } else {
+ $this->tracking_number = null;
+ }
+
+ return $this->tracking_number;
+ }
+
+ public function fetchPostageAmount(){
+ if ($this->response === null || $this->sxml === null)
+ throw new \LogicException('fetchPostageAmount requires a parsed and valid label response before quotes can be assembled');
+
+ if ( isset($this->sxml->FinalPostage) )
+ $this->postage_paid = $this->sxml->FinalPostage;
+ else
+ $this->postage_paid = null;
+ return $this->postage_paid;
}
}

0 comments on commit eb7ba09

Please sign in to comment.