<commit_before>/*
 * Syrup Pay Token Library
 *
 * Copyright (C) 2015 SK PLANET. ALL Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the SK PLANET., Bundang-gu, 264,
 * Pangyo-ro The Planet SK planet co., Ltd., Seongnam-si, Gyeonggi-do, Korea
 * or see https://www.syruppay.co.kr/
 */

package com.skplanet.syruppay.token.claims;

import com.skplanet.syruppay.token.TokenBuilder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 시럽페이 체크아웃을 위한 Claim 정보를 설정한다.
 *
 * @author 임형태
 * @since 1.1
 */
public final class OrderConfigurer<H extends TokenBuilder<H>> extends AbstractTokenConfigurer<OrderConfigurer<H>, H> {
    private int productPrice;
    private String submallName;
    private ProductDeliveryInfo productDeliveryInfo;
    private List<Offer> offerList = new ArrayList<Offer>();
    private List<Loyalty> loyaltyList = new ArrayList<Loyalty>();
    private List<PayConfigurer.ShippingAddress> shippingAddressList = new ArrayList<PayConfigurer.ShippingAddress>();
    private List<MonthlyInstallment> monthlyInstallmentList = new ArrayList<MonthlyInstallment>();

    public List<MonthlyInstallment> getMonthlyInstallmentList() {
        return Collections.unmodifiableList(monthlyInstallmentList);
    }

    public int getProductPrice() {
        return productPrice;
    }

    public String getSubmallName() {
        return submallName;
    }

    public ProductDeliveryInfo getProductDeliveryInfo() {
        return this.productDeliveryInfo;
    }

    public String claimName() {
        return "checkoutInfo";
    }

    public void validRequired() throws Exception {
        if (productPrice <= 0) {
            throw new IllegalArgumentException("product price field couldn't be zero. check yours input value : " + productPrice);
        }
        if (productDeliveryInfo == null) {
            throw new IllegalArgumentException("you should contain ProductDeliveryInfo object.");
        }
        productDeliveryInfo.validRequired();

        for (Offer o : offerList) {
            o.validRequired();
        }
        for (Loyalty l : loyaltyList) {
            l.validRequired();
        }
        for (PayConfigurer.ShippingAddress a : shippingAddressList) {
            a.validRequiredToCheckout();
        }
        for (MonthlyInstallment m : monthlyInstallmentList) {
            m.validRequired();
        }
    }

    public OrderConfigurer<H> withShippingAddresses(PayConfigurer.ShippingAddress... shippingAddress) {
        return withShippingAddresses(Arrays.asList(shippingAddress));
    }

    public OrderConfigurer<H> withShippingAddresses(List<PayConfigurer.ShippingAddress> shippingAddresses) {
        for (PayConfigurer.ShippingAddress a : shippingAddresses) {
            a.validRequiredToCheckout();
        }
        shippingAddressList.addAll(shippingAddresses);
        return this;
    }

    public OrderConfigurer<H> withProductPrice(int productPrice) {
        if (productPrice <= 0) {
            throw new IllegalArgumentException("Cannot be smaller than 0. Check yours input value : " + productPrice);
        }
        this.productPrice = productPrice;
        return this;
    }

    public OrderConfigurer<H> withSubmallName(String submallName) {
        this.submallName = submallName;
        return this;
    }

    public OrderConfigurer<H> withProductDeliveryInfo(ProductDeliveryInfo productDeliveryInfo) {
        this.productDeliveryInfo = productDeliveryInfo;
        return this;
    }

    public OrderConfigurer<H> withOffers(Offer... offer) {
        return withOffers(Arrays.asList(offer));
    }

    public OrderConfigurer<H> withOffers(List<Offer> offers) {
        for (Offer o : offers) {
            o.validRequired();
        }
        this.offerList.addAll(offers);
        return this;
    }

    public OrderConfigurer<H> withLoyalties(Loyalty... loyalty) {
        return withLoyalties(Arrays.asList(loyalty));
    }

    public OrderConfigurer<H> withLoyalties(List<Loyalty> loyalties) {
        for (Loyalty l : loyalties) {
            l.validRequired();
        }
        this.loyaltyList.addAll(loyalties);
        return this;
    }

    public OrderConfigurer<H> withMonthlyInstallment(MonthlyInstallment... monthlyInstallment) {
        return withMonthlyInstallment(Arrays.asList(monthlyInstallment));
    }

    public OrderConfigurer<H> withMonthlyInstallment(List<MonthlyInstallment> monthlyInstallments) {
        for (MonthlyInstallment s : monthlyInstallments) {
            s.validRequired();
        }
        this.monthlyInstallmentList.addAll(monthlyInstallments);
        return this;
    }

    public List<Offer> getOfferList() {
        return Collections.unmodifiableList(offerList);
    }

    public List<Loyalty> getLoyaltyList() {
        return Collections.unmodifiableList(loyaltyList);
    }

    public List<PayConfigurer.ShippingAddress> getShippingAddressList() {
        return Collections.unmodifiableList(shippingAddressList);
    }

    public static enum LoyaltyId {
        POINT_OF_11ST("www.11st.co.kr:point"), MILEAGE_OF_11ST("www.11st.co.kr:mileage"), T_MEMBERSHIP("www.sktmemebership.co.kr"), OK_CASHBAG("www.okcashbag.com");

        private String urn;

        LoyaltyId(String urn) {
            this.urn = urn;
        }

        public String getUrn() {
            return urn;
        }
    }

    public static enum ErrorType {
        MAINTENACE, SYSTEM_ERR;
    }

    public static enum DeliveryRestriction {
        NOT_FAR_AWAY, FAR_AWAY, FAR_FAR_AWAY
    }

    public static enum OfferType {
        DELIVERY_COUPON
    }

    public static enum AcceptType {
        CARD
    }

    public static enum DeliveryType {
        PREPAID, FREE, DIY, QUICK, PAYMENT_ON_DELIVERY
    }
<commit_msg>AcceptType Element 추가 #6 closed<commit_after>/*
 * Syrup Pay Token Library
 *
 * Copyright (C) 2015 SK PLANET. ALL Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the SK PLANET., Bundang-gu, 264,
 * Pangyo-ro The Planet SK planet co., Ltd., Seongnam-si, Gyeonggi-do, Korea
 * or see https://www.syruppay.co.kr/
 */

package com.skplanet.syruppay.token.claims;

import com.skplanet.syruppay.token.TokenBuilder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 시럽페이 체크아웃을 위한 Claim 정보를 설정한다.
 *
 * @author 임형태
 * @since 1.1
 */
public final class OrderConfigurer<H extends TokenBuilder<H>> extends AbstractTokenConfigurer<OrderConfigurer<H>, H> {
    private int productPrice;
    private String submallName;
    private ProductDeliveryInfo productDeliveryInfo;
    private List<Offer> offerList = new ArrayList<Offer>();
    private List<Loyalty> loyaltyList = new ArrayList<Loyalty>();
    private List<PayConfigurer.ShippingAddress> shippingAddressList = new ArrayList<PayConfigurer.ShippingAddress>();
    private List<MonthlyInstallment> monthlyInstallmentList = new ArrayList<MonthlyInstallment>();

    public List<MonthlyInstallment> getMonthlyInstallmentList() {
        return Collections.unmodifiableList(monthlyInstallmentList);
    }

    public int getProductPrice() {
        return productPrice;
    }

    public String getSubmallName() {
        return submallName;
    }

    public ProductDeliveryInfo getProductDeliveryInfo() {
        return this.productDeliveryInfo;
    }

    public String claimName() {
        return "checkoutInfo";
    }

    public void validRequired() throws Exception {
        if (productPrice <= 0) {
            throw new IllegalArgumentException("product price field couldn't be zero. check yours input value : " + productPrice);
        }
        if (productDeliveryInfo == null) {
            throw new IllegalArgumentException("you should contain ProductDeliveryInfo object.");
        }
        productDeliveryInfo.validRequired();

        for (Offer o : offerList) {
            o.validRequired();
        }
        for (Loyalty l : loyaltyList) {
            l.validRequired();
        }
        for (PayConfigurer.ShippingAddress a : shippingAddressList) {
            a.validRequiredToCheckout();
        }
        for (MonthlyInstallment m : monthlyInstallmentList) {
            m.validRequired();
        }
    }

