package com.sonic.lion.domain.resp;
/**
 * {
 * "status": "CANCELLED",
 * "status_update_time": "2021-08-27T07:50:07Z",
 * "id": "I-5E6A3FRHY0T6",
 * "plan_id": "P-5CJ13061CV159492MMEUFKAA",
 * "start_time": "2021-08-27T07:36:33Z",
 * "quantity": "1",
 * "shipping_amount": {
 * "currency_code": "USD",
 * "value": "0.0"
 * },
 * "subscriber": {
 * "email_address": "hulongcoder@qq.com",
 * "payer_id": "4P3LS3G4JLXZW",
 * "name": {
 * "given_name": "九龙",
 * "surname": "胡"
 * },
 * "shipping_address": {
 * "address": {
 * "address_line_1": "温江区江安路739号",
 * "admin_area_2": "成都市",
 * "admin_area_1": "四川",
 * "postal_code": "610000",
 * "country_code": "C2"
 * }
 * }
 * },
 * "billing_info": {
 * "outstanding_balance": {
 * "currency_code": "USD",
 * "value": "0.0"
 * },
 * "cycle_executions": [
 * {
 * "tenure_type": "REGULAR",
 * "sequence": 1,
 * "cycles_completed": 1,
 * "cycles_remaining": 0,
 * "current_pricing_scheme_version": 1,
 * "total_cycles": 0
 * }
 * ],
 * "last_payment": {
 * "amount": {
 * "currency_code": "USD",
 * "value": "0.02"
 * },
 * "time": "2021-08-27T07:36:48Z"
 * },
 * "failed_payments_count": 0
 * },
 * "create_time": "2021-08-27T07:36:47Z",
 * "update_time": "2021-08-27T07:50:07Z",
 * "plan_overridden": false,
 * "links": [
 * {
 * "href": "https://api.paypal.com/v1/billing/subscriptions/I-5E6A3FRHY0T6",
 * "rel": "self",
 * "method": "GET"
 * }
 * ]
 * }
 */

import com.paypal.http.annotations.Model;
import com.paypal.http.annotations.SerializedName;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@Model
@Data
public class SubscriptionDetailResp {

    @SerializedName("id")
    private String id;
    @SerializedName("status")
    private String status;

    @SerializedName("status_update_time")
    private String status_update_time;

    @SerializedName("plan_id")
    private String plan_id;


    @SerializedName("start_time")
    private String start_time;

    public LocalDateTime getPurchaseDate() {
        String timestring = status_update_time.substring(0, status_update_time.length() - 1);
        ZonedDateTime utcTime = LocalDateTime.parse(timestring, DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss")).atZone(ZoneId.from(ZoneOffset.UTC));
        ZonedDateTime beijingTime = utcTime.withZoneSameInstant(ZoneOffset.ofHours(8));
        return beijingTime.toLocalDateTime();
    }
}