package com.amazon.ads.ema.api.model;

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

import java.util.ArrayList;
import java.util.List;

/**
 * Result for getTimezoneList API
 */
public class TimezoneListResult implements Parcelable {
    public static final Creator<TimezoneListResult> CREATOR = new Creator<TimezoneListResult>() {
        @Override
        public TimezoneListResult createFromParcel(Parcel in) {
            return new TimezoneListResult(in);
        }

        @Override
        public TimezoneListResult[] newArray(int size) {
            return new TimezoneListResult[size];
        }
    };
    public int code;                    // Status code
    public String message;              // Status message
    public String timestamp;            // ISO 8601 timestamp
    public String currentTimezoneId;    // Current device timezone ID
    public List<TimezoneInfo> timezones; // List of available timezones

    public TimezoneListResult() {
        timezones = new ArrayList<>();
    }

    protected TimezoneListResult(Parcel in) {
        code = in.readInt();
        message = in.readString();
        timestamp = in.readString();
        currentTimezoneId = in.readString();
        timezones = in.createTypedArrayList(TimezoneInfo.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(code);
        dest.writeString(message);
        dest.writeString(timestamp);
        dest.writeString(currentTimezoneId);
        dest.writeTypedList(timezones);
    }

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