Skip to content

Latest commit

 

History

History
351 lines (274 loc) · 16.5 KB

File metadata and controls

351 lines (274 loc) · 16.5 KB

Clients

Overview

Available Operations

  • list - List clients
  • get - Get client

list

Retrieve a list of all clients linked to your account.

The results are paginated.

Example Usage

import { Client } from "mollie-api-typescript";

const client = new Client({
  security: {
    advancedAccessToken: process.env["CLIENT_ADVANCED_ACCESS_TOKEN"] ?? "",
  },
});

async function run() {
  const result = await client.clients.list({
    embed: "organization",
    from: "org_12345678",
    limit: 50,
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { ClientCore } from "mollie-api-typescript/core.js";
import { clientsList } from "mollie-api-typescript/funcs/clientsList.js";

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

async function run() {
  const res = await clientsList(client, {
    embed: "organization",
    from: "org_12345678",
    limit: 50,
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("clientsList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListClientsRequest ✔️ 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.ListClientsResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400, 404, 429 application/hal+json
errors.ClientDefaultError 4XX, 5XX */*

get

Retrieve a single client by its ID.

Example Usage: get-client-200-1

import { Client } from "mollie-api-typescript";

const client = new Client({
  security: {
    advancedAccessToken: process.env["CLIENT_ADVANCED_ACCESS_TOKEN"] ?? "",
  },
});

async function run() {
  const result = await client.clients.get({
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ClientCore } from "mollie-api-typescript/core.js";
import { clientsGet } from "mollie-api-typescript/funcs/clientsGet.js";

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

async function run() {
  const res = await clientsGet(client, {
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientsGet failed:", res.error);
  }
}

run();

Example Usage: get-client-200-2

import { Client } from "mollie-api-typescript";

const client = new Client({
  security: {
    advancedAccessToken: process.env["CLIENT_ADVANCED_ACCESS_TOKEN"] ?? "",
  },
});

async function run() {
  const result = await client.clients.get({
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ClientCore } from "mollie-api-typescript/core.js";
import { clientsGet } from "mollie-api-typescript/funcs/clientsGet.js";

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

async function run() {
  const res = await clientsGet(client, {
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientsGet failed:", res.error);
  }
}

run();

Example Usage: get-client-200-3

import { Client } from "mollie-api-typescript";

const client = new Client({
  security: {
    advancedAccessToken: process.env["CLIENT_ADVANCED_ACCESS_TOKEN"] ?? "",
  },
});

async function run() {
  const result = await client.clients.get({
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ClientCore } from "mollie-api-typescript/core.js";
import { clientsGet } from "mollie-api-typescript/funcs/clientsGet.js";

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

async function run() {
  const res = await clientsGet(client, {
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientsGet failed:", res.error);
  }
}

run();

Example Usage: get-client-200-4

import { Client } from "mollie-api-typescript";

const client = new Client({
  security: {
    advancedAccessToken: process.env["CLIENT_ADVANCED_ACCESS_TOKEN"] ?? "",
  },
});

async function run() {
  const result = await client.clients.get({
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ClientCore } from "mollie-api-typescript/core.js";
import { clientsGet } from "mollie-api-typescript/funcs/clientsGet.js";

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

async function run() {
  const res = await clientsGet(client, {
    organizationId: "org_1234567",
    embed: "organization",
    idempotencyKey: "123e4567-e89b-12d3-a456-426",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("clientsGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetClientRequest ✔️ 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.GetClientResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404, 429 application/hal+json
errors.ClientDefaultError 4XX, 5XX */*