Skip to content

pdxacm/acmapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Cameron Brandon White
Jul 7, 2014
77eeb53 · Jul 7, 2014

History

66 Commits
Jul 7, 2014
Jul 7, 2014
Apr 6, 2014
Jun 5, 2014
May 4, 2014
Apr 6, 2014
May 18, 2014
May 16, 2014
May 18, 2014
May 18, 2014
May 18, 2014
Jul 7, 2014

Repository files navigation

acmapi

Build Status

API for the @acmpdx

Methods

HTTP method Description
GET To view a resource(s)
PUSH To add a resource
POST To update/change a resource
DELETE To delete/remove a resource

Examples

Top Level

$ curl http://acm.pdx.edu/api/v1/
{
    "events_url": [
        "http://acm.pdx.edu/api/v1/events/"
        "http://acm.pdx.edu/api/v1/events/<int:event_id>"
    ], 
    "memberships_url": [
        "http://acm.pdx.edu/api/v1/memberships/", 
        "http://acm.pdx.edu/api/v1/memberships/<int:membership_id>"
    ], 
    "officerships_url": [
        "http://acm.pdx.edu/api/v1/officerships/", 
        "http://acm.pdx.edu/api/v1/officerships/<int:officership_id>"
    ], 
    "people_url": [
        "http://acm.pdx.edu/api/v1/people/", 
        "http://acm.pdx.edu/api/v1/people/<int:person_id>", 
        "http://acm.pdx.edu/api/v1/people/<int:editor_id>", 
        "http://acm.pdx.edu/api/v1/people/<string:username>"
    ], 
    "posts_url": [
        "http://acm.pdx.edu/api/v1/posts/"
        "http://acm.pdx.edu/api/v1/posts/<int:post_id>"
    ]
}

People

Add a person

$ curl http://acm.pdx.edu/api/v1/people/ \
    -u root:1234 \
    -d username="foobar" \
    -d name="Foo Bar" \
    -d email="foobar@example.com" \
    -d password="password1234"
{
    "email": "foobar@example.com", 
    "id": 2, 
    "name": "Foo Bar", 
    "username": "foobar", 
    "website": null,
}

Add a second user

$ curl http://acm.pdx.edu/api/v1/people/ \
    -u root:1234 \
    -d username="war5" 
    -d password="password1234"
{
    "email": null, 
    "id": 2, 
    "name": null, 
    "username": "war5", 
    "website": null,
}

Update user by username

$ curl -X PUT http://acm.pdx.edu/api/v1/people/war5 \
    -u root:1234 \
    -d name="Billy Bob" 
{
    "email": null, 
    "id": 2, 
    "name": "Billy Bob", 
    "username": "war5", 
    "website": null
}

Update user by id

$ curl -X PUT http://acm.pdx.edu/api/v1/people/war5 \
    -u root:1234 \
    -d email="billybob@example.com" 
{
    "email": "billybob@example.com", 
    "id": 2, 
    "name": "Billy Bob", 
    "username": "war5", 
    "website": null
}

List all users

$ curl http://acm.pdx.edu/api/v1/people/
[
    {
        "email": null, 
        "id": 1, 
        "name": "Foo Bar", 
        "username": "foobar", 
        "website": null
    }, 
    {
        "email": "billybob@example.com",
        "id": 2, 
        "name": "Billy Bob", 
        "username": "war5", 
        "website": null
    }
]

Find people by id

$ curl http://acm.pdx.edu/api/v1/people/1
{
    "email": null, 
    "id": 1, 
    "name": "Foo Bar", 
    "username": "foobar", 
    "website": null
}

Find people by username

$ curl http://acm.pdx.edu/api/v1/people/foobar
{
    "email": null, 
    "id": 1, 
    "name": "Foo Bar", 
    "username": "foobar", 
    "website": null
}

Delete people by username

$ curl -X DELETE http://acm.pdx.edu/api/v1/people/foobar \
    -u root:1234 
{
    "message": "delete successful"
}

Delete people by id

$ curl -X DELETE http://acm.pdx.edu/api/v1/people/1 \
    -u root:1234
{
    "message": "delete successful"
}

Memberships

Add membership to user

$ curl http://acm.pdx.edu/api/v1/memberships/ \
    -u root:1234 \
    -d person_id=1 \
    -d start_date="2014-10-11" \
    -d end_date="2015-10-11"
{
    "end_date": "2015-10-11", 
    "id": 1, 
    "person": "http://acm.pdx.edu/api/v1/people/1", 
    "person_id": 1, 
    "start_date": "2014-10-11"
}

List all memberships

$ curl http://acm.pdx.edu/api/v1/memberships/
[
    {
        "end_date": "2015-10-11", 
        "id": 1, 
        "person": "http://acm.pdx.edu/api/v1/people/1", 
        "person_id": 1, 
        "start_date": "2014-10-11"
    }
]

