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.PublisherPromotionApi Maven / Gradle / Ivy
package com.tinypass.client.publisher.api;
import com.tinypass.client.common.*;
import java.math.BigDecimal;
import java.util.Date;
import com.tinypass.client.publisher.model.Promotion;
import java.util.*;
import java.math.*;
import java.io.*;
public class PublisherPromotionApi {
private String basePath = "https://api.piano.io/api/v3";
private String token;
private ApiInvoker apiInvoker = null;
private Map headerParams = new LinkedHashMap();
public PublisherPromotionApi(String basePath, String token) {
this.basePath = basePath;
this.token = token;
}
public PublisherPromotionApi(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 codeExists
*/
public class codeExistsRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public codeExistsRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public codeExistsRequest promotionId(String promotionId) {
setQueryParam(this.formParams, "promotion_id", promotionId);
return this;
}
public codeExistsRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public codeExistsRequest email(String email) {
setQueryParam(this.formParams, "email", email);
return this;
}
public Boolean execute() throws ApiException{
String path = "/publisher/promotion/exists".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Boolean.class);
}
}
/**
* Helper method to create a new request.
*/
public codeExistsRequest codeExistsRequest(){
return new codeExistsRequest(headerParams);
}
/**
* API Request for count
*/
public class countRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public countRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public countRequest aid(String aid) {
setQueryParam(this.queryParams, "aid", aid);
return this;
}
public countRequest expired(String expired) {
setQueryParam(this.queryParams, "expired", expired);
return this;
}
public Long execute() throws ApiException{
String path = "/publisher/promotion/count".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"",
Long.class);
}
}
/**
* Helper method to create a new request.
*/
public countRequest countRequest(){
return new countRequest(headerParams);
}
/**
* 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 createRequest startDate(Date startDate) {
setQueryParam(this.formParams, "start_date", startDate);
return this;
}
public createRequest endDate(Date endDate) {
setQueryParam(this.formParams, "end_date", endDate);
return this;
}
public createRequest newCustomersOnly(Boolean newCustomersOnly) {
setQueryParam(this.formParams, "new_customers_only", newCustomersOnly);
return this;
}
public createRequest discountType(String discountType) {
setQueryParam(this.formParams, "discount_type", discountType);
return this;
}
public createRequest percentageDiscount(BigDecimal percentageDiscount) {
setQueryParam(this.formParams, "percentage_discount", percentageDiscount);
return this;
}
public createRequest unlimitedUses(Boolean unlimitedUses) {
setQueryParam(this.formParams, "unlimited_uses", unlimitedUses);
return this;
}
public createRequest usesAllowed(Integer usesAllowed) {
setQueryParam(this.formParams, "uses_allowed", usesAllowed);
return this;
}
public createRequest neverAllowZero(Boolean neverAllowZero) {
setQueryParam(this.formParams, "never_allow_zero", neverAllowZero);
return this;
}
public createRequest fixedPromotionCode(String fixedPromotionCode) {
setQueryParam(this.formParams, "fixed_promotion_code", fixedPromotionCode);
return this;
}
public createRequest promotionCodePrefix(String promotionCodePrefix) {
setQueryParam(this.formParams, "promotion_code_prefix", promotionCodePrefix);
return this;
}
public createRequest termDependencyType(String termDependencyType) {
setQueryParam(this.formParams, "term_dependency_type", termDependencyType);
return this;
}
public createRequest applyToAllBillingPeriods(Boolean applyToAllBillingPeriods) {
setQueryParam(this.formParams, "apply_to_all_billing_periods", applyToAllBillingPeriods);
return this;
}
public createRequest canBeAppliedOnRenewal(Boolean canBeAppliedOnRenewal) {
setQueryParam(this.formParams, "can_be_applied_on_renewal", canBeAppliedOnRenewal);
return this;
}
public createRequest billingPeriodLimit(Integer billingPeriodLimit) {
setQueryParam(this.formParams, "billing_period_limit", billingPeriodLimit);
return this;
}
public Promotion execute() throws ApiException{
String path = "/publisher/promotion/create".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Promotion.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 promotionId(String promotionId) {
setQueryParam(this.formParams, "promotion_id", promotionId);
return this;
}
public deleteRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public void execute() throws ApiException{
String path = "/publisher/promotion/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 generateCodes
*/
public class generateCodesRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public generateCodesRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public generateCodesRequest promotionId(String promotionId) {
setQueryParam(this.formParams, "promotion_id", promotionId);
return this;
}
public generateCodesRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public generateCodesRequest fixedPromotionCode(String fixedPromotionCode) {
setQueryParam(this.formParams, "fixed_promotion_code", fixedPromotionCode);
return this;
}
public generateCodesRequest promotionCodePrefix(String promotionCodePrefix) {
setQueryParam(this.formParams, "promotion_code_prefix", promotionCodePrefix);
return this;
}
public generateCodesRequest amount(Long amount) {
setQueryParam(this.formParams, "amount", amount);
return this;
}
public generateCodesRequest assetId(String assetId) {
setQueryParam(this.formParams, "asset_id", assetId);
return this;
}
public Promotion execute() throws ApiException{
String path = "/publisher/promotion/generate".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Promotion.class);
}
}
/**
* Helper method to create a new request.
*/
public generateCodesRequest generateCodesRequest(){
return new generateCodesRequest(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 promotionId(String promotionId) {
setQueryParam(this.queryParams, "promotion_id", promotionId);
return this;
}
public getRequest aid(String aid) {
setQueryParam(this.queryParams, "aid", aid);
return this;
}
public Promotion execute() throws ApiException{
String path = "/publisher/promotion/get".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"",
Promotion.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.queryParams, "aid", aid);
return this;
}
public listRequest expired(String expired) {
setQueryParam(this.queryParams, "expired", expired);
return this;
}
public listRequest orderBy(String orderBy) {
setQueryParam(this.queryParams, "order_by", orderBy);
return this;
}
public listRequest orderDirection(String orderDirection) {
setQueryParam(this.queryParams, "order_direction", orderDirection);
return this;
}
public listRequest q(String q) {
setQueryParam(this.queryParams, "q", q);
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 PageList execute() throws ApiException{
String path = "/publisher/promotion/list".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"array",
Promotion.class);
}
}
/**
* Helper method to create a new request.
*/
public listRequest listRequest(){
return new listRequest(headerParams);
}
/**
* API Request for totalSale
*/
public class totalSaleRequest implements ApiRequest {
Map headerParams;
Map> queryParams = new HashMap<>();
Map> formParams = new HashMap<>();
Object body = null;
public totalSaleRequest(Map headerParams) {
this.headerParams = headerParams;
}
public Map> getPreparedFormParams() {
return Collections.unmodifiableMap(formParams);
}
public totalSaleRequest promotionId(String promotionId) {
setQueryParam(this.queryParams, "promotion_id", promotionId);
return this;
}
public totalSaleRequest aid(String aid) {
setQueryParam(this.queryParams, "aid", aid);
return this;
}
public totalSaleRequest currencyCode(String currencyCode) {
setQueryParam(this.queryParams, "currency_code", currencyCode);
return this;
}
public String execute() throws ApiException{
String path = "/publisher/promotion/total".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "GET", token,
queryParams, null,
headerParams,
formParams,
"",
String.class);
}
}
/**
* Helper method to create a new request.
*/
public totalSaleRequest totalSaleRequest(){
return new totalSaleRequest(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 promotionId(String promotionId) {
setQueryParam(this.formParams, "promotion_id", promotionId);
return this;
}
public updateRequest aid(String aid) {
setQueryParam(this.formParams, "aid", aid);
return this;
}
public updateRequest name(String name) {
setQueryParam(this.formParams, "name", name);
return this;
}
public updateRequest startDate(Date startDate) {
setQueryParam(this.formParams, "start_date", startDate);
return this;
}
public updateRequest endDate(Date endDate) {
setQueryParam(this.formParams, "end_date", endDate);
return this;
}
public updateRequest newCustomersOnly(Boolean newCustomersOnly) {
setQueryParam(this.formParams, "new_customers_only", newCustomersOnly);
return this;
}
public updateRequest discountType(String discountType) {
setQueryParam(this.formParams, "discount_type", discountType);
return this;
}
public updateRequest percentageDiscount(BigDecimal percentageDiscount) {
setQueryParam(this.formParams, "percentage_discount", percentageDiscount);
return this;
}
public updateRequest unlimitedUses(Boolean unlimitedUses) {
setQueryParam(this.formParams, "unlimited_uses", unlimitedUses);
return this;
}
public updateRequest usesAllowed(Integer usesAllowed) {
setQueryParam(this.formParams, "uses_allowed", usesAllowed);
return this;
}
public updateRequest neverAllowZero(Boolean neverAllowZero) {
setQueryParam(this.formParams, "never_allow_zero", neverAllowZero);
return this;
}
public updateRequest fixedPromotionCode(String fixedPromotionCode) {
setQueryParam(this.formParams, "fixed_promotion_code", fixedPromotionCode);
return this;
}
public updateRequest promotionCodePrefix(String promotionCodePrefix) {
setQueryParam(this.formParams, "promotion_code_prefix", promotionCodePrefix);
return this;
}
public updateRequest termDependencyType(String termDependencyType) {
setQueryParam(this.formParams, "term_dependency_type", termDependencyType);
return this;
}
public updateRequest applyToAllBillingPeriods(Boolean applyToAllBillingPeriods) {
setQueryParam(this.formParams, "apply_to_all_billing_periods", applyToAllBillingPeriods);
return this;
}
public updateRequest canBeAppliedOnRenewal(Boolean canBeAppliedOnRenewal) {
setQueryParam(this.formParams, "can_be_applied_on_renewal", canBeAppliedOnRenewal);
return this;
}
public updateRequest billingPeriodLimit(Integer billingPeriodLimit) {
setQueryParam(this.formParams, "billing_period_limit", billingPeriodLimit);
return this;
}
public Promotion execute() throws ApiException{
String path = "/publisher/promotion/update".replaceAll("\\{format\\}","json");
return getInvoker().invokeAPI(basePath, path, "POST", token,
queryParams, null,
headerParams,
formParams,
"",
Promotion.class);
}
}
/**
* Helper method to create a new request.
*/
public updateRequest updateRequest(){
return new updateRequest(headerParams);
}
}