Giter Club home page Giter Club logo

how_are_you_doing_be's Introduction

"How Are You Doing?" is a group project where a user can create an account, reflect and log their feelings, and check in on friends.

Table of contents

Schema:

The schema of the project includes 4 tables.

Setup

  • Ruby 2.7.4
  • Rails 5.2.8.1'
  • Fork this repository
  • Clone your fork
  • From the command line, install gems and set up your DB:
  • bundle install
  • rails db:{create,migrate,seed}
  • run the server with 'rails s'
  • Go to Postman and use one of these endpoints. The endpoints must look something like: http://localhost:5000/api/v1/users/history
  • Alternatively you can download the Postman Suite and run the premade endpoints

Endpoints

Emotions

Get all emotions for a post

get 'api/v1/emotions'

{
   "data": [
       {
           "id": "1",
           "type": "emotion",
           "attributes": {
               "emotion": "Affectionate",
               "definition": "(of a person) Having affection or warm regard; loving; fond."
           }
       },
       {
           "id": "2",
           "type": "emotion",
           "attributes": {
               "emotion": "Confident",
               "definition": "A person in whom one can confide or share one's secrets: a friend."
           }
       },
       {
           "id": "3",
           "type": "emotion",
           "attributes": {
               "emotion": "Grateful",
               "definition": "Appreciative; thankful."
           }
       }
     ]
 }

Users

Get a specific user based on their google id

get 'api/v2/users?search=<google_id>'

{
    "data": {
        "id": "6",
        "type": "user",
        "attributes": {
            "name": "Hisoka Morow",
            "email": "[email protected]",
            "google_id": "91239464"
        }
    }
}

returns this if no user is found with that google id

{
    "data": []
}

Search for a user using their email address

get '/api/v2/users?email='

{
    "data": {
        "id": "5",
        "type": "user",
        "attributes": {
            "name": "Gon Freecss",
            "email": "[email protected]",
            "google_id": "58544636"
        }
    }
}

returns this if no user is found with that email address

{
    "data": []
}

Post or Create a new user to the backend database

post 'api/v1/users'

pass in name, google_id, and email in headers

or

post '/api/v2/users?name=&email=&google_id=<google_id>'

{
    "message": "User successfully created"
}

Posts [And by Posts we mean posts that a user makes on their dashboard]

Get all posts of a user (history)

get '/api/v1/users/history' & pass in user through headers or get '/api/v2/users/history?user=<google_id>'

{ “data” : 
   [
   	{ 
   		“id”: 1 ,
   	“type": "post",
   	"attributes": {
   			"emotion": "pensive"
   			"post_status": "public"
   			"description": "This was what I typed when I made this post."	 
   			"tone" : "anger"
   			"created_at": "2022-11-01 17:02:19.036593 -0600"	 
   		}
   	},
   	{ 
   		“id”: 2 ,
   	“type": "post",
   	"attributes": {
   			"emotion": "pensive"
   			"post_status": "public"
   			"description": "This was what I typed when I made this post."	 
   			"tone" : "anger"
   			"created_at": "2022-11-01 17:02:19.036593 -0600"	 
   		}
   	},
   	{ 
   		“id”: 3 ,
   	“type": "post",
   	"attributes": {
   			"emotion": "pensive"
   			"post_status": "public"
   			"description": "This was what I typed when I made this post."	 
   			"tone" : "anger"
   			"created_at": "2022-11-01 17:02:19.036593 -0600"	 
   		}	
   	}
   ]
}

returns this is a user has no posts

{
  "data": []
}

Get the last post of a user (recent post)

get 'api/v2/users/last?user=<google_id>' or get 'api/v1/posts/last & pass in user google id through headers

{ “data” : 
   	{ 
   		“id”: 3 ,
   	“type": "post",
   	"attributes": {
   			"emotion": "pensive"
   			"post_status": "public"
   			"description": "This was what I typed when I made this post."	 
   			"tone" : "anger"
   			"created_at": "2022-11-01 17:02:19.036593 -0600"	 
   		}	
   	}
}

returns this if a user has no posts

{
  "data": []
}

create a new post

post '/api/v2/posts?user=<google_id>&emotion=<emotion_term>&description=&post_status=<personal_or_shared>'

if the post was successfully created

{
  “data” : 
  {
    “id”: 808 ,
   “type": "post",
   "attributes": {
     "emotion": "thrilled",
     "post_status": "personal",
     "description": "Today I got a job offer for the company that I really loved, and have admired for a long time.",
     "tone": "joy",
     "created_at": "2022-11-05T23:05:26.971Z"
    }
  }
}

if the post was not successfully created

{
    "data": {}
}

update an existing post

patch '/api/v2/posts/:post_id?emotion=<emotion_term>&description=&post_status=<personal_or_shared>'

Get all posts of a particular friend of a user

get '/api/v1/friends/<google_id>/posts'

if the friend has posts

{
    "data": [
        {
            "id": "17",
            "type": "post",
            "attributes": {
                "emotion": "Embarrassed",
                "post_status": "shared",
                "description": "This is the text for user 5 post 1",
                "tone": "eager",
                "created_at": "2022-11-10T16:46:38.465Z"
            }
        },
        {
            "id": "20",
            "type": "post",
            "attributes": {
                "emotion": "Disconnected",
                "post_status": "shared",
                "description": "This is the text for user 5 post 4",
                "tone": "melancholy",
                "created_at": "2022-11-10T16:46:38.476Z"
            }
        }
    ]
}

if the friend has no posts

{
    "data": []
}

Friends

Get all users a user is following with a status of pending

get 'api/v1/friends?request_status=pending' or get '/api/v2/friends?request_status=&user=<google_id>'

v1 response

{
   "data": [
       {
           "id": "5",
           "type": "user",
           "attributes": {
               "name": "Gon Freecss",
               "email": "[email protected]"
           }
       },
       {
           "id": "6",
           "type": "user",
           "attributes": {
               "name": "Hisoka Morow",
               "email": "[email protected]"
           }
       }
   ]
}

v2 response

{
  "data": [
      {
          "id": 7,
          "friendship_id": 4,
          "type": "friend_followee",
          "attributes": {
              "name": "Jenny",
              "email": "[email protected]",
              "google_id": "8675309",
              "request_status": "pending"
          }
      }
  ]
}

returns the following if the user doesn't have any pending requests to follow another user

{
  "data": []
}

Get all users the current user is following with a request status of accepted

get 'api/v1/friends?request_status=accepted' or get '/api/v2/friends?request_status=&user=<google_id>'

v1 response

{
   "data": [
       {
           "id": "10",
           "type": "user",
           "attributes": {
               "name": "Andrew Mullins",
               "email": "[email protected]"
           }
       },
       {
           "id": "13",
           "type": "user",
           "attributes": {
               "name": "Sable",
               "email": "[email protected]"
           }
       }
   ]
}

v2 response

{
  "data": [
      {
          "id": 2,
          "friendship_id": 1,
          "type": "friend_followee",
          "attributes": {
              "name": "Bubbles",
              "email": "[email protected]",
              "google_id": "7357151",
              "request_status": "accepted"
          }
      }
  ]
}

returns the following if no user has accepted the current users follow request

{
  "data": []
}

Get all users a user has requested to follow regardless of status

get 'api/v1/friends' or get '/api/v2/friends?user=<google_id>'

v1 response

{
   "data": [
       {
           "id": "10",
           "type": "user",
           "attributes": {
               "name": "Andrew Mullins",
               "email": "[email protected]"
           }
       },
       {
           "id": "13",
           "type": "user",
           "attributes": {
               "name": "Sable",
               "email": "[email protected]"
           }
       }
   ]
}

