Edits history of script submission #12555 for ' Create client link (mollie)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Mollie = {
      token: string;
    };
    /**
     * Create client link
     * > 🚧 Open beta
    >
    > This feature is currently in open beta, and the final specification may still change.
     */
    export async function main(
      auth: Mollie,
      body: {
        resource?: string;
        id?: string;
        owner: {
          email: string;
          givenName: string;
          familyName: string;
          locale?: string;
        };
        name: string;
        address: {
          streetAndNumber?: string;
          postalCode?: string;
          city?: string;
          country: string;
        };
        registrationNumber?: string;
        vatNumber?: string;
        _links?: {
          self?: { href?: string; type?: string };
          clientLink?: { href?: string; type?: string };
          documentation?: { href?: string; type?: string };
        };
      },
    ) {
      const url = new URL(`https://api.mollie.com/v2/client-links`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago