response

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

package response provides methods for unmarshaling Flickr API responses in to structs and instances corresponding to specific API methods. Not all Flickr API responses are supported yet and may not be until time and circumstance warrant their inclusion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckTicket

type CheckTicket struct {
	// An Uploader instance that maps to the "uploader" element in the API response.
	Uploader *Uploader `json:"uploader"`
}

CheckTicket is a struct that maps to the Flickr API flickr.photos.upload.checkTickets method response.

func UnmarshalCheckTicketResponse

func UnmarshalCheckTicketResponse(fh io.Reader) (*CheckTicket, error)

Unmarshal Flickr API flickr.photos.upload.checkTickets method response into a CheckTicket instance.

type Error

type Error struct {
	// The numeric code for the error.
	Code int `xml:"code,attr" json:"code"`
	// The message associated with the error.
	Message string `xml:"msg,attr" json:"msg"`
}

Error is a struct containing information about a failed API request.

func (*Error) Error

func (e *Error) Error() string

Return a Flickr API error as a string containing both the error code and message.

type Login

type Login struct {
	Status    string `json:"stat"`
	Error     *Error `json:"error,omitempty"`
	User      *User  `json:"user,omitempty"`
	PathAlias string `json:"path_alias"`
}

func UnmarshalCheckLoginJSONResponse

func UnmarshalCheckLoginJSONResponse(fh io.Reader) (*Login, error)

type Pagination

type Pagination struct {
	// The current page of results for an API request.
	Page int `json:"page"`
	// The total number of pages of results for an API request.
	Pages int `json:"pages"`
	// The number of results, per page, for an API request.
	PerPage int `json:"perpage"`
	// The total number of results, across all pages, for an API request.
	Total int `json:"total"`
}

Pagination is a struct containing pagination metrics for a given API response.

func DerivePagination

func DerivePagination(ctx context.Context, fh io.ReadSeekCloser) (*Pagination, error)

Given an API response try to derive pagination metrics.

type Response

type Response struct {
	XMLName xml.Name `xml:"rsp" json:"-"`
	// A string label indicating whether or not an API request succeeded or failed, "ok" and "error" respectively.
	Status string `xml:"stat,attr" json:"stat"`
	// An optional Error instance containing specific details about a failed API request.
	Error *Error `xml:"err,omitempty" json:"err,omitempty"`
}

Response is a struct containing only minimal information about an API request, notably it's Status and optionally an Error associated with the request.

func UnmarshalResponse

func UnmarshalResponse(fh io.Reader) (*Response, error)

Unmarshal a Flickr API response in to a Response struct.

type Upload

type Upload struct {
	XMLName xml.Name `xml:"rsp" json:"-"`
	// The Flickr API response status.
	Status string       `xml:"stat,attr" json:"stat"`
	Error  *Error       `xml:"err,omitempty" json:"error,omitempty"`
	Photo  *UploadPhoto `xml:"photoid" json:"photo,omitempty"`
}

func UnmarshalUploadResponse

func UnmarshalUploadResponse(fh io.Reader) (*Upload, error)

type UploadPhoto

type UploadPhoto struct {
	Id             int64  `xml:",chardata" json:"id"`
	Secret         string `xml:"secret,attr,omitempty" json:"secret"`
	OriginalSecret string `xml:"originalsecret,attr,omitempty" json:"originalsecret"`
}

type UploadTicket

type UploadTicket struct {
	XMLName xml.Name `xml:"rsp"`
	// The Flickr API response status.
	Status   string `xml:"stat,attr"`
	Error    *Error `xml:"err,omitempty"`
	TicketId string `xml:"ticketid"`
}

func UmarshalUploadTicketResponse

func UmarshalUploadTicketResponse(fh io.Reader) (*UploadTicket, error)

Unmarshal Flickr API flickr.photos.upload method response, for asynchronous uploads, in to a UploadTicket instance.

func UnmarshalUploadTicketResponse

func UnmarshalUploadTicketResponse(fh io.Reader) (*UploadTicket, error)

type Uploader

type Uploader struct {
	// An array of UploaderTicket instances that map to the "ticket" array in the API response.
	Tickets []*UploaderTicket `json:"ticket"`
}

Uploader is a struct that maps to the "uploader" element in a Flickr API flickr.photos.upload.checkTickets method response.

type UploaderTicket

type UploaderTicket struct {
	// A Flickr API upload ticket ID.
	TicketId string `json:"id"`
	// A numeric flag (1 or 0) indicating whether an upload ticket has been completed.
	Complete int `json:"complete"`
	// The Flickr photo ID for a successful upload. Note that this is encoded (by the Flickr API) a string.
	PhotoId string `json:"photoid"`
	// The creation time (Unix timestamp) for a successful upload. Note that this is encoded (by the Flickr API) a string.
	Imported string `json:"imported"`
}

UploaderTicket is a struct that maps to the "ticket" array in a Flickr API flickr.photos.upload.checkTickets method response.

type User

type User struct {
	Id       string    `json:"id"`
	Username *Username `json:"username"`
}

type Username

type Username struct {
	Value string `json:"_content"`
}

Jump to

Keyboard shortcuts

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