0.0.20241028 • Published 8 months ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months 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.20241028

8 months ago

0.0.20241021

9 months ago

0.0.20241014

9 months ago

0.0.20240906

10 months ago

0.0.20240826

10 months ago

0.0.20240902

10 months ago

0.0.20240805

11 months ago

0.0.20240603

1 year ago

0.0.20240527

1 year ago

0.0.20240722

12 months ago

0.0.20240819

11 months ago

0.0.20240617

1 year ago

0.0.20240812

11 months ago

0.0.20240730

11 months ago

0.0.20240610

1 year ago

0.0.20240708

12 months ago

0.0.20240701

1 year ago

0.0.20240624

1 year ago

0.0.20240520

1 year ago

0.0.20240715

12 months ago

0.0.20240429

1 year ago

0.0.20240422

1 year ago

0.0.20240401

1 year ago

0.0.20240325

1 year ago

0.0.20240318

1 year ago

0.0.20240312

1 year ago

0.0.20240304

1 year ago

0.0.20240226

1 year ago

0.0.20240219

1 year ago

0.0.20240205

1 year ago

0.0.20240108

1 year ago

0.0.20240101

2 years ago

0.0.20231218

2 years ago

0.0.20231211

2 years ago

0.0.20231204

2 years ago

0.0.20231106

2 years ago

0.0.20230731

2 years ago

0.0.20231113

2 years ago

0.0.20231030

2 years ago

0.0.20230807

2 years ago

0.0.20230925

2 years ago

0.0.20230724

2 years ago

0.0.20231023

2 years ago

0.0.20230918

2 years ago

0.0.20230717

2 years ago

0.0.20231127

2 years ago

0.0.20231009

2 years ago

0.0.20230710

2 years ago

0.0.20230911

2 years ago

0.0.20230904

2 years ago

0.0.20230828

2 years ago

0.0.20230703

2 years ago

0.0.20231120

2 years ago

0.0.20231002

2 years ago

0.0.20230626

2 years ago

0.0.20230619

2 years ago

0.0.20230612

2 years ago

0.0.20230515

2 years ago

0.0.20230522

2 years ago

0.0.20230501

2 years ago

0.0.20230605

2 years ago

0.0.20230313

2 years ago

0.0.20230417

2 years ago

0.0.20230320

2 years ago

0.0.20230403

2 years ago

0.0.20230327

2 years ago

0.0.20230424

2 years ago

0.0.20230306

2 years ago

0.0.20230410

2 years ago

0.0.20230216

2 years ago

0.0.20230220

2 years ago

0.0.20230206

2 years ago

0.0.20230130

2 years ago

0.0.20230213

2 years ago

0.0.20221114

3 years ago

0.0.20230116

2 years ago

0.0.20221212

3 years ago

0.0.20221121

3 years ago

0.0.20230102

3 years ago

0.0.20221219

3 years ago

0.0.20221107

3 years ago

0.0.20230123

2 years ago

0.0.20221128

3 years ago

0.0.20221031

3 years ago

0.0.20221017

3 years ago

0.0.20221003

3 years ago

0.0.20221024

3 years ago

0.0.20221010

3 years ago

0.0.20220926

3 years ago

0.0.20220829

3 years ago

0.0.20220919

3 years ago

0.0.20220822

3 years ago

0.0.20220904

3 years ago

0.0.20220815

3 years ago

0.0.20220808

3 years ago