Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .spec-sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1acbf02fb5996004ee72495da2440677842bc7d8a705b9a4a0741565f353df4e
1c648bd5dd3dab534723d1cb26e19fdbfcc7359cd8a33a1f8d99e5688e4ba54f
45 changes: 34 additions & 11 deletions src/main/java/com/controlresell/sdk/ControlResell.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.controlresell.sdk.generated.model.Message;
import com.controlresell.sdk.generated.model.MessagePage;
import com.controlresell.sdk.generated.model.Order;
import com.controlresell.sdk.generated.model.OrderLabel;
import com.controlresell.sdk.generated.model.OrderLabelPage;
import com.controlresell.sdk.generated.model.OrderPage;
import com.controlresell.sdk.generated.model.PriceDropRequest;
Expand Down Expand Up @@ -244,16 +245,23 @@ public final class Conversations {

private Conversations() {}

/** One page of conversations; every argument may be {@code null}. */
public ConversationPage list(Integer limit, String cursor, Boolean unread, UUID accountId) {
return call(false, h -> api.listConversations(limit, cursor, unread, accountId, h));
/**
* One page of conversations; every argument may be {@code null}. {@code from} (inclusive) and {@code to}
* (exclusive) bound the last message.
*/
public ConversationPage list(Integer limit, String cursor, Boolean unread, UUID accountId, OffsetDateTime from,
OffsetDateTime to) {
return call(false, h -> api.listConversations(limit, cursor, unread, accountId, from, to, h));
}

public Conversation get(UUID id) { return call(false, h -> api.getConversation(id, h)); }

/** One page of the messages of a conversation, oldest first. */
public MessagePage messages(UUID id, Integer limit, String cursor) {
return call(false, h -> api.listConversationMessages(id, limit, cursor, h));
/**
* One page of the messages of a conversation, oldest first; {@code from} (inclusive) and {@code to} (exclusive)
* bound the period and may be {@code null}.
*/
public MessagePage messages(UUID id, Integer limit, String cursor, OffsetDateTime from, OffsetDateTime to) {
return call(false, h -> api.listConversationMessages(id, limit, cursor, from, to, h));
}

/** Sends a message to the buyer, with a random {@code Idempotency-Key}. */
Expand All @@ -275,13 +283,15 @@ public Message sendOffer(UUID id, SendOfferRequest request, String idempotencyKe
}

/** Every conversation, page after page, with the same filters. */
public Iterable<Conversation> listAll(Integer limit, Boolean unread, UUID accountId) {
return new Paginator<>(cursor -> list(limit, cursor, unread, accountId), p -> page(p.getData(), p.getNextCursor()));
public Iterable<Conversation> listAll(Integer limit, Boolean unread, UUID accountId, OffsetDateTime from,
OffsetDateTime to) {
return new Paginator<>(cursor -> list(limit, cursor, unread, accountId, from, to),
p -> page(p.getData(), p.getNextCursor()));
}

/** Every message of a conversation, page after page. */
public Iterable<Message> listAllMessages(UUID id, Integer limit) {
return new Paginator<>(cursor -> messages(id, limit, cursor), p -> page(p.getData(), p.getNextCursor()));
/** Every message of a conversation, page after page, with the same period. */
public Iterable<Message> listAllMessages(UUID id, Integer limit, OffsetDateTime from, OffsetDateTime to) {
return new Paginator<>(cursor -> messages(id, limit, cursor, from, to), p -> page(p.getData(), p.getNextCursor()));
}
}

Expand All @@ -305,6 +315,19 @@ public OrderPage list(Integer limit, String cursor, String bucket, String platfo
/** The shipping labels of an order. */
public OrderLabelPage labels(UUID id) { return call(false, h -> api.listOrderLabels(id, h)); }

/**
* One page of the shipping labels still to ship over all the orders, the oldest order first; each label names its
* order ({@code getOrderId()}). Both arguments may be {@code null}.
*/
public OrderLabelPage labelsToShip(Integer limit, String cursor) {
return call(false, h -> api.listLabelsToShip(limit, cursor, h));
}

/** Every label still to ship, page after page. */
public Iterable<OrderLabel> listAllLabelsToShip(Integer limit) {
return new Paginator<>(cursor -> labelsToShip(limit, cursor), p -> page(p.getData(), p.getNextCursor()));
}

/** Every order, page after page, with the same filters. */
public Iterable<Order> listAll(Integer limit, String bucket, String platform, UUID accountId, OffsetDateTime from,
OffsetDateTime to) {
Expand Down
Loading
Loading