Edits history of script submission #14595 for ' Get transfer (brex)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Brex = {
      token: string;
    };
    /**
     * 
    Get transfer
    
     * 
    This endpoint gets a transfer by ID.
    
    Currently, the API can only return transfers for the following payment rails:
    - ACH
    - DOMESTIC_WIRE
    - CHEQUE
    - INTERNATIONAL_WIRE
    
     */
    export async function main(auth: Brex, id: string) {
      const url = new URL(`https://platform.brexapis.com/v1/transfers/${id}`);
    
      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.json();
    }
    

    Submitted by hugo697 217 days ago