More cleaning...
This commit is contained in:
@@ -5,6 +5,11 @@ export class EmitcomService {
|
||||
|
||||
@Output() change: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
/*
|
||||
For communication between components i've used an event emitter service that uses simple JSON objects
|
||||
I could compact everything into one simple method that accepts an object parameter however I wanted to keep the action
|
||||
separate incase I wanted to expand on them later.
|
||||
*/
|
||||
sendData(data: string) {
|
||||
let sendData = {
|
||||
type: "ipo",
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import 'rxjs/add/operator/map'
|
||||
|
||||
/*
|
||||
|
||||
Works much on the same principle as the login service the only difference is we are searching for anything that starts with
|
||||
the provided string.
|
||||
*/
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NasdaqSearchService {
|
||||
|
||||
/* URL to the mock DB to be intercepted by the web-api in memory data service */
|
||||
private loginUrl = "api/nasdaq";
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -12,6 +12,8 @@ const httpOptions = {
|
||||
})
|
||||
export class StockService {
|
||||
|
||||
private baseUrl = "https://api.iextrading.com/1.0/stock/";
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private jsonp: Jsonp
|
||||
@@ -19,6 +21,7 @@ export class StockService {
|
||||
|
||||
getLogos(symbols) {
|
||||
|
||||
/* Before we can get the logos we need to turn the data into comma delimited string */
|
||||
var symbolsComma = "";
|
||||
var commaCheck = false;
|
||||
|
||||
@@ -31,23 +34,33 @@ export class StockService {
|
||||
|
||||
}
|
||||
|
||||
const url = "https://api.iextrading.com/1.0/stock/market/batch?symbols=" + symbolsComma + "&types=logo&callback=JSONP_CALLBACK";
|
||||
/*
|
||||
|
||||
As we are accessing resources from a 3rd party it is best to use padding with the request
|
||||
...that and it's required by the API
|
||||
|
||||
*/
|
||||
const url = this.baseUrl + "market/batch?symbols=" + symbolsComma + "&types=logo&callback=JSONP_CALLBACK";
|
||||
return this.jsonp.request(url)
|
||||
.map(logos => {
|
||||
/* return just the responce body we don't need anything else */
|
||||
return logos["_body"];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
getCharByTime(symbol, timeFrame) {
|
||||
const url2 = "https://api.iextrading.com/1.0/stock/" + symbol + "/chart/1m?callback=JSONP_CALLBACK";
|
||||
return this.jsonp.request(url2)
|
||||
const url = this.baseUrl + symbol + "/chart/1m?callback=JSONP_CALLBACK";
|
||||
return this.jsonp.request(url)
|
||||
.map(chartData => {
|
||||
/* return just the responce body we don't need anything else */
|
||||
return chartData["_body"];
|
||||
});
|
||||
}
|
||||
|
||||
getIpoBulkData(symbols) {
|
||||
|
||||
/* Before we can get the logos we need to turn the data into comma delimited string */
|
||||
var symbolsComma = "";
|
||||
var commaCheck = false;
|
||||
|
||||
@@ -60,9 +73,10 @@ export class StockService {
|
||||
|
||||
}
|
||||
|
||||
const url = "https://api.iextrading.com/1.0/stock/market/batch?symbols=" + symbolsComma + "&types=quote,logo&callback=JSONP_CALLBACK";
|
||||
const url = this.baseUrl + "market/batch?symbols=" + symbolsComma + "&types=quote,logo&callback=JSONP_CALLBACK";
|
||||
return this.jsonp.request(url)
|
||||
.map(logos => {
|
||||
/* return just the responce body we don't need anything else */
|
||||
return logos["_body"];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
@Injectable({
|
||||
@@ -8,9 +7,9 @@ import 'rxjs/add/operator/map';
|
||||
})
|
||||
|
||||
|
||||
|
||||
export class WatcherService {
|
||||
|
||||
/* URL to the mock DB to be intercepted by the web-api in memory data service */
|
||||
private apiUrl = "api/watching/";
|
||||
|
||||
constructor(
|
||||
@@ -18,7 +17,7 @@ export class WatcherService {
|
||||
|
||||
) { }
|
||||
|
||||
|
||||
/* Simple method to return all data within the mock DB */
|
||||
getWatching() {
|
||||
const url = this.apiUrl
|
||||
return this.http.get<any>(url)
|
||||
@@ -27,6 +26,7 @@ export class WatcherService {
|
||||
});
|
||||
}
|
||||
|
||||
/* Add to Mock DB, keep in mind this is only going to work with the current instince */
|
||||
addWatching(symbol) {
|
||||
let newWatchingSymbol = {
|
||||
symbol: symbol
|
||||
@@ -43,6 +43,7 @@ export class WatcherService {
|
||||
|
||||
}
|
||||
|
||||
/* Remove from Mock DB, keep in mind this is only going to work with the current instince */
|
||||
removeFromWatching(id) {
|
||||
let apiUrl = "api/watching/" + id;
|
||||
const httpOptions = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Waters</title>
|
||||
@@ -8,7 +9,9 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user