Git Product home page Git Product logo

buy_coins_graphql's Introduction

buy_coins_graphql

GraphQL Aptitude Test For Buy Coins

Coding Challenge

You're going to create a GraphQL API with one query. The query calculatePrice will accept three required arguments:

  • type: This can either be buy or sell, nothing else.
  • margin: This is a percentage that will be used in a calculation. Not a fraction, a percentage. For example, if 0.2 is passed into this argument, then the calculation should be done with 0.2%.
  • exchangeRate: This is a custom USD/NGN exchange rate that will be used in the calculation detailed below.

The calculation

  • When calculatePrice is called, your API must make a request to Coindesk's API to retrieve the current price of Bitcoin in USD.
  • If the type is sell, then your API should subtract the computed value of the margin percentage from the current Bitcoin price it just retrieved.
  • If the type is buy, then your API should add the computed value of the margin percentage to the current Bitcoin price it just retrieved.
  • Finally, the number calculatePrice responds will be in NGN and not USD. This should be calculated using the exchangeRate argument.

Test Data

  • Query: query calculatePrice($type:String!, $margin: Float!, $exchangeRate: String!) { calculatePrice(type: $type, margin: $margin, exchangeRate: $exchangeRate){ price, currency, type } }

  • Query Variables: { "type": "sell", "margin": 0.2, "exchangeRate": "USD" }

buy_coins_graphql's People

Contributors

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