Please wait. This can take some minutes ...
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.
com.tinypass.client.publisher.api.PublisherConversionExternalApi Maven / Gradle / Ivy
package com.tinypass.client.publisher.api;
import com.tinypass.client.common.*;
import java.util.Date;
import com.tinypass.client.publisher.model.TermConversion;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherConversionExternalApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherConversionExternalApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherConversionExternalApi(String basePath, String token, ApiInvoker invoker, Map headerParams) {
this(basePath, token);
this.apiInvoker = invoker;
this.headerParams = headerParams;
}
public ApiInvoker getInvoker() {
if(apiInvoker == null) apiInvoker = ApiInvoker.getInstance();
return apiInvoker;
}
public void setApiToken(String token){
this.token = token;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
public String toQueryParam(Object arg) {
if(arg == null)
return null;
if (arg instanceof Date) {
Date date = (Date) arg;
long epochTime = date.getTime() / 1000;
return String.valueOf(epochTime);
} else {
return String.valueOf(arg);
}
}
public void setQueryParam(Map> params, String paramName, Object value) {
List currentValues = params.computeIfAbsent(paramName, k -> new ArrayList<>());
if (value instanceof List) {
List values = (List) value;
values.forEach(o -> addQueryParam(currentValues, o));
} else {
addQueryParam(currentValues, value);
}
}
private void addQueryParam(List currentValues, Object value) {
String v = toQueryParam(value);
if (v != null)
currentValues.add(v);
}
/**
* API Request for externalVerificationCreate
*/
public class externalVerificationCreateRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public externalVerificationCreateRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public externalVerificationCreateRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public externalVerificationCreateRequest termId(String termId) {
setQueryParam(this.formParams, "term_id", termId);
return this;
}
public externalVerificationCreateRequest uid(String uid) {
setQueryParam(this.formParams, "uid", uid);
return this;
}
public externalVerificationCreateRequest fields(String fields) {
setQueryParam(this.formParams, "fields", fields);
return this;
}
public externalVerificationCreateRequest checkValidity(Boolean checkValidity) {
setQueryParam(this.formParams, "check_validity", checkValidity);
return this;
}
public externalVerificationCreateRequest accessTo(Date accessTo) {
setQueryParam(this.formParams, "access_to", accessTo);
return this;
}
public externalVerificationCreateRequest trackingId(String trackingId) {
setQueryParam(this.formParams, "tracking_id", trackingId);
return this;
}
public externalVerificationCreateRequest customParams(String customParams) {
setQueryParam(this.formParams, "custom_params", customParams);
return this;
}
public externalVerificationCreateRequest browserId(String browserId) {
setQueryParam(this.formParams, "browser_id", browserId);
return this;
}
public externalVerificationCreateRequest pageTitle(String pageTitle) {
setQueryParam(this.formParams, "page_title", pageTitle);
return this;
}
public externalVerificationCreateRequest url(String url) {
setQueryParam(this.formParams, "url", url);
return this;
}
public externalVerificationCreateRequest referer(String referer) {
setQueryParam(this.formParams, "referer", referer);
return this;
}
public externalVerificationCreateRequest contentAuthor(String contentAuthor) {
setQueryParam(this.formParams, "content_author", contentAuthor);
return this;
}
public externalVerificationCreateRequest contentCreated(String contentCreated) {
setQueryParam(this.formParams, "content_created", contentCreated);
return this;
}
public externalVerificationCreateRequest contentSection(String contentSection) {
setQueryParam(this.formParams, "content_section", contentSection);
return this;
}
public externalVerificationCreateRequest contentType(String contentType) {
setQueryParam(this.formParams, "content_type", contentType);
return this;
}
public externalVerificationCreateRequest tags(List tags) {
setQueryParam(this.formParams, "tags", tags);
return this;
}
public externalVerificationCreateRequest previousUserSegments(String previousUserSegments) {
setQueryParam(this.formParams, "previous_user_segments", previousUserSegments);
return this;
}
public externalVerificationCreateRequest userState(String userState) {
setQueryParam(this.formParams, "user_state", userState);
return this;
}
public externalVerificationCreateRequest cookieConsents(String cookieConsents) {
setQueryParam(this.formParams, "cookie_consents", cookieConsents);
return this;
}
public TermConversion execute() throws ApiException{
String path = "/publisher/conversion/external/create".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
TermConversion.class);
}
}
/**
* Helper method to create a new request.
*/
public externalVerificationCreateRequest externalVerificationCreateRequest(){
return new externalVerificationCreateRequest(headerParams);
}
}