+
-
+
diff --git a/src/app/malls/malls.page.ts b/src/app/malls/malls.page.ts
index 1f2d742..8d40d15 100644
--- a/src/app/malls/malls.page.ts
+++ b/src/app/malls/malls.page.ts
@@ -20,12 +20,15 @@ export class MallsPage implements OnInit {
) { }
ngOnInit() {
+ this.mallService.mallsByLocation(10.998264, 77.032465).then((response) => {
+ console.log(response);
+ }, (error) => {
+ console.log(error);
+ });
}
ionViewDidEnter() {
- this.mallService.getAllMalls().then((data: Array) => {
- this.malls = data;
- });
+
}
showMallDetails(mall: IMall) {
diff --git a/src/app/mocks/url.ts b/src/app/mocks/url.ts
new file mode 100644
index 0000000..af31e22
--- /dev/null
+++ b/src/app/mocks/url.ts
@@ -0,0 +1,3 @@
+export const URL: string = 'http://13.126.110.70:8080/mall-aggregator/';
+
+export const TOKEN: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
diff --git a/src/app/services/mall.service.ts b/src/app/services/mall.service.ts
index 218dc15..60b4d12 100644
--- a/src/app/services/mall.service.ts
+++ b/src/app/services/mall.service.ts
@@ -3,6 +3,9 @@ import { MALLS } from '../mocks/malls';
import Mall, { IMall } from '../models/mall';
import { OfferService } from './offer.service';
import { OutletService } from './outlet.service';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
+import { TOKEN, URL } from '../mocks/url';
+
@Injectable({
providedIn: 'root'
@@ -12,11 +15,23 @@ export class MallService {
constructor(
private offerService: OfferService,
- private outletService: OutletService
+ private outletService: OutletService,
+ private http: HttpClient
) {
this.fetchMalls();
}
+ async mallsByLocation(latitude: number, longitude: number) {
+ const httpOptions = {
+ headers: new HttpHeaders({
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Token ' + TOKEN
+ })
+ };
+
+ return await this.http.get(URL + '/api/maioraservice/mall/v1/latitude/' + latitude + '/longitude/' + longitude + '/', httpOptions).toPromise();
+ }
+
private getDenormalizedMall = async (mall: Mall) => {
const offers = await Promise.all(mall.offers.map(offer_id => this.offerService.getOfferByID(offer_id)));
const outlets = await Promise.all(mall.outlets.map(outlet_id => this.outletService.getOutletByID(outlet_id)));