mockclient

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 7 Imported by: 0

README

Mock API client

Just a test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HostURL    string
	HTTPClient *http.Client
}

Client

func NewClient

func NewClient(hostURL *string) (*Client, error)

NewClient

func (*Client) CreateProduct

func (c *Client) CreateProduct(product *Product) (*Product, error)

CreateProduct - Create a new product

func (*Client) CreateUser

func (c *Client) CreateUser(user *User) (*User, error)

CreateUser - Creates a new user (no auth required)

func (*Client) DeleteProduct

func (c *Client) DeleteProduct(id int) error

DeleteProduct - Delete a product by ID

func (*Client) DeleteUser

func (c *Client) DeleteUser(id int) error

DeleteUser - Deletes a user by ID (no auth required)

func (*Client) GetProductByID

func (c *Client) GetProductByID(id int) (*Product, error)

GetProductByID - Get product by ID

func (*Client) GetProducts

func (c *Client) GetProducts() ([]Product, error)

func (*Client) GetUserByID

func (c *Client) GetUserByID(id int) (*User, error)

GetUserByID - Returns a user by ID (no auth required)

func (*Client) GetUsers

func (c *Client) GetUsers() ([]User, error)

GetUsers - Returns a list of users (no auth required)

func (*Client) UpdateProduct

func (c *Client) UpdateProduct(product *Product) (*Product, error)

UpdateProduct - Update an existing product (no auth required)

func (*Client) UpdateUser

func (c *Client) UpdateUser(user *User) (*User, error)

UpdateUser - Updates an existing user (no auth required)

type Product

type Product struct {
	ID         int     `json:"id,omitempty"`
	Name       string  `json:"name,omitempty"`
	Price      float64 `json:"price,omitempty"`
	Stock      int     `json:"stock,omitempty"`
	CreatedAt  string  `json:"createdAt,omitempty"`
	Type       string  `json:"type,omitempty"`
	Department string  `json:"department,omitempty"`
}

func (Product) MarshalJSON

func (p Product) MarshalJSON() ([]byte, error)

Implementinc custom marshaler for Product

func (*Product) UnmarshalJSON

func (p *Product) UnmarshalJSON(data []byte) error

UnmarshalJSON - Custom unmarshal for Product struct

type User

type User struct {
	ID               int    `json:"id,omitempty"`
	Name             string `json:"name,omitempty"`
	LastName         string `json:"lastName,omitempty"`
	Address          string `json:"address,omitempty"`
	FavoriteDogBreed string `json:"favoriteDogBreed,omitempty"`
	CreatedAt        string `json:"createdAt,omitempty"`
}

func (User) MarshalJSON

func (u User) MarshalJSON() ([]byte, error)

Implementing custom marshaler for User

func (*User) UnmarshalJSON

func (u *User) UnmarshalJSON(data []byte) error

Implementing custom unmarshaler for User

Jump to

Keyboard shortcuts

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