import { Action, task, api } from "actionhero"; export class OrderLogsList extends Action { constructor () { super() this.name = 'orderLogsList' this.description = 'I list all order Logs' this.outputExample = {} this.inputs = { filter: {required: false}, offset: {required: false}, limit: {required: false}, sort: {required: false} } } async run ({ response, params, session }) { const where = params.filter && JSON.parse(params.filter); const sort = params.sort && JSON.parse(params.sort); const limit = (params.sort && JSON.parse(params.limit)) || 10; const offset = (params.sort && JSON.parse(params.offset)) || 0; const boundLimit = Math.min(limit, 100); const {shopifySession} = session; const exportLogData = await api.exportLogs.orders.list(shopifySession.shop, where, boundLimit, offset, sort); //console.log(exportLogData.rows); response.data = exportLogData.rows; response.pagination = { count: exportLogData.count, boundLimit, offset, } } } export class OrderLogGet extends Action { constructor () { super() this.name = 'orderLogGet' this.description = 'I get a specific order log' this.outputExample = {} this.inputs = { id : { required:true } } } async run ({ response, params, session }) { const {shopifySession} = session; response.data = await api.exportLogs.orders.getLog(params.id, shopifySession.shop); } } export class CronLogsList extends Action { constructor () { super() this.name = 'cronLogsList' this.description = 'I list all cron logs' this.outputExample = {} this.inputs = { filter: {required: false}, offset: {required: false}, limit: {required: false}, sort: {required: false} } } async run ({ response, params, session }) { const where = params.filter && JSON.parse(params.filter); const sort = params.sort && JSON.parse(params.sort); const limit = (params.sort && JSON.parse(params.limit)) || 10; const offset = (params.sort && JSON.parse(params.offset)) || 0; const boundLimit = Math.min(limit, 100); const {shopifySession} = session; const exportLogData = await api.exportLogs.cron.list(shopifySession.shop, where, boundLimit, offset, sort); response.data = exportLogData.rows; response.pagination = { count: exportLogData.count, boundLimit, offset, } } } export class CronLogGet extends Action { constructor () { super() this.name = 'cronLogGet' this.description = 'I get a specific cron log' this.outputExample = {} this.inputs = { id : { required:true } } } async run ({ response, params, session }) { const {shopifySession} = session; response.data = await api.exportLogs.cron.getLog(params.id, shopifySession.shop); } }