- list - List all buyers
- create - Add a buyer
- get - Get a buyer
- update - Update a buyer
- delete - Delete a buyer
List all buyers or search for a specific buyer.
import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";
const gr4vy = new Gr4vy({
id: "example",
server: "sandbox",
merchantAccountId: "default",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.buyers.list();
for await (const page of result) {
console.log(page);
}
}
run();The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { buyersList } from "@gr4vy/sdk/funcs/buyersList.js";
// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
merchantAccountId: "<id>",
bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await buyersList(gr4vy);
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("buyersList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.ListBuyersRequest | ✔️ | 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. |
Promise<operations.ListBuyersResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.Error400 | 400 | application/json |
| errors.Error401 | 401 | application/json |
| errors.Error403 | 403 | application/json |
| errors.Error404 | 404 | application/json |
| errors.Error405 | 405 | application/json |
| errors.Error409 | 409 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.Error425 | 425 | application/json |
| errors.Error429 | 429 | application/json |
| errors.Error500 | 500 | application/json |
| errors.Error502 | 502 | application/json |
| errors.Error504 | 504 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Create a new buyer record.
import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";
const gr4vy = new Gr4vy({
id: "example",
server: "sandbox",
merchantAccountId: "default",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.buyers.create({});
console.log(result);
}
run();The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { buyersCreate } from "@gr4vy/sdk/funcs/buyersCreate.js";
// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
merchantAccountId: "<id>",
bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await buyersCreate(gr4vy, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("buyersCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
buyerCreate |
components.BuyerCreate | ✔️ | N/A |
merchantAccountId |
string | ➖ | The ID of the merchant account to use for this 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. |
Promise<components.Buyer>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.Error400 | 400 | application/json |
| errors.Error401 | 401 | application/json |
| errors.Error403 | 403 | application/json |
| errors.Error404 | 404 | application/json |
| errors.Error405 | 405 | application/json |
| errors.Error409 | 409 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.Error425 | 425 | application/json |
| errors.Error429 | 429 | application/json |
| errors.Error500 | 500 | application/json |
| errors.Error502 | 502 | application/json |
| errors.Error504 | 504 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Fetches a buyer by its ID.
import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";
const gr4vy = new Gr4vy({
id: "example",
server: "sandbox",
merchantAccountId: "default",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.buyers.get("fe26475d-ec3e-4884-9553-f7356683f7f9");
console.log(result);
}
run();The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { buyersGet } from "@gr4vy/sdk/funcs/buyersGet.js";
// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
merchantAccountId: "<id>",
bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await buyersGet(gr4vy, "fe26475d-ec3e-4884-9553-f7356683f7f9");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("buyersGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
buyerId |
string | ✔️ | The ID of the buyer to retrieve. | fe26475d-ec3e-4884-9553-f7356683f7f9 |
merchantAccountId |
string | ➖ | The ID of the merchant account to use for this 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. |
Promise<components.Buyer>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.Error400 | 400 | application/json |
| errors.Error401 | 401 | application/json |
| errors.Error403 | 403 | application/json |
| errors.Error404 | 404 | application/json |
| errors.Error405 | 405 | application/json |
| errors.Error409 | 409 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.Error425 | 425 | application/json |
| errors.Error429 | 429 | application/json |
| errors.Error500 | 500 | application/json |
| errors.Error502 | 502 | application/json |
| errors.Error504 | 504 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Updates a buyer record.
import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";
const gr4vy = new Gr4vy({
id: "example",
server: "sandbox",
merchantAccountId: "default",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.buyers.update({}, "fe26475d-ec3e-4884-9553-f7356683f7f9");
console.log(result);
}
run();The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { buyersUpdate } from "@gr4vy/sdk/funcs/buyersUpdate.js";
// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
merchantAccountId: "<id>",
bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await buyersUpdate(gr4vy, {}, "fe26475d-ec3e-4884-9553-f7356683f7f9");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("buyersUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
buyerId |
string | ✔️ | The ID of the buyer to edit. | fe26475d-ec3e-4884-9553-f7356683f7f9 |
buyerUpdate |
components.BuyerUpdate | ✔️ | N/A | |
merchantAccountId |
string | ➖ | The ID of the merchant account to use for this 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. |
Promise<components.Buyer>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.Error400 | 400 | application/json |
| errors.Error401 | 401 | application/json |
| errors.Error403 | 403 | application/json |
| errors.Error404 | 404 | application/json |
| errors.Error405 | 405 | application/json |
| errors.Error409 | 409 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.Error425 | 425 | application/json |
| errors.Error429 | 429 | application/json |
| errors.Error500 | 500 | application/json |
| errors.Error502 | 502 | application/json |
| errors.Error504 | 504 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Permanently removes a buyer record.
import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";
const gr4vy = new Gr4vy({
id: "example",
server: "sandbox",
merchantAccountId: "default",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
await gr4vy.buyers.delete("fe26475d-ec3e-4884-9553-f7356683f7f9");
}
run();The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { buyersDelete } from "@gr4vy/sdk/funcs/buyersDelete.js";
// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
merchantAccountId: "<id>",
bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await buyersDelete(gr4vy, "fe26475d-ec3e-4884-9553-f7356683f7f9");
if (res.ok) {
const { value: result } = res;
} else {
console.log("buyersDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
buyerId |
string | ✔️ | The ID of the buyer to delete. | fe26475d-ec3e-4884-9553-f7356683f7f9 |
merchantAccountId |
string | ➖ | The ID of the merchant account to use for this 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. |
Promise<void>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.Error400 | 400 | application/json |
| errors.Error401 | 401 | application/json |
| errors.Error403 | 403 | application/json |
| errors.Error404 | 404 | application/json |
| errors.Error405 | 405 | application/json |
| errors.Error409 | 409 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.Error425 | 425 | application/json |
| errors.Error429 | 429 | application/json |
| errors.Error500 | 500 | application/json |
| errors.Error502 | 502 | application/json |
| errors.Error504 | 504 | application/json |
| errors.SDKError | 4XX, 5XX | */* |