dj

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseUrl   *url.URL
	UserAgent string

	HttpClient *http.Client
}

func NewClient added in v0.2.0

func NewClient() *Client

func (*Client) GetJoke

func (c *Client) GetJoke() (Joke, error)

func (*Client) GetJokeAsImage

func (c *Client) GetJokeAsImage(id, imagePath string) error

func (*Client) GetJokeAsSlackMessage

func (c *Client) GetJokeAsSlackMessage() (SlackJoke, error)

func (*Client) SearchDadJokes

func (c *Client) SearchDadJokes(term string, page int, limit int) (Search, error)

type Joke

type Joke struct {
	ID   string `json:"id"`
	Joke string `json:"joke"`
}
type Search struct {
	CurrentPage  int    `json:"current_page"`
	Limit        int    `json:"limit"`
	NextPage     int    `json:"next_page"`
	PreviousPage int    `json:"previous_page"`
	Results      []Joke `json:"results"`
	SearchTerm   string `json:"search_term"`
	Status       int    `json:"status"`
	TotalJokes   int    `json:"total_jokes"`
	TotalPages   int    `json:"total_pages"`
}

type SlackAttachment

type SlackAttachment struct {
	Fallback string `json:"fallback"`
	Footer   string `json:"footer"`
	Text     string `json:"text"`
}

type SlackJoke

type SlackJoke struct {
	Attachments  []SlackAttachment `json:"attachments"`
	ResponseType string            `json:"response_type"`
	Username     string            `json:"username"`
}

Jump to

Keyboard shortcuts

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