{"version":3,"file":"perp-notifications.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/perp-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,mCAAmC;AAIpC,MAAM,CAAC,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAC5D,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,SAAS,gBAAgB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,WAAmB,EACnB,UAAsB;IAEtB,IAAI,CAAC;QACH,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;YAC7C,OAAO,eAAe,CAAC,uBAAuB,EAAE;gBAC9C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,aAAa,EAAE,UAAU,WAAW,EAAE;iBACvC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;aACjC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;AACH,CAAC","sourcesContent":["import {\n  createServicePolicy,\n  successfulFetch,\n} from '@metamask/controller-utils';\n\nimport type { OrderInput } from '../types';\n\nexport const PERPS_API = 'https://perps.api.cx.metamask.io';\nexport const PERPS_API_CREATE_ORDERS = `${PERPS_API}/api/v1/orders`;\n\n/**\n * Sends a perp order to our API to create a perp order subscription\n *\n * @param bearerToken - JWT for authentication\n * @param orderInput - order input shape\n */\nexport async function createPerpOrderNotification(\n  bearerToken: string,\n  orderInput: OrderInput,\n): Promise<void> {\n  try {\n    await createServicePolicy().execute(async () => {\n      return successfulFetch(PERPS_API_CREATE_ORDERS, {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json',\n          Authorization: `Bearer ${bearerToken}`,\n        },\n        body: JSON.stringify(orderInput),\n      });\n    });\n  } catch (error) {\n    console.error('Failed to create perp order notification', error);\n  }\n}\n"]}