Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Updating README to include header changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TZK- committed Apr 26, 2017
1 parent e066afa commit 0c5daa4
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TaigaPHP has been written for PHP >=5.3 and and earlier versions and you need to

To install the library, just run the command below:
```sh
composer require tzk/taiga-php
composer require tzk/taiga-php
```
The Library has been added into your dependencies and ready to be used.

Expand All @@ -36,6 +36,49 @@ $credentials = [
echo TZK\Taiga\Taiga::getAuthToken($baseUrl, $credentials);
```

# Get Taiga instance
```php
$headers = [
'language' => 'fr',
'x-disable-pagination' => true
];

$taiga = new TZK\Taiga\Taiga($baseUrl, $auth_token, $headers);
```

# Change configuration on the fly

You can change the configuration through HTTP headers on the fly.

You just need to call magic methods which has the same name as the header you wanna set prefixed by 'set'.

Some headers has composed by multiple words separated by dashed (Ex. Accept-Language).

To get it works, you should write the header name without dashes and camel-cased.

## Example

```php
$taiga->setAcceptLanguage('fr')->setAuthorization('Bearer ' . $auth_token);
```

To ease changing auth token or language on the fly, you can use shortcuts specified in *Taiga.php*

```php
// In Taiga.php
protected static $HEADER_MAP = [
'language' => [
'header' => 'Accept-Language'
],
'authToken' => [
'header' => 'Authorization',
'prefix' => 'Bearer '
]
];

$taiga->setLanguage('fr')->setAuthToken($token); // Will produce the same as above.
```

# Register a new service

The wrapper is based on 'Services' which wrap the API calls.
Expand Down Expand Up @@ -97,16 +140,10 @@ If you wanna add new services, the only thing you have to do is to create a new

TaigaPHP will automatically load the service for you and it will be accessible from a public method which has the same name as your service.

# Example
# Examples

## Get issue types
```php
/*
* You can specify the locale to use giving language code
* @see https://taigaio.github.io/taiga-doc/dist/api.html#object-locale-detail
*/
$taiga = new TZK\Taiga\Taiga($baseUrl, $auth_token, 'fr');

// Access with the 'issueTypes' public method
$issues = $taiga->issueTypes()->getList(['project' => $projectId]);
```
Expand Down

0 comments on commit 0c5daa4

Please sign in to comment.