com.notronix.etsy.impl.method.GetShopMethod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JEtsy Show documentation
Show all versions of JEtsy Show documentation
A Java implementation of a Java version of the Etsy API
package com.notronix.etsy.impl.method;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.notronix.etsy.api.model.ShopAssociations;
import com.notronix.etsy.impl.model.EtsyShop;
import java.util.List;
import static com.notronix.etsy.impl.method.MethodUtils.addIfProvided;
import static com.notronix.etsy.impl.method.MethodUtils.safeList;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.joining;
public class GetShopMethod extends AbstractEtsyMethod>
{
private List shopIdsOrNames;
private ShopAssociations[] associations;
@Override
String getURI() {
String uri = "/shops/" + requireNonNull(shopIdsOrNames).stream().distinct().collect(joining(","));
uri = addIfProvided(uri, "includes", safeList(associations), ASSOCIATIONS_CONVERTER);
return uri;
}
@Override
public List getResponse(Gson gson, String jsonPayload) {
EtsyResponse> response
= gson.fromJson(jsonPayload, new TypeToken>>(){}.getType());
return response.getResults();
}
public List getShopIdsOrNames() {
return shopIdsOrNames;
}
public void setShopIdsOrNames(List shopIdsOrNames) {
this.shopIdsOrNames = shopIdsOrNames;
}
public GetShopMethod withShopIdsOrNames(List shopIdsOrNames) {
this.shopIdsOrNames = shopIdsOrNames;
return this;
}
public ShopAssociations[] getAssociations() {
return associations;
}
public void setAssociations(ShopAssociations[] associations) {
this.associations = associations;
}
public GetShopMethod withAssociations(ShopAssociations[] associations) {
this.associations = associations;
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy