README

Intro

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

Database

DB

Setup

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

API Endpoints

Create a New Customer

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"
}

create_customer

Subscribe Customer

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
}

create_customer_subscription

Toggle Subscription Status

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
}

cancelled activated

If the subscription status is active ("1"), it will switch to inactive ("0"). If the subscription status is inactive, it will switch to active.

Get All Subscriptions for a Customer

To view all subscriptions for a customer, send a GET request in the format http://localhost:3000/api/v1/customer_subscriptions/:user_id.

customer_subscriptions