All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.notronix.etsy.impl.method.GetShopMethod Maven / Gradle / Ivy

There is a newer version: 3.0.0014
Show newest version
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