Skip to content

Latest commit

 

History

History
176 lines (132 loc) · 11.1 KB

File metadata and controls

176 lines (132 loc) · 11.1 KB

Users

(users)

Overview

Manage users

Available Operations

  • get - Retrieve the current user
  • update - Update the current user

get

Retrieve the current user for the authenticated team.

Example Usage

import { Midday } from "@midday-ai/sdk";

const midday = new Midday({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const result = await midday.users.get();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MiddayCore } from "@midday-ai/sdk/core.js";
import { usersGet } from "@midday-ai/sdk/funcs/usersGet.js";

// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const res = await usersGet(midday);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetCurrentUserResponse>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

update

Update the current user for the authenticated team.

Example Usage

import { Midday } from "@midday-ai/sdk";

const midday = new Midday({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const result = await midday.users.update({
    fullName: "Jane Doe",
    email: "jane.doe@acme.com",
    avatarUrl: "https://cdn.midday.ai/avatars/jane-doe.jpg",
    locale: "en-US",
    weekStartsOnMonday: true,
    timezone: "America/New_York",
    timezoneAutoSync: true,
    timeFormat: 24,
    dateFormat: "yyyy-MM-dd",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MiddayCore } from "@midday-ai/sdk/core.js";
import { usersUpdate } from "@midday-ai/sdk/funcs/usersUpdate.js";

// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const res = await usersUpdate(midday, {
    fullName: "Jane Doe",
    email: "jane.doe@acme.com",
    avatarUrl: "https://cdn.midday.ai/avatars/jane-doe.jpg",
    locale: "en-US",
    weekStartsOnMonday: true,
    timezone: "America/New_York",
    timezoneAutoSync: true,
    timeFormat: 24,
    dateFormat: "yyyy-MM-dd",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateCurrentUserRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateCurrentUserResponse>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*