type Stripe = {
token: string;
};
/**
* Get files
* Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top.
*/
export async function main(
auth: Stripe,
created: any,
ending_before: string | undefined,
expand: any,
limit: string | undefined,
purpose:
| "account_requirement"
| "additional_verification"
| "business_icon"
| "business_logo"
| "customer_signature"
| "dispute_evidence"
| "document_provider_identity_document"
| "finance_report_run"
| "identity_document"
| "identity_document_downloadable"
| "pci_document"
| "selfie"
| "sigma_scheduled_query"
| "tax_document_user_upload"
| "terminal_reader_splashscreen"
| undefined,
starting_after: string | undefined
) {
const url = new URL(`https://api.stripe.com/v1/files`);
for (const [k, v] of [
["ending_before", ending_before],
["limit", limit],
["purpose", purpose],
["starting_after", starting_after],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
encodeParams({ created, expand }).forEach((v, k) => {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
});
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 291 days ago
type Stripe = {
token: string;
};
/**
* Get files
* <p>Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top.</p>
*/
export async function main(
auth: Stripe,
created: any,
ending_before: string | undefined,
expand: any,
limit: string | undefined,
purpose:
| "account_requirement"
| "additional_verification"
| "business_icon"
| "business_logo"
| "customer_signature"
| "dispute_evidence"
| "document_provider_identity_document"
| "finance_report_run"
| "identity_document"
| "identity_document_downloadable"
| "pci_document"
| "selfie"
| "sigma_scheduled_query"
| "tax_document_user_upload"
| "terminal_reader_splashscreen"
| undefined,
starting_after: string | undefined
) {
const url = new URL(`https://api.stripe.com/v1/files`);
for (const [k, v] of [
["ending_before", ending_before],
["limit", limit],
["purpose", purpose],
["starting_after", starting_after],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
encodeParams({ created, expand }).forEach((v, k) => {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
});
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 419 days ago