Skip to content

Curdal/address-book

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Address Book - API

GitHub Tests Action Status GitHub Code Style Action Status

This package was build for an assessment it allows for the management of your Address Book via Api calls.

Installation

You can't install the package via composer so a manual install is required. Clone the repo and add the following to your composer.json

"require": {
    // ...
    "curdal/address-book": "dev-main"
},
// ...
"repositories": [
    // ...
    {
        "type": "path",
        "url": "../address-book"
    }
],

NOTE: The url in the repositories array should point to where you cloned the repo.

Next you will need to run:

composer update

You can publish and run the migrations with:

php artisan vendor:publish --tag="address-book-migrations"
php artisan migrate

Note: Package migrations will still run wether they are published or not

Usage

The Api exposes the following endpoints for usage.

# Search/List endpoints
GET       api/address-book

# Groups endpoints
GET       api/address-book/groups
POST      api/address-book/groups
GET       api/address-book/groups/{group}
PUT       api/address-book/groups/{group}
DELETE    api/address-book/groups/{group}

## Group/People management endpoints
POST      api/address-book/groups/{group}/people
DELETE    api/address-book/groups/{group}/people

# People endpoints
GET       api/address-book/people
POST      api/address-book/people
GET       api/address-book/people/{person}
PUT       api/address-book/people/{person}
DELETE    api/address-book/people/{person}

## People/Groups management endpoints
POST      api/address-book/people/{person}/groups
DELETE    api/address-book/people/{person}/groups

Example

Adding a group via POST request

POST http://127.0.0.1:8000/api/address-book/groups HTTP/1.1
content-type: application/json

{
    "name": "Sample G",
    "description": "Test Group"
}

Returns the following output

{
    "data": {
        "id": 1,
        "name": "Sample G",
        "description": "Test Group",
        "people": []
    }
}

Adding a person via POST request

POST http://127.0.0.1:8000/api/address-book/people HTTP/1.1
content-type: application/json

{
    "first_name": "Bartholomew",
    "last_name": "Gingersnap",
    "emails": ["[email protected]"]
}

Returns the following output

{
    "data": {
        "id": 1,
        "first_name": "Bartholomew",
        "last_name": "Gingersnap",
        "addresses": [],
        "emails": [
            {
                "id":1,
                "value":"[email protected]",
                "default":0
            }
        ],
        "phone_numbers": []
    }
}

Adding people to a group via POST (Returns no output)

POST http://127.0.0.1:8000/api/address-book/groups/1/people HTTP/1.1
content-type: application/json

{
    "people": [1]
}

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages