Viewing Party API is an API-only Rails application that allows users to create and manage viewing parties for movies. It integrates with a third-party movie service to fetch movie details and supports features like user authentication and invitee management.
- User Authentication: Secure login and API key generation using
bcrypt
. - Movie Integration: Search and fetch movie details using the Movie Service.
- Viewing Party Management: Create and manage viewing parties with runtime checks and invitees.
- RESTful API Endpoints: Structured routes for users, sessions, movies, and viewing parties.
- Ruby 3.2.2
- Rails 7.1.3
- PostgreSQL
- Clone the repository:
git clone [email protected]:MDelarosa1993/viewing-party-api-Mod3.git cd viewing_party_api
- Install dependencies:
bundle install
- Set up the database:
rails db:create db:migrate
- Start the Rails server:
rails server
id
: Primary keyname
: Stringusername
: String (unique)password_digest
: Stringapi_key
: String (unique)- Timestamps:
created_at
,updated_at
id
: Primary keyname
: String (unique)start_time
: Datetimeend_time
: Datetimemovie_id
: Integermovie_title
: Stringhost_id
: Foreign key (User)- Timestamps:
created_at
,updated_at
id
: Primary keyviewing_party_id
: Foreign key (Viewing Party)user_id
: Foreign key (User)- Timestamps:
created_at
,updated_at
POST /api/v1/users
: Create a new user.GET /api/v1/users
: Retrieve a list of all users.
POST /api/v1/sessions
: Login and retrieve API key.
GET /api/v1/movies
: Fetch top-rated movies or search by query.GET /api/v1/movies/:id
: Retrieve details of a specific movie.
POST /api/v1/viewing_parties
: Create a new viewing party.GET /api/v1/viewing_parties
: Retrieve all viewing parties.PATCH /api/v1/viewing_parties/:id
: Update viewing party invitees.
bcrypt
: Secure password handling.faraday
: HTTP client for external API requests.jsonapi-serializer
: JSON serialization for API responses.rspec-rails
: Testing framework.shoulda-matchers
: Testing matchers for Rails models and controllers.webmock
andvcr
: Mock and record HTTP requests during testing.
Run the test suite using:
bundle exec rspec
- Code coverage is handled by
simplecov
. - External API requests are mocked using
webmock
andvcr
.
POST /api/v1/viewing_parties
Content-Type: application/json
Authorization: Bearer <api_key>
{
"name": "Avengers Party",
"start_time": "2025-01-10T18:00:00Z",
"end_time": "2025-01-10T21:00:00Z",
"movie_id": 12345,
"movie_title": "Avengers: Endgame",
"invitees": [2, 3]
}
{
"data": {
"id": "1",
"type": "viewing_party",
"attributes": {
"name": "Avengers Party",
"start_time": "2025-01-10T18:00:00Z",
"end_time": "2025-01-10T21:00:00Z",
"movie_id": 12345,
"movie_title": "Avengers: Endgame",
"host_id": 1
}
}
}
- Add user authentication for endpoints using JWT.
- Implement email notifications for invitees.
- Add pagination for large datasets.