api

package
v0.0.0-...-ab98604 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CountryEU = "EU"
	CountryGB = "GB"
	CountryUS = "US"
)
View Source
const DefaultAppleNewsBaseURL = "https://news-api.apple.com"
View Source
const SORTDIR_ASC = "ASC"
View Source
const SORTDIR_DESC = "DESC"

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleComponent

type BundleComponent struct {
	Data io.Reader
	Name string
	Ext  string
}

type Client

type Client struct {
	Client    *http.Client
	APIKey    string
	APISecret string
	BaseURL   string
	ChannelID string
}

Client to communicate to Apple API

func NewClient

func NewClient(httpClient *http.Client, key, secret, url, channelID string) *Client

func (*Client) CreateArticle

func (c *Client) CreateArticle(article io.Reader, bundleComponents []MultipartUploadComponent, metadata *Metadata) (*ReadArticleResponse, error)

func (*Client) DeleteArticle

func (c *Client) DeleteArticle(articleId string) error

func (*Client) ListSections

func (c *Client) ListSections() (*ListSectionsResponse, error)

func (*Client) PromoteArticles

func (c *Client) PromoteArticles(sectionId string, articleIds []string) (*PromoteArticlesResponse, error)

func (*Client) ReadArticle

func (c *Client) ReadArticle(articleId string) (*ReadArticleResponse, error)

func (*Client) ReadChannel

func (c *Client) ReadChannel(channelId string) (*ReadChannelResponse, error)

func (*Client) ReadSection

func (c *Client) ReadSection(sectionId string) (*ReadSectionResponse, error)

func (*Client) SearchArticles

func (c *Client) SearchArticles(options *SearchArticlesOptions) (*SearchArticlesResponse, error)

func (*Client) SendNotification

func (c *Client) SendNotification(articleId string, alertBody string, countries []string, ignoreWarnings bool) (*NotificationResponse, error)

func (*Client) UpdateArticle

func (c *Client) UpdateArticle(articleId string, revision string, article io.Reader, bundleComponents []MultipartUploadComponent, metadata *Metadata) (*ReadArticleResponse, error)

func (*Client) UpdateArticleMetadata

func (c *Client) UpdateArticleMetadata(articleId string, metadata *Metadata) (*ReadArticleResponse, error)

type ContentType

type ContentType string
const (
	ContentTypeJpeg        ContentType = "image/jpeg"
	ContentTypePng         ContentType = "image/png"
	ContentTypeGif         ContentType = "image/gif"
	ContentTypeOctetStream ContentType = "application/octet-stream"
	ContentTypeJson        ContentType = "application/json"
	ContentTypeHtml        ContentType = "text/html"
	ContentTypeCss         ContentType = "text/css"
	ContentTypeJs          ContentType = "text/javascript"
	ContentTypeManifest    ContentType = "text/cache-manifest"
	ContentTypeMultipart   ContentType = "multipart/form-data"

	MaturityRatingKids    = "KIDS"
	MaturityRatingMature  = "MATURE"
	MaturityRatingGeneral = "GENERAL"
)

func GetContentType

func GetContentType(extension string) (ContentType, error)

type CoverArtType

type CoverArtType string

type Data

type Data struct {
	Links                   Links  `json:"links,omitempty"`
	IsSponsored             bool   `json:"isSponsored,omitempty"`
	IsPreview               bool   `json:"isPreview,omitempty"`
	AccessoryText           string `json:"accessoryText,omitempty"`
	MaturityRating          string `json:"maturityRating,omitempty"`
	IsCandidateToBeFeatured bool   `json:"isCandidateToBeFeatured,omitempty"`
	IsDevelopingStory       bool   `json:"isDevelopingStory,omitempty"`
	IsHidden                bool   `json:"isHidden,omitempty"`
	Revision                string `json:"revision,omitempty"`
}
type Links struct {
	Channel        string   `json:"channel,omitempty"`
	Next           string   `json:"next,omitempty"`
	Self           string   `json:"self,omitempty"`
	DefaultSection string   `json:"defaultSection,omitempty"`
	Sections       []string `json:"sections,omitempty"`
}

type ListSectionsResponse

type ListSectionsResponse struct {
	Data []struct {
		CreatedAt  time.Time `json:"createdAt"`
		ModifiedAt time.Time `json:"modifiedAt"`
		ID         string    `json:"id"`
		Type       string    `json:"type"`
		ShareURL   string    `json:"shareUrl"`
		Links      Links     `json:"links"`
		Name       string    `json:"name"`
		IsDefault  bool      `json:"isDefault"`
	} `json:"data"`
}

type MaturityRating

type MaturityRating string

type Meta

type Meta struct {
	Throttling struct {
		IsThrottled             bool `json:"isThrottled,omitempty"`
		QuotaAvailable          int  `json:"quotaAvailable,omitempty"`
		QueueSize               int  `json:"queueSize,omitempty"`
		EstimatedDelayInSeconds int  `json:"estimatedDelayInSeconds,omitempty"`
	} `json:"throttling,omitempty"`
}

type Metadata

type Metadata struct {
	Data Data `json:"data"`
}

type MultipartUploadComponent

type MultipartUploadComponent struct {
	Data     io.Reader
	Name     string
	FileName string
	ContentType
}

func GetBundleComponents

func GetBundleComponents(articleJson io.Reader, bundleBasePath string) ([]MultipartUploadComponent, error)

type NotificationData

type NotificationData struct {
	AlertBody string   `json:"alertBody"`
	Countries []string `json:"countries,omitempty"`
}

type NotificationRequest

type NotificationRequest struct {
	NotificationData `json:"data"`
}

type NotificationResponse

type NotificationResponse struct {
	Data struct {
		CreatedAt  time.Time `json:"createdAt"`
		ModifiedAt time.Time `json:"modifiedAt"`
		ID         string    `json:"id"`
		Type       string    `json:"type"`
		Links      struct {
			Article string `json:"article"`
		} `json:"links"`
		AlertBody string   `json:"alertBody"`
		Countries []string `json:"countries"`
	} `json:"data"`
	Meta struct {
		Quotas struct {
			Daily struct {
				Sent  int `json:"sent"`
				Limit int `json:"limit"`
			} `json:"daily"`
		} `json:"quotas"`
	} `json:"meta"`
}

type PromoteArticlesRequest

type PromoteArticlesRequest struct {
	Data struct {
		PromotedArticles []string `json:"promotedArticles"`
	} `json:"data"`
}

type PromoteArticlesResponse

type PromoteArticlesResponse struct {
	Data struct {
		PromotedArticles []string `json:"promotedArticles"`
	} `json:"data"`
}

type ReadArticleResponse

type ReadArticleResponse struct {
	Data struct {
		CreatedAt                   time.Time     `json:"createdAt"`
		ModifiedAt                  time.Time     `json:"modifiedAt"`
		ID                          string        `json:"id"`
		Type                        string        `json:"type"`
		ShareURL                    string        `json:"shareUrl"`
		Links                       Links         `json:"links"`
		Document                    interface{}   `json:"document"`
		Revision                    string        `json:"revision"`
		State                       string        `json:"state"`
		AccessoryText               string        `json:"accessoryText"`
		Title                       string        `json:"title"`
		MaturityRating              string        `json:"maturityRating"`
		Warnings                    []interface{} `json:"warnings"`
		TargetTerritoryCountryCodes []string      `json:"targetTerritoryCountryCodes"`
		IsCandidateToBeFeatured     bool          `json:"isCandidateToBeFeatured"`
		IsSponsored                 bool          `json:"isSponsored"`
		IsPreview                   bool          `json:"isPreview"`
		IsDevelopingStory           bool          `json:"isDevelopingStory"`
		IsHidden                    bool          `json:"isHidden"`
	} `json:"data"`
	Meta Meta `json:"meta,omitempty"`
}

type ReadChannelResponse

type ReadChannelResponse struct {
	Data struct {
		CreatedAt  time.Time `json:"createdAt"`
		ModifiedAt time.Time `json:"modifiedAt"`
		ID         string    `json:"id"`
		Type       string    `json:"type"`
		ShareURL   string    `json:"shareUrl"`
		Links      Links     `json:"links"`
		Name       string    `json:"name"`
		Website    string    `json:"website"`
	} `json:"data"`
}

type ReadSectionResponse

type ReadSectionResponse struct {
	Data struct {
		CreatedAt  time.Time `json:"createdAt"`
		ModifiedAt time.Time `json:"modifiedAt"`
		ID         string    `json:"id"`
		Type       string    `json:"type"`
		ShareURL   string    `json:"shareUrl"`
		Links      Links     `json:"links"`
		Name       string    `json:"name"`
		IsDefault  bool      `json:"isDefault"`
	} `json:"data"`
}

type ResultPage

type ResultPage struct {
	Results []SearchResult
}

type SearchArticlesOptions

type SearchArticlesOptions struct {
	SortDir   string
	FromDate  *time.Time
	ToDate    *time.Time
	PageSize  int
	PageToken string
}

func DefaultSearchArticlesOptions

func DefaultSearchArticlesOptions() *SearchArticlesOptions

func (*SearchArticlesOptions) ApplyToQuery

func (options *SearchArticlesOptions) ApplyToQuery(query *url.Values)

type SearchArticlesResponse

type SearchArticlesResponse struct {
	Data []struct {
		CreatedAt               time.Time     `json:"createdAt"`
		ModifiedAt              time.Time     `json:"modifiedAt"`
		ID                      string        `json:"id"`
		Type                    string        `json:"type"`
		ShareURL                string        `json:"shareUrl"`
		Links                   Links         `json:"links"`
		Revision                string        `json:"revision"`
		State                   string        `json:"state"`
		AccessoryText           string        `json:"accessoryText"`
		Title                   string        `json:"title"`
		MaturityRating          string        `json:"maturityRating"`
		Warnings                []interface{} `json:"warnings"`
		IsCandidateToBeFeatured bool          `json:"isCandidateToBeFeatured"`
		IsSponsored             bool          `json:"isSponsored"`
		IsPreview               bool          `json:"isPreview"`
		IsDevelopingStory       bool          `json:"isDevelopingStory"`
		IsHidden                bool          `json:"isHidden"`
	} `json:"data"`
	Links Links              `json:"links,omitempty"`
	Meta  SearchResponseMeta `json:"meta,omitempty"`
}

type SearchResponseMeta

type SearchResponseMeta struct {
	NextPageToken string `json:"nextPageToken,omitempty"`
}

type SearchResult

type SearchResult struct {
	Id        string    `json:"id"`
	CreatedAt time.Time `json:"createdAt"`
}

Jump to

Keyboard shortcuts

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