From 0771ef62e6353960772d210d758f09e507b54402 Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Wed, 2 Mar 2016 11:40:30 +0530 Subject: [PATCH 1/8] fixed issue --- src/Client.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Client.php b/src/Client.php index 309ae0a..c1662b3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -38,17 +38,17 @@ private function getStatusCode($ch) $info = curl_getinfo($ch); return (int)$info['http_code']; } - + public function getBaseUrl() { return $this->baseUrl; } - + public function getPartition() { return $this->partition; } - + public function getUsername() { return $this->username; @@ -64,7 +64,7 @@ public function getUsersWithDetails() } return $users; } - + protected function itemToUser($data) { $user = new User($data['username']); @@ -105,14 +105,14 @@ protected function itemToUser($data) } return $user; } - + protected function itemToAccount($data) { $account = new Account($data['name']); $account->setDisplayName($data['display_name']); $account->setAbout($data['about']); $account->setEmail($data['email']); - if (isset($data['mobile']) { + if (isset($data['mobile'])) { $account->setMobile($data['mobile']); } if (isset($data['type'])) { @@ -146,22 +146,22 @@ protected function itemToAccount($data) return $account; } - + public function getUserByUsername($username) { - + $data = $this->getData('/users/' . $username); $user = $this->itemToUser($data); return $user; } - + public function getAccountByName($name) { $data = $this->getData('/accounts/' . $name); $account = $this->itemToAccount($data); return $account; } - + public function getAccountsWithDetails() { $data = $this->getData('/accounts?details'); @@ -193,7 +193,7 @@ public function getData($uri) return $data; } - + public function checkCredentials($username, $password) { try { From 89397981e14286484a1703ea52abb2b17acd21ef Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Mon, 7 Mar 2016 14:23:05 +0530 Subject: [PATCH 2/8] #356 allow to set an account peroperty --- examples/account_property.php | 14 ++++++++++++++ src/Client.php | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 examples/account_property.php diff --git a/examples/account_property.php b/examples/account_property.php new file mode 100644 index 0000000..f0195c4 --- /dev/null +++ b/examples/account_property.php @@ -0,0 +1,14 @@ +setAccountProperty($accountName, $propertyName, $propertyValue); + print_r($users); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} diff --git a/src/Client.php b/src/Client.php index c1662b3..72883ac 100644 --- a/src/Client.php +++ b/src/Client.php @@ -205,4 +205,13 @@ public function checkCredentials($username, $password) $valid = $encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt()); return $valid; } + + public function setAccountProperty($accountName, $propertyName, $propertyValue) + { + $accountProperty = new AccountProperty(); + $accountProperty->setAccountName($accountName); + $accountProperty->setName($propertyName); + $accountProperty->setValue($propertyValue); + $account->addAccountProperty($accountProperty); + } } From 8ffb8482ea1130596b5cae433d6779970090cfbe Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Mon, 7 Mar 2016 14:46:16 +0530 Subject: [PATCH 3/8] #356 enhance userbase client properlty --- src/Client.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Client.php b/src/Client.php index 72883ac..0de4904 100644 --- a/src/Client.php +++ b/src/Client.php @@ -208,10 +208,7 @@ public function checkCredentials($username, $password) public function setAccountProperty($accountName, $propertyName, $propertyValue) { - $accountProperty = new AccountProperty(); - $accountProperty->setAccountName($accountName); - $accountProperty->setName($propertyName); - $accountProperty->setValue($propertyValue); - $account->addAccountProperty($accountProperty); + $data = $this->getData('/'.$accountName.'/setProperty/'.$propertyName.'/'.$propertyValue); + return $data; } } From 40e05a9c32f35b40bb661533c6f98f0a4302de92 Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Mon, 7 Mar 2016 18:42:01 +0530 Subject: [PATCH 4/8] #357 API Allow to add user from organization/group --- examples/common.php | 2 +- src/Client.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/common.php b/examples/common.php index 8082dd5..e7133ce 100644 --- a/examples/common.php +++ b/examples/common.php @@ -1,6 +1,6 @@ getData('/'.$accountName.'/setProperty/'.$propertyName.'/'.$propertyValue); + $data = $this->getData('/accounts/'.$accountName.'/setProperty/'.$propertyName.'/'.$propertyValue); + return $data; + } + + public function addAccountUser($accountName, $userName, $isAdmin) + { + $data = $this->getData('/accounts/'.$accountName.'/addUser/'.$userName.'/'.$isAdmin); return $data; } } From 177f442a04e812fe5bb335117c7b6bcdcf23abfb Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Mon, 7 Mar 2016 18:46:11 +0530 Subject: [PATCH 5/8] #357 API Allow to add user from organization/group --- examples/account_adduser.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/account_adduser.php diff --git a/examples/account_adduser.php b/examples/account_adduser.php new file mode 100644 index 0000000..cee962f --- /dev/null +++ b/examples/account_adduser.php @@ -0,0 +1,14 @@ +addAccountUser($accountName, $userName, $isAdmin); + print_r($users); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} From 1d08d9ad53ea30f6a9f259596fd958310c0d6f96 Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Tue, 8 Mar 2016 12:16:14 +0530 Subject: [PATCH 6/8] #358 API allow to add event --- examples/account_addevent.php | 13 +++++++++++++ src/Client.php | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 examples/account_addevent.php diff --git a/examples/account_addevent.php b/examples/account_addevent.php new file mode 100644 index 0000000..9050c30 --- /dev/null +++ b/examples/account_addevent.php @@ -0,0 +1,13 @@ +addEvent($accountName, $eventName, $data); + print_r($users); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} diff --git a/src/Client.php b/src/Client.php index 2574be9..7146b95 100644 --- a/src/Client.php +++ b/src/Client.php @@ -217,4 +217,11 @@ public function addAccountUser($accountName, $userName, $isAdmin) $data = $this->getData('/accounts/'.$accountName.'/addUser/'.$userName.'/'.$isAdmin); return $data; } + + public function addEvent($accountName, $eventName, $data) + { + $data = $this->getData('/accounts/'.$accountName.'/addEvent/'.urlencode($eventName).'?'.$data); + return $data; + + } } From 3e5b2a016587debe49b9d13e5668806ce412728f Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Mon, 14 Mar 2016 15:52:25 +0530 Subject: [PATCH 7/8] #400 account add/update api --- examples/account_add.php | 12 ++++++++++++ examples/account_update.php | 15 +++++++++++++++ src/Client.php | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 examples/account_add.php create mode 100644 examples/account_update.php diff --git a/examples/account_add.php b/examples/account_add.php new file mode 100644 index 0000000..db7f932 --- /dev/null +++ b/examples/account_add.php @@ -0,0 +1,12 @@ +createAccount($accountName, $accountType); + print_r($acount); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} diff --git a/examples/account_update.php b/examples/account_update.php new file mode 100644 index 0000000..498c477 --- /dev/null +++ b/examples/account_update.php @@ -0,0 +1,15 @@ +updateAccount($accountName, $displayName, $email, $mobile, $about); + print_r($acount); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} diff --git a/src/Client.php b/src/Client.php index 7146b95..23c41fa 100644 --- a/src/Client.php +++ b/src/Client.php @@ -224,4 +224,18 @@ public function addEvent($accountName, $eventName, $data) return $data; } + + public function createAccount($accountName, $accountType) + { + $data = $this->getData('/accounts/create/'.urlencode($accountName).'/'.urlencode($accountType)); + return $data; + } + + public function updateAccount($accountName, $displayName, $email, $mobile, $about) + { + //die('/accounts/'.$accountName.'/update/'.$displayName.'/'.$email.'/'.$mobile.'/'.$about); + $data = $this->getData('/accounts/'.$accountName.'/update/'. + urlencode($displayName).'/'.urlencode($email).'/'.urlencode($mobile).'/'.urlencode($about)); + return $data; + } } From 2dcea611ced9673fde43e85f996fc3cdb56eaca9 Mon Sep 17 00:00:00 2001 From: kaushikindianic Date: Tue, 15 Mar 2016 18:45:52 +0530 Subject: [PATCH 8/8] #373 account notification add, get --- examples/account_notification.php | 20 ++++++++++++++++++++ examples/account_notification_get.php | 16 ++++++++++++++++ src/Client.php | 21 +++++++++++++++++++-- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 examples/account_notification.php create mode 100644 examples/account_notification_get.php diff --git a/examples/account_notification.php b/examples/account_notification.php new file mode 100644 index 0000000..9785486 --- /dev/null +++ b/examples/account_notification.php @@ -0,0 +1,20 @@ + "", + "sourceAccountName" => "", + "subject" => "", + "body" => "", + "link" => "" + ]); + + $users = $client->createNotification($accountName, $jsonData); + print_r($users); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} diff --git a/examples/account_notification_get.php b/examples/account_notification_get.php new file mode 100644 index 0000000..4681b1c --- /dev/null +++ b/examples/account_notification_get.php @@ -0,0 +1,16 @@ + "", + "status" => "", + ]); + + $users = $client->getNotifications($accountName, $jsonData); + print_r($users); +} catch (Exception $e) { + echo "Exception " . $e->getMessage() . "\n"; +} diff --git a/src/Client.php b/src/Client.php index 23c41fa..6e3467b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -174,14 +174,19 @@ public function getAccountsWithDetails() //print_r($data); } - public function getData($uri) + public function getData($uri, $jsonData = null) { - $url = $this->baseUrl . $uri; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $this->username . ":" . $this->password); + if ($jsonData) { + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + } + $json = curl_exec($ch); $info = curl_getinfo($ch); $code = $this->getStatusCode($ch); @@ -238,4 +243,16 @@ public function updateAccount($accountName, $displayName, $email, $mobile, $abou urlencode($displayName).'/'.urlencode($email).'/'.urlencode($mobile).'/'.urlencode($about)); return $data; } + + public function createNotification($accountName, $jsonData = null) + { + $data = $this->getData('/accounts/'.$accountName.'/notifications/add', $jsonData); + return $data; + } + + public function getNotifications($accountName, $jsonData) + { + $data = $this->getData('/accounts/'.$accountName.'/notifications', $jsonData); + return $data; + } }