mzalendo

package
v0.0.0-...-c2bcb9a Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package mzalendo provides a client for using the Mzalendo API. Access different parts of the API using the various services.

c := mzalendo.NewClient(nil)
// search for an interest
results, err := c.Api.GetPerson("1290")

The full Mzalendo API is documented at http://info.mzalendo.com/help/api. To use the package in App Engine you need to create a http.Client that uses urlfetch package.

        deadline := time.Duration(60) * time.Second
		client := &http.Client{
		Transport: &urlfetch.Transport{
			Context:  c,
			Deadline: deadline,
		},
	}

	c := mzalendo.NewClient(client)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

Types

type Api

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

func (*Api) GetOrganization

func (a *Api) GetOrganization(id string) (Organization, error)

func (*Api) GetPerson

func (a *Api) GetPerson(id string) (Person, error)

type Client

type Client struct {
	BaseURL *url.URL
	Api     *Api
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlString string) (*http.Request, error)

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Organization

type Organization struct {
	Result OrganizationResult `json:"result"`
}

type OrganizationResult

type OrganizationResult struct {
	HTMLURL        string        `json:"html_url"`
	URL            string        `json:"url"`
	Category       string        `json:"category"`
	Classification string        `json:"classification"`
	ID             string        `json:"id"`
	Name           string        `json:"name"`
	Slug           string        `json:"slug"`
	Images         []interface{} `json:"images",omitempty`
	Posts          []interface{} `json:"posts",omitempty`
	Memberships    []struct {
		HTMLURL        string        `json:"html_url"`
		URL            string        `json:"url"`
		EndDate        string        `json:"end_date"`
		ID             string        `json:"id"`
		Identifiers    []interface{} `json:"identifiers"`
		OrganizationID string        `json:"organization_id"`
		PersonID       string        `json:"person_id"`
		Role           string        `json:"role"`
		StartDate      string        `json:"start_date"`
		Images         []interface{} `json:"images",omitempty`
		Links          []interface{} `json:"links",omitempty`
		ContactDetails []interface{} `json:"contact_details",omitempty`
	} `json:"memberships"`
	Links          []interface{} `json:"links, omitempty"`
	ContactDetails []interface{} `json:"contact_details,omitempty"`
	Identifiers    []interface{} `json:"identifiers,omitempty"`
	OtherNames     []interface{} `json:"other_names",omitempty`
}

type Person

type Person struct {
	Result struct {
		BirthDate       string        `json:"birth_date"`
		ContactDetails  []interface{} `json:"contact_details"`
		Gender          string        `json:"gender"`
		HonorificSuffix string        `json:"honorific_suffix"`
		HtmlURL         string        `json:"html_url"`
		ID              string        `json:"id"`
		Identifiers     []interface{} `json:"identifiers"`
		Image           string        `json:"image"`
		Images          []struct {
			ProxyURL string `json:"proxy_url"`
			URL      string `json:"url"`
		} `json:"images"`
		Links       []interface{} `json:"links"`
		Memberships []struct {
			ContactDetails []interface{} `json:"contact_details"`
			HtmlURL        string        `json:"html_url"`
			ID             string        `json:"id"`
			Identifiers    []interface{} `json:"identifiers"`
			Images         []interface{} `json:"images"`
			Links          []interface{} `json:"links"`
			OrganizationID string        `json:"organization_id"`
			PersonID       string        `json:"person_id"`
			Role           string        `json:"role"`
			StartDate      string        `json:"start_date"`
			URL            string        `json:"url"`
		} `json:"memberships"`
		Name       string        `json:"name"`
		OtherNames []interface{} `json:"other_names"`
		ProxyImage string        `json:"proxy_image"`
		SortName   string        `json:"sort_name"`
		URL        string        `json:"url"`
	} `json:"result"`
}

type Response

type Response struct {
	*http.Response
}

Response is a Mzalendo API response. This wraps the standard http.Response returned from Mzalendo.

Jump to

Keyboard shortcuts

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