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

com.twilio.rest.preview.wireless.sim.Usage Maven / Gradle / Ivy

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

package com.twilio.rest.preview.wireless.sim;

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.google.common.base.MoreObjects;
import com.twilio.base.Resource;
import com.twilio.converter.Converter;
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 java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.Map;
import java.util.Objects;

/**
 * PLEASE NOTE that this class contains preview products that are subject to
 * change. Use them with caution. If you currently do not have developer preview
 * access, please contact [email protected].
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class Usage extends Resource {
    private static final long serialVersionUID = 16456693522984L;

    /**
     * Create a UsageFetcher to execute fetch.
     * 
     * @param pathSimSid The sim_sid
     * @return UsageFetcher capable of executing the fetch
     */
    public static UsageFetcher fetcher(final String pathSimSid) {
        return new UsageFetcher(pathSimSid);
    }

    /**
     * Converts a JSON String into a Usage object using the provided ObjectMapper.
     * 
     * @param json Raw JSON String
     * @param objectMapper Jackson ObjectMapper
     * @return Usage object represented by the provided JSON
     */
    public static Usage fromJson(final String json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, Usage.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 Usage object using the provided
     * ObjectMapper.
     * 
     * @param json Raw JSON InputStream
     * @param objectMapper Jackson ObjectMapper
     * @return Usage object represented by the provided JSON
     */
    public static Usage fromJson(final InputStream json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, Usage.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 simSid;
    private final String simUniqueName;
    private final String accountSid;
    private final Map period;
    private final Map commandsUsage;
    private final Map commandsCosts;
    private final Map dataUsage;
    private final Map dataCosts;
    private final URI url;

    @JsonCreator
    private Usage(@JsonProperty("sim_sid")
                  final String simSid, 
                  @JsonProperty("sim_unique_name")
                  final String simUniqueName, 
                  @JsonProperty("account_sid")
                  final String accountSid, 
                  @JsonProperty("period")
                  final Map period, 
                  @JsonProperty("commands_usage")
                  final Map commandsUsage, 
                  @JsonProperty("commands_costs")
                  final Map commandsCosts, 
                  @JsonProperty("data_usage")
                  final Map dataUsage, 
                  @JsonProperty("data_costs")
                  final Map dataCosts, 
                  @JsonProperty("url")
                  final URI url) {
        this.simSid = simSid;
        this.simUniqueName = simUniqueName;
        this.accountSid = accountSid;
        this.period = period;
        this.commandsUsage = commandsUsage;
        this.commandsCosts = commandsCosts;
        this.dataUsage = dataUsage;
        this.dataCosts = dataCosts;
        this.url = url;
    }

    /**
     * Returns The The sim_sid.
     * 
     * @return The sim_sid
     */
    public final String getSimSid() {
        return this.simSid;
    }

    /**
     * Returns The The sim_unique_name.
     * 
     * @return The sim_unique_name
     */
    public final String getSimUniqueName() {
        return this.simUniqueName;
    }

    /**
     * Returns The The account_sid.
     * 
     * @return The account_sid
     */
    public final String getAccountSid() {
        return this.accountSid;
    }

    /**
     * Returns The The period.
     * 
     * @return The period
     */
    public final Map getPeriod() {
        return this.period;
    }

    /**
     * Returns The The commands_usage.
     * 
     * @return The commands_usage
     */
    public final Map getCommandsUsage() {
        return this.commandsUsage;
    }

    /**
     * Returns The The commands_costs.
     * 
     * @return The commands_costs
     */
    public final Map getCommandsCosts() {
        return this.commandsCosts;
    }

    /**
     * Returns The The data_usage.
     * 
     * @return The data_usage
     */
    public final Map getDataUsage() {
        return this.dataUsage;
    }

    /**
     * Returns The The data_costs.
     * 
     * @return The data_costs
     */
    public final Map getDataCosts() {
        return this.dataCosts;
    }

    /**
     * Returns The The url.
     * 
     * @return The url
     */
    public final URI getUrl() {
        return this.url;
    }

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

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

        Usage other = (Usage) o;

        return Objects.equals(simSid, other.simSid) && 
               Objects.equals(simUniqueName, other.simUniqueName) && 
               Objects.equals(accountSid, other.accountSid) && 
               Objects.equals(period, other.period) && 
               Objects.equals(commandsUsage, other.commandsUsage) && 
               Objects.equals(commandsCosts, other.commandsCosts) && 
               Objects.equals(dataUsage, other.dataUsage) && 
               Objects.equals(dataCosts, other.dataCosts) && 
               Objects.equals(url, other.url);
    }

    @Override
    public int hashCode() {
        return Objects.hash(simSid,
                            simUniqueName,
                            accountSid,
                            period,
                            commandsUsage,
                            commandsCosts,
                            dataUsage,
                            dataCosts,
                            url);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                          .add("simSid", simSid)
                          .add("simUniqueName", simUniqueName)
                          .add("accountSid", accountSid)
                          .add("period", period)
                          .add("commandsUsage", commandsUsage)
                          .add("commandsCosts", commandsCosts)
                          .add("dataUsage", dataUsage)
                          .add("dataCosts", dataCosts)
                          .add("url", url)
                          .toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy