124 lines
4.5 KiB
C++
124 lines
4.5 KiB
C++
// Twillo management toosl
|
|
#include "clog.h"
|
|
#include "cgi.h"
|
|
#include "input.h"
|
|
#include "wrenchboard_api.h"
|
|
#include "reco_engine.h"
|
|
#include "email.h"
|
|
#include "safestring.h"
|
|
#include <string>
|
|
#include "pgsql.h"
|
|
#include "pgsql_wrapper.h"
|
|
#include <curl/curl.h>
|
|
#include "account.h"
|
|
#include "cards.h"
|
|
#include "twilo.h"
|
|
|
|
/*
|
|
#define RECOMMEND_COUPON 1000
|
|
#define RECOMMEND_BLOG 1005
|
|
#define RECOMMEND_NEWTASK 1010
|
|
#define RECOMMEND_TOKEN 1015
|
|
#define RECOMMEND_OFFERS 1020
|
|
//========================
|
|
*/
|
|
long sendOffersRecommendation( CVars in, CVars &out);
|
|
long sendCouponRecommendation( CVars in, CVars &out);
|
|
long recommendation_engine(long action , CVars in, CVars &out) {
|
|
try{
|
|
|
|
switch (action) {
|
|
case RECOMMEND_COUPON:
|
|
return sendCouponRecommendation( in, out);
|
|
break;
|
|
|
|
case RECOMMEND_BLOG:
|
|
return 0;
|
|
break;
|
|
|
|
case RECOMMEND_NEWTASK:
|
|
return 0;
|
|
break;
|
|
|
|
case RECOMMEND_TOKEN:
|
|
return 0;
|
|
break;
|
|
|
|
case RECOMMEND_OFFERS:
|
|
return sendOffersRecommendation( in, out);
|
|
break;
|
|
}
|
|
|
|
} catch (bad_parameter) {
|
|
logfmt(logINFO, "ERROR CALL long recommendation_engine");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
long sendOffersRecommendation( CVars in, CVars &out){
|
|
|
|
try{
|
|
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
|
REQ_LONG(in, "offer_id", 1, -1);
|
|
|
|
if ( load_db_record(out, "SELECT client_id FROM members_jobs_offer WHERE id=%lu", in["offer_id"].Long())> 0){
|
|
CVars xx;
|
|
CVars xout;
|
|
xx["action"] = WRENCHBOARD_CARDS_CREATECARD; xx["action"].set_valid( true );
|
|
xx["member_id"] = out["client_id"]; xx["member_id"].set_valid( true ); // the card is going to job recipient
|
|
xx["title"] = "New job offer"; xx["title"].set_valid( true );
|
|
xx["description"] = "You have received a new Task/Job offer"; xx["description"].set_valid( true );
|
|
xx["card_type"] = "OFFERS"; xx["card_type"].set_valid( true );
|
|
xx["card_style"] = "card2"; xx["card_style"].set_valid( true );
|
|
xx["card_icon"] = "icon1"; xx["card_icon"].set_valid( true );
|
|
xx["offer_id"] = in["offer_id"]; xx["offer_id"].set_valid( true );
|
|
xx["blog_id"] = "0"; xx["blog_id"].set_valid( true );
|
|
card_calls(xx, xout);
|
|
}
|
|
} catch (bad_parameter) {
|
|
logfmt(logINFO, "ERROR CALL long sendCouponRecommendation");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
long sendCouponRecommendation( CVars in, CVars &out){
|
|
/*
|
|
CVars xx;
|
|
xx["member_id"] = in["member_id"]; xx["member_id"].set_valid(true);
|
|
xx["code"] = rec["code"]; xx["code"].set_valid(true);
|
|
xx["amount"] = rec["amount"]; xx["amount"].set_valid(true);
|
|
xx["status"] = COUPON_ACTIVE; xx["status"].set_valid(true);
|
|
coupon_id = insert_db_record(DBS_VALID, "coupons_allocation", "coupons_allocation_id_seq", xx);
|
|
|
|
['title'=>'This is your coupon',
|
|
'description'=>'This is the description of the description',
|
|
'card_type'=>'COUPON',
|
|
'card_style' =>'card1',
|
|
'card_icon' =>'icon1',
|
|
'assign_id'=> 0,
|
|
*/
|
|
|
|
try{
|
|
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
|
REQ_LONG(in, "coupon_id", 1, -1);
|
|
|
|
CVars xx;
|
|
CVars xout;
|
|
xx["action"] = WRENCHBOARD_CARDS_CREATECARD; xx["action"].set_valid( true );
|
|
xx["member_id"] = member_id; xx["member_id"].set_valid( true );
|
|
xx["title"] = "This is your coupon"; xx["title"].set_valid( true );
|
|
xx["description"] = "Click to redeem your coupon to your account"; xx["description"].set_valid( true );
|
|
xx["card_type"] = "COUPON"; xx["card_type"].set_valid( true );
|
|
xx["card_style"] = "card1"; xx["card_style"].set_valid( true );
|
|
xx["card_icon"] = "icon1"; xx["card_icon"].set_valid( true );
|
|
xx["blog_id"] = "0"; xx["blog_id"].set_valid( true );
|
|
xx["offer_id"] = "0"; xx["offer_id"].set_valid( true );
|
|
card_calls(xx, xout);
|
|
} catch (bad_parameter) {
|
|
logfmt(logINFO, "ERROR CALL long sendCouponRecommendation");
|
|
}
|
|
return 0;
|
|
}
|
|
|