webwinkelkeur / client
A client for the WebwinkelKeur API
Installs: 7 682
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: >=5.5
- guzzlehttp/guzzle: >=6.3 <8
Requires (Dev)
- phpunit/phpunit: ^7.1
This package is auto-updated.
Last update: 2024-11-09 20:51:04 UTC
README
This is a web client for the WebwinkelKeur API.
The documentation of the API is available at https://dashboard.webwinkelkeur.nl/pages/api.
Should you experience any issues with the API client, feel free to open a GitHub issue.
Installation
You can use composer
to install the API client into your project:
composer require webwinkelkeur/client
Usage
To send requests to the API, you need your WebwinkelKeur ID and authentication token.
use WebwinkelKeur\Client; use WebwinkelKeur\Client\Request; $webwinkelKeurClient = new Client($id, $authToken);
Sending invitations
$invitation = new Request\Invitation(); $invitation ->setCustomerName('John Doe') ->setEmailAddress('john.doe@example.com') ->setPhoneNumbers(['+1.2024561111', '+1.2024561414']) ->setOrderNumber(184553) ->setOrderTotal(23.55); try { $webwinkelKeurClient->sendInvitation($invitation); echo 'Success!'; } catch (Client\Exception $e) { echo $e->getMessage(); }
Retrieving sent invitations
try { foreach ($webwinkelKeurClient->getSentInvitations() as $sentInvitation) { echo 'Invitation for order ' . $sentInvitation->getOrderNumber() . ' was sent on ' . $sentInvitation->getCreatedAt()->format('r') . ' to ' . $sentInvitation->getEmail() . "\n"; } } catch (Client\Exception $e) { echo $e->getMessage(); }
Retrieving ratings
try { foreach ($webwinkelKeurClient->getRatings() as $rating) { echo $rating->getName() . ' says "' . $rating->getComment() . "\"\n"; } } catch (Client\Exception $e) { echo $e->getMessage(); }
Retrieving ratings summary
try { $ratingsSummary = $webwinkelKeurClient->getRatingsSummary(); echo 'The average rating is ' . $ratingsSummary->getRatingAverage() . ' out of ' . $ratingsSummary->getAmount() . " ratings."; } catch (Client\Exception $e) { echo $e->getMessage(); }
Retrieving web shop details
try { $webshop = $webwinkelKeurClient->getWebshop(); $address = $webshop->getAddress(); echo $webshop->getName() . ' is located at ' . $address->getNumber() . ' ' . $address->getStreet() . ', ' . $address->getCity(); } catch (Client\Exception $e) { echo $e->getMessage(); }
Retrieving rich snippet
try { $richSnippet = $webwinkelKeurClient->getRichSnippet(); echo $richSnippet; } catch (Client\Exception $e) { echo $e->getMessage(); }