Skip to content

Naskalin/test_14_11_23

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

install

  1. git clone git@github.com:Naskalin/test_14_11_23.git
  2. php composer install

run tests

php vendor/bin/pest

usage factory

// create instance of api
$api = new ApiJsonPlaceholder();

$resp = api()->users()->list();

// App\Models\User
$user = UserFactory::new($resp[0]);

// array of App\Models\User
$users = UserFactory::collection($resp);

usage api

// create instance of api
$api = new ApiJsonPlaceholder();

$userId = 1;
$pageNumber = 2;
$postId = 3;

// list users
$api->users()->list();
// or
$api->users()->list($pageNumber);

// list todos by userId
$api->users()->listTodos($userId);
//or
$api->users()->listTodos($userId, $pageNumber);

// list posts by userId
$api->users()->listPosts($userId);
//or
$api->users()->listPosts($userId, $pageNumber);

// create post
$api->users()->createPost($userId, [
    'title' => 'Naskalin post',
    'body' => 'Lorem ipsum'
]);

// get post
$api->posts()->get($postId);

// update post
$api->posts()->update($postId, ['title' => 'Lorem ipsum']);

// delete post
$api->posts()->delete($postId);

// more...

// get user by id
$api->users()->get($userId);

// create user
$api->users()->create([
    'name' => 'Naskalin',
    'username' => 'Michelle',
    'email' => 'test@example.com',
]);

// update user
$api->users()->update($userId, ['name' => 'NewName']);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages