0.0.20240429 • Published 21 days ago

@maxim_mazurok/gapi.client.gmail-v1 v0.0.20240429

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

TypeScript typings for Gmail API v1

The Gmail API lets you view and manage Gmail mailbox data like threads, messages, and labels. For detailed description please check documentation.

Installing

Install typings for Gmail API:

npm install @types/gapi.client.gmail-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(
  'https://gmail.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.gmail
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('gmail', 'v1', () => {
  // now we can use:
  // gapi.client.gmail
});

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 = [
    // Read, compose, send, and permanently delete all your email from Gmail
    'https://mail.google.com/',

    // Manage drafts and send emails when you interact with the add-on
    'https://www.googleapis.com/auth/gmail.addons.current.action.compose',

    // View your email messages when you interact with the add-on
    'https://www.googleapis.com/auth/gmail.addons.current.message.action',

    // View your email message metadata when the add-on is running
    'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',

    // View your email messages when the add-on is running
    'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',

    // Manage drafts and send emails
    'https://www.googleapis.com/auth/gmail.compose',

    // Add emails into your Gmail mailbox
    'https://www.googleapis.com/auth/gmail.insert',

    // See and edit your email labels
    'https://www.googleapis.com/auth/gmail.labels',

    // View your email message metadata such as labels and headers, but not the email body
    'https://www.googleapis.com/auth/gmail.metadata',

    // Read, compose, and send emails from your Gmail account
    'https://www.googleapis.com/auth/gmail.modify',

    // View your email messages and settings
    'https://www.googleapis.com/auth/gmail.readonly',

    // Send email on your behalf
    'https://www.googleapis.com/auth/gmail.send',

    // See, edit, create, or change your email settings and filters in Gmail
    'https://www.googleapis.com/auth/gmail.settings.basic',

    // Manage your sensitive mail settings, including who can manage your mail
    'https://www.googleapis.com/auth/gmail.settings.sharing',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Gmail API resources:

/*
Gets the current user's Gmail profile.
*/
await gapi.client.gmail.users.getProfile({userId: 'userId'});

/*
Stop receiving push notifications for the given user mailbox.
*/
await gapi.client.gmail.users.stop({userId: 'userId'});

/*
Set up or update a push notification watch on the given user mailbox.
*/
await gapi.client.gmail.users.watch({userId: 'userId'});
0.0.20240429

21 days ago

0.0.20240422

27 days ago

0.0.20240401

2 months ago

0.0.20240325

2 months ago

0.0.20240318

2 months ago

0.0.20240312

2 months ago

0.0.20240304

3 months ago

0.0.20240226

3 months ago

0.0.20240219

3 months ago

0.0.20240205

3 months ago

0.0.20240108

4 months ago

0.0.20240101

5 months ago

0.0.20231218

5 months ago

0.0.20231211

5 months ago

0.0.20231204

6 months ago

0.0.20231106

7 months ago

0.0.20230731

10 months ago

0.0.20231113

6 months ago

0.0.20231030

7 months ago

0.0.20230807

10 months ago

0.0.20230925

8 months ago

0.0.20230724

10 months ago

0.0.20231023

7 months ago

0.0.20230918

8 months ago

0.0.20230717

10 months ago

0.0.20231127

6 months ago

0.0.20231009

7 months ago

0.0.20230710

10 months ago

0.0.20230911

8 months ago

0.0.20230904

9 months ago

0.0.20230828

9 months ago

0.0.20230703

11 months ago

0.0.20231120

6 months ago

0.0.20231002

8 months ago

0.0.20230626

11 months ago

0.0.20230619

11 months ago

0.0.20230612

11 months ago

0.0.20230515

1 year ago

0.0.20230522

12 months ago

0.0.20230501

1 year ago

0.0.20230605

12 months ago

0.0.20230313

1 year ago

0.0.20230417

1 year ago

0.0.20230320

1 year ago

0.0.20230403

1 year ago

0.0.20230327

1 year ago

0.0.20230424

1 year ago

0.0.20230306

1 year ago

0.0.20230410

1 year ago

0.0.20230216

1 year ago

0.0.20230220

1 year ago

0.0.20230206

1 year ago

0.0.20230130

1 year ago

0.0.20230213

1 year ago

0.0.20221114

2 years ago

0.0.20230116

1 year ago

0.0.20221212

1 year ago

0.0.20221121

1 year ago

0.0.20230102

1 year ago

0.0.20221219

1 year ago

0.0.20221107

2 years ago

0.0.20230123

1 year ago

0.0.20221128

1 year ago

0.0.20221031

2 years ago

0.0.20221017

2 years ago

0.0.20221003

2 years ago

0.0.20221024

2 years ago

0.0.20221010

2 years ago

0.0.20220926

2 years ago

0.0.20220829

2 years ago

0.0.20220919

2 years ago

0.0.20220822

2 years ago

0.0.20220904

2 years ago

0.0.20220815

2 years ago

0.0.20220808

2 years ago