Skip to main content

DiscountsApi

All URIs are relative to http://localhost

MethodHTTP requestDescription
activateRandomYatCodePOST /codes/{code_id}/random_yatUse random yat code
addPubkeyForCodePOST /codes/{code_id}/pubkeys/{pubkey}Add pubkey for code
listCodesGET /codesFetch codes
revokePubkeyForCodeDELETE /codes/{code_id}/pubkeys/{pubkey}Revoke pubkey for code

activateRandomYatCode#

/*** @returns DisplayOrder**/async function activateRandomYatCode(codeId: String, body: RandomYatActivateBody)

Use random yat code

Notes:#

Creates cart with random yat

Example#

const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let codeId = null; // String // populate codeId...
let body = new YatJs.RandomYatActivateBody(); // RandomYatActivateBody // populate body...
try {  let res = await api.discounts().activateRandomYatCode(codeId, body);  // res is of type DisplayOrder  console.log('API called successfully. Result: ', res);} catch (error) {  console.error(error);}

Parameters#

NameTypeDescriptionNotes
codeIdString
bodyRandomYatActivateBody

Return type#

DisplayOrder

Authorization#

apiKey

HTTP request headers#

  • Content-Type: Not defined
  • Accept: /

addPubkeyForCode#

/*** @returns String**/async function addPubkeyForCode(codeId: String, pubkey: String)

Add pubkey for code

Notes:#

NOTE: user should have scope OrganizationCodeAdmin or CodeWrite

Example#

const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let codeId = null; // String // populate codeId...
let pubkey = "pubkey_example"; // String | Public key to authorize usage of a code// populate pubkey...
try {  let res = await api.discounts().addPubkeyForCode(codeId, pubkey);  // res is of type String  console.log('API called successfully. Result: ', res);} catch (error) {  console.error(error);}

Parameters#

NameTypeDescriptionNotes
codeIdString
pubkeyStringPublic key to authorize usage of a code

Return type#

String

Authorization#

two_factor

HTTP request headers#

  • Content-Type: Not defined
  • Accept: /

listCodes#

/*** @returns ListOfCodeAvailability**/async function listCodes(opts)

Fetch codes

Notes:#

Return codes with their usage and availability information NOTE: user should have scope OrganizationCodeAdmin or CodeRead

Example#

const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let opts = {  'codeType': "codeType_example", // String | Optional: filter by code type  'dir': "dir_example", // String |   'limit': 56, // Number |   'organizationId': null, // String | Optional: filter by organization id  'page': 56, // Number |   'sort': "sort_example" // String | };try {  let res = await api.discounts().listCodes(opts);  // res is of type ListOfCodeAvailability  console.log('API called successfully. Result: ', res);} catch (error) {  console.error(error);}

Parameters#

NameTypeDescriptionNotes
codeTypeStringOptional: filter by code type[optional]
dirString[optional]
limitNumber[optional]
organizationIdString
Optional: filter by organization id[optional]
pageNumber[optional]
sortString[optional]

Return type#

ListOfCodeAvailability

Authorization#

apiKey

HTTP request headers#

  • Content-Type: Not defined
  • Accept: /

revokePubkeyForCode#

/*** @returns String**/async function revokePubkeyForCode(codeId: String, pubkey: String)

Revoke pubkey for code

Notes:#

NOTE: user should have scope OrganizationCodeAdmin or CodeWrite

Example#

const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let codeId = null; // String // populate codeId...
let pubkey = "pubkey_example"; // String | Public key to authorize usage of a code// populate pubkey...
try {  let res = await api.discounts().revokePubkeyForCode(codeId, pubkey);  // res is of type String  console.log('API called successfully. Result: ', res);} catch (error) {  console.error(error);}

Parameters#

NameTypeDescriptionNotes
codeIdString
pubkeyStringPublic key to authorize usage of a code

Return type#

String

Authorization#

two_factor

HTTP request headers#

  • Content-Type: Not defined
  • Accept: /