Code Monkey home page Code Monkey logo

vote_widget's People

Contributors

elasim avatar

Watchers

 avatar  avatar

vote_widget's Issues

API Specification

This issue is proposal about API specifications.

API

This describes the resources that make up vote widget API v1

Table of Contents

  1. Common
    1. Protocol
    2. Version
    3. Cross Origin Resource Sharing (CORS)
    4. Client Errors
  2. Movie

1. Common

Protocol

All API must have to access is over HTTPS.
also, All data is sent and recieved as JSON

Most of API methods take optional parameters

For GET requests, any parameters not specificed as a segment in the path
can be passed as an HTTP query string parameter

For POST, PATCH, PUT and DELETE requests, parameters not included in the URL
should be encoded as JSON with a Content-Type of "application/json"

Version

By default, all requests receive the v1 version of the API.
You can request specific version via 'Accept' field on the request header

Accept: application/vnd.votewidget.v1+json

Currently, These versions are available.

  • application/vnd.votewidget.v1+json

Cross Origin Resource Sharing

The API supports Cross Origin Resource Sharing (CORS) for AJAX requests
from any origin.

Client Errors

There are three possible types of client errors
on API calls that receive request body

  1. Sending invalid JSON will result in a 400 Bad Request response
    with message

    {
     "message": "Problems parsing JSON"
    }
    
  2. Sending invalid fields will result in a 422 Unprocessable Entity response
    with message and errors

    {
     "message": "Invalid parameter",
     "errors": [
       {
         "resource": "Like",
         "field": "movieId",
         "code": "missing_field"
       }
     ]
    }
    

    All error objects have resource and field properties so that your client
    can tell what the problem is.
    There's also an error code to let you know what is wrong with the field.
    These are the possible validation error codes

    Code Description
    not_exist This means a resource does not exist
    missing_field This means a required field on aresource has not been set
    invalid This means the formatting of a field is invalid

    Most of errors will provide a message field describing the error

Movie

the Movie APIs provide access to movie information, vote, and vote results

List all movies

GET /movies

Parameters

Name Type Description min max default
offset unsigned skip offset items 0 0
limit unsigned get limit items 1 100 30

Response

{
  "movies": [
    {
      "id": 1,
      "title": "Sample A",
      "director_name": "Sample A's Director",
      "summary": "This is summary of Sample A"
    },
    {
      "id": 2,
      "title": "Sample B",
      "director_name": "Sample B's Director",
      "summary": "This is summary of Sample B"
    }
  ],
  offset: 0,
  limit: 2,
  total: 3,
}
Name Type Description
movies array Retrieved movie informations
total unsigned Total number of stored movie informations
id unsigned The key value of movie information
title string Title of movie
director_name string Director of movie
summary string Summary of movie

Vote a movie

PUT /movies/:movie/votes

Parameters

Name Type Description
movie unsigned Required key value of specific Movie
name string Required Username (at least two-character)

Response

{
  "title": "Sample A",
  "votes": 3383
}
Name Type Description
title string Title of movie
votes unsigned Number of votes

Get vote result

GET /movies/:movie/votes

Parameters

Name Type Description
movie unsigned Required key value of specific Movie

Response

{
  "title": "Sample A",
  "votes": 3383
}
Name Type Description
title string Title of movie
votes unsigned Number of votes

build view to vote movies

Requirements

  • Showing 3 Movies and their information (title, director name, summary)
  • User can vote in realtime
  • User can choose among of them
  • When User select a movie, It should be stored in Users table
  • When User select a movie, It should be show vote results

create 'Movies' table and insert records

id : PK
title : 영화 제목
director_name : 감독 이름
summary : 영화 줄거리

위 구조를 갖는 테이블을 생성하고 임의로 레코드를 3개 추가하는 쿼리 작성

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.