DefinitelyTyped/types/gapi.client.mirror
Alexey Bolisov 4f8a3d571b Add Google APIs typings (#19083)
* Add Google APIs typings

* [gapi.cliebt.* ] Add version as part of typings name and fix gapi.client tslint errors

* versions should not get their own folders
fixing a few typos
using /** syntax so comments show up in editors
export only actual (last) version for now

* export only actual (last) version for now

* merge namespaces and remove unnecessary namespace qualifiers

* remove namespace qualifier for gapi.client.Request from nested namespaces and change Request base interface to Promise

* disable await-promise rule

* fix collision between gapi.client.Request and Request from nested namespace
disable no-irregular-whitespace rule

* sort properties and namespace resources

* remove empty comments
sort resources amd methods in tests and readme.md

* update 'this is autogenerated file' banner to remove this text from gapi.client namespace hint
use multiline comments when comment has several lines

* implement no-trailing-whitespace, no-padding, max-line-length, await-promise, no-irregular-whitespace rules

* add strictFunctionTypes to tsconfig

* fix "Whitespace within parentheses is not allowed" rule

* fix ts-lint rules

* fixes

* remove deprecated replicapool and replicapoolupdater api

* fix no-irregular-whitespace

* fix no-irregular-whitespace
2017-10-09 14:55:04 -07:00
..
gapi.client.mirror-tests.ts
index.d.ts
readme.md
tsconfig.json
tslint.json

TypeScript typings for Google Mirror API v1

Interacts with Glass users via the timeline. For detailed description please check documentation.

Installing

Install typings for Google Mirror API:

npm install @types/gapi.client.mirror@v1 --save-dev

Usage

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('mirror', 'v1', () => {
    // now we can use gapi.client.mirror
    // ... 
});

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 = [     
        // View your location
        'https://www.googleapis.com/auth/glass.location',
    
        // View and manage your Glass timeline
        'https://www.googleapis.com/auth/glass.timeline',
    ],
    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 Google Mirror API resources:

    
/* 
Inserts a new account for a user  
*/
await gapi.client.accounts.insert({ accountName: "accountName", accountType: "accountType", userToken: "userToken",  }); 
    
/* 
Deletes a contact.  
*/
await gapi.client.contacts.delete({ id: "id",  }); 
    
/* 
Gets a single contact by ID.  
*/
await gapi.client.contacts.get({ id: "id",  }); 
    
/* 
Inserts a new contact.  
*/
await gapi.client.contacts.insert({  }); 
    
/* 
Retrieves a list of contacts for the authenticated user.  
*/
await gapi.client.contacts.list({  }); 
    
/* 
Updates a contact in place. This method supports patch semantics.  
*/
await gapi.client.contacts.patch({ id: "id",  }); 
    
/* 
Updates a contact in place.  
*/
await gapi.client.contacts.update({ id: "id",  }); 
    
/* 
Gets a single location by ID.  
*/
await gapi.client.locations.get({ id: "id",  }); 
    
/* 
Retrieves a list of locations for the user.  
*/
await gapi.client.locations.list({  }); 
    
/* 
Gets a single setting by ID.  
*/
await gapi.client.settings.get({ id: "id",  }); 
    
/* 
Deletes a subscription.  
*/
await gapi.client.subscriptions.delete({ id: "id",  }); 
    
/* 
Creates a new subscription.  
*/
await gapi.client.subscriptions.insert({  }); 
    
/* 
Retrieves a list of subscriptions for the authenticated user and service.  
*/
await gapi.client.subscriptions.list({  }); 
    
/* 
Updates an existing subscription in place.  
*/
await gapi.client.subscriptions.update({ id: "id",  }); 
    
/* 
Deletes a timeline item.  
*/
await gapi.client.timeline.delete({ id: "id",  }); 
    
/* 
Gets a single timeline item by ID.  
*/
await gapi.client.timeline.get({ id: "id",  }); 
    
/* 
Inserts a new item into the timeline.  
*/
await gapi.client.timeline.insert({  }); 
    
/* 
Retrieves a list of timeline items for the authenticated user.  
*/
await gapi.client.timeline.list({  }); 
    
/* 
Updates a timeline item in place. This method supports patch semantics.  
*/
await gapi.client.timeline.patch({ id: "id",  }); 
    
/* 
Updates a timeline item in place.  
*/
await gapi.client.timeline.update({ id: "id",  });