/*
main entry point for API calls Chiefsoft July 2017 */
#include "jubabox_api_main.h"
#include "jubabox_api.h"
#include "clog.h"
#include "input.h"
#include "pgsql.h"
#include "pgsql_wrapper.h"

/*Other savvy functions*/
#include "medTrBackOffice.h"
#include "medTrMembers.h"
#include "medTrTransporter.h"
#include "stripe_charge.h"
#include "medTEmails.h"
#include "medTUpload.h"
#include "mobile.h"
#include "members.h"

long jubabox_api_main(CVars in, CVars &out) {
    logfmt(logINFO, "long jubabox_api_main(CVars in, CVars &out)");
    long retval = PHP_API_BAD_PARAM;
    long action = REQ_LONG(in, "action", 0, -1);
    REQ_LONG(in, "pid", 0, -1); // global implementation - who is calling
    try {


        if (action >= USER_START && action <= USER_END) {
            return members_calls(in, out);
        }

        if (action >= MEDTRANS_BKO_START && action <= MEDTRANS_BKO_END) {
            return backoffice_calls(in, out);
        }

        if (action >= SAVVY_USER_MOBILESTART && action <= SAVVY_USER_MOBILEEND) {
            return -1; //mobile_call(in, out);
        }



    } catch (bad_parameter) {
        logfmt(logINFO, "ERROR CALL long jubabox_api_main(CVars in, CVars &out)");
    }
    return retval;

}


