socialMedia static method
Creates a social media API definition.
Implementation
static ApiDefinition socialMedia() {
return SimpleApiBuilder(
title: 'Social Media API',
baseUrl: 'https://jsonplaceholder.typicode.com',
description: 'Social media platform API for posts, comments, and users',
)
// Posts
.get('/posts',
name: 'Get All Posts',
queryParams: ['userId', '_limit', '_start', '_sort', '_order'],
tags: ['posts', 'read'],
responseType: 'List<Post>')
.get('/posts/{id}',
name: 'Get Post',
tags: ['posts', 'read'],
responseType: 'Post')
.post('/posts',
name: 'Create Post',
tags: ['posts', 'write'],
responseType: 'Post')
.put('/posts/{id}',
name: 'Update Post',
tags: ['posts', 'write'],
responseType: 'Post')
.patch('/posts/{id}',
name: 'Partial Update Post',
tags: ['posts', 'write'],
responseType: 'Post')
.delete('/posts/{id}',
name: 'Delete Post',
tags: ['posts', 'write'],
responseType: 'void')
// Comments
.get('/comments',
name: 'Get All Comments',
queryParams: ['postId', 'email', '_limit', '_start'],
tags: ['comments', 'read'],
responseType: 'List<Comment>')
.get('/comments/{id}',
name: 'Get Comment',
tags: ['comments', 'read'],
responseType: 'Comment')
.get('/posts/{id}/comments',
name: 'Get Post Comments',
queryParams: ['_limit', '_start'],
tags: ['posts', 'comments', 'read'],
responseType: 'List<Comment>')
.post('/comments',
name: 'Add Comment',
tags: ['comments', 'write'],
responseType: 'Comment')
.put('/comments/{id}',
name: 'Update Comment',
tags: ['comments', 'write'],
responseType: 'Comment')
.delete('/comments/{id}',
name: 'Delete Comment',
tags: ['comments', 'write'],
responseType: 'void')
// Users
.get('/users',
name: 'Get All Users',
queryParams: ['_limit', '_start', '_sort', '_order'],
tags: ['users', 'read'],
responseType: 'List<User>')
.get('/users/{id}',
name: 'Get User Profile',
tags: ['users', 'read'],
responseType: 'User')
.get('/users/{id}/posts',
name: 'Get User Posts',
queryParams: ['_limit', '_start'],
tags: ['users', 'posts', 'read'],
responseType: 'List<Post>')
.get('/users/{id}/albums',
name: 'Get User Albums',
queryParams: ['_limit', '_start'],
tags: ['users', 'albums', 'read'],
responseType: 'List<Album>')
.get('/users/{id}/todos',
name: 'Get User Todos',
queryParams: ['_limit', '_start', 'completed'],
tags: ['users', 'todos', 'read'],
responseType: 'List<Todo>')
// Albums & Photos
.get('/albums',
name: 'Get All Albums',
queryParams: ['userId', '_limit', '_start'],
tags: ['albums', 'read'],
responseType: 'List<Album>')
.get('/albums/{id}',
name: 'Get Album',
tags: ['albums', 'read'],
responseType: 'Album')
.get('/albums/{id}/photos',
name: 'Get Album Photos',
queryParams: ['_limit', '_start'],
tags: ['albums', 'photos', 'read'],
responseType: 'List<Photo>')
.get('/photos',
name: 'Get All Photos',
queryParams: ['albumId', '_limit', '_start'],
tags: ['photos', 'read'],
responseType: 'List<Photo>')
// Todos
.get('/todos',
name: 'Get All Todos',
queryParams: ['userId', 'completed', '_limit', '_start'],
tags: ['todos', 'read'],
responseType: 'List<Todo>')
.get('/todos/{id}',
name: 'Get Todo',
tags: ['todos', 'read'],
responseType: 'Todo')
.build();
}