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

io.github.stewseo.client.yelpfusion.events.FeaturedEventRequest Maven / Gradle / Ivy

package io.github.stewseo.client.yelpfusion.events;

import co.elastic.clients.elasticsearch._types.RequestBase;
import io.github.stewseo.client.json.JsonpMapper;
import io.github.stewseo.client.json.JsonpSerializable;
import io.github.stewseo.client.json.JsonpUtils;
import io.github.stewseo.client.util.ObjectBuilder;
import io.github.stewseo.client.transport.endpoints.SimpleEndpoint;
import jakarta.json.stream.JsonGenerator;

import java.util.HashMap;
import java.util.function.Function;

public class FeaturedEventRequest extends RequestBase implements JsonpSerializable {
    // class fields
    private final String location;
    private final Double longitude;
    private final Double latitude;
    private final String locale;

    // constructor
    private FeaturedEventRequest(Builder builder) {
        this.location = builder.location;
        this.latitude = builder.latitude;
        this.longitude = builder.longitude;
        this.locale = builder.locale;
    }
    public static FeaturedEventRequest of(Function> fn) {
        return fn.apply(new FeaturedEventRequest.Builder()).build();
    }

    public String location() {
        return location;
    }

    public Double longitude() {
        return longitude;
    }

    public Double latitude() {
        return latitude;
    }

    public String locale() {
        return locale;
    }

    public void serialize(JsonGenerator generator, JsonpMapper mapper) {
        generator.writeStartObject();
        if (this.location != null) {
            generator.writeKey("location");
            generator.write(this.location);
        }
        generator.writeEnd();
    }
    @Override
    public String toString() {
        return JsonpUtils.toString(this);
    }

    // getters
    // create with Function
    // serialize
    // Builder
    public static class Builder extends RequestBase.AbstractBuilder
            implements
            ObjectBuilder {
        private String location;
        private Double longitude;
        private Double latitude;
        private String locale;

        public final Builder location(String value) {
            this.location = value;
            return this;
        }
        public final Builder latitude(Double value) {
            this.latitude = value;
            return this;
        }
        public final Builder longitude(Double value) {
            this.longitude = value;
            return this;
        }
        public final Builder locale(String value) {
            this.locale = value;
            return this;
        }
        @Override
        protected Builder self() {
            return this;
        }

        public FeaturedEventRequest build() {
            _checkSingleUse();
            return new FeaturedEventRequest(this);
        }
    }
    public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("v3/events/featured",// Request method

            request -> "GET",
            // Request path
            request -> "v3/events/featured",

            request -> {
                HashMap params = new HashMap<>();
                if (request.location() != null) {
                    params.put("location", request.location());
                }
                if (request.latitude() != null) {
                    params.put("latitude", String.valueOf(request.latitude()));
                }
                if (request.longitude() != null) {
                    params.put("longitude", String.valueOf(request.longitude()));
                }
                if (request.locale() != null) {
                    params.put("locale", request.locale());
                }
                return params;

            }, SimpleEndpoint.emptyMap(), false, FeaturedEventResponse._DESERIALIZER);


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy