Skip to content

On-y-va/onyva_be_graphql

 
 

Repository files navigation

onyva logo

Onyva Backend Service

This application consumes external APIs to fetch information about any travel destination, whether it's a bustling city, a serene countryside, or a quaint village. With this data, we create personalized trip plans that cater to our users' unique interests and preferences. Onyva backend provides seamless integration with our frontend application, allowing users to effortlessly organize their trips with ease. By consuming our API, the frontend communicates with our application and unlocks a wealth of local recommendations for restaurants, attractions, and hidden gems.

About Onyva

Onyva is an innovative travel application that aims to simplify the process of planning a trip and enhance the overall travel experience for users. With Onyva, users can easily create personalized itineraries for their trips, complete with local recommendations for restaurants and tourist attractions. Users can also invite their friends to join them on their trips and manage their trip details together.

Users can also invite their friends to join them on their trips and easily share their flight information for added convenience. One of the key features of Onyva is its advanced flight tracking technology, which allows users to keep track of their friends' flight status in real-time, ensuring a safer and more stress-free travel experience.

At its core, Onyva is committed to providing an exceptional travel experience for users, and we believe that our application can be a valuable tool for anyone looking to plan their next adventure.

RESTful Endpoints

Get a User

GET /api/v1/users/:id
Details

Parameters:

No Parameters
Code Description
200 OK

Example Value:

{
    "data": {
        "id": "1",
        "type": "user",
        "attributes": {
            "first_name": "Kaylah",
            "last_name": "Rose",
            "phone_number": null,
            "email": "[email protected]",
            "emergency_contact_name": null,
            "emergency_contact_phone_number": null,
            "google_uid": "12345678901234567890"
        }
    }
}

Search for user

GET /api/v1/users/find
Details

Parameters:

GOOGLE_UID=12345678901234567890
Code Description
200 OK

Example Value:

{
    "data": {
        "id": "1",
        "type": "user",
        "attributes": {
            "first_name": "Kaylah",
            "last_name": "Rose",
            "phone_number": null,
            "email": "[email protected]",
            "emergency_contact_name": null,
            "emergency_contact_phone_number": null,
            "google_uid": "12345678901234567890"
        }
    }
}

Create a User

POST /api/v1/users
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
201 Created

Example Value:

{
    "data": {
        "id": "3",
        "type": "user",
        "attributes": {
            "first name": "Harry",
            "last_name": "Potter",
            "phone_number": "123456789",
            "email": "[email protected]",
            "emergency_contact_name": null,
            "emergency_contact_phone_number": null
        }
    }
}

Edit a User

PATCH /api/v1/users/:id
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
200 OK

Example Value:

{
    "data": {
        "id": "1",
        "type": "user",
        "attributes": {
            "first name": "bob",
            "Last_name": "Jef",
            "phone_number": "123456789",
            "email": "[email protected]",
            "emergency_contact_name": null,
            "emergency_contact_phone_number": null
        }
    }
}

Get a Trip

GET /api/v1/trips/:id
Details

Parameters:

No Parameters
Code Description
200 OK

Example Value:

{
    "data": {
        "id": "1",
        "type": "trip",
        "attributes": {
            "name": "Girl's Trip",
            "city": "Denver",
            "country": "United States",
            "postcode": "80020",
            "place_id": "21fqirl123b1278",
            "start_date": "2023-03-14",
            "end_date": "2023-03-17",
            "image_url": "https://live.staticflickr.com/65535/52190921778_23ed1cc279_w.jpg",
            "events": [
                {
                    "id": 236,
                    "trip_id": 21,
                    "event_date": null,
                    "event_time": null,
                    "event_id": "515dc823b891e357c059ae4731ce3ad34040f00102f901af846c1000000000920315546865204465706f74204261722026204772696c6c",
                    "votes": null,
                    "confirmed": false,
                    "created_at": "2023-03-03T04:24:25.625Z",
                    "updated_at": "2023-03-03T04:24:25.625Z",
                    "name": "The Depot Bar & Grill",
                    "address": "East Hearne Avenue, Paris, TX 75460, United States of America",
                    "category": "restaurant"
                },
                {...},
                {...},
                {...},
                {etc},
            ]
        },
        "relationships": {
            "events": {
                "data": [
                    {
                        "id": "236",
                        "type": "event"
                    },
                    {...},
                    {etc},
                ]
            }
        }
    },
    "included": [
        {
            "id": "236",
            "type": "event",
            "attributes": {
                "id": 236,
                "trip_id": 21,
                "event_date": null,
                "event_time": null,
                "event_id": "515dc823b891e357c059ae4731ce3ad34040f00102f901af846c1000000000920315546865204465706f74204261722026204772696c6c",
                "votes": null,
                "confirmed": false,
                "name": "The Depot Bar & Grill",
                "address": "East Hearne Avenue, Paris, TX 75460, United States of America",
                "category": "restaurant"
            },
            "relationships": {
                "trip": {
                    "data": {
                        "id": "21",
                        "type": "trip"
                    }
                }
            }
        },
        {etc},
    ]
}

Create a Trip

POST /api/v1/trips
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
201 CREATED

Example Value:

{
    "data": {
        "id": "1",
        "type": "trip",
        "attributes": {
            "name": "Girl's Trip",
            "city": "Denver",
            "country": "United States",
            "postcode": "80020",
            "place_id": "21fqirl123b1278",
            "start_date": "2023-03-14",
            "end_date": "2023-03-17",
            "image_url": "https://live.staticflickr.com/65535/52190921778_23ed1cc279_w.jpg",
            "events": [
                {
                    "id": 236,
                    "trip_id": 21,
                    "event_date": null,
                    "event_time": null,
                    "event_id": "515dc823b891e357c059ae4731ce3ad34040f00102f901af846c1000000000920315546865204465706f74204261722026204772696c6c",
                    "votes": null,
                    "confirmed": false,
                    "created_at": "2023-03-03T04:24:25.625Z",
                    "updated_at": "2023-03-03T04:24:25.625Z",
                    "name": "The Depot Bar & Grill",
                    "address": "East Hearne Avenue, Paris, TX 75460, United States of America",
                    "category": "restaurant"
                },
                {...},
                {...},
                {...},
                {etc},
            ]
        },
        "relationships": {
            "events": {
                "data": [
                    {
                        "id": "236",
                        "type": "event"
                    },
                    {...},
                    {etc},
                ]
            }
        }
    },
    "included": [
        {
            "id": "236",
            "type": "event",
            "attributes": {
                "id": 236,
                "trip_id": 21,
                "event_date": null,
                "event_time": null,
                "event_id": "515dc823b891e357c059ae4731ce3ad34040f00102f901af846c1000000000920315546865204465706f74204261722026204772696c6c",
                "votes": null,
                "confirmed": false,
                "name": "The Depot Bar & Grill",
                "address": "East Hearne Avenue, Paris, TX 75460, United States of America",
                "category": "restaurant"
            },
            "relationships": {
                "trip": {
                    "data": {
                        "id": "21",
                        "type": "trip"
                    }
                }
            }
        },
        {etc},
    ]
}

Edit a Trip

PATCH /api/v1/trips
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
200 OK

Example Value:

{
    "data": {
        "id": "1",
        "type": "trip",
        "attributes": {
            "name": "Girl's Trip",
            "city": "Denver",
            "country": "United States",
            "postcode": "80020",
            "place_id": "21fqirl123b1278",
            "start_date": "2023-03-14",
            "end_date": "2023-03-17",
            "image_url": "https://live.staticflickr.com/65535/52190921778_23ed1cc279_w.jpg",
            "events": [
                {
                    "id": 236,
                    "trip_id": 21,
                    "event_date": null,
                    "event_time": null,
                    "event_id": "515dc823b891e357c059ae4731ce3ad34040f00102f901af846c1000000000920315546865204465706f74204261722026204772696c6c",
                    "votes": null,
                    "confirmed": false,
                    "created_at": "2023-03-03T04:24:25.625Z",
                    "updated_at": "2023-03-03T04:24:25.625Z",
                    "name": "The Depot Bar & Grill",
                    "address": "East Hearne Avenue, Paris, TX 75460, United States of America",
                    "category": "restaurant"
                },
                {...},
                {...},
                {...},
                {etc},
            ]
        },
        "relationships": {
            "events": {
                "data": [
                    {
                        "id": "236",
                        "type": "event"
                    },
                    {...},
                    {etc},
                ]
            }
        }
    },
    "included": [
        {
            "id": "236",
            "type": "event",
            "attributes": {
                "id": 236,
                "trip_id": 21,
                "event_date": null,
                "event_time": null,
                "event_id": "515dc823b891e357c059ae4731ce3ad34040f00102f901af846c1000000000920315546865204465706f74204261722026204772696c6c",
                "votes": null,
                "confirmed": false,
                "name": "The Depot Bar & Grill",
                "address": "East Hearne Avenue, Paris, TX 75460, United States of America",
                "category": "restaurant"
            },
            "relationships": {
                "trip": {
                    "data": {
                        "id": "21",
                        "type": "trip"
                    }
                }
            }
        },
        {etc},
    ]
}

Delete a Trip

DELETE /api/v1/trip/:id
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
204 No Content

Example Value:

""

Get a User's Trips

GET /api/v1/users/:id/trips/find_all?status=status
Details

Parameters:

STATUS=status
Code Description
200 'OK'

Example Value:

{
    "data": [
        {
            "id": "9",
            "type": "trip",
            "attributes": {
                "name": "Trippin",
                    "city": "Cabo",
                    "country": "Mexico",
                    "postcode": "00123",
                    "place_id": "518120e5cc1b8441c0594f07b29e5a9120c0f00101f90188a2040000000000c00208",
                    "start_date": "2023-02-28",
                    "end_date": "2023-03-09",
                    "image_url": "https://live.staticflickr.com/65535/5716766064_64559491a3_w.jpg",
                    "events": [
                        {
                            "id": 121,
                            "trip_id": 9,
                            "event_date": null,
                            "event_time": null,
                            "event_id": "51d30736b1098341c0596f03fc1c808e20c0f00102f90139476d250000000092030a41204368c3a163617261",
                            "votes": null,
                            "confirmed": false,
                            "created_at": "2023-03-01T02:55:00.282Z",
                            "updated_at": "2023-03-01T02:55:00.282Z",
                            "name": "A Chácara",
                            "address": "Rua Trapiche, Cabo de Santo Agostinho - PE, 54515-330, Brazil",
                            "category": "restaurant"
                        },
                        {etc}
                    ]
            "relationships": {etc}
            }
        }
    ] 
}

Create Trip Attendee (Trip Invitation)

POST /api/v1/trips/:id/users
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
204 No Content

Example Value:

""

Get Trip Attendees

GET /api/v1/trips/:id/users
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
200 'OK'

Example Value:

{
    "data": [
        {
            "id": "7",
            "type": "user",
            "attributes": {
                "first_name": "Kaylah",
                "last_name": "Rose",
                "phone_number": "123456789",
                "email": "[email protected]",
                "emergency_contact_name": null,
                "emergency_contact_phone_number": "720938547",
            }
        },
        {
            "id": "3",
            "type": "user",
            "attributes": {
                "first name": "Harry",
                "last_name": "Potter",
                "phone_number": "123456789",
                "email": "[email protected]",
                "emergency_contact_name": null,
                "emergency_contact_phone_number": null
            }
        }
    ]
}

Update Trip Attendee (Accept Trip Invitation)

PATCH /api/v1/users/:id/trips/:id
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
204 No Content

Example Value:

""

Delete Trip Attendee (Decline Trip Invitation)

DELETE /api/v1/users/:id/trips/:id
Details

Parameters:

CONTENT_TYPE=application/json
Code Description
204 No Content

Example Value:

""

Status Codes

Onyva returns the following status codes in its API:

Status Code Description
200 OK
201 CREATED
400 BAD REQUEST
404 NOT FOUND
500 INTERNAL SERVER ERROR

Prerequisites

Running this project requires:

  • Rails 5.2.8
  • Ruby 2.7.4
  • External APIs:
    • This application required external API keys which are stored in a .env file at the top level of the program directory

Installation

  1. Fork and clone this repository
  2. cd into the root directiory
  3. bundle install
  4. rails db:{drop,create,migrate,seed}
  5. Run the test suite with bundle exec rspec
  6. Start the local server by running rails s
  7. Visit the app on localhost:5000 in your web browser

Pull down the Front-end repo. Set up instructions are in that repository's README.

Database Schema

Screen Shot 2023-03-03 at 15 30 07

Contributors

All participants in this project are graduates from the Turing School of Software & Design.

Anhnhi Tran, PT, DPT
      GitHub: @anhtran811
      LinkedIn: anhtran8

Kaylah Rose Mitchell
      GitHub: @kaylahrose
      LinkedIn: kaylahrose

Matisse Mallette
      GitHub: @MatisseMallette
      LinkedIn: matisse-mallette

Braxton Eddings
      GitHub: @beddings81
      LinkedIn: braxton-eddings

Alastair Lloyd
      GitHub: @Adrlloyd
      LinkedIn: adrlloyd

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 99.8%
  • HTML 0.2%