Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/main/java/com/twilio/base/ResourceDeleter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.twilio.base;

import com.twilio.Twilio;
import com.twilio.http.TwilioRestClient;

import java.util.concurrent.CompletableFuture;

/**
* Executor for deletes of a resource that return a response object.
*
* @param <T> type of the resource
* @param <R> type of the delete response
*/
public abstract class ResourceDeleter<T extends Resource, R extends Resource> {

Check warning on line 14 in src/main/java/com/twilio/base/ResourceDeleter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

T is not used in the class.

See more on https://sonarcloud.io/project/issues?id=twilio_twilio-java&issues=AZ0_tCrvip1ffNXdB8Js&open=AZ0_tCrvip1ffNXdB8Js&pullRequest=947

public CompletableFuture<R> deleteAsync() {
return deleteAsync(Twilio.getRestClient());
}

public CompletableFuture<R> deleteAsync(final TwilioRestClient client) {
return CompletableFuture.supplyAsync(() -> delete(client), Twilio.getExecutorService());
}

public R delete() {
return delete(Twilio.getRestClient());
}

public abstract R delete(final TwilioRestClient client);

public TwilioResponse<R> deleteWithResponse() {
return deleteWithResponse(Twilio.getRestClient());
}

public TwilioResponse<R> deleteWithResponse(final TwilioRestClient client) {
throw new UnsupportedOperationException("deleteWithResponse is not supported for this resource.");
}
}
42 changes: 42 additions & 0 deletions src/main/java/com/twilio/rest/numbers/v3/HostedNumberOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.IOException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import lombok.ToString;

@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down Expand Up @@ -104,6 +105,47 @@
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
static class DeleteHostedNumberOrderResponse extends Resource {

@JsonCreator
private DeleteHostedNumberOrderResponse() {}

public static DeleteHostedNumberOrderResponse fromJson(
final InputStream json,
final ObjectMapper objectMapper
) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(
json,
DeleteHostedNumberOrderResponse.class
);
} catch (final JsonMappingException | JsonParseException e) {
throw new ApiException(e.getMessage(), e);
} catch (final IOException e) {
throw new ApiConnectionException(e.getMessage(), e);
}
}

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

if (o == null || getClass() != o.getClass()) {

Check warning on line 137 in src/main/java/com/twilio/rest/numbers/v3/HostedNumberOrder.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this if-then-else statement by a single return statement.

See more on https://sonarcloud.io/project/issues?id=twilio_twilio-java&issues=AZ0_tCotip1ffNXdB8Jr&open=AZ0_tCotip1ffNXdB8Jr&pullRequest=947
return false;
}
return true;
}

@Override
public int hashCode() {
return Objects.hash();
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
static class ListHostedNumberOrderResponse extends Resource {

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/twilio/rest/studio/v2/flow/ExecutionReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
public class ExecutionReader extends Reader<Execution> {

private String pathFlowSid;
private Execution.Status status;
private ZonedDateTime dateCreatedFrom;
private ZonedDateTime dateCreatedTo;
private Long pageSize;
Expand All @@ -45,6 +46,11 @@ public ExecutionReader(final String pathFlowSid) {
this.pathFlowSid = pathFlowSid;
}

public ExecutionReader setStatus(final Execution.Status status) {
this.status = status;
return this;
}

public ExecutionReader setDateCreatedFrom(
final ZonedDateTime dateCreatedFrom
) {
Expand Down Expand Up @@ -206,6 +212,10 @@ public Page<Execution> getPage(
}

private void addQueryParams(final Request request) {
if (status != null) {
Serializer.toString(request, "status", status, ParameterType.QUERY);
}

if (dateCreatedFrom != null) {
Serializer.toString(
request,
Expand Down
Loading