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

com.barchart.ondemand.api.IncomeStatementRequest 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 IncomeStatementRequest implements OnDemandRequest {

	private final String symbols;
	private final String fields;

	private final Map params = new HashMap();

	private IncomeStatementRequest(final Builder b) {

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

		if (b.frequency != null) {
			params.put("frequency", b.frequency.getValue(b.frequency));
		} else {
			params.put("frequency", GenericRequestField.QUARTER);
		}

		this.fields = "";

		params.put("count", b.count);

	}

	@Override
	public String endpoint() {

		return "getIncomeStatements.json";
	}

	@Override
	public String name() {

		return "Income Statement";
	}

	@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 GenericRequestField frequency;
		private int count;

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

		public Builder eventTypes(final GenericRequestField frequency) {
			this.frequency = frequency;
			return this;
		}

		public Builder count(final int count) {
			this.count = count;
			return this;
		}

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy