Beta

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 or Category.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 }]
Metaprogramming
Fundamentals

Similar Kata:

Stats:

CreatedOct 4, 2015
PublishedOct 4, 2015
Warriors Trained196
Total Skips50
Total Code Submissions80
Total Times Completed4
Ruby Completions4
Total Stars6
% of votes with a positive feedback rating100% of 2
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Total Rank Assessments2
Average Assessed Rank
4 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • mikezaby Avatar
  • jhoffner Avatar
Ad