How to use the got.patch function in got

To help you get started, we’ve selected a few got examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Polymer / tachometer / src / github.ts View on Github external
async function completeCheckRun(
    {label, repo, installationToken, checkId, markdown}: {
      label: string,
      repo: string,
      checkId: string,
      markdown: string,
      installationToken: string
    }) {
  await got.patch(
      `https://api.github.com/repos/${repo}/check-runs/${checkId}`, {
        headers: {
          Accept: 'application/vnd.github.antiope-preview+json',
          Authorization: `Bearer ${installationToken}`,
        },
        // https://developer.github.com/v3/checks/runs/#parameters-1
        body: JSON.stringify({
          name: label,
          completed_at: new Date().toISOString(),
          // Note that in the future we will likely want to be able to report
          // a failing check (e.g. if there appears to be a difference greater
          // than some threshold).
          conclusion: 'neutral',
          output: {
            title: label,
            summary: 'Benchmark results',
github wopian / kitsu / src / methods / patch.js View on Github external
export default async function (model, data) {
  try {
    if (!this.isAuth) throw new Error('Not authenticated')
    if (typeof data.id === 'undefined') throw new Error('PATCH request is missing a model ID')
    // Handle request
    const opts = Object.assign({
      body: JSON.stringify(serialise(model, data, 'PATCH'))
    }, this._opts)
    await r.patch(`${this._apiUrl}/${this._apiVer}/${kebab(model, '-')}/${data.id}`, opts)
      .catch(e => { throw e.response.body })
  } catch (e) {
    throw e
  }
}
github everyone-bot / everyone-bot / util / groupRepository.js View on Github external
optIn(user, groupId) {
        arg.checkIfExists(user, 'user');
        arg.checkIfNumber(groupId, 'groupId');

        const path = this.firebaseSettings.buildPath(`groups/${groupId}/members/${user.id}.json`);
        const payload = JSON.stringify({
            id: user.id,
            username: user.username,
            optIn: true
        });
        
        return got.patch(path, {
            body: payload
        }).catch(err => {
            console.log(err);
        });
    }
github everyone-bot / everyone-bot / util / groupRepository.js View on Github external
optOut(user, groupId) {
        arg.checkIfExists(user, 'user');
        arg.checkIfNumber(groupId, 'groupId');

        const path = this.firebaseSettings.buildPath(`groups/${groupId}/members/${user.id}.json`);
        const payload = JSON.stringify({
            id: user.id,
            username: user.username,
            optIn: false
        });

        return got.patch(path, {
            body: payload
        }).catch(err => {
            console.log(err);
        });
    }
}
github babel / babel-bot / src / github.js View on Github external
exports.editComment = async ({ owner, repo, id, body }: EditCommentsParams) => {
    await got.patch(`${BASE_URI}/repos/${owner}/${repo}/issues/comments/${id}`, {
        body: JSON.stringify({ body }),
        headers,
        json: true,
    });
};
github mozilla / blurts-server / lib / remote-settings.js View on Github external
async requestReviewOnBreachesCollection() {
    const auth = `${FX_RS_WRITER_USER}:${FX_RS_WRITER_PASS}`;

    return await got.patch(FX_RS_COLLECTION, {
      json: true, auth, body: { data: {status: "to-review"} },
    });
  },
};
github alex-phillips / node-clouddrive / lib / Node.js View on Github external
rename(name, callback) {
    let retval = {
      success: false,
      data: {},
    };

    Logger.verbose('Requesting nodes:files:patch endpoint (rename)');
    Logger.debug(`HTTP Request: PATCH '${account.metadataUrl}nodes/${this.getId()}'`);
    got.patch(`${account.metadataUrl}nodes/${this.getId()}`, {
      headers: {
        Authorization: `Bearer ${account.token.access_token}`
      },
      body: JSON.stringify({
        name: name,
      })
    })
      .then(response => {
        Logger.debug(`Response returned with status code ${response.statusCode}.`);
        Logger.silly(`Response body: ${response.body}`);
        retval.data = JSON.parse(response.body);

        if (response.statusCode === 200) {
          retval.success = true;
          this.replace(retval.data);
github alex-phillips / node-clouddrive / lib / Node.js View on Github external
update(options, callback) {
    let retval = {
      success: false,
      data: {},
    };

    Logger.verbose('Requesting nodes:files:patch endpoint (update)');
    Logger.debug(`HTTP Request: PATCH '${account.metadataUrl}nodes/${this.getId()}'`);
    got.patch(`${account.metadataUrl}nodes/${this.getId()}`, {
      headers: {
        Authorization: `Bearer ${account.token.access_token}`
      },
      body: JSON.stringify({
        labels: options.labels || this.getLabels(),
        description: options.description || this.getDescription(),
      })
    })
      .then(response => {
        Logger.debug(`Response returned with status code ${response.statusCode}.`);
        Logger.silly(`Response body: ${response.body}`);
        retval.data = JSON.parse(response.body);

        if (response.statusCode === 200) {
          retval.success = true;
          this.replace(retval.data);