Edits history of script submission #20581 for ' BulkUpdateCustomers (square)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Square = {
      token: string;
    };
    /**
     * BulkUpdateCustomers
     * Updates multiple customer profiles.
    
    This endpoint takes a map of individual update requests and returns a map of responses.
    
    You cannot use this endpoint to change cards on file. To make changes, use the [Cards API]($e/Cards) or [Gift Cards API]($e/GiftCards).
     */
    export async function main(auth: Square, body: { customers: {} }) {
      const url = new URL(`https://connect.squareup.com/v2/customers/bulk-update`);
    
      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.json();
    }
    

    Submitted by hugo697 235 days ago