@@ -66,4 +66,163 @@ public function listCarriers($config = null): array
6666
6767 return $ apiResponse ;
6868 }
69+
70+ /**
71+ * Address validation ensures accurate addresses and can lead to reduced shipping costs by preventing address
72+ * correction surcharges. ShipEngine cross references multiple databases to validate addresses and identify
73+ * potential deliverability issues.
74+ * See: https://shipengine.github.io/shipengine-openapi/#operation/validate_address
75+ *
76+ * @param array $params A list of addresses that are to be validated
77+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
78+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
79+ * @return array An array of Address objects that correspond the to carrier accounts connected
80+ * to a given ShipEngine account.
81+ */
82+ public function validateAddresses ($ params , $ config = null ): array
83+ {
84+ $ config = $ this ->config ->merge ($ config );
85+ $ client = new ShipEngineClient ();
86+ $ apiResponse = $ client ->post (
87+ 'v1/addresses/validate ' ,
88+ $ config ,
89+ $ params
90+ );
91+
92+ return $ apiResponse ;
93+ }
94+
95+ /**
96+ * When retrieving rates for shipments using the /rates endpoint, the returned information contains a rateId
97+ * property that can be used to generate a label without having to refill in the shipment information repeatedly.
98+ * See: https://shipengine.github.io/shipengine-openapi/#operation/create_label_from_rate
99+ *
100+ * @param string $rateId A rate identifier for the label
101+ * @param array $params An array of label params that will dictate the label display and level of verification.
102+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
103+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
104+ * @return array A label that correspond the to shipment details for a rate id
105+ */
106+ public function createLabelFromRate ($ rateId , $ params , $ config = null ): array
107+ {
108+ $ config = $ this ->config ->merge ($ config );
109+ $ client = new ShipEngineClient ();
110+ $ apiResponse = $ client ->post (
111+ "v1/labels/rates/ {$ rateId }" ,
112+ $ config ,
113+ $ params
114+ );
115+
116+ return $ apiResponse ;
117+ }
118+
119+ /**
120+ * Purchase and print a label for shipment.
121+ * https://shipengine.github.io/shipengine-openapi/#operation/create_label
122+ *
123+ * @param array $params An array of shipment details for the label creation.
124+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
125+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
126+ * @return array A label that correspond the to shipment details
127+ */
128+ public function createLabelFromShipmentDetails ($ params , $ config = null ): array
129+ {
130+ $ config = $ this ->config ->merge ($ config );
131+ $ client = new ShipEngineClient ();
132+ $ apiResponse = $ client ->post (
133+ 'v1/labels ' ,
134+ $ config ,
135+ $ params
136+ );
137+
138+ return $ apiResponse ;
139+ }
140+
141+ /**
142+ * Void label with a Label Id.
143+ * https://shipengine.github.io/shipengine-openapi/#operation/void_label
144+ *
145+ * @param string $labelId A label id
146+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
147+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
148+ * @return array A voided label approval and message
149+ */
150+ public function voidLabelWithLabelId ($ labelId , $ config = null ): array
151+ {
152+ $ config = $ this ->config ->merge ($ config );
153+ $ client = new ShipEngineClient ();
154+ $ apiResponse = $ client ->put (
155+ "v1/labels/ $ {labelId}/void " ,
156+ $ config
157+ );
158+
159+ return $ apiResponse ;
160+ }
161+
162+ /**
163+ * Given some shipment details and rate options, this endpoint returns a list of rate quotes.
164+ * See: https://shipengine.github.io/shipengine-openapi/#operation/calculate_rates
165+ *
166+ * @param array $params An array of rate options and shipment details.
167+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
168+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
169+ * @return array An array of Rate objects that correspond to the rate options and shipment details.
170+ */
171+ public function getRatesWithShipmentDetails ($ params , $ config = null ): array
172+ {
173+ $ config = $ this ->config ->merge ($ config );
174+ $ client = new ShipEngineClient ();
175+ $ apiResponse = $ client ->post (
176+ 'v1/rates ' ,
177+ $ config ,
178+ $ params
179+ );
180+
181+ return $ apiResponse ;
182+ }
183+
184+ /**
185+ * Retrieve the label's tracking information with Label Id
186+ * See: https://shipengine.github.io/shipengine-openapi/#operation/get_tracking_log_from_label
187+ *
188+ * @param string $labelId A label id
189+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
190+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
191+ * @return array An array of Tracking information corresponding to the Label Id.
192+ */
193+ public function trackUsingLabelId ($ labelId , $ config = null ): array
194+ {
195+ $ config = $ this ->config ->merge ($ config );
196+ $ client = new ShipEngineClient ();
197+ $ apiResponse = $ client ->post (
198+ "v1/labels/ $ {labelId}/track " ,
199+ $ config
200+ );
201+
202+ return $ apiResponse ;
203+ }
204+
205+ /**
206+ * Retrieve the label's tracking information with Carrier Code and Tracking Number
207+ * See: https://shipengine.github.io/shipengine-openapi/#operation/get_tracking_log
208+ *
209+ * @param string $carrierCode Carrier code used to retrieve tracking information
210+ * @param string $trackingNumber The tracking number associated with a shipment
211+ * @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
212+ * baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
213+ * @return array An array of Tracking information corresponding to the Label Id.
214+ */
215+ public function trackUsingCarrierCodeAndTrackingNumber ($ carrierCode , $ trackingNumber , $ config = null ): array
216+ {
217+ $ config = $ this ->config ->merge ($ config );
218+ $ client = new ShipEngineClient ();
219+ $ apiResponse = $ client ->post (
220+ "v1/tracking " ,
221+ $ config ,
222+ array ('carrier_code ' => $ carrierCode , 'tracking_number ' => $ trackingNumber )
223+ );
224+
225+ return $ apiResponse ;
226+ }
227+
69228}
0 commit comments