Find membership by id

$ curl http://acm.pdx.edu/api/v1/memberships/1
{
    "end_date": "2015-10-11", 
    "id": 1, 
    "person": "http://acm.pdx.edu/api/v1/people/1", 
    "person_id": 1, 
    "start_date": "2014-10-11"
}

Delete membership by id

$ curl -X DELETE http://acm.pdx.edu/api/v1/memberships/1 \
    -u root:1234
{
    "message": "delete successful"
}

Officerships

Add officerships to user

$ curl http://acm.pdx.edu/api/v1/officerships/ \
    -u root:1234 \
    -d person_id=1 \
    -d title="Vice Chair" \
    -d start_date="2014-10-11" \
    -d end_date="2015-10-11"
{
    "end_date": "2015-10-11", 
    "id": 1, 
    "person": "http://acm.pdx.edu/api/v1/people/1", 
    "person_id": 1, 
    "start_date": "2014-10-11",
    "title": "Vice Chair"
}

List all officerships

$ curl http://acm.pdx.edu/api/v1/officerships/
[
    {
        "end_date": "2015-10-11", 
        "id": 1, 
        "person": "http://acm.pdx.edu/api/v1/people/1", 
        "person_id": 1, 
        "start_date": "2014-10-11",
        "title": "Vice Chair"
    }
]

Find officerships by id

$ curl http://acm.pdx.edu/api/v1/officerships/1
{
    "end_date": "2015-10-11", 
    "id": 1, 
    "person": "http://acm.pdx.edu/api/v1/people/1", 
    "person_id": 1, 
    "start_date": "2014-10-11",
    "title": "Vice Chair"
}

Delete membership by id

$ curl -X DELETE http://acm.pdx.edu/api/v1/officerships/1 \
    -u root:1234
{
    "message": "delete successful"
}

Events

Add Events

$ curl http://acm.pdx.edu/api/v1/events/ \
    -u root:1234 \
    -d title="Event Title 1" \
    -d description="Event 1" \
    -d location="Room 1" \
    -d speaker="Bob" \
    -d start="2014-10-10 20:20:00.00000" \
    -d end="2014-10-10 21:10:00.00000"
{
    "canceled": false, 
    "description": "Event 1", 
    "edited_at": "Mon, 21 Apr 2014 04:12:35 -0000", 
    "editor": "http://acm.pdx.edu/api/v1/people/1", 
    "editor_id": 1, 
    "end": "Fri, 10 Oct 2014 21:10:00 -0000", 
    "event_id": 1, 
    "hidden": false, 
    "location": "Room 1", 
    "revision": 1, 
    "speaker": "Bob", 
    "start": "Fri, 10 Oct 2014 20:20:00 -0000", 
    "title": "Event Title 1"
}
$ curl http://acm.pdx.edu/api/v1/events/ \
    -u root:1234 \
    -d title="Event Title 2" \
    -d description="Event 2" \
    -d location="Room 2" \
    -d speaker="Alex" \
    -d start="2014-11-10 20:20:00.00000" \
    -d end="2014-11-10 21:10:00.00000"
{
    "canceled": false, 
    "description": "Event 2", 
    "edited_at": "Mon, 21 Apr 2014 04:14:42 -0000", 
    "editor": "http://acm.pdx.edu/api/v1/people/1", 
    "editor_id": 1, 
    "end": "Mon, 10 Nov 2014 21:10:00 -0000", 
    "event_id": 2, 
    "hidden": false, 
    "location": "Room 2", 
    "revision": 1, 
    "speaker": "Alex", 
    "start": "Mon, 10 Nov 2014 20:20:00 -0000", 
    "title": "Event Title 2"
}

Update Events by id

$ curl -X PUT http://acm.pdx.edu/api/v1/events/1 -d canceled=True \
    -u root:1234 \
{
    "canceled": true, 
    "description": "Event 1", 
    "edited_at": "Mon, 21 Apr 2014 04:16:35 -0000", 
    "editor": "http://acm.pdx.edu/api/v1/people/1", 
    "editor_id": 1, 
    "end": "Fri, 10 Oct 2014 21:10:00 -0000", 
    "event_id": 1, 
    "hidden": false, 
    "location": "Room 1", 
    "revision": 2, 
    "speaker": "Bob", 
    "start": "Fri, 10 Oct 2014 20:20:00 -0000", 
    "title": "Event Title 1"
}

List all Events

