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.voice;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.fasterxml.jackson.databind.util.ArrayIterator;
020import com.vonage.client.Jsonable;
021import com.vonage.client.JsonableBaseObject;
022import java.util.Iterator;
023
024public class CallInfoPage extends JsonableBaseObject implements Iterable<CallInfo> {
025    private int count, pageSize, recordIndex;
026    private PageLinks links;
027    private EmbeddedCalls embedded;
028
029    @JsonProperty("count")
030    public int getCount() {
031        return count;
032    }
033
034    @JsonProperty("page_size")
035    public int getPageSize() {
036        return pageSize;
037    }
038
039    @JsonProperty("record_index")
040    public int getRecordIndex() {
041        return recordIndex;
042    }
043
044    @JsonProperty("_links")
045    public PageLinks getLinks() {
046        return links;
047    }
048
049    @JsonProperty("_embedded")
050    public EmbeddedCalls getEmbedded() {
051        return embedded;
052    }
053    
054    @Override
055    public Iterator<CallInfo> iterator() {
056        return new ArrayIterator<>(embedded.getCallInfos());
057    }
058
059    /**
060     * Creates an instance of this class from a JSON payload.
061     *
062     * @param json The JSON string to parse.
063     *
064     * @return An instance of this class with the fields populated, if present.
065     */
066    public static CallInfoPage fromJson(String json) {
067        return Jsonable.fromJson(json);
068    }
069}