You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: S3 bucket has been disabled due to rapidly reached AWS free tier limit. There may be issues with seeds photos loading/production level image upload. If so, I can look into a more sustainable fix. - Henry
The database was configured and created using postgres and was deployed through Heroku.
Environment Variables
AUTH0_CLIENT_ID - gem installed that configures the token audience
AUTH0_DOMAIN - Our particular company's account with auth0
JWT_SECRET - json webtoken secret for authorization
PASSWORD - postgress password for local db
ACCESS_KEY_ID - access key for s3
SECRET_ACCESS_KEY - secret for s3
BUCKET - s3 storage
STRIPE_PUBLISHABLE_KEY - our stripe account key
STRIPE_SECRET_KEY - stripe secret for rails configuration
SENDGRID_API_KEY - connects to email server when order is confirmed
To Run Tests....
Rspec was used for testing.
The command to run all of the tests at once is -> rspec
The command for running a testing file is -> rspec pathtofile
Finds a user by their email. If the user doesn't exist, it creates one. If a user does exist it checks to see if the user is a customer or a business and then logs them in accordingly.
CHARGES
create -->
Handles transaction creation between customers and businesses utilizing a custom stripe_charge_service that essentially retrieves a businesses' stripe information (or creates it if it doesn't yet exist),retrieves a customer's stripe information (or creates it if it doesn't exist) and then creates a linked charge/transaction between the two parties.
SEARCH
search -->
Find businesses by theme or items
Users
index -->
Finds all user's in the database.
show -->
Finds a user by ID.
update -->
Edit an existing user's information by their ID.
destroy -->
Delete an existing user from the database by their ID.
Customers
index -->
Finds a user's customer if a user_id is present in the params. Else it finds all users in the database
show -->
Finds a customer by ID.
create -->
Adds a new customer to the database. Requires a user_id.
update -->
Edit an existing customer information by their ID.
destroy -->
Delete a customer from the database by their ID.
Reviews
index -->
If a customer_id is found in the parameters, it returns all of the customer's reviews.
If a business_id is found in the parameters, it returns all of the reviews on a business.
show -->
Returns a review associated with an ID.
create -->
Allows a customer to post a review to a business. It also ensures that they can only post one review
per business.
update -->
Allows reviews to be updated by ID.
destroy -->
Allows a review to be deleted
Carts
index -->
If a valid customer_id is in the params it returns that customer's active cart, else it returns all of the carts in the db.
create -->
Returns the customer's active cart, or creates a new active cart if they do not have one.
show -->
Returns a cart based on the provided ID.
add -->
Adds an item to a cart.
itemfetch -->
Returns all of the items within a customer's cart.
destroy -->
Delete an existing cart from the database by its ID.
Orders
index -->
If a customer's ID is present in the params, it returns all of that customer's orders.
If a businesses' ID is present in the params, it returns all of that businesses' orders.
If no Id is present, it returns all orders in the database.
show -->
Returns a business by it's ID.
create -->
Transforms a customer's cart into an order. It takes all of the items within a customer's cart and creates
new order_items for the order as well.
update -->
Update an order's status with its ID.
destroy -->
Deletes an order from the database.
ship -->
Checks to see if an order meets the criteria required to be shipped off. If so, it is shipped.
OrderItems
index -->
If an order_id is present in the params, it returns all of that order's items. Else it returns all of the order_items in the database.
show -->
Finds an order_item by it's ID.
create -->
Creates/adds an order_item to an order. Requires order_id.
update -->
Edit an existing order_item by its ID.
destroy -->
Deletes an order_item from the database by ID.
Businesses
index -->
Finds a user's business if a user_id is present in the params, else it returns all businesses in the database.
show -->
Finds a business by its ID.
create -->
Creates a business for a user. The user_id is required for creation.
update -->
Edit an existing business by its ID.
destroy -->
Delete an existing business by its ID.
ratings -->
Finds a businesses average rating based off of all reviews for that business.
Schedules
index -->
Finds a businesses' schedule.
show -->
Finds a business by its ID.
create -->
Create/add a schedule to a business. Business_id is required.
update -->
Edit an existing schedule by it's ID.
destroy -->
Delete an existing schedule by it's ID.
Menus
index -->
Finds a businesses' menu.
show -->
Finds a menu by its ID.
create -->
Create/add a menu for a business. Business_id is required.
update -->
Edit an existing menu by it's ID.
destroy -->
Delete an existing menu by it's ID.
Items
index -->
Finds all items associated with a menu.
show -->
Finds an item by it's ID.
create -->
Creates/adds an item to a menu. Requires order_id.
update -->
Edit an existing item by its ID.
destroy -->
Deletes an item from the database by ID.
Services
OrderProcessor
The order_processor takes in an order and initializes with that order and the items belonging to that order.
It has a private method that check an order_item against the item in the database to make sure that there is sufficient inventory. It returns a true or false boolean value.
It also has a "ship" method which uses the private "items_available?" method to insure that the order can be shipped. It then reduces the inventory of each item in the database and ships the order provided that it is a pending order with items.
ImageUploader
The image_uploader is/can be initialized with any model instance that can have an attached image and with the params for it.
It has two private methods. One (file?) which checks to see if there is already an attached image. And another (delete_image), which can remove an attached image.
It also has a "call" method which checks to see if an image is being sent through the params and if there is already an attached image. If so it removes the old attached image and updates it with the new one. If there isn't an attached image, it just adds one, if provided.
Serializers
All serializers attach image files to the json blob to be consumed by the frontend.
StripeChargesService
See Charges action for generalized description of this service.
Private Methods:
find_business --> Finds a businesses stripe information or creates it if it doesn't exist.
retrieve_business --> Retrieves a businesses stripe account using their stripe_token.
create_business --> Creates a businesses stripe account and adds the stripe_token to the database.
Sends terms of service agreement to stripe.
find_customer --> Finds a customer's stripe information or creates it if it does not exist.
retrieve_customer --> Retrieves a customer's stripe account using their stripe_token.
create_customer --> Creates a customer's stripe account and adds the stripe_token to the database.
create_charge --> Creates a charge to the customer's account.
Public Methods:
call --> Uses the private method "create_charge" on a customer.
buscall --> Uses the private method "find_business".
Front-End Documentation
Refer to Front-End Docs to view
our Front-End information