GithubHelp home page GithubHelp logo

api_query's Introduction

API query - Tech Test

Build Status

Intro

This project was made for an application.
It was built with Ruby and its testing framework RSpec, using OOD and TDD.
Rubocop and SimpleCov were used from the beginning to improve the syntax and get the test coverage.

User stories

As a marketer,
So that I know what's my best seller,
I'd like an app to retrive the most sold item.

As a marketer,
So that I can see how much a given customer has spent,
I'd like an app to retrieve the total spend of this customer.

As a marketer,
So that I can reward my most loyal customer,
I'd like an app to retrieve their name.

Download and run project

$ git clone [email protected]/ChocolatineMathou/api_query.git
$ cd api-query
$ bundle install

Tests can be run using RSpec from the root of the project directory.
Test coverage is 98.14%. I didn't test the HTTP request in the API object, this is why I couldn't reach 100% coverage. However, there is no styling offense.

$ rspec / # To run the tests (include test coverage)
$ rubocop / # To inspect the syntax

You can interact with this project in your favourite REPL as follows:

$ ruby app.rb most_sold
"Heavy Duty Concrete Watch"
$ ruby app.rb total_spend [email protected]
245.01
$ ruby app.rb most_loyal
"[email protected]"
$ ruby app.rb total_spend [email protected]                                                                                                               (master)
#<RuntimeError: User does not exist>
$ ruby app.rb total_spend
"Email not provided"
$ ruby app.rb hello_world
"I did not understand your question."

Approach

I started to explore the given API and draw a diagram to get an idea of the domain model and the interactions the user will have.
I finally used three different classes - API, Purchases and Users - as they don't have the same responsabilities. API is in charge of retrieving information from the API, Purchases has all the purchases-related logic while Users has the users-related logic.
Moreover, I choose to integrate Travis CI to make sure the codebase could be used without breaking in a clean environment.
During my pairing session with the company, I've been able to refactor the codebase using a helper (frequency_map method) and memoization, and create unit tests for the App class.

Specification

Create a script that can be run from the command line and can answer the questions listed below. The script accepts one parameter to specify which question it will answer and in some cases an optional argument. The script will print the answer to the console output.
ruby app.rb COMMAND PARAMETERS

api_query's People

Contributors

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