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

com.tinypass.client.publisher.api.PublisherLicensingLicenseeApi 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.Licensee;

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

public class PublisherLicensingLicenseeApi {

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

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

	public PublisherLicensingLicenseeApi(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 archiveLicensee
      */
	public class archiveLicenseeRequest implements ApiRequest {

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

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

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


		public archiveLicenseeRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public archiveLicenseeRequest licenseeId(String licenseeId) {
            setQueryParam(this.formParams, "licensee_id", licenseeId);
			return this;
		}





		public void  execute() throws ApiException{

			String path = "/publisher/licensing/licensee/archive".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for createLicensee
      */
	public class createLicenseeRequest implements ApiRequest {

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

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

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


		public createLicenseeRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public createLicenseeRequest description(String description) {
            setQueryParam(this.formParams, "description", description);
			return this;
		}
		public createLicenseeRequest managerUids(List managerUids) {
            setQueryParam(this.formParams, "manager_uids", managerUids);
			return this;
		}
		public createLicenseeRequest representatives(String representatives) {
            setQueryParam(this.formParams, "representatives", representatives);
			return this;
		}
		public createLicenseeRequest logoUrl(String logoUrl) {
            setQueryParam(this.formParams, "logo_url", logoUrl);
			return this;
		}
		public createLicenseeRequest name(String name) {
            setQueryParam(this.formParams, "name", name);
			return this;
		}





		public Licensee  execute() throws ApiException{

			String path = "/publisher/licensing/licensee/create".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for getLicensee
      */
	public class getLicenseeRequest implements ApiRequest {

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

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

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

		public getLicenseeRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public getLicenseeRequest licenseeId(String licenseeId) {
            setQueryParam(this.queryParams, "licensee_id", licenseeId);
			return this;
		}






		public Licensee  execute() throws ApiException{

			String path = "/publisher/licensing/licensee/get".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for getLicenseeCount
      */
	public class getLicenseeCountRequest implements ApiRequest {

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

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

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

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






		public Long  execute() throws ApiException{

			String path = "/publisher/licensing/licensee/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 getLicenseeCountRequest getLicenseeCountRequest(){
		return new getLicenseeCountRequest(headerParams);
	}



    /**
      * API Request for getLicenseeList
      */
	public class getLicenseeListRequest implements ApiRequest {

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

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

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

		public getLicenseeListRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public getLicenseeListRequest q(String q) {
            setQueryParam(this.queryParams, "q", q);
			return this;
		}
		public getLicenseeListRequest offset(Integer offset) {
            setQueryParam(this.queryParams, "offset", offset);
			return this;
		}
		public getLicenseeListRequest limit(Integer limit) {
            setQueryParam(this.queryParams, "limit", limit);
			return this;
		}






		public PageList  execute() throws ApiException{

			String path = "/publisher/licensing/licensee/list".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for updateLicensee
      */
	public class updateLicenseeRequest implements ApiRequest {

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

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

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


		public updateLicenseeRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public updateLicenseeRequest licenseeId(String licenseeId) {
            setQueryParam(this.formParams, "licensee_id", licenseeId);
			return this;
		}
		public updateLicenseeRequest description(String description) {
            setQueryParam(this.formParams, "description", description);
			return this;
		}
		public updateLicenseeRequest managerUids(List managerUids) {
            setQueryParam(this.formParams, "manager_uids", managerUids);
			return this;
		}
		public updateLicenseeRequest representatives(String representatives) {
            setQueryParam(this.formParams, "representatives", representatives);
			return this;
		}
		public updateLicenseeRequest logoUrl(String logoUrl) {
            setQueryParam(this.formParams, "logo_url", logoUrl);
			return this;
		}
		public updateLicenseeRequest name(String name) {
            setQueryParam(this.formParams, "name", name);
			return this;
		}





		public Licensee  execute() throws ApiException{

			String path = "/publisher/licensing/licensee/update".replaceAll("\\{format\\}","json");

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

	}


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




}