Returns a list of companies. Example
curl -i http://0.0.0.0:9292/api/companies
Returns
[
{
"id": 2,
"name": "Doe Ltd.",
"address": "123 Steep Street",
"city": "San Francisco, CA",
"country": "USA",
"email": null,
"phone": null
}
]
Returns details of the company with :id and its directors. For example:
curl -i http://0.0.0.0:9292/api/companies/2
Returns:
{
"address": "holi",
"city": "stgo",
"country": "chileasdf",
"directors": [
{
"id": 2,
"name": "John Doe"
},
{
"id": 4,
"name": "Jane Doe"
}
],
"email": null,
"id": 2,
"name": "ian",
"phone": null
}
Creates a company with the posted JSON payload. Example:
curl -i --data '{"name":"Company Ltd.", "address": "123 Downhill Rd.", "city": "Santiago", "country": "Chile"}' http://0.0.0.0:9292/api/companies
Will return
{
"address": "123 Downhill Rd.",
"city": "Santiago",
"country": "Chile",
"email": null,
"id": 6,
"name": "Company Ltd.",
"phone": null
}
Failing to send a required field will return an error:
{
"error": "validation_failed",
"errors": [
"Country can't be blank"
]
}
Updates a company with the posted JSON payload. Example:
curl -i -X PUT --data '{"name":"Company Limited"}' http://0.0.0.0:9292/api/companies/6
Returns the new company object:
{
"address": "123 Downhill Rd.",
"city": "Santiago",
"country": "Chile",
"email": null,
"id": 6,
"name": "Company Limited",
"phone": null
}
Deletes a company. Example
curl -i -X DELETE http://0.0.0.0:9292/api/companies/6
Returns a status of 204 No Content.
Returns details of a director. For example:
curl -i http://0.0.0.0:9292/api/companies/2/directors/2
Returns
{
"company_id": 2,
"id": 2,
"name": "John Doe"
}
Redirects (via a status 302) to the PDF of the passport of the director.
curl -i http://0.0.0.0:9292/api/companies/2/directors/22/passport
Returns
HTTP/1.1 302 Found
Location: http://0.0.0.0:9292/uploads/john.doe.pdf
Creates a director with the posted JSON payload. For example:
curl -i -X POST --data '{"name": "Jamie Doe"}' http://0.0.0.0:9292/api/companies/2/directors
Returns
{
"company_id": 2,
"id": 23,
"name": "Jamie Doe"
}
Uploads a passport PDF and returns its temporary id. You can use this id to attach it to a director. It's designed this way to be used by Javascript frontends.
curl -i -X POST -F "passport=@/Users/macbook/Desktop/passport.pdf" http://0.0.0.0:9292/api/companies/2/directors/upload
This returns:
{"passport_cache": "1386111293-90552-1809/passport.pdf"}
To later create or update a director using this id, you can just add it to the payload, like so:
curl -i -X POST --data '{"name": "Jamie Doe", "passport_cache": ""1386111293-90552-1809/passport.pdf""}' http://0.0.0.0:9292/api/companies/2/directors
Creates a director with the posted JSON payload. For example:
curl -i -X PUT --data '{"name": "Jamie Doe Jr."}' http://0.0.0.0:9292/api/companies/2/directors/20
Returns
{
"company_id": 2,
"id": 20,
"name": "Jamie Doe Jr."
}
Deletes a director. Example:
curl -i -X DELETE http://0.0.0.0:9292/api/companies/2/directors/23