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.PublisherScheduleApi Maven / Gradle / Ivy
package com.tinypass.client.publisher.api;
import com.tinypass.client.common.*;
import com.tinypass.client.publisher.model.Schedule;
import com.tinypass.client.publisher.model.Term;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherScheduleApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherScheduleApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherScheduleApi(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 name(String name) {
setQueryParam(this.formParams, "name", name);
return this;
}
public Schedule execute() throws ApiException{
String path = "/publisher/schedule/create".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Schedule.class);
}
}
/**
* Helper method to create a new request.
*/
public createRequest createRequest(){
return new createRequest(headerParams);
}
/**
* API Request for delete
*/
public class deleteRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public deleteRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public deleteRequest scheduleId(String scheduleId) {
setQueryParam(this.formParams, "schedule_id", scheduleId);
return this;
}
public void execute() throws ApiException{
String path = "/publisher/schedule/delete".replaceAll("\\{format\\}","json");
getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
null,
null);
}
}
/**
* Helper method to create a new request.
*/
public deleteRequest deleteRequest(){
return new deleteRequest(headerParams);
}
/**
* API Request for get
*/
public class getRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public getRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public getRequest scheduleId(String scheduleId) {
setQueryParam(this.formParams, "schedule_id", scheduleId);
return this;
}
public Schedule execute() throws ApiException{
String path = "/publisher/schedule/get".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Schedule.class);
}
}
/**
* Helper method to create a new request.
*/
public getRequest getRequest(){
return new getRequest(headerParams);
}
/**
* API Request for list
*/
public class listRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public listRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public listRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public listRequest orderBy(String orderBy) {
setQueryParam(this.formParams, "order_by", orderBy);
return this;
}
public listRequest orderDirection(String orderDirection) {
setQueryParam(this.formParams, "order_direction", orderDirection);
return this;
}
public listRequest q(String q) {
setQueryParam(this.formParams, "q", q);
return this;
}
public listRequest offset(Integer offset) {
setQueryParam(this.formParams, "offset", offset);
return this;
}
public listRequest limit(Integer limit) {
setQueryParam(this.formParams, "limit", limit);
return this;
}
public PageList execute() throws ApiException{
String path = "/publisher/schedule/list".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"array",
Schedule.class);
}
}
/**
* Helper method to create a new request.
*/
public listRequest listRequest(){
return new listRequest(headerParams);
}
/**
* API Request for terms
*/
public class termsRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public termsRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public termsRequest scheduleId(String scheduleId) {
setQueryParam(this.formParams, "schedule_id", scheduleId);
return this;
}
public termsRequest orderBy(String orderBy) {
setQueryParam(this.formParams, "order_by", orderBy);
return this;
}
public termsRequest orderDirection(String orderDirection) {
setQueryParam(this.formParams, "order_direction", orderDirection);
return this;
}
public termsRequest q(String q) {
setQueryParam(this.formParams, "q", q);
return this;
}
public termsRequest offset(Integer offset) {
setQueryParam(this.formParams, "offset", offset);
return this;
}
public termsRequest limit(Integer limit) {
setQueryParam(this.formParams, "limit", limit);
return this;
}
public PageList execute() throws ApiException{
String path = "/publisher/schedule/terms".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"array",
Term.class);
}
}
/**
* Helper method to create a new request.
*/
public termsRequest termsRequest(){
return new termsRequest(headerParams);
}
/**
* API Request for update
*/
public class updateRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public updateRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public updateRequest scheduleId(String scheduleId) {
setQueryParam(this.formParams, "schedule_id", scheduleId);
return this;
}
public updateRequest name(String name) {
setQueryParam(this.formParams, "name", name);
return this;
}
public Schedule execute() throws ApiException{
String path = "/publisher/schedule/update".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Schedule.class);
}
}
/**
* Helper method to create a new request.
*/
public updateRequest updateRequest(){
return new updateRequest(headerParams);
}
}