From a7d2f88928f5a42011acbb5a273339d9a00d095e Mon Sep 17 00:00:00 2001 From: zeena Date: Sun, 23 Jul 2023 10:53:34 +0300 Subject: [PATCH] new update --- SASConnector.php | 25 +++++++++++++++++++++++++ update_manager.php | 12 +++++++++++- update_profile.php | 9 ++++++++- update_user.php | 9 ++++++++- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/SASConnector.php b/SASConnector.php index 928e365..3ecb124 100644 --- a/SASConnector.php +++ b/SASConnector.php @@ -83,6 +83,31 @@ class SASConnector{ } } + public function put($route, $payload, $withAuth = true){ + + $json = json_encode($payload); + $e_json = $this->aes::encrypt($json, 'abcdefghijuklmno0123456789012345'); + $res = $this->client->request('PUT',$this->base_url.$route, + [ + 'headers' => [ + 'authorization' => 'Bearer '.$this->token + ], + 'json' => [ + 'payload' => $e_json + ] + ] + ); + if ($res->getStatusCode() >= 200 && $res->getStatusCode()< 400) + return $res->getBody(); + else + return -1; + } + + + + + + } diff --git a/update_manager.php b/update_manager.php index 678a0ba..81d2935 100644 --- a/update_manager.php +++ b/update_manager.php @@ -6,7 +6,7 @@ $api = new SASConnector('172.16.12.108', 'admin', 'admin'); $api->login(); -$res = $api->post('manager/128', [ +$res = $api->put('manager/128', [ "enabled" => 1, "password" => null, "confirm_password" => null, @@ -45,3 +45,13 @@ $res = $api->post('manager/128', [ ]); print_r(json_decode($res)); + +//this is the expected response + +//stdClass Object +//( +// [status] => 200 +// [message] => rsp_manager_updated +//) + + diff --git a/update_profile.php b/update_profile.php index c619aff..18573b7 100644 --- a/update_profile.php +++ b/update_profile.php @@ -6,7 +6,7 @@ $api = new SASConnector('172.16.12.108', 'admin', 'admin'); $api->login(); -$res = $api->post('profile/31', [ +$res = $api->put('profile/31', [ "name" => "testprofiletest", "enabled" => 1, "price" => "12.22222", @@ -86,3 +86,10 @@ $res = $api->post('profile/31', [ ]); print_r(json_decode($res)); +//this is the expected response + +//stdClass Object +//( +//[status] => 200 +//) + diff --git a/update_user.php b/update_user.php index 7a07f1d..08dd297 100644 --- a/update_user.php +++ b/update_user.php @@ -6,7 +6,7 @@ $api = new SASConnector('172.16.12.108', 'admin', 'admin'); $api->login(); -$res = $api->post('user/id', [ +$res = $api->put('user/id', [ "enabled" => 1, "password" => null, "confirm_password" => null, @@ -44,3 +44,10 @@ $res = $api->post('user/id', [ ]); print_r(json_decode($res)); +//this is the expected response + +//stdClass Object +//( +// [status] => 200 +//) +