v2 response

  {
  "data": [
      {
          "id": 2,
          "friendship_id": 1,
          "type": "friend_followee",
          "attributes": {
              "name": "Bubbles",
              "email": "[email protected]",
              "google_id": "7357151",
              "request_status": "accepted"
          }
      },
      {
          "id": 3,
          "friendship_id": 2,
          "type": "friend_followee",
          "attributes": {
              "name": "Jim Lahey",
              "email": "[email protected]",
              "google_id": "83465653",
              "request_status": "rejected"
          }
      },
      {
          "id": 4,
          "friendship_id": 3,
          "type": "friend_followee",
          "attributes": {
              "name": "Randy Bobandy",
              "email": "[email protected]",
              "google_id": "52785579",
              "request_status": "rejected"
          }
      },
      {
          "id": 7,
          "friendship_id": 4,
          "type": "friend_followee",
          "attributes": {
              "name": "Jenny",
              "email": "[email protected]",
              "google_id": "8675309",
              "request_status": "pending"
          }
      }
  ]
}

returns the following if a user has not requested to follow any other users

{
  "data": []
}

Get all users following the current user regardless of request status

get 'api/v2/users/followers?user=<google_id>'

{
  "data": [
      {
          "id": 3,
          "friendship_id": 10,
          "type": "friend_follower",
          "attributes": {
              "name": "Jim Lahey",
              "email": "[email protected]",
              "google_id": "83465653",
              "request_status": "pending"
          }
      },
      {
          "id": 4,
          "friendship_id": 12,
          "type": "friend_follower",
          "attributes": {
              "name": "Randy Bobandy",
              "email": "[email protected]",
              "google_id": "52785579",
              "request_status": "pending"
          }
      },
      {
          "id": 5,
          "friendship_id": 14,
          "type": "friend_follower",
          "attributes": {
              "name": "Gon Freecss",
              "email": "[email protected]",
              "google_id": "58544636",
              "request_status": "accepted"
          }
      }
  ]
}

returns the following if no one has requested to follow the user

{
  "data": []
}

Get all users where the current user has accepted a follow request

get /api/v2/users/followers?user=<google_id>&request_status=accepted

{
    "data": [
        {
            "id": 5,
            "friendship_id": 14,
            "type": "friend_follower",
            "attributes": {
                "name": "Gon Freecss",
                "email": "[email protected]",
                "google_id": "58544636",
                "request_status": "accepted"
            }
        }
    ]
}

returns the following if the user has not accepted any follow requests

{
  "data": []
}

Get all users that have requested to follow the current user with a status of pending

get /api/v2/users/followers?user=<google_id>&request_status=pending

{
    "data": [
        {
            "id": 3,
            "friendship_id": 10,
            "type": "friend_follower",
            "attributes": {
                "name": "Jim Lahey",
                "email": "[email protected]",
                "google_id": "83465653",
                "request_status": "pending"
            }
        },
        {
            "id": 4,
            "friendship_id": 12,
            "type": "friend_follower",
            "attributes": {
                "name": "Randy Bobandy",
                "email": "[email protected]",
                "google_id": "52785579",
                "request_status": "pending"
            }
        }
    ]
}

returns the following if the user has no pending follow requests

{
  "data": []
}

Get all users that have requested to follow the current user where current user rejected request

get /api/v2/users/followers?user=<google_id>&request_status=rejected

{
   "data": [
       {
           "id": 1,
           "friendship_id": 2,
           "type": "friend_follower",
           "attributes": {
               "name": "Ricky LaFleur",
               "email": "[email protected]",
               "google_id": "19023306",
               "request_status": "rejected"
           }
       }
   ]
}

returns the following if the user has no rejected follow requests

{
  "data": []
}

Other endpoints to be updated later

Friends: get '/api/v2/friends?email=&user=<google_id>' get '/api/v2/friends/:friendship_id?request_status='

Contributors

how_are_you_doing_be's People

Contributors

aleish-m avatar cballrun avatar alaina-noel avatar mullinsand avatar mballantyne3 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

musselmanth

how_are_you_doing_be's Issues

Lookup a Post

"/api/v2/users/posts" with params user (google_id) and id (post_id) that looks up a post by a specific user. can only be returned if the current user is the writer of that post. returns standard json of the post with all attributes typically sent back to the FE.
can look something like what is below and will probably need additional strong params for the post id param

  def show
    user = User.find_by(google_id: current_user_params[:user])
    post = Post.find(params[:id])
    if user && (post.user_id == user.id)
      render json: PostSerializer.new(post)
    else
      render json:{data: {}}, status: :bad_request
    end
  end

Account for If our API goes down all together

What would the user experience be like if our API went down mid dashboard? Would the app crash? Would they be redirected?
We could account for a 400 error message response from any external APIs or a host of error messages and make sure that the user doesn't get booted if our API is down.

POST create friend

POST api/v1/friends

Creates a new friendship between users in the database creates with request status pending. (user will be followee of friend)

  • Headers pass in user's google_id as user
    • Received in request as USER_HTTP => <google_id>
  • Headers or Params used to pass in friend details (id(or)email)

The return on the request should be:

{ 
  "status": 201
}

GET find friends by status

GET api/v1/friends

Returns all friends for a user in the database with id of the friend, friend name and email address.

Accepts parameters for status eg: ?request_status=pending

  • Headers pass in user's google_id as user
    • Received in request as USER_HTTP => <google_id>

The endpoint for JSON contract should look like:

{ "data" : 
  [
  { 
    "id": 1 ,
  "type": "user",
  "attributes": { "name": "Melissa", 
                  "email": "[email protected]" }
  },
  { 
    "id": 2 ,
  "type": "user",
  "attributes": { "name": "Joseph",
                  "email": "[email protected]" }
  },
  { 
    "id": 3 ,
  "type": "user",
  "attributes": { "name": "Josephine",
                  "email": "[email protected]" }
  },
...
  ]
}

GET latest user post

GET api/v1/posts/last

Returns the last post made by user

-Headers pass in user's google_id as user

  • Received in request as USER_HTTP => <google_id>

The endpoint for JSON contract should look like:

