com.notronix.etsy.impl.method.GetUserMethod 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.UserAssociations;
import com.notronix.etsy.impl.model.EtsyUser;
import java.util.List;
import static com.notronix.etsy.api.EtsyAPI.__SELF__;
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 GetUserMethod extends AbstractEtsyMethod>
{
private List userIdsOrNames;
private UserAssociations[] associations;
@Override
public boolean requiresOAuth() {
return requireNonNull(userIdsOrNames).stream().anyMatch(__SELF__::equals);
}
@Override
public String getURI() {
String uri = "/users/" + requireNonNull(userIdsOrNames).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 getUserIdsOrNames() {
return userIdsOrNames;
}
public void setUserIdsOrNames(List userIdsOrNames) {
this.userIdsOrNames = userIdsOrNames;
}
public GetUserMethod withUserIdsOrNames(List userIdsOrNames) {
this.userIdsOrNames = userIdsOrNames;
return this;
}
public UserAssociations[] getAssociations() {
return associations;
}
public void setAssociations(UserAssociations[] associations) {
this.associations = associations;
}
public GetUserMethod withAssociations(UserAssociations[] associations) {
this.associations = associations;
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy