diff --git a/CHANGELOG.md b/CHANGELOG.md index ccab0b0..0bef2bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,6 @@ All notable changes to `ips-api` will be documented in this file -## 1.0.0 - 201X-XX-XX +## 1.0.0 - 2022-03-26 - initial release diff --git a/README.md b/README.md index 2086d0f..06490dc 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -# Very short description of the package +# IPS REST API Laravel Client [![Latest Version on Packagist](https://img.shields.io/packagist/v/ova-studio/ips-api.svg?style=flat-square)](https://packagist.org/packages/ova-studio/ips-api) [![Total Downloads](https://img.shields.io/packagist/dt/ova-studio/ips-api.svg?style=flat-square)](https://packagist.org/packages/ova-studio/ips-api) -![GitHub Actions](https://github.com/ova-studio/ips-api/actions/workflows/main.yml/badge.svg) -This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors. +# [IPS REST API Documentation](https://invisioncommunity.com/developers/rest-api) ## Installation @@ -14,10 +13,69 @@ You can install the package via composer: composer require ova-studio/ips-api ``` -## Usage +## Configuration +In `config/services.php`: + +```php +'ips' => [ + // ... other options + 'base_uri' => env('IPS_BASE_URI'), + 'api_key' => env('IPS_API_KEY'), + 'default_user' => env('IPS_DEFAULT_USER_ID') +] +``` + +## Implemented API Methods + +### Sending private message + +[Method documentation](https://invisioncommunity.com/developers/rest-api?endpoint=core/messages/POSTindex) + +Basic usage: +```php +$api = new IpsApi(); +$to_user_id = 1; + +$api->system()->messages()->create($to_user_id, 'Message title', 'Message body'); +``` + +By default, message is sent from default user from config file. +If you want to send message from another user, you can set user id with +`withSender` method. ```php -// Usage description here +$api = new IpsApi(); +$from_user_id = 1; +$to_user_id = 1; + +$api->system()->messages()->withSender($from_user_id)->create($to_user_id, 'Message title', 'Message body'); +``` + +### Sending message to topic + +[Method documentation](https://invisioncommunity.com/developers/rest-api?endpoint=forums/posts/POSTindex) + +Basic usage: +```php +$api = new IpsApi(); +$topic_id = 1; + +$api->forums()->posts()->create($topic_id, '
Message HTML body
'); +``` + +By default, message is sent from default user from config file. +If you want to send message from another user, you can set user id with +`withAuthor(int $author, ?string $author_name = null)` method. + +If author ID is equal 0, author name is required. +```php +$api = new IpsApi(); +$from_user_id = 1; +$topic_id = 1; + +$api->forums()->posts() + ->withAuthor($from_user_id) // or ->withAuthor(0, 'Somename') + ->create($to_user_id, 'Message title', 'Message body'); ``` ### Testing