package it.near.sdk.reactions.coupon;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import it.near.sdk.morpheusnear.annotations.Relationship;
import it.near.sdk.morpheusnear.Resource;

/**
 * @author cattaneostefano.
 */
public class Claim extends Resource implements Parcelable {
    @SerializedName("serial_number")
    public String serial_number;
    @SerializedName("claimed_at")
    public String claimed_at;
    @SerializedName("redeemed_at")
    public String redeemed_at;
    @Relationship("coupon")
    public Coupon coupon;

    public Claim() {
    }

    public String getSerial_number() {
        return serial_number;
    }

    public void setSerial_number(String serial_number) {
        this.serial_number = serial_number;
    }

    public String getClaimed_at() {
        return claimed_at;
    }

    public void setClaimed_at(String claimed_at) {
        this.claimed_at = claimed_at;
    }

    public String getRedeemed_at() {
        return redeemed_at;
    }

    public void setRedeemed_at(String redeemed_at) {
        this.redeemed_at = redeemed_at;
    }

    public Coupon getCoupon() {
        return coupon;
    }

    public void setCoupon(Coupon coupon) {
        this.coupon = coupon;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(getId());
        dest.writeString(serial_number);
        dest.writeString(claimed_at);
        dest.writeString(redeemed_at);
    }

    public static final Creator<Claim> CREATOR = new Creator<Claim>() {
        @Override
        public Claim createFromParcel(Parcel in) {
            return new Claim(in);
        }

        @Override
        public Claim[] newArray(int size) {
            return new Claim[size];
        }
    };

    protected Claim(Parcel in) {
        setId(in.readString());
        serial_number = in.readString();
        claimed_at = in.readString();
        redeemed_at = in.readString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Claim claim = (Claim) o;

        if (serial_number != null ? !serial_number.equals(claim.serial_number) : claim.serial_number != null)
            return false;
        if (claimed_at != null ? !claimed_at.equals(claim.claimed_at) : claim.claimed_at != null)
            return false;
        return redeemed_at != null ? redeemed_at.equals(claim.redeemed_at) : claim.redeemed_at == null;

    }

    @Override
    public int hashCode() {
        int result = serial_number != null ? serial_number.hashCode() : 0;
        result = 31 * result + (claimed_at != null ? claimed_at.hashCode() : 0);
        result = 31 * result + (redeemed_at != null ? redeemed_at.hashCode() : 0);
        return result;
    }
}

@@ -534,24 +534,86 @@
 edeemed_at;%0A
+    @SerializedName(%22recipe_id%22)%0A    public String recipe_id;%0A
     @Relatio
@@ -628,16 +628,16 @@
 oupon%22)%0A
-
     publ
@@ -1339,32 +1339,192 @@
  coupon;%0A    %7D%0A%0A
+    public String getRecipe_id() %7B%0A        return recipe_id;%0A    %7D%0A%0A    public void setRecipe_id(String recipe_id) %7B%0A        this.recipe_id = recipe_id;%0A    %7D%0A%0A
     @Override%0A  
@@ -1801,24 +1801,61 @@
 deemed_at);%0A
+        dest.writeString(recipe_id);%0A
     %7D%0A%0A    p
@@ -2334,23 +2334,61 @@
 ring();%0A
+        recipe_id = in.readString();%0A
     %7D%0A%0A
+%0A
     @Ove
@@ -2829,39 +2829,36 @@
  false;%0A        
-return 
+if (
 redeemed_at != n
@@ -2855,32 +2855,33 @@
 ed_at != null ? 
+!
 redeemed_at.equa
@@ -2922,16 +2922,138 @@
 emed_at 
+!= null)%0A            return false;%0A        return recipe_id != null ? recipe_id.equals(claim.recipe_id) : claim.recipe_id 
 == null;
@@ -3251,32 +3251,32 @@
 ashCode() : 0);%0A
-
         result =
@@ -3334,32 +3334,111 @@
 ashCode() : 0);%0A
+        result = 31 * result + (recipe_id != null ? recipe_id.hashCode() : 0);%0A
         return r

add recipe_id in claim object