- Make sure that you have ruby and sqlite3.
To install:
- git clone [email protected]:ranvold/ranvity.git
- Move to the directory project
- bundle install
Then you can use such commands:
bin/ranvity new
bin/ranvity new --type education --participants 1 --price_min 0.1 --price_max 30 --accessibility_min 0.1 --accessibility_max 0.5
bin/ranvity list
For this challenge, you are going to use the API of bored API. This API gives us a random activity to do every time you call it, for example, if you make the following call:
GET https://www.boredapi.com/api/activity
You will get a response like this:
{
"activity": "Learn Express.js",
"type": "education",
"participants": 1,
"price": 0.1,
"link": "https://expressjs.com/",
"key": "3943509",
"accessibility": 0.1
}
For more details, check the documentation.
We will use this API to create a simple program that will give us a random activity to do.
Clone this repository and create a new one on your own GitHub account. When you are done, please send us the link to your repository.
- Create an API wrapper for bored API, This wrapper should have a method that returns a random activity, and should accept parameters to filter the activities by type, number of participants, price range, and accessibility range.
-
Write a class that will save the activities in a database, this class should have a method that will accept the activity as a parameter
-
Add another method that will return the latest activities saved in the database. The database can be any database you want (e.g. SQLite), but it should be a relational database.
-
Create a simple command line program that will use the API wrapper and the database class to get a random activity and save it in the database. The program should accept parameters to filter the activities by type, number of participants, price range, and accessibility range. The command should look like this:
my_program new --type education --participants 1 --price_min 0.1 --price_max 30 --accessibility_min 0.1 --accessibility_max 0.5
This command should get a random activity with the type education, 1 participant, a price of 0.1, and an accessibility of 0.1 and save it in the database.
-
Add another command to the program that will return the last activities saved in the database. The command should look like this:
my_program list
This command should return the last 5 activities saved in the database.
- Make sure that you include a dependencies file (requirements.txt, gemfile, package.json, etc.). But don't include any virtual environment or packages installed in your repository.
- Add unit tests for your work.