pfapi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://api.petfinder.com/v2"

DefaultBaseURL contains url for petfinder API

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Address1 string
	Address2 string
	City     string
	State    string
	PostCode string
	Country  string
}

type AdoptionPolicy

type AdoptionPolicy struct {
	Policy string
	URL    string
}

type Animal

type Animal struct {
	ID             int
	OrganizationID string `mapstructure:"organization_id"`
	URL            string
	Type           string
	Species        string
	Breeds         Breeds
	Colors         Colors
	Age            string
	Gender         string
	Size           string
	Coat           string
	Name           string
	Description    string
	Photos         []Photo
	Status         string
	Attributes     Attribute
	Environment    Environment
	Tags           []string
	Contact        Contact
}
type AnimalLinks struct {
	Self         Link
	Type         Link
	Organization Link
}

type AnimalResponse

type AnimalResponse struct {
	Animals    []Animal
	Pagination Pagination
}

type AnimalType

type AnimalType struct {
	Name    string
	Coats   []string
	Genders []string
	Colors  []string
	Links   TypeLinks `mapstructure:"_links"`
}

type Attribute

type Attribute struct {
	SpayedNeutered bool `mapstructure:"spayed_neutered"`
	HouseTrainied  bool `mapstructure:"house_trained"`
	Declawed       bool
	SpecialNeeds   bool `mapstructure:"special_needs"`
	ShotsCurrent   bool `mapstructure:"shots_current"`
}

type Breeds

type Breeds struct {
	Primary   string
	Secondary string
	Mixed     bool
	Unknown   bool
}

type Client

type Client struct {
	*http.Client
}

Client struct is used to hold http.Client

func NewClient

func NewClient(accessToken string, secretAccessToken string) (Client, error)

NewClient accepts client id and secret client id issued by Petfinder It returns a struct callled Client that contains a pointer to http.Client

func (Client) GetAllTypes

func (c Client) GetAllTypes() ([]AnimalType, error)

GetAllTypes function is a method of Client It returns a struct of animals types and error

func (Client) GetAnimalById

func (c Client) GetAnimalById(animalID string) (Animal, error)

GetAnimal takes a string of the type id (1234134) and returns an Animal struct and error.

func (Client) GetAnimals

func (c Client) GetAnimals(params SearchParams) (AnimalResponse, error)

GetAnimals takes a key,value pair for query string parameters It returns a hash of animals or error

func (Client) GetOrganizations

func (c Client) GetOrganizations() (OrganizationResponse, error)

GetOrganizations takes a key,value pair for query string parameters It returns a hash of organizations or error

func (Client) GetOrganizationsByID

func (c Client) GetOrganizationsByID(organizationID string) (Organization, error)

GetOrganizationsByID takes a string ID It returns a hash of organizations or error

func (Client) GetType

func (c Client) GetType(reqType string) (AnimalType, error)

GetType takes a string of the type name (dog, cat, etc) and returns an AnimalType struct and error.

type Colors

type Colors struct {
	Primary   string
	Secondary string
	Tertiary  string
}

type Contact

type Contact struct {
	Email   string
	Phone   string
	Address Address
}

type Environment

type Environment struct {
	Children bool
	Dogs     bool
	// contains filtered or unexported fields
}

type Hours

type Hours struct {
	Monday    string
	Tuesday   string
	Wednesday string
	Thursday  string
	Friday    string
	Saturday  string
	Sunday    string
}
type Link struct {
	Href string
}

type Organization

type Organization struct {
	ID               string
	Name             string
	Email            string
	Phone            string
	Address          Address
	Hours            Hours
	URL              string
	WebSite          string
	MissionStatement string
	AdoptionPolicy   AdoptionPolicy
	SocialMedia      SocialMedia `mapstructure:"social_media"`
	Photos           []Photo
	Links            OrganizationLinks `mapstructure:"_links"`
}
type OrganizationLinks struct {
	Self    Link
	Animals Link
}

type OrganizationResponse

type OrganizationResponse struct {
	Organizations []Organization
	Pagination    Pagination
}

type Pagination

type Pagination struct {
	CountPerPage int             `mapstructure:"count_per_page"`
	TotalCount   int             `mapstructure:"total_count"`
	CurrentPage  int             `mapstructure:"current_page"`
	TotalPages   int             `mapstructure:"total_pages"`
	Links        PaginationLinks `mapstructure:"_links"`
}
type PaginationLinks struct {
	Next Link
}

type Photo

type Photo struct {
	Small  string
	Medium string
	Large  string
	Full   string
}

type SearchParams

type SearchParams map[string]string

func NewPetSearchParams

func NewPetSearchParams() SearchParams

func (SearchParams) AddParam

func (p SearchParams) AddParam(key string, value string)

func (SearchParams) CreateQueryString

func (p SearchParams) CreateQueryString() string

type SocialMedia

type SocialMedia struct {
	Facebook  string
	Twitter   string
	Youtube   string
	Instagram string
	Pinterest string
}
type TypeLinks struct {
	Self   Link
	Breeds Link
}

Jump to

Keyboard shortcuts

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