001/*
002 *   Copyright 2024 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.subaccounts;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.Jsonable;
020import com.vonage.client.JsonableBaseObject;
021import java.math.BigDecimal;
022import java.time.Instant;
023
024/**
025 * Represents a subaccount.
026 */
027public class Account extends JsonableBaseObject {
028        private String apiKey, primaryAccountApiKey, name, secret;
029        private Boolean usePrimaryAccountBalance, suspended;
030        private Instant createdAt;
031        private BigDecimal balance, creditLimit;
032
033        protected Account() {
034        }
035
036        /**
037         * Unique subaccount ID.
038         * 
039         * @return The subaccount API key.
040         */
041        @JsonProperty("api_key")
042        public String getApiKey() {
043                return apiKey;
044        }
045
046        /**
047         * Unique primary account ID.
048         * 
049         * @return The primary account API key.
050         */
051        @JsonProperty("primary_account_api_key")
052        public String getPrimaryAccountApiKey() {
053                return primaryAccountApiKey;
054        }
055
056        /**
057         * Name of the subaccount.
058         * 
059         * @return The subaccount name.
060         */
061        @JsonProperty("name")
062        public String getName() {
063                return name;
064        }
065
066        /**
067         * API secret of the subaccount.
068         *
069         * @return The subaccount secret if available, or {@code null} if redacted for this response.
070         */
071        @JsonProperty("secret")
072        public String getSecret() {
073                return secret;
074        }
075
076        /**
077         * Flag showing if balance is shared with primary account.
078         * 
079         * @return Whether the balance is shared with the primary account.
080         */
081        @JsonProperty("use_primary_account_balance")
082        public Boolean getUsePrimaryAccountBalance() {
083                return usePrimaryAccountBalance;
084        }
085
086        /**
087         * Subaccount suspension status.
088         * 
089         * @return Whether this subaccount has been suspended.
090         */
091        @JsonProperty("suspended")
092        public Boolean getSuspended() {
093                return suspended;
094        }
095
096        /**
097         * Subaccount creation date and time.
098         * 
099         * @return The subaccount creation timestamp in ISO 8601 format.
100         */
101        @JsonProperty("created_at")
102        public Instant getCreatedAt() {
103                return createdAt;
104        }
105
106        /**
107         * Balance of the subaccount.
108         * 
109         * @return The subaccount balance, or {@code null} if it is shared with primary account.
110         */
111        @JsonProperty("balance")
112        public BigDecimal getBalance() {
113                return balance;
114        }
115
116        /**
117         * Credit limit of the subaccount.
118         * 
119         * @return The subaccount credit limit, or {@code null} if it is shared with primary account.
120         */
121        @JsonProperty("credit_limit")
122        public BigDecimal getCreditLimit() {
123                return creditLimit;
124        }
125        
126        /**
127         * Creates an instance of this class from a JSON payload.
128         *
129         * @param json The JSON string to parse.
130         * @return An instance of this class with the fields populated, if present.
131         */
132        public static Account fromJson(String json) {
133                return Jsonable.fromJson(json);
134        }
135}