Documentation
¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, error)
- func (c *Client) Client() *http.Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- type Collection
- type CollectionsService
- type DeleteItemResponse
- type Domain
- type DomainsService
- type EcommerceService
- type ErrorResponse
- type Field
- type Item
- type ItemResponse
- type ItemsService
- func (s *ItemsService) CreateItem(ctx context.Context, collectionId string, item Item) (Item, error)
- func (s *ItemsService) CreateItemLive(ctx context.Context, collectionId string, item Item) (Item, error)
- func (s *ItemsService) DeleteItem(ctx context.Context, collectionId string, itemId string) (*DeleteItemResponse, error)
- func (s *ItemsService) GetItem(ctx context.Context, collectionId string, itemId string) (*ItemResponse, error)
- func (s *ItemsService) ListItems(ctx context.Context, collectionId string, opts *ListItemsOptions) (*ItemResponse, error)
- func (s *ItemsService) PatchItem(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
- func (s *ItemsService) PatchItemLive(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
- func (s *ItemsService) UpdateItem(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
- func (s *ItemsService) UpdateItemLive(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
- type ListCollectionsOptions
- type ListDomainsOptions
- type ListItemsOptions
- type ListOptions
- type ListSitesOptions
- type MetaService
- type PageInfo
- type PublishSiteResponse
- type Rate
- type RateLimitError
- type Response
- type Site
- type SitesService
- type WebhooksService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. Defaults to the public Webflow API, but can be // set to a domain endpoint to use with Webflow Enterprise. BaseURL should // always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating with the Webflow API. UserAgent string // Services used for talking to different parts of the Webflow API. //TODO: Add services Meta *MetaService Sites *SitesService Domains *DomainsService Collections *CollectionsService Items *ItemsService Ecommerce *EcommerceService Webhooks *WebhooksService // contains filtered or unexported fields }
A Client manages communication with the Webflow API.
func (*Client) BareDo ¶
BareDo sends an API request and lets you handle the api response. If an error or API Error occurs, the error will contain more information. Otherwise you are supposed to read and close the response's Body. If rate limit is exceeded and reset time is in the future, BareDo returns *RateLimitError immediately without making a network API call.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If v is nil, and no error happens, the response is returned as is. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type Collection ¶
type Collection struct { Id string `json:"_id"` LastUpdated time.Time `json:"lastUpdated"` CreatedOn time.Time `json:"createdOn"` Name string `json:"name"` Slug string `json:"slug"` SingularName string `json:"singularName"` Fields []interface{} `json:"fields"` }
Collection models a Webflow API collection ref: https://developers.webflow.com/#model16
type CollectionsService ¶
type CollectionsService service
CollectionsService handles communication with the collections related methods of the Webflow API.
ref: https://developers.webflow.com/#collections
func (*CollectionsService) GetCollection ¶
func (s *CollectionsService) GetCollection(ctx context.Context, collectionId string) (*Collection, error)
GetCollection retrieves the specified collection ref: https://developers.webflow.com/#get-collection-with-full-schema
func (*CollectionsService) ListCollections ¶
func (s *CollectionsService) ListCollections(ctx context.Context, site string, opts *ListCollectionsOptions) ([]*Collection, error)
ListCollections lists all the collections for the given site ref: https://developers.webflow.com/#list-collections
type DeleteItemResponse ¶
type DeleteItemResponse struct {
Deleted int `json:"deleted"`
}
type DomainsService ¶
type DomainsService service
DomainsService handles communication with the meta related methods of the Webflow API.
ref: https://developers.webflow.com/#domains
func (*DomainsService) ListDomains ¶
func (s *DomainsService) ListDomains(ctx context.Context, site string, opts *ListDomainsOptions) ([]*Domain, error)
ListDomains lists of all domains for the provided site. ref: https://developers.webflow.com/#list-domains
type EcommerceService ¶
type EcommerceService service
EcommerceService handles communication with the ecommerce related methods of the Webflow API.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Msg string `json:"msg"` Code int `json:"code"` Name string `json:"name"` Path string `json:"path"` Err string `json:"err"` }
An ErrorResponse reports one or more errors caused by an API request. Webflow API docs: https://developers.webflow.com/?shell#errors
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Field ¶
type Field struct { Validations struct { SingleLine bool `json:"singleLine,omitempty"` MaxLength int `json:"maxLength,omitempty"` MinLength int `json:"minLength,omitempty"` Minimum int `json:"minimum,omitempty"` Maximum int `json:"maximum,omitempty"` MaxSize int `json:"maxSize,omitempty"` DecimalPlaces int `json:"decimalPlaces,omitempty"` Options []interface{} `json:"options,omitempty"` Format string `json:"format,omitempty"` Precision int `json:"precision,omitempty"` AllowNegative bool `json:"allowNegative,omitempty"` CollectionId string `json:"collectionId,omitempty"` } `json:"validations"` Id string `json:"id"` Editable bool `json:"editable"` Required bool `json:"required"` Type string `json:"type"` Slug string `json:"slug"` Name string `json:"name"` }
Field models a Webflow API field ref: https://developers.webflow.com/#fields
type Item ¶
type Item map[string]interface{}
Item is a dynamic object. Its fields depend on the fields a user creates for a collection ref: https://developers.webflow.com/#item-model
type ItemResponse ¶
ItemResponse models a response returned by the Items Webflow API
type ItemsService ¶
type ItemsService service
ItemsService handles communication with the items related methods of the Webflow API.
ref: https://developers.webflow.com/#items
func (*ItemsService) CreateItem ¶
func (s *ItemsService) CreateItem(ctx context.Context, collectionId string, item Item) (Item, error)
CreateItem creates a new item inside the given collection ref: https://developers.webflow.com/#create-new-collection-item
func (*ItemsService) CreateItemLive ¶
func (s *ItemsService) CreateItemLive(ctx context.Context, collectionId string, item Item) (Item, error)
CreateItemLive creates a new item inside the given collection and publish it ref: https://developers.webflow.com/#create-new-live-collection-item
func (*ItemsService) DeleteItem ¶
func (s *ItemsService) DeleteItem(ctx context.Context, collectionId string, itemId string) (*DeleteItemResponse, error)
func (*ItemsService) GetItem ¶
func (s *ItemsService) GetItem(ctx context.Context, collectionId string, itemId string) (*ItemResponse, error)
GetItem retrieves the specified item ref: https://developers.webflow.com/#get-single-item
func (*ItemsService) ListItems ¶
func (s *ItemsService) ListItems(ctx context.Context, collectionId string, opts *ListItemsOptions) (*ItemResponse, error)
ListItems lists all the items of the given collection ref: https://developers.webflow.com/#get-all-items-for-a-collection
func (*ItemsService) PatchItem ¶
func (s *ItemsService) PatchItem(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
PatchItem updates the selected fields of the given item ref: https://developers.webflow.com/#patch-collection-item
func (*ItemsService) PatchItemLive ¶
func (s *ItemsService) PatchItemLive(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
PatchItemLive updates the selected fields of the given item and publishes the changes ref: https://developers.webflow.com/#patch-live-collection-item
func (*ItemsService) UpdateItem ¶
func (s *ItemsService) UpdateItem(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
UpdateItem updates (replaces) the collection item with the given fields ref: https://developers.webflow.com/#update-collection-item
func (*ItemsService) UpdateItemLive ¶
func (s *ItemsService) UpdateItemLive(ctx context.Context, collectionId string, itemId string, item Item) (Item, error)
UpdateItemLive updates (replaces) the collection item with the given fields and publishes the changes ref: https://developers.webflow.com/#update-live-collection-item
type ListCollectionsOptions ¶
type ListCollectionsOptions struct {
ListOptions
}
type ListDomainsOptions ¶
type ListDomainsOptions struct {
ListOptions
}
type ListItemsOptions ¶
type ListItemsOptions struct {
ListOptions
}
ListItemsOptions defines the available list options
type ListOptions ¶
type ListOptions struct { // Maximum number of Items to be returned (max limit: 100) Limit int `url:"limit,omitempty"` // Offset used for pagination if collection has more than limit items Offset int `url:"offset,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support offset pagination.
type ListSitesOptions ¶
type ListSitesOptions struct {
ListOptions
}
type MetaService ¶
type MetaService service
MetaService handles communication with the meta related methods of the Webflow API.
Webflow API docs: https://developers.webflow.com/#meta
func (*MetaService) GetCurrentAuthorizationInfo ¶
func (s *MetaService) GetCurrentAuthorizationInfo(ctx context.Context) (interface{}, error)
func (*MetaService) GetCurrentAuthorizedUser ¶
func (s *MetaService) GetCurrentAuthorizedUser(ctx context.Context) (interface{}, error)
type PageInfo ¶
type PageInfo struct { Count int `json:"count,omitempty"` Limit int `json:"limit,omitempty"` Offset int `json:"offset,omitempty"` Total int `json:"total,omitempty"` }
PageInfo holds the pagination information for a Webflow API request
type PublishSiteResponse ¶
type PublishSiteResponse struct {
Queued bool `json:"queued"`
}
type Rate ¶
type Rate struct { // The number of requests per hour the client is currently limited to. Limit int `json:"limit"` // The number of remaining requests the client can make this hour. Remaining int `json:"remaining"` // The time at which the current rate limit will reset. Reset time.Time `json:"reset"` }
Rate represents the rate limit for the current client.
type RateLimitError ¶
type RateLimitError struct { Rate Rate // Rate specifies last known rate limit for the client Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message }
RateLimitError occurs when Webflow returns 403 Forbidden response with a rate limit remaining value of 0.
func (*RateLimitError) Error ¶
func (r *RateLimitError) Error() string
func (*RateLimitError) Is ¶
func (r *RateLimitError) Is(target error) bool
Is returns whether the provided error equals this error.
type Response ¶
type Response struct { *http.Response // These fields provide the page values for paginating through a set of // results. Any or all of these may be set to the zero value for // responses that are not part of a paginated set, or for which there // are no additional pages. // // These fields support what is called "offset pagination" and should // be used with the ListOptions struct. NextPage int PrevPage int FirstPage int LastPage int // Explicitly specify the Rate type so Rate's String() receiver doesn't // propagate to Response. Rate Rate // token's expiration date TokenExpiration time.Time }
Response is a Webflow API response. This wraps the standard http.Response returned from Webflow and provides convenient access to things like pagination links.
type Site ¶
type Site struct { Id string `json:"_id"` CreatedOn time.Time `json:"createdOn"` Name string `json:"name"` ShortName string `json:"shortName"` LastPublished time.Time `json:"lastPublished"` PreviewUrl string `json:"previewUrl"` Timezone string `json:"timezone"` Database string `json:"database"` }
Site models a Webflow API site ref: https://developers.webflow.com/#model
type SitesService ¶
type SitesService service
SitesService handles communication with the meta related methods of the Webflow API.
ref: https://developers.webflow.com/#sites
func (*SitesService) GetSite ¶
GetSite retrieves the specified site ref: https://developers.webflow.com/#get-specific-site
func (*SitesService) ListSites ¶
func (s *SitesService) ListSites(ctx context.Context, opts *ListSitesOptions) ([]*Site, error)
ListSites lists of all sites the provided access token is able to access. ref: https://developers.webflow.com/#list-sites
func (*SitesService) PublishSite ¶
func (s *SitesService) PublishSite(ctx context.Context, siteId string, domains []string) (*PublishSiteResponse, error)
PublishSite publishes a new site ref: https://developers.webflow.com/#publish-site
type WebhooksService ¶
type WebhooksService service
WebhooksService handles communication with the webhooks related methods of the Webflow API.