-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,29 +109,13 @@ $postId = 'post_id_of_the_post_to_return'; | |
$result = $driver->getPostModel($teamId)->getPost($channelId, $postId); | ||
``` | ||
|
||
### File data model | ||
```php | ||
//Upload a file | ||
$teamId = 'the_id_of_one_of_the_current_users_teams'; | ||
$requestOptions = [ | ||
'files' => 'a file to be uploaded', | ||
'channel_id' => 'the id of the channel that this file will be uploaded to' | ||
]; | ||
$result = $driver->getFileModel()->uploadFile($teamId, $requestOptions); | ||
|
||
|
||
//Get a file | ||
$fileId = 'the_id_of_the_file_to_get'; | ||
$result = $driver->getFileModel()->getFile($fileId); | ||
``` | ||
|
||
## ToDo | ||
[x] Add Team data model | ||
[x] Add Channel data model | ||
[x] Add Post data model | ||
[x] Add File data model | ||
[ ] Add Admin data model (in development) | ||
[ ] Add Preference data model | ||
[x] Add Preference data model | ||
|
||
## Contact | ||
- [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* This Driver is based entirely on official documentation of the Mattermost Web | ||
* Services API and you can extend it by following the directives of the documentation. | ||
* | ||
* For the full copyright and license information, please read the LICENSE.txt | ||
* file that was distributed with this source code. For the full list of | ||
* contributors, visit https://github.com/gnello/php-mattermost-driver/contributors | ||
* | ||
* God bless this mess. | ||
* | ||
* @author Luca Agnello <[email protected]> | ||
* @link https://api.mattermost.com/ | ||
*/ | ||
|
||
namespace Gnello\Mattermost\Models; | ||
|
||
/** | ||
* Class PreferenceModel | ||
* | ||
* @package Gnello\Mattermost\Models | ||
*/ | ||
class PreferenceModel extends AbstractModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public static $endpoint = '/preferences'; | ||
|
||
/** | ||
* @param array $requestOptions | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function saveUserPreferences(array $requestOptions) | ||
{ | ||
return $this->client->post(self::$endpoint . '/save', $requestOptions); | ||
} | ||
|
||
/** | ||
* @param array $requestOptions | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function deleteUserPreferences(array $requestOptions) | ||
{ | ||
return $this->client->post(self::$endpoint . '/delete', $requestOptions); | ||
} | ||
|
||
/** | ||
* @param $category | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function listUserPreferences($category) | ||
{ | ||
return $this->client->get(self::$endpoint . '/' . $category); | ||
} | ||
|
||
/** | ||
* @param $category | ||
* @param $name | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function getSpecificUserPreference($category, $name) | ||
{ | ||
return $this->client->get(self::$endpoint . '/' . $category . '/' . $name); | ||
} | ||
|
||
} |