import { Action, task, api } from "actionhero"; export class ListShopSettings extends Action { constructor () { super() this.name = 'listShopSettings' this.description = 'I list all order Logs' this.outputExample = {} this.inputs = {} } async run ({ response, params, session }) { const {shopifySession} = session; response.data = await api.shopSettings.list(shopifySession.shop); } } export class SetShopSetting extends Action { constructor () { super() this.name = 'setShopSetting' this.description = 'I get a specific order log' this.outputExample = {} this.inputs = { exportInterval : { required:false }, exportLocation : { required:false }, exportPatern : { required:false }, webhooks : {required: false}, ftp_password : {required: false} } } async run ({ response, params, session }) { const {shopifySession} = session; const {action, apiVersion, ...settings} = params for (var setting in settings) { if (settings.hasOwnProperty(setting)) { await api.shopSettings.set(shopifySession.shop, setting, settings[setting]); } } response.data = await api.shopSettings.list(shopifySession.shop); } } export class UninstallWebhook extends Action { constructor () { super() this.name = 'uninstallWebhook' this.description = 'I erase all shop settings' this.outputExample = {} this.inputs = { xShopifyApiVersion: {required: false}, xShopifyHmacSha256: {required: false}, xShopifyShopDomain: {required: false}, xShopifyTest: {required: false}, xShopifyTopic: {required: false} } } async run ({ response, params, session }) { const { xShopifyShopDomain } = params; await api.shopSettings.removeSettings(xShopifyShopDomain); await api.shopifyShops.removeShop(xShopifyShopDomain); } }