All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinypass.client.publisher.api.PublisherExportCreateSubscriptionDetailsReportApi Maven / Gradle / Ivy

There is a newer version: 16.331.0
Show newest version
package com.tinypass.client.publisher.api;

import com.tinypass.client.common.*;
import java.util.Date;
import com.tinypass.client.publisher.model.Export;

import java.util.*;
import java.math.*;
import java.io.*;

public class PublisherExportCreateSubscriptionDetailsReportApi {

	private String basePath = "https://api.piano.io/api/v3";
	private String token;
	private ApiInvoker apiInvoker = null;
	private Map headerParams = new LinkedHashMap();

	public PublisherExportCreateSubscriptionDetailsReportApi(String basePath, String token) {
		this.basePath = basePath;
		this.token = token;
	}

	public PublisherExportCreateSubscriptionDetailsReportApi(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 createSubscriptionDetailedReportTZ
      */
	public class createSubscriptionDetailedReportTZRequest implements ApiRequest {

        Map headerParams;
        Map> queryParams = new HashMap<>();
        Map> formParams = new HashMap<>();
        Object body = null;

        public createSubscriptionDetailedReportTZRequest(Map headerParams) {
            this.headerParams = headerParams;
        }

        public Map> getPreparedFormParams() {
            return Collections.unmodifiableMap(formParams);
        }


		public createSubscriptionDetailedReportTZRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest exportName(String exportName) {
            setQueryParam(this.formParams, "export_name", exportName);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest q(String q) {
            setQueryParam(this.formParams, "q", q);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchNewSubscriptions(Boolean searchNewSubscriptions) {
            setQueryParam(this.formParams, "search_new_subscriptions", searchNewSubscriptions);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest newSubscriptionsCreatedFrom(Date newSubscriptionsCreatedFrom) {
            setQueryParam(this.formParams, "new_subscriptions_created_from", newSubscriptionsCreatedFrom);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest newSubscriptionsCreatedTo(Date newSubscriptionsCreatedTo) {
            setQueryParam(this.formParams, "new_subscriptions_created_to", newSubscriptionsCreatedTo);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchActiveNowSubscriptions(Boolean searchActiveNowSubscriptions) {
            setQueryParam(this.formParams, "search_active_now_subscriptions", searchActiveNowSubscriptions);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest activeNowSubscriptionsStatuses(List activeNowSubscriptionsStatuses) {
            setQueryParam(this.formParams, "active_now_subscriptions_statuses", activeNowSubscriptionsStatuses);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchInactiveSubscriptions(Boolean searchInactiveSubscriptions) {
            setQueryParam(this.formParams, "search_inactive_subscriptions", searchInactiveSubscriptions);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest inactiveSubscriptionsStatuses(List inactiveSubscriptionsStatuses) {
            setQueryParam(this.formParams, "inactive_subscriptions_statuses", inactiveSubscriptionsStatuses);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsInactiveFrom(Date subscriptionsInactiveFrom) {
            setQueryParam(this.formParams, "subscriptions_inactive_from", subscriptionsInactiveFrom);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsInactiveTo(Date subscriptionsInactiveTo) {
            setQueryParam(this.formParams, "subscriptions_inactive_to", subscriptionsInactiveTo);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchUpdatedSubscriptions(Boolean searchUpdatedSubscriptions) {
            setQueryParam(this.formParams, "search_updated_subscriptions", searchUpdatedSubscriptions);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest updatedSubscriptionsStatuses(List updatedSubscriptionsStatuses) {
            setQueryParam(this.formParams, "updated_subscriptions_statuses", updatedSubscriptionsStatuses);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsUpdatedFrom(Date subscriptionsUpdatedFrom) {
            setQueryParam(this.formParams, "subscriptions_updated_from", subscriptionsUpdatedFrom);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsUpdatedTo(Date subscriptionsUpdatedTo) {
            setQueryParam(this.formParams, "subscriptions_updated_to", subscriptionsUpdatedTo);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchAutoRenewingSubscriptions(Boolean searchAutoRenewingSubscriptions) {
            setQueryParam(this.formParams, "search_auto_renewing_subscriptions", searchAutoRenewingSubscriptions);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsAutoRenewing(Boolean subscriptionsAutoRenewing) {
            setQueryParam(this.formParams, "subscriptions_auto_renewing", subscriptionsAutoRenewing);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchSubscriptionsByNextBillingDate(Boolean searchSubscriptionsByNextBillingDate) {
            setQueryParam(this.formParams, "search_subscriptions_by_next_billing_date", searchSubscriptionsByNextBillingDate);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsNextBillingDateFrom(Date subscriptionsNextBillingDateFrom) {
            setQueryParam(this.formParams, "subscriptions_next_billing_date_from", subscriptionsNextBillingDateFrom);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsNextBillingDateTo(Date subscriptionsNextBillingDateTo) {
            setQueryParam(this.formParams, "subscriptions_next_billing_date_to", subscriptionsNextBillingDateTo);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest searchSubscriptionsByTerms(Boolean searchSubscriptionsByTerms) {
            setQueryParam(this.formParams, "search_subscriptions_by_terms", searchSubscriptionsByTerms);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsTerms(List subscriptionsTerms) {
            setQueryParam(this.formParams, "subscriptions_terms", subscriptionsTerms);
			return this;
		}
		public createSubscriptionDetailedReportTZRequest subscriptionsTermTypes(List subscriptionsTermTypes) {
            setQueryParam(this.formParams, "subscriptions_term_types", subscriptionsTermTypes);
			return this;
		}





		public Export  execute() throws ApiException{

			String path = "/publisher/export/create/subscriptionDetailsReport/v2".replaceAll("\\{format\\}","json");

			return getInvoker().invokeAPI(basePath, path, "POST", token,
                                                     queryParams, null,
                                                     headerParams,
                                                     formParams,
                                                     "",
                                                     Export.class);
		}

	}


    /**
      * Helper method to create a new request.
      */
	public createSubscriptionDetailedReportTZRequest createSubscriptionDetailedReportTZRequest(){
		return new createSubscriptionDetailedReportTZRequest(headerParams);
	}




}