//native
type Mollie = {
token: string;
};
/**
* Get organization
* Retrieve a single organization by its ID.
You can normally only retrieve the currently authenticated organization with this endpoint. This is primarily useful for OAuth apps. See also [Get current organization](get-current-organization).
If you have a *partner account*', you can retrieve organization details of connected organizations.
> 🔑 Access with
>
> Access token with **organizations.read**
*/
export async function main(
auth: Mollie,
id: string,
testmode: string | undefined,
) {
const url = new URL(`https://api.mollie.com/v2/organizations/${id}`);
for (const [k, v] of [["testmode", testmode]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago