Package com.buttercms
Class ButterCMSClient
java.lang.Object
com.buttercms.ButterCMSClient
- All Implemented Interfaces:
IButterCMSClient
public class ButterCMSClient extends Object implements IButterCMSClient
-
Constructor Summary
Constructors Constructor Description ButterCMSClient(String authToken, boolean preview)Requests made with a missing or invalid token will get a 401 Unauthorized response.ButterCMSClient(String authToken, boolean preview, org.apache.http.client.HttpClient client)Requests made with a missing or invalid token will get a 401 Unauthorized response. -
Method Summary
Modifier and Type Method Description DocumentgetAtom()AuthorResponsegetAuthor(String slug, Map<String,String> queryParameters)Retrieves an author’s informationAuthorsResponsegetAuthors(Map<String,String> queryParameters)Retrieves a list of authorsStringgetAuthToken()CategoriesResponsegetCategories(Map<String,String> queryParameters)Returns a list of blog categories.CategoryResponsegetCategory(String slug, Map<String,String> queryParameters)Retrieves the details of a category<T> CollectionResponse<T>getCollection(String collectionSlug, Map<String,String> queryParameters, Class<T> classType)Returns values for the supplied Collection slug<T> PageResponse<T>getPage(String pageTypeSlug, String pageSlug, Map<String,String> queryParameters, Class<T> classType)Get a single Page using its slug<T> PagesResponse<T>getPages(String pageTypeSlug, Map<String,String> queryParameters, Class<T> classType)Get a list of all pages for a given Page Type using its slug.PostResponsegetPost(String slug)Get your Blog PostPostsResponsegetPosts(Map<String,String> queryParameters)Returns a list of published posts.DocumentgetRSS()<T> PagesResponse<T>getSearchPages(String pageTypeSlug, Map<String,String> queryParameters, Class<T> classType)Get a list of all pages for a given Page Type using its slug.PostsResponsegetSearchPosts(Map<String,String> queryParameters)Returns a list of published posts searched by the given 'query' search term.DocumentgetSiteMap()TagResponsegetTag(String slug, Map<String,String> queryParameters)Retrieves the details of a tagTagsResponsegetTags(Map<String,String> queryParameters)Returns a list of blog tags.voidsetAuthToken(String authToken)sets new auth_token
-
Constructor Details
-
ButterCMSClient
Requests made with a missing or invalid token will get a 401 Unauthorized response. All requests must be made over HTTPS- Parameters:
authToken- ButterCMS auth_token
-
ButterCMSClient
public ButterCMSClient(String authToken, boolean preview, org.apache.http.client.HttpClient client)Requests made with a missing or invalid token will get a 401 Unauthorized response. All requests must be made over HTTPS- Parameters:
authToken- ButterCMS auth_tokenclient- custom HttpClient
-
-
Method Details
-
getAuthToken
- Specified by:
getAuthTokenin interfaceIButterCMSClient- Returns:
- current auth_token
-
setAuthToken
Description copied from interface:IButterCMSClientsets new auth_token- Specified by:
setAuthTokenin interfaceIButterCMSClient- Parameters:
authToken- new auth_token
-
getAuthor
Description copied from interface:IButterCMSClientRetrieves an author’s information- Specified by:
getAuthorin interfaceIButterCMSClient- Parameters:
slug- the slug of the author to be retrieved.queryParameters- query parameters as described in https://buttercms.com/docs/api/#authors- Returns:
- author object
-
getAuthors
Description copied from interface:IButterCMSClientRetrieves a list of authors- Specified by:
getAuthorsin interfaceIButterCMSClient- Parameters:
queryParameters- query parameters as described in https://buttercms.com/docs/api/#authors- Returns:
- a list of authors
-
getCategory
Description copied from interface:IButterCMSClientRetrieves the details of a category- Specified by:
getCategoryin interfaceIButterCMSClient- Parameters:
slug- The slug of the category to be retrievedqueryParameters- query parameters as described in https://buttercms.com/docs/api/#categories- Returns:
- a category object
-
getCategories
Description copied from interface:IButterCMSClientReturns a list of blog categories. You can include each category’s posts using the include=recent_posts query parameter.- Specified by:
getCategoriesin interfaceIButterCMSClient- Parameters:
queryParameters- query parameters as described in https://buttercms.com/docs/api/#categories- Returns:
- an array of categories
-
getPage
public <T> PageResponse<T> getPage(String pageTypeSlug, String pageSlug, Map<String,String> queryParameters, Class<T> classType)Description copied from interface:IButterCMSClientGet a single Page using its slug- Specified by:
getPagein interfaceIButterCMSClient- Parameters:
pageTypeSlug- Use '*'. If limiting to a Page Type, use the Page Type slug.pageSlug- The slug of the page.queryParameters- query parameters as described in https://buttercms.com/docs/api/#get-a-single-pageclassType- Object that Page should be deserialize in to- Returns:
- A single page
-
getPages
public <T> PagesResponse<T> getPages(String pageTypeSlug, Map<String,String> queryParameters, Class<T> classType)Description copied from interface:IButterCMSClientGet a list of all pages for a given Page Type using its slug.- Specified by:
getPagesin interfaceIButterCMSClient- Parameters:
pageTypeSlug- The slug of the type of pages you want to retrievequeryParameters- query parameters as described in https://buttercms.com/docs/api/#get-multiple-pages-(page-type)classType- Object that Page should be deserialize in to- Returns:
- A list of pages
-
getSearchPages
public <T> PagesResponse<T> getSearchPages(String pageTypeSlug, Map<String,String> queryParameters, Class<T> classType)Description copied from interface:IButterCMSClientGet a list of all pages for a given Page Type using its slug.- Specified by:
getSearchPagesin interfaceIButterCMSClient- Parameters:
pageTypeSlug- The slug of the type of pages you want to retrievequeryParameters- query parameters as described in https://buttercms.com/docs/api/#search-pagesclassType- Object that Page should be deserialize in to- Returns:
- A list of pages
-
getCollection
public <T> CollectionResponse<T> getCollection(String collectionSlug, Map<String,String> queryParameters, Class<T> classType)Description copied from interface:IButterCMSClientReturns values for the supplied Collection slug- Specified by:
getCollectionin interfaceIButterCMSClient- Parameters:
collectionSlug- The slug of collectionqueryParameters- query parameters as described in https://buttercms.com/docs/api/#retrieve-a-collectionclassType- Object that Collection item should be deserialize in to- Returns:
- a single collection
-
getPost
Description copied from interface:IButterCMSClientGet your Blog Post- Specified by:
getPostin interfaceIButterCMSClient- Parameters:
slug- The slug of post- Returns:
- a single post
-
getPosts
Description copied from interface:IButterCMSClientReturns a list of published posts. The posts are returned sorted by publish date, with the most recent posts appearing first. The endpoint supports pagination and filtering.- Specified by:
getPostsin interfaceIButterCMSClient- Parameters:
queryParameters- query parameters as described in https://buttercms.com/docs/api/?shell#get-your-blog-posts- Returns:
- a list of posts
-
getSearchPosts
Description copied from interface:IButterCMSClientReturns a list of published posts searched by the given 'query' search term. The posts are returned sorted by publish date, with the most recent posts appearing first. The endpoint supports pagination and filtering.- Specified by:
getSearchPostsin interfaceIButterCMSClient- Parameters:
queryParameters- query parameters as described in https://buttercms.com/docs/api/?shell#search-posts- Returns:
- a list of posts
-
getTag
Description copied from interface:IButterCMSClientRetrieves the details of a tag- Specified by:
getTagin interfaceIButterCMSClient- Parameters:
slug- Unique identifierqueryParameters- query parameters as described in https://buttercms.com/docs/api/?shell#tags- Returns:
- a single tag object
-
getTags
Description copied from interface:IButterCMSClientReturns a list of blog tags. You can incude each tags’s posts using the include=recent_posts query parameter.- Specified by:
getTagsin interfaceIButterCMSClient- Parameters:
queryParameters- query parameters as described in https://buttercms.com/docs/api/?shell#tags- Returns:
- a list of blog tags
-
getSiteMap
- Specified by:
getSiteMapin interfaceIButterCMSClient- Returns:
- site map
-
getRSS
- Specified by:
getRSSin interfaceIButterCMSClient- Returns:
- an RSS feed
-
getAtom
- Specified by:
getAtomin interfaceIButterCMSClient- Returns:
- an ATOM feed
-