Providers status example

Retrieve the business' providers and their status. Optionally include a provider number as a query param to filter the results and retrieve only a single provider.

by joshpiper_medipass

HTML

<script src="https://unpkg.com/@medipass/partner-sdk/umd/@medipass/partner-sdk.min.js"></script>
<div id="providers">
  
</div>

JavaScript

// import MedipassTransactionSDK from '@medipass/partner-sdk';
// const MedipassTransactionSDK = require('@medipass/partner-sdk');

MedipassTransactionSDK.setConfig({
  env: 'stg', // Enter the environment you want to target (stg/prod)
  apiKey: 'xyz', // Can be found in your business settings in Connect
  appId: 'my-app', // Your application identifier
  appVersion: '1.0.0' // The transaction SDK version to target 
});

/**
 * Retrieve a list of the business' providers, and optionally filter by provider number.
 *
 * Example response:
 * {
 *   "providers": [
 *     {
 *         "providerNumber": "1234567A",
 *         "funders": [
 *             {
 *                 "displayName": "Example 1",
 *                 "code": "exmpl1"
 *             }
 *         ]
 *     },
 *     {
 *         "providerNumber": "11111111",
 *         "funders": [
 *             {
 *                 "displayName": "Example 1",
 *                 "code": "exmpl1"
 *             },
 *             {
 *                 "displayName": "Example 2",
 *                 "code": "exmpl2"
 *             }
 *         ]
 *     }
 *   ]
 * }   
 */
async function main() {
  // Optional provider number to filter the results
  const providerNumber = '1234567A';

  const {
    providers
  } = await MedipassTransactionSDK.providers.getProvidersStatus({
    query: {
      providerNumber
    }
  });

  document.getElementById('providers').textContent = JSON.stringify(providers, null, 2);
}

main();