Overview

Namespaces

  • ShippoClient
    • Entity
    • Http
      • Request
        • Addresses
        • Parcels
        • Shipments
        • Transactions
      • Response
        • Exception

Classes

  • ShippoClient\Addresses
  • ShippoClient\Entity\Address
  • ShippoClient\Entity\AddressCollection
  • ShippoClient\Entity\EntityCollection
  • ShippoClient\Entity\Location
  • ShippoClient\Entity\ObjectInformation
  • ShippoClient\Entity\Parcel
  • ShippoClient\Entity\ParcelCollection
  • ShippoClient\Entity\Rate
  • ShippoClient\Entity\RateCollection
  • ShippoClient\Entity\Refund
  • ShippoClient\Entity\RefundCollection
  • ShippoClient\Entity\ServiceLevel
  • ShippoClient\Entity\Shipment
  • ShippoClient\Entity\ShipmentCollection
  • ShippoClient\Entity\TrackingHistory
  • ShippoClient\Entity\TrackingStatus
  • ShippoClient\Entity\Tracks
  • ShippoClient\Entity\Transaction
  • ShippoClient\Entity\TransactionCollection
  • ShippoClient\Entity\WebhookTracks
  • ShippoClient\Http\Request
  • ShippoClient\Http\Request\Addresses\CreateObject
  • ShippoClient\Http\Request\CommonParameter
  • ShippoClient\Http\Request\MockCollection
  • ShippoClient\Http\Request\Parcels\CreateObject
  • ShippoClient\Http\Request\Shipments\CreateObject
  • ShippoClient\Http\Request\Shipments\CreateObjectByNested
  • ShippoClient\Http\Request\Shipments\CreateReturnObject
  • ShippoClient\Http\Request\Transactions\CreateObject
  • ShippoClient\Http\Response\AddressList
  • ShippoClient\Http\Response\ListResponse
  • ShippoClient\Http\Response\ParcelList
  • ShippoClient\Http\Response\RateList
  • ShippoClient\Http\Response\RefundList
  • ShippoClient\Http\Response\ShipmentList
  • ShippoClient\Http\Response\TransactionList
  • ShippoClient\Parcels
  • ShippoClient\Rates
  • ShippoClient\Refunds
  • ShippoClient\Shipments
  • ShippoClient\ShippoClient
  • ShippoClient\Tracks
  • ShippoClient\Transactions

