public class Api extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Api.ApiData |
static class |
Api.Error |
| Constructor and Description |
|---|
Api(Api.ApiData apiData,
String accessToken,
Cache cache,
Logger logger)
Deprecated.
|
Api(Api.ApiData apiData,
String accessToken,
String defaultReference,
Cache cache,
Logger logger)
Constructor to build a proper
Api object. |
| Modifier and Type | Method and Description |
|---|---|
static Api |
get(String url)
Entry point to get an
Api object. |
static Api |
get(String url,
Cache cache,
Logger logger) |
static Api |
get(String url,
String accessToken)
Entry point to get an
Api object. |
static Api |
get(String endpoint,
String accessToken,
Cache cache,
Logger logger) |
static Api |
get(String url,
String accessToken,
String defaultReference)
Entry point to get an
Api object. |
static Api |
get(String endpoint,
String accessToken,
String defaultReference,
Cache cache,
Logger logger)
Entry point to get an
Api object. |
String |
getAccessToken() |
Document |
getBookmark(String bookmark) |
Document |
getBookmark(String bookmark,
String ref) |
Map<String,String> |
getBookmarks()
From a properly built
Api object, returns the map associating the bookmark names to their document IDs. |
Document |
getByID(String documentId)
Retrieve a document by its ID on the master reference
|
Document |
getByID(String documentId,
String ref)
Retrieve a document by its ID on the given reference
|
Form.SearchForm |
getByIDs(Iterable<String> ids)
Retrieve multiple documents from their IDS
|
Document |
getByUID(String documentType,
String documentUid)
Retrieve a document by its UID on the master reference
|
Document |
getByUID(String documentType,
String documentUid,
String ref)
Retrieve a document by its UID on the given reference
|
Cache |
getCache() |
Experiments |
getExperiments()
Return the current experiments on the repository
|
Form.SearchForm |
getForm(String form)
From a properly built
Api object, return a Form object that will allow to perform queries. |
Map<String,String> |
getFormNames()
From a properly built
Api object, returns the Map of available form names. |
Logger |
getLogger() |
Ref |
getMaster()
From a properly built
Api object, returns the ref ID (points in a prismic.io repository's timeline,
whether in the past, in the present, or in the future) of the master ref (the one presently live). |
String |
getOAuthInitiateEndpoint() |
String |
getOAuthTokenEndpoint() |
Ref |
getRef(String label)
From a properly built
Api object, returns the ref with the corresponding label |
List<Ref> |
getRefs()
From a properly built
Api object, returns the ref IDs (points in a prismic.io repository's timeline,
whether in the past, in the present, or in the future) to which the passed credentials give access. |
List<String> |
getTags()
From a properly built
Api object, returns the list of available tags. |
Map<String,String> |
getTypes()
From a properly built
Api object, returns the map associating the type names to their readable text. |
static String |
getVersion() |
String |
previewSession(String token,
LinkResolver linkResolver,
String defaultUrl)
Return the URL to display a given preview
|
Form.SearchForm |
query()
Start a query defaulting on the master reference (you can still override it)
|
Form.SearchForm |
query(Predicate... predicates)
Start a query defaulting on the master reference (you can still override it)
|
Form.SearchForm |
query(String q)
Start a query defaulting on the master reference (you can still override it)
|
Document |
queryFirst(Predicate p) |
Document |
queryFirst(Predicate p,
String ref)
Return the first document matching the predicate
|
public Api(Api.ApiData apiData, String accessToken, String defaultReference, Cache cache, Logger logger)
Api object. This is not to build an Api object
from an Api endpoint (the most usual case). In this case, you'll use the API.get method.apiData - the data retrieved from the API document, ready to be stored in memoryaccessToken - Your Oauth access token if you wish to use one (to access future content releases, for instance)defaultReference - The default reference to use with queries. Will default to master if nullcache - instance of a class that implements the Cache interface, and will handle the cachelogger - instance of a class that implements the Logger interface, and will handle the logging@Deprecated public Api(Api.ApiData apiData, String accessToken, Cache cache, Logger logger)
public static String getVersion()
public static Api get(String endpoint, String accessToken, String defaultReference, Cache cache, Logger logger)
Api object.
Example: API api = API.get("https://lesbonneschoses.prismic.io/api", null, new Cache.BuiltInCache(999), new Logger.PrintlnLogger());endpoint - the endpoint of your prismic.io content repository, typically https://yourrepoid.prismic.io/apiaccessToken - Your Oauth access token if you wish to use one (to access future content releases, for instance)defaultReference - The default reference to use with queries. Will default to master if nullcache - instance of a class that implements the Cache interface, and will handle the cachelogger - instance of a class that implements the Logger interface, and will handle the loggingpublic static Api get(String url, String accessToken, String defaultReference)
Api object.
Example: API api = API.get("https://lesbonneschoses.prismic.io/api", null);url - the endpoint of your prismic.io content repository, typically https://yourrepoid.prismic.io/apiaccessToken - Your Oauth access token if you wish to use one (to access future content releases, for instance)public static Api get(String url, String accessToken)
Api object.
Example: API api = API.get("https://lesbonneschoses.prismic.io/api", null);url - the endpoint of your prismic.io content repository, typically https://yourrepoid.prismic.io/apiaccessToken - Your Oauth access token if you wish to use one (to access future content releases, for instance)public static Api get(String url)
Api object.
Example: API api = API.get("https://lesbonneschoses.prismic.io/api");url - the endpoint of your prismic.io content repository, typically https://yourrepoid.prismic.io/apipublic Logger getLogger()
public String getAccessToken()
public Cache getCache()
public List<Ref> getRefs()
Api object, returns the ref IDs (points in a prismic.io repository's timeline,
whether in the past, in the present, or in the future) to which the passed credentials give access.public Ref getRef(String label)
Api object, returns the ref with the corresponding labellabel - the ref label as defined in the Writing Roompublic Map<String,String> getBookmarks()
Api object, returns the map associating the bookmark names to their document IDs.
Therefore, to get a bookmarked document's ID, it will look like this: api.getBookmarks().get("home")public Map<String,String> getTypes()
Api object, returns the map associating the type names to their readable text.
Therefore, to get a type's readable text, it will look like this: api.getTypes().get("blog")public List<String> getTags()
Api object, returns the list of available tags.
Therefore, to get all available tags, it will look like this: api.getTags()public Map<String,String> getFormNames()
Api object, returns the Map of available form names.public Form.SearchForm getForm(String form)
Api object, return a Form object that will allow to perform queries.
Currently, all the forms offered by prismic.io are SearchForms, but this will change.
To use it: api.get("everything").query(.....)......form - the name of the form to query onForm.SearchFormpublic Experiments getExperiments()
public Ref getMaster()
Api object, returns the ref ID (points in a prismic.io repository's timeline,
whether in the past, in the present, or in the future) of the master ref (the one presently live).public Form.SearchForm query()
public Form.SearchForm query(String q)
public Form.SearchForm query(Predicate... predicates)
public Form.SearchForm getByIDs(Iterable<String> ids)
public Document queryFirst(Predicate p, String ref)
public Document getByID(String documentId, String ref)
public Document getByID(String documentId)
public Document getByUID(String documentType, String documentUid, String ref)
public Document getByUID(String documentType, String documentUid)
public String previewSession(String token, LinkResolver linkResolver, String defaultUrl)
token - as received from Prismic server to identify the content to previewlinkResolver - the link resolver to build URL for your sitedefaultUrl - the URL to default to return if the preview doesn't correspond to a document
(usually the home page of your site)public String getOAuthInitiateEndpoint()
public String getOAuthTokenEndpoint()
Copyright © 2016. All rights reserved.