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

com.tinypass.client.publisher.api.PublisherInquiryApi 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 com.tinypass.client.publisher.model.CommentAction;
import com.tinypass.client.publisher.model.InquiryComment;
import com.tinypass.client.publisher.model.PaymentInquiry;

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

public class PublisherInquiryApi {

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

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

	public PublisherInquiryApi(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 addComment
      */
	public class addCommentRequest implements ApiRequest {

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

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

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

		public addCommentRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public addCommentRequest paymentInquiryId(String paymentInquiryId) {
            setQueryParam(this.queryParams, "payment_inquiry_id", paymentInquiryId);
			return this;
		}
		public addCommentRequest action(List action) {
            setQueryParam(this.queryParams, "action", action);
			return this;
		}
		public addCommentRequest comment(String comment) {
            setQueryParam(this.queryParams, "comment", comment);
			return this;
		}
		public addCommentRequest internal(Boolean internal) {
            setQueryParam(this.queryParams, "internal", internal);
			return this;
		}






		public PaymentInquiry  execute() throws ApiException{

			String path = "/publisher/inquiry/add".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for comments
      */
	public class commentsRequest implements ApiRequest {

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

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

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

		public commentsRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public commentsRequest paymentInquiryId(String paymentInquiryId) {
            setQueryParam(this.queryParams, "payment_inquiry_id", paymentInquiryId);
			return this;
		}






		public PageList  execute() throws ApiException{

			String path = "/publisher/inquiry/comments".replaceAll("\\{format\\}","json");

			return getInvoker().invokeAPI(basePath, path, "GET", token,
                                                     queryParams, null,
                                                     headerParams,
                                                     formParams,
                                                     "array",
                                                     InquiryComment.class);
		}

	}


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



    /**
      * API Request for details
      */
	public class detailsRequest implements ApiRequest {

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

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

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

		public detailsRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public detailsRequest paymentInquiryId(String paymentInquiryId) {
            setQueryParam(this.queryParams, "payment_inquiry_id", paymentInquiryId);
			return this;
		}






		public PaymentInquiry  execute() throws ApiException{

			String path = "/publisher/inquiry/details".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for getInquiryActions
      */
	public class getInquiryActionsRequest implements ApiRequest {

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

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

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

		public getInquiryActionsRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public getInquiryActionsRequest paymentInquiryId(String paymentInquiryId) {
            setQueryParam(this.queryParams, "payment_inquiry_id", paymentInquiryId);
			return this;
		}






		public PageList  execute() throws ApiException{

			String path = "/publisher/inquiry/inquiryActions".replaceAll("\\{format\\}","json");

			return getInvoker().invokeAPI(basePath, path, "GET", token,
                                                     queryParams, null,
                                                     headerParams,
                                                     formParams,
                                                     "array",
                                                     CommentAction.class);
		}

	}


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



    /**
      * API Request for lastComment
      */
	public class lastCommentRequest implements ApiRequest {

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

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

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

		public lastCommentRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public lastCommentRequest uid(String uid) {
            setQueryParam(this.queryParams, "uid", uid);
			return this;
		}






		public PaymentInquiry  execute() throws ApiException{

			String path = "/publisher/inquiry/lastComment".replaceAll("\\{format\\}","json");

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

	}


    /**
      * Helper method to create a new request.
      */
	public lastCommentRequest lastCommentRequest(){
		return new lastCommentRequest(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 uid(String uid) {
            setQueryParam(this.queryParams, "uid", uid);
			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/inquiry/list".replaceAll("\\{format\\}","json");

			return getInvoker().invokeAPI(basePath, path, "GET", token,
                                                     queryParams, null,
                                                     headerParams,
                                                     formParams,
                                                     "array",
                                                     PaymentInquiry.class);
		}

	}


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



    /**
      * API Request for unresolvedCount
      */
	public class unresolvedCountRequest implements ApiRequest {

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

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

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

		public unresolvedCountRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public unresolvedCountRequest uid(String uid) {
            setQueryParam(this.queryParams, "uid", uid);
			return this;
		}






		public Integer  execute() throws ApiException{

			String path = "/publisher/inquiry/unresolvedCount".replaceAll("\\{format\\}","json");

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

	}


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




}