/*
 * Selling Partner API for Direct Fulfillment Payments
 * The Selling Partner API for Direct Fulfillment Payments provides programmatic access to a direct fulfillment vendor's invoice data.
 *
 * OpenAPI spec version: v1
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */


package com.github.shuaidd.aspi.model.vendor.fulfillment.payment;

import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Monetary and tax details of the charge.
 */

public class ChargeDetails {
  /**
   * Type of charge applied.
   */
  @JsonAdapter(TypeEnum.Adapter.class)
  public enum TypeEnum {
    GIFTWRAP("GIFTWRAP"),

    FULFILLMENT("FULFILLMENT"),

    MARKETINGINSERT("MARKETINGINSERT"),

    PACKAGING("PACKAGING"),

    LOADING("LOADING"),

    FREIGHTOUT("FREIGHTOUT"),

    TAX_COLLECTED_AT_SOURCE("TAX_COLLECTED_AT_SOURCE");

    private String value;

    TypeEnum(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    public static TypeEnum fromValue(String text) {
      for (TypeEnum b : TypeEnum.values()) {
        if (String.valueOf(b.value).equals(text)) {
          return b;
        }
      }
      return null;
    }

    public static class Adapter extends TypeAdapter<TypeEnum> {
      @Override
      public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException {
        jsonWriter.value(enumeration.getValue());
      }

      @Override
      public TypeEnum read(final JsonReader jsonReader) throws IOException {
        String value = jsonReader.nextString();
        return TypeEnum.fromValue(String.valueOf(value));
      }
    }
  }

  @SerializedName("type")
  private TypeEnum type = null;

  @SerializedName("chargeAmount")
  private Money chargeAmount = null;

  @SerializedName("taxDetails")
  private List<TaxDetail> taxDetails = null;

  public ChargeDetails type(TypeEnum type) {
    this.type = type;
    return this;
  }

   /**
   * Type of charge applied.
   * @return type
  **/

  public TypeEnum getType() {
    return type;
  }

  public void setType(TypeEnum type) {
    this.type = type;
  }

  public ChargeDetails chargeAmount(Money chargeAmount) {
    this.chargeAmount = chargeAmount;
    return this;
  }

   /**
   * Get chargeAmount
   * @return chargeAmount
  **/

  public Money getChargeAmount() {
    return chargeAmount;
  }

  public void setChargeAmount(Money chargeAmount) {
    this.chargeAmount = chargeAmount;
  }

  public ChargeDetails taxDetails(List<TaxDetail> taxDetails) {
    this.taxDetails = taxDetails;
    return this;
  }

  public ChargeDetails addTaxDetailsItem(TaxDetail taxDetailsItem) {
    if (this.taxDetails == null) {
      this.taxDetails = new ArrayList<TaxDetail>();
    }
    this.taxDetails.add(taxDetailsItem);
    return this;
  }

   /**
   * Individual tax details per line item.
   * @return taxDetails
  **/

  public List<TaxDetail> getTaxDetails() {
    return taxDetails;
  }

  public void setTaxDetails(List<TaxDetail> taxDetails) {
    this.taxDetails = taxDetails;
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ChargeDetails chargeDetails = (ChargeDetails) o;
    return Objects.equals(this.type, chargeDetails.type) &&
        Objects.equals(this.chargeAmount, chargeDetails.chargeAmount) &&
        Objects.equals(this.taxDetails, chargeDetails.taxDetails);
  }

  @Override
  public int hashCode() {
    return Objects.hash(type, chargeAmount, taxDetails);
  }


  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ChargeDetails {\n");

    sb.append("    type: ").append(toIndentedString(type)).append("\n");
    sb.append("    chargeAmount: ").append(toIndentedString(chargeAmount)).append("\n");
    sb.append("    taxDetails: ").append(toIndentedString(taxDetails)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

}

