tarique313 / campaign-rails-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prerequisites

The setups steps expect following tools installed on the system.

The app can be run in both local and via Docker.

  1. Run in Local

  2. Run from Dockerfile

1. Run in Local

1.1 Check out the repository
git clone git@github.com:organization/project-name.git
1.2 Change .env file

You can find a .env file in the project's root directory. Create a .env file if the file is not present. Enter your Postgresql database username and password.

DB_USERNAME:<your_postgresql_username>

DB_USER_PASSWORD=<your_postgresql_password>
1.3 Install Gems

Run bundle install to install gem files. If you encounter Ruby version mismatch error, change the the ruby version with the Ruby version installed in your machine. To do that, you will find Ruby version mentioned in Gemfile and .ruby-version files. Both files can be found in project's root directory.

1.4 Create and Seed the Database

Run the following commands to create development and test databases. The second command is for migration and the third command is for generating seed data.

rails db:create

rails db:migrate

rails db:seed
1.5. Start the Rails server

You can start the rails server using the command given below.

rails s

And now you can visit the site with the URL http://localhost:3000

2. Run from Dockerfile

2.1. Docker

Make sure you have Docker installed and running in your machine.

2.2 Docker Commands
docker-compose -f docker-compose.yml build
docker-compose -f docker-compose.yml run web rails db:create db:migrate
docker-compose -f docker-compose.yml up -d

Test the API

Run the following command to run RSpec tests.

rspec

Campaign API

1. Create a Campaign
POST /api/v1/campaigns

Screenshot 2022-05-23 165407

2. Getting the List of Campaigns
GET /api/v1/campaigns

Get all Campaigns

3. Getting a Single Campaign
GET /api/v1/campaigns/1

get a campaign

4. Update a Campaigns
PUT /api/v1/campaigns/1

Update a Campaign

Investment API

1. Create a Investment
POST /api/v1/campaigns/1/investments/

Create a investment

2. Getting the List of Investments of a Campaign
GET /api/v1/campaigns/1/investments/

all investments

About


Languages

Language:Ruby 96.2%Language:Dockerfile 2.8%Language:HTML 0.6%Language:Shell 0.4%