Skip to content

Commit

Permalink
Merge pull request #54 from ainize-team/fix/yoojin/trigger_function
Browse files Browse the repository at this point in the history
Fix trigger function
  • Loading branch information
yoojinko authored Sep 21, 2023
2 parents cb56952 + 1544131 commit 97a6915
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/controllers/appController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,30 @@ export default class AppController {
setRuleOps.push(ruleOp);
}

const depositParam = this.depositTriggerFunctionConfig(appName, serviceUrl);
const value = this.buildSetFunctionValue(depositParam);
const funcOp = buildSetOperation("SET_FUNCTION", depositParam.ref, value);
setFunctionOps.push(funcOp);
const depositPath = `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey`
const depositUrl = `${serviceUrl}/deposit`;
const depositParam: setTriggerFunctionParm = {
ref: depositPath,
function_id: "deposit-trigger",
function_type: "REST",
function_url: depositUrl
}
const depositValue = this.buildSetFunctionValue(depositParam);
const depositFuncOp = buildSetOperation("SET_FUNCTION", depositParam.ref, depositValue);
setFunctionOps.push(depositFuncOp);

const serviceFuncPath = Path.app(appName).request("$userAddress", "$requestKey")
const serviceFuncUrl = `${serviceUrl}/service`;
const serviceFuncParam: setTriggerFunctionParm = {
ref: serviceFuncPath,
function_id: "service-trigger",
function_type: "REST",
function_url: serviceFuncUrl
}
const serviceFuncValue = this.buildSetFunctionValue(serviceFuncParam);
const serviceFuncOp = buildSetOperation("SET_FUNCTION", serviceFuncParam.ref, serviceFuncValue);
setFunctionOps.push(serviceFuncOp);

const configOp = this.buildSetAppBillingConfigOp(appName, billingConfig);
setBillingConfigOps.push(configOp);

Expand Down Expand Up @@ -213,13 +233,4 @@ export default class AppController {
const value = !isRemoveOp ? null : true;
return buildSetOperation("SET_VALUE", path, value);
}

private depositTriggerFunctionConfig = (appName: string, serviceUrl: string): setTriggerFunctionParm => {
return {
ref: `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey`,
function_type: "REST",
function_id: "deposit-trigger",
function_url: `${serviceUrl}/deposit`,
}
}
}

0 comments on commit 97a6915

Please sign in to comment.