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

com.notronix.etsy.impl.method.GetAvatarImgSrcMethod 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 java.util.Map;

import static com.notronix.etsy.api.EtsyAPI.__SELF__;
import static java.util.Objects.requireNonNull;

public class GetAvatarImgSrcMethod extends AbstractEtsyMethod
{
    private String userId;

    @Override
    public boolean requiresOAuth() {
        return __SELF__.equals(userId);
    }

    @Override
    public String getURI() {
        return "/users/" + requireNonNull(userId) + "/avatar/src";
    }

    @Override
    public String getResponse(Gson gson, String jsonPayload) {
        EtsyResponse> response =
                gson.fromJson(jsonPayload, new TypeToken>>(){}.getType());

        return response.getResults().get("src");
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public GetAvatarImgSrcMethod withUserId(String userId) {
        this.userId = userId;
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy