Skip to content

Level-turing-team/level_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Level

Table of Contents
  1. About The Project
  2. Getting Started
  3. ReST Endpoints

About The Project

This repository serves as a proxy between the Level Front End repo and the Level Zipcode Microservice which uses the ZipcodeBase API. While solely handling API requests and responses to serve profile data back into the front end, using Amazon's S3 Cloud Storage platform to upload and present pictures

Schema

Built With

Getting Started

  1. Clone this repo
  2. Install gem packages: bundle install
  3. Register for a google OAuth Client
  4. Create and Migrate DB
$rails db:{create,migrate}
  1. Install needed Figaro config
$bundle exec figaro install
  1. Add environemnt variables to config/application.yml

Sample config


CLIENT_ID: 'your google oauth client id'
CLIENT_SECRET: 'your google oauth client secret'
development:
  API_URL: 'http://localhost:3001'
production:
  API_URL: "your microservice heroku link"
test:
  API_URL: 'http://localhost:3001'
  1. Start your server!

Must have backend application running on port 3001

$ rails s

Prerequisites

  • Ruby 2.5.3
  • Rails 5.2.5
  • Deployed microservice and backend repo
ReST Endpoints

POST Profile

  • Create a profile

Required Parameters: :user_id :zipcode

POST   /api/v1/profiles
Sample Response
{
  'data': 'profile created successfully'
}

GET Profiles Circles

  • Returns the circle of a given profile

Required Parameters: :user_id

GET    /api/v1/profiles/:id/circle
Sample Response
{
  "data": [
      {
          "id": "2",
          "type": "profile",
          "attributes": {
              "zipcode": "80305",
              "user_id": 2,
              "profile_picture": "http://www.google.com",
              "username": "korn"
          }
      },
      {
          "id": "3",
          "type": "profile",
          "attributes": {
              "zipcode": "80304",
              "user_id": 3,
              "profile_picture": "http://www.google.com",
              "username": "slipknot"
          }
      },
      {
          "id": "4",
          "type": "profile",
          "attributes": {
              "zipcode": "80303",
              "user_id": 4,
              "profile_picture": "http://www.google.com",
              "username": "photos by jim"
          }
      },
      {
          "id": "5",
          "type": "profile",
          "attributes": {
              "zipcode": "80544",
              "user_id": 5,
              "profile_picture": "http://www.google.com",
              "username": "arteest"
          }
      }
  ]
}

POST Create Profile Post

  • Creates a post for the given profile

Required Parameters: :user_id :content Optional Parameters: :link

POST   /api/v1/profiles/:id/post
Sample Response
{
  'data': 'post created successfully'
}

GET Profile's Circle Recent Posts

  • Returns the recent posts of a given profile's circle

Required Parameters: :user_id

GET    /api/v1/profiles/:id/circle/posts

Sample Response
{
  "data": [
      {
          "id": "4",
          "type": "post",
          "attributes": {
              "content": "hey did you see that headline?",
              "link": "photoURL.com",
              "user_id": 2,
              "created_at": "2021-04-21T20:35:56.040Z"
          }
      },
      {
          "id": "5",
          "type": "post",
          "attributes": {
              "content": "hey checkout my create shoes?",
              "link": "photoURL.com",
              "user_id": 2,
              "created_at": "2021-04-21T20:35:56.043Z"
          }
      },
      {
          "id": "6",
          "type": "post",
          "attributes": {
              "content": "hey did you see software update?",
              "link": "photoURL.com",
              "user_id": 3,
              "created_at": "2021-04-21T20:35:56.047Z"
          }
      },
      {
          "id": "7",
          "type": "post",
          "attributes": {
              "content": "hey did you see I called you?",
              "link": null,
              "user_id": 3,
              "created_at": "2021-04-21T20:35:56.050Z"
          }
      },
      {
          "id": "8",
          "type": "post",
          "attributes": {
              "content": "hey did you see that we're not friends on FB anymore?",
              "link": "photoURL.com",
              "user_id": 4,
              "created_at": "2021-04-21T20:35:56.053Z"
          }
      },
      {
          "id": "9",
          "type": "post",
          "attributes": {
              "content": "hey did you see hear about that create app called 'level'?",
              "link": "photoURL.com",
              "user_id": 4,
              "created_at": "2021-04-21T20:35:56.057Z"
          }
      },
      {
          "id": "10",
          "type": "post",
          "attributes": {
              "content": "hey i just got hired at a sick new comapny",
              "link": null,
              "user_id": 5,
              "created_at": "2021-04-21T20:35:56.060Z"
          }
      }
  ]
}

GET Profile

  • Returns a given profile

Required Parameters: :user_id

GET    /api/v1/profiles/:id 

Sample Response
{
    "data": {
        "id": "1",
        "type": "profile",
        "attributes": {
            "zipcode": "80301",
            "user_id": 1,
            "profile_picture": "http://www.google.com",
            "username": "the painter man"
        }
    }
}

GET Profile's Posts

  • Returns posts for a given profile

Required Parameters: :user_id

GET    /api/v1/profiles/:id/post

Sample Response
{
  "data": [
      {
          "id": "1",
          "type": "post",
          "attributes": {
              "content": "hey did you see new movie trailer?",
              "link": "photoURL.com",
              "user_id": 1,
              "created_at": "2021-04-21T20:35:56.029Z"
          }
      },
      {
          "id": "2",
          "type": "post",
          "attributes": {
              "content": "hey did you see that create meme?",
              "link": "photoURL.com",
              "user_id": 1,
              "created_at": "2021-04-21T20:35:56.032Z"
          }
      },
      {
          "id": "3",
          "type": "post",
          "attributes": {
              "content": "hey did you see that new phone?",
              "link": null,
              "user_id": 1,
              "created_at": "2021-04-21T20:35:56.036Z"
          }
      }
  ]
}

GET Profile's Galleries

  • Returns the galleries of a given profile

Required Parameters: :user_id

GET  /api/v1/profiles/:id/galleries

Sample Response
{
  "data": [
      {
          "id": "1",
          "type": "gallery",
          "attributes": {
              "user_id": 1,
              "name": "photos from cali",
              "created_at": "2021-04-21T20:35:56.071Z",
              "updated_at": "2021-04-21T20:35:56.071Z",
              "photo_url": "http://www.google.com"
          }
      },
      {
          "id": "9",
          "type": "gallery",
          "attributes": {
              "user_id": 1,
              "name": "PROFILE",
              "created_at": "2021-04-21T20:35:56.100Z",
              "updated_at": "2021-04-21T20:35:56.100Z",
              "photo_url": "http://www.example.com"
          }
      }
  ]
}

GET Distance

  • Returns the distance between two users Granted those two users have valid zip copdes

Required Parameters: :current_user :user

GET /api/v1/distance
Sample Response
{
    "data": 5.19
}

POST Profile Circle

  • Creates a circle record for given profile

Required Parameters: :user_id :following_id

POST   /api/v1/profiles/:id/circle
Sample Response
 {
  'data': 'circle created successfully'
 }

POST Profile Gallery

  • Creates a gallery for a given profile

Required Parameters: :user_id :following_id

POST   /api/v1/profiles/:id/circle
Sample Response
 {
  'data': 'circle created successfully'
 }

POST Profile Gallery Photo

  • Creates a photo in the profiles given gallery

Required Parameters: :user_id :gallery_id :description

Endpoint Options

  • Postman
  • Attach a body and select _binary_
  • Front-End
  • Click the _Choose File_ button when uploading a photo to a gallery
POST   /api/v1/profiles/:id/galleries/:gallery_id/photos
Sample Response
{
  'data': 'photo created successfully'
}

GET Profile Gallery Photos

  • Returns a given profile's gallery photos

Required Parameters: :id :gallery_id

GET    /api/v1/profiles/:id/galleries/:gallery_id/photos
Sample Response
  {
    "data": [
        {
            "id": "1",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.114Z",
                "updated_at": "2021-04-21T20:35:56.114Z",
                "gallery_id": 1
            }
        },
        {
            "id": "2",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.119Z",
                "updated_at": "2021-04-21T20:35:56.119Z",
                "gallery_id": 1
            }
        },
        {
            "id": "3",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.124Z",
                "updated_at": "2021-04-21T20:35:56.124Z",
                "gallery_id": 1
            }
        }
    ]
}
  

DELETE Destroy Profile Gallery

  • Deletes the given gallery

Required Parameters: :gallery_id

POST   /api/v1/profiles/:id/galleries/:gallery_id/photos
Sample Response
  {
    'data': 'gallery deleted successfully'
  }

GET Profile Discover

  • Returns profile's in a set radius

Required Parameters: :id

GET    /api/v1/profiles/:id/discover
Sample Response
  {
    UPDATE WITH SAMPLE RESPONSE
  }

GET Discover Photos

  • Returns recent photos posted
GET    /api/v1/photos
Sample Response
 {
    "data": [
        {
            "id": "23",
            "type": "photo",
            "attributes": {
                "description": "feature photo",
                "url": "http:www.example.com",
                "created_at": "2021-04-21T20:35:56.221Z",
                "updated_at": "2021-04-21T20:35:56.221Z",
                "gallery_id": 9
            }
        },
        {
            "id": "22",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.217Z",
                "updated_at": "2021-04-21T20:35:56.217Z",
                "gallery_id": 8
            }
        },
        {
            "id": "21",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.211Z",
                "updated_at": "2021-04-21T20:35:56.211Z",
                "gallery_id": 8
            }
        },
        {
            "id": "20",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.206Z",
                "updated_at": "2021-04-21T20:35:56.206Z",
                "gallery_id": 8
            }
        },
        {
            "id": "19",
            "type": "photo",
            "attributes": {
                "description": "pic 1",
                "url": "http:www.google.com",
                "created_at": "2021-04-21T20:35:56.201Z",
                "updated_at": "2021-04-21T20:35:56.201Z",
                "gallery_id": 8
            }
        }

    ]
}

GET Profile Search

  • Returns profile based off of search type and search term

Required Parameters: :id and :search_type = :search_term

GET    /api/v1/profiles/:id/search?search_type=search_term
Sample Response
  {
    {
    "data": [
        {
            "id": "3",
            "type": "profile",
            "attributes": {
                "zipcode": "80304",
                "user_id": 3,
                "profile_picture": "http://www.google.com",
                "username": "slipknot"
            }
        },
        {
            "id": "4",
            "type": "profile",
            "attributes": {
                "zipcode": "80303",
                "user_id": 4,
                "profile_picture": "http://www.google.com",
                "username": "photos by jim"
            }
        },
        {
            "id": "6",
            "type": "profile",
            "attributes": {
                "zipcode": "80228",
                "user_id": 6,
                "profile_picture": "http://www.google.com",
                "username": "former salesman"
            }
        }
    ]
}
  }

GET Profile Tags

  • Returns the tags available for a given profile

Required Parameters: :user_id

GET    /api/v1/profile/:id/tags
Sample Response
{
    "data": [
        {
            "id": "1",
            "type": "tag",
            "attributes": {
                "name": "Painter"
            }
        },
        {
            "id": "3",
            "type": "tag",
            "attributes": {
                "name": "Sculpter"
            }
        }
    ]
}

POST Tags Create

  • Creates a tag

Required Parameters: :name

POST   /api/v1/tags
Sample Response
{
    'data': 'tags successfully created' 
}

POST Profile Tags

  • Creates a tag

Required Parameters: :user_id :tag_id

POST   /api/v1/profile/:id/tags
Sample Response
{
    'data': 'tags successfully created' 
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8

Languages