com.twilio.rest.video.v1.room.participant.SubscribeRules Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of twilio Show documentation
Show all versions of twilio Show documentation
Twilio Java Helper Library
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
package com.twilio.rest.video.v1.room.participant;
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.DateConverter;
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 com.twilio.type.SubscribeRule;
import lombok.ToString;
import java.io.IOException;
import java.io.InputStream;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class SubscribeRules extends Resource {
private static final long serialVersionUID = 98678820953889L;
/**
* Create a SubscribeRulesFetcher to execute fetch.
*
* @param pathRoomSid The SID of the Room resource where the subscribe rules to
* fetch apply
* @param pathParticipantSid The SID of the Participant resource with the
* subscribe rules to fetch
* @return SubscribeRulesFetcher capable of executing the fetch
*/
public static SubscribeRulesFetcher fetcher(final String pathRoomSid,
final String pathParticipantSid) {
return new SubscribeRulesFetcher(pathRoomSid, pathParticipantSid);
}
/**
* Create a SubscribeRulesUpdater to execute update.
*
* @param pathRoomSid The SID of the Room resource where the subscribe rules to
* update apply
* @param pathParticipantSid The SID of the Participant resource to update the
* Subscribe Rules
* @return SubscribeRulesUpdater capable of executing the update
*/
public static SubscribeRulesUpdater updater(final String pathRoomSid,
final String pathParticipantSid) {
return new SubscribeRulesUpdater(pathRoomSid, pathParticipantSid);
}
/**
* Converts a JSON String into a SubscribeRules object using the provided
* ObjectMapper.
*
* @param json Raw JSON String
* @param objectMapper Jackson ObjectMapper
* @return SubscribeRules object represented by the provided JSON
*/
public static SubscribeRules fromJson(final String json, final ObjectMapper objectMapper) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, SubscribeRules.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 SubscribeRules object using the provided
* ObjectMapper.
*
* @param json Raw JSON InputStream
* @param objectMapper Jackson ObjectMapper
* @return SubscribeRules object represented by the provided JSON
*/
public static SubscribeRules fromJson(final InputStream json, final ObjectMapper objectMapper) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, SubscribeRules.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 participantSid;
private final String roomSid;
private final List rules;
private final ZonedDateTime dateCreated;
private final ZonedDateTime dateUpdated;
@JsonCreator
private SubscribeRules(@JsonProperty("participant_sid")
final String participantSid,
@JsonProperty("room_sid")
final String roomSid,
@JsonProperty("rules")
final List rules,
@JsonProperty("date_created")
final String dateCreated,
@JsonProperty("date_updated")
final String dateUpdated) {
this.participantSid = participantSid;
this.roomSid = roomSid;
this.rules = rules;
this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated);
this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated);
}
/**
* Returns The SID of the Participant resource for the Subscribe Rules.
*
* @return The SID of the Participant resource for the Subscribe Rules
*/
public final String getParticipantSid() {
return this.participantSid;
}
/**
* Returns The SID of the Room resource for the Subscribe Rules.
*
* @return The SID of the Room resource for the Subscribe Rules
*/
public final String getRoomSid() {
return this.roomSid;
}
/**
* Returns A collection of Subscribe Rules that describe how to include or
* exclude matching tracks.
*
* @return A collection of Subscribe Rules that describe how to include or
* exclude matching tracks
*/
public final List getRules() {
return this.rules;
}
/**
* Returns The ISO 8601 date and time in GMT when the resource was created.
*
* @return The ISO 8601 date and time in GMT when the resource was created
*/
public final ZonedDateTime getDateCreated() {
return this.dateCreated;
}
/**
* Returns The ISO 8601 date and time in GMT when the resource was last updated.
*
* @return The ISO 8601 date and time in GMT when the resource was last updated
*/
public final ZonedDateTime getDateUpdated() {
return this.dateUpdated;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SubscribeRules other = (SubscribeRules) o;
return Objects.equals(participantSid, other.participantSid) &&
Objects.equals(roomSid, other.roomSid) &&
Objects.equals(rules, other.rules) &&
Objects.equals(dateCreated, other.dateCreated) &&
Objects.equals(dateUpdated, other.dateUpdated);
}
@Override
public int hashCode() {
return Objects.hash(participantSid,
roomSid,
rules,
dateCreated,
dateUpdated);
}
}