Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions src/Traits/WooCommerceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}

Expand All @@ -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);

}
}

Expand All @@ -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);

}
}

Expand All @@ -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);

}
}

Expand All @@ -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);

}
}

Expand All @@ -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);

}

}

/**
Expand All @@ -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);

}
}

Expand Down
9 changes: 3 additions & 6 deletions src/WooCommerceApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -45,10 +44,8 @@ public function __construct()
'timeout' => config('woocommerce.timeout'),
]
);

} catch ( \Exception $e) {
} catch (\Exception $e) {
throw new \Exception($e->getMessages(), 1);

}
}
}