{ "data" : 
    { 
      "id": 1 ,
    "type": "post",
    "attributes": {
        "emotion": "pensive"
        "post_status": "public"
        "description": "This was what I typed when I made this post." 
        "tone": "sad"
        "created_at": "2022-11-01 17:02:19.036593 -0600"   
      }
    }

POST create user post

POST api/v1/posts

Creates a new post for user in the database with emotion, tone, and description.

  • Headers pass in user's google_id as user
    • Received in request as USER_HTTP => <google_id>
  • Headers also used to pass in details about post (emotion and description)
    • Need to find tone prior to saving post to database

The return on the request should be:

{ "data" : 
    { 
      "id": 1 ,
    "type": "post",
    "attributes": {
        "emotion": "pensive"
        "post_status": "public"
        "description": "This was what I typed when I made this post." 
        "tone": "sad"
        "created_at": "2022-11-01 17:02:19.036593 -0600"   
      }
    }

or

{ 
     "message" : "Post successfully created"
}

return status code 201

PATCH update user post

POST api/v1/posts/:id

Updates an existing post for user in the database with emotion and description.

  • Headers pass in user's google_id as user

    • Received in request as USER_HTTP => <google_id>
  • Headers also used to pass in details about post (emotion, description)

The return on the request should be:

{ "data" : 
    { 
      "id": 1 ,
    "type": "post",
    "attributes": {
        "emotion": "pensive"
        "post_status": "public"
        "description": "This was what I typed when I made this post." 
        "tone": "sad"
        "created_at": "2022-11-01 17:02:19.036593 -0600"   
      }
    }

return status code 201

Build Emotions Model and Table

Set up Emotions:

  • Rspec

    • Model relationships
    • Model Validations
  • Emotions Model

    • Relationships
    • validations
  • Rails Emotions Migration

    • Word
    • Timestamps

PATCH update friend

PATCH api/v1/friends/:id

Updates request_status for an existing friendship in the database.

  • Headers used to pass in details about friendship (request_status)

The return on the request should be:

{
"status": 201
}

GET user post history

GET api/v1/users/history

Returns all friends for a user in the database with post_id, emotion term, post_status, description, and timestamp.

  • Headers pass in user's google_id as user
    • Received in request as USER_HTTP => <google_id>

The endpoint for JSON contract should look like:

{ "data" : 
  [
    { 
      "id": "1" ,
    "type": "post",
    "attributes": {
        "emotion": "pensive"
        "post_status": "public"
        "description": "This was what I typed when I made this post."  
        "tone": "sad"
        "created_at": "2022-11-01 17:02:19.036593 -0600"   
      }
    },
    { 
      "id": "2" ,
    "type": "post",
    "attributes": {
        "emotion": "pensive"
        "post_status": "public"
        "description": "This was what I typed when I made this post."  
        "tone": "sad"
        "created_at": "2022-11-01 17:02:19.036593 -0600"   
      }
    },
    { 
      "id": 3 ,
    "type": "post",
    "attributes": {
        "emotion": "pensive"
        "post_status": "public"
        "description": "This was what I typed when I made this post."  
        "tone": "sad"
        "created_at": "2022-11-01 17:02:19.036593 -0600"   
      } 
    },
...
  ]
}

GET all friends for a user

GET api/v1/friends

Returns all friends for a user in the database with id of the friend, friend name and email address.

  • Headers pass in user's google_id as user
    • Received in request as USER_HTTP => <google_id>

The endpoint for JSON contract should look like:

{ "data" : 
  [
  { 
    "id": 1 ,
  "type": "user",
  "attributes": { "name": "Melissa", 
                  "email": "[email protected]" }
  },
  { 
    "id": 2 ,
  "type": "user",
  "attributes": { "name": "Joseph",
                  "email": "[email protected]" }
  },
  { 
    "id": 3 ,
  "type": "user",
  "attributes": { "name": "Josephine",
                  "email": "[email protected]" }
  },
...
  ]
}

GET all public posts for a users friend

GET api/v1/friends/:friends_google_id/posts

Returns all friends for a user in the database with id of the post, emotion, post_status, description, tone, and timestamp.

  • Headers pass in user's google_id as user

    • Received in request as USER_HTTP => <google_id>
  • This is referring to a specific users friend

The endpoint for JSON contract should look like:

{ "data" : 
  [
    { 
      "id": "1 ",
    "type": "post",
    "attributes": {
      "emotion": "joyful"
      "post_status": "public"
      "description": "This was what I typed when I made this post."  
      "tone": "joyful"
      "created_at": "2022-11-01 17:02:19.036593 -0600"   
      }
    },
    { 
      "id": "2",
    "type": "post",
    "attributes": {
      "emotion": "pensive"
      "post_status": "public"
      "description": "This was what I typed when I made this post."  
      "tone": "sad"
      "created_at": "2022-11-01 17:02:19.036593 -0600"   
    }
  },
...
  ]
}

GET follower pending friends

GET api/v2/users/followers

Returns all friends who are following or want to follow a user, returns id of the friend, friend name, and email address, friends google_id.

Requires parameters for:

  • request_status eg: ?request_status=pending or ?request_status=accepted
  • user google_id eg:?user=<google_id>

The endpoint for JSON contract should look like:

{ "data" : 
  [
  { 
    "id": 1 ,
  "type": "user",
  "attributes": { "name": "Melissa", 
                  "email": "[email protected]", 
                  "google_id": "9999999" }
  },
  { 
    "id": 2 ,
  "type": "user",
  "attributes": { "name": "Joseph",
                  "email": "[email protected]", 
                  "google_id": "9999999" }
  },
  { 
    "id": 3 ,
  "type": "user",
  "attributes": { "name": "Josephine",
                  "email": "[email protected]",
                  "google_id": "9999999" }
  },
...
  ]
}

Search to GET a user

GET api/v1/users

Searches for a specific user in the database with using google_id of the user.

  • Returns name, google_id, and email address.

Accepts parameters for status eg: ?search=<google_id>

The endpoint for JSON contract should look like:

If user doesn't exist

{ "data" : 
  { }
}

If user exists, return

{ "data" : 
  { 
    "id": 36 ,
  "type": "user",
  "attributes": {
    "name": "Jacob Methusula"  
    "email": "[email protected]"   
    "google_id": "fhsajbd912671284bf001028472jf"   
    }
  }
}

Refactor_User_Queries

Refactor user queries so that we aren't hitting multiple endpoints to get the same information.
Rather we are calling one time and getting all information and then only using the information we need.

Update all create methods

Update all the create methods to return the data hash of the newly created item per how FE is expecting the response on create to look.

eg: POST api/v1(v2)/friends
response is currently:
{ message: 'Friend successfully created' }
update to:

"data": [{
        "id": 113,
        "friendship_id": 5,
        "type": "friend_followee",
        "attributes": {
          "name": "Fofandalf",
          "email": "[email protected]",
          "google_id": "midtierearth"
        }
      }]

Build Friends Model and Table

Set up User:

  • Rspec

    • Model relationships
    • Model Validations
  • User Model

    • Relationships
    • validations
  • Rails User Migration

    • Follower
    • Followee
    • Status
    • Timestamps

GET all emotions

GET api/v1/post_emotions

Returns all emotions in the database with id, term, and definition.

The endpoint for JSON contract should look like:

{"data":   [
   {
    "id": "1",
    "type": "emotion",
    "attributes": { 
                    "emotion": "contemplative",
                    "definition": "expressing or involving prolonged thought"
                    }
  },
  {
    "id": "2",
    "type": "emotion",
    "attributes": { 
                    "emotion": "forlorn",
                    "definition": "pitifully sad and abandoned or lonely"
                    }
  }  
] }

Build Post Model and Table

Set up Post:

  • Rspec

    • Model relationships
    • Model Validations
  • Post Model

    • Relationships
    • validations
  • Rails Post Migration

    • Emotion_id
    • Description
    • Tone
    • Post_status
    • User_id
    • Timestamps

Build User Model and DB table

Set up User:

  • Rspec

    • Model relationships
    • Model Validations
  • User Model

    • Relationships
    • validations
  • Rails User Migration

    • Name
    • Email
    • Phone Number
    • Timestamps

POST create a user

POST api/v1/users

Creates a new user in the database with google_id, name, and email address.

  • Headers used to pass in details about user (name, email, google_id)

The return on the request should be:

{ 
  "status": 201
}

DELETE user post

DELETE api/v1/posts/:id

Deletes an existing post for user in the database with emotion and description.

The return on the request should be:

{ 
  	"message": "Post successfully deleted"
}

return status code 204

README Update with Versioning

Include versioning description in the Readme.
Include a link in the readme to ruby version installation and rails version installation for user friendiness.

GET find user by email

GET api/v1/users

This endpoint would allow a user to find a friend by searching for them by name and email at the same time

Returns the user in the database that matches the email address found by search.

Accepts email param to search for user: (eg: ?email=#{email})

The endpoint for JSON contract should look like:

If No user found by email:

{ “data” : 
	{ }
}

If a User is found by email:

{ “data” : 
	{ 
		“id”: “36”,
	“type": "user",
	"attributes": {
		"name": "Jacob Methusula"	 
		}
	}
}

API key uuid generation and use instead of google id

When a new user is created, they are assigned a new secure uuid that is stored in the db INSTEAD of the good_id. The response from the user creation is the api key. Similarly, when a user logs in and a user look up on the BE user db is needed, the response includes this API key.

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.