Giter VIP home page Giter VIP logo

api_cli's Introduction

Api CLI

The scope of the app is to query two endpoints (users and purchases) and with with the data retrieved allow the user to know the most sold item, the most loyal user and the total spend of a specific user.

Gem

  1. Faraday HTTP/REST API client library.
  2. Rspec BDD for Ruby
  3. Vcr Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
  4. email_address The EmailAddress Gem to work with and validate email addresses.

Usage

install the dependency: bundle install then ruby app.rb most_sold to get the most sold item ruby app.rb total_spend [EMAIL]to get the total spend of a user ruby app.rb most_loyal to get the email of the most loyal user (most purchases)

or require the file driftlock.rb in another ruby script to have access to the sam function in a programmatic way

ruby app.rb most_sold total_spend [EMAIL]to get the total spend of a user most_loyal to get the email of the most loyal user (most purchases)

Driftrock.most_sold will return a string with the name of the most sold item (in a real world application I would return the product object) Driftrock.total_spend([EMAIL]) will return a float number with the total spent from the user Driftrock.most_loyal will return a user object of the userwith the most purchases

Errors

app.rb

the app will raise a this exception: Malformed command if a parameter is passed to commands that dont need it (most_sold, most_loyal) Missing argument if the email parameter is not passed to the most_loyal command Unrecognized command if the command cannot be recognized

lib/hash.rb

Malfomed Hash if the monkey patched method top_element is used on an hash not composed of only array as values

lib/purchase.rb

Attribute not available if an unavailable attribute is passed to the all_by method

lib/user.rb

Malformed Email Address if the email address for the find_by_email function is invalid User not found if a user is not found in the methods find and find_by_email

api_cli's People

Contributors

jabawack81 avatar

Watchers

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