diff --git a/getgologisticsapi/composer.json b/getgologisticsapi/composer.json deleted file mode 100644 index 380b45c..0000000 --- a/getgologisticsapi/composer.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "adityafullstackdeveloper/getgologisticsapi", - "description": "Getgologisticsapi API (V1) Laravel SDK.", - "keywords": [ - "getgologisticsapi", - "laravel getgologisticsapi Api", - "Laravel getgologisticsapi Wrapper", - "getgologisticsapi SDK Module" - ], - "homepage": "https://github.com/adityafullstackdeveloper/getgologisticsapi", - "license": "MIT", - "authors": [ - { - "name": "adityafullstackdeveloper", - "email": "adityafullstackdeveloper@gmail.com", - "homepage": "https://github.com/adityafullstackdeveloper", - "role": "Developer" - } - ], - "require": { - "php": "^7.2.5" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", - "orchestra/testbench": "^5.0", - "phpunit/phpunit": "^7.5|^9.0", - "psalm/plugin-laravel": "^1.2", - "vimeo/psalm": "^3.11" - }, - "autoload": { - "psr-4": { - "Adityafullstackdeveloper\\GetGoLogistics\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "Adityafullstackdeveloper\\GetGoLogistics\\Tests\\": "tests" - } - }, - "scripts": { - "psalm": "vendor/bin/psalm", - "test": "vendor/bin/phpunit", - "test-coverage": "vendor/bin/phpunit --coverage-html coverage", - "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" - }, - "config": { - "sort-packages": true - }, - "extra": { - "laravel": { - "providers": [ - "Adityafullstackdeveloper\\GetGoLogistics\\ShiprocketServiceProvider" - ], - "aliases": { - "Shiprocket": "Adityafullstackdeveloper\\GetGoLogistics\\GetGoLogistics" - } - } - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/getgologisticsapi/config/getgologistics.php b/getgologisticsapi/config/getgologistics.php deleted file mode 100644 index 15ed7a3..0000000 --- a/getgologisticsapi/config/getgologistics.php +++ /dev/null @@ -1,31 +0,0 @@ - [ - 'email' => env('SHIPROCKET_EMAIL', 'youemail@email.com'), - 'password' => env('SHIPROCKET_PASSWORD', 'secret'), - ], - - - /* - |-------------------------------------------------------------------------- - | Default output response type - |-------------------------------------------------------------------------- - | - | Here you may specify which of the output response you need. - | - | Supported: "collection" , "object", "array" - | - */ - - 'responseType' => 'collection', -]; diff --git a/getgologisticsapi/src/Clients/Client.php b/getgologisticsapi/src/Clients/Client.php deleted file mode 100644 index bc22154..0000000 --- a/getgologisticsapi/src/Clients/Client.php +++ /dev/null @@ -1,15 +0,0 @@ -responseType = config('getgologistics.responseType'); - } - - /** - * set the endpoint - * - * @param string $endpoint - * @return object $this - */ - public function setEndpoint(string $endpoint) :object - { - $this->endpoint = $this->url . $endpoint; - - return $this; - } - - /** - * set the header - * - * @param string $token - * @return object - */ - public function setHeaders(string $token) :object - { - $this->headers = [ "Content-Type: application/json" ]; - if ($token != 'login') { - array_push($this->headers, "Authorization: Bearer {$token}"); - } - - return $this; - } - - /** - * Send the data using post request - * - * @param array $data - * @return mixed - */ - public function post(array $data, $type = "POST") - { - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => $this->endpoint, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => $type, - CURLOPT_POSTFIELDS => json_encode($data), - CURLOPT_HTTPHEADER => $this->headers, - ]); - - $response = curl_exec($curl); - - if (! $this->isValid($response)) { - $response = json_encode([ 'curl_error' => curl_error($curl) ]); - } - - curl_close($curl); - - return $this->responseType($response); - } - - /** - * Send a data using PATCH Request - * - * @param array $data - * @return mixed - */ - public function patch(array $data) - { - return $this->post($data, 'PATCH'); - } - - /** - * get the requested data using get request - * - * @return mixed - */ - public function get() - { - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => $this->endpoint, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_HTTPHEADER => $this->headers, - ]); - - $response = curl_exec($curl); - - if (! $this->isValid($response)) { - $response = json_encode(['curl_error' => curl_error($curl)]); - } - - curl_close($curl); - - return $this->responseType($response); - } - - /** - * Check the return data is valid - * - * @param mixed $string - * @return bool - */ - private function isValid($string) :bool - { - if (! $string) { - return false; - } - - return json_decode($string) ? true : false; - } - - /** - * Return the response type based on config responseType - * - * @param $response - * @return mixed - */ - private function responseType($response) - { - if ($this->responseType == 'collection') { - return collect(json_decode($response, true)); - } - - if ($this->responseType == 'object') { - return json_decode($response); - } - - return json_decode($response, true); - } -} diff --git a/getgologisticsapi/src/Commands/SketchCommand.php b/getgologisticsapi/src/Commands/SketchCommand.php deleted file mode 100644 index a5f2eff..0000000 --- a/getgologisticsapi/src/Commands/SketchCommand.php +++ /dev/null @@ -1,17 +0,0 @@ -comment('All done'); - } -} diff --git a/getgologisticsapi/src/Exceptions/GetGoLogisticsException.php b/getgologisticsapi/src/Exceptions/GetGoLogisticsException.php deleted file mode 100644 index 893e426..0000000 --- a/getgologisticsapi/src/Exceptions/GetGoLogisticsException.php +++ /dev/null @@ -1,8 +0,0 @@ -client = $client; - } - - /** - * Get the login details including token (valid for 24 hours) - * - * @param array $credentials - * @return mixed - */ - public function login($credentials = null) - { - return $this->auth($this->client, $credentials); - } - - /** - * Get the auth token (valid for 24 hours) - * - * @param array $credentials - * @return string - */ - public function getToken($credentials = null) - { - return $this->auth($this->client, $credentials) - ->get('token'); - } - - /** - * Order related wrapper class - * - * @param string $token - * @return mixed - */ - public function order(string $token) - { - return new OrderResource($this->client, $token); - } - - /** - * Pickup related wrapper class - * - * @param string $token - * @return mixed - */ - public function pickup(string $token) - { - return new PickupResource($this->client, $token); - } - - /** - * Courier related wrapper class - * - * @param string $token - * @return mixed - */ - public function courier(string $token) - { - return new CourierResource($this->client, $token); - } - - /** - * Tracking related wrapper class - * - * @param string $token - * @return mixed - */ - public function track(string $token) - { - return new TrackingResource($this->client, $token); - } - - /** - * Channel related wrapper class - * - * @param string $token - * @return mixed - */ - public function channel(string $token) - { - return new ChannelResource($this->client, $token); - } - - /** - * Shipment related wrapper class - * - * @param string $token - * @return mixed - */ - public function shipment(string $token) - { - return new ShipmentResource($this->client, $token); - } - - /** - * Print manifest/labels related wrapper class - * - * @param string $token - * @return mixed - */ - public function generate(string $token) - { - return new GenerateResource($this->client, $token); - } - - /** - * Product related wrapper class - * - * @param string $token - * @return mixed - */ - public function product(string $token) - { - return new ProductResource($this->client, $token); - } -} diff --git a/getgologisticsapi/src/GetGoLogisticsServiceProvider.php b/getgologisticsapi/src/GetGoLogisticsServiceProvider.php deleted file mode 100644 index 4028ebc..0000000 --- a/getgologisticsapi/src/GetGoLogisticsServiceProvider.php +++ /dev/null @@ -1,24 +0,0 @@ -app->runningInConsole()) { - $this->publishes([ - __DIR__.'/../config/getgologistics.php' => config_path('getgologistics.php'), - ], 'config'); - } - } - - public function register() - { - $this->app->alias(GetGoLogisticsApi::class, 'getgologistics'); - $this->mergeConfigFrom(__DIR__.'/../config/getgologistics.php', 'getgologistics'); - } - } diff --git a/getgologisticsapi/src/Resources/ChannelResource.php b/getgologisticsapi/src/Resources/ChannelResource.php deleted file mode 100644 index 6f8378b..0000000 --- a/getgologisticsapi/src/Resources/ChannelResource.php +++ /dev/null @@ -1,20 +0,0 @@ -getRequest($endpoint); - } -} diff --git a/getgologisticsapi/src/Resources/CourierResource.php b/getgologisticsapi/src/Resources/CourierResource.php deleted file mode 100644 index 34da0de..0000000 --- a/getgologisticsapi/src/Resources/CourierResource.php +++ /dev/null @@ -1,59 +0,0 @@ -postRequest($endpoint, $data); - } - - /** - * Check the serviability for local pincode - * - * @param array $data - * @return mixed - */ - public function checkServiceability(array $data) - { - $endpoint = 'courier/serviceability/?' . http_build_query($data); - - return $this->getRequest($endpoint); - } - - /** - * Check International Courier Serviceability - * - * @param array $params - * @return mixed - */ - public function checkInterNationalServiceability(array $params) - { - $endpoint = 'courier/international/serviceability/?'. http_build_query($params); - - return $this->getRequest($endpoint); - } - - /** - * Request for Shipments Pickup - * - * @param array $data - * @return mixed - */ - public function requestPickup(array $pickupDetails) - { - $endpoint = 'courier/generate/pickup'; - - return $this->postRequest($endpoint, $pickupDetails); - } -} diff --git a/getgologisticsapi/src/Resources/GenerateResource.php b/getgologisticsapi/src/Resources/GenerateResource.php deleted file mode 100644 index a6f3b45..0000000 --- a/getgologisticsapi/src/Resources/GenerateResource.php +++ /dev/null @@ -1,59 +0,0 @@ -postRequest($endpoint, $shipmentIds); - } - - /** - * 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) - * - * @param array $orderIds - * @return mixed - */ - public function printManifest(array $orderIds) - { - $endpoint = 'manifests/print'; - - return $this->postRequest($endpoint, $orderIds); - } - - /** - * Generate the label of an order by passing the shipment id in the form of an array - * - * @param array $shipmentIds - * @return mixed - */ - public function label(array $shipmentIds) - { - $endpoint = 'courier/generate/label'; - - return $this->postRequest($endpoint, $shipmentIds); - } - - /** - * Generate the invoice for you're order. - * - * @param array $orderIds - * @return mixed - */ - public function invoice(array $orderIds) - { - $endpoint = 'orders/print/invoice'; - - return $this->postRequest($endpoint, $orderIds); - } -} diff --git a/getgologisticsapi/src/Resources/OrderResource.php b/getgologisticsapi/src/Resources/OrderResource.php deleted file mode 100644 index 93c76ff..0000000 --- a/getgologisticsapi/src/Resources/OrderResource.php +++ /dev/null @@ -1,66 +0,0 @@ -postRequest($endpoint, $order); - } - - /** - * Create a custom or channel specific order - * - * @param array $order - * @param bool $channelSpecificOrder - * @return mixed - */ - public function create(array $order, bool $channelSpecificOrder = false) - { - if ($channelSpecificOrder) { - $endpoint = 'orders/create'; - } else { - $endpoint = 'orders/create/adhoc'; - } - - return $this->postRequest($endpoint, $order); - } - - /** - * Cancel an Order - * - * @param array $ids - * @return mixed - */ - public function cancel(array $ids) - { - $endpoint = 'orders/cancel'; - - return $this->postRequest($endpoint, $ids); - } - - - /** - * Update the pickup location - * - * @param array $data - * @return mixed - */ - public function updatePickupLocation(array $data) - { - $endpoint = 'orders/address/pickup'; - - return $this->patchRequest($endpoint, $data); - } -} diff --git a/getgologisticsapi/src/Resources/PickupResource.php b/getgologisticsapi/src/Resources/PickupResource.php deleted file mode 100644 index e129631..0000000 --- a/getgologisticsapi/src/Resources/PickupResource.php +++ /dev/null @@ -1,32 +0,0 @@ -postRequest($endpoint, $location); - } - - /** - * Get All Pickup Locations - * - * @return mixed - */ - public function getLocations() - { - $endpoint = 'settings/company/pickup'; - - return $this->getRequest($endpoint); - } -} diff --git a/getgologisticsapi/src/Resources/ProductResource.php b/getgologisticsapi/src/Resources/ProductResource.php deleted file mode 100644 index 3e8da9f..0000000 --- a/getgologisticsapi/src/Resources/ProductResource.php +++ /dev/null @@ -1,50 +0,0 @@ -getRequest($endpoint); - } - - /** - * Get the details of a specific Product - * - * @param string $productId - * @return mixed - */ - public function getSpecific(string $productId) - { - $endpoint = 'products/show/' . $productId; - - return $this->getRequest($endpoint); - } - - /** - * Add New Products - * - * @param array $productDetails - * @return mixed - */ - public function create(array $productDetails) - { - $endpoint = "products"; - - return $this->postRequest($endpoint, $productDetails); - } -} diff --git a/getgologisticsapi/src/Resources/Resource.php b/getgologisticsapi/src/Resources/Resource.php deleted file mode 100644 index 7ed7cb8..0000000 --- a/getgologisticsapi/src/Resources/Resource.php +++ /dev/null @@ -1,39 +0,0 @@ -client = $client; - $this->token = $token; - } - - public function getRequest(string $endpoint) - { - return $this->client->setEndpoint($endpoint) - ->setHeaders($this->token) - ->get(); - } - - public function postRequest(string $endpoint, array $params) - { - return $this->client->setEndpoint($endpoint) - ->setHeaders($this->token) - ->post($params); - } - - public function patchRequest(string $endpoint, array $params) - { - return $this->client->setEndpoint($endpoint) - ->setHeaders($this->token) - ->patch($params); - } -} diff --git a/getgologisticsapi/src/Resources/ResourceInterface.php b/getgologisticsapi/src/Resources/ResourceInterface.php deleted file mode 100644 index 2a0a1cf..0000000 --- a/getgologisticsapi/src/Resources/ResourceInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -getRequest($endpoint); - } - - /** - * Get the details of a specific Shipment - * - * @param string $shipmentId - * @return mixed - */ - public function getSpecific(string $shipmentId) - { - $endpoint = 'shipments/' . $shipmentId; - - return $this->getRequest($endpoint); - } -} diff --git a/getgologisticsapi/src/Resources/TrackingResource.php b/getgologisticsapi/src/Resources/TrackingResource.php deleted file mode 100644 index 52a8300..0000000 --- a/getgologisticsapi/src/Resources/TrackingResource.php +++ /dev/null @@ -1,63 +0,0 @@ -getRequest($endpoint); - } - - - /** - * Get the tracking details of multiple shipments by using AWB codes together as an array. - * - * @param array $data - * @return mixed - */ - public function throwMultipleAwb(array $awbs) - { - $endpoint = 'courier/track/awbs'; - - return $this->postRequest($endpoint, $awbs); - } - - /** - * Get the tracking details of shipment by using the ShipmentId - * - * @param string $shipmentId - * @return mixed - */ - public function throwShipmentId(string $shipmentId) - { - $endpoint = 'courier/track/shipment/' . $shipmentId; - - return $this->getRequest($endpoint); - } - - /** - * Get the tracking details of shipment by using the OrderId - * - * @param string $orderId - * @param string $channelId - * @return mixed - */ - public function throwOrderId(string $orderId, string $channelId = null) - { - $endpoint = 'courier/track?order_id='. $orderId; - if ($channelId) { - $endpoint = $endpoint . '&channel_id=' . $channelId; - } - - return $this->getRequest($endpoint); - } -} diff --git a/getgologisticsapi/src/Traits/Authenticate.php b/getgologisticsapi/src/Traits/Authenticate.php deleted file mode 100644 index 8808315..0000000 --- a/getgologisticsapi/src/Traits/Authenticate.php +++ /dev/null @@ -1,27 +0,0 @@ -setEndpoint($endpoint) - ->setHeaders('login') - ->post($credentials); - - return $authDetails; - } -} diff --git a/getgologisticsapi/src/Wrapper.php b/getgologisticsapi/src/Wrapper.php deleted file mode 100644 index 5a1b02f..0000000 --- a/getgologisticsapi/src/Wrapper.php +++ /dev/null @@ -1,6 +0,0 @@ -