com.dft.api.shopify.SmartCollectionAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shopify-admin-rest Show documentation
Show all versions of shopify-admin-rest Show documentation
Shopify Admin REST API using JDK 11 and Reactive Programming
The newest version!
package com.dft.api.shopify;
import com.dft.api.shopify.model.*;
import com.dft.api.shopify.model.collection.smart.SmartCollection;
import com.dft.api.shopify.model.collection.smart.SmartCollectionsRoot;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import java.util.*;
public class SmartCollectionAPI {
static final String SMART_COLLECTIONS = "smart_collections";
private final ShopifySdk shopifySdk;
public SmartCollectionAPI(ShopifySdk shopifySdk) {
this.shopifySdk = shopifySdk;
}
public ShopifyPage getSmartCollectios(HashMap parameters) {
WebTarget webTarget = shopifySdk.getWebTarget().path(ShopifySdk.VERSION_2023_01).path(SMART_COLLECTIONS);
for (String key : parameters.keySet()) {
String value = parameters.get(key);
webTarget = webTarget.queryParam(key, value);
}
final Response response = shopifySdk.get(webTarget);
final SmartCollectionsRoot smartCollectionsRoot = response.readEntity(SmartCollectionsRoot.class);
return shopifySdk.mapPagedResponse(smartCollectionsRoot.getSmartCollections(), response);
}
public SmartCollection create(SmartCollectionsRoot smartCollection) {
WebTarget webTarget = shopifySdk.getWebTarget().path(ShopifySdk.VERSION_2023_01).path(SMART_COLLECTIONS);
final Response response = shopifySdk.post(webTarget, smartCollection);
final SmartCollectionsRoot smartCollectionsRoot = response.readEntity(SmartCollectionsRoot.class);
return smartCollectionsRoot.getSmartCollection();
}
}