A JavaScript library for MNV Ads Client
You can install the mnv-ads-client
using npm
npm install mnv-ads-client
In your JavaScript file, import the MNV Ads Client
class:
import mnvAdsClient from "mnv-ads-client";
Create an instance of the MnvAdsClient class, passing your publisherKey and adsId as arguments:
const mnvAdsClient = new MnvAdsClient({
publisherKey: "YOUR_PUBLISHER_KEY", //STRING, REQUIRED
adsId: "YOUR_ADS_ID", // STRING, REQUIRED
initUri: "MNV ADS INIT URI", // STRING, REQUIRED
enrichUri: "MNV ADS ENRICH URI", // STRING, REQUIRED,
initTimeout: 5000, // NUMBER, OPTIONAL
enrichTimeout: 5000, // NUMBER, OPTIONAL
});
Replace YOUR_PUBLISHER_KEY and YOUR_ADS_ID with your actual publisher key and ads ID. Replace MNVA ADS INIT URI and MNV ADS ENRICH URI with information about these URI's from administator Optionally, you can set request timeout for init and enrich request timeout using number in millisecond. The default timeout for both of them are 5000 milliseconds (5 seconds)
The MNV Ads Client instance has three methods: init, enrich, and initAndEnrich.
Makes a POST request to https://{{mnv-ads-uri}}/webhook/init with the publisherKey and adsId as payload.
mnvAdsClient
.init()
.then((response) => {
console.log(response); // response from https://{{mnv-ads-uri}}/webhook/init
})
.catch((error) => {
console.error(error); // error response from https://{{mnv-ads-uri}}/webhook/init
});
Makes a POST request to https://{{mnv-ads-uri}}/webhook/enrich with the publisherKey, adsId, and referenceId as payload.
const referenceId = "REFERENCE_ID_FROM_INIT_RESPONSE";
mnvAdsClient
.enrich(referenceId)
.then((response) => {
console.log(response); // response from https://{{mnv-ads-uri}}/webhook/enrich
})
.catch((error) => {
console.error(error); // error response from https://{{mnv-ads-uri}}/webhook/enrich
});
Calls init and then enrich sequentially.
mnvAdsClient
.verify()
.then((response) => {
console.log(response); // response from https://{{mnv-ads-uri}}/webhook/enrich
})
.catch((error) => {
console.error(error); // error response from either init or enrich
});
The mnv-ads-client library depends on axios for making HTTP requests.
The mnv-ads-client library is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request to contribute to the library.
If you have any questions or need support, please open an issue or contact the maintainers.