Pàiring session - Martin

                Never    
## Objective

Implement a function that authorizes a transaction for a specific account, following some predefined rules.

## Input

You'll receive as input:

* The account data
  * Card status (`active` or `blocked`)
  * Current available limit, i.e., the amount available for purchases for the account.

* Transaction to be authorized
  * Merchant (the name is enough)
  * Amount
  * Time of the transaction

* List of approved transactions (using the same data model of the transaction to be authorized)

## Output

The output should consist of:
* Whether the purchase was authorized or not
* The updated available limit for the account
* All of the reasons why the transaction was denied, when relevant.

## Transaction validation rules

1. The transaction amount should not be above the account limit
2. No transaction should be approved when the card is blocked
3. The first transaction shouldn't be above 90% of the limit
4. There should not be more than 10 transactions for the same merchant
5. Transactions from a list of denied merchants should not be approved
6. There should not be more than 3 approved transactions on a 2 minutes interval
7. There should not be more than 2 similar transactions (same amount and merchant) in a 2 minutes interval

## Guidance

Here are some tips that might help you think about the problem and implement the solution:

* Consider starting by implementing few rules and then expanding your solution to support the rest.
* Consider designing the solution as if you were implementing the business logic layer of a service/application.
* [These examples](./examples.md) (in Clojure) suggest how the data structures and function signatures could look like.
These are just suggestions; you can use modified versions of the schemas.

Raw Text