├── .php-cs-fixer.cache ├── .php_cs.dist.php ├── CHANGELOG.md ├── CONTRIBUTING.md ├── README.md ├── composer.json ├── config └── shiprocket.php ├── phpunit.xml.dist.bak └── src ├── Clients ├── Client.php └── ShiprocketClient.php ├── Commands └── SketchCommand.php ├── Exceptions └── ShiprocketException.php ├── Resources ├── ChannelResource.php ├── CourierResource.php ├── GenerateResource.php ├── NdrResource.php ├── OrderResource.php ├── PickupResource.php ├── ProductResource.php ├── Resource.php ├── ResourceInterface.php ├── ShipmentResource.php ├── TrackingResource.php └── WarehouseResource.php ├── Shiprocket.php ├── ShiprocketApi.php ├── ShiprocketServiceProvider.php ├── Traits └── Authenticate.php └── Wrapper.php /.php-cs-fixer.cache: -------------------------------------------------------------------------------- 1 | {"php":"8.3.3","version":"3.50.0","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Commands\/SketchCommand.php":"645740985226d44e21a79ee5a8cd57c5","src\/Traits\/Authenticate.php":"880aec7b0efa082a3f788a0a49357c62","src\/Exceptions\/ShiprocketException.php":"7f367a6a5461fe5f1c865067c29befcb","src\/ShiprocketServiceProvider.php":"af83e39dd58ca22fc342e3ab8f78dbb3","src\/Clients\/ShiprocketClient.php":"cb6a51cf4af1ee713bdb36754824f28b","src\/Clients\/Client.php":"9d50c76de57f70a4d4678b738ddcc1c5","src\/Wrapper.php":"28cc68d5715ddc22575b053708ec6f68","src\/Resources\/OrderResource.php":"5bc245b782058215e83e1f41a4510da0","src\/Resources\/ChannelResource.php":"2adc3ae5c725d085d891e259526a854d","src\/Resources\/Resource.php":"d2752dc1a9e305a97ab1479ba042b1f4","src\/Resources\/ProductResource.php":"af08af3a01166dda9fdd2b55c57c032e","src\/Resources\/WarehouseResource.php":"a6415a38e8e64f22bf94cc726b80c8ee","src\/Resources\/GenerateResource.php":"b3a930f3e1721dc3a11d0e9f638c2779","src\/Resources\/TrackingResource.php":"5e0d19d96965f2d655c4de69826161b4","src\/Resources\/NdrResource.php":"674fde9b9806d058850b46aba1aa824f","src\/Resources\/ShipmentResource.php":"41cadd30b630610fa6b2766472c48ac5","src\/Resources\/PickupResource.php":"b3dbd2263fc91c9f39d6c1aa77c6d1d5","src\/Resources\/CourierResource.php":"033364eb9af2f6508c354701300a1280","src\/Resources\/ResourceInterface.php":"d5d09eaa18b89496800d80363b998b19","src\/Shiprocket.php":"2f1598acb94b82c063c6075d7396c363","src\/ShiprocketApi.php":"8948dca98b53a9b5d959765bc41dec8e","tests\/Unit\/AuthenticationTest.php":"94dda90319017c14e1faa555cd097d1c","tests\/Feature\/CouriersTest.php":"5e372adefea932b3c917faa1943d79eb","tests\/Feature\/OrdersTest.php":"9c938debf5d823fecf0df0f563d7bd4d","tests\/Feature\/PickupLocationsTest.php":"d3d79bd1c141eaff9dfb5ee35786bdec","tests\/Feature\/AuthenticateTest.php":"fc2ce1ed389d96fa422cba624feed7dc","tests\/Feature\/ChannelTest.php":"94d5af80d368206493b5b2cadf4d1fd9","tests\/Feature\/WarehouseTest.php":"81cb714e0d84a28bbf060eb01c22fa94","tests\/Feature\/NdrShipmentsTest.php":"2a452c6ce5a449d062725de2cae92831","tests\/Traits\/SampleData.php":"de9c9e2b85861c73a93e33f4bb7617e7","tests\/Traits\/Authenticate.php":"c7bf9c1a2704a96884fde129adcf1b95","tests\/TestCase.php":"5c45a5f4647a4754f97e1bd40af9183a"}} -------------------------------------------------------------------------------- /.php_cs.dist.php: -------------------------------------------------------------------------------- 1 | in([ 5 | __DIR__ . '/src', 6 | __DIR__ . '/tests', 7 | ]) 8 | ->name('*.php') 9 | ->notName('*.blade.php') 10 | ->ignoreDotFiles(true) 11 | ->ignoreVCS(true); 12 | 13 | return (new PhpCsFixer\Config()) 14 | ->setRules([ 15 | '@PSR12' => true, 16 | 'array_syntax' => ['syntax' => 'short'], 17 | 'ordered_imports' => ['sort_algorithm' => 'alpha'], 18 | 'no_unused_imports' => true, 19 | 'not_operator_with_successor_space' => true, 20 | 'trailing_comma_in_multiline' => true, 21 | 'phpdoc_scalar' => true, 22 | 'unary_operator_spaces' => true, 23 | 'binary_operator_spaces' => true, 24 | 'blank_line_before_statement' => [ 25 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 26 | ], 27 | 'phpdoc_single_line_var_spacing' => true, 28 | 'phpdoc_var_without_name' => true, 29 | 'class_attributes_separation' => [ 30 | 'elements' => [ 31 | 'method' => 'one', 32 | ], 33 | ], 34 | 'method_argument_space' => [ 35 | 'on_multiline' => 'ensure_fully_multiline', 36 | 'keep_multiple_spaces_after_comma' => true, 37 | ], 38 | 'single_trait_insert_per_statement' => true, 39 | ]) 40 | ->setFinder($finder); -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `:package_name` will be documented in this file 4 | 5 | ## 0.0.1 - 2020-07-03 6 | 7 | - pre release 8 | 9 | 10 | ## 1.0.0 - 2020-07-19 11 | 12 | - initial release 13 | 14 | ## 1.0.1 - 2020-08-13 15 | 16 | - Added product API and suppported for php 7.2.5 -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Enjoy coding**! 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shiprocket API (V1) Laravel SDK 2 | ## Laravel SDK (module) for [Shiprocket API Version 1](https://apidocs.shiprocket.in/?version=latest#intro). The integration of Shiprocket API in your laravel application is made easy. 3 | 4 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/seshac/laravel-shiprocket-api.svg?style=flat-square)](https://packagist.org/packages/seshac/laravel-shiprocket-api) 5 | [![Total Downloads](https://img.shields.io/packagist/dt/seshac/laravel-shiprocket-api.svg?style=flat-square)](https://packagist.org/packages/seshac/laravel-shiprocket-api) 6 | ![Tests](https://github.com/seshac/laravel-shiprocket-api/workflows/Tests/badge.svg?branch=master) 7 | 8 | ## Index 9 | 1. [Installation](https://github.com/seshac/laravel-shiprocket-api#installation) 10 | 2. [Usage](https://github.com/seshac/laravel-shiprocket-api#installation) 11 | 1. [Authentication](https://github.com/seshac/laravel-shiprocket-api#Authentication) 12 | 2. [Orders](https://github.com/seshac/laravel-shiprocket-api#Orders) 13 | 3. [Couriers](https://github.com/seshac/laravel-shiprocket-api#Couriers) 14 | 4. [Tracking](https://github.com/seshac/laravel-shiprocket-api#Tracking) 15 | 5. [Shipments](https://github.com/seshac/laravel-shiprocket-api#Shipments) 16 | 6. [Pickup Addresses](https://github.com/seshac/laravel-shiprocket-api#Pickup-Addresses) 17 | 7. [Channels](https://github.com/seshac/laravel-shiprocket-api#Channels) 18 | 8. [Manifest/Generate-Labels/Print-Invoice](https://github.com/seshac/laravel-shiprocket-api#Generate) 19 | 9. [Products](https://github.com/seshac/laravel-shiprocket-api#Products) 20 | 9. [Warehouse](https://github.com/seshac/laravel-shiprocket-api#Warehouse) 21 | 3. [Contributors](https://github.com/seshac/laravel-shiprocket-api#contributors) 22 | 23 | ## Installation 24 | 25 | You can install the package via composer: 26 | 27 | ```bash 28 | composer require seshac/laravel-shiprocket-api 29 | ``` 30 | 31 | You can publish config file with: 32 | 33 | ```bash 34 | php artisan vendor:publish --provider="Seshac\Shiprocket\ShiprocketServiceProvider" --tag="config" 35 | ``` 36 | 37 | ## This is the contents of the published config file: 38 | ```php 39 | return [ 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Default Shiprocket Credentilas 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Here you can set the default shiprocket credentilas. However, you can pass the credentials while connecting to shiprocket client 46 | | 47 | */ 48 | 49 | 'credentials' => [ 50 | 'email' => env('SHIPROCKET_EMAIL', 'example@email.com'), 51 | 'password' => env('SHIPROCKET_PASSWORD', 'password'), 52 | ], 53 | 54 | 55 | /* 56 | |-------------------------------------------------------------------------- 57 | | Default output response type 58 | |-------------------------------------------------------------------------- 59 | | 60 | | Here you may specify which of the output response you need. 61 | | 62 | | Supported: "collection" , "object", "array" 63 | | 64 | */ 65 | 66 | 'responseType' => 'collection', 67 | ]; 68 | ``` 69 | 70 | 71 | ## Authentication 72 | https://apidocs.shiprocket.in/?version=latest#8a56b4d6-b418-43cf-be25-ead62532aa18 73 | 74 | ##### Get the login details 75 | ```php 76 | use Seshac\Shiprocket\Shiprocket; 77 | . 78 | . 79 | . 80 | 81 | $loginDetails = Shiprocket::login([ 82 | 'email' => 'yourAPiMail@example.com', 83 | 'password' => 'example' 84 | ]) 85 | // if you added credentials at shiprocket.php config file no need to pass credentials 86 | ``` 87 | Or 88 | ##### Get the Token directly 89 | ```php 90 | use Seshac\Shiprocket\Shiprocket; 91 | . 92 | . 93 | . 94 | 95 | $token = Shiprocket::getToken();// if you added credentials at shiprocket.php config 96 | ``` 97 | 98 | 99 | ## Orders 100 | 101 | #### get all Orders 102 | https://apidocs.shiprocket.in/?version=latest#d4f48023-b0b2-40af-8072-1adf97227d21 103 | ```php 104 | $token = Shiprocket::getToken(); 105 | $orderDetails = [ 106 | // refer above url for required parameters 107 | 'per_page'=>20, 108 | ]; 109 | $response = Shiprocket::order($token)->getOrders($orderDetails); 110 | 111 | ``` 112 | 113 | #### Get specific Order 114 | https://apidocs.shiprocket.in/?version=latest#aa23cc40-6ee8-4ce0-b0ab-1a7291514299 115 | ```php 116 | $token = Shiprocket::getToken(); 117 | $orderId = 16167171; 118 | $response = Shiprocket::order($token)->find($orderId); 119 | 120 | ``` 121 | 122 | #### Create Custom Order 123 | https://apidocs.shiprocket.in/?version=latest#247e58f3-37f3-4dfb-a4bb-b8f6ab6d41ec 124 | ```php 125 | $orderDetails = [ 126 | // refer above url for required parameters 127 | ]; 128 | $token = Shiprocket::getToken(); 129 | $response = Shiprocket::order($token)->create($orderDetails); 130 | ``` 131 | 132 | #### Create Channel Specific Order 133 | https://apidocs.shiprocket.in/?version=latest#45126d19-74ed-4cf5-9447-8ac1041bbb3c 134 | ```php 135 | $orderDetails = [ 136 | // refer above url for required parameters 137 | ]; 138 | 139 | $channelSpecificOrder = true; 140 | 141 | $response = Shiprocket::order($token)->create($orderDetails,$channelSpecificOrder); 142 | ``` 143 | 144 | #### Create quick order ( Wrapper API ) 145 | This is an all in one API to create an order, ship the order, add a new pickup location and generate label along with the manifest for the same. 146 | Create, Ship and Generate Label and Manifest for Order 147 | 148 | https://apidocs.shiprocket.in/?version=latest#7bd788f4-63ba-49c3-889e-960a379d090f 149 | ```php 150 | $orderDetails = [ 151 | // refer aboce url for required parameters 152 | ]; 153 | $response = Shiprocket::order($token)->quickCreate($orderDetails); 154 | ``` 155 | 156 | #### Cancel an order 157 | https://apidocs.shiprocket.in/?version=latest#5c0e41ca-d868-44c4-8ddb-73a8de239401 158 | ```php 159 | $ids = [12345,12346]; 160 | $response = Shiprocket::order($token)->cancel(['ids' => $ids]); 161 | ``` 162 | 163 | ### Update pickup location 164 | https://apidocs.shiprocket.in/?version=latest#4ba045ab-e25b-4bb1-adbd-37bbd07b354e 165 | ```php 166 | $orderDetails = [ 167 | 'order_id' => [12345,123456 ] 168 | 'pickup_location' => 'location name' 169 | ]; 170 | $response = Shiprocket::order($token)->updatePickupLocation($orderDetails); 171 | ``` 172 | 173 | 174 | ## Couriers 175 | Use these API's to assign AWB to your order, check for courier serviceability, and request for the pickup of your order. 176 | https://apidocs.shiprocket.in/?version=latest#a091dfc1-f882-466a-96a1-e245d3c80c5b 177 | #### Generate AWB for Shipment 178 | https://apidocs.shiprocket.in/?version=latest#b267ca9a-f7aa-4edc-8477-7dc15e46e08a 179 | ```php 180 | $data = [ 181 | 'shipment_id' => '', 182 | 'courier_id' => '' 183 | ]; 184 | $response = Shiprocket::courier($token)->generateAWB($data); 185 | // for more details visit above url 186 | ``` 187 | #### Check Courier Serviceability 188 | https://apidocs.shiprocket.in/?version=latest#29ff5116-0917-41ba-8c82-638412604916 189 | ```php 190 | $pincodeDetails = [ 191 | // for paramets refer obove url. 192 | ]; 193 | $response = Shiprocket::courier($token)->checkServiceability($pincodeDetails); 194 | ``` 195 | 196 | #### Check International Courier Serviceability 197 | https://apidocs.shiprocket.in/?version=latest#6d1f2fb0-43c1-434f-8c93-50674a0b59ef 198 | ```php 199 | $pincodeDetails = [ 200 | // for paramets refer obove url. 201 | ]; 202 | $response = Shiprocket::courier($token)->checkInterNationalServiceability($pincodeDetails); 203 | ``` 204 | #### Request for Shipments Pickup 205 | https://apidocs.shiprocket.in/?version=latest#9f42cdfd-a055-4934-a0f4-86764f87c80d 206 | ```php 207 | $pickupDetails = [ 208 | // for paramets refer obove url. 209 | ]; 210 | $response = Shiprocket::courier($token)->requestPickup($pickupDetails); 211 | ``` 212 | 213 | 214 | ## Shipments 215 | https://apidocs.shiprocket.in/?version=latest#0f9a75fd-6d23-453c-a3d7-85857e8c8759 216 | 217 | #### Get the all shipment details 218 | https://apidocs.shiprocket.in/?version=latest#a9913eaf-94ba-4012-a105-9687fddc7221 219 | ```php 220 | $filterParam = []; // you can use sort, sort_by, filter,filter_by 221 | $shipments = Shiprocket::shipment($token)->get(); 222 | ``` 223 | #### Get the details of a specific Shipment 224 | https://apidocs.shiprocket.in/?version=latest#5f9bced5-4f16-4868-be55-a8c0215d0711 225 | ```php 226 | $shipemntId = 1232122; 227 | $shipments = Shiprocket::shipment($token)->getSpecific($shipemntId); 228 | ``` 229 | 230 | 231 | ## Tracking 232 | Use these API's to get the tracking details of your shipments through the AWB code or the Shipment ID. 233 | https://apidocs.shiprocket.in/?version=latest#62304450-5d27-4a28-929f-6c68d08040aa 234 | 235 | #### Get Tracking through AWB 236 | https://apidocs.shiprocket.in/?version=latest#f2ac0962-4c34-4fe4-8266-50f8a1e8eab0 237 | ```php 238 | $awb = 1234444222; 239 | $response = Shiprocket::track($token)->throughAwb($awb); 240 | ``` 241 | 242 | #### Get Tracking Data for Multiple AWBS 243 | https://apidocs.shiprocket.in/?version=latest#cf273e6a-08d0-4624-bf7a-7510c28292e0 244 | ``` php 245 | $awbs = ["788830567028","788829354408"]; 246 | $response = Shiprocket::track($token)->throwMultipleAwb($awb); 247 | ``` 248 | 249 | #### Get Tracking through Shipment ID 250 | https://apidocs.shiprocket.in/?version=latest#89005f4f-2b2f-473d-95b0-f54665a16b42 251 | ```php 252 | $shipmentId = 123213; 253 | $response = Shiprocket::track($token)->throwShipmentId($shipmentId); 254 | ``` 255 | 256 | #### Get Tracking Data through Order iD 257 | https://apidocs.shiprocket.in/?version=latest#bfcf3357-4e39-4134-831a-1ff33f67205e 258 | 259 | ```php 260 | $orderId = 123213; 261 | $channelID = 121; //optional 262 | $shipment = Shiprocket::track($token)->throwOrderId($orderId,$channelID); 263 | ``` 264 | 265 | 266 | ## Pickup-Addresses 267 | https://apidocs.shiprocket.in/?version=latest#6949d954-d0ba-4749-99aa-2435ab7aaf4f 268 | 269 | #### Add a New Pickup Location 270 | https://apidocs.shiprocket.in/?version=latest#6fbe81f5-c3d5-462e-b18f-d6316dde7779 271 | ```php 272 | $newLocation = []; //Refer the above url for required parameteres 273 | $location = Shiprocket::pickup($token)->addLocation($newLocation); 274 | ``` 275 | 276 | #### Get All Pickup Locations 277 | https://apidocs.shiprocket.in/?version=latest#3bd67de6-8f00-435f-a708-c0c3ab252fee 278 | ```php 279 | $location = Shiprocket::pickup($token)->getLocations(); 280 | ``` 281 | 282 | 283 | ## Channels 284 | https://apidocs.shiprocket.in/?version=latest#6233e207-6de3-4960-a59c-b34ebe3fe33d 285 | 286 | #### To get details about all the integrated channels 287 | https://apidocs.shiprocket.in/?version=latest#b9b9bcbe-923c-4ccd-a46e-d9f089622a80 288 | ```php 289 | $channels = Shiprocket::channel($token)->get(); 290 | ``` 291 | 292 | ## Manifest/Generate-Labels/Print-Invoice 293 | https://apidocs.shiprocket.in/?version=latest#a9f708ec-5861-43b9-a510-8c1bba074cb5 294 | 295 | #### Generate the manifest of orders using shipment Id's 296 | https://apidocs.shiprocket.in/?version=latest#dc281151-33e6-485f-a76a-015d8d36b49f 297 | ```php 298 | $shipmentIds = [ 'shipment_id' => [121221,122112] ]; 299 | $manifestDetails = Shiprocket::generate($token)->manifest(shipmentIds); 300 | ``` 301 | 302 | #### Print the Manifest (Mnaifest needs to be generated first in order for this API to print it. Use the 'Generate Manifest' API to do the same) 303 | https://apidocs.shiprocket.in/?version=latest#dd1e168b-6bb2-45b9-a930-68cae3cbe97c 304 | ```php 305 | $orderIds = [ 'order_ids' => [121221,122112] ]; 306 | $response = Shiprocket::generate($token)->printManifest(orderIds); 307 | ``` 308 | #### Generate the label of an order by passing the shipment id in the form of an array 309 | https://apidocs.shiprocket.in/?version=latest#4dfcbd78-4789-4680-82bf-9ff07f56d34e 310 | ```php 311 | $shipmentIds = [ 'shipment_id' => [121221,122112] ]; 312 | $response = Shiprocket::generate($token)->label(shipmentIds); 313 | ``` 314 | 315 | #### Generate the invoice for you're order. 316 | https://apidocs.shiprocket.in/?version=latest#421f997f-1216-41e0-8c9b-433ddb666ad4 317 | ```php 318 | $orderIds = [ 'ids' => [121221,122112] ]; 319 | $response = Shiprocket::generate($token)->invoice(orderIds); 320 | ``` 321 | 322 | ## Products 323 | https://apidocs.shiprocket.in/?version=latest#5046ae90-2014-4453-90d5-2ce776567f47 324 | 325 | #### Get the all products 326 | https://apidocs.shiprocket.in/?version=latest#0b8d1f26-3abd-4f4e-9cd8-3928bcfcf30b 327 | ```php 328 | $filterParam = []; // you can use sort, sort_by, filter,filter_by 329 | $shipments = Shiprocket::product($token)->get(); 330 | ``` 331 | #### Get the details of a specific Product 332 | https://apidocs.shiprocket.in/?version=latest#134f7710-660c-464f-b579-6da46ba9402f 333 | ```php 334 | $productId = 1232122; 335 | $shipments = Shiprocket::product($token)->getSpecific($productId); 336 | ``` 337 | #### Add New Products 338 | https://apidocs.shiprocket.in/?version=latest#344b789d-584e-486a-a7a9-0cf33ce52bf3 339 | ```php 340 | $productDetails = [ 341 | // refer above url for required parameters 342 | ]; 343 | $response = Shiprocket::product($token)->create($productDetails); 344 | ``` 345 | 346 | ## NDR Shipments 347 | 348 | #### Where you can get all the shipments that's are in NDR status 349 | 350 | ```php 351 | 352 | $response = Shiprocket::ndr($this->token)->getShipments(); 353 | 354 | // EX : GET : https://apiv2.shiprocket.in/v1/external/ndr/all where you can get all the shipments that are in NDR. 355 | ``` 356 | 357 | 358 | #### Where you can information of specific AWB which is in NDR 359 | 360 | ```php 361 | $awb_code = '0212331233322'; 362 | $response = Shiprocket::ndr($this->token)->getSpecificShipment($awb_code); 363 | 364 | // GET : https://apiv2.shiprocket.in/v1/external/ndr/{AWB} Where you can information of specific AWB which is in NDR 365 | ``` 366 | 367 | #### For open NDR where you can take action such as Reattempt, RTO : 368 | 369 | ```php 370 | $shipmentDetails = ['awb' => '', 'address_1' => '', 'address2' => '', 'phone' => '']; 371 | $response = Shiprocket::ndr($this->token)->reattempt($shipmentDetails); 372 | 373 | // POST : https://apiv2.shiprocket.in/v1/external/ndr/reattempt?awb=190729394&address1=Dr Nageshwar&address2=opposite Ashok Nagar&phone=9534952626&deferred_date=2020-08-27 374 | ``` 375 | 376 | 377 | ## Warehouse 378 | 379 | #### Check Warehouse SRF serviceabbility 380 | 381 | ```php 382 | $filterParam = [ 383 | 'postcode' => 110030, // Delivery Post Code 384 | 'sku' => "SKU name", 385 | 'quantity' => 1, //Quantity in numbers 386 | ]; 387 | $response = Shiprocket::warehouse($this->token)->checkServiceability($filterParam); 388 | 389 | // EX : https://apiv2.shiprocket.in/v1/warehouse/srf-serviceability?postcode=784001&sku=Baby-socket&quantity=1 390 | // Response : ['serviceability'=>true,'etd'=>'2020-12-06'] 391 | ``` 392 | 393 | ## Changelog 394 | 395 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 396 | 397 | ## Contributing 398 | 399 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 400 | 401 | ## Credits 402 | 403 | - [Sesha](https://github.com/seshac) 404 | - [All Contributors](../../contributors) 405 | 406 | ## Please feel free to contact me if you find any bug or create an issue for that!. 407 | 408 | ## License 409 | 410 | The MIT License (MIT). Please see [License File](LICENSE) for more information. 411 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "seshac/laravel-shiprocket-api", 3 | "description": "Shiprocket API (V1) Laravel SDK. Integration of Shiprocket API in your laravel application is easy, This package enables you to utilize most of your Shiprocket functions.", 4 | "keywords": [ 5 | "sesha", 6 | "laravel Shiprcoket Api", 7 | "Laravel Shiprocket Wrapper", 8 | "Shiprocket SDK Module" 9 | ], 10 | "homepage": "https://github.com/seshac/laravel-shiprocket-api", 11 | "license": "MIT", 12 | "authors": [{ 13 | "name": "Sesha", 14 | "email": "seshadriece008@gmail.com", 15 | "homepage": "https://sesha.in", 16 | "role": "Developer" 17 | }], 18 | "require": { 19 | "php": "^7.3|^8.0" 20 | }, 21 | "require-dev": { 22 | "orchestra/testbench": "^6.0", 23 | "phpunit/phpunit": "^9.3" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "Seshac\\Shiprocket\\": "src" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Seshac\\Shiprocket\\Tests\\": "tests" 33 | } 34 | }, 35 | "scripts": { 36 | "test": "vendor/bin/phpunit", 37 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage", 38 | "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" 39 | }, 40 | "config": { 41 | "sort-packages": true 42 | }, 43 | "extra": { 44 | "laravel": { 45 | "providers": [ 46 | "Seshac\\Shiprocket\\ShiprocketServiceProvider" 47 | ], 48 | "aliases": { 49 | "Shiprocket": "Seshac\\Shiprocket\\Shiprocket" 50 | } 51 | } 52 | }, 53 | "minimum-stability": "dev", 54 | "prefer-stable": true 55 | } -------------------------------------------------------------------------------- /config/shiprocket.php: -------------------------------------------------------------------------------- 1 | [ 14 | 'email' => env('SHIPROCKET_EMAIL', 'youemail@email.com'), 15 | 'password' => env('SHIPROCKET_PASSWORD', 'secret'), 16 | ], 17 | 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Default output response type 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may specify which of the output response you need. 25 | | 26 | | Supported: "collection" , "object", "array" 27 | | 28 | */ 29 | 30 | 'responseType' => 'collection', 31 | ]; 32 | -------------------------------------------------------------------------------- /phpunit.xml.dist.bak: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | tests/Unit 15 | 16 | 17 | tests/Feature 18 | 19 | 20 | 21 | 22 | src/ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/Clients/Client.php: -------------------------------------------------------------------------------- 1 | responseType = config('shiprocket.responseType'); 18 | } 19 | 20 | /** 21 | * set the endpoint 22 | * 23 | * @param string $endpoint 24 | * @return object $this 25 | */ 26 | public function setEndpoint(string $endpoint): object 27 | { 28 | if (strpos($endpoint, 'warehouse') === false) { 29 | $this->endpoint = $this->url . 'external/' .$endpoint; 30 | } else { 31 | $this->endpoint = $this->url .$endpoint; 32 | } 33 | 34 | return $this; 35 | } 36 | 37 | /** 38 | * set the header 39 | * 40 | * @param string $token 41 | * @return object 42 | */ 43 | public function setHeaders(string $token): object 44 | { 45 | $this->headers = [ "Content-Type: application/json" ]; 46 | if ($token != 'login') { 47 | array_push($this->headers, "Authorization: Bearer {$token}"); 48 | } 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * Send the data using post request 55 | * 56 | * @param array $data 57 | * @return mixed 58 | */ 59 | public function post(array $data, $type = "POST") 60 | { 61 | $curl = curl_init(); 62 | 63 | curl_setopt_array($curl, [ 64 | CURLOPT_URL => $this->endpoint, 65 | CURLOPT_RETURNTRANSFER => true, 66 | CURLOPT_ENCODING => "", 67 | CURLOPT_MAXREDIRS => 10, 68 | CURLOPT_TIMEOUT => 0, 69 | CURLOPT_FOLLOWLOCATION => true, 70 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 71 | CURLOPT_CUSTOMREQUEST => $type, 72 | CURLOPT_POSTFIELDS => json_encode($data), 73 | CURLOPT_HTTPHEADER => $this->headers, 74 | ]); 75 | 76 | $response = curl_exec($curl); 77 | 78 | if (! $this->isValid($response)) { 79 | $response = json_encode([ 'curl_error' => curl_error($curl) ]); 80 | } 81 | 82 | curl_close($curl); 83 | 84 | return $this->responseType($response); 85 | } 86 | 87 | /** 88 | * Send a data using PATCH Request 89 | * 90 | * @param array $data 91 | * @return mixed 92 | */ 93 | public function patch(array $data) 94 | { 95 | return $this->post($data, 'PATCH'); 96 | } 97 | 98 | /** 99 | * get the requested data using get request 100 | * 101 | * @return mixed 102 | */ 103 | public function get() 104 | { 105 | $curl = curl_init(); 106 | 107 | curl_setopt_array($curl, [ 108 | CURLOPT_URL => $this->endpoint, 109 | CURLOPT_RETURNTRANSFER => true, 110 | CURLOPT_ENCODING => "", 111 | CURLOPT_MAXREDIRS => 10, 112 | CURLOPT_TIMEOUT => 0, 113 | CURLOPT_FOLLOWLOCATION => true, 114 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 115 | CURLOPT_CUSTOMREQUEST => "GET", 116 | CURLOPT_HTTPHEADER => $this->headers, 117 | ]); 118 | 119 | $response = curl_exec($curl); 120 | 121 | if (! $this->isValid($response)) { 122 | $response = json_encode(['curl_error' => curl_error($curl)]); 123 | } 124 | 125 | curl_close($curl); 126 | 127 | return $this->responseType($response); 128 | } 129 | 130 | /** 131 | * Check the return data is valid 132 | * 133 | * @param mixed $string 134 | * @return bool 135 | */ 136 | private function isValid($string): bool 137 | { 138 | if (! $string) { 139 | return false; 140 | } 141 | 142 | return json_decode($string) ? true : false; 143 | } 144 | 145 | /** 146 | * Return the response type based on config responseType 147 | * 148 | * @param $response 149 | * @return mixed 150 | */ 151 | private function responseType($response) 152 | { 153 | if ($this->responseType == 'collection') { 154 | return collect(json_decode($response, true)); 155 | } 156 | 157 | if ($this->responseType == 'object') { 158 | return json_decode($response); 159 | } 160 | 161 | return json_decode($response, true); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/Commands/SketchCommand.php: -------------------------------------------------------------------------------- 1 | comment('All done'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Exceptions/ShiprocketException.php: -------------------------------------------------------------------------------- 1 | getRequest($endpoint); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Resources/CourierResource.php: -------------------------------------------------------------------------------- 1 | postRequest($endpoint, $data); 18 | } 19 | 20 | /** 21 | * Check the Serviceability for local pincode 22 | * 23 | * @param array $data 24 | * @return mixed 25 | */ 26 | public function checkServiceability(array $data) 27 | { 28 | $endpoint = 'courier/serviceability/?' . http_build_query($data); 29 | 30 | return $this->getRequest($endpoint); 31 | } 32 | 33 | /** 34 | * Check International Courier Serviceability 35 | * 36 | * @param array $params 37 | * @return mixed 38 | */ 39 | public function checkInterNationalServiceability(array $params) 40 | { 41 | $endpoint = 'courier/international/serviceability/?' . http_build_query($params); 42 | 43 | return $this->getRequest($endpoint); 44 | } 45 | 46 | /** 47 | * Request for Shipments Pickup 48 | * 49 | * @param array $data 50 | * @return mixed 51 | */ 52 | public function requestPickup(array $pickupDetails) 53 | { 54 | $endpoint = 'courier/generate/pickup'; 55 | 56 | return $this->postRequest($endpoint, $pickupDetails); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Resources/GenerateResource.php: -------------------------------------------------------------------------------- 1 | postRequest($endpoint, $shipmentIds); 18 | } 19 | 20 | /** 21 | * Print the Manifest (Mnaifest needs to be generated first in order for this API to print it. Use the 'Generate Manifest' API to do the same) 22 | * 23 | * @param array $orderIds 24 | * @return mixed 25 | */ 26 | public function printManifest(array $orderIds) 27 | { 28 | $endpoint = 'manifests/print'; 29 | 30 | return $this->postRequest($endpoint, $orderIds); 31 | } 32 | 33 | /** 34 | * Generate the label of an order by passing the shipment id in the form of an array 35 | * 36 | * @param array $shipmentIds 37 | * @return mixed 38 | */ 39 | public function label(array $shipmentIds) 40 | { 41 | $endpoint = 'courier/generate/label'; 42 | 43 | return $this->postRequest($endpoint, $shipmentIds); 44 | } 45 | 46 | /** 47 | * Generate the invoice for you're order. 48 | * 49 | * @param array $orderIds 50 | * @return mixed 51 | */ 52 | public function invoice(array $orderIds) 53 | { 54 | $endpoint = 'orders/print/invoice'; 55 | 56 | return $this->postRequest($endpoint, $orderIds); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Resources/NdrResource.php: -------------------------------------------------------------------------------- 1 | getRequest($endpoint); 17 | } 18 | 19 | /** 20 | * Get the information about specific AWB which is in NDR 21 | * 22 | * @param string $awb 23 | * @return mixed 24 | */ 25 | public function getSpecificShipment(string $awb) 26 | { 27 | $endpoint = "ndr/$awb"; 28 | 29 | return $this->getRequest($endpoint); 30 | } 31 | 32 | /** 33 | * For open NDR where you can take action such as Reattempt, RTO. 34 | * @example https://apiv2.shiprocket.in/v1/external/ndr/reattempt?awb=190729394&address1=Dr Nageshwar&address2=opposite Ashok Nagar&phone=9534952626&deferred_date=2020-08-27 35 | * 36 | * @param array $shipmentDetails 37 | * @return mixed 38 | */ 39 | public function reattempt(array $shipmentDetails) 40 | { 41 | $endpoint = 'ndr/reattempt'; 42 | 43 | return $this->postRequest($endpoint, $shipmentDetails); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Resources/OrderResource.php: -------------------------------------------------------------------------------- 1 | postRequest($endpoint, $order); 19 | } 20 | 21 | /** 22 | * Create a custom or channel specific order 23 | * 24 | * @param array $order 25 | * @param bool $channelSpecificOrder 26 | * @return mixed 27 | */ 28 | public function create(array $order, bool $channelSpecificOrder = false) 29 | { 30 | if ($channelSpecificOrder) { 31 | $endpoint = 'orders/create'; 32 | } else { 33 | $endpoint = 'orders/create/adhoc'; 34 | } 35 | 36 | return $this->postRequest($endpoint, $order); 37 | } 38 | 39 | /** 40 | * Cancel an Order 41 | * 42 | * @param array $ids 43 | * @return mixed 44 | */ 45 | public function cancel(array $ids) 46 | { 47 | $endpoint = 'orders/cancel'; 48 | 49 | return $this->postRequest($endpoint, $ids); 50 | } 51 | 52 | /** 53 | * Update the pickup location 54 | * 55 | * @param array $data 56 | * @return mixed 57 | */ 58 | public function updatePickupLocation(array $data) 59 | { 60 | $endpoint = 'orders/address/pickup'; 61 | 62 | return $this->patchRequest($endpoint, $data); 63 | } 64 | 65 | /** 66 | * Use this API to do multiple tasks in one go, namely getting order, 67 | * just pass parameter and u will get result 68 | * https://apidocs.shiprocket.in/#d4f48023-b0b2-40af-8072-1adf97227d21 69 | * @param array $param 70 | * @return mixed 71 | */ 72 | public function getOrders(array $param) 73 | { 74 | $endpoint = 'orders'; 75 | if ($param) { 76 | $endpoint = $endpoint . '?' . http_build_query($param); 77 | } 78 | 79 | return $this->getRequest($endpoint, $param); 80 | } 81 | 82 | /** 83 | * Use this API to get a single order by order id 84 | * https://apidocs.shiprocket.in/?version=latest#aa23cc40-6ee8-4ce0-b0ab-1a7291514299 85 | * @param int $id 86 | * @return mixed 87 | */ 88 | public function find(int $id) 89 | { 90 | $endpoint = "orders/show/$id"; 91 | 92 | return $this->getRequest($endpoint); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Resources/PickupResource.php: -------------------------------------------------------------------------------- 1 | postRequest($endpoint, $location); 18 | } 19 | 20 | /** 21 | * Get All Pickup Locations 22 | * 23 | * @return mixed 24 | */ 25 | public function getLocations() 26 | { 27 | $endpoint = 'settings/company/pickup'; 28 | 29 | return $this->getRequest($endpoint); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Resources/ProductResource.php: -------------------------------------------------------------------------------- 1 | getRequest($endpoint); 22 | } 23 | 24 | /** 25 | * Get the details of a specific Product 26 | * 27 | * @param string $productId 28 | * @return mixed 29 | */ 30 | public function getSpecific(string $productId) 31 | { 32 | $endpoint = 'products/show/' . $productId; 33 | 34 | return $this->getRequest($endpoint); 35 | } 36 | 37 | /** 38 | * Add New Products 39 | * 40 | * @param array $productDetails 41 | * @return mixed 42 | */ 43 | public function create(array $productDetails) 44 | { 45 | $endpoint = "products"; 46 | 47 | return $this->postRequest($endpoint, $productDetails); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Resources/Resource.php: -------------------------------------------------------------------------------- 1 | client = $client; 16 | $this->token = $token; 17 | } 18 | 19 | public function getRequest(string $endpoint) 20 | { 21 | return $this->client->setEndpoint($endpoint) 22 | ->setHeaders($this->token) 23 | ->get(); 24 | } 25 | 26 | public function postRequest(string $endpoint, array $params) 27 | { 28 | return $this->client->setEndpoint($endpoint) 29 | ->setHeaders($this->token) 30 | ->post($params); 31 | } 32 | 33 | public function patchRequest(string $endpoint, array $params) 34 | { 35 | return $this->client->setEndpoint($endpoint) 36 | ->setHeaders($this->token) 37 | ->patch($params); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Resources/ResourceInterface.php: -------------------------------------------------------------------------------- 1 | getRequest($endpoint); 22 | } 23 | 24 | /** 25 | * Get the details of a specific Shipment 26 | * 27 | * @param string $shipmentId 28 | * @return mixed 29 | */ 30 | public function getSpecific(string $shipmentId) 31 | { 32 | $endpoint = 'shipments/' . $shipmentId; 33 | 34 | return $this->getRequest($endpoint); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Resources/TrackingResource.php: -------------------------------------------------------------------------------- 1 | getRequest($endpoint); 17 | } 18 | 19 | /** 20 | * Get the tracking details of multiple shipments by using AWB codes together as an array. 21 | * 22 | * @param array $data 23 | * @return mixed 24 | */ 25 | public function throwMultipleAwb(array $awbs) 26 | { 27 | $endpoint = 'courier/track/awbs'; 28 | 29 | return $this->postRequest($endpoint, $awbs); 30 | } 31 | 32 | /** 33 | * Get the tracking details of shipment by using the ShipmentId 34 | * 35 | * @param string $shipmentId 36 | * @return mixed 37 | */ 38 | public function throwShipmentId(string $shipmentId) 39 | { 40 | $endpoint = 'courier/track/shipment/' . $shipmentId; 41 | 42 | return $this->getRequest($endpoint); 43 | } 44 | 45 | /** 46 | * Get the tracking details of shipment by using the OrderId 47 | * 48 | * @param string $orderId 49 | * @param string $channelId 50 | * @return mixed 51 | */ 52 | public function throwOrderId(string $orderId, string $channelId = null) 53 | { 54 | $endpoint = 'courier/track?order_id='. $orderId; 55 | if ($channelId) { 56 | $endpoint = $endpoint . '&channel_id=' . $channelId; 57 | } 58 | 59 | return $this->getRequest($endpoint); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Resources/WarehouseResource.php: -------------------------------------------------------------------------------- 1 | getRequest($endpoint); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Shiprocket.php: -------------------------------------------------------------------------------- 1 | client = $client; 27 | } 28 | 29 | /** 30 | * Get the login details including token (valid for 24 hours) 31 | * 32 | * @param array $credentials 33 | * @return mixed 34 | */ 35 | public function login($credentials = null) 36 | { 37 | return $this->auth($this->client, $credentials); 38 | } 39 | 40 | /** 41 | * Get the auth token (valid for 24 hours) 42 | * 43 | * @param array $credentials 44 | * @return string 45 | */ 46 | public function getToken($credentials = null) 47 | { 48 | return $this->auth($this->client, $credentials) 49 | ->get('token'); 50 | } 51 | 52 | /** 53 | * Order related wrapper class 54 | * 55 | * @param string $token 56 | * @return mixed 57 | */ 58 | public function order(string $token) 59 | { 60 | return new OrderResource($this->client, $token); 61 | } 62 | 63 | /** 64 | * Pickup related wrapper class 65 | * 66 | * @param string $token 67 | * @return mixed 68 | */ 69 | public function pickup(string $token) 70 | { 71 | return new PickupResource($this->client, $token); 72 | } 73 | 74 | /** 75 | * Courier related wrapper class 76 | * 77 | * @param string $token 78 | * @return mixed 79 | */ 80 | public function courier(string $token) 81 | { 82 | return new CourierResource($this->client, $token); 83 | } 84 | 85 | /** 86 | * Tracking related wrapper class 87 | * 88 | * @param string $token 89 | * @return mixed 90 | */ 91 | public function track(string $token) 92 | { 93 | return new TrackingResource($this->client, $token); 94 | } 95 | 96 | /** 97 | * Channel related wrapper class 98 | * 99 | * @param string $token 100 | * @return mixed 101 | */ 102 | public function channel(string $token) 103 | { 104 | return new ChannelResource($this->client, $token); 105 | } 106 | 107 | /** 108 | * Shipment related wrapper class 109 | * 110 | * @param string $token 111 | * @return mixed 112 | */ 113 | public function shipment(string $token) 114 | { 115 | return new ShipmentResource($this->client, $token); 116 | } 117 | 118 | /** 119 | * Print manifest/labels related wrapper class 120 | * 121 | * @param string $token 122 | * @return mixed 123 | */ 124 | public function generate(string $token) 125 | { 126 | return new GenerateResource($this->client, $token); 127 | } 128 | 129 | /** 130 | * Product related wrapper class 131 | * 132 | * @param string $token 133 | * @return mixed 134 | */ 135 | public function product(string $token) 136 | { 137 | return new ProductResource($this->client, $token); 138 | } 139 | 140 | /** 141 | * Courier related wrapper class 142 | * 143 | * @param string $token 144 | * @return mixed 145 | */ 146 | public function warehouse(string $token) 147 | { 148 | return new WarehouseResource($this->client, $token); 149 | } 150 | 151 | /** 152 | * NDR related wrapper class 153 | * 154 | * @param string $token 155 | * @return mixed 156 | */ 157 | public function ndr(string $token) 158 | { 159 | return new NdrResource($this->client, $token); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/ShiprocketServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 12 | $this->publishes([ 13 | __DIR__.'/../config/shiprocket.php' => config_path('shiprocket.php'), 14 | ], 'config'); 15 | } 16 | } 17 | 18 | public function register() 19 | { 20 | $this->app->alias(ShiprocketApi::class, 'shiprocket'); 21 | $this->mergeConfigFrom(__DIR__.'/../config/shiprocket.php', 'shiprocket'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Traits/Authenticate.php: -------------------------------------------------------------------------------- 1 | setEndpoint($endpoint) 23 | ->setHeaders('login') 24 | ->post($credentials); 25 | 26 | return $authDetails; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Wrapper.php: -------------------------------------------------------------------------------- 1 |