client

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the wrapper around the republik GraphQL API

func NewClient

func NewClient(SID string) *Client

NewClient returns a new API client

func (*Client) Fetch

func (c *Client) Fetch(filter Filter, limit int) ([]Document, error)

Fetch fetches a list of documents

type Document

type Document struct {
	ID   string
	Meta struct {
		Title                       string
		Path                        string
		Image                       string
		Description                 string
		PublishDate                 string
		Template                    string
		EstimatedReadingMinutes     int
		EstimatedConsumptionMinutes int
		AudioCoverCrop              struct {
			X      int
			Y      int
			Width  int
			Height int
		}
		AudioSource struct {
			MP3        string
			Kind       string
			DurationMs int
		}
		Format struct {
			Meta struct {
				Path  string
				Title string
				Kind  string
			}
		}
	}
}

Document is marshalled from GraphQL response for a single document

func (*Document) PubDate

func (d *Document) PubDate() time.Time

PubDate returns parsed publication date of a document

type Filter

type Filter struct {
	Feed            bool
	HasAudio        bool
	AudioSourceKind string
	Format          string
}

func (Filter) String

func (f Filter) String() string

type Response

type Response struct {
	Documents struct {
		Nodes []struct {
			Entity Document
		}
	}
}

Response is marshalled from the GraphQL response from search query

Jump to

Keyboard shortcuts

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