Services¶
Instead of calling the serializer every time, you can enhance the original Speedy client by decorating it with the SpeedyModelDecorator. This enhancement makes the responses more convenient, predictable and easy to use.
1<?php
2
3$speedy = new SpeedyModelDecorator(
4 new Speedy($configuration, $client, $factory)
5);
Client Service¶
Get Client¶
Get client by id. Client id is provided as parameter in URL path
1$request = new GetClientRequest($id);
2$response = $speedy->getClient($request);
3
4/** @var Client $client */
5$client = $response->getClient();
Get Contract Clients¶
Get clients with same contract as logged user’s one, if any
1$request = new GetContractClientsRequest();
2$response = $speedy->getContractClients($request);
3
4/** @var ArrayCollection $clients */
5$clients = $response->getClients();
6
7/** @var Model\Client $client */
8$client = $clients->first();
9
10$clientId = $client->getClientId();
11$clientName = $client->getClientName();
12$contractName = $client->getContractName();
13
14/** @var Model\Address $address */
15$address = $client->getAddress();
Shipment Service¶
Create Shipment¶
1$request = new CreateShipmentRequest(
2 new ShipmentSender(),
3 new ShipmentRecipient(),
4 new ShipmentService(),
5 new ShipmentContent(),
6 new ShipmentPayment()
7);
8
9$response = $speedy->createShipment($request);
Cancel Shipment¶
1$request = new CancelShipmentRequest();
2$response = $speedy->cancelShipment($request);
Update Shipment¶
1$request = new UpdateShipmentRequest();
2$response = $speedy->updateShipment($request);
Shipment Information¶
Print Service¶
Print Service
Track And Trace Service¶
Track And Trace Service
Pickup¶
Pickup
Location Service¶
Location Service
Find Country¶
1$request = new FindCountry('Bulgaria');
2
3/** @var FindCountryResponse $countries */
4$response = $speedy->findCountry($request);
5
6/** @var ArrayCollection $countries */
7$countries = $response->getCountries();
8
9/** @var Model\Country $country */
10$country = $countries->first();
11
12$countryId = $country->getId(); // int 100
13$countryName = $country->getName(); // string BULGARIA
Find Site¶
1<?php
2
3$request = new FindSite(countryId: 100, name: 'Sof');
4
5$response = $speedy->findSite($request);
6foreach($response->getCities()) {
7 $countryId = $city->getId();
8 $countryName = $city->getName();
9}