"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const query_1=require("@b/utils/query"),utils_1=require("../utils");exports.metadata={summary:"Updates a specific deposit gateway",operationId:"updateDepositGateway",tags:["Admin","Deposit Gateways"],parameters:[{index:0,name:"id",in:"path",description:"ID of the deposit gateway to update",required:!0,schema:{type:"string"}}],requestBody:{description:"New data for the deposit gateway",content:{"application/json":{schema:utils_1.gatewayUpdateSchema}}},responses:(0,query_1.updateRecordResponses)("Deposit Gateway"),requiresAuth:!0,permission:"edit.deposit.gateway",logModule:"ADMIN_FIN",logTitle:"Update deposit gateway"};exports.default=async e=>{const{body:t,params:a,ctx:s}=e,{id:i}=a,{title:r,description:o,image:n,alias:p,currencies:u,fixedFee:d,percentageFee:c,minAmount:l,maxAmount:y,status:m}=t;null==s||s.step("Fetching deposit gateway record");const g=Array.isArray(u)?u:"string"==typeof u?u.split(",").map(e=>e.trim()):null,f=e=>{if(null==e)return null;if("number"==typeof e)return e;if("string"==typeof e){const t=parseFloat(e);if(!isNaN(t))return t;try{const t=JSON.parse(e);return"object"==typeof t&&null!==t||"number"==typeof t?t:0}catch(e){return 0}}return"object"==typeof e&&null!==e?e:0};null==s||s.step("Updating deposit gateway");const w=await(0,query_1.updateRecord)("depositGateway",i,{title:r,description:o,image:n,alias:p,currencies:g,fixedFee:f(d),percentageFee:f(c),minAmount:f(l),maxAmount:f(y),status:m});null==s||s.success("Deposit gateway updated successfully");return w};