contentapi

package
v0.0.0-...-2719905 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package contentapi implements the Ghost Content SDK

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorResource

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

AuthorResource represents actions that can be done on the Author resource

func (*AuthorResource) Browse

func (a *AuthorResource) Browse(opts *BrowseOptions) ([]*models.Author, *Meta, error)

Browse returns a list of authors

func (*AuthorResource) BrowseAll

func (a *AuthorResource) BrowseAll(opts *BrowseOptions, fn func([]*models.Author, bool) bool) error

BrowseAll iterates through all authors, calling the callback with the result of each request

func (*AuthorResource) Read

func (a *AuthorResource) Read(id string, opts *ReadOptions) (*models.Author, error)

Read reads a specific author

type BrowseOptions

type BrowseOptions struct {
	ReadOptions

	Filter string
	Limit  int64
	Page   int64
	Order  string
}

BrowseOptions represents options that can be passed to Browse methods

type Client

type Client struct {
	Posts   *PostResource
	Pages   *PageResource
	Authors *AuthorResource
	Tags    *TagResource
	// contains filtered or unexported fields
}

Client represents a Ghost Content API client

func New

func New(httpClient *http.Client, opts *ClientOptions) (*Client, error)

New takes in options and returns a new Client

type ClientOptions

type ClientOptions struct {
	Host      string
	GhostPath string
	Version   string
	Key       string
}

ClientOptions represents options given when creating a Client

func (*ClientOptions) Validate

func (opts *ClientOptions) Validate() error

Validate validations the options

type ErrorList

type ErrorList []*GhostError

ErrorList represents a list of errors

func (ErrorList) Error

func (l ErrorList) Error() string

type GhostError

type GhostError struct {
	Message   string `json:"message"`
	ErrorType string `json:"errorType"`
}

GhostError represents an error returned from the Ghost API

type Meta

type Meta struct {
	Pagination *Pagination `json:"pagination"`
}

Meta represents the meta information returned from browse endpoints

type PageResource

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

PageResource represents actions that can be done on the Page resource

func (*PageResource) Browse

func (p *PageResource) Browse(opts *BrowseOptions) ([]*models.Post, *Meta, error)

Browse returns a list of pages

func (*PageResource) BrowseAll

func (p *PageResource) BrowseAll(opts *BrowseOptions, fn func([]*models.Post, bool) bool) error

BrowseAll iterates through all posts, calling the callback with the result of each request

func (*PageResource) Read

func (p *PageResource) Read(id string, opts *ReadOptions) (*models.Post, error)

type Pagination

type Pagination struct {
	Page  int64 `json:"page"`
	Limit int64 `json:"limit"`
	Pages int64 `json:"pages"`
	Total int64 `json:"total"`
	Next  int64 `json:"next"`
	Prev  int64 `json:"prev"`
}

Pagination represents pagination info returned from browse endpoints

type PostResource

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

PostResource represents actions that can be done on the Posts resource

func (*PostResource) Browse

func (p *PostResource) Browse(opts *BrowseOptions) ([]*models.Post, *Meta, error)

Browse returns a list of posts

func (*PostResource) BrowseAll

func (p *PostResource) BrowseAll(opts *BrowseOptions, fn func([]*models.Post, bool) bool) error

BrowseAll iterates through all posts, calling the callback with the result of each request

func (*PostResource) Read

func (p *PostResource) Read(id string, opts *ReadOptions) (*models.Post, error)

type ReadOptions

type ReadOptions struct {
	Include string
	Fields  string
	Formats string
}

ReadOptions represents options that can be passed to Read methods

type TagResource

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

TagResource represents actions that can be done on the Tag resource

func (*TagResource) Browse

func (t *TagResource) Browse(opts *BrowseOptions) ([]*models.Tag, *Meta, error)

Browse returns a list of tags

func (*TagResource) BrowseAll

func (t *TagResource) BrowseAll(opts *BrowseOptions, fn func([]*models.Tag, bool) bool) error

BrowseAll iterates through all authors, calling the callback with the result of each request

func (*TagResource) Read

func (t *TagResource) Read(id string, opts *ReadOptions) (*models.Tag, error)

Read reads a specific author

Jump to

Keyboard shortcuts

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