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

com.barchart.ondemand.api.MomentumRequest Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.barchart.ondemand.api;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.barchart.ondemand.api.responses.Momentums;

public class MomentumRequest implements OnDemandRequest {

	private final String exchanges;
	private final String fields;

	private final Map params = new HashMap();

	private MomentumRequest(final Builder b) {

		this.exchanges = StringUtils.join(b.exchanges, ",");

		this.fields = "";

	}

	@Override
	public String endpoint() {

		return "getMomentum.json";
	}

	@Override
	public String name() {

		return "Exchange Momentum";
	}

	@Override
	public Map parameters() {

		params.put("exchanges", exchanges);

		if (!fields.isEmpty()) {
			params.put("fields", fields);
		}

		return params;
	}

	@Override
	public Class responseType() {
		return Momentums.class;
	}

	public static class Builder {

		private String[] exchanges;

		public Builder exchanges(final String[] exchanges) {
			this.exchanges = exchanges;
			return this;
		}

		public MomentumRequest build() {
			return new MomentumRequest(this);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy