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

com.tinypass.client.publisher.api.PublisherLicensingContractUserApi 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.ContractUser;

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

public class PublisherLicensingContractUserApi {

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

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

	public PublisherLicensingContractUserApi(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 createContractUser
      */
	public class createContractUserRequest implements ApiRequest {

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

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

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


		public createContractUserRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public createContractUserRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public createContractUserRequest email(String email) {
            setQueryParam(this.formParams, "email", email);
			return this;
		}
		public createContractUserRequest firstName(String firstName) {
            setQueryParam(this.formParams, "first_name", firstName);
			return this;
		}
		public createContractUserRequest lastName(String lastName) {
            setQueryParam(this.formParams, "last_name", lastName);
			return this;
		}
		public createContractUserRequest contractUserSessionId(String contractUserSessionId) {
            setQueryParam(this.formParams, "contract_user_session_id", contractUserSessionId);
			return this;
		}





		public ContractUser  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for getContractUserList
      */
	public class getContractUserListRequest implements ApiRequest {

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

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

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

		public getContractUserListRequest aid(String aid) {
            setQueryParam(this.queryParams, "aid", aid);
			return this;
		}
		public getContractUserListRequest contractId(String contractId) {
            setQueryParam(this.queryParams, "contract_id", contractId);
			return this;
		}
		public getContractUserListRequest orderBy(String orderBy) {
            setQueryParam(this.queryParams, "order_by", orderBy);
			return this;
		}
		public getContractUserListRequest orderDirection(String orderDirection) {
            setQueryParam(this.queryParams, "order_direction", orderDirection);
			return this;
		}
		public getContractUserListRequest statusList(List statusList) {
            setQueryParam(this.queryParams, "status_list", statusList);
			return this;
		}
		public getContractUserListRequest q(String q) {
            setQueryParam(this.queryParams, "q", q);
			return this;
		}
		public getContractUserListRequest offset(Integer offset) {
            setQueryParam(this.queryParams, "offset", offset);
			return this;
		}
		public getContractUserListRequest limit(Integer limit) {
            setQueryParam(this.queryParams, "limit", limit);
			return this;
		}






		public PageList  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for inviteContractUsers
      */
	public class inviteContractUsersRequest implements ApiRequest {

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

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

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


		public inviteContractUsersRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public inviteContractUsersRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public inviteContractUsersRequest contractUserSessionId(String contractUserSessionId) {
            setQueryParam(this.formParams, "contract_user_session_id", contractUserSessionId);
			return this;
		}





		public void  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for removeAndRevokeContractUser
      */
	public class removeAndRevokeContractUserRequest implements ApiRequest {

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

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

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


		public removeAndRevokeContractUserRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public removeAndRevokeContractUserRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public removeAndRevokeContractUserRequest contractUserId(String contractUserId) {
            setQueryParam(this.formParams, "contract_user_id", contractUserId);
			return this;
		}
		public removeAndRevokeContractUserRequest contractUserSessionId(String contractUserSessionId) {
            setQueryParam(this.formParams, "contract_user_session_id", contractUserSessionId);
			return this;
		}





		public void  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for removeContractUser
      */
	public class removeContractUserRequest implements ApiRequest {

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

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

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


		public removeContractUserRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public removeContractUserRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public removeContractUserRequest contractUserId(String contractUserId) {
            setQueryParam(this.formParams, "contract_user_id", contractUserId);
			return this;
		}





		public void  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for restoreContractUser
      */
	public class restoreContractUserRequest implements ApiRequest {

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

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

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


		public restoreContractUserRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public restoreContractUserRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public restoreContractUserRequest contractUserId(String contractUserId) {
            setQueryParam(this.formParams, "contract_user_id", contractUserId);
			return this;
		}





		public void  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for revokeContractUser
      */
	public class revokeContractUserRequest implements ApiRequest {

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

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

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


		public revokeContractUserRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public revokeContractUserRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public revokeContractUserRequest contractUserId(String contractUserId) {
            setQueryParam(this.formParams, "contract_user_id", contractUserId);
			return this;
		}





		public void  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for updateContractUser
      */
	public class updateContractUserRequest implements ApiRequest {

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

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

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


		public updateContractUserRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public updateContractUserRequest contractId(String contractId) {
            setQueryParam(this.formParams, "contract_id", contractId);
			return this;
		}
		public updateContractUserRequest contractUserId(String contractUserId) {
            setQueryParam(this.formParams, "contract_user_id", contractUserId);
			return this;
		}
		public updateContractUserRequest email(String email) {
            setQueryParam(this.formParams, "email", email);
			return this;
		}
		public updateContractUserRequest firstName(String firstName) {
            setQueryParam(this.formParams, "first_name", firstName);
			return this;
		}
		public updateContractUserRequest lastName(String lastName) {
            setQueryParam(this.formParams, "last_name", lastName);
			return this;
		}
		public updateContractUserRequest contractUserSessionId(String contractUserSessionId) {
            setQueryParam(this.formParams, "contract_user_session_id", contractUserSessionId);
			return this;
		}





		public ContractUser  execute() throws ApiException{

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

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

	}


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




}