Skip to content

Commit dad8db2

Browse files
author
Camille Baronnet
committed
Fix #8 explain multiple api sources and fix other typos
1 parent fb93d4b commit dad8db2

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

docs/more-about-wrapper.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class CustomWrapper
1919

2020
//...
2121

22-
public function getUser($id) // Retrive just ONE user
22+
public function getUser($id) // Retrieve just ONE user
2323
{
2424
return $this->transport->request('/user/'.$id);
2525
}
2626

27-
public function getUsers(array $filters) // Retrive multiple users
27+
public function getUsers(array $filters) // Retrieve multiple users
2828
{
2929
return $this->transport->request('/users', $filters);
3030
}
@@ -41,7 +41,7 @@ class CustomWrapper
4141

4242
public function deleteUser($id)
4343
{
44-
return $this->transport->request('/user/'.$id, 'delete');
44+
return $this->transport->request('/user/'.$id, [], 'delete');
4545
}
4646

4747
//...

docs/work-standalone.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ class MyModel extends Model
2828

2929
```
3030

31-
Next, follow this example to register your API Wrapper into your new model :
31+
Next, follow this example to register your custom API Wrapper into your custom model :
3232

3333
```php
3434
<?php
3535

3636
use App\MyModel;
37+
use App\CustomWrapper;
3738
use Curl\Curl;
3839
use Cristal\ApiWrapper\Transports\Basic;
3940

4041
$transport = new Basic('username', 'password', 'http://api.example.com/v1/', new Curl);
41-
$api = new YourCustomAPIWrapper($transport);
42+
$api = new CustomWrapper($transport);
4243
MyModel::setApi($api);
4344

4445
```
4546

46-
As you can see, if we need to provide another API Wrapper, we can create a new empty model to set another API Wrapper.
47+
As you can see, if you need to provide another API Wrapper, you can create a new empty model to set another API Wrapper.
4748

4849
## Create a model
4950

docs/work-with-laravel.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,47 +27,48 @@ class MyModel extends Model
2727

2828
> **Tips !** Instead of the standard Model, this bridged one returns Collections, is Serializable, Jsonable, can be used in your Routes and allows relations between an Api Model and an Eloquent Model.
2929
30-
Next, into your ServiceProvider, you need to create a link between instance of Api Wrapper and your model :
30+
Next, into your ServiceProvider, you need to create a link between instance of your custom Api Wrapper and your custom model :
3131

3232
```php
3333
<?php
3434

3535
namespace App\Providers;
3636

3737
use App\MyModel;
38+
use App\CustomWrapper;
3839
use Illuminate\Support\ServiceProvider;
39-
use Cristal\ApiWrapper\Api;
4040
use Cristal\ApiWrapper\Transports\Basic;
4141
use Curl\Curl;
4242

4343
class AppServiceProvider extends ServiceProvider
4444
{
4545
public function boot(): void
4646
{
47-
MyModel::setApi($this->app->make(Api::class));
47+
MyModel::setApi($this->app->make(CustomWrapper::class));
4848
}
4949

5050
public function register()
5151
{
52-
$this->app->bind(Api::class, function(){
52+
$this->app->bind(CustomWrapper::class, function(){
5353
$transport = new Basic(
5454
'username',
5555
'password',
5656
'http://api.example.com/v1/',
5757
$this->app->make(Curl::class)
5858
);
59-
return new Api($transport);
59+
return new CustomWrapper($transport);
6060
});
6161
}
6262

6363
}
6464

65-
6665
```
6766

67+
As you can see, if you need to provide another API Wrapper, you can create a new empty model to set another API Wrapper.
68+
6869
## Create a model
6970

70-
Next, create a model that represent your object :
71+
Next, create a model that represents your object :
7172

7273
```php
7374
<?php
@@ -79,7 +80,7 @@ class User extends MyModel
7980
// This property is directly used and pluralized by the API Wrapper (ex : getUsers).
8081
protected $entity = 'user';
8182

82-
// If your API ressource can be identified with a unique key you can define
83+
// If your API resource can be identified with a unique key you can define
8384
// the primary key. By default it is 'id'.
8485
protected $primaryKey = 'id';
8586
}

0 commit comments

Comments
 (0)