This is a Rails API application, completed as an 8-hour-maximum takehome assessment for the Turing School of Software and Design's Module 4, and requirements for the assessment can be found here: Take-Home Back End Prompt
To begin, clone this repository to your local machine, and run:
$ bundle
to update and install gems/dependencies.
To create and seed a database with random customers, subscriptions, and joins between them, run:
$ rails db:create
$ rails db:migrate
$ rails db:seed
To create a new customer, send a JSON POST
request to http://localhost:3000/api/v1/customers/
in the format:
{
"first_name": "Jimmy",
"last_name": "Snakes",
"email": "jimmy_snakes@email.net",
"street_address": "123 Python St",
"city": "Reno",
"state_ab": "NV"
}
To subscribe an existing customer to an existing subscription, send a JSON POST
request to http://localhost:3000/api/v1/customer_subscriptions/
in the format:
{
"customer_id": 1,
"subscription_id": 1,
"status": 1
}
To toggle a user's subscription status between active and inactive, send a JSON PATCH
request to http://localhost:3000/api/v1/customer_subscriptions/status
in the format:
{
"customer_id": 1,
"subscription_id": 2
}
If the subscription status is active ("1"), it will switch to inactive ("0"). If the subscription status is inactive, it will switch to active.
To view all subscriptions for a customer, send a GET
request in the format http://localhost:3000/api/v1/customer_subscriptions/:user_id
.