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

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

The 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.Technicals;

public class TechnicalsRequest implements OnDemandRequest {

	private final String symbols;
	private final String fields;

	private final Map params = new HashMap();

	private TechnicalsRequest(final Builder b) {

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

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

	}

	@Override
	public String endpoint() {

		return "getTechnicals.json";
	}

	@Override
	public String name() {

		return "Technical Quote";
	}

	@Override
	public Map parameters() {

		params.put("symbols", symbols);

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

		return params;
	}

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

	public static class Builder {

		private String[] symbols;
		private TechnicalsRequestField[] fields;

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

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

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy