urlshortener

package
v0.0.0-...-adba394 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2016 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package urlshortener provides access to the URL Shortener API.

See https://developers.google.com/url-shortener/v1/getting_started

Usage example:

import "google.golang.org/api/urlshortener/v1"
...
urlshortenerService, err := urlshortener.New(oauthHttpClient)

Index

Constants

View Source
const (
	// Manage your goo.gl short URLs
	UrlshortenerScope = "https://www.googleapis.com/auth/urlshortener"
)

OAuth2 scopes used by this API.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyticsSnapshot

type AnalyticsSnapshot struct {
	// Browsers: Top browsers, e.g. "Chrome"; sorted by (descending) click
	// counts. Only present if this data is available.
	Browsers []*StringCount `json:"browsers,omitempty"`

	// Countries: Top countries (expressed as country codes), e.g. "US" or
	// "DE"; sorted by (descending) click counts. Only present if this data
	// is available.
	Countries []*StringCount `json:"countries,omitempty"`

	// LongUrlClicks: Number of clicks on all goo.gl short URLs pointing to
	// this long URL.
	LongUrlClicks int64 `json:"longUrlClicks,omitempty,string"`

	// Platforms: Top platforms or OSes, e.g. "Windows"; sorted by
	// (descending) click counts. Only present if this data is available.
	Platforms []*StringCount `json:"platforms,omitempty"`

	// Referrers: Top referring hosts, e.g. "www.google.com"; sorted by
	// (descending) click counts. Only present if this data is available.
	Referrers []*StringCount `json:"referrers,omitempty"`

	// ShortUrlClicks: Number of clicks on this short URL.
	ShortUrlClicks int64 `json:"shortUrlClicks,omitempty,string"`

	// ForceSendFields is a list of field names (e.g. "Browsers") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`
}

func (*AnalyticsSnapshot) MarshalJSON

func (s *AnalyticsSnapshot) MarshalJSON() ([]byte, error)

type AnalyticsSummary

type AnalyticsSummary struct {
	// AllTime: Click analytics over all time.
	AllTime *AnalyticsSnapshot `json:"allTime,omitempty"`

	// Day: Click analytics over the last day.
	Day *AnalyticsSnapshot `json:"day,omitempty"`

	// Month: Click analytics over the last month.
	Month *AnalyticsSnapshot `json:"month,omitempty"`

	// TwoHours: Click analytics over the last two hours.
	TwoHours *AnalyticsSnapshot `json:"twoHours,omitempty"`

	// Week: Click analytics over the last week.
	Week *AnalyticsSnapshot `json:"week,omitempty"`

	// ForceSendFields is a list of field names (e.g. "AllTime") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`
}

func (*AnalyticsSummary) MarshalJSON

func (s *AnalyticsSummary) MarshalJSON() ([]byte, error)

type Service

type Service struct {
	BasePath  string // API endpoint base URL
	UserAgent string // optional additional User-Agent fragment

	Url *UrlService
	// contains filtered or unexported fields
}

func New

func New(client *http.Client) (*Service, error)

type StringCount

type StringCount struct {
	// Count: Number of clicks for this top entry, e.g. for this particular
	// country or browser.
	Count int64 `json:"count,omitempty,string"`

	// Id: Label assigned to this top entry, e.g. "US" or "Chrome".
	Id string `json:"id,omitempty"`

	// ForceSendFields is a list of field names (e.g. "Count") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`
}

func (*StringCount) MarshalJSON

func (s *StringCount) MarshalJSON() ([]byte, error)

type Url

type Url struct {
	// Analytics: A summary of the click analytics for the short and long
	// URL. Might not be present if not requested or currently unavailable.
	Analytics *AnalyticsSummary `json:"analytics,omitempty"`

	// Created: Time the short URL was created; ISO 8601 representation
	// using the yyyy-MM-dd'T'HH:mm:ss.SSSZZ format, e.g.
	// "2010-10-14T19:01:24.944+00:00".
	Created string `json:"created,omitempty"`

	// Id: Short URL, e.g. "http://goo.gl/l6MS".
	Id string `json:"id,omitempty"`

	// Kind: The fixed string "urlshortener#url".
	Kind string `json:"kind,omitempty"`

	// LongUrl: Long URL, e.g. "http://www.google.com/". Might not be
	// present if the status is "REMOVED".
	LongUrl string `json:"longUrl,omitempty"`

	// Status: Status of the target URL. Possible values: "OK", "MALWARE",
	// "PHISHING", or "REMOVED". A URL might be marked "REMOVED" if it was
	// flagged as spam, for example.
	Status string `json:"status,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the
	// server.
	googleapi.ServerResponse `json:"-"`

	// ForceSendFields is a list of field names (e.g. "Analytics") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`
}

func (*Url) MarshalJSON

func (s *Url) MarshalJSON() ([]byte, error)

type UrlGetCall

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

func (*UrlGetCall) Context

func (c *UrlGetCall) Context(ctx context.Context) *UrlGetCall

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*UrlGetCall) Do

func (c *UrlGetCall) Do(opts ...googleapi.CallOption) (*Url, error)

Do executes the "urlshortener.url.get" call. Exactly one of *Url or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *Url.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*UrlGetCall) Fields

func (c *UrlGetCall) Fields(s ...googleapi.Field) *UrlGetCall

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*UrlGetCall) IfNoneMatch

func (c *UrlGetCall) IfNoneMatch(entityTag string) *UrlGetCall

IfNoneMatch sets the optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request. Use googleapi.IsNotModified to check whether the response error from Do is the result of In-None-Match.

func (*UrlGetCall) Projection

func (c *UrlGetCall) Projection(projection string) *UrlGetCall

Projection sets the optional parameter "projection": Additional information to return.

Possible values:

"ANALYTICS_CLICKS" - Returns only click counts.
"ANALYTICS_TOP_STRINGS" - Returns only top string counts.
"FULL" - Returns the creation timestamp and all available

analytics.

type UrlHistory

type UrlHistory struct {
	// Items: A list of URL resources.
	Items []*Url `json:"items,omitempty"`

	// ItemsPerPage: Number of items returned with each full "page" of
	// results. Note that the last page could have fewer items than the
	// "itemsPerPage" value.
	ItemsPerPage int64 `json:"itemsPerPage,omitempty"`

	// Kind: The fixed string "urlshortener#urlHistory".
	Kind string `json:"kind,omitempty"`

	// NextPageToken: A token to provide to get the next page of results.
	NextPageToken string `json:"nextPageToken,omitempty"`

	// TotalItems: Total number of short URLs associated with this user (may
	// be approximate).
	TotalItems int64 `json:"totalItems,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the
	// server.
	googleapi.ServerResponse `json:"-"`

	// ForceSendFields is a list of field names (e.g. "Items") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`
}

func (*UrlHistory) MarshalJSON

func (s *UrlHistory) MarshalJSON() ([]byte, error)

type UrlInsertCall

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

func (*UrlInsertCall) Context

func (c *UrlInsertCall) Context(ctx context.Context) *UrlInsertCall

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*UrlInsertCall) Do

func (c *UrlInsertCall) Do(opts ...googleapi.CallOption) (*Url, error)

Do executes the "urlshortener.url.insert" call. Exactly one of *Url or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *Url.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*UrlInsertCall) Fields

func (c *UrlInsertCall) Fields(s ...googleapi.Field) *UrlInsertCall

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

type UrlListCall

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

func (*UrlListCall) Context

func (c *UrlListCall) Context(ctx context.Context) *UrlListCall

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*UrlListCall) Do

func (c *UrlListCall) Do(opts ...googleapi.CallOption) (*UrlHistory, error)

Do executes the "urlshortener.url.list" call. Exactly one of *UrlHistory or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *UrlHistory.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*UrlListCall) Fields

func (c *UrlListCall) Fields(s ...googleapi.Field) *UrlListCall

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*UrlListCall) IfNoneMatch

func (c *UrlListCall) IfNoneMatch(entityTag string) *UrlListCall

IfNoneMatch sets the optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request. Use googleapi.IsNotModified to check whether the response error from Do is the result of In-None-Match.

func (*UrlListCall) Projection

func (c *UrlListCall) Projection(projection string) *UrlListCall

Projection sets the optional parameter "projection": Additional information to return.

Possible values:

"ANALYTICS_CLICKS" - Returns short URL click counts.
"FULL" - Returns short URL click counts.

func (*UrlListCall) StartToken

func (c *UrlListCall) StartToken(startToken string) *UrlListCall

StartToken sets the optional parameter "start-token": Token for requesting successive pages of results.

type UrlService

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

func NewUrlService

func NewUrlService(s *Service) *UrlService

func (*UrlService) Get

func (r *UrlService) Get(shortUrl string) *UrlGetCall

Get: Expands a short URL or gets creation time and analytics.

func (*UrlService) Insert

func (r *UrlService) Insert(url *Url) *UrlInsertCall

Insert: Creates a new short URL.

func (*UrlService) List

func (r *UrlService) List() *UrlListCall

List: Retrieves a list of URLs shortened by a user.

Jump to

Keyboard shortcuts

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