-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Holiday Park and Hellendoorn (temporarily), added Shops support
- Loading branch information
1 parent
b159be8
commit 7b9b74c
Showing
41 changed files
with
14,760 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/_interfaces/attractions-io/attractions-io-category.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface AttractionsIoCategoryInterface { | ||
'_id': number, | ||
'Name': { | ||
'nl-NL': string, | ||
'en-GB': string, | ||
'de-DE': string | ||
}, | ||
'Icon': string, | ||
'Parent': string | ||
} |
34 changes: 34 additions & 0 deletions
34
src/_interfaces/attractions-io/attractions-io-item.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export interface AttractionsIoItemInterface { | ||
'_id': number, | ||
'Name': { | ||
'nl-NL': string, | ||
'de-DE': string, | ||
'en-GB': string | ||
}, | ||
'Summary': { | ||
'nl-NL': string, | ||
'de-DE': string, | ||
'en-GB': string | ||
}, | ||
'Keywords': string, | ||
'DefaultImage': number, | ||
'Location': string, | ||
'Featured': boolean, | ||
'WayfindingEnabled': boolean, | ||
'VisibleOnMap': boolean, | ||
'Category': number, | ||
'Parent': string, | ||
'entityIds': [], | ||
'Classifications': [], | ||
'MinimumHeightRequirement': number, | ||
'MinimumUnaccompaniedHeightRequirement': number, | ||
'MaximumHeightRequirement': number, | ||
'MinimumAgeRequirement': number, | ||
'MinimumUnaccompaniedAgeRequirement': number, | ||
'MaximumAgeRequirement': number, | ||
'RestrictionSummary': { | ||
'nl-NL': string, | ||
'de-DE': string, | ||
'en-GB': string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/_services/attractions-io-theme-park/attractions-io-theme-park.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { AttractionsIoThemeParkService } from './attractions-io-theme-park.service'; | ||
|
||
describe('AttractionsIoThemeParkService', () => { | ||
let service: AttractionsIoThemeParkService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [AttractionsIoThemeParkService], | ||
}).compile(); | ||
|
||
service = module.get<AttractionsIoThemeParkService>(AttractionsIoThemeParkService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
142 changes: 142 additions & 0 deletions
142
src/_services/attractions-io-theme-park/attractions-io-theme-park.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import { HttpService, Injectable } from '@nestjs/common'; | ||
import { ThemeParkService } from '../themepark/theme-park.service'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { AxiosError, AxiosRequestConfig } from 'axios'; | ||
import { Poi } from '../../_interfaces/poi.interface'; | ||
import { AttractionsIoItemInterface } from '../../_interfaces/attractions-io/attractions-io-item.interface'; | ||
import { PoiCategory } from '../../_interfaces/poi-categories.enum'; | ||
|
||
@Injectable() | ||
export class AttractionsIoThemeParkService extends ThemeParkService { | ||
private readonly _attractionsIoApiUrl: string; | ||
private readonly _attractionsIoApiInstallationBody: string; | ||
|
||
private _tempToken: string; | ||
|
||
constructor(private readonly httpService: HttpService, | ||
private readonly configService: ConfigService) { | ||
super(); | ||
|
||
this._attractionsIoApiUrl = 'https://api.attractions.io/v1'; | ||
this._attractionsIoApiInstallationBody = '\n' + | ||
'--s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc\n' + | ||
'Content-Disposition: form-data; name="device_identifier"\n' + | ||
'\n' + | ||
'6FE3A85A-B6EF-4D19-A199-15EE46386BB6\n' + | ||
'--s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc\n' + | ||
'Content-Disposition: form-data; name="user_identifier"\n' + | ||
'\n' + | ||
'D1982D4C-FF0C-4FE8-BDA3-2DE392E54544\n' + | ||
'--s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc\n' + | ||
'Content-Disposition: form-data; name="app_version"\n' + | ||
'\n' + | ||
'1.2\n' + | ||
'--s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc\n' + | ||
'Content-Disposition: form-data; name="app_build"\n' + | ||
'\n' + | ||
'23\n' + | ||
'--s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc--\n' + | ||
'\n'; | ||
} | ||
|
||
private async getTempToken() { | ||
return this._tempToken ?? await this.getToken(); | ||
} | ||
|
||
protected async getToken(): Promise<string> { | ||
const headers = { | ||
'Authorization': 'Attractions-Io api-key="3acb983d-a451-4700-b607-aac8ab1bedee"', | ||
'User-Agent': 'Avonturenpark/23 CFNetwork/1220.1 Darwin/20.3.0', | ||
'Occasio-Platform-Version': '14.4', | ||
'Occasio-Platform': 'iOS', | ||
'Occasio-App-Build': '23', | ||
'Content-Type': 'multipart/form-data; boundary=s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc', | ||
}; | ||
|
||
const config: AxiosRequestConfig = { headers: headers }; | ||
|
||
return await this.httpService | ||
.post( | ||
this._attractionsIoApiUrl + '/installation', | ||
this._attractionsIoApiInstallationBody, | ||
config, | ||
) | ||
.toPromise() | ||
.then(value => { | ||
this._tempToken = value.data.token; | ||
return this._tempToken; | ||
}); | ||
} | ||
|
||
protected async getData() { | ||
const token = await this.getToken(); | ||
|
||
const headers = { | ||
'Authorization': 'Attractions-Io api-key="3acb983d-a451-4700-b607-aac8ab1bedee", installation-token="' + token + '"', | ||
'User-Agent': 'Avonturenpark/23 CFNetwork/1220.1 Darwin/20.3.0', | ||
'Occasio-Platform-Version': '14.4', | ||
'Occasio-Platform': 'iOS', | ||
'Occasio-App-Build': '23', | ||
'Content-Type': 'multipart/form-data; boundary=s47UC4ujBvwu4tUZny16oB9EYPIK2lYen2gqiaI3cG8N2xg2xG4CuZ88uVFUzeVBcHglTSA5twz4fJCrDwgWt1vy0Ff8gIwp3DPc', | ||
'Date': '2021-03-15', | ||
}; | ||
|
||
const config: AxiosRequestConfig = { | ||
headers: headers, | ||
params: { | ||
'version': '2021-03-05T20:10:46%2B01:00', | ||
}, | ||
}; | ||
|
||
return await this.httpService | ||
.post( | ||
this._attractionsIoApiUrl + '/data', | ||
null, | ||
config, | ||
) | ||
.toPromise() | ||
.then((value) => { | ||
console.log(value); | ||
console.log(value.data); | ||
}) | ||
.catch((reason: AxiosError) => { | ||
console.log(reason.response.data); | ||
console.log(reason.config.headers); | ||
}); | ||
} | ||
|
||
public getFileItems(file: any): Poi[] { | ||
return file.Item.map((item: AttractionsIoItemInterface) => { | ||
let category: PoiCategory = this.getCategory(item.Category); | ||
|
||
const poi: Poi = { | ||
id: item._id + '', | ||
title: item.Name['en-GB'], | ||
description: item.Summary ? item.Summary['en-GB'] : undefined, | ||
category: category, | ||
original: item, | ||
minSize: item.MinimumHeightRequirement ? item.MinimumHeightRequirement * 100 : undefined, | ||
minSizeEscort: item.MinimumUnaccompaniedHeightRequirement ? item.MinimumUnaccompaniedHeightRequirement : undefined, | ||
maxSize: item.MaximumHeightRequirement ? item.MaximumHeightRequirement * 100 : undefined, | ||
minAge: item.MinimumAgeRequirement ?? undefined, | ||
maxAge: item.MaximumAgeRequirement ?? undefined, | ||
}; | ||
|
||
if (item.Location) { | ||
const lat = parseFloat(item.Location.split(',')[0]); | ||
const lng = parseFloat(item.Location.split(',')[1]); | ||
|
||
poi.location = { | ||
lat: lat, | ||
lng: lng, | ||
}; | ||
} | ||
|
||
return poi; | ||
}); | ||
} | ||
|
||
public getCategory(category: number): PoiCategory { | ||
return PoiCategory.UNDEFINED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.