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.id.api.PublisherIdentityApi Maven / Gradle / Ivy
package com.tinypass.client.id.api;
import com.tinypass.client.common.*;
import com.tinypass.client.id.model.PublisherLoginRequest;
import com.tinypass.client.id.model.PublisherPasswordRequest;
import com.tinypass.client.id.model.PublisherRegisterRequest;
import com.tinypass.client.id.model.TokenResponse;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherIdentityApi {
private String basePath = "https://api.piano.io/id/api/v1";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherIdentityApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherIdentityApi(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 createPassword
*/
public class createPasswordRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public createPasswordRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public createPasswordRequest authorization(String authorization) {
this.headerParams.put("Authorization", toQueryParam(authorization));
return this;
}
public createPasswordRequest body(PublisherPasswordRequest body) {
this.body = body;
return this;
}
public createPasswordRequest body(InputStream body) {
this.body = body;
return this;
}
public createPasswordRequest bodyString(String body) {
this.body = body;
return this;
}
public void execute() throws ApiException{
String path = "/publisher/identity/password".replaceAll("\\{format\\}","json");
getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, body,
headerParams,
formParams,
null,
null);
}
}
/**
* Helper method to create a new request.
*/
public createPasswordRequest createPasswordRequest(){
return new createPasswordRequest(headerParams);
}
/**
* API Request for login
*/
public class loginRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public loginRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public loginRequest authorization(String authorization) {
this.headerParams.put("Authorization", toQueryParam(authorization));
return this;
}
public loginRequest body(PublisherLoginRequest body) {
this.body = body;
return this;
}
public loginRequest body(InputStream body) {
this.body = body;
return this;
}
public loginRequest bodyString(String body) {
this.body = body;
return this;
}
public TokenResponse execute() throws ApiException{
String path = "/publisher/identity/login".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, body,
headerParams,
formParams,
"",
TokenResponse.class);
}
}
/**
* Helper method to create a new request.
*/
public loginRequest loginRequest(){
return new loginRequest(headerParams);
}
/**
* API Request for register
*/
public class registerRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public registerRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public registerRequest authorization(String authorization) {
this.headerParams.put("Authorization", toQueryParam(authorization));
return this;
}
public registerRequest body(PublisherRegisterRequest body) {
this.body = body;
return this;
}
public registerRequest body(InputStream body) {
this.body = body;
return this;
}
public registerRequest bodyString(String body) {
this.body = body;
return this;
}
public TokenResponse execute() throws ApiException{
String path = "/publisher/identity/register".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, body,
headerParams,
formParams,
"",
TokenResponse.class);
}
}
/**
* Helper method to create a new request.
*/
public registerRequest registerRequest(){
return new registerRequest(headerParams);
}
}