Commit 57bb633f by jay

initial commit

1 parent dc363670
Showing 77 changed files with 24 additions and 2683 deletions
......@@ -7,9 +7,9 @@ JWT_SECRET=tobemodified
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=offers
DATABASE_USERNAME=harishpatel
DATABASE_PASSWORD=harishpatel
DATABASE_NAME=games
DATABASE_USERNAME=jay
DATABASE_PASSWORD=postgres
DATABASE_SCHEMA=public
SMTP_HOST=smtp.mailtrap.io
......
......@@ -16,9 +16,9 @@ module.exports = ({ env }) => ({
connection: {
host: env("DATABASE_HOST", "localhost"),
port: env.int("DATABASE_PORT", 5432),
database: env("DATABASE_NAME", "strapidev"),
user: env("DATABASE_USERNAME", "harishpatel"),
password: env("DATABASE_PASSWORD", "harishpatel"),
database: env("DATABASE_NAME", "games"),
user: env("DATABASE_USERNAME", "jay"),
password: env("DATABASE_PASSWORD", "postgres"),
schema: env("DATABASE_SCHEMA", "public"), // Not required
// ssl: {
// rejectUnauthorized: env.bool("DATABASE_SSL_SELF", false)
......
{
"kind": "collectionType",
"collectionName": "amenities",
"info": {
"singularName": "amenity",
"pluralName": "amenities",
"displayName": "Amenity",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"icon": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"type": {
"type": "enumeration",
"enum": [
"Internal",
"External",
"Common"
]
},
"serialNumber": {
"type": "integer",
"default": 0
}
}
}
'use strict';
/**
* amenity controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::amenity.amenity');
'use strict';
/**
* amenity router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::amenity.amenity');
'use strict';
/**
* amenity service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::amenity.amenity');
{
"kind": "collectionType",
"collectionName": "banking_partners",
"info": {
"singularName": "banking-partner",
"pluralName": "banking-partners",
"displayName": "Banking Partner",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"logo": {
"type": "media",
"multiple": false,
"required": true,
"allowedTypes": [
"images"
]
},
"title": {
"type": "string"
},
"serialNumber": {
"type": "integer",
"default": 1,
"required": true
}
}
}
'use strict';
/**
* banking-partner controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::banking-partner.banking-partner');
'use strict';
/**
* banking-partner router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::banking-partner.banking-partner');
'use strict';
/**
* banking-partner service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::banking-partner.banking-partner');
{
"kind": "collectionType",
"collectionName": "channel_partners",
"info": {
"singularName": "channel-partner",
"pluralName": "channel-partners",
"displayName": "Channel Partner",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"companyName": {
"type": "string",
"required": true
},
"companyType": {
"type": "string"
},
"contactPersonName": {
"type": "string"
},
"email": {
"type": "string"
},
"communicationAddress": {
"type": "text"
},
"mobileNo": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"reraNumber": {
"type": "string"
},
"regionOfOperation": {
"type": "string"
},
"sourcingManager": {
"type": "string"
},
"pan": {
"type": "string"
},
"panFile": {
"type": "media",
"multiple": true,
"required": false,
"allowedTypes": [
"images",
"files"
]
},
"memberOf": {
"type": "string"
},
"termsAndConditions": {
"type": "boolean"
},
"user": {
"type": "relation",
"relation": "oneToOne",
"target": "plugin::users-permissions.user"
},
"dialCode": {
"type": "string"
},
"httpSMSResposneBody": {
"type": "text"
},
"httpSMSRequestMethod": {
"type": "text"
},
"httpSMSRequestUrl": {
"type": "text"
},
"httpSMSRequestHeaders": {
"type": "text"
},
"httpsSMSRequestBody": {
"type": "text"
},
"thirdPartyApiError": {
"type": "boolean"
},
"httpEmailResposneBody": {
"type": "text"
},
"httpEmailRequestMethod": {
"type": "text"
},
"httpEmailRequestUrl": {
"type": "text"
},
"httpEmailRequestHeaders": {
"type": "text"
},
"httpsEmailRequestBody": {
"type": "text"
},
"httpThirdPartyOTPApiRequestMethod": {
"type": "text"
},
"httpThirdPartyOTPApiRequestUrl": {
"type": "text"
},
"httpsThirdPartyOTPApiRequestBody": {
"type": "text"
},
"httpThirdPartyOTPApiResposneBody": {
"type": "text"
},
"httpThirdPartyOTPApiError": {
"type": "boolean"
},
"token": {
"type": "text"
},
"httpRegisterCPResposneBody": {
"type": "text"
},
"httpRegisterCPRequestMethod": {
"type": "text"
},
"httpRegisterCPRequestUrl": {
"type": "text"
},
"httpRegisterCPRequestHeaders": {
"type": "text"
},
"httpsRegisterCPRequestBody": {
"type": "text"
},
"thirdPartyApiRegisterCPError": {
"type": "boolean"
}
}
}
"use strict";
/**
* channel-partner controller
*/
const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController(
"api::channel-partner.channel-partner",
({ strapi: Strapi }) => ({
async create(ctx) {
console.log(ctx);
// const currentChannelPartner = ctx.state.user;
const reraNumber = ctx.request.body?.data?.reraNumber;
console.log(reraNumber);
if (!reraNumber) {
return ctx.bad(`Please specify your rera number.`);
}
// 1. check if the channel partner already exist
const existingChannelPartner = await strapi.entityService.findMany(
"api::channel-partner.channel-partner",
{
filters: { reraNumber: reraNumber },
}
);
// if (existingChannelPartner && existingChannelPartner.length !== 0) {
// return ctx.badRequest(
// `Channel Partner Already Exist with the Given rera number ${reraNumber}`
// );
// }
// try {
// const spertoRegisterCP = await strapi
// .service("api::channel-partner.channel-partner")
// .sendCPToSperto(ctx.request.body.data);
// console.log("Helllo >>>>>>>>", spertoRegisterCP);
// ctx.request.body.data.httpRegisterCPRequestHeaders = JSON.stringify(
// spertoRegisterCP.headers
// );
// ctx.request.body.data.httpRegisterCPRequestMethod =
// spertoRegisterCP.config.method;
// ctx.request.body.data.httpRegisterCPRequestUrl =
// spertoRegisterCP.config.url;
// ctx.request.body.data.httpsRegisterCPRequestBody =
// spertoRegisterCP.config.data;
// ctx.request.body.data.httpRegisterCPResposneBody = JSON.stringify(
// spertoRegisterCP.data
// );
// ctx.request.body.data.thirdPartyApiRegisterCPError = false;
// } catch (error) {
// ctx.request.body.data.httpRegisterCPRequestHeaders = JSON.stringify(
// error.config.headers
// );
// ctx.request.body.data.httpRegisterCPRequestMethod = error.config.method;
// ctx.request.body.data.httpRegisterCPRequestUrl = error.config.url;
// ctx.request.body.data.httpsRegisterCPRequestBody = error.config.data;
// ctx.request.body.data.httpRegisterCPResposneBody = JSON.stringify(error.message);
// ctx.request.body.data.thirdPartyApiRegisterCPError=true;
// }
return await super.create(ctx);
},
async regsiterCPToSperto(ctx) {
// console.log(ctx);
// const currentChannelPartner = ctx.state.user;
const reraNumber = ctx.request.body.reraNumber;
// console.log(reraNumber);
// if (existingChannelPartner && existingChannelPartner.length !== 0) {
// return ctx.badRequest(
// `Channel Partner Already Exist with the Given rera number ${reraNumber}`
// );
// }
try {
const spertoRegisterCP = await strapi
.service("api::channel-partner.channel-partner")
.sendCPToSperto(ctx.request.body);
// console.log("Helllo >>>>>>>>", spertoRegisterCP);
ctx.request.body.httpRegisterCPRequestHeaders = JSON.stringify(
spertoRegisterCP.headers
);
ctx.request.body.httpRegisterCPRequestMethod =
spertoRegisterCP.config.method;
ctx.request.body.httpRegisterCPRequestUrl = spertoRegisterCP.config.url;
ctx.request.body.httpsRegisterCPRequestBody =
spertoRegisterCP.config.data;
ctx.request.body.httpRegisterCPResposneBody = JSON.stringify(
spertoRegisterCP.data
);
ctx.request.body.thirdPartyApiRegisterCPError = false;
} catch (error) {
ctx.request.body.httpRegisterCPRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.httpRegisterCPRequestMethod = error.config.method;
ctx.request.body.httpRegisterCPRequestUrl = error.config.url;
ctx.request.body.httpsRegisterCPRequestBody = error.config.data;
ctx.request.body.httpRegisterCPResposneBody = JSON.stringify(
error.message
);
ctx.request.body.thirdPartyApiRegisterCPError = true;
}
// const existingChannelPartner = await strapi.entityService.findOne(
// "api::channel-partner.channel-partner",
// where: {
// reraNumber: reraNumber
// }
// );
const existingChannelPartner = await strapi
.query("api::channel-partner.channel-partner")
.findOne({
// populate: ["id"],
where: {
$and: [{ reraNumber: reraNumber }],
},
});
console.log("existingChannelPartner >>>>>>>>>>", existingChannelPartner);
const res = await strapi.entityService.update(
"api::channel-partner.channel-partner",
existingChannelPartner.id,
{
data: {
httpRegisterCPRequestHeaders:
ctx.request.body.httpRegisterCPRequestHeaders,
httpRegisterCPRequestMethod:
ctx.request.body.httpRegisterCPRequestMethod,
httpRegisterCPRequestUrl: ctx.request.body.httpRegisterCPRequestUrl,
httpsRegisterCPRequestBody:
ctx.request.body.httpsRegisterCPRequestBody,
httpRegisterCPResposneBody:
ctx.request.body.httpRegisterCPResposneBody,
thirdPartyApiRegisterCPError:
ctx.request.body.thirdPartyApiRegisterCPError,
},
}
);
console.log("res >>>>>",res);
ctx.send({ ok: true, data: res});
},
})
);
'use strict';
/**
* channel-partner router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::channel-partner.channel-partner');
const routes = {
routes: [
{
method: "POST",
path: "/channel-partner/register-cp-to-sperto",
handler: "api::channel-partner.channel-partner.regsiterCPToSperto",
config: {
// some configuration...
}
},
]
};
module.exports = routes;
"use strict";
// const { default: axios } = require("axios");
const axios = require("axios");
/**
* channel-partner service
*/
const { createCoreService } = require("@strapi/strapi").factories;
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.companyType, // --
address: data.communicationAddress,
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: Number(data.sourcingManager),
// 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;
},
async getCPDataFromSperto(data) {
// console.log(data);
const headers = { "Content-Type": "application/json" };
const cpData = {
api_key: process.env.SPERTO_API_KEY,
// cp_rera_no: "RE12389222"
cp_rera_no: data.mahareraNumber,
// sourcing_manager_id
// gst_certificate_path: data.
};
const spertoCPOTPResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_cp_login.php",
cpData,
{ headers: headers }
);
// console.log("cp response", spertoCPOTPResponse);
return spertoCPOTPResponse;
},
})
);
{
"kind": "singleType",
"collectionName": "company_informations",
"info": {
"singularName": "company-information",
"pluralName": "company-informations",
"displayName": "Company Information",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"companyEmail": {
"type": "string",
"required": true
},
"companyContactNumber": {
"type": "string"
},
"facebookPage": {
"type": "text"
},
"twitterPage": {
"type": "text"
},
"youtubePage": {
"type": "text"
},
"instagramPage": {
"type": "text"
},
"linkedinPage": {
"type": "text"
},
"logo": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
}
}
}
'use strict';
/**
* company-information controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::company-information.company-information');
'use strict';
/**
* company-information router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::company-information.company-information');
'use strict';
/**
* company-information service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::company-information.company-information');
{
"kind": "singleType",
"collectionName": "cp_connect_pages",
"info": {
"singularName": "cp-connect-page",
"pluralName": "cp-connect-pages",
"displayName": "Cp Connect Page",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"banner": {
"type": "media",
"multiple": false,
"required": true,
"allowedTypes": [
"images"
]
},
"content": {
"type": "richtext",
"required": true
},
"disclaimer": {
"type": "richtext",
"required": true
},
"cpGuidelines": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"invoice": {
"allowedTypes": [
"images",
"videos",
"audios",
"files"
],
"type": "media",
"multiple": false
}
}
}
'use strict';
/**
* cp-connect-page controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::cp-connect-page.cp-connect-page');
'use strict';
/**
* cp-connect-page router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::cp-connect-page.cp-connect-page');
'use strict';
/**
* cp-connect-page service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::cp-connect-page.cp-connect-page');
{
"kind": "collectionType",
"collectionName": "custom_pdfs",
"info": {
"singularName": "custom-pdf",
"pluralName": "custom-pdfs",
"displayName": "Custom PDFs",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"pdf": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
}
}
}
'use strict';
/**
* custom-pdf controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::custom-pdf.custom-pdf');
'use strict';
/**
* custom-pdf router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::custom-pdf.custom-pdf');
'use strict';
/**
* custom-pdf service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::custom-pdf.custom-pdf');
{
"kind": "singleType",
"collectionName": "delivery_stats",
"info": {
"singularName": "delivery-stat",
"pluralName": "delivery-stats",
"displayName": "Delivery Stat",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"backgroundImage": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"stat2Label": {
"type": "string"
},
"stat3Label": {
"type": "string"
},
"stat4Label": {
"type": "string"
},
"stat2Value": {
"type": "string"
},
"stat3Value": {
"type": "string"
},
"stat4Value": {
"type": "string"
}
}
}
'use strict';
/**
* delivery-stat controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::delivery-stat.delivery-stat');
'use strict';
/**
* delivery-stat router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::delivery-stat.delivery-stat');
'use strict';
/**
* delivery-stat service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::delivery-stat.delivery-stat');
{
"kind": "collectionType",
"collectionName": "end_users",
"info": {
"singularName": "end-user",
"pluralName": "end-users",
"displayName": "End User",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"fullName": {
"type": "string"
},
"mobileNo": {
"type": "string",
"unique": true
},
"whatsappAccepted": {
"type": "boolean"
},
"user": {
"type": "relation",
"relation": "oneToOne",
"target": "plugin::users-permissions.user"
},
"dialCode": {
"type": "string"
},
"httpsRequestBody": {
"type": "text"
},
"httpRequestHeaders": {
"type": "text"
},
"httpRequestUrl": {
"type": "text"
},
"httpRequestMethod": {
"type": "string"
},
"httpResposneBody": {
"type": "text"
},
"thirdPartyApiError": {
"type": "boolean"
},
"httpsRequestEmailBody": {
"type": "text"
},
"httpRequestEmailHeaders": {
"type": "text"
},
"httpRequestEmailUrl": {
"type": "text"
},
"httpRequestEmailMethod": {
"type": "text"
},
"httpResposneEmailBody": {
"type": "text"
},
"httpsRequestIsVerifiedBody": {
"type": "text"
},
"httpRequestIsVerifiedHeaders": {
"type": "text"
},
"httpRequestIsVerifiedUrl": {
"type": "text"
},
"httpRequestIsVerifiedMethod": {
"type": "text"
},
"httpResposneIsVerifiedBody": {
"type": "text"
},
"httpsSMSRequestBody": {
"type": "text"
},
"httpSMSRequestHeaders": {
"type": "text"
},
"httpSMSRequestUrl": {
"type": "text"
},
"httpSMSRequestMethod": {
"type": "text"
},
"httpSMSResposneBody": {
"type": "text"
}
}
}
"use strict";
const fs = require("fs");
/**
* end-user controller
*/
const { factories } = require("@strapi/strapi");
const { getService } = require("@strapi/plugin-users-permissions/server/utils");
const utils = require("@strapi/utils");
const { sanitize } = utils;
const { ValidationError } = utils.errors;
module.exports = factories.createCoreController(
"api::end-user.end-user",
({ strapi: Strapi }) => ({
// Method 1: Creating an entirely custom action
// async finishEndUserOtpVerification(ctx) {
// (await strapi.service) <
// PostService >
// "api::post.post".exampleService({});
// try {
// ctx.body = "ok";
// } catch (err) {
// ctx.body = err;
// }
// },
// Method 1: Creating an entirely custom action
async finishEndUserOtpVerification(ctx) {
const { mobileNo, oneTimePassword } = ctx.request.body;
// console.log(">>>>>> One", ctx.request.body);
// 1. Identify the end-user record using the above.
const endUser = await strapi.query("api::end-user.end-user").findOne({
populate: ["user"],
where: {
$and: [{ publishedAt: { $null: true } }, { mobileNo: mobileNo }],
},
});
if (!endUser) {
throw new ValidationError("Invalid mobile number.");
}
// console.log(" >>>> two ", endUser);
// 2. Then identify the user record using step 1.
// 3. Verify otp.
const user = await strapi
.query("plugin::users-permissions.user")
.findOne({
where: {
$and: [
{ id: endUser.user.id },
{ oneTimePassword: oneTimePassword },
],
},
});
if (!user || user.blocked) {
throw new ValidationError("Code provided is not valid.");
}
try {
// console.log("inside try", user.email);
const spretoLeadData = await strapi
.service("api::end-user.end-user")
.sendLeadToSperto({ ...endUser, email: user.email }, "Y");
// console.log("spretoLeadData.data", spretoLeadData.data);
ctx.request.body.httpRequestIsVerifiedHeaders = JSON.stringify(
spretoLeadData.headers
);
ctx.request.body.httpRequestIsVerifiedMethod =
spretoLeadData.config.method;
ctx.request.body.httpRequestIsVerifiedUrl = spretoLeadData.config.url;
ctx.request.body.httpsRequestIsVerifiedBody =
spretoLeadData.config.data;
ctx.request.body.httpResposneIsVerifiedBody = JSON.stringify(
spretoLeadData.data
);
ctx.request.body.thirdPartyApiError = false;
} catch (error) {
console.log(error);
ctx.request.body.httpRequestIsVerifiedHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.httpRequestIsVerifiedMethod = error.config.method;
ctx.request.body.httpRequestIsVerifiedUrl = error.config.url;
ctx.request.body.httpsRequestIsVerifiedBody = error.config.data;
ctx.request.body.httpResposneIsVerifiedBody = JSON.stringify(
error.message
);
ctx.request.body.thirdPartyApiError = true;
}
// 4. stamp otp in user to null.
await getService("user").edit(user.id, {
oneTimePassword: null,
password: oneTimePassword,
});
// 5. change from draft to published.
await strapi.entityService.update("api::end-user.end-user", endUser.id, {
data: {
publishedAt: new Date(),
httpRequestIsVerifiedHeaders:
ctx.request.body.httpRequestIsVerifiedHeaders,
httpsRequestIsVerifiedBody:
ctx.request.body.httpsRequestIsVerifiedBody,
httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl,
httpRequestIsVerifiedMethod:
ctx.request.body.httpRequestIsVerifiedMethod,
httpResposneIsVerifiedBody:
ctx.request.body.httpResposneIsVerifiedBody,
},
});
// TODO: at this point we might have to invoke a Hiranandani API to send the newly registered user there.
ctx.send({ ok: true, message: "user registered" });
},
// Wrapping a core action (leaves core logic in place)
async create(ctx) {
// console.log("ctx.request.body", ctx.request.body);
try {
const spretoLeadData = await strapi
.service("api::end-user.end-user")
.sendLeadToSperto(ctx.request.body.data, "N");
// console.log("spretoLeadData.data", spretoLeadData.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 currentUser = ctx.state.user;
// 2. check if the current user already has an existing business listing (existingEndUser) against their name.
const existingEndUser = await strapi.entityService.findMany(
"api::end-user.end-user",
{
fields: ["id"],
filters: { mobileNo: ctx.request.body.data.mobileNo },
}
);
const oneTimePassword = Math.floor(100000 + Math.random() * 900000);
const emailToSend = {
oneTimePassword: oneTimePassword,
to: ctx.request.body.data.email,
from: `contact@hiranandani.net`,
// replyTo: undefined,
subject: `Your Request for One Time Password`,
text: `Hello ${"Jay Mehta"}, Your one time password to login to your end user portal is ${oneTimePassword}`,
html: `<p>Dear ${ctx.request.body.data.fullName},
Your OTP for Hiranandani Exclusive website login is <strong>${oneTimePassword}</strong> . Valid for 10 minutes. Please do not
share this OTP.
Regards,
Hiranandani Team.`,
};
// NOTE: Update the user before sending the email so an Admin can generate the link if the email fails
await strapi.entityService.update(
"plugin::users-permissions.user",
currentUser.id,
{
data: {
oneTimePassword: `${oneTimePassword}`,
},
}
);
ctx.request.body.data = { ...ctx.request.body.data, emailToSend };
// console.log("ctx.request.body.data", ctx.request.body.data);
// Send an email to the user.
// await strapi.plugin("email").service("email").send(emailToSend).sendOTPToSpreto({...ctx.request.body.data,body: emailToSend });
try {
const spretoOTP = await strapi
.service("api::end-user.end-user")
.sendOTPToSpreto(ctx.request.body.data);
// console.log("spretoOTP>>>>>>>>", spretoOTP);
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
spretoOTP.spertoEmailResponse.headers
);
ctx.request.body.data.httpRequestEmailMethod =
spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpRequestEmailUrl =
spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsRequestEmailBody =
spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpResposneEmailBody = JSON.stringify(
spretoOTP.spertoEmailResponse.data
);
ctx.request.body.data.httpSMSRequestHeaders = JSON.stringify(
spretoOTP.spertoSMSResponse.headers
);
ctx.request.body.data.httpSMSRequestMethod =
spretoOTP.spertoSMSResponse.config.method;
ctx.request.body.data.httpSMSRequestUrl =
spretoOTP.spertoSMSResponse.config.url;
ctx.request.body.data.httpsSMSRequestBody =
spretoOTP.spertoSMSResponse.config.data;
ctx.request.body.data.httpSMSResposneBody = JSON.stringify(
spretoOTP.spertoSMSResponse.data
);
ctx.request.body.data.thirdPartyApiError = false;
} catch (error) {
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpRequestEmailMethod = error.config.method;
ctx.request.body.data.httpRequestEmailUrl = error.config.url;
ctx.request.body.data.httpsRequestEmailBody = error.config.data;
ctx.request.body.data.httpResposneEmailBody = JSON.stringify(
error.message
);
ctx.request.body.data.httpSMSRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpSMSRequestMethod = error.config.method;
ctx.request.body.data.httpSMSRequestUrl = error.config.url;
ctx.request.body.data.httpsSMSRequestBody = error.config.data;
ctx.request.body.data.httpSMSResposneBody = JSON.stringify(
error.message
);
ctx.request.body.data.thirdPartyApiError = true;
}
// TODO: Send SMS.
if (existingEndUser && existingEndUser.length !== 0) {
console.log(`Found existing end user: `);
console.log(existingEndUser);
// This makes sure that we are updating the existing business listing only.
ctx.params.id = existingEndUser[0].id;
return super.update(ctx);
} else {
// We make sure that the newly created listing is created against the current business owner.
ctx.request.body.data["user"] = currentUser.id;
// Now go ahead and create the listing.
return await super.create(ctx);
}
},
async removedirectory(ctx) {
// directory path
const dir = `${__dirname}/../../../../../offers-frontend`;
// delete directory recursively
fs.rm(dir, { recursive: true }, err => {
if (err) {
throw err;
}
});
ctx.send({ ok: true, dir });
},
async apartmentfilterConfiguration(ctx) {
const location = ctx.request.body.location;
const matchingTownshipID = await strapi.entityService.findMany(
"api::township.township",
{
filters: {
location: location,
},
}
);
// console.log("matchingTownshipID");
// console.log(matchingTownshipID);
let projectsId = [];
let projectType = [];
for (let j = 0; j < matchingTownshipID.length; j++) {
const townshipId = matchingTownshipID[j].id;
const matchingTownship = await strapi.entityService.findMany(
"api::township.township",
{
// populate:{
// projects:{
// fields: ["id"]
// }},
populate: ["projects", "projects.projectType"],
filters: {
id: townshipId,
},
}
);
for (let i = 0; i < matchingTownship[0].projects.length; i++) {
const element = matchingTownship[0].projects[i];
projectsId.push(element.id);
projectType.push(element.projectType);
}
}
function removeDuplicates(arr) {
return arr.filter((item, index) => arr.indexOf(item) === index);
}
const finalArray = removeDuplicates(projectType);
// const matchingProjects =
// console.log(projectsId);
ctx.send({
ok: true,
projectType: finalArray,
message: "filterConfiguration caleed",
});
},
async bedroomfilterConfiguration(ctx) {
const location = ctx.request.body.location;
const projectType = ctx.request.body.projectType;
const matchingProjects = await strapi.entityService.findMany(
"api::project.project",
{
populate: ["configurations"],
filters: {
$and: [
{
location: location,
},
{
projectType: projectType,
},
],
},
}
);
let finalProjects = [];
let porjectConfiguration = [];
for (let j = 0; j < matchingProjects.length; j++) {
const individualProject = matchingProjects[j];
for (let i = 0; i < individualProject.configurations.length; i++) {
const element = individualProject.configurations[i].bedrooms;
porjectConfiguration.push(element);
}
}
function removeDuplicates(arr) {
return arr.filter((item, index) => arr.indexOf(item) === index);
}
const finalArray = removeDuplicates(porjectConfiguration).sort();
// console.log("matchingProjects",finalArray);
// const matchingProjects =
ctx.send({
ok: true,
porjectConfiguration: finalArray,
message: "filterConfiguration caleed",
});
},
})
);
// http://localhost:1337/api/end-users/removedirectory/delete
\ No newline at end of file
const routes = {
routes: [
{
method: "POST",
path: "/end-users/finish-otp-verification",
handler: "api::end-user.end-user.finishEndUserOtpVerification",
config: {
// some configuration...
}
},
{
method: "POST",
path: "/end-users/apartment-filter-configuration",
handler: "api::end-user.end-user.apartmentfilterConfiguration",
config: {
// some configuration...
}
},
{
method: "POST",
path: "/end-users/bedroom-filter-configuration",
handler: "api::end-user.end-user.bedroomfilterConfiguration",
config: {
// some configuration...
}
},
{
method: "GET",
path: "/end-users/removedirectory/delete",
handler: "api::end-user.end-user.removedirectory",
config: {
// some configuration...
}
}
]
};
module.exports = routes;
'use strict';
/**
* end-user router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::end-user.end-user');
"use strict";
const axios = require("axios");
/**
* end-user service
*/
const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService(
"api::end-user.end-user",
({ strapi: Strapi }) => ({
async sendLeadToSperto(data, isVerified) {
// 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.mobileNo,
email_id1: data.email,
otp_verified_yn: isVerified,
};
// console.log("lead data", leadData);
// 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;
}
const spertoLeadResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
leadData,
{ headers: headers }
);
// console.log("spertoLeadResponse", spertoLeadResponse);
return spertoLeadResponse;
},
async sendOTPToSpreto(data) {
// console.log("OTP data", data);
const headers = { "Content-Type": "application/json" };
const otpDetails = {
api_key: process.env.SPERTO_API_KEY,
from_name: "Hiranandani",
from_mail: data.emailToSend.from,
to: data.emailToSend.to,
subject: data.emailToSend.subject,
body: data.emailToSend.html,
// 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",
};
// console.log("OTPDETAILS", otpDetails);
const spertoSMSResponse = await axios.get(`http://vas.themultimedia.in/domestic/sendsms/bulksms.php?username=OSAPI&password=os123456&type=TEXT&sender=HROTPs&entityId=1101407690000029629&templateId=1507166789848358346&mobile=${data.mobileNo}&message=Dear%20${data.fullName}%0AYour%20OTP%20for%20Hiranandani%20Exclusive%20website%20login%20is%20${data.emailToSend.oneTimePassword}%0AValid%20for%2010%20minute%20Please%20do%20not%20share%20this%20OTP.%0ARegards%2C%0AHiranandani%20Team.`)
const spertoEmailResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_send_mail.php",
otpDetails,
{ headers: headers }
);
// const finalReturn = {}
// console.log("spertoSMSResponse", spertoSMSResponse);
return {spertoSMSResponse, spertoEmailResponse} ;
// return ;
},
})
);
// module.exports = createCoreService(
// "api::end-user.end-user",
// ({ strapi: Strapi }) => ({
// // ({ 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.mobileNo,
// // 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;
// // }
// // const spertoResponse = await axios.post(
// // "https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
// // leadData,
// // { headers: headers }
// // );
// // return spertoResponse;
// // }})
// })
// );
// http://vas.themultimedia.in/domestic/sendsms/bulksms.php?username=OSAPI&password=os123456&type=TEXT&sender=HROTPs&entityId=1101407690000029629&templateId=1507166789848358346&mobile=${data.mobileNo}&message=Dear%20${data.fullName}%0AYour%20OTP%20for%20Hiranandani%20Exclusive%20website%20login%20is%20${data.emailToSend.oneTimePassword}%0AValid%20for%2010%20minute%20Please%20do%20not%20share%20this%20OTP.%0ARegards%2C%0AHiranandani%20Team.
\ No newline at end of file
{
"kind": "collectionType",
"collectionName": "about_uses",
"collectionName": "games",
"info": {
"singularName": "about-us",
"pluralName": "about-uses",
"displayName": "About us",
"description": ""
"singularName": "game",
"pluralName": "games",
"displayName": "Games"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"year": {
"firstReleaseDate": {
"type": "string"
},
"description1": {
"type": "text"
"name": {
"type": "string"
},
"image": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
"rating": {
"type": "string"
},
"description2": {
"summary": {
"type": "text"
}
}
......
'use strict';
/**
* about-us controller
* game controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::about-us.about-us');
module.exports = createCoreController('api::game.game');
'use strict';
/**
* about-us router
* game router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::about-us.about-us');
module.exports = createCoreRouter('api::game.game');
'use strict';
/**
* about-us service
* game service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::about-us.about-us');
module.exports = createCoreService('api::game.game');
{
"kind": "singleType",
"collectionName": "home_banner_videos",
"info": {
"singularName": "home-banner-video",
"pluralName": "home-banner-videos",
"displayName": "Home Banner Video",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"video": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"videos",
"audios",
"files"
]
},
"mobileVideo": {
"allowedTypes": [
"images",
"videos",
"audios",
"files"
],
"type": "media",
"multiple": false
}
}
}
'use strict';
/**
* home-banner-video controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::home-banner-video.home-banner-video');
'use strict';
/**
* home-banner-video router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::home-banner-video.home-banner-video');
'use strict';
/**
* home-banner-video service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::home-banner-video.home-banner-video');
{
"kind": "collectionType",
"collectionName": "home_banners",
"info": {
"singularName": "home-banner",
"pluralName": "home-banners",
"displayName": "Home Banner",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string",
"required": false
},
"subTitle": {
"type": "string"
},
"image": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"serialNumber": {
"type": "integer",
"default": 1,
"required": true
},
"phoneBanner": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
}
}
}
'use strict';
/**
* home-banner controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::home-banner.home-banner');
'use strict';
/**
* home-banner router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::home-banner.home-banner');
'use strict';
/**
* home-banner service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::home-banner.home-banner');
{
"kind": "singleType",
"collectionName": "home_contents",
"info": {
"singularName": "home-content",
"pluralName": "home-contents",
"displayName": "Home Content",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"content": {
"type": "richtext",
"required": true
},
"image1": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"image2": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"image3": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"title1": {
"type": "richtext"
},
"title2": {
"type": "richtext"
},
"title3": {
"type": "richtext"
}
}
}
'use strict';
/**
* home-content controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::home-content.home-content');
'use strict';
/**
* home-content router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::home-content.home-content');
'use strict';
/**
* home-content service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::home-content.home-content');
{
"kind": "collectionType",
"collectionName": "leads",
"info": {
"singularName": "lead",
"pluralName": "leads",
"displayName": "Leads",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"fullName": {
"type": "string"
},
"mobileNumber": {
"type": "string"
},
"email": {
"type": "email"
},
"Comments": {
"type": "text"
},
"project": {
"type": "relation",
"relation": "oneToOne",
"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";
/**
* lead controller
*/
const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController("api::lead.lead", () => ({
async sendLeads(ctx) {},
async create(ctx) {
// console.log(">>>>", ctx);
try {
const spretoLeadData = await strapi
.service("api::lead.lead")
.sendLeadToSperto(ctx.request.body.data);
// console.log("spretoLeadData", spretoLeadData);
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';
/**
* lead router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::lead.lead');
"use strict";
const axios = require("axios");
/**
* lead service
*/
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: data.projectSRDCampaignKey ? data.projectSRDCampaignKey : "",
customer_name: data.fullName,
mobile1_isd: "",
mobile_no1: data.mobileNumber,
email_id1: data.email,
otp_verified_yn: "N",
page_url: data.UTMLink ? data.UTMLink : "",
utm_medium: data.utm_medium ? data.utm_medium : "",
utm_source: data.utm_source ? data.utm_source : "",
utm_campaign: data.utm_campaign ? data.utm_campaign : ""
};
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;
}
// if (data.UTMLink) {
// leadData = {...leadData, page_url: data.UTMLink}
// }
// if (data.utm_medium) {
// leadData = {...leadData, utm_medium: data.utm_medium}
// }
// if (data.utm_source) {
// leadData = {...leadData, utm_source: data.utm_source}
// }
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
leadData,
{ headers: headers }
);
// console.log("spertoResponse",spertoResponse);
return spertoResponse;
},
}));
{
"kind": "collectionType",
"collectionName": "locations",
"info": {
"singularName": "location",
"pluralName": "locations",
"displayName": "Location",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string",
"required": true,
"unique": true
},
"city": {
"type": "enumeration",
"enum": [
"Mumbai",
"Navi Mumbai",
"Gandhinagar",
"Chennai",
"Khandala"
],
"required": true
},
"slug": {
"type": "uid",
"targetField": "name",
"required": true
},
"serialNumber": {
"type": "integer"
}
}
}
'use strict';
/**
* location controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::location.location');
'use strict';
/**
* location router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::location.location');
'use strict';
/**
* location service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::location.location');
{
"kind": "collectionType",
"collectionName": "menu_items",
"info": {
"singularName": "menu-item",
"pluralName": "menu-items",
"displayName": "Menu Item",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"label": {
"type": "string",
"required": true
},
"url": {
"type": "string",
"required": true
},
"children": {
"type": "relation",
"relation": "oneToMany",
"target": "api::menu-item.menu-item",
"mappedBy": "parent"
},
"parent": {
"type": "relation",
"relation": "manyToOne",
"target": "api::menu-item.menu-item",
"inversedBy": "children"
},
"menu": {
"type": "relation",
"relation": "manyToOne",
"target": "api::menu.menu",
"inversedBy": "menuItems"
},
"serialNumber": {
"type": "integer",
"required": true
}
}
}
'use strict';
/**
* menu-item controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::menu-item.menu-item');
'use strict';
/**
* menu-item router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::menu-item.menu-item');
'use strict';
/**
* menu-item service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::menu-item.menu-item');
{
"kind": "collectionType",
"collectionName": "menus",
"info": {
"singularName": "menu",
"pluralName": "menus",
"displayName": "Menu"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string",
"required": true,
"unique": true
},
"menuItems": {
"type": "relation",
"relation": "oneToMany",
"target": "api::menu-item.menu-item",
"mappedBy": "menu"
}
}
}
'use strict';
/**
* menu controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::menu.menu');
'use strict';
/**
* menu router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::menu.menu');
'use strict';
/**
* menu service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::menu.menu');
{
"kind": "collectionType",
"collectionName": "projects",
"info": {
"singularName": "project",
"pluralName": "projects",
"displayName": "Project",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"projectName": {
"type": "string",
"required": true,
"unique": true
},
"address": {
"type": "text",
"required": true
},
"status": {
"type": "enumeration",
"enum": [
"New",
"Under Construction",
"Ready To Move In",
"Completed"
],
"required": true,
"default": "New"
},
"description": {
"type": "richtext",
"required": true
},
"featuredOnHome": {
"type": "boolean",
"default": false,
"required": true
},
"projectImages": {
"displayName": "Project Image",
"type": "component",
"repeatable": true,
"component": "layout.project-image"
},
"location": {
"type": "relation",
"relation": "oneToOne",
"target": "api::location.location"
},
"projectType": {
"type": "enumeration",
"enum": [
"Villas",
"Apartments",
"Commercial",
"Studio Residences"
],
"required": true
},
"configurations": {
"displayName": "Project Configuration",
"type": "component",
"repeatable": true,
"component": "layout.project-configuration"
},
"bedroomTitle": {
"type": "string",
"required": true
},
"sizeTitle": {
"type": "string",
"required": false
},
"heroText1": {
"type": "string"
},
"heroText2": {
"type": "string"
},
"heroText3": {
"type": "string"
},
"heroText4": {
"type": "string"
},
"floorPlanImages": {
"type": "component",
"repeatable": true,
"component": "layout.project-image"
},
"masterPlanImages": {
"type": "component",
"repeatable": true,
"component": "layout.project-image"
},
"township": {
"type": "relation",
"relation": "manyToOne",
"target": "api::township.township",
"inversedBy": "projects"
},
"amenities": {
"type": "relation",
"relation": "oneToMany",
"target": "api::amenity.amenity"
},
"priceTitle": {
"type": "string",
"required": true
},
"offersText": {
"type": "richtext"
},
"slug": {
"type": "uid",
"targetField": "projectName",
"required": true
},
"details1": {
"type": "richtext",
"required": true
},
"details2": {
"type": "richtext",
"required": true
},
"details3": {
"type": "richtext",
"required": true
},
"storeys": {
"type": "integer"
},
"posession": {
"type": "string"
},
"digitalSalesPresentationURL": {
"type": "string"
},
"brochure": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files"
]
},
"viewLocationLink": {
"type": "text"
},
"phoneBanner": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"projectSRDCampaignKey": {
"type": "text"
},
"reraNumber": {
"type": "text"
},
"projectID": {
"type": "string"
},
"alternateYoutubeLink": {
"type": "text"
}
}
}
'use strict';
/**
* project controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::project.project');
'use strict';
/**
* project router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::project.project');
'use strict';
/**
* project service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::project.project');
{
"kind": "collectionType",
"collectionName": "referrals",
"info": {
"singularName": "referral",
"pluralName": "referrals",
"displayName": "Referral",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": {
"fullName": {
"type": "string",
"required": true,
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"mobileNumber": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"email": {
"type": "email",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"wing": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"flatNumber": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"ownershipType": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"purchasedYear": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"purchasedSource": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"referralName": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"referralPhoneNo": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"referralEmail": {
"type": "email",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"projectReferredTo": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"project": {
"type": "relation",
"relation": "oneToOne",
"target": "api::project.project"
},
"termsAndConditions": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "boolean"
},
"existingOwner": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"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"
},
"building": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
},
"address": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"country": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
},
"pincode": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
},
"township": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
}
}
}
"use strict";
/**
* referral controller
*/
const { createCoreController } = require("@strapi/strapi").factories;
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);
const spertoReferralData = await strapi.service("api::referral.referral").sendReferral({...ctx.request.body.data, parent_id: spertoRefereeData.data.member_id})
console.log("spertoReferralData", spertoReferralData)
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';
/**
* referral router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::referral.referral');
"use strict";
const axios = require("axios");
/**
* referral service
*/
const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService(
"api::referral.referral",
({ strapi: Strapi }) => ({
async sendReferral(data) {
console.log("data 1",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.referralName,
mobile1_isd: null,
mobile1: data.referralPhoneNo,
email1: data.referralEmail,
// 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 2",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,
};
// console.log("entered try2");
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php",
refereelData,
{ headers: headers }
);
// console.log("spertoResponse2", spertoResponse);
return spertoResponse;
},
})
);
......@@ -12,11 +12,7 @@
},
"pluginOptions": {},
"attributes": {
"location": {
"type": "relation",
"relation": "oneToOne",
"target": "api::location.location"
},
"title": {
"type": "string",
"required": true,
......@@ -55,17 +51,7 @@
"bedroomTitle": {
"type": "string"
},
"projects": {
"type": "relation",
"relation": "oneToMany",
"target": "api::project.project",
"mappedBy": "township"
},
"amenities": {
"type": "relation",
"relation": "oneToMany",
"target": "api::amenity.amenity"
},
"townshipContactEmail": {
"type": "string",
"required": true
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!