Skip to content

Commit

Permalink
README update
Browse files Browse the repository at this point in the history
  • Loading branch information
chaker2710 committed Mar 26, 2022
1 parent fb67857 commit 2256d32
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 63 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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, '<p>Message HTML body</p>');
```

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
Expand Down

0 comments on commit 2256d32

Please sign in to comment.