SnippetsApi snippetsApi = client.getSnippetsApi();
SnippetsApi
Removes your snippet from a Square Online site.
You can call ListSites to get the IDs of the sites that belong to a seller.
Note: Square Online APIs are publicly available as part of an early access program. For more information, see Early access program for Square Online APIs.
CompletableFuture<DeleteSnippetResponse> deleteSnippetAsync(
final String siteId)
Parameter | Type | Tags | Description |
---|---|---|---|
siteId |
String |
Template, Required | The ID of the site that contains the snippet. |
String siteId = "site_id6";
snippetsApi.deleteSnippetAsync(siteId).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Retrieves your snippet from a Square Online site. A site can contain snippets from multiple snippet applications, but you can retrieve only the snippet that was added by your application.
You can call ListSites to get the IDs of the sites that belong to a seller.
Note: Square Online APIs are publicly available as part of an early access program. For more information, see Early access program for Square Online APIs.
CompletableFuture<RetrieveSnippetResponse> retrieveSnippetAsync(
final String siteId)
Parameter | Type | Tags | Description |
---|---|---|---|
siteId |
String |
Template, Required | The ID of the site that contains the snippet. |
String siteId = "site_id6";
snippetsApi.retrieveSnippetAsync(siteId).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Adds a snippet to a Square Online site or updates the existing snippet on the site.
The snippet code is appended to the end of the head
element on every page of the site, except checkout pages. A snippet application can add one snippet to a given site.
You can call ListSites to get the IDs of the sites that belong to a seller.
Note: Square Online APIs are publicly available as part of an early access program. For more information, see Early access program for Square Online APIs.
CompletableFuture<UpsertSnippetResponse> upsertSnippetAsync(
final String siteId,
final UpsertSnippetRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
siteId |
String |
Template, Required | The ID of the site where you want to add or update the snippet. |
body |
UpsertSnippetRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
String siteId = "site_id6";
UpsertSnippetRequest body = new UpsertSnippetRequest.Builder(
new Snippet.Builder(
"<script>var js = 1;</script>"
)
.build()
)
.build();
snippetsApi.upsertSnippetAsync(siteId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});