Exceptions

  • ShippoClient\Http\Response\Exception\BadResponseException
  • ShippoClient\Http\Response\Exception\ClientErrorException
  • ShippoClient\Http\Response\Exception\ServerErrorException
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace ShippoClient\Entity;
  4: 
  5: use TurmericSpice\ReadableAttributes;
  6: 
  7: /**
  8:  * response type is different between each carrier.
  9:  * if carrier label is generated via shippo, you will get type same to Transaction object.
 10:  * if not, you will get type same to Tracks object.
 11:  */
 12: class WebhookTracks
 13: {
 14:     use ReadableAttributes {
 15:         // tracks object properties
 16:         mayHaveAsString as public getCarrier;
 17:         mayHaveAsString as public getEta;
 18:         // transaction object properties
 19:         mayHaveAsString as public getObjectState;
 20:         mayHaveAsString as public getObjectStatus;
 21:         mayHaveAsString as public getObjectId;
 22:         mayHaveAsString as public getObjectOwner;
 23:         mayHaveAsString as public getLabelUrl;
 24:         mayHaveAsString as public getTrackingUrlProvider;
 25:         mayHaveAsString as public getCommercialInvoiceUrl;
 26:         mayHaveAsString as public getCustomsNote;
 27:         mayHaveAsString as public getSubmissionNote;
 28:         mayHaveAsString as public getMetadata;
 29:         mayHaveAsArray  as public getMessages;
 30:         // common properties
 31:         mayHaveAsString as public getTrackingNumber;
 32:         toArray as public __toArray;
 33:     }
 34: 
 35:     /**
 36:      * transaction object property
 37:      *
 38:      * @return \DateTime
 39:      */
 40:     public function getObjectCreated()
 41:     {
 42:         return $this->attributes->mayHave('object_created')->asInstanceOf('\\DateTime');
 43:     }
 44: 
 45:     /**
 46:      * transaction object property
 47:      *
 48:      * @return \DateTime
 49:      */
 50:     public function getObjectUpdated()
 51:     {
 52:         return $this->attributes->mayHave('object_updated')->asInstanceOf('\\DateTime');
 53:     }
 54: 
 55:     /**
 56:      * tracks object property
 57:      *
 58:      * @return \ShippoClient\Entity\Location
 59:      */
 60:     public function getAddressFrom()
 61:     {
 62:         $addressFrom = $this->attributes->mayHave('address_from')->asArray();
 63: 
 64:         return new Location($addressFrom);
 65:     }
 66: 
 67:     /**
 68:      * tracks object property
 69:      *
 70:      * @return \ShippoClient\Entity\Location
 71:      */
 72:     public function getAddressTo()
 73:     {
 74:         $addressTo = $this->attributes->mayHave('address_to')->asArray();
 75: 
 76:         return new Location($addressTo);
 77:     }
 78: 
 79:     /**
 80:      * tracks object property
 81:      *
 82:      * @return \ShippoClient\Entity\ServiceLevel
 83:      */
 84:     public function getServiceLevel()
 85:     {
 86:         $serviceLevel = $this->attributes->mayHave('servicelevel')->asArray();
 87: 
 88:         return new ServiceLevel($serviceLevel);
 89:     }
 90: 
 91:     /**
 92:      * common property
 93:      *
 94:      * @return \ShippoClient\Entity\TrackingStatus
 95:      */
 96:     public function getTrackingStatus()
 97:     {
 98:         return new TrackingStatus($this->attributes->mayHave('tracking_status')->asArray());
 99:     }
100: 
101:     /**
102:      * common property
103:      *
104:      * @return \ShippoClient\Entity\TrackingHistory
105:      */
106:     public function getTrackingHistory()
107:     {
108:         $entities = $this->attributes->mayHave('tracking_history')
109:             ->asInstanceArray('ShippoClient\\Entity\\TrackingStatus');
110: 
111:         return new TrackingHistory($entities);
112:     }
113: 
114:     public function toArray()
115:     {
116:         return [
117:             // tracks
118:             'carrier'                => $this->getCarrier(),
119:             'tracking_number'        => $this->getTrackingNumber(),
120:             'tracking_status'        => $this->getTrackingStatus()->toArray(),
121:             'tracking_history'       => $this->getTrackingHistory()->toArray(),
122:             'eta'                    => $this->getEta(),
123:             'address_from'           => $this->getAddressFrom()->toArray(),
124:             'address_to'             => $this->getAddressTo()->toArray(),
125:             'servicelevel'           => $this->getServiceLevel()->toArray(),
126:             // transaction
127:             'object_state'           => $this->getObjectState(),
128:             'object_status'          => $this->getObjectStatus(),
129:             'object_created'         => $this->getObjectCreated(),
130:             'object_updated'         => $this->getObjectUpdated(),
131:             'object_id'              => $this->getObjectId(),
132:             'object_owner'           => $this->getObjectOwner(),
133:             'label_url'              => $this->getLabelUrl(),
134:             'tracking_url_provider'  => $this->getTrackingUrlProvider(),
135:             'commercial_invoice_url' => $this->getCommercialInvoiceUrl(),
136:             'customs_note'           => $this->getCustomsNote(),
137:             'submission_note'        => $this->getSubmissionNote(),
138:             'metadata'               => $this->getMetadata(),
139:             'messages'               => $this->getMessages(),
140:         ];
141:     }
142: }
143: 
API documentation generated by ApiGen