var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let CRM; (function (CRM) { let Companies; (function (Companies) { let Managers; (function (Managers) { class CompanyManager extends Unibase.Platform.Core.BaseManager { getAssignedCompanies(Ids) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/assignedcompanies/selectedcompanyids/' + Ids; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } getAssignedBranches(BranchIds, UserId) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/getbranchesbyids/selectedbranchids/' + BranchIds + '/userid/' + UserId; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } getWarehousesbyCompanyid(CompanyId, BranchId) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/unibase/platform/companies/getwarehousesbycompanyid/companyid/' + CompanyId + '/branchid/' + BranchId; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } refreshBranchTypes() { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/refreshbranchtypes/np'; return yield this.dataHelper().postAsync(url, "{}").then(function (response) { return response.message; }); }); } getBankBranchDetails(id) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/getbankbranches/bankbranchid/' + id; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } getUserBranches(id) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/getuserbranches/contactid/' + id; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } changeBranch(branchid, partitionid) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/changebranch/branchid/' + branchid + '/partitionid/' + partitionid; return yield this.dataHelper().postAsync(url, null).then(function (response) { if (response.result !== null) var identity = JSON.parse(response.result); identity = Object.keys(identity).reduce((c, k) => (c[k.charAt(0).toLowerCase() + k.slice(1)] = identity[k], c), {}); for (var s = 0; s < identity.settings.length; s++) { identity.settings[s] = Object.keys(identity.settings[s]).reduce((c, k) => (c[k.charAt(0).toLowerCase() + k.slice(1)] = identity.settings[s][k], c), {}); } Unibase.Platform.Membership.Infos.Identity.setCurrentUser(identity); response.result = JSON.parse(response.result); return response; }); }); } getBranch(branchid) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/getbranchbybranchid/branchid/' + branchid; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } getBranches(CompanyId) { return __awaiter(this, void 0, void 0, function* () { const url = 'apis/v4/bizgaze/crm/companies/getallbranchesbycompanyid/companyid/' + CompanyId; return yield this.dataHelper().getAsync(url).then(function (response) { if (response.result !== null) response.result = JSON.parse(response.result); return response; }); }); } static Instance() { if (this._instance === undefined) this._instance = new CompanyManager(); return this._instance; } } Managers.CompanyManager = CompanyManager; })(Managers = Companies.Managers || (Companies.Managers = {})); })(Companies = CRM.Companies || (CRM.Companies = {})); })(CRM = Apps.CRM || (Apps.CRM = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));