All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.billing.fluent.models.PaymentMethodProperties Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.billing.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.billing.models.PaymentMethodFamily;
import com.azure.resourcemanager.billing.models.PaymentMethodLogo;
import com.azure.resourcemanager.billing.models.PaymentMethodStatus;
import java.io.IOException;
import java.util.List;

/**
 * The properties of a payment method.
 */
@Fluent
public final class PaymentMethodProperties implements JsonSerializable {
    /*
     * Id of payment method.
     */
    private String id;

    /*
     * The account holder name for the payment method. This is only supported for payment methods with family
     * CreditCard.
     */
    private String accountHolderName;

    /*
     * The display name of the payment method.
     */
    private String displayName;

    /*
     * The expiration month and year of the payment method. This is only supported for payment methods with family
     * CreditCard.
     */
    private String expiration;

    /*
     * The family of payment method.
     */
    private PaymentMethodFamily family;

    /*
     * Last four digits of payment method.
     */
    private String lastFourDigits;

    /*
     * The list of logos for the payment method.
     */
    private List logos;

    /*
     * The type of payment method.
     */
    private String paymentMethodType;

    /*
     * Status of the payment method.
     */
    private PaymentMethodStatus status;

    /**
     * Creates an instance of PaymentMethodProperties class.
     */
    public PaymentMethodProperties() {
    }

    /**
     * Get the id property: Id of payment method.
     * 
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Get the accountHolderName property: The account holder name for the payment method. This is only supported for
     * payment methods with family CreditCard.
     * 
     * @return the accountHolderName value.
     */
    public String accountHolderName() {
        return this.accountHolderName;
    }

    /**
     * Get the displayName property: The display name of the payment method.
     * 
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Get the expiration property: The expiration month and year of the payment method. This is only supported for
     * payment methods with family CreditCard.
     * 
     * @return the expiration value.
     */
    public String expiration() {
        return this.expiration;
    }

    /**
     * Get the family property: The family of payment method.
     * 
     * @return the family value.
     */
    public PaymentMethodFamily family() {
        return this.family;
    }

    /**
     * Set the family property: The family of payment method.
     * 
     * @param family the family value to set.
     * @return the PaymentMethodProperties object itself.
     */
    public PaymentMethodProperties withFamily(PaymentMethodFamily family) {
        this.family = family;
        return this;
    }

    /**
     * Get the lastFourDigits property: Last four digits of payment method.
     * 
     * @return the lastFourDigits value.
     */
    public String lastFourDigits() {
        return this.lastFourDigits;
    }

    /**
     * Get the logos property: The list of logos for the payment method.
     * 
     * @return the logos value.
     */
    public List logos() {
        return this.logos;
    }

    /**
     * Set the logos property: The list of logos for the payment method.
     * 
     * @param logos the logos value to set.
     * @return the PaymentMethodProperties object itself.
     */
    public PaymentMethodProperties withLogos(List logos) {
        this.logos = logos;
        return this;
    }

    /**
     * Get the paymentMethodType property: The type of payment method.
     * 
     * @return the paymentMethodType value.
     */
    public String paymentMethodType() {
        return this.paymentMethodType;
    }

    /**
     * Get the status property: Status of the payment method.
     * 
     * @return the status value.
     */
    public PaymentMethodStatus status() {
        return this.status;
    }

    /**
     * Set the status property: Status of the payment method.
     * 
     * @param status the status value to set.
     * @return the PaymentMethodProperties object itself.
     */
    public PaymentMethodProperties withStatus(PaymentMethodStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (logos() != null) {
            logos().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("family", this.family == null ? null : this.family.toString());
        jsonWriter.writeArrayField("logos", this.logos, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of PaymentMethodProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of PaymentMethodProperties if the JsonReader was pointing to an instance of it, or null if it
     * was pointing to JSON null.
     * @throws IOException If an error occurs while reading the PaymentMethodProperties.
     */
    public static PaymentMethodProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            PaymentMethodProperties deserializedPaymentMethodProperties = new PaymentMethodProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("id".equals(fieldName)) {
                    deserializedPaymentMethodProperties.id = reader.getString();
                } else if ("accountHolderName".equals(fieldName)) {
                    deserializedPaymentMethodProperties.accountHolderName = reader.getString();
                } else if ("displayName".equals(fieldName)) {
                    deserializedPaymentMethodProperties.displayName = reader.getString();
                } else if ("expiration".equals(fieldName)) {
                    deserializedPaymentMethodProperties.expiration = reader.getString();
                } else if ("family".equals(fieldName)) {
                    deserializedPaymentMethodProperties.family = PaymentMethodFamily.fromString(reader.getString());
                } else if ("lastFourDigits".equals(fieldName)) {
                    deserializedPaymentMethodProperties.lastFourDigits = reader.getString();
                } else if ("logos".equals(fieldName)) {
                    List logos = reader.readArray(reader1 -> PaymentMethodLogo.fromJson(reader1));
                    deserializedPaymentMethodProperties.logos = logos;
                } else if ("paymentMethodType".equals(fieldName)) {
                    deserializedPaymentMethodProperties.paymentMethodType = reader.getString();
                } else if ("status".equals(fieldName)) {
                    deserializedPaymentMethodProperties.status = PaymentMethodStatus.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPaymentMethodProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy