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.PublisherTermChangeApi Maven / Gradle / Ivy
package com.tinypass.client.publisher.api;
import com.tinypass.client.common.*;
import com.tinypass.client.publisher.model.SubscriptionUpgradeStatus;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherTermChangeApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherTermChangeApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherTermChangeApi(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 canChangeTerm
*/
public class canChangeTermRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public canChangeTermRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public canChangeTermRequest subscriptionId(String subscriptionId) {
setQueryParam(this.formParams, "subscription_id", subscriptionId);
return this;
}
public Boolean execute() throws ApiException{
String path = "/publisher/term/change/can".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Boolean.class);
}
}
/**
* Helper method to create a new request.
*/
public canChangeTermRequest canChangeTermRequest(){
return new canChangeTermRequest(headerParams);
}
/**
* API Request for cancel
*/
public class cancelRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public cancelRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public cancelRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public cancelRequest subscriptionFrom(String subscriptionFrom) {
setQueryParam(this.formParams, "subscription_from", subscriptionFrom);
return this;
}
public Boolean execute() throws ApiException{
String path = "/publisher/term/change/cancel".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Boolean.class);
}
}
/**
* Helper method to create a new request.
*/
public cancelRequest cancelRequest(){
return new cancelRequest(headerParams);
}
/**
* API Request for change
*/
public class changeRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public changeRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public changeRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public changeRequest uid(String uid) {
setQueryParam(this.formParams, "uid", uid);
return this;
}
public changeRequest subscriptionFrom(String subscriptionFrom) {
setQueryParam(this.formParams, "subscription_from", subscriptionFrom);
return this;
}
public changeRequest termTo(String termTo) {
setQueryParam(this.formParams, "term_to", termTo);
return this;
}
public changeRequest termToPeriodId(String termToPeriodId) {
setQueryParam(this.formParams, "term_to_period_id", termToPeriodId);
return this;
}
public changeRequest billingTiming(String billingTiming) {
setQueryParam(this.formParams, "billing_timing", billingTiming);
return this;
}
public changeRequest immediateAccess(Boolean immediateAccess) {
setQueryParam(this.formParams, "immediate_access", immediateAccess);
return this;
}
public changeRequest prorateAccess(Boolean prorateAccess) {
setQueryParam(this.formParams, "prorate_access", prorateAccess);
return this;
}
public changeRequest sharedAccounts(String sharedAccounts) {
setQueryParam(this.formParams, "shared_accounts", sharedAccounts);
return this;
}
public changeRequest userAddress(String userAddress) {
setQueryParam(this.formParams, "user_address", userAddress);
return this;
}
public Boolean execute() throws ApiException{
String path = "/publisher/term/change/do".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Boolean.class);
}
}
/**
* Helper method to create a new request.
*/
public changeRequest changeRequest(){
return new changeRequest(headerParams);
}
/**
* API Request for getSubscriptionUpgradeStatus
*/
public class getSubscriptionUpgradeStatusRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public getSubscriptionUpgradeStatusRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public getSubscriptionUpgradeStatusRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public getSubscriptionUpgradeStatusRequest uid(String uid) {
setQueryParam(this.formParams, "uid", uid);
return this;
}
public getSubscriptionUpgradeStatusRequest subscriptionId(String subscriptionId) {
setQueryParam(this.formParams, "subscription_id", subscriptionId);
return this;
}
public SubscriptionUpgradeStatus execute() throws ApiException{
String path = "/publisher/term/change/getSubscriptionUpgradeStatus".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
SubscriptionUpgradeStatus.class);
}
}
/**
* Helper method to create a new request.
*/
public getSubscriptionUpgradeStatusRequest getSubscriptionUpgradeStatusRequest(){
return new getSubscriptionUpgradeStatusRequest(headerParams);
}
}