Commit 5b7bf09a by root
2 parents 5c1b85ee 00989511
...@@ -21,3 +21,6 @@ AWS_ACCESS_KEY_ID= ...@@ -21,3 +21,6 @@ AWS_ACCESS_KEY_ID=
AWS_ACCESS_SECRET= AWS_ACCESS_SECRET=
AWS_REGION= AWS_REGION=
AWS_BUCKET= AWS_BUCKET=
SPERTO_API_KEY= "REALATTE-16072021-HVV14-KKJD4-GTCNJ"
CAMPAIGN_KEY="2022110305181116215817187355647526363aa7bc261a662375614"
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"@strapi/provider-email-nodemailer": "^4.3.8", "@strapi/provider-email-nodemailer": "^4.3.8",
"@strapi/provider-upload-aws-s3": "^4.3.9", "@strapi/provider-upload-aws-s3": "^4.3.9",
"@strapi/strapi": "4.3.6", "@strapi/strapi": "4.3.6",
"axios": "^1.1.3",
"better-sqlite3": "7.4.6", "better-sqlite3": "7.4.6",
"pg": "^8.8.0", "pg": "^8.8.0",
"strapi-plugin-ckeditor5": "^2.1.1-rc.1" "strapi-plugin-ckeditor5": "^2.1.1-rc.1"
......
...@@ -68,6 +68,9 @@ ...@@ -68,6 +68,9 @@
"type": "relation", "type": "relation",
"relation": "oneToOne", "relation": "oneToOne",
"target": "plugin::users-permissions.user" "target": "plugin::users-permissions.user"
},
"dialCode": {
"type": "string"
} }
} }
} }
...@@ -29,6 +29,31 @@ module.exports = createCoreController( ...@@ -29,6 +29,31 @@ module.exports = createCoreController(
); );
} }
try {
const spertoCPData = await strapi
.service("api::channel-partner.channel-partner")
.sendCPToSperto(ctx.request.body.data);
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
spertoCPData.headers
);
ctx.request.body.data.httpRequestMethod = spertoCPData.config.method;
ctx.request.body.data.httpRequestUrl = spertoCPData.config.url;
ctx.request.body.data.httpsRequestBody = spertoCPData.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(
spertoCPData.data
);
ctx.request.body.data.thirdPartyApiError=false;
} catch (error) {
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpRequestMethod = error.config.method;
ctx.request.body.data.httpRequestUrl = error.config.url;
ctx.request.body.data.httpsRequestBody = error.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiError=true;
}
return await super.create(ctx); return await super.create(ctx);
}, },
}) })
......
'use strict'; "use strict";
const { default: axios } = require("axios");
/** /**
* channel-partner service * channel-partner service
*/ */
const { createCoreService } = require('@strapi/strapi').factories; const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService('api::channel-partner.channel-partner'); module.exports = createCoreService(
"api::channel-partner.channel-partner",
({ strapi: Strapi }) => ({
async sendCPToSperto(data) {
console.log(data);
const headers = { "Content-Type": "application/json" };
const cpData = {
api_key: process.env.SPERTO_API_KEY,
name: data.contactPersonName,
firm_type: data.firm_type, // --
address: null,
mobile_number: data.mobileNo,
email: data.email,
city: data.city,
state: data.state,
rera_reg_no: data.reraNumber,
region_of_operation: data.regionOfOperation,
pancard: data.pan,
member_of: data.memberOf,
// scanned_cancelled_cheque_url: data.
// scanned_pan_url: data.panFile,
// rera_certificate_url:
firm_name: data.companyName,
// sourcing_manager_id
// gst_certificate_path: data.
};
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_cp_register.php",
cpData,
{ headers: headers }
);
console.log("cp response", spertoResponse);
return spertoResponse;
},
})
);
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
"type": "relation", "type": "relation",
"relation": "oneToOne", "relation": "oneToOne",
"target": "plugin::users-permissions.user" "target": "plugin::users-permissions.user"
},
"dialCode": {
"type": "string"
} }
} }
} }
...@@ -114,8 +114,10 @@ module.exports = factories.createCoreController( ...@@ -114,8 +114,10 @@ module.exports = factories.createCoreController(
); );
// Send an email to the user. // Send an email to the user.
await strapi.plugin("email").service("email").send(emailToSend); // await strapi.plugin("email").service("email").send(emailToSend).sendOTPToSpreto({...ctx.request.body.data,body: emailToSend });
const spretoOTP = await strapi
.service("api::end-user.end-user")
.sendOTPToSpreto(ctx.request.body.data);
// TODO: Send SMS. // TODO: Send SMS.
if (existingEndUser && existingEndUser.length !== 0) { if (existingEndUser && existingEndUser.length !== 0) {
......
'use strict'; "use strict";
const { default: axios } = require("axios");
/** /**
* end-user service * end-user service
*/ */
const { createCoreService } = require('@strapi/strapi').factories; const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService('api::end-user.end-user'); module.exports = createCoreService(
"api::end-user.end-user",
({ strapi: Strapi }) => ({
async sendOTPToSpreto(data) {
console.log(data);
const headers = { "Content-Type": "application/json" };
const otpDetails = {
api_key: process.env.SPERTO_API_KEY,
from_name: data.from_name,
from_mail: data.from_mail,
to: data.to,
subject: data.subject,
body: data.body,
// lead_category: "W",
// campaign_key: process.env.CAMPAIGN_KEY,
// customer_name: data.fullName,
// mobile1_isd: "",
// mobile_no1: data.mobileNumber,
// email_id1: data.email,
// otp_verified_yn: "N",
};
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_send_mail.php",
otpDetails,
{ headers: headers }
);
return spertoResponse;
},
})
);
...@@ -28,6 +28,28 @@ ...@@ -28,6 +28,28 @@
"type": "relation", "type": "relation",
"relation": "oneToOne", "relation": "oneToOne",
"target": "api::project.project" "target": "api::project.project"
},
"httpsRequestBody": {
"type": "text"
},
"httpRequestHeaders": {
"type": "text"
},
"httpRequestUrl": {
"type": "string"
},
"httpRequestMethod": {
"type": "string"
},
"httpResposneBody": {
"type": "text"
},
"thirdPartyApiError": {
"type": "boolean",
"default": false
},
"dialCode": {
"type": "string"
} }
} }
} }
'use strict'; "use strict";
/** /**
* lead controller * lead controller
*/ */
const { createCoreController } = require('@strapi/strapi').factories; const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController('api::lead.lead'); module.exports = createCoreController("api::lead.lead", () => ({
async sendLeads(ctx) {},
async create(ctx) {
try {
const spretoLeadData = await strapi
.service("api::lead.lead")
.sendLeadToSperto(ctx.request.body.data);
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
spretoLeadData.headers
);
ctx.request.body.data.httpRequestMethod = spretoLeadData.config.method;
ctx.request.body.data.httpRequestUrl = spretoLeadData.config.url;
ctx.request.body.data.httpsRequestBody = spretoLeadData.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(
spretoLeadData.data
);
ctx.request.body.data.thirdPartyApiError=false;
} catch (error) {
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpRequestMethod = error.config.method;
ctx.request.body.data.httpRequestUrl = error.config.url;
ctx.request.body.data.httpsRequestBody = error.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiError=true;
}
const leadData = await super.create(ctx);
return ctx.send({
leadData,
});
},
}));
'use strict'; "use strict";
const axios = require("axios");
/** /**
* lead service * lead service
*/ */
const { createCoreService } = require('@strapi/strapi').factories; const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({
async sendLeadToSperto(data) {
console.log(data);
const headers = { "Content-Type": "application/json" };
const leadData = {
api_key: process.env.SPERTO_API_KEY,
lead_category: "W",
campaign_key: process.env.CAMPAIGN_KEY,
customer_name: data.fullName,
mobile1_isd: "",
mobile_no1: data.mobileNumber,
email_id1: data.email,
otp_verified_yn: "N",
};
if (data.comments) {
leadData.comments = data.comments;
}
if (data?.project) {
const projectData = await strapi.db
.query("api::project.project")
.findOne({
where: {
id: data?.project,
},
});
leadData.project_name = projectData.projectName;
}
module.exports = createCoreService('api::lead.lead'); const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
leadData,
{ headers: headers }
);
return spertoResponse;
},
}));
...@@ -140,6 +140,15 @@ ...@@ -140,6 +140,15 @@
}, },
"digitalSalesPresentationURL": { "digitalSalesPresentationURL": {
"type": "string" "type": "string"
},
"brochure": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files"
]
} }
} }
} }
...@@ -138,6 +138,70 @@ ...@@ -138,6 +138,70 @@
} }
}, },
"type": "boolean" "type": "boolean"
},
"dialCode": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
},
"referralDialCode": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
},
"httpsRequestBody": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"httpRequestHeaders": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"httpRequestUrl": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"httpRequestMethod": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"httpResposneBody": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"thirdPartyApiError": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "boolean"
} }
} }
} }
'use strict'; "use strict";
/** /**
* referral controller * referral controller
*/ */
const { createCoreController } = require('@strapi/strapi').factories; const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController('api::referral.referral'); module.exports = createCoreController("api::referral.referral", () => ({
async create(ctx) {
console.log("create started");
try {
const spertoRefereeData = await strapi
.service("api::referral.referral")
.sendReferee(ctx.request.body.data);
console.log("spertoRefereeData", spertoRefereeData.data.member_id);
const spertoReferralData = await strapi.service("api::referral.referral").sendReferral({...ctx.request.body.data, parent_id: spertoRefereeData.data.member_id})
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
spertoRefereeData.headers
);
ctx.request.body.data.httpReferralRequestHeaders = JSON.stringify(
spertoReferralData.headers
);
ctx.request.body.data.httpRequestMethod = spertoRefereeData.config.method;
ctx.request.body.data.httpReferralRequestMethod = spertoReferralData.config.method;
ctx.request.body.data.httpReferralRequestUrl = spertoReferralData.config.url;
ctx.request.body.data.httpRequestUrl = spertoRefereeData.config.url;
ctx.request.body.data.httpsReferralRequestBody = spertoReferralData.config.data;
ctx.request.body.data.httpsRequestBody = spertoRefereeData.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(
spertoRefereeData.data
);
ctx.request.body.data.httpReferralResposneBody = JSON.stringify(
spertoReferralData.data
);
ctx.request.body.data.thirdPartyApiError = false;
} catch (error) {
console.log("error", error);
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpRequestMethod = error.config.method;
ctx.request.body.data.httpRequestUrl = error.config.url;
ctx.request.body.data.httpsRequestBody = error.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiError = true;
}
const referralData = await super.create(ctx);
return ctx.send({
referralData,
});
},
}));
'use strict'; "use strict";
const { default: axios } = require("axios");
/** /**
* referral service * referral service
*/ */
const { createCoreService } = require('@strapi/strapi').factories; const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService(
"api::referral.referral",
({ strapi: Strapi }) => ({
async sendReferral(data) {
console.log(data);
const headers = { "Content-Type": "application/json" };
const referralData = {
api_key: process.env.SPERTO_API_KEY,
campaign_key: process.env.CAMPAIGN_KEY,
member_type: "REFERRAL",
full_name: data.fullName,
mobile1_isd: null,
mobile1: data.mobileNumber,
email1: data.email,
// building: data.building,
wing: data.wing,
unit_name: data.flatNumber ? data.flatNumber : "",
owner_type: data.ownershipType ? data.ownershipType : "",
// buy_type: data.buy_type,
// buy_year: data.buy_year,
terms_agreed: data.termsAndConditions,
resident_yn: data.existingOwner ? "Y" : "N",
// address: data.address,
// country: data.country,
// pincode: data.pincode,
// page_url: null,
referring_location: data.projectReferredTo,
parent_id: data.parent_id,
};
if (data?.project) {
const projectData = await strapi.db
.query("api::project.project")
.findOne({
where: {
id: data?.project,
},
});
referralData.building = projectData.projectName;
}
console.log("entered try");
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php",
referralData,
{ headers: headers }
);
console.log("spertoResponse", spertoResponse);
return spertoResponse;
},
async sendReferee(data) {
console.log(data);
const headers = { "Content-Type": "application/json" };
const refereelData = {
api_key: process.env.SPERTO_API_KEY,
campaign_key: process.env.CAMPAIGN_KEY,
member_type: "REFEREE",
full_name: data.fullName,
mobile1_isd: null,
mobile1: data.mobileNumber,
email1: data.email,
// building: data.building,
wing: data.wing,
unit_name: data.flatNumber ? data.flatNumber : "",
owner_type: data.ownershipType ? data.ownershipType : "",
// buy_type: data.buy_type,
// buy_year: data.buy_year,
terms_agreed: data.termsAndConditions,
resident_yn: data.existingOwner ? "Y" : "N",
// address: data.address,
// country: data.country,
// pincode: data.pincode,
// page_url: null,
referring_location: data.projectReferredTo,
};
module.exports = createCoreService('api::referral.referral'); console.log("entered try");
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php",
refereelData,
{ headers: headers }
);
console.log("spertoResponse", spertoResponse);
return spertoResponse;
},
})
);
...@@ -90,14 +90,13 @@ ...@@ -90,14 +90,13 @@
] ]
}, },
"brochure": { "brochure": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [ "allowedTypes": [
"images", "images",
"files", "files"
"videos", ]
"audios"
],
"type": "media",
"multiple": false
} }
} }
} }
...@@ -67,6 +67,9 @@ ...@@ -67,6 +67,9 @@
"type": "string", "type": "string",
"configurable": false, "configurable": false,
"private": true "private": true
},
"dialCode": {
"type": "string"
} }
} }
} }
...@@ -103,6 +103,7 @@ const userPermissionExtension = (plugin) => { ...@@ -103,6 +103,7 @@ const userPermissionExtension = (plugin) => {
// Send an email to the user. // Send an email to the user.
await strapi.plugin("email").service("email").send(emailToSend); await strapi.plugin("email").service("email").send(emailToSend);
// await getService("user").sendOTPOnEmail(emailToSend);
// TODO: Send SMS. // TODO: Send SMS.
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!