GithubHelp home page GithubHelp logo

points-api's Introduction

FetchRewards Points API

This project is a web API used for managing users' point balances while keeping track of which partner's points are spent at specific times.

Building

Building this project requires Go to be installed. Please refer to the documentation here for installing the latest version of Go. This project uses 1.15 but the latest version should work fine.

You can run this project two different ways, build the binary and run the binary or just hand the main folder to the go command.

Running from binary

go build cmd/api
./api

Running with the go commaand

go run cmd/api

Specifying the port

You can specify the port in which the server listens by providing an additional integer argument in the run command. The default port is 8090.

go run cmd/api 9090

Testing

Run the following command from the project root to run the tests.

go test ./...

Local endpoint testing

Once you start the server you may want to test it out. The following commands exercise most of the API's functionality. You can use these as a starting point.

Initialize transactions

curl -X POST \
  http://localhost:8090/v1/users/1/points/add \
  -d '{ "payer": "DANNON", "points": 1000, "timestamp": "2020-11-02T14:00:00Z" }'

curl -X POST \
  http://localhost:8090/v1/users/1/points/add \
  -d '{ "payer": "UNILEVER", "points": 200, "timestamp": "2020-10-31T11:00:00Z" }'

curl -X POST \
  http://localhost:8090/v1/users/1/points/add \
  -d '{ "payer": "DANNON", "points": -200, "timestamp": "2020-10-31T15:00:00Z" }'

curl -X POST \
  http://localhost:8090/v1/users/1/points/add \
  -d '{ "payer": "MILLER COORS", "points": 10000, "timestamp": "2020-11-01T14:00:00Z" }'

curl -X POST \
  http://localhost:8090/v1/users/1/points/add \
  -d '{ "payer": "DANNON", "points": 300, "timestamp": "2020-10-31T10:00:00Z" }'  

Spend points

curl -X POST \
  http://localhost:8090/v1/users/1/points/spend \
  -d '{
	"points": 5000
}'

Get payer balances

curl -X GET \
  http://localhost:8090/v1/users/1/payers

points-api's People

Contributors

jchappelle avatar

Watchers

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