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

com.twilio.rest.supersim.v1.UsageRecord Maven / Gradle / Ivy

There is a newer version: 10.7.0
Show newest version
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

package com.twilio.rest.supersim.v1;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.twilio.base.Resource;
import com.twilio.converter.Converter;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
import com.twilio.http.HttpMethod;
import com.twilio.http.Request;
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
import lombok.ToString;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Objects;

/**
 * PLEASE NOTE that this class contains beta products that are subject to
 * change. Use them with caution.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class UsageRecord extends Resource {
    private static final long serialVersionUID = 259624164977521L;

    public enum Granularity {
        HOUR("hour"),
        DAY("day"),
        ALL("all");

        private final String value;

        private Granularity(final String value) {
            this.value = value;
        }

        public String toString() {
            return value;
        }

        /**
         * Generate a Granularity from a string.
         * @param value string value
         * @return generated Granularity
         */
        @JsonCreator
        public static Granularity forValue(final String value) {
            return Promoter.enumFromString(value, Granularity.values());
        }
    }

    public enum Group {
        SIM("sim"),
        FLEET("fleet"),
        NETWORK("network"),
        ISOCOUNTRY("isoCountry");

        private final String value;

        private Group(final String value) {
            this.value = value;
        }

        public String toString() {
            return value;
        }

        /**
         * Generate a Group from a string.
         * @param value string value
         * @return generated Group
         */
        @JsonCreator
        public static Group forValue(final String value) {
            return Promoter.enumFromString(value, Group.values());
        }
    }

    public enum SortBy {
        TIME("time");

        private final String value;

        private SortBy(final String value) {
            this.value = value;
        }

        public String toString() {
            return value;
        }

        /**
         * Generate a SortBy from a string.
         * @param value string value
         * @return generated SortBy
         */
        @JsonCreator
        public static SortBy forValue(final String value) {
            return Promoter.enumFromString(value, SortBy.values());
        }
    }

    /**
     * Create a UsageRecordReader to execute read.
     *
     * @return UsageRecordReader capable of executing the read
     */
    public static UsageRecordReader reader() {
        return new UsageRecordReader();
    }

    /**
     * Converts a JSON String into a UsageRecord object using the provided
     * ObjectMapper.
     *
     * @param json Raw JSON String
     * @param objectMapper Jackson ObjectMapper
     * @return UsageRecord object represented by the provided JSON
     */
    public static UsageRecord fromJson(final String json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, UsageRecord.class);
        } catch (final JsonMappingException | JsonParseException e) {
            throw new ApiException(e.getMessage(), e);
        } catch (final IOException e) {
            throw new ApiConnectionException(e.getMessage(), e);
        }
    }

    /**
     * Converts a JSON InputStream into a UsageRecord object using the provided
     * ObjectMapper.
     *
     * @param json Raw JSON InputStream
     * @param objectMapper Jackson ObjectMapper
     * @return UsageRecord object represented by the provided JSON
     */
    public static UsageRecord fromJson(final InputStream json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, UsageRecord.class);
        } catch (final JsonMappingException | JsonParseException e) {
            throw new ApiException(e.getMessage(), e);
        } catch (final IOException e) {
            throw new ApiConnectionException(e.getMessage(), e);
        }
    }

    private final String accountSid;
    private final String simSid;
    private final String networkSid;
    private final String fleetSid;
    private final String isoCountry;
    private final Map period;
    private final Long dataUpload;
    private final Long dataDownload;
    private final Long dataTotal;

    @JsonCreator
    private UsageRecord(@JsonProperty("account_sid")
                        final String accountSid,
                        @JsonProperty("sim_sid")
                        final String simSid,
                        @JsonProperty("network_sid")
                        final String networkSid,
                        @JsonProperty("fleet_sid")
                        final String fleetSid,
                        @JsonProperty("iso_country")
                        final String isoCountry,
                        @JsonProperty("period")
                        final Map period,
                        @JsonProperty("data_upload")
                        final Long dataUpload,
                        @JsonProperty("data_download")
                        final Long dataDownload,
                        @JsonProperty("data_total")
                        final Long dataTotal) {
        this.accountSid = accountSid;
        this.simSid = simSid;
        this.networkSid = networkSid;
        this.fleetSid = fleetSid;
        this.isoCountry = isoCountry;
        this.period = period;
        this.dataUpload = dataUpload;
        this.dataDownload = dataDownload;
        this.dataTotal = dataTotal;
    }

    /**
     * Returns The SID of the Account that incurred the usage..
     *
     * @return The SID of the Account that incurred the usage.
     */
    public final String getAccountSid() {
        return this.accountSid;
    }

    /**
     * Returns SID of a Sim resource to which the UsageRecord belongs..
     *
     * @return SID of a Sim resource to which the UsageRecord belongs.
     */
    public final String getSimSid() {
        return this.simSid;
    }

    /**
     * Returns SID of the Network resource on which the usage occurred..
     *
     * @return SID of the Network resource on which the usage occurred.
     */
    public final String getNetworkSid() {
        return this.networkSid;
    }

    /**
     * Returns SID of the Fleet resource on which the usage occurred..
     *
     * @return SID of the Fleet resource on which the usage occurred.
     */
    public final String getFleetSid() {
        return this.fleetSid;
    }

    /**
     * Returns Alpha-2 ISO Country Code of the country the usage occurred in..
     *
     * @return Alpha-2 ISO Country Code of the country the usage occurred in.
     */
    public final String getIsoCountry() {
        return this.isoCountry;
    }

    /**
     * Returns The time period for which the usage is reported..
     *
     * @return The time period for which the usage is reported.
     */
    public final Map getPeriod() {
        return this.period;
    }

    /**
     * Returns Total data uploaded in bytes, aggregated by the query parameters..
     *
     * @return Total data uploaded in bytes, aggregated by the query parameters.
     */
    public final Long getDataUpload() {
        return this.dataUpload;
    }

    /**
     * Returns Total data downloaded in bytes, aggregated by the query parameters..
     *
     * @return Total data downloaded in bytes, aggregated by the query parameters.
     */
    public final Long getDataDownload() {
        return this.dataDownload;
    }

    /**
     * Returns Total of data_upload and data_download..
     *
     * @return Total of data_upload and data_download.
     */
    public final Long getDataTotal() {
        return this.dataTotal;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        UsageRecord other = (UsageRecord) o;

        return Objects.equals(accountSid, other.accountSid) &&
               Objects.equals(simSid, other.simSid) &&
               Objects.equals(networkSid, other.networkSid) &&
               Objects.equals(fleetSid, other.fleetSid) &&
               Objects.equals(isoCountry, other.isoCountry) &&
               Objects.equals(period, other.period) &&
               Objects.equals(dataUpload, other.dataUpload) &&
               Objects.equals(dataDownload, other.dataDownload) &&
               Objects.equals(dataTotal, other.dataTotal);
    }

    @Override
    public int hashCode() {
        return Objects.hash(accountSid,
                            simSid,
                            networkSid,
                            fleetSid,
                            isoCountry,
                            period,
                            dataUpload,
                            dataDownload,
                            dataTotal);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy