0.0.20241022 • Published 8 months ago

@maxim_mazurok/gapi.client.forms-v1 v0.0.20241022

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

TypeScript typings for Google Forms API v1

Reads and writes Google Forms and responses. For detailed description please check documentation.

Installing

Install typings for Google Forms API:

npm install @types/gapi.client.forms-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://forms.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.forms
  }
);
// 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('forms', 'v1', () => {
  // now we can use:
  // gapi.client.forms
});

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 = [
    // See, edit, create, and delete all of your Google Drive files
    'https://www.googleapis.com/auth/drive',

    // See, edit, create, and delete only the specific Google Drive files you use with this app
    'https://www.googleapis.com/auth/drive.file',

    // See and download all your Google Drive files
    'https://www.googleapis.com/auth/drive.readonly',

    // See, edit, create, and delete all your Google Forms forms
    'https://www.googleapis.com/auth/forms.body',

    // See all your Google Forms forms
    'https://www.googleapis.com/auth/forms.body.readonly',

    // See all responses to your Google Forms forms
    'https://www.googleapis.com/auth/forms.responses.readonly',
  ],
  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 Google Forms API resources:

/*
Change the form with a batch of updates.
*/
await gapi.client.forms.forms.batchUpdate({formId: 'formId'});

/*
Create a new form using the title given in the provided form message in the request. *Important:* Only the form.info.title and form.info.document_title fields are copied to the new form. All other fields including the form description, items and settings are disallowed. To create a new form and add items, you must first call forms.create to create an empty form with a title and (optional) document title, and then call forms.update to add the items.
*/
await gapi.client.forms.forms.create({});

/*
Get a form.
*/
await gapi.client.forms.forms.get({formId: 'formId'});
0.0.20241022

8 months ago

0.0.20241015

9 months ago

0.0.20241008

9 months ago

0.0.20240924

9 months ago

0.0.20241001

9 months ago

0.0.20240917

9 months ago

0.0.20240912

10 months ago

0.0.20240903

10 months ago

0.0.20240827

10 months ago

0.0.20240820

10 months ago

0.0.20240723

11 months ago

0.0.20240604

1 year ago

0.0.20240730

11 months ago

0.0.20240625

1 year ago

0.0.20240806

11 months ago

0.0.20240528

1 year ago

0.0.20240521

1 year ago

0.0.20240813

11 months ago

0.0.20240702

12 months ago

0.0.20240716

12 months ago

0.0.20240507

1 year ago

0.0.20240430

1 year ago

0.0.20240425

1 year ago

0.0.20240416

1 year ago

0.0.20240402

1 year ago

0.0.20240326

1 year ago

0.0.20240321

1 year ago

0.0.20240305

1 year ago

0.0.20240227

1 year ago

0.0.20240220

1 year ago

0.0.20240214

1 year ago

0.0.20240130

1 year ago

0.0.20240118

1 year ago

0.0.20240109

1 year ago

0.0.20231212

2 years ago

0.0.20231128

2 years ago

0.0.20231107

2 years ago

0.0.20230815

2 years ago

0.0.20231031

2 years ago

0.0.20231114

2 years ago

0.0.20230808

2 years ago

0.0.20230926

2 years ago

0.0.20230920

2 years ago

0.0.20231017

2 years ago

0.0.20230720

2 years ago

0.0.20230727

2 years ago

0.0.20230725

2 years ago

0.0.20231024

2 years ago

0.0.20230718

2 years ago

0.0.20230711

2 years ago

0.0.20230713

2 years ago

0.0.20230912

2 years ago

0.0.20230829

2 years ago

0.0.20230706

2 years ago

0.0.20230905

2 years ago

0.0.20230822

2 years ago

0.0.20230704

2 years ago

0.0.20231003

2 years ago

0.0.20230622

2 years ago

0.0.20230613

2 years ago

0.0.20230620

2 years ago

0.0.20230608

2 years ago

0.0.20230601

2 years ago

0.0.20230523

2 years ago

0.0.20230606

2 years ago

0.0.20230530

2 years ago

0.0.20230518

2 years ago

0.0.20230516

2 years ago

0.0.20230502

2 years ago

0.0.20230504

2 years ago

0.0.20230418

2 years ago

0.0.20230420

2 years ago

0.0.20230328

2 years ago

0.0.20230406

2 years ago

0.0.20230330

2 years ago

0.0.20230314

2 years ago

0.0.20230323

2 years ago

0.0.20230321

2 years ago

0.0.20230425

2 years ago

0.0.20230228

2 years ago

0.0.20230309

2 years ago

0.0.20230307

2 years ago

0.0.20230214

2 years ago

0.0.20230202

2 years ago

0.0.20230221

2 years ago

0.0.20230126

2 years ago

0.0.20230209

2 years ago

0.0.20230207

2 years ago

0.0.20230131

2 years ago

0.0.20230117

2 years ago

0.0.20221115

3 years ago

0.0.20230119

2 years ago

0.0.20221110

3 years ago

0.0.20230124

2 years ago

0.0.20221208

3 years ago

0.0.20230103

2 years ago

0.0.20221108

3 years ago

0.0.20221206

3 years ago

0.0.20221129

3 years ago

0.0.20221103

3 years ago

0.0.20230105

2 years ago

0.0.20221201

3 years ago

0.0.20230110

2 years ago

0.0.20221117

3 years ago

0.0.20221020

3 years ago

0.0.20221006

3 years ago

0.0.20221027

3 years ago

0.0.20221025

3 years ago

0.0.20221101

3 years ago

0.0.20221013

3 years ago

0.0.20221011

3 years ago

0.0.20220927

3 years ago

0.0.20221018

3 years ago

0.0.20220906

3 years ago

0.0.20220829

3 years ago

0.0.20220818

3 years ago

0.0.20220908

3 years ago

0.0.20220920

3 years ago

0.0.20220921

3 years ago

0.0.20220823

3 years ago

0.0.20220913

3 years ago

0.0.20220825

3 years ago

0.0.20220915

3 years ago

0.0.20220816

3 years ago

0.0.20220811

3 years ago

0.0.20220808

3 years ago