"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.strikeApiRequest = strikeApiRequest; exports.strikeApiRequestAllItems = strikeApiRequestAllItems; async function strikeApiRequest(method, endpoint, body = {}, query = {}) { const credentials = await this.getCredentials('strikeApi'); const baseUrl = credentials.environment === 'sandbox' ? 'https://api.strike.me' : 'https://api.strike.me'; const options = { method, url: `${baseUrl}/v1${endpoint}`, headers: { 'Content-Type': 'application/json', }, body, qs: query, json: true, }; if (Object.keys(body).length === 0) { delete options.body; } if (Object.keys(query).length === 0) { delete options.qs; } return this.helpers.requestWithAuthentication.call(this, 'strikeApi', options); } async function strikeApiRequestAllItems(method, endpoint, body = {}, query = {}) { const returnData = []; let responseData; query.$top = query.$top || 100; query.$skip = 0; do { responseData = await strikeApiRequest.call(this, method, endpoint, body, query); const items = responseData.items || responseData; if (Array.isArray(items)) { returnData.push(...items); } query.$skip += query.$top; } while (responseData.items && responseData.items.length === query.$top); return returnData; }