"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const query_1=require("@b/utils/query"),utils_1=require("../utils"),error_1=require("@b/utils/error");exports.metadata={summary:"Updates an existing deposit method",operationId:"updateDepositMethod",tags:["Admin","Deposit Methods"],parameters:[{index:0,name:"id",in:"path",description:"ID of the deposit method to update",required:!0,schema:{type:"string"}}],requestBody:{required:!0,description:"New data for the deposit method",content:{"application/json":{schema:utils_1.depositMethodUpdateSchema}}},responses:(0,query_1.updateRecordResponses)("Deposit Method"),requiresAuth:!0,permission:"edit.deposit.method",logModule:"ADMIN_FIN",logTitle:"Update deposit method"};exports.default=async e=>{const{body:t,params:s,ctx:o}=e,{id:i}=s,{image:r,title:d,instructions:a,fixedFee:p,percentageFee:u,minAmount:n,maxAmount:m,customFields:c}=t;null==o||o.step("Fetching deposit method record");let l=c;if("string"==typeof c)try{l=JSON.parse(c)}catch(e){throw(0,error_1.createError)({statusCode:400,message:"Invalid JSON format for customFields"})}null==o||o.step("Updating deposit method");const h=await(0,query_1.updateRecord)("depositMethod",i,{image:r,title:d,instructions:a,fixedFee:p,percentageFee:u,minAmount:n,maxAmount:m,customFields:l});null==o||o.success("Deposit method updated successfully");return h};