GithubHelp home page GithubHelp logo

presalebc's Introduction

PROGRAMMING TASK

PREFACE

Implement a simple API that allows to validate bonus codes for pre-sale program. Given a set of products with title attribute. Each product has a set of bonus codes assigned. These bonus codes may be either pre-loaded into the system or not. When user enters a bonus code we need to validate it to check that bonus code has been purchased. For some products a third-party service can be used for validation. There are 2 types of such services(but may be more in future). Each product can be linked to a particular service.

There is no need to implement a complete wrapper for a third-party API. A dummy on is enough. Full test coverage is required.

DATA

Products:

"Id", "Title", "Bonus Codes", "Status", "Service"
"1", "Halo 4", "Pre-loaded", "Pre-loaded", ""
"2", "Samsung Galaxy 4", "Pre-loaded", "via Services", "TV"
"3", "Skype $10", "via Services", "via Services", "RTG"

API requirements

URL: /bonus_codes/validate
HTTP METHOD: GET
PARAMS: product_id, bonus_code

Sample request:

GET /bonus_codes/validate?product_id=12354345&bonus_code=68483737392

Sample responses:

HTTP 200 OK

or

HTTP 404 NOT FOUND if bonus code doesn’t belong to a product with provided product_id.
HTTP 403 FORBIDDEN if bonus code hasn’t been sold.

USAGE

cd presalebc/
bundle install
rake db:setup
rspec
rails s
curl -D - 'http://localhost:3000/bonus_codes/validate?product_id=1&bonus_code=68483737392'
curl -D - 'http://localhost:3000/bonus_codes/validate?product_id=3&bonus_code=4000000019'
curl -D - 'http://localhost:3000/bonus_codes/validate?product_id=232323&bonus_code=4000000019'
curl -D - 'http://localhost:3000/bonus_codes/validate?product_id=zzzzsdd&bonus_code=asdasd'

presalebc's People

Contributors

scoricov avatar

Watchers

James Cloos 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.