$ curl http://acm.pdx.edu/api/v1/events/
[
    {
        "canceled": true, 
        "description": "Event 1", 
        "edited_at": "Mon, 21 Apr 2014 04:16:35 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "end": "Fri, 10 Oct 2014 21:10:00 -0000", 
        "event_id": 1, 
        "hidden": false, 
        "location": "Room 1", 
        "revision": 2, 
        "speaker": "Bob", 
        "start": "Fri, 10 Oct 2014 20:20:00 -0000", 
        "title": "Event Title 1"
    }, 
    {
        "canceled": false, 
        "description": "Event 2", 
        "edited_at": "Mon, 21 Apr 2014 04:14:42 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "end": "Mon, 10 Nov 2014 21:10:00 -0000", 
        "event_id": 2, 
        "hidden": false, 
        "location": "Room 2", 
        "revision": 1, 
        "speaker": "Alex", 
        "start": "Mon, 10 Nov 2014 20:20:00 -0000", 
        "title": "Event Title 2"
    }
]

List all Event revisions by id

$ curl http://acm.pdx.edu/api/v1/events/1
[
    {
        "canceled": false, 
        "description": "Event 1", 
        "edited_at": "Mon, 21 Apr 2014 04:12:35 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "end": "Fri, 10 Oct 2014 21:10:00 -0000", 
        "event_id": 1, 
        "hidden": false, 
        "location": "Room 1", 
        "revision": 1, 
        "speaker": "Bob", 
        "start": "Fri, 10 Oct 2014 20:20:00 -0000", 
        "title": "Event Title 1"
    }, 
    {
        "canceled": true, 
        "description": "Event 1", 
        "edited_at": "Mon, 21 Apr 2014 04:16:35 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "end": "Fri, 10 Oct 2014 21:10:00 -0000", 
        "event_id": 1, 
        "hidden": false, 
        "location": "Room 1", 
        "revision": 2, 
        "speaker": "Bob", 
        "start": "Fri, 10 Oct 2014 20:20:00 -0000", 
        "title": "Event Title 1"
    }
]

Posts

Add Posts

$ curl http://acm.pdx.edu/api/v1/posts/ \
    -u root:1234 \
    -d title="This is the Title" \
    -d description="This is the description" \
    -d content="This is the content" 
{
    "content": "This is the content", 
    "description": "This is the description", 
    "edited_at": "Mon, 21 Apr 2014 04:26:59 -0000", 
    "editor": "http://acm.pdx.edu/api/v1/people/1", 
    "editor_id": 1, 
    "hidden": false, 
    "post_id": 1, 
    "revision": 1, 
    "title": "This is the Title"
}
$ curl http://acm.pdx.edu/api/v1/posts/ \
    -u root:1234 \
    -d title="This is another Title" \
    -d description="This is another description" \
    -d content="This is some more content" 
{
    "content": "This is some more content", 
    "description": "This is another description", 
    "edited_at": "Mon, 21 Apr 2014 04:29:07 -0000", 
    "editor": "http://acm.pdx.edu/api/v1/people/1", 
    "editor_id": 1, 
    "hidden": false, 
    "post_id": 2, 
    "revision": 1, 
    "title": "This is another Title"
}

Update Posts by id

$ curl -X PUT http://acm.pdx.edu/api/v1/posts/1 -d canceled=True \
    -u root:1234 
{
    "content": "This is the content", 
    "description": "This is the description", 
    "edited_at": "Mon, 21 Apr 2014 04:30:12 -0000", 
    "editor": "http://acm.pdx.edu/api/v1/people/1", 
    "editor_id": 1, 
    "hidden": false, 
    "post_id": 1, 
    "revision": 2, 
    "title": "This is the Title"
}

List all Posts

$ curl http://acm.pdx.edu/api/v1/posts/
[
    {
        "content": "This is the content", 
        "description": "This is the description", 
        "edited_at": "Mon, 21 Apr 2014 04:30:12 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "hidden": false, 
        "post_id": 1, 
        "revision": 2, 
        "title": "This is the Title"
    }, 
    {
        "content": "This is some more content", 
        "description": "This is another description", 
        "edited_at": "Mon, 21 Apr 2014 04:29:07 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "hidden": false, 
        "post_id": 2, 
        "revision": 1, 
        "title": "This is another Title"
    }
]

List all Posts revisions by id

$ curl http://acm.pdx.edu/api/v1/posts/1
[
    {
        "content": "This is the content", 
        "description": "This is the description", 
        "edited_at": "Mon, 21 Apr 2014 04:26:59 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "hidden": false, 
        "post_id": 1, 
        "revision": 1, 
        "title": "This is the Title"
    }, 
    {
        "content": "This is the content", 
        "description": "This is the description", 
        "edited_at": "Mon, 21 Apr 2014 04:30:12 -0000", 
        "editor": "http://acm.pdx.edu/api/v1/people/1", 
        "editor_id": 1, 
        "hidden": false, 
        "post_id": 1, 
        "revision": 2, 
        "title": "This is the Title"
    }
]