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.anon.api.AccessApi Maven / Gradle / Ivy
package com.tinypass.client.anon.api;
import com.tinypass.client.common.*;
import com.tinypass.client.anon.model.AccessDTO;
import java.util.*;
import java.math.*;
import java.io.*;
public class AccessApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public AccessApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public AccessApi(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 check
*/
public class checkRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public checkRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public checkRequest rid(String rid) {
setQueryParam(this.queryParams, "rid", rid);
return this;
}
public checkRequest aid(String aid) {
setQueryParam(this.queryParams, "aid", aid);
return this;
}
public checkRequest tpAccessTokenV2(String tpAccessTokenV2) {
setQueryParam(this.queryParams, "tp_access_token_v2", tpAccessTokenV2);
return this;
}
public checkRequest umc(String umc) {
setQueryParam(this.queryParams, "umc", umc);
return this;
}
public checkRequest crossApp(Boolean crossApp) {
setQueryParam(this.queryParams, "cross_app", crossApp);
return this;
}
public checkRequest userToken(String userToken) {
setQueryParam(this.queryParams, "user_token", userToken);
return this;
}
public checkRequest userProvider(String userProvider) {
setQueryParam(this.queryParams, "user_provider", userProvider);
return this;
}
public checkRequest userRef(String userRef) {
setQueryParam(this.queryParams, "user_ref", userRef);
return this;
}
public AccessDTO execute() throws ApiException{
String path = "/access/check".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"",
AccessDTO.class);
}
}
/**
* Helper method to create a new request.
*/
public checkRequest checkRequest(){
return new checkRequest(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.queryParams, "aid", aid);
return this;
}
public listRequest active(Boolean active) {
setQueryParam(this.queryParams, "active", active);
return this;
}
public listRequest expandBundled(Boolean expandBundled) {
setQueryParam(this.queryParams, "expand_bundled", expandBundled);
return this;
}
public listRequest crossApp(Boolean crossApp) {
setQueryParam(this.queryParams, "cross_app", crossApp);
return this;
}
public listRequest offset(Integer offset) {
setQueryParam(this.queryParams, "offset", offset);
return this;
}
public listRequest limit(Integer limit) {
setQueryParam(this.queryParams, "limit", limit);
return this;
}
public listRequest userToken(String userToken) {
setQueryParam(this.queryParams, "user_token", userToken);
return this;
}
public listRequest userProvider(String userProvider) {
setQueryParam(this.queryParams, "user_provider", userProvider);
return this;
}
public listRequest userRef(String userRef) {
setQueryParam(this.queryParams, "user_ref", userRef);
return this;
}
public PageList execute() throws ApiException{
String path = "/access/list".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"array",
AccessDTO.class);
}
}
/**
* Helper method to create a new request.
*/
public listRequest listRequest(){
return new listRequest(headerParams);
}
}