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.PublisherTermChangeOptionApi Maven / Gradle / Ivy
package com.tinypass.client.publisher.api;
import com.tinypass.client.common.*;
import com.tinypass.client.publisher.model.TermChangeOption;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherTermChangeOptionApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherTermChangeOptionApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherTermChangeOptionApi(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 create
*/
public class createRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public createRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public createRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public createRequest fromTermId(String fromTermId) {
setQueryParam(this.formParams, "from_term_id", fromTermId);
return this;
}
public createRequest toTermId(String toTermId) {
setQueryParam(this.formParams, "to_term_id", toTermId);
return this;
}
public createRequest billingTiming(String billingTiming) {
setQueryParam(this.formParams, "billing_timing", billingTiming);
return this;
}
public createRequest immediateAccess(Boolean immediateAccess) {
setQueryParam(this.formParams, "immediate_access", immediateAccess);
return this;
}
public createRequest prorateAccess(Boolean prorateAccess) {
setQueryParam(this.formParams, "prorate_access", prorateAccess);
return this;
}
public createRequest description(String description) {
setQueryParam(this.formParams, "description", description);
return this;
}
public createRequest toPeriodId(String toPeriodId) {
setQueryParam(this.formParams, "to_period_id", toPeriodId);
return this;
}
public createRequest fromPeriodId(String fromPeriodId) {
setQueryParam(this.formParams, "from_period_id", fromPeriodId);
return this;
}
public TermChangeOption execute() throws ApiException{
String path = "/publisher/term/change/option/create".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
TermChangeOption.class);
}
}
/**
* Helper method to create a new request.
*/
public createRequest createRequest(){
return new createRequest(headerParams);
}
}