    public OrderConfigurer<H> withShippingAddresses(PayConfigurer.ShippingAddress... shippingAddress) {
        return withShippingAddresses(Arrays.asList(shippingAddress));
    }

    public OrderConfigurer<H> withShippingAddresses(List<PayConfigurer.ShippingAddress> shippingAddresses) {
        for (PayConfigurer.ShippingAddress a : shippingAddresses) {
            a.validRequiredToCheckout();
        }
        shippingAddressList.addAll(shippingAddresses);
        return this;
    }

    public OrderConfigurer<H> withProductPrice(int productPrice) {
        if (productPrice <= 0) {
            throw new IllegalArgumentException("Cannot be smaller than 0. Check yours input value : " + productPrice);
        }
        this.productPrice = productPrice;
        return this;
    }

    public OrderConfigurer<H> withSubmallName(String submallName) {
        this.submallName = submallName;
        return this;
    }

    public OrderConfigurer<H> withProductDeliveryInfo(ProductDeliveryInfo productDeliveryInfo) {
        this.productDeliveryInfo = productDeliveryInfo;
        return this;
    }

    public OrderConfigurer<H> withOffers(Offer... offer) {
        return withOffers(Arrays.asList(offer));
    }

    public OrderConfigurer<H> withOffers(List<Offer> offers) {
        for (Offer o : offers) {
            o.validRequired();
        }
        this.offerList.addAll(offers);
        return this;
    }

    public OrderConfigurer<H> withLoyalties(Loyalty... loyalty) {
        return withLoyalties(Arrays.asList(loyalty));
    }

    public OrderConfigurer<H> withLoyalties(List<Loyalty> loyalties) {
        for (Loyalty l : loyalties) {
            l.validRequired();
        }
        this.loyaltyList.addAll(loyalties);
        return this;
    }

    public OrderConfigurer<H> withMonthlyInstallment(MonthlyInstallment... monthlyInstallment) {
        return withMonthlyInstallment(Arrays.asList(monthlyInstallment));
    }

    public OrderConfigurer<H> withMonthlyInstallment(List<MonthlyInstallment> monthlyInstallments) {
        for (MonthlyInstallment s : monthlyInstallments) {
            s.validRequired();
        }
        this.monthlyInstallmentList.addAll(monthlyInstallments);
        return this;
    }

    public List<Offer> getOfferList() {
        return Collections.unmodifiableList(offerList);
    }

    public List<Loyalty> getLoyaltyList() {
        return Collections.unmodifiableList(loyaltyList);
    }

    public List<PayConfigurer.ShippingAddress> getShippingAddressList() {
        return Collections.unmodifiableList(shippingAddressList);
    }

    public static enum LoyaltyId {
        POINT_OF_11ST("www.11st.co.kr:point"), MILEAGE_OF_11ST("www.11st.co.kr:mileage"), T_MEMBERSHIP("www.sktmemebership.co.kr"), OK_CASHBAG("www.okcashbag.com");

        private String urn;

        LoyaltyId(String urn) {
            this.urn = urn;
        }

        public String getUrn() {
            return urn;
        }
    }

    public static enum ErrorType {
        MAINTENACE, SYSTEM_ERR;
    }

    public static enum DeliveryRestriction {
        NOT_FAR_AWAY, FAR_AWAY, FAR_FAR_AWAY
    }

    public static enum OfferType {
        DELIVERY_COUPON
    }

    public static enum AcceptType {
        CARD, SYRUP_PAY_COUPON
    }

    public static enum DeliveryType {
        PREPAID, FREE, DIY, QUICK, PAYMENT_ON_DELIVERY
    }

{'fraction_non_alphanumeric': 0.08547271329746349, 'fraction_numerical': 0.0034588777863182167, 'mean_word_length': 2.998463429625077, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 65, 'https://': 2, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4503833', 'n_tokens_mistral': 3836, 'n_tokens_neox': 3764, 'n_words': 913}