diff --git a/src/Traits/WooCommerceTrait.php b/src/Traits/WooCommerceTrait.php index 4c5e649..8878919 100644 --- a/src/Traits/WooCommerceTrait.php +++ b/src/Traits/WooCommerceTrait.php @@ -19,10 +19,8 @@ public function all($endpoint = '', $options = []) self::__construct(); return $this->client->get($endpoint, $options); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } @@ -41,10 +39,8 @@ public function find($endpoint = '', $options = []) self::__construct(); return $this->client->get($endpoint, $options); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } @@ -63,10 +59,8 @@ public function create($endpoint, $data) self::__construct(); return $this->client->post($endpoint, $data); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } @@ -85,10 +79,8 @@ public function update($endpoint, $data) self::__construct(); return $this->client->put($endpoint, $data); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } @@ -107,10 +99,8 @@ public function delete($endpoint, $options = []) self::__construct(); return $this->client->delete($endpoint, $options); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } @@ -122,14 +112,10 @@ public function delete($endpoint, $options = []) public function getRequest() { try { - return $this->client->http->getRequest(); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } - } /** @@ -140,12 +126,9 @@ public function getRequest() public function getResponse() { try { - return $this->client->http->getResponse(); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } diff --git a/src/WooCommerceApi.php b/src/WooCommerceApi.php index 7521937..2f86e1e 100644 --- a/src/WooCommerceApi.php +++ b/src/WooCommerceApi.php @@ -27,12 +27,11 @@ class WooCommerceApi public function __construct() { try { - $this->headers = [ - 'header_total' => config('woocommerce.header_total') ?? 'X-WP-Total', + 'header_total' => config('woocommerce.header_total') ?? 'X-WP-Total', 'header_total_pages' => config('woocommerce.header_total_pages') ?? 'X-WP-TotalPages', ]; - + $this->client = new Client( config('woocommerce.store_url'), config('woocommerce.consumer_key'), @@ -45,10 +44,8 @@ public function __construct() 'timeout' => config('woocommerce.timeout'), ] ); - - } catch ( \Exception $e) { + } catch (\Exception $e) { throw new \Exception($e->getMessages(), 1); - } } }