jsonplaceholder

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package jsonplaceholder implements an example httpclient

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.6

type Client struct {
	*httpclient.Client

	// Services used for communicating with the API
	Post PostService
}

Client is a generated wrapper for a http client and detected services.

func NewClient added in v0.1.6

func NewClient(baseURL string, opts ...httpclient.Opt) (*Client, error)

NewClient returns a new API client.

type Post

type Post struct {
	UserID int    `json:"userId"`
	ID     int    `json:"id"`
	Title  string `json:"title"`
	Body   string `json:"body"`
}

Post a post entry

type PostImpl

type PostImpl struct {
	// contains filtered or unexported fields
}

PostImpl implements the PostService interface

func (*PostImpl) Create

func (p *PostImpl) Create(ctx context.Context, newPost *Post) (*Post, *http.Response, error)

Create a new post

func (*PostImpl) Delete

func (p *PostImpl) Delete(ctx context.Context, id int) (*http.Response, error)

Delete a post by ID

func (*PostImpl) Get

func (p *PostImpl) Get(ctx context.Context, id int) (*Post, *http.Response, error)

Get a post by ID

func (*PostImpl) List

func (p *PostImpl) List(ctx context.Context) ([]Post, *http.Response, error)

List all posts

type PostService

type PostService interface {
	Get(context.Context, int) (*Post, *http.Response, error)
	List(context.Context) ([]Post, *http.Response, error)
	Create(context.Context, *Post) (*Post, *http.Response, error)
	Delete(context.Context, int) (*http.Response, error)
}

PostService interface defines service methods

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL