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

com.sailthru.client.params.Purchase Maven / Gradle / Ivy

There is a newer version: 2.4.1
Show newest version
package com.sailthru.client.params;

import com.google.gson.reflect.TypeToken;
import com.google.gson.annotations.SerializedName;
import com.sailthru.client.ApiAction;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.List;

/**
 *
 * @author Prajwal Tuladhar 
 */
public class Purchase extends AbstractApiParams implements ApiParams {
    protected String email;
    protected List> items;
    protected Integer incomplete;

    @SerializedName("message_id")
    protected String messageId;

    @SerializedName("reminder_template")
    protected String reminderTemplate;

    @SerializedName("reminder_time")
    protected String reminderTime;

    @SerializedName("send_template")
    protected String sendTemplate;

    protected String date;

    protected List> tenders;
    protected List> adjustments;
    protected Map vars;

    public Purchase setEmail(String email) {
        this.email = email;
        return this;
    }

    public Purchase setItems(List items) {
        this.items = new ArrayList>();
        for (PurchaseItem item : items) {
            this.items.add(item.toHashMap());
        }
        return this;
    }

    public Purchase setTenders(List> tenders) {
        this.tenders = tenders;
        return this;
    }

    public Purchase setAdjustments(List> adjustments) {
        this.adjustments = adjustments;
        return this;
    }

    public Purchase setAsIncomplete() {
        this.incomplete = 1;
        return this;
    }

    public Purchase setMessageId(String messageId) {
        this.messageId = messageId;
        return this;
    }

    public Purchase setReminderTemplate(String reminderTemplate) {
        this.reminderTemplate =  reminderTemplate;
        return this;
    }

    public Purchase setReminderTime(Date reminderTime) {
        this.reminderTime = reminderTime.toString();
        return this;
    }

    public Purchase setReminderTime(String reminderTime) {
        this.reminderTime = reminderTime;
        return this;
    }

    public Purchase setDate(Date date) {
        this.date = date.toString();
        return this;
    }

    public Purchase setDate(String date) {
        this.date = date;
        return this;
    }

    public Purchase setSendTemplate(String sendTemplate) {
        this.sendTemplate = sendTemplate;
        return this;
    }

    public Purchase setPurchaseLevelVars(Map vars) {
        this.vars = vars;
        return this;
    }

    public Type getType() {
        Type type = new TypeToken() {}.getType();
        return type;
    }

    @Override
    public ApiAction getApiCall() {
        return ApiAction.purchase;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy