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

com.barchart.ondemand.api.SignalsRequest 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;

public class SignalsRequest implements OnDemandRequest {

	private final String symbols;
	private final String fields;

	private final Map params = new HashMap();

	private SignalsRequest(final Builder b) {

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

		this.fields = SignalsRequestField.forQuery(b.fields);

	}

	@Override
	public String endpoint() {

		return "getSignal.json";
	}

	@Override
	public String name() {

		return "Signals";
	}

	@Override
	public Map parameters() {

		params.put("symbols", symbols);

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

		return params;
	}

	public static class Builder {

		private String[] symbols;
		private SignalsRequestField[] fields;

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

		public Builder fields(final SignalsRequestField[] fields) {
			this.fields = fields;
			return this;
		}

		public OnDemandRequest build() {
			return new SignalsRequest(this);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy