Code Monkey home page Code Monkey logo

fetch_rewards's Introduction

README

Languages and Frameworks:

  • Ruby Version 2.5.3

  • Rails Version 5.2.7

Set Up Instructions:

a) Enter $ git clone https://github.com/Aphilosopher30/fetch_rewards.git into your terminal

b) Enter the folder that you just cloned, probably by entering $ cd fetch_rewards

c) In terminal run the bundler: $ bundler or $ bundle install

  • you may have to download bundler with $ gem install bundler to make this work

  • if you cannot use Ruby 2.5.3, then you may have to open the Gemfile, and change the version there

d) To start the server terminal run $ rails s, or $ rails server

END POINTS:

There are three endpoints in this App. A. One which creates a new transaction, B. One which spends points, C. One which reports the payers and their balances. When you call these endpoints you may need to provide a JSON object in the Body of the http request.


A. Create Transaction: this end point creates and saves a new transaction. It receives information on how the transaction is to be created in JSON format. (Note: If you do not provide an appropriate DateTime object for the timestamp, then it will generate it's own timestamp.) It returns information on the transaction that has just been created.

URL: get 'user/transactions/new'

body: {"payer": String, "points": Integer, "timestamp": DateTime}

returns => {"data": { "id": null, "type": "transaction", "attributes": { "payer": String "points": Integer "timestamp": DateTime } } }


B. Spend Points: This endpoint receives an integer packaged in a json object, that represents how many points are to be spent. It then creates new transactions that subtract points equal to the number of points spent. It spends the oldest points first. It then returns a JSON object that specifies which payers have which points subtracted from their total. In the event that there are not enough points to spend, then it will return an error.

URL: get 'user/transactions/spend'

body: {"points": Integer}

returns => [ { "payer": String, "points": Integer }, { "payer": "String", "points": Integer } ]

OR
returns => {"error": "insufficent funds"}


C. List Payer Balances: This provides a JSON object that lists each payer, and how many points the user currently has from that payer. It does not require any input in the body.

URL: get '/user/payers'

returns => { payer_name1: Integer payer_name2: Integer payer_name3: Integer }

fetch_rewards's People

Contributors

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