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

com.tinypass.client.publisher.api.PublisherUserBillingAddressApi 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.UserBillingAddress;

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

public class PublisherUserBillingAddressApi {

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

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

	public PublisherUserBillingAddressApi(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 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 uid(String uid) {
            setQueryParam(this.formParams, "uid", uid);
			return this;
		}
		public createRequest country(String country) {
            setQueryParam(this.formParams, "country", country);
			return this;
		}
		public createRequest region(String region) {
            setQueryParam(this.formParams, "region", region);
			return this;
		}
		public createRequest city(String city) {
            setQueryParam(this.formParams, "city", city);
			return this;
		}
		public createRequest postalCode(String postalCode) {
            setQueryParam(this.formParams, "postal_code", postalCode);
			return this;
		}
		public createRequest addressLine1(String addressLine1) {
            setQueryParam(this.formParams, "address_line1", addressLine1);
			return this;
		}
		public createRequest addressLine2(String addressLine2) {
            setQueryParam(this.formParams, "address_line2", addressLine2);
			return this;
		}
		public createRequest addressLine3(String addressLine3) {
            setQueryParam(this.formParams, "address_line3", addressLine3);
			return this;
		}
		public createRequest type(Integer type) {
            setQueryParam(this.formParams, "type", type);
			return this;
		}





		public UserBillingAddress  execute() throws ApiException{

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

			return getInvoker().invokeAPI(basePath, path, "POST", token,
                                                     queryParams, null,
                                                     headerParams,
                                                     formParams,
                                                     "",
                                                     UserBillingAddress.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 aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public deleteRequest uid(String uid) {
            setQueryParam(this.formParams, "uid", uid);
			return this;
		}
		public deleteRequest addressPubId(String addressPubId) {
            setQueryParam(this.formParams, "address_pub_id", addressPubId);
			return this;
		}





		public UserBillingAddress  execute() throws ApiException{

			String path = "/publisher/user/billingAddress/delete".replaceAll("\\{format\\}","json");

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

	}


    /**
      * Helper method to create a new request.
      */
	public deleteRequest deleteRequest(){
		return new deleteRequest(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 aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public getRequest uid(String uid) {
            setQueryParam(this.formParams, "uid", uid);
			return this;
		}
		public getRequest addressPubId(String addressPubId) {
            setQueryParam(this.formParams, "address_pub_id", addressPubId);
			return this;
		}





		public UserBillingAddress  execute() throws ApiException{

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

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

	}


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



    /**
      * API Request for getByPayment
      */
	public class getByPaymentRequest implements ApiRequest {

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

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

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


		public getByPaymentRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public getByPaymentRequest userPaymentId(String userPaymentId) {
            setQueryParam(this.formParams, "user_payment_id", userPaymentId);
			return this;
		}





		public UserBillingAddress  execute() throws ApiException{

			String path = "/publisher/user/billingAddress/getByPayment".replaceAll("\\{format\\}","json");

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

	}


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



    /**
      * API Request for getByPaymentInfo
      */
	public class getByPaymentInfoRequest implements ApiRequest {

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

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

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


		public getByPaymentInfoRequest aid(String aid) {
            setQueryParam(this.formParams, "aid", aid);
			return this;
		}
		public getByPaymentInfoRequest userPaymentInfoId(String userPaymentInfoId) {
            setQueryParam(this.formParams, "user_payment_info_id", userPaymentInfoId);
			return this;
		}





		public UserBillingAddress  execute() throws ApiException{

			String path = "/publisher/user/billingAddress/getByPaymentInfo".replaceAll("\\{format\\}","json");

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

	}


    /**
      * Helper method to create a new request.
      */
	public getByPaymentInfoRequest getByPaymentInfoRequest(){
		return new getByPaymentInfoRequest(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.formParams, "aid", aid);
			return this;
		}
		public listRequest uid(String uid) {
            setQueryParam(this.formParams, "uid", uid);
			return this;
		}





		public PageList  execute() throws ApiException{

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

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

	}


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




}