Skip to content
Closed
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 @@
41311cb64247613fcc1634a63a1804e344c71873d665fc58af33e053a5f919f1
15321a7caa009c61dd09fb6412b8f44544953a2a90355f1afc081dc79d784900
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ for (Item item : client.items().listAll(null, false, null)) {
for (Order order : client.orders().listAll(null, "to_send", null, null, null, null)) {
System.out.println(order.getId()); // needs the orders:read scope; also orders().get(id), orders().labels(id)
}
for (CatalogBrand brand : client.catalogs().brandsAll(null, "nik")) {
System.out.println(brand.getId() + " " + brand.getName()); // the identifiers an item is written with (items:read): categories, category, categoryFields, brands, sizes, colors, conditions, packageSizes, materials
}

// Writes (API key with items:write / conversations:write); the last argument, optional, is the Idempotency-Key.
client.items().create(new ItemCreateRequest().name("Jacket")); // items().update(42, new ItemUpdateRequest()...) patches
Expand Down
96 changes: 96 additions & 0 deletions src/main/java/com/controlresell/sdk/ControlResell.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
import com.controlresell.sdk.generated.ApiClient;
import com.controlresell.sdk.generated.ApiException;
import com.controlresell.sdk.generated.api.AccountsApi;
import com.controlresell.sdk.generated.api.CatalogsApi;
import com.controlresell.sdk.generated.api.ConversationsApi;
import com.controlresell.sdk.generated.api.CustomersApi;
import com.controlresell.sdk.generated.api.ItemsApi;
import com.controlresell.sdk.generated.api.MeApi;
import com.controlresell.sdk.generated.api.OrdersApi;
import com.controlresell.sdk.generated.model.Account;
import com.controlresell.sdk.generated.model.AccountPage;
import com.controlresell.sdk.generated.model.CatalogBrand;
import com.controlresell.sdk.generated.model.CatalogBrandPage;
import com.controlresell.sdk.generated.model.CatalogCategory;
import com.controlresell.sdk.generated.model.CatalogCategoryFields;
import com.controlresell.sdk.generated.model.CatalogCategoryPage;
import com.controlresell.sdk.generated.model.CatalogSize;
import com.controlresell.sdk.generated.model.CatalogSizePage;
import com.controlresell.sdk.generated.model.CatalogValue;
import com.controlresell.sdk.generated.model.CatalogValuePage;
import com.controlresell.sdk.generated.model.Conversation;
import com.controlresell.sdk.generated.model.ConversationPage;
import com.controlresell.sdk.generated.model.Customer;
Expand Down Expand Up @@ -149,6 +159,9 @@ public <T> T call(boolean write, HttpCall<T> call) {
/** The other parties of the seller's sales and purchases (needs the {@code customers:read} scope). */
public Customers customers() { return new Customers(); }

/** The catalog an item is written with: categories, brands, sizes, colors... (needs the {@code items:read} scope). */
public Catalogs catalogs() { return new Catalogs(); }

/** The seller the API key acts for. */
public final class MeResource {
private final MeApi api = new MeApi(apiClient);
Expand Down Expand Up @@ -365,6 +378,89 @@ public Iterable<Customer> listAll(Integer limit, UUID accountId, OffsetDateTime
}
}

/** The catalog an item is written with. Every list argument may be {@code null}; {@code categoryId} keeps what applies to one category. */
public final class Catalogs {
private final CatalogsApi api = new CatalogsApi(apiClient);

private Catalogs() {}

/** One page of categories, flat, by identifier; {@code parentId} keeps the children of one, {@code platform} one marketplace. */
public CatalogCategoryPage categories(Integer limit, String cursor, Long parentId, String platform) {
return call(false, h -> api.listCatalogCategories(limit, cursor, parentId, platform, h));
}

/** Every category, page after page, with the same filters. */
public Iterable<CatalogCategory> categoriesAll(Integer limit, Long parentId, String platform) {
return new Paginator<>(cursor -> categories(limit, cursor, parentId, platform),
p -> page(p.getData(), p.getNextCursor()));
}

public CatalogCategory category(long id) { return call(false, h -> api.getCatalogCategory(id, h)); }

/** What an item of a category is filled with: its size groups, enumerated and text fields, measurements. */
public CatalogCategoryFields categoryFields(long id) { return call(false, h -> api.getCatalogCategoryFields(id, h)); }

/** One page of brands, by identifier or, with {@code q}, those whose name starts with it. */
public CatalogBrandPage brands(Integer limit, String cursor, String q) {
return call(false, h -> api.listCatalogBrands(limit, cursor, q, h));
}

/** Every brand, page after page, with the same filters. */
public Iterable<CatalogBrand> brandsAll(Integer limit, String q) {
return new Paginator<>(cursor -> brands(limit, cursor, q), p -> page(p.getData(), p.getNextCursor()));
}

/** One page of sizes, each with its size group. */
public CatalogSizePage sizes(Integer limit, String cursor, Long categoryId) {
return call(false, h -> api.listCatalogSizes(limit, cursor, categoryId, h));
}

/** Every size, page after page, with the same filters. */
public Iterable<CatalogSize> sizesAll(Integer limit, Long categoryId) {
return new Paginator<>(cursor -> sizes(limit, cursor, categoryId), p -> page(p.getData(), p.getNextCursor()));
}

/** One page of colors. */
public CatalogValuePage colors(Integer limit, String cursor, Long categoryId) {
return call(false, h -> api.listCatalogColors(limit, cursor, categoryId, h));
}

/** Every one of the colors, page after page, with the same filters. */
public Iterable<CatalogValue> colorsAll(Integer limit, Long categoryId) {
return new Paginator<>(cursor -> colors(limit, cursor, categoryId), p -> page(p.getData(), p.getNextCursor()));
}

/** One page of conditions. */
public CatalogValuePage conditions(Integer limit, String cursor, Long categoryId) {
return call(false, h -> api.listCatalogConditions(limit, cursor, categoryId, h));
}

/** Every one of the conditions, page after page, with the same filters. */
public Iterable<CatalogValue> conditionsAll(Integer limit, Long categoryId) {
return new Paginator<>(cursor -> conditions(limit, cursor, categoryId), p -> page(p.getData(), p.getNextCursor()));
}

/** One page of package sizes. */
public CatalogValuePage packageSizes(Integer limit, String cursor, Long categoryId) {
return call(false, h -> api.listCatalogPackageSizes(limit, cursor, categoryId, h));
}

/** Every one of the package sizes, page after page, with the same filters. */
public Iterable<CatalogValue> packageSizesAll(Integer limit, Long categoryId) {
return new Paginator<>(cursor -> packageSizes(limit, cursor, categoryId), p -> page(p.getData(), p.getNextCursor()));
}

/** One page of materials. */
public CatalogValuePage materials(Integer limit, String cursor, Long categoryId) {
return call(false, h -> api.listCatalogMaterials(limit, cursor, categoryId, h));
}

/** Every one of the materials, page after page, with the same filters. */
public Iterable<CatalogValue> materialsAll(Integer limit, Long categoryId) {
return new Paginator<>(cursor -> materials(limit, cursor, categoryId), p -> page(p.getData(), p.getNextCursor()));
}
}

/**
* The {@code Idempotency-Key} of a write: the caller's, else a random one. It is chosen once, outside the retries, so
* every attempt of the call sends the same key (the typed methods take the key as an argument, not through the retrier).
Expand Down
Loading
Loading