Skip to content

Latest commit

 

History

History
276 lines (240 loc) · 8.46 KB

README.md

File metadata and controls

276 lines (240 loc) · 8.46 KB

Let's Change the Subject -- API

Let's change the subject is an app that facilitates conversations big and small between friends, coworkers, partners and strangers by suggesting conversation prompts.


Table of contents

Getting Started

For development, you will only need Ruby on Rails and Postgres, which depends on Homebrew and Ruby.

Node installation on OS X

You will need to use a Terminal. On OS X, you can find the default terminal in /Applications/Utilities/Terminal.app.

  1. Install Homebrew:

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. Install Ruby:

    $ brew install rbenv ruby-build
    # Add rbenv to bash so that it loads every time you open a terminal
    $ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
    $ source ~/.bash_profile

    # Install Ruby
    $ rbenv install 2.7.1
    $ rbenv global 2.7.1
    $ ruby -v
  1. Install Rails
    $ gem install rails -v 6.0.2.2
  1. Install PostgreSQL
    $ brew install postgresql

Node installation on Linux

Go on official Rails website & follow the steps.

Node installation on Windows

Go on official Rails website & follow the steps.

Installation

  1. Clone the repo and cd into the folder:
    $ git clone https://github.com/luanesouza/backend-lets-change-the-subject.git
    $ cd backend-lets-change-the-subject
  1. Install dependencies (gems)
    $ bundle
  1. Create migrations, migrate and seed:
    $ rails db:create
    $ rails db:migrate
    $ rails db:seed

Start and Watch

    $ rails s

Domain model

Domain model

Endpoints and sample responses

This app uses API versioning. Currently, the calls can be made to /api/v1/. Below you will find available endpoints with sample responses:

Questions

Endpoint: GET /api/v1/questions Action description: Response will consist of 50 random questions from all categories Sample response:

[
  {
    "id": 111,
    "content": "What fictional character is amazing in their book / show / movie, but would be insufferable if you had to deal with them in mundane everyday situations?",
    "additionalLink": "https://conversationstartersworld.com",
    "spiciness": 1
  },
  {
    "id": 130,
    "content": "If you were given an envelope with the the time and date of your death inside, would you open it?",
    "additionalLink": "https://conversationstartersworld.com",
    "spiciness": 1
  }
]

Categories

Endpoint: GET /api/v1/categories Action description: Response will consist of all currently available categories. Sample response:

[
  {
    "name": "friends"
  },
  {
    "name": "coworkers"
  }
]

Category Questions

Endpoint: GET /api/v1/categories/name-of-the-category Action description: Response will contain 50 random questions from the given category. Sample response:

{
  "name": "friends",
  "questions": [
    {
      "id": 77,
      "spiciness": 1,
      "additionalLink": "",
      "content": "What's the most embarrasing thing you've ever said?"
    },
    {
      "id": 43,
      "spiciness": 1,
      "additionalLink": "",
      "content": "What is a thing you always wanted to learn but never got around to?"
    },
  ]
}

User and Remaining Questions

Endpoint: GET /api/v1/users/:id Action description: Response will provide information about the user, together with 100 random questions from each category that the user has not yet seen. Sample response:

{
  "id": 1,
  "email": "xyz2020@gmail.com",
  "username": "xyz2020",
  "remainingFriendsQs": [
    {
      "id": 4,
      "spiciness": 2,
      "additionalLink": "https://ggia.berkeley.edu/practice/36_questions_for_increasing_closeness",
      "content": "Would you like to be famous? In what way?"
    },
  ],
  "remainingCoworkersQs": [
    {
      "id": 78,
      "spiciness": 1,
      "additionalLink": "",
      "content": "If you could have two of a body part, which one would you duplicate and why?"
    },
  ],
  "remainingPartnersQs": [
    {
      "id": 25,
      "spiciness": 1,
      "additionalLink": "https://ggia.berkeley.edu/practice/36_questions_for_increasing_closeness",
      "content": "Alternate sharing something you consider a positive characteristic of your partner. Share a total of five items."
    },
  ]
}

Add Seen Questions

Endpoint: POST /api/v1/seen_questions Action description: The body of the requests needs to contain: user_id, question_id and, in case the question was skipped, skipped: true. Sample OK response:

tba

Sample error response:

tba

Sign up

Endpoint: POST /api/v1/users Action description: The body of the requests needs to contain: username, password, password_confirmation and email and these params need to be in accordance with our validations. Sample OK response:

tba

Sample error response:

tba

Login

Endpoint: POST /api/v1/auth/login Action description: The body of the requests needs to contain: username and password. Sample OK response:

tba

Sample error response:

tba

Autologin

Endpoint: GET /api/v1/auth/auto_login Action description: The body of the requests needs to contain a token. Sample OK response:

tba

Sample 401 error response:

{
  "message": "Please log in"
}

Languages and Tools

Contributing

Pull requests are welcome. Please make sure that your PR is well-scoped. For major changes, please open an issue first to discuss what you would like to change.

Known issues

Visit issues section.

Contributors


Sylwia Vargas

💻 🐛📖💡

Annie Souza

🚇 🐛💡

License

MIT