Skip to content

Instantly share code, notes, and snippets.

@BobGu
Last active January 19, 2017 01:47
Show Gist options
  • Save BobGu/b7650e96ef19517f42687c4da50579cf to your computer and use it in GitHub Desktop.
Save BobGu/b7650e96ef19517f42687c4da50579cf to your computer and use it in GitHub Desktop.

User

Registration

  • Example URL POST host_name/v1/registrations/?api_key=9014e51c-f5b0-4cd9-8725-f1e729665905

  • Example body required

{
	"user": {
		"email": "john@example.com",
		"password": "password",
		"password_confirmation": "password",
		"first_name": "Robert",
		"last_name": "johny",
		"zip_code": "20001",
		"phone_number": "0123456789",
		"display_name": "cooluser",
		"age": "17",
		"gender": "male",
		"profile_photo": "urlOfThePhoto.com",
		"device_id": "theAppleDeviceId"
	}
}
  • Example response {"email":"john@example.com","token_type":"Bearer","user_id":8,"access_token":"Ji_oSa_rmzs_gMXKrGAp"}

Login

  • Example URL POST host_name/v1/login/?api_key=9014e51c-f5b0-4cd9-8725-f1e729665905

  • Body

{
  "email": "bob@example.com",
  "password" : "password"
}
  • Example response {"email":"john@example.com","token_type":"Bearer","user_id":8,"access_token":"Ji_oSa_rmzs_gMXKrGAp"}

Token authentication with user

  • Example URL HTTP_VERB host_name/v1/comments/?api_key=API_KEY

The headers need a field called 'Authroization' where the value is the access_token being sent back after the initial login.

Uploads

  • URL POST host_name/v1/uploads/?api_key=API_KEY

  • Body

{
	"upload": {
		"location_id": "1",
		"user_id": "1",
		"upload_type": "0",
		"url": "golf.MOV"
	}
}

The url is the input_key of the bucket we are using on amazon. The example resonse will be

{
  "id": 2,
  "location_id": 1,
  "user_id": 1,
  "caption": null,
  "url": "https://s3-us-west-2.amazonaws.com/geoplay-video-output/elastic-transcoder-samples/output/hls/4693cc81a649a04f93dc1a1de923de11f64b5aaa0e79fe2e54734fde4780929a/hls_4693cc81a649a04f93dc1a1de923de11f64b5aaa0e79fe2e54734fde4780929a.m3u8",
  "reported_count": 0,
  "upvote_count": 0,
  "downvote_count": 0,
  "active": true,
  "created_at": "2016-11-07T22:08:50.904Z",
  "updated_at": "2016-11-07T22:08:50.904Z",
  "upload_type": "video"
}

Where URL is the location of the manifest file to retrieve the video.

Pictures work the same way and will the be the URL where the photo is located.

Report/Upvote/Downvote

  • User can also report an upload as being appropriate, upvote if they like it, and downvote if they don't like it. The current endpoints look like this.

put 'uploads/report/:id' put 'uploads/upvote/:id' put 'uploads/downvote/:id'

The ID for the video I imagine is more securely passed through the body, but either way is fine. This will change as we currently have no way to link a report, upvote, and downvote to a user.

Comments

Create

  • Example request POST host_name/v1/comments/?api_key=API_KEY
{
  "user_id": "5",
  "upload_id": "1",
  "text": "what a cool video!"
}

Update

  • Example request

PUT host_name/v1/comments/?api_key=API_KEY

{
  "id": "1",
  "text": "what a cooler video!"
}

Delete

  • Example request DELETE host_name/v1/comments/?api_key=API_KEY
{
  "id": "1",
  "text": "what a cooler video!"
}

Report a comment

  • Example request PUT host_name/v1/comments/report/?api_key=API_KEY
  {
    "id": "1"
  }

Locations

Create

  • Example Request POST host_name/v1/locations/?api_key=API_KEY

Body

  {
    "location": {
      "map_location_id": '???',
      "map_location_name": '???'
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment