{"id":21688470,"url":"https://github.com/ag84ark/colete-online-ro-php","last_synced_at":"2025-03-20T12:27:28.711Z","repository":{"id":229379143,"uuid":"776376028","full_name":"ag84ark/colete-online-ro-php","owner":"ag84ark","description":"PHP library to work with colete-online.ro API","archived":false,"fork":false,"pushed_at":"2024-03-25T21:02:00.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T12:41:29.632Z","etag":null,"topics":["colete-online","colete-online-ro","php","php8","saloonphp","shipping-api","shipping-module"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ag84ark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-23T10:34:39.000Z","updated_at":"2024-03-25T15:07:49.000Z","dependencies_parsed_at":"2024-03-25T16:30:34.009Z","dependency_job_id":"7bf47cfd-7ddc-4c44-bad4-14dbac8e653c","html_url":"https://github.com/ag84ark/colete-online-ro-php","commit_stats":null,"previous_names":["ag84ark/colete-online-ro-php"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ag84ark%2Fcolete-online-ro-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ag84ark%2Fcolete-online-ro-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ag84ark%2Fcolete-online-ro-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ag84ark%2Fcolete-online-ro-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ag84ark","download_url":"https://codeload.github.com/ag84ark/colete-online-ro-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244610669,"owners_count":20481033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colete-online","colete-online-ro","php","php8","saloonphp","shipping-api","shipping-module"],"created_at":"2024-11-25T17:15:20.336Z","updated_at":"2025-03-20T12:27:28.681Z","avatar_url":"https://github.com/ag84ark.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ColeteOnline.ro API PHP Library\nPHP library to work with colete-online.ro API using Saloon PHP Framework.\n\nThis library requires PHP 8.1 or newer.\n\n## Installation\n```bash\ncomposer require ag84ark/colete-online-ro-php\n```\n\n## Usage\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline;\nuse Ag84ark\\ColeteOnlineRoPhp\\ColeteOnlineApiConnector;\n\n\n$coleteOnline = new ColeteOnline(\n    new ColeteOnlineApiConnector(\n        clientId: \"your-client-id\",\n        clientSecret: \"your-client-secret\",\n        staging: false\n    )\n);\n```\n## Store authenticator for later user\nIt is recommended to store the authenticator object for later use to avoid re-authenticating on every request.  \nThe expiration time of the authenticator is 2 hour.\n```php\n$authenticator = $coleteOnline-\u003eauthenticate();\n// Or $authenticator = $coleteOnline-\u003egetAuthenticator()\n// if already authenticated by using any method that requires authentication\n$serializeAuth = $authenticator-\u003eserialize();\n// Store $serializeAuth for later use\n\n// Later\n$coleteOnline = new ColeteOnline(\n    new ColeteOnlineApiConnector(\n        clientId: \"your-client-id\",\n        clientSecret: \"your-client-secret\",\n        staging: false\n    ),\n    unserialize($serializeAuth)\n);\n\n```\n\n\n## Methods\n\n### Get all available services\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Service\\ServiceItemDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Service\\ServiceListResponse $services */\n$services = $coleteOnline-\u003egetServicesList();\n$servicesList = $services-\u003eitems(); // Array\n$servicesListCollection = $services-\u003eitemsCollection(); // Illuminate\\Support\\Collection\n\n$servicesListCollection-\u003eeach(function (ServiceItemDTO $service) {\n    echo $service-\u003ename . PHP_EOL;\n});\n```\n\n### Get user balance\n```php\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\User\\UserBalanceResponse $userBalance */\n$userBalance = $coleteOnline-\u003egetUserBalance();\necho $userBalance-\u003ebalance()-\u003eamount . PHP_EOL;\necho $userBalance-\u003ebalance()-\u003ebonus . PHP_EOL;\n```\n\n### Get the AWB\n```php\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n$awbDownload = $coleteOnline-\u003egetOrderAwb(123456)-\u003esaveBodyToFile('awb.pdf');\n// Or\n$coleteOnline-\u003egetOrderAwbAndSaveToFile(123456, 'awb.pdf');\n// Or\n$stream = $coleteOnline-\u003egetOrderAwbStream(123456);\n```\n\n### Get order status\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Order\\OrderStatusHistoryItemDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Order\\OrderStatusResponse $orderStatus */\n$orderStatus = $coleteOnline-\u003egetOrderStatus(123456);\n\necho $orderStatus-\u003eresponse()-\u003esummary-\u003euniqueId . PHP_EOL; \necho $orderStatus-\u003eresponse()-\u003esummary-\u003eawb . PHP_EOL;\n\necho $orderStatus-\u003eresponse()\n        -\u003egetHistoryCollection()\n        -\u003eeach(function (OrderStatusHistoryItemDTO $history) {\n            echo $history-\u003estatusTextParts-\u003ero-\u003ename . PHP_EOL;  # \"Alocata pentru ridicare\"\n            echo $history-\u003ecomment-\u003ero . PHP_EOL;  # \"Locatie: Bucuresti; \"\n        });\n```\n\n### Search Country\n```php\n\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Search\\CountryDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Search\\SearchCountryResponse $countries */\n$countries = $coleteOnline-\u003esearchCountry('rom');\n\n\n$countries-\u003eitemsCollection()-\u003eeach(function (CountryDTO $country) {\n    echo $country-\u003ename . PHP_EOL; # \"Romania\"\n    echo $country-\u003enameRo . PHP_EOL; # \"Romania\"\n    echo $country-\u003eisoCode . PHP_EOL; # \"RO\"\n});\n```\n\n### Search Location\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Search\\LocationDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Search\\SearchLocationResponse $locations */\n$locations = $coleteOnline-\u003esearchLocation('ro', 'ghim');\n\n$locations-\u003eitemsCollection()-\u003eeach(function (LocationDTO $location) {\n    echo $location-\u003ecity . PHP_EOL; # \"Ghimbav\"\n    echo $location-\u003ecounty . PHP_EOL; # \"Brasov\"\n    echo $location-\u003ecountyCode . PHP_EOL; # \"BV\"\n});\n```\n\n\n### Search City\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Search\\CityDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Search\\SearchCityResponse $cities */\n\n$cities = $coleteOnline-\u003esearchCity('RO', 'Ilfov', 'draga');\n// Or\n$cities = $coleteOnline-\u003esearchCity('ro', 'IF', 'draga', true); // use county code\n\n$cities-\u003eitemsCollection()-\u003eeach(function (CityDTO $city) {\n    echo $city-\u003elocalityName . PHP_EOL; # \"Draganesti\"\n    echo $city-\u003ecountyName . PHP_EOL; # \"Ilfov\"\n    echo $city-\u003ecountyCode . PHP_EOL; # \"IF\"\n});\n```\n\n### Search Street\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Search\\StreetDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Search\\SearchStreetResponse $streets */\n\n$streets = $coleteOnline-\u003esearchStreet('RO', 'Pitesti', 'Arges', 'gr');\n$streets = $coleteOnline-\u003esearchStreet('RO', 'Pitesti', 'Arges', 'gr', 300367); // use postal code\n// Or\n$streets = $coleteOnline-\u003esearchStreet(\"RO\", \"Pitesti\", \"AG\", \"gr\", null, true); // don't use postal code\n$streets = $coleteOnline-\u003esearchStreet('RO', 'Pitesti', 'AG', 'gr', 300367, true); // use county code\n\n$streets-\u003eitemsCollection()-\u003eeach(function (StreetDTO $street) {\n    echo $street-\u003ename . PHP_EOL; # \"Piața Avram Iancu\"\n    echo $street-\u003ehighlight . PHP_EOL; # \"true|false|null\"\n});\n```\n\n### Search Postal Code\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Search\\PostalCodeDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Search\\SearchPostalCodeResponse $postalCodes */\n\n$postalCodes = $coleteOnline-\u003esearchPostalCode('RO', 'Timis', 'Timisoara', 'Piața Avram Iancu');\n// Or\n$postalCodes = $coleteOnline-\u003esearchPostalCode('RO', 'TM', 'Timisoara', 'Piața Avram Iancu', 1, true); // use county code\n\n\n$postalCodes-\u003eitemsCollection()-\u003eeach(function (PostalCodeDTO $postalCode) {\n    echo $postalCode-\u003ecode . PHP_EOL; # \"300367\"\n    echo $postalCode-\u003einfo . PHP_EOL; # \"nr. 9-13; 6-T\"\n    echo $postalCode-\u003estreet . PHP_EOL; # \"Piața Avram Iancu\"\n});\n```\n\n### Get Addresses List\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Address\\AddressItemDTO;\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Address\\AddressListResponse $addresses */\n\n$addresses = $coleteOnline-\u003egetAddressList();\n\n$addresses-\u003eitemsCollection()-\u003eeach(function (AddressItemDTO $addressItem) {\n    echo $addressItem-\u003elocationId . PHP_EOL; # \"123456\"\n    echo $addressItem-\u003eshortNamename . PHP_EOL; # \"Home\"\n    echo $addressItem-\u003eaddress-\u003estreet . PHP_EOL; # \"Piața Avram Iancu\"\n    echo $addressItem-\u003eaddress-\u003enumber . PHP_EOL; # \"13\"\n    \n    echo $addressItem-\u003econtact-\u003ename . PHP_EOL; # \"John Doe\"\n    echo $addressItem-\u003econtact-\u003ephone . PHP_EOL; # \"0723456789\"\n});\n```\n\n### Create Order\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Order;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\OrderSender;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\OrderRecipient;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Contact;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Address;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Packages;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\PackageTypeEnum;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\PackageItem;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\CurrierService;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\ServiceSelectionTypeEnum;\n\n\n$orderSender = OrderSender::create(\n            contact: Contact(\n                name: 'John Doe',\n                phone: '0740000000',\n                phone2: '',\n                email: 'jonh@exmaple.ro',\n            ),\n            address: new Address(\n                countryCode: 'RO',\n                postalCode: '123456',\n                city: 'Bucuresti',\n                county: 'Bucuresti',\n                street: 'Str. Matei Basarab',\n                number: '45',\n            ),\n        );\n\n        $orderRecipient = OrderRecipient::create(\n            contact: new Contact(\n                name: 'Jane Doe',\n                phone: '0742222222',\n                phone2: '',\n                email: 'jane@example.ro',\n            ),\n            address: new Address(\n                countryCode: 'RO',\n                postalCode: '233333',\n                city: 'Ploiesti',\n                county: 'Prahova',\n                additionalInfo: 'Bloc 1, Scara A, Etaj 2, Apartament 3',\n            ),\n        );\n        \n        $packages = (new Packages(type: PackageTypeEnum::Box, content: 'Produse'))\n                -\u003eaddPackageItem(\n                    new PackageItem(\n                        weight: 2.1,\n                        height: 10,\n                        width: 15,\n                        length: 20,\n                    ),\n                );\n        \n        $extraOptions = (new ExtraOptions())\n            -\u003eaddInsurance(1000)\n            -\u003eaddCashRepayment(1000)\n            -\u003eaddDeclaredValue(1000)\n            -\u003eaddOpenAtDelivery()\n            -\u003eaddSaturdayDelivery()\n            -\u003eaddStatusChangeNotify(\"https://example.com/status-change-notify\");\n\n        $request = new Order(\n            sender: $orderSender,\n            recipient: $orderRecipient,\n            packages: $packages,\n            service: new CurrierService(\n                selectionType: ServiceSelectionTypeEnum::BestPrice,\n            ),\n            extraOptions: $extraOptions\n        );\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Order\\CreateOrderResponse $createOrder */\n$createOrder = $coleteOnline-\u003ecreateOrder($request);\n\necho $createOrder-\u003eresponse()-\u003euniqueId . PHP_EOL; # \"123456\"\necho $createOrder-\u003eresponse()-\u003eawb . PHP_EOL; # \"ASA123456\"\necho $createOrder-\u003eresponse()-\u003ecurierService-\u003eservice-\u003eid . PHP_EOL; # \"6\"\necho $createOrder-\u003eresponse()-\u003ecurierService-\u003eservice-\u003ename . PHP_EOL; # \"Domestic Express\"\necho $createOrder-\u003eresponse()-\u003ecurierService-\u003eservice-\u003ecourierName . PHP_EOL; # \"TNT\"\necho $createOrder-\u003eresponse()-\u003ecurierService-\u003eprice-\u003etotal . PHP_EOL; # \"23.80\"\necho $createOrder-\u003eresponse()-\u003ecurierService-\u003eprice-\u003enoVat . PHP_EOL; # \"20.00\"\n```\n\n\n### Get Order Pricing\n\n```php\nuse Ag84ark\\ColeteOnlineRoPhp\\DTOs\\Order\\OrderCurrierServiceDTO;\n\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\OrderPricing;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\OrderSender;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\OrderRecipient;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Contact;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Address;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\Packages;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\PackageTypeEnum;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\PackageItem;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\CurrierService;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\ServiceSelectionTypeEnum;\nuse Ag84ark\\ColeteOnlineRoPhp\\Types\\ExtraOptions;\n\n\n$orderSender = OrderSender::create(\n            contact: Contact(\n                name: 'John Doe',\n                phone: '0740000000',\n                phone2: '',\n                email: 'jonh@exmaple.ro',\n            ),\n            address: new Address(\n                countryCode: 'RO',\n                postalCode: '123456',\n                city: 'Bucuresti',\n                county: 'Bucuresti',\n                street: 'Str. Matei Basarab',\n                number: '45',\n            ),\n        );\n\n        $orderRecipient = OrderRecipient::create(\n            contact: new Contact(\n                name: 'Jane Doe',\n                phone: '0742222222',\n                phone2: '',\n                email: 'jane@example.ro',\n            ),\n            address: new Address(\n                countryCode: 'RO',\n                postalCode: '233333',\n                city: 'Ploiesti',\n                county: 'Prahova',\n                additionalInfo: 'Bloc 1, Scara A, Etaj 2, Apartament 3',\n            ),\n        );\n        \n        $extraOptions = (new ExtraOptions())\n            -\u003eaddInsurance(1000)\n            -\u003eaddCashRepayment(1000)\n            -\u003eaddDeclaredValue(1000)\n            -\u003eaddOpenAtDelivery()\n            -\u003eaddSaturdayDelivery()\n            -\u003eaddStatusChangeNotify(\"https://example.com/status-change-notify\");\n\n        $request = new OrderPricing(\n            sender: $orderSender,\n            recipient: $orderRecipient,\n            packages: (new Packages(type: PackageTypeEnum::Box, content: 'Produse'))\n                -\u003eaddPackageItem(\n                    new PackageItem(\n                        weight: 2.1,\n                        height: 10,\n                        width: 15,\n                        length: 20,\n                    ),\n                ),\n            service: new CurrierService(\n                selectionType: ServiceSelectionTypeEnum::BestPrice,\n            ),\n            extraOptions: $extraOptions\n        );\n\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\ColeteOnline $coleteOnline */\n/** @var \\Ag84ark\\ColeteOnlineRoPhp\\Responses\\Order\\OrderPricingResponse $orderPricing */\n$orderPricing = $coleteOnline-\u003egetOrderPricing($request);\n\necho $orderPricing-\u003eresponse()-\u003eselected-\u003eservice-\u003eid . PHP_EOL; # \"6\"\necho $orderPricing-\u003eresponse()-\u003eselected-\u003eservice-\u003ename . PHP_EOL; # \"Domestic Express\"\necho $orderPricing-\u003eresponse()-\u003eselected-\u003eservice-\u003ecourierName . PHP_EOL; # \"TNT\"\necho $orderPricing-\u003eresponse()-\u003eselected-\u003eprice-\u003etotal . PHP_EOL; # \"23.80\"\necho $orderPricing-\u003eresponse()-\u003eselected-\u003eprice-\u003enoVat . PHP_EOL; # \"20.00\"\n\n$orderPricing-\u003eresponse()-\u003egetCurriersList()-\u003eeach(function (OrderCurrierServiceDTO $currier) {\n    echo $currier-\u003eservice-\u003eid . PHP_EOL; # \"6\"\n    echo $currier-\u003eservice-\u003ename . PHP_EOL; # \"Domestic Express\"\n    echo $currier-\u003eservice-\u003ecourierName . PHP_EOL; # \"TNT\"\n    echo $currier-\u003eprice-\u003etotal . PHP_EOL; # \"23.80\"\n    echo $currier-\u003eprice-\u003enoVat . PHP_EOL; # \"20.00\"\n});\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fag84ark%2Fcolete-online-ro-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fag84ark%2Fcolete-online-ro-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fag84ark%2Fcolete-online-ro-php/lists"}