# Beetrack-DispatchTrack technical evaluation - Ruby on Rails π©βπ»π¨βπ»π§βπ»
## Introduction
This test is inteded to evaluate the candidate's Ruby on Rails and software engineering skils. For any kind of questions please write to techops@beetrack.com (the content of the email can be in spanish or english as long as it is clear).
## The problem
Write a Ruby on Rails App that can organize `Clients` information. A `Client` can have many properties such as `name`, `country`, `address`, etcetera. A `Client` may have information that other `Clients` do not have. You have to model this using a relational database.
A `Client` must **always** have a `name`. Other properties are optional, but each one **must be unique** for a client (ie: a same `Client` cannot 2 postal codes or 2 or more countries, etc.). The uniqueness scope is based on the name of the`Property` and the `Client`.
The goal is to expose an API where you can **C**reate, **R**ead, **U**pdate and **D**elete information about a client. The route `/clients` has to return the different clients information in `JSON` format. A response example could be the following:
###### Response format
```javascript
{
clients: [
{
id: 1,
name: 'Atriles N.K.',
properties: [
{name: 'has_erp', value: 'true'},
{name: 'address', value: 'San Pedro 530, Puerto Varas, Los Lagos'},
{name: 'country', value: 'Chile'},
{name: 'currency', value: 'CLP'},
{name: 'company_owner', value: 'NicolΓ‘s Kipreos'}
]
},
{
id: 2,
name: 'Sencozud',
properties: [
{name: 'address', value: 'Avenida Kennedy 5510'},
{name: 'postal_code', value: '12345'},
{name: 'employees', value: '12500'},
]
},
]
}
```
Note that any `value` information can be stored as a string.
The payload to create a new `Client` should be a `POST` to route `/client` with the following payload:
```javascript
{
name: 'Transportes Smile'
}
```
You should also create an enpoint to add new properties to a specific `Client` through a `POST` to the route `/properties`. The payload you send should have the following format:
```javascript
{
client_id: 1,
properties: [
{name: 'address', value: 'Calle Falsa 123'},
{name: 'country', value: 'Chile'}
]
}
```
The other endpoints to develop are Delete and Update for both `Client` and `Properties`, these should be done according to your criteria.
## Evaluation criteria π
- Good class and code architecture is fundamental
- Production-grade code and practices are expected: please leave documentation, tests (we suggest the use of `RSpec`) and git commits.
- Please use Ruby on Rails 6.0 (or up).
- Use PostgreSQL as the relational database
## Bonus π₯Έ
Now that we have our client properties, we want to make our developers use of the API more intuitive with regards to the `type` of the stored values.
To make this API more intuitive we want to have a `type` for the stored values in the `Property`. The types can be either `boolean`, `string` or `integer`. The end result should be one in which when the client is queried, the stored value is returned as the corresponding type.
The [previous example](#Response-format) should result in the following response:
```javascript
{
clients: [
{
id: 1,
name: 'Atriles N.K.',
properties: [
{
name: 'has_erp',
value: true,
type: 'boolean'
},
{
name: 'address',
value: 'San Pedro 530, Puerto Varas, Los Lagos',
type: 'string'
},
{
name: 'country',
value: 'Chile',
type: 'string'
},
{
name: 'currency',
value: 'CLP',
type: 'string'
},
{
name: 'company_owner',
value: 'NicolΓ‘s Kipreos',
type: 'string'
}
]
},
{
id: 2,
properties: [
{
name: 'name',
value: 'Sencozud',
type: 'string'
},
{
name: 'address',
value: 'Avenida Kennedy 5510',
type: 'string'
},
{
name: 'postal_code',
value: 12345,
type: 'integer'
},
{
name: 'employees',
value: 12500,
type: 'integer'
},
]
},
]
}
```
Note that now the properties such as `has_erp` or `postal_code` have a return value which is the one defined by their `type`.
## Submission π¬
Please submit your codebase to a public repository in [Github](https://github.com) and send the repository link via email to techops@beetrack.com.