Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.squareup.square.api;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.squareup.square.ApiHelper;
import com.squareup.square.AuthManager;
import com.squareup.square.Configuration;
import com.squareup.square.exceptions.ApiException;
import com.squareup.square.http.Headers;
import com.squareup.square.http.client.HttpCallback;
import com.squareup.square.http.client.HttpClient;
import com.squareup.square.http.client.HttpContext;
import com.squareup.square.http.request.HttpRequest;
import com.squareup.square.http.response.HttpResponse;
import com.squareup.square.http.response.HttpStringResponse;
import com.squareup.square.models.DeleteSnippetResponse;
import com.squareup.square.models.RetrieveSnippetResponse;
import com.squareup.square.models.UpsertSnippetRequest;
import com.squareup.square.models.UpsertSnippetResponse;
import java.io.IOException;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* This class lists all the endpoints of the groups.
*/
public final class DefaultSnippetsApi extends BaseApi implements SnippetsApi {
/**
* Initializes the controller.
* @param config Configurations added in client.
* @param httpClient Send HTTP requests and read the responses.
* @param authManagers Apply authorization to requests.
*/
public DefaultSnippetsApi(Configuration config, HttpClient httpClient,
Map authManagers) {
super(config, httpClient, authManagers);
}
/**
* Initializes the controller with HTTPCallback.
* @param config Configurations added in client.
* @param httpClient Send HTTP requests and read the responses.
* @param authManagers Apply authorization to requests.
* @param httpCallback Callback to be called before and after the HTTP call.
*/
public DefaultSnippetsApi(Configuration config, HttpClient httpClient,
Map authManagers, HttpCallback httpCallback) {
super(config, httpClient, authManagers, httpCallback);
}
/**
* Removes your snippet from a Square Online site. You can call [ListSites]($e/Sites/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](https://developer.squareup.com/docs/online-api#early-access-program-for-square-online-apis).
* @param siteId Required parameter: The ID of the site that contains the snippet.
* @return Returns the DeleteSnippetResponse response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public DeleteSnippetResponse deleteSnippet(
final String siteId) throws ApiException, IOException {
HttpRequest request = buildDeleteSnippetRequest(siteId);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleDeleteSnippetResponse(context);
}
/**
* Removes your snippet from a Square Online site. You can call [ListSites]($e/Sites/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](https://developer.squareup.com/docs/online-api#early-access-program-for-square-online-apis).
* @param siteId Required parameter: The ID of the site that contains the snippet.
* @return Returns the DeleteSnippetResponse response from the API call
*/
public CompletableFuture deleteSnippetAsync(
final String siteId) {
return makeHttpCallAsync(() -> buildDeleteSnippetRequest(siteId),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleDeleteSnippetResponse(context));
}
/**
* Builds the HttpRequest object for deleteSnippet.
*/
private HttpRequest buildDeleteSnippetRequest(
final String siteId) {
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/v2/sites/{site_id}/snippet");
//process template parameters
Map> templateParameters = new HashMap<>();
templateParameters.put("site_id",
new SimpleEntry