type Stripe = {
token: string;
};
/**
* Get radar early fraud warnings early fraud warning
* Retrieves the details of an early fraud warning that has previously been created.
Please refer to the early fraud warning object reference for more details.
*/
export async function main(
auth: Stripe,
early_fraud_warning: string,
expand: any
) {
const url = new URL(
`https://api.stripe.com/v1/radar/early_fraud_warnings/${early_fraud_warning}`
);
encodeParams({ 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 radar early fraud warnings early fraud warning
* <p>Retrieves the details of an early fraud warning that has previously been created. </p>
<p>Please refer to the <a href="#early_fraud_warning_object">early fraud warning</a> object reference for more details.</p>
*/
export async function main(
auth: Stripe,
early_fraud_warning: string,
expand: any
) {
const url = new URL(
`https://api.stripe.com/v1/radar/early_fraud_warnings/${early_fraud_warning}`
);
encodeParams({ 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