-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
109 lines (77 loc) · 2.85 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
require '../vendor/autoload.php';
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use Classes\Database\DatabaseFactory;
use Classes\AWS\awsS3;
use Classes\controllers\CustomerController;
use Classes\controllers\MAARASController;
$app = new \Slim\App([
'settings' => [
'displayErrorDetails' => true
]
]);
header("Access-Control-Allow-Origin: *");
//POST Method
$app->post('/validateCustomer', function (Request $request, Response $response, array $args) {
$data = $request->getBody()->getContents();
$res = json_decode($data, true);
//error_log("You messed up!", 3, dirname(__FILE__)."/../logs/RAAS.log");
if (isset($res) && $res['program'] === 'MADHRAAS') {
$finalRes = MAARASController::customerValidation($res);
} else {
$finalRes = MAARASController::customerValidation($_POST);
}
return $this->response->withJson($finalRes, 200);
});
$app->get('/resetCoupons', function (Request $request, Response $response, array $args) {
$sql = "update coupon_codes set is_issued=0";
$sth = DatabaseFactory::RDSConnection()->query($sql);
$sth->execute();
$dsql = "truncate coupon_customer_participation";
$dsth = DatabaseFactory::RDSConnection()->query($dsql);
$dsth->execute();
$res =[
'status' => 1,
'Message' => 'successfully resetted'
];
return $this->response->withJson($res, 200);
});
/// Testing methods
/*
$app->get('/getFieldNames', function (Request $request, Response $response, array $args) {
$q = DatabaseFactory::RDSConnection()->query("DESCRIBE CUSTOMERS");
$fieldnames = $q->fetchAll();
return $this->response->withJson($fieldnames, 200);
});
$app->get('/getAllCustomers', function ($id) use ($app) {
$customers = CustomerController::getAllCustomers();
return $this->response->withJson($customers, 200);
});
$app->get('/getCustomer/{id}', function ($request, $response, $args) {
$customer = CustomerController::getCustomerByFirstName($args['id']);
return $this->response->withJson($customer, 200);
});
$app->get('/deleteCustomer/{id}', function ($request, $response, $args) {
$customer = CustomerController::deleteAccountNumber($args['id']);
if ($customer == 'true') {
return 'Successfully Deleted';
} else {
return 'Something went wrong';
}
});
//Payload check from nodejs
$app->post('/getAdressValidate', function ($request, $response, $args) {
$data = $request->getBody()->getContents();
$res = json_decode($data, true);
if ($res) {
$finalRes = CustomerController::guzzleGetFromCustomerValidationAPI($res);
} else {
$finalRes = CustomerController::guzzleGetFromCustomerValidationAPI($_POST);
}
return ($finalRes);
});
*/
$app->run();