Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
strapi-setup-file
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit b7629830
authored
2022-11-18 10:43:37 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
APIs integrated
1 parent
b7ffd1ad
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
299 additions
and
14 deletions
src/api/channel-partner/controllers/channel-partner.js
src/api/channel-partner/services/channel-partner.js
src/api/end-user/controllers/end-user.js
src/api/end-user/services/end-user.js
src/api/referral/content-types/referral/schema.json
src/api/referral/controllers/referral.js
src/api/referral/services/referral.js
src/api/channel-partner/controllers/channel-partner.js
View file @
b762983
...
...
@@ -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
);
},
})
...
...
src/api/channel-partner/services/channel-partner.js
View file @
b762983
'use strict'
;
"use strict"
;
const
{
default
:
axios
}
=
require
(
"axios"
);
/**
* 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
;
},
})
);
src/api/end-user/controllers/end-user.js
View file @
b762983
...
...
@@ -114,8 +114,10 @@ module.exports = factories.createCoreController(
);
// 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.
if
(
existingEndUser
&&
existingEndUser
.
length
!==
0
)
{
...
...
src/api/end-user/services/end-user.js
View file @
b762983
'use strict'
;
"use strict"
;
const
{
default
:
axios
}
=
require
(
"axios"
);
/**
* 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
;
},
})
);
src/api/referral/content-types/referral/schema.json
View file @
b762983
...
...
@@ -154,6 +154,54 @@
}
},
"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"
}
}
}
src/api/referral/controllers/referral.js
View file @
b762983
'use strict'
;
"use strict"
;
/**
* 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
,
});
},
}));
src/api/referral/services/referral.js
View file @
b762983
'use strict'
;
"use strict"
;
const
{
default
:
axios
}
=
require
(
"axios"
);
/**
* 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
;
},
})
);
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment