You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-6Lines changed: 16 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,24 @@
1
1
# Informat API Wrapper
2
2
PHP client library for the Informat school software API. This client allows you to
3
3
- Fetch students
4
-
- Fetch registration
4
+
- Fetch registrations
5
5
- Create new preregistrations
6
6
7
+
## Installation
8
+
You can simply install the library through composer:
9
+
```
10
+
composer require koba/informat-php-client
11
+
```
12
+
The library also requires a PSR-17 and PSR-18 implementation. If these are not yet included in your project, you can install Guzzle 7 to meet this requirement (although any other implementation will work fine):
13
+
```
14
+
composer require guzzlehttp/guzzle
15
+
```
16
+
7
17
## Usage
8
18
The library is built on 3 main 'layers':
9
19
- The `Informat` class, which is instantiated with your client ID and secret.
10
-
- Directories, which are logical groups of api calls. These can be obtained by function calls on the `Informat` class.
11
-
- API calls, these can be instantiated by function calls on the directories.
20
+
- Directories, which are logical groups of api calls. These can be obtained by using the provided methods on the `Informat` class.
21
+
- API calls, these can be instantiated by using the provided methods on the directories.
12
22
13
23
The code below is a quick example of how you can fetch students
14
24
```php
@@ -29,15 +39,15 @@ $informat = new Informat(
29
39
This will return an array of `Student` objects, which has typed (and documented) properties.
30
40
31
41
### Scopes
32
-
Creating the `Informat` object can be done fairly easily as demonstrated above. The scopes paramete might need some extra explanation.
42
+
Creating the `Informat` object can be done fairly easily as demonstrated above. The scopes parameter might need some extra explanation.
33
43
34
44
In the example above you see we pass an `AllScopesStrategy` object to the constructor. This is a way to let the API client know which scopes we want to request, which directly impacts which API calls you will be authorized to execute. The library supplies the `AllScopesStrategy`, which will request all possible scopes and the `SpecificScopesStrategy`, which allows you to specify the scopes that will be requested. Both require you to pass the institute numbers for all schools you wnat to access as parameters. The latter might be desirable if your client isn't authorized for all scopes or you want to limit the functionality for security reasons.
35
45
36
46
You can also create your own scope strategy by implementing the `ScopeStrategyInterface`.
37
47
38
48
### Calls
39
49
There are a couple of 'rules' that should be followed when managing calls
40
-
- When creating a call using a function on a directory, all required parameters for the API call need to be passed to the function. The institute number will always be the first parameter as it is required for all API calls.
50
+
- When creating a call using a method on a directory, all required parameters for the API call need to be passed to the function. The institute number will always be the first parameter as it is required for all API calls.
41
51
- All optional paremeters can be set using setters on the API call.
42
52
- Setters on the API calls returns the call itself, which means you can easily chain them together.
43
53
- An API call will always be executed with the `send` method.
@@ -55,4 +65,4 @@ $informat
55
65
```
56
66
57
67
### Advanced
58
-
The `Informat` object has some advanced setup options. You can pass an `AccessTokenManagerInterface` object, which allows you to implement your own access token caching solution. The rest of the constructor can be used to pass a [psr-18](https://www.php-fig.org/psr/psr-18/) client interface and [psr-17](https://www.php-fig.org/psr/psr-17/) HTTP response factories. If these options are omitted, the library will autodiscover any suitable implementations. If your project doesn't currently have one, you could take a look at [Guzzle 7](https://docs.guzzlephp.org/en/stable/).
68
+
The `Informat` object has some advanced setup options. You can pass an `AccessTokenManagerInterface` object, which allows you to implement your own access token caching solution. The rest of the constructor can be used to pass a [psr-18](https://www.php-fig.org/psr/psr-18/) client interface and [psr-17](https://www.php-fig.org/psr/psr-17/) HTTP response factories. If these options are omitted, the library will autodiscover any suitable implementations.
0 commit comments