Implement a client for an API
Description:
Overview
We have an api that responds to the following 4 endpoints:
- GET Post
- GET Categories
- GET Category
- GET Category Posts
For this kata we will be building a client to interact with these endpoints.
Client Details
We want to implement a Client
class that should be responsible for the requests and parsing of the responses. After this we want to implement a Model
class that should have the base functionality of defining methods for the attributes of json responses.
We want to implement the equality method ==
so we can compare if two object are the same.
Also we want to provide an interface for the associations:
belongs_to
example:belongs_to :category
has_many
example:has_many :categories
find
example:Category.find(1)
that find one category orCategory.find
that finds all categories
Last we want to Implement the Category
and Post
classes that should inherit the Model
class.
The active_support
is already required.
API Endpoints
GET Post
www.myblog.com/posts/:id
Example:
GET www.myblog.com/posts/1
{ id: 1, title: "my post", category_id: 1 }
## GET Categories
`www.myblog.com/categories`
> ### Example:
> `GET www.myblog.com/categories`
> ```
[{ id: 1, name: "category1" }, { id: 2, name: "category2" }]
GET Category
www.myblog.com/categories/:id
Example:
www.myblog.com/categories/1
{ id: 1, name: "category1" }
## GET Category Posts
`www.myblog.com/categories/:id/posts`
> ### Example:
> `www.myblog.com/categories/1/posts`
> ```
[{ id: 1, title: "my post", category_id: 1 }, { id: 5, title: "my post5", category_id: 1 }]
Similar Kata:
Stats:
Created | Oct 4, 2015 |
Published | Oct 4, 2015 |
Warriors Trained | 196 |
Total Skips | 50 |
Total Code Submissions | 80 |
Total Times Completed | 4 |
Ruby Completions | 4 |
Total Stars | 6 |
% of votes with a positive feedback rating | 100% of 2 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 2 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 5 kyu |