Edits history of script submission #12645 for ' Update profile (mollie)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Mollie = {
      token: string;
    };
    /**
     * Update profile
     * Update an existing profile.
    
    Profiles are required for payment processing. Normally they are created and updated via the Mollie dashboard. Alternatively, you can use this endpoint to automate profile management.
    
    > 🔑 Access with
    >
    > Access token with **profiles.write**
     */
    export async function main(
      auth: Mollie,
      id: string,
      body: {
        name?: string;
        website?: string;
        email?: string;
        phone?: string;
        description?: string;
        countriesOfActivity?: string[];
        businessCategory?: string;
        mode?: string;
      },
    ) {
      const url = new URL(`https://api.mollie.com/v2/profiles/${id}`);
    
      const response = await fetch(url, {
        method: "PATCH",
        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