1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ShippoClient\Entity; |
4
|
|
|
|
5
|
|
|
use TurmericSpice\ReadableAttributes; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Each valid Shipment object will automatically trigger the calculation of all available Rates. |
9
|
|
|
* Depending on your Addresses and Parcel, there may be none, one or multiple Rates. |
10
|
|
|
* |
11
|
|
|
* By default, the calculated Rates will return the price in two currencies under the "amount" and "amount_local" keys, respectively. |
|
|
|
|
12
|
|
|
* The "amount" key will contain the price of a Rate expressed in the currency that is used in the country from which Parcel originates, |
|
|
|
|
13
|
|
|
* and the "amount_local" key will contain the price expressed in the currency that is used in the country the Parcel is shipped to. |
|
|
|
|
14
|
|
|
* You can request Rates with prices expressed in a different currency by adding the desired currency code in the end of the resource URL. |
|
|
|
|
15
|
|
|
* The full list of supported currencies along with their codes can be viewed on open exchange rates. |
16
|
|
|
* |
17
|
|
|
* Rates are created asynchronously. The response time depends exclusively on the carrier's server. |
18
|
|
|
*/ |
19
|
|
|
class Rate extends ObjectInformation |
20
|
|
|
{ |
21
|
|
|
use ReadableAttributes { |
22
|
|
|
mayHaveAsString as public getShipment; |
23
|
|
|
mayHaveAsArray as public getAttributes; |
24
|
|
|
mayHaveAsFloat as public getAmountLocal; |
25
|
|
|
mayHaveAsString as public getCurrencyLocal; |
26
|
|
|
mayHaveAsFloat as public getAmount; |
27
|
|
|
mayHaveAsString as public getCurrency; |
28
|
|
|
mayHaveAsString as public getProvider; |
29
|
|
|
mayHaveAsString as public getServicelevelName; |
30
|
|
|
mayHaveAsString as public getServicelevelTerms; |
31
|
|
|
mayHaveAsInt as public getDays; |
32
|
|
|
mayHaveAsBoolean as public getTrackable; |
33
|
|
|
mayHaveAsBoolean as public getInsurance; |
34
|
|
|
mayHaveAsFloat as public getInsuranceAmountLocal; |
35
|
|
|
mayHaveAsString as public getInsuranceCurrencyLocal; |
36
|
|
|
mayHaveAsFloat as public getInsuranceAmount; |
37
|
|
|
mayHaveAsString as public getInsuranceCurrency; |
38
|
|
|
mayHaveAsString as public getCarrierAccount; |
39
|
|
|
mayHaveAsString as public getDurationTerms; |
40
|
|
|
mayHaveAsArray as public getMessages; |
41
|
|
|
mayHaveAsString as public getProviderImage_75; |
42
|
|
|
mayHaveAsString as public getProviderImage_200; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Description is not found in Shippo API doc, but this key is returned in fact. |
47
|
|
|
* |
48
|
|
|
* @return mixed|null |
49
|
|
|
*/ |
50
|
|
|
public function getAvailableShippo() |
51
|
|
|
{ |
52
|
|
|
return $this->attributes->mayHave('available_shippo')->value(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Description is not found in Shippo API doc, but this key is returned in fact. |
57
|
|
|
* |
58
|
|
|
* @return mixed|null |
59
|
|
|
*/ |
60
|
|
|
public function getOutboundEndpoint() |
61
|
|
|
{ |
62
|
|
|
return $this->attributes->mayHave('outbound_endpoint')->value(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Description is not found in Shippo API doc, but this key is returned in fact. |
67
|
|
|
* |
68
|
|
|
* @return mixed|null |
69
|
|
|
*/ |
70
|
|
|
public function getInboundEndpoint() |
71
|
|
|
{ |
72
|
|
|
return $this->attributes->mayHave('inbound_endpoint')->value(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Description is not found in Shippo API doc, but this key is returned in fact. |
77
|
|
|
* |
78
|
|
|
* @return mixed|null |
79
|
|
|
*/ |
80
|
|
|
public function getArrivesBy() |
81
|
|
|
{ |
82
|
|
|
return $this->attributes->mayHave('arrives_by')->value(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Description is not found in Shippo API doc, but this key is returned in fact. |
87
|
|
|
* |
88
|
|
|
* @return mixed|null |
89
|
|
|
*/ |
90
|
|
|
public function getDeliveryAttempts() |
91
|
|
|
{ |
92
|
|
|
return $this->attributes->mayHave('delivery_attempts')->value(); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.