Google API Typescript definitions
First you need to install typings:
npm install typings --save
Then install typings for Google API client:
typings install gapi.client --save
And finally install typings for selected Google API:
typings install gapi.client.<api_name> --save
You need to initialize Google API client in your code:
gapi.load("client", () => {
// now we can use gapi.client
// ...
});
Then load api client wrapper:
gapi.client.load('<api_name>', '<api_version>', () => {
// now we can use gapi.client.adexchangebuyer
// ...
});
Don't forget to authenticate your client before sending any request to resources:
// declare client_id registered in Google Developers Console
var client_id = '',
scope = [
// <api_scope>
],
immediate = true;
// ...
gapi.auth.authorize({ client_id: client_id, scope: scope, immediate: immediate }, authResult => {
if (authResult && !authResult.error) {
/* handle succesfull authorization */
} else {
/* handle authorization error */
}
});
After that you can use Ad Exchange Buyer API resources:
gapi.client.<api_name>.<api_resource>.<method name>({ /* method parameters */ })
.then(response => { /* handling response */ });