Skip to content

Commit a1e0057

Browse files
committed
Improve the documentation
1 parent 5cefd43 commit a1e0057

File tree

12 files changed

+160
-107
lines changed

12 files changed

+160
-107
lines changed

.php_cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ return PhpCsFixer\Config::create()
3636
))
3737
->setFinder(PhpCsFixer\Finder::create()
3838
->in(__DIR__)
39-
->exclude('doc')
39+
->exclude('docs')
4040
->exclude('ci_generated')
4141
)
4242
;

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* Add a new Client to ease iteration over Slack paginated endpoints thanks to `iterateXxxx` methods (where `xxxx` is the endpoint name to iterate over)
6+
* Improve the documentation
67

78
## 4.1.1 (2021-03-16)
89

README.md

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
# A PHP client for Slack's API
1+
# Introduction
22

3-
There is a bunch of PHP clients for Slack. But some are not up to date or miss
4-
features, some only cover a small part of the API and most are simply no longer
5-
maintained.
3+
This library is a **PHP client** for **Slack's Web API**.
4+
5+
There is a bunch of existing PHP clients for Slack. But some are not up to date
6+
or miss features, some only cover a small part of the API and most are simply
7+
no longer maintained.
68

79
This SDK is generated automatically with [JanePHP](https://github.com/janephp/janephp)
810
from the [official Slack API specs](https://github.com/slackapi/slack-api-specs).
911

10-
It provides a **full object oriented interface** for all the endpoints, requests and responses of the Slack Web API.
12+
It also provides a **full object oriented interface** for all the endpoints,
13+
requests and responses of the Slack Web API.
1114

1215
## Installation
1316

1417
This library is built atop of [PSR-7](https://www.php-fig.org/psr/psr-7/) and
1518
[PSR-18](https://www.php-fig.org/psr/psr-18/). So you will need to install some
16-
implementations for those interfaces.
19+
implementations for those standard interfaces.
1720

1821
If no PSR-18 client or PSR-7 message factory is available yet in your project
1922
or you don't know or don't care which one to use, just install some default:
@@ -28,35 +31,16 @@ You can now install the Slack client:
2831
composer require jolicode/slack-php-api
2932
```
3033

31-
## Usage
32-
33-
First, you need to retrieve a token from Slack.
34-
35-
Checkout Slack's documentation about [all different kind of tokens](https://api.slack.com/authentication/token-types).
36-
A good starting point is the [Authentication Basics documentation](https://api.slack.com/authentication/basics).
37-
38-
Then, use the factory that is provided to create the client:
34+
## Quick start
3935

4036
```php
4137
// $client contains all the methods to interact with the API
42-
$client = JoliCode\Slack\ClientFactory::create($yourToken);
38+
$client = JoliCode\Slack\ClientFactory::create($yourSlackToken);
4339

4440
$user = $client->usersInfo(['user' => 'U123AZER'])->getUser();
45-
46-
dump($user);
4741
```
4842

49-
<p align="center">
50-
<img src="doc/images/model-sample.png" alt="Sample user object" />
51-
<p>
52-
53-
Want more example or documentation? See the [full documentation here](doc/index.md).
54-
55-
## Troubleshoots
56-
57-
Got some problems using this library? Need a missing feature?
58-
Do not hesitate to [open an issue](https://github.com/jolicode/slack-php-api/issues)
59-
and share it with us.
43+
Want more documentation or examples? See the [full documentation here](https://jolicode.github.io/slack-php-api/#/docs/usage).
6044

6145
## Further documentation
6246

doc/images/model-sample.png

-120 KB
Binary file not shown.

doc/index.md

Lines changed: 0 additions & 78 deletions
This file was deleted.

docs/_sidebar.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Documentation
2+
3+
* [Home](/)
4+
* [Introduction](/introduction)
5+
* [Usage](/docs/usage)
6+
* [Troubleshoots](/docs/troubleshoots)
7+
* [Updating the SDK](/docs/updating-sdk)
8+
* [Changelog](/CHANGELOG)

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Here is the documentation of jolicode/slack-php-api
2+
3+
Start by reading [the introduction](../README.md).

docs/troubleshoots.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Troubleshoots
2+
3+
## Bypassing the incomplete API specification
4+
5+
Slack's OpenAPI spec is not 100% complete yet, hence our generated client may
6+
miss some features.
7+
8+
If you miss an option in a method, until Slack add it to their spec, we can
9+
manually add it to our [versioned spec](https://github.com/jolicode/slack-php-api/tree/main/resources/slack-openapi-patched.json) then
10+
[regenerate](updating-sdk.md) and release a new version of the library.
11+
12+
## Missing data in the DTO?
13+
14+
The Slack specification is not up to date and miss some critical parts. We do
15+
build a [better one on top of the official](doc/updating-sdk.md) but it can't
16+
be perfect.
17+
18+
What's good is that some models use `\ArrayObject` as base classes so if the
19+
API returns data we don't have in the OpenAPI mapping, you can still access it via
20+
Array like syntax:
21+
22+
```php
23+
$results = $client->searchMessages([
24+
'query' => 'test'
25+
]);
26+
27+
var_dump($results->getOk()); // ok property is mapped
28+
var_dump($results['messages']); // messages property is not mapped but still readable
29+
```
30+
31+
Feel free to open issues if you think a model miss some fields.
32+
33+
## Other problems?
34+
35+
The above documentation did not answer your question? Do not hesitate to open
36+
an issue and share your issue with us.

0 commit comments

Comments
 (0)