Edits history of script submission #14618 for ' Unlock card (brex)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Brex = {
      token: string;
    };
    /**
     * 
    Unlock card
    
     * 
    Unlocks an existing card.
    
     */
    export async function main(auth: Brex, id: string, Idempotency_Key?: string) {
      const url = new URL(`https://platform.brexapis.com/v2/cards/${id}/unlock`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          ...(Idempotency_Key ? { "Idempotency-Key": Idempotency_Key } : {}),
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 217 days ago