Giter Site home page Giter Site logo

fetch_rewards_backend_exercise's Introduction

README

Starting the Server

Run 'bundle install' to install the dependencies. Run 'rails db:migrate' to run the migrations for the database. To start the rails server run 'rails s'.

Testing the API with the SPA

To test the backend I made a Singe Page Application which has forms for adding new transactions and spending points. To use the page for testing make sure to run the server and open 'index.html' located in the root directory of this application. You can open the console for viewing the responses after submitting the forms. The SPA uses JavaScript for submitting forms without reloading.

Manual Testing

You can manually test the API by making requests to the API endpoints.

Adding Transactions

To add a transaction send a POST request to 'http://localhost:3000/transactions' with a body of stringified JSON data in the form of... {transaction: { payer: string, points: integer, timestamp: datetime } }

Succesfully adding a transaction will return JSON of the newly added transcation.

Spending Points

To spend points send a POST request to 'http://localhost:3000/spend' with a body of stringified JSON data in the form of... {points: integer}

Spending points will return JSON of the payers that had points withdrawn and the amount points that was withdrawn from those payers.

Viewing Points

To view points send a GET request to 'http://localhost:3000/points' Returns JSON of each payer and the amount of points that is available from those payers. I.E. {payer: points}

Viewing Transactions

To view transactions send a GET request to 'http://localhost:3000/transactions' Returns JSON of each transaction including the payer, points and time.

fetch_rewards_backend_exercise's People

Contributors

nrymarz 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.