Coder Social home page Coder Social logo

fetch-rewards-test's Introduction

README

Environment Setup

Before starting, make sure your computer has all the necessary tools to build the application and that these tools match up with what you'll use in a production environment. This will ensure that when it comes time to deploy your project, you'll be able to do so more easily.

Requirements

  • Ruby 2.7.4
  • Postgresql

Install the Latest Ruby Version

Verify which version of Ruby you're running by entering this in the terminal:

$ ruby -v

Make sure that the Ruby version you're running is listed in the [supported runtimes][] by Heroku. At the time of writing, supported versions are 2.6.8, 2.7.4, or 3.0.2. Our recommendation is 2.7.4, but make sure to check the site for the latest supported versions.

If it's not, you can use rvm to install a newer version of Ruby:

$ rvm install 2.7.4 --default

You should also install the latest versions of bundler and rails:

$ gem install bundler
$ gem install rails

Install Postgresql

Heroku requires that you use PostgreSQL for your database instead of SQLite. PostgreSQL (or just Postgres for short) is an advanced database management system with more features than SQLite. If you don't already have it installed, you'll need to set it up.

PostgreSQL Installation for WSL

To install Postgres for WSL, run the following commands from your Ubuntu terminal:

$ sudo apt update
$ sudo apt install postgresql postgresql-contrib libpq-dev

Then confirm that Postgres was installed successfully:

$ psql --version

Run this command to start the Postgres service:

$ sudo service postgresql start

Finally, you'll also need to create a database user so that you are able to connect to the database from Rails. First, check what your operating system username is:

$ whoami

If your username is "ian", for example, you'd need to create a Postgres user with that same name. To do so, run this command to open the Postgres CLI:

$ sudo -u postgres -i

From the Postgres CLI, run this command (replacing "ian" with your username):

$ createuser -sr ian

Then enter control + d or type logout to exit.

This guide has more info on setting up Postgres on WSL if you get stuck.

Postgresql Installation for OSX

To install Postgres for OSX, you can use Homebrew:

$ brew install postgresql

Once Postgres has been installed, run this command to start the Postgres service:

$ brew services start postgresql

Start Up App

In order to test this API out I recommend using Postman as all visual examples of each step will be shown below using Postman.

To test this API out I used postman but any service similar to Postman should work. Link to download Postman. https://www.postman.com/downloads/

Once you set up with all of the necessary tools, if you haven't already done so, go ahead and clone this repository into your machine. Then cd into that repository. Start your PostgresSQL server in a new terminal. Link to blog with instructions on starting and stopping PostgresSQL server https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html. Once your PostgresSQL server is running, in a different or new terminal create your database with the following command:

$ rails db:create

If the database cannot be made due to pending migrations, run the following command:

$ rails db:migrate

Start your rails server with the following command.

$ rails s

Open up your Postman service and create a new tab. http://127.0.0.1:3000/ will be your beginning url. Make a post request to http://127.0.0.1:3000/signup in order to create a user. The body requires a json object with a string for the username and password (there are no requirements for the password).

Next you need to make a post request to http://127.0.0.1:3000/login with the same json object for the body as the last request.

After that, you are free to make request the following request in order to test out the functionality of the API.

Post request http://127.0.0.1:3000/payers

To create a new payer. Also instead of "payer", I used the variable payer_name.

Post request http://127.0.0.1:3000/transactions

To post transactions. For this request the user_id is required in the body along with the rest of the information called out in the pdf. Also instead of "payer", I used the variable payer_name.

Get request http://127.0.0.1:3000/balance

To get the balance.

Post request http://127.0.0.1:3000/spend

To spend points.

fetch-rewards-test's People

Contributors

createrz23 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.