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.PublisherOfferTermApi Maven / Gradle / Ivy
package com.tinypass.client.publisher.api;
import com.tinypass.client.common.*;
import com.tinypass.client.publisher.model.Term;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherOfferTermApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherOfferTermApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherOfferTermApi(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 addTerms
*/
public class addTermsRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public addTermsRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public addTermsRequest offerId(String offerId) {
setQueryParam(this.formParams, "offer_id", offerId);
return this;
}
public addTermsRequest termId(List termId) {
setQueryParam(this.formParams, "term_id", termId);
return this;
}
public void execute() throws ApiException{
String path = "/publisher/offer/term/add".replaceAll("\\{format\\}","json");
getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
null,
null);
}
}
/**
* Helper method to create a new request.
*/
public addTermsRequest addTermsRequest(){
return new addTermsRequest(headerParams);
}
/**
* API Request for listTerms
*/
public class listTermsRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public listTermsRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public listTermsRequest offerId(String offerId) {
setQueryParam(this.queryParams, "offer_id", offerId);
return this;
}
public PageList execute() throws ApiException{
String path = "/publisher/offer/term/list".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"array",
Term.class);
}
}
/**
* Helper method to create a new request.
*/
public listTermsRequest listTermsRequest(){
return new listTermsRequest(headerParams);
}
/**
* API Request for reorderTerms
*/
public class reorderTermsRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public reorderTermsRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public reorderTermsRequest offerId(String offerId) {
setQueryParam(this.formParams, "offer_id", offerId);
return this;
}
public reorderTermsRequest termId(List termId) {
setQueryParam(this.formParams, "term_id", termId);
return this;
}
public void execute() throws ApiException{
String path = "/publisher/offer/term/reorder".replaceAll("\\{format\\}","json");
getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
null,
null);
}
}
/**
* Helper method to create a new request.
*/
public reorderTermsRequest reorderTermsRequest(){
return new reorderTermsRequest(headerParams);
}
/**
* API Request for unlinkTerms
*/
public class unlinkTermsRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public unlinkTermsRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public unlinkTermsRequest offerId(String offerId) {
setQueryParam(this.formParams, "offer_id", offerId);
return this;
}
public unlinkTermsRequest termId(List termId) {
setQueryParam(this.formParams, "term_id", termId);
return this;
}
public void execute() throws ApiException{
String path = "/publisher/offer/term/remove".replaceAll("\\{format\\}","json");
getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
null,
null);
}
}
/**
* Helper method to create a new request.
*/
public unlinkTermsRequest unlinkTermsRequest(){
return new unlinkTermsRequest(headerParams);
}
}