A PHP client for Wave API.
Note: I've created this package for my personal need. Not all the Wave API operation has been implemented. But you can add an operation by creating a new class in
src/Operations
.
$ composer require cba85/wave-api-php-client
use Wave\Wave;
$wave = new Wave('YOUR_WAVE_FULL_ACCESS_TOKEN');
https://developer.waveapps.com/hc/en-us/articles/360032552912-Query-Get-user
$optionalFields = ['user' => ['id', 'firstName']];
$user = $wave->getUser($optionalFields);
https://developer.waveapps.com/hc/en-us/articles/360032908111-Query-List-businesses
$optionalFields = ['pageInfo' => ['totalCount']];
$optionalArguments = ['businesses' => ['pageSize' => 25]];
$businesses = $wave->listbusinesses($optionalFields, $optionalArguments);
https://developer.waveapps.com/hc/en-us/articles/360032572872-Query-Paginate-list-of-products
$wave = new Wave(getenv('WAVE_FULL_ACCESS_TOKEN'));
$products = $wave->listProducts([], [], [
'businessId' => getenv('WAVE_BUSINESS_ID'),
'page' => 1,
'pageSize' => 1
]);
https://developer.waveapps.com/hc/en-us/articles/360032911011-Query-Get-customer-by-id
$optionalFields = ['customer' => ['id', 'name', 'email']];
$wave = new Wave(getenv('WAVE_FULL_ACCESS_TOKEN'));
$customer = $wave->getCustomerById($optionalFields, [], [
'businessId' => getenv('WAVE_BUSINESS_ID'),
'customerId' => getenv('WAVE_CUSTOMER_ID')
]);
https://developer.waveapps.com/hc/en-us/articles/360032569232-Mutation-Create-customer
$optionalFields = ['customer' => ['id', 'name', 'email']];
$wave = new Wave(getenv('WAVE_FULL_ACCESS_TOKEN'));
$customerCreate = $wave->createCustomer($optionalFields, [], [
'input' => [
'businessId' => getenv('WAVE_BUSINESS_ID'),
'name' => "Santa",
'firstName' => "Saint",
'lastName' => "Nicolas",
'email' => "santa@claus.com",
'address' => [
'city' => "North Pole",
'postalCode' => "H0H H0H",
'countryCode' => "CA"
],
'currency' => "EUR"
]
]);
https://developer.waveapps.com/hc/en-us/articles/360033059491-Mutation-Patch-customer
$optionalFields = ['customer' => ['id', 'name', 'email']];
$wave = new Wave(getenv('WAVE_FULL_ACCESS_TOKEN'));
$customerPatch = $wave->patchCustomer([], [], [
'input' => [
'id' => getenv('WAVE_CUSTOMER_ID'),
'email' => "new@email.com"
]
]);
https://developer.waveapps.com/hc/en-us/articles/360019968212-API-Reference
$wave = new Wave(getenv('WAVE_FULL_ACCESS_TOKEN'));
$invoiceCreate = $wave->createInvoice([], [], [
'input' => [
'businessId' => getenv('WAVE_BUSINESS_ID'),
'customerId' => getenv('WAVE_CUSTOMER_ID'),
'status' => "DRAFT",
'items' => [
'productId' => getenv('WAVE_PRODUCT_ID'),
'description' => "test",
'quantity' => 1,
'unitPrice' => 14.99,
'taxes' => [
'salesTaxId' => getenv('WAVE_TAX_ID'),
]
]
]
]);
It's also possible to manually send a GraphQL query using the GraphQL client included behind the scene:
$query = <<<'GRAPHQL'
query {
user {
id
firstName
lastName
defaultEmail
createdAt
modifiedAt
}
}
GRAPHQL;
$wave = new Wave('YOUR_WAVE_FULL_ACCESS_TOKEN');
$results = $wave->client->runRawQuery($query, false);
See Wave API documentation for reference.
Add Wave tokens and ids in an .env
file based on .env.example
file example to test Wave API.
WAVE_FULL_ACCESS_TOKEN
: You Wave account full access token.WAVE_BUSINESS_ID
: Wave Business ID you can use for tests only.- List them and pick one using :
$ ./vendor/bin/phpunit --filter testListBusiness
- List them and pick one using :
WAVE_CUSTOMER_ID
: Wave Customer ID you can use for tests only.WAVE_PRODUCT_ID
: Wave Product ID you can use for tests only.- List them and pick one using :
$ ./vendor/bin/phpunit --filter testListProducts
- List them and pick one using :
WAVE_TAX_ID
: A Wave Tax ID used for invoice creation tests.- Find your defaultSalesTaxes using :
$ ./vendor/bin/phpunit --filter testListProducts
- Find your defaultSalesTaxes using :
Then launch tests:
$ ./vendor/bin/phpunit