@studyportals/domain-client 3.6.0-0 → 3.6.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.eslintrc.js +12 -0
- package/.github/dependabot.yml +17 -0
- package/.github/stale.yml +10 -0
- package/.mocharc.yml +3 -0
- package/.nycrc +15 -0
- package/README.md +117 -0
- package/{index.d.ts → bin/index.d.ts} +45 -45
- package/{index.js → bin/index.js} +27 -27
- package/{index.js.map → bin/index.js.map} +0 -0
- package/bin/package.json +54 -0
- package/{src → bin/src}/domain-client.d.ts +14 -14
- package/{src → bin/src}/domain-client.js +60 -60
- package/{src → bin/src}/domain-client.js.map +0 -0
- package/{src → bin/src}/exceptions/bad-request-exception.d.ts +2 -2
- package/{src → bin/src}/exceptions/bad-request-exception.js +6 -6
- package/{src → bin/src}/exceptions/bad-request-exception.js.map +0 -0
- package/{src → bin/src}/exceptions/client-exception.d.ts +2 -2
- package/{src → bin/src}/exceptions/client-exception.js +6 -6
- package/{src → bin/src}/exceptions/client-exception.js.map +0 -0
- package/{src → bin/src}/exceptions/internal-server-exception.d.ts +2 -2
- package/{src → bin/src}/exceptions/internal-server-exception.js +6 -6
- package/{src → bin/src}/exceptions/internal-server-exception.js.map +0 -0
- package/{src → bin/src}/exceptions/not-found-exception.d.ts +2 -2
- package/{src → bin/src}/exceptions/not-found-exception.js +6 -6
- package/{src → bin/src}/exceptions/not-found-exception.js.map +0 -0
- package/{src → bin/src}/exceptions/property-not-available-exception.d.ts +2 -2
- package/{src → bin/src}/exceptions/property-not-available-exception.js +6 -6
- package/{src → bin/src}/exceptions/property-not-available-exception.js.map +0 -0
- package/{src → bin/src}/factories/DateFactory.d.ts +5 -5
- package/{src → bin/src}/factories/DateFactory.js +9 -9
- package/{src → bin/src}/factories/DateFactory.js.map +0 -0
- package/{src → bin/src}/factories/InternalLinkFactory.d.ts +9 -9
- package/{src → bin/src}/factories/InternalLinkFactory.js +19 -19
- package/{src → bin/src}/factories/InternalLinkFactory.js.map +0 -0
- package/{src → bin/src}/i-api-response.d.ts +6 -6
- package/{src → bin/src}/i-api-response.js +2 -2
- package/{src → bin/src}/i-api-response.js.map +0 -0
- package/{src → bin/src}/i-class-factory.d.ts +4 -4
- package/{src → bin/src}/i-class-factory.js +2 -2
- package/{src → bin/src}/i-class-factory.js.map +0 -0
- package/{src → bin/src}/i-model-description.d.ts +7 -7
- package/{src → bin/src}/i-model-description.js +9 -9
- package/{src → bin/src}/i-model-description.js.map +0 -0
- package/{src → bin/src}/model-client.d.ts +16 -16
- package/{src → bin/src}/model-client.js +45 -45
- package/{src → bin/src}/model-client.js.map +0 -0
- package/{src → bin/src}/model-factory.d.ts +11 -11
- package/{src → bin/src}/model-factory.js +71 -71
- package/{src → bin/src}/model-factory.js.map +0 -0
- package/{src → bin/src}/models/bestfit-programme/bestfit-programme-client.d.ts +7 -7
- package/{src → bin/src}/models/bestfit-programme/bestfit-programme-client.js +16 -16
- package/{src → bin/src}/models/bestfit-programme/bestfit-programme-client.js.map +0 -0
- package/{src → bin/src}/models/bestfit-programme/i-best-fit-programme.d.ts +82 -82
- package/{src → bin/src}/models/bestfit-programme/i-best-fit-programme.js +2 -2
- package/{src → bin/src}/models/bestfit-programme/i-best-fit-programme.js.map +0 -0
- package/{src → bin/src}/models/bestfit-programme/i-g-p-a-requirement.d.ts +20 -20
- package/{src → bin/src}/models/bestfit-programme/i-g-p-a-requirement.js +2 -2
- package/{src → bin/src}/models/bestfit-programme/i-g-p-a-requirement.js.map +0 -0
- package/{src → bin/src}/models/bestfit-programme/i-living-cost.d.ts +20 -20
- package/{src → bin/src}/models/bestfit-programme/i-living-cost.js +2 -2
- package/{src → bin/src}/models/bestfit-programme/i-living-cost.js.map +0 -0
- package/{src → bin/src}/models/common/i-city.d.ts +14 -14
- package/{src → bin/src}/models/common/i-city.js +2 -2
- package/{src → bin/src}/models/common/i-city.js.map +0 -0
- package/{src → bin/src}/models/common/i-country.d.ts +14 -14
- package/{src → bin/src}/models/common/i-country.js +2 -2
- package/{src → bin/src}/models/common/i-country.js.map +0 -0
- package/{src → bin/src}/models/common/i-english-requirements.d.ts +30 -30
- package/{src → bin/src}/models/common/i-english-requirements.js +2 -2
- package/{src → bin/src}/models/common/i-english-requirements.js.map +0 -0
- package/{src → bin/src}/models/common/i-internal-link.d.ts +28 -28
- package/{src → bin/src}/models/common/i-internal-link.js +2 -2
- package/{src → bin/src}/models/common/i-internal-link.js.map +0 -0
- package/{src → bin/src}/models/common/i-logo.d.ts +14 -14
- package/{src → bin/src}/models/common/i-logo.js +2 -2
- package/{src → bin/src}/models/common/i-logo.js.map +0 -0
- package/{src → bin/src}/models/common/i-tuition-fee.d.ts +50 -50
- package/{src → bin/src}/models/common/i-tuition-fee.js +2 -2
- package/{src → bin/src}/models/common/i-tuition-fee.js.map +0 -0
- package/{src → bin/src}/models/dotdigital-organisation/dotdigital-organisation-client.d.ts +7 -7
- package/{src → bin/src}/models/dotdigital-organisation/dotdigital-organisation-client.js +16 -16
- package/{src → bin/src}/models/dotdigital-organisation/dotdigital-organisation-client.js.map +0 -0
- package/{src → bin/src}/models/dotdigital-organisation/i-dot-digital-organisation.d.ts +32 -30
- package/{src → bin/src}/models/dotdigital-organisation/i-dot-digital-organisation.js +2 -2
- package/{src → bin/src}/models/dotdigital-organisation/i-dot-digital-organisation.js.map +0 -0
- package/{src → bin/src}/models/dotdigital-organisation/i-review.d.ts +7 -7
- package/{src → bin/src}/models/dotdigital-organisation/i-review.js +2 -2
- package/{src → bin/src}/models/dotdigital-organisation/i-review.js.map +0 -0
- package/{src → bin/src}/models/dotdigital-programme/dotdigital-programme-client.d.ts +7 -7
- package/{src → bin/src}/models/dotdigital-programme/dotdigital-programme-client.js +16 -16
- package/{src → bin/src}/models/dotdigital-programme/dotdigital-programme-client.js.map +0 -0
- package/{src → bin/src}/models/dotdigital-programme/i-dot-digital-programme.d.ts +89 -89
- package/{src → bin/src}/models/dotdigital-programme/i-dot-digital-programme.js +2 -2
- package/{src → bin/src}/models/dotdigital-programme/i-dot-digital-programme.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-click-tracking-data.d.ts +5 -5
- package/{src → bin/src}/models/programme-card/i-click-tracking-data.js +2 -2
- package/{src → bin/src}/models/programme-card/i-click-tracking-data.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-cover.d.ts +14 -14
- package/{src → bin/src}/models/programme-card/i-cover.js +2 -2
- package/{src → bin/src}/models/programme-card/i-cover.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-deadline.d.ts +20 -20
- package/{src → bin/src}/models/programme-card/i-deadline.js +2 -2
- package/{src → bin/src}/models/programme-card/i-deadline.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-duration.d.ts +40 -40
- package/{src → bin/src}/models/programme-card/i-duration.js +2 -2
- package/{src → bin/src}/models/programme-card/i-duration.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-link.d.ts +22 -22
- package/{src → bin/src}/models/programme-card/i-link.js +2 -2
- package/{src → bin/src}/models/programme-card/i-link.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-location.d.ts +7 -7
- package/{src → bin/src}/models/programme-card/i-location.js +2 -2
- package/{src → bin/src}/models/programme-card/i-location.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-optional-link.d.ts +23 -23
- package/{src → bin/src}/models/programme-card/i-optional-link.js +2 -2
- package/{src → bin/src}/models/programme-card/i-optional-link.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-programme-card.d.ts +126 -126
- package/{src → bin/src}/models/programme-card/i-programme-card.js +2 -2
- package/{src → bin/src}/models/programme-card/i-programme-card.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-start-date.d.ts +33 -33
- package/{src → bin/src}/models/programme-card/i-start-date.js +2 -2
- package/{src → bin/src}/models/programme-card/i-start-date.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-timing.d.ts +45 -45
- package/{src → bin/src}/models/programme-card/i-timing.js +2 -2
- package/{src → bin/src}/models/programme-card/i-timing.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-tracked-link.d.ts +29 -29
- package/{src → bin/src}/models/programme-card/i-tracked-link.js +2 -2
- package/{src → bin/src}/models/programme-card/i-tracked-link.js.map +0 -0
- package/{src → bin/src}/models/programme-card/i-tracking.d.ts +46 -46
- package/{src → bin/src}/models/programme-card/i-tracking.js +2 -2
- package/{src → bin/src}/models/programme-card/i-tracking.js.map +0 -0
- package/{src → bin/src}/models/programme-card/programme-card-client.d.ts +7 -7
- package/{src → bin/src}/models/programme-card/programme-card-client.js +16 -16
- package/{src → bin/src}/models/programme-card/programme-card-client.js.map +0 -0
- package/{src → bin/src}/models/search-country-faq/i-search-country-faq.d.ts +18 -18
- package/{src → bin/src}/models/search-country-faq/i-search-country-faq.js +2 -2
- package/{src → bin/src}/models/search-country-faq/i-search-country-faq.js.map +0 -0
- package/{src → bin/src}/models/search-country-faq/public-search-country-faq-client.d.ts +7 -7
- package/{src → bin/src}/models/search-country-faq/public-search-country-faq-client.js +16 -16
- package/{src → bin/src}/models/search-country-faq/public-search-country-faq-client.js.map +0 -0
- package/{src → bin/src}/models/search-projection/i-geo-targeting-configuration.d.ts +38 -38
- package/{src → bin/src}/models/search-projection/i-geo-targeting-configuration.js +2 -2
- package/{src → bin/src}/models/search-projection/i-geo-targeting-configuration.js.map +0 -0
- package/{src → bin/src}/models/search-projection/i-geo-targeting-values.d.ts +30 -30
- package/{src → bin/src}/models/search-projection/i-geo-targeting-values.js +2 -2
- package/{src → bin/src}/models/search-projection/i-geo-targeting-values.js.map +0 -0
- package/{src → bin/src}/models/search-projection/i-organisation-values.d.ts +40 -40
- package/{src → bin/src}/models/search-projection/i-organisation-values.js +2 -2
- package/{src → bin/src}/models/search-projection/i-organisation-values.js.map +0 -0
- package/{src → bin/src}/models/search-projection/i-premium-values.d.ts +35 -35
- package/{src → bin/src}/models/search-projection/i-premium-values.js +2 -2
- package/{src → bin/src}/models/search-projection/i-premium-values.js.map +0 -0
- package/{src → bin/src}/models/search-projection/i-search-projection.d.ts +180 -180
- package/{src → bin/src}/models/search-projection/i-search-projection.js +2 -2
- package/{src → bin/src}/models/search-projection/i-search-projection.js.map +0 -0
- package/{src → bin/src}/models/search-projection/i-tuition-values.d.ts +50 -50
- package/{src → bin/src}/models/search-projection/i-tuition-values.js +2 -2
- package/{src → bin/src}/models/search-projection/i-tuition-values.js.map +0 -0
- package/{src → bin/src}/models/search-projection/search-projection-client.d.ts +7 -7
- package/{src → bin/src}/models/search-projection/search-projection-client.js +16 -16
- package/{src → bin/src}/models/search-projection/search-projection-client.js.map +0 -0
- package/{src → bin/src}/types/portal-map.d.ts +2 -2
- package/{src → bin/src}/types/portal-map.js +2 -2
- package/{src → bin/src}/types/portal-map.js.map +0 -0
- package/{src → bin/src}/types/portal-type.d.ts +7 -7
- package/{src → bin/src}/types/portal-type.js +11 -11
- package/{src → bin/src}/types/portal-type.js.map +0 -0
- package/{src → bin/src}/types.d.ts +4 -4
- package/{src → bin/src}/types.js +2 -2
- package/{src → bin/src}/types.js.map +0 -0
- package/index.ts +91 -0
- package/package.json +1 -1
- package/src/domain-client.ts +70 -0
- package/src/exceptions/bad-request-exception.ts +2 -0
- package/src/exceptions/client-exception.ts +2 -0
- package/src/exceptions/internal-server-exception.ts +2 -0
- package/src/exceptions/not-found-exception.ts +2 -0
- package/src/exceptions/property-not-available-exception.ts +2 -0
- package/src/factories/DateFactory.ts +8 -0
- package/src/factories/InternalLinkFactory.ts +27 -0
- package/src/i-api-response.ts +7 -0
- package/src/i-class-factory.ts +5 -0
- package/src/i-model-description.ts +13 -0
- package/src/model-client.ts +77 -0
- package/src/model-factory.ts +94 -0
- package/src/models/bestfit-programme/bestfit-programme-client.ts +16 -0
- package/src/models/bestfit-programme/i-best-fit-programme.ts +102 -0
- package/src/models/bestfit-programme/i-g-p-a-requirement.ts +23 -0
- package/src/models/bestfit-programme/i-living-cost.ts +23 -0
- package/src/models/common/i-city.ts +16 -0
- package/src/models/common/i-country.ts +16 -0
- package/src/models/common/i-english-requirements.ts +38 -0
- package/src/models/common/i-internal-link.ts +32 -0
- package/src/models/common/i-logo.ts +16 -0
- package/src/models/common/i-tuition-fee.ts +57 -0
- package/src/models/dotdigital-organisation/dotdigital-organisation-client.ts +16 -0
- package/src/models/dotdigital-organisation/i-dot-digital-organisation.ts +59 -0
- package/src/models/dotdigital-organisation/i-review.ts +12 -0
- package/src/models/dotdigital-programme/dotdigital-programme-client.ts +16 -0
- package/src/models/dotdigital-programme/i-dot-digital-programme.ts +108 -0
- package/src/models/programme-card/i-click-tracking-data.ts +8 -0
- package/src/models/programme-card/i-cover.ts +16 -0
- package/src/models/programme-card/i-deadline.ts +23 -0
- package/src/models/programme-card/i-duration.ts +46 -0
- package/src/models/programme-card/i-link.ts +25 -0
- package/src/models/programme-card/i-location.ts +12 -0
- package/src/models/programme-card/i-optional-link.ts +27 -0
- package/src/models/programme-card/i-programme-card.ts +152 -0
- package/src/models/programme-card/i-start-date.ts +39 -0
- package/src/models/programme-card/i-timing.ts +53 -0
- package/src/models/programme-card/i-tracked-link.ts +34 -0
- package/src/models/programme-card/i-tracking.ts +55 -0
- package/src/models/programme-card/programme-card-client.ts +16 -0
- package/src/models/search-country-faq/i-search-country-faq.ts +22 -0
- package/src/models/search-country-faq/public-search-country-faq-client.ts +16 -0
- package/src/models/search-projection/i-geo-targeting-configuration.ts +44 -0
- package/src/models/search-projection/i-geo-targeting-values.ts +38 -0
- package/src/models/search-projection/i-organisation-values.ts +46 -0
- package/src/models/search-projection/i-premium-values.ts +43 -0
- package/src/models/search-projection/i-search-projection.ts +216 -0
- package/src/models/search-projection/i-tuition-values.ts +63 -0
- package/src/models/search-projection/search-projection-client.ts +16 -0
- package/src/types/portal-map.ts +3 -0
- package/src/types/portal-type.ts +7 -0
- package/src/types.ts +4 -0
- package/tsconfig.json +39 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: npm
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
time: "04:00"
|
|
8
|
+
open-pull-requests-limit: 10
|
|
9
|
+
reviewers:
|
|
10
|
+
- studyportals/plop
|
|
11
|
+
labels:
|
|
12
|
+
- component-library
|
|
13
|
+
allow:
|
|
14
|
+
- dependency-name: "@studyportals/*"
|
|
15
|
+
ignore:
|
|
16
|
+
- dependency-name: "@studyportals/*"
|
|
17
|
+
update-types: ["version-update:semver-patch"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
daysUntilStale: 14
|
|
2
|
+
daysUntilClose: 46
|
|
3
|
+
exemptLabels:
|
|
4
|
+
- pinned
|
|
5
|
+
staleLabel: stale
|
|
6
|
+
markComment: >
|
|
7
|
+
This issue has been automatically marked as stale because it has not had
|
|
8
|
+
recent activity. It will be closed if no further activity occurs. Thank you
|
|
9
|
+
for your contributions.
|
|
10
|
+
closeComment: false
|
package/.mocharc.yml
ADDED
package/.nycrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Domain Client
|
|
2
|
+
|
|
3
|
+
A lightweight client for fetching data from the Domain API and returning it as
|
|
4
|
+
strongly typed classes defined by the `Domain API`.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm install @studyportals/domain-client --save
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Publishing new version
|
|
13
|
+
To publish a new version to npm run one of the following commnads
|
|
14
|
+
```bash
|
|
15
|
+
npm run publish-beta # Increase the beta version and publishes
|
|
16
|
+
npm run publish-major # Increases the major version publishes
|
|
17
|
+
npm run publish-minor # Increases the minor version and publishes
|
|
18
|
+
npm run publish-patch # Increases the patch version and publishes
|
|
19
|
+
npm run publish-current # Publishes the current version.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Default usage
|
|
23
|
+
|
|
24
|
+
Instantiate your client class (_ProgrammeCard client as example_) with all
|
|
25
|
+
parameters:
|
|
26
|
+
```typescript
|
|
27
|
+
const client = new ProgrammeCardClient(
|
|
28
|
+
domainApiUrl, // The url to the Domain API endpoint
|
|
29
|
+
apiKey, // The API key provided by PLOP for your implementation
|
|
30
|
+
probabilitySeed, // Number between 1 and 100 (inclusive)
|
|
31
|
+
portalMap // PortalMap mapping between PortalType and portal base url
|
|
32
|
+
);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
A PortalMap example:
|
|
36
|
+
```typescript
|
|
37
|
+
const portalMap = new Map<PortalType, string>()
|
|
38
|
+
.set(PortalType.MASTER, 'https://42069.mastersportal.fyi')
|
|
39
|
+
.set(PortalType.PHD, 'https://42069.phdportal.fyi')
|
|
40
|
+
.set(PortalType.BACHELOR, 'https://42069.bachelorsportal.fyi')
|
|
41
|
+
.set(PortalType.SHORT, 'https://42069.shortcoursesportal.fyi')
|
|
42
|
+
.set(PortalType.DISTANCE_LEARNING, 'https://42069.distancelearningportal.fyi')
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Fetch your model using the `fetch()` method with the requested ID (_in this
|
|
46
|
+
example programme ID_):
|
|
47
|
+
```typescript
|
|
48
|
+
const card: IProgrammeCard = await client.fetch(5);
|
|
49
|
+
```
|
|
50
|
+
Or get multiple using `fetchMultiple()` with the requested IDs (_in this example
|
|
51
|
+
programme IDs_):
|
|
52
|
+
```typescript
|
|
53
|
+
const cards: IProgrammeCard[] = await client.fetchMultiple([5, 9, 13]);
|
|
54
|
+
```
|
|
55
|
+
Some functions are accompanied by a `canShow` function that indicates its
|
|
56
|
+
availability. If the value is not set the function will throw a
|
|
57
|
+
`PropertyNotAvailableException`:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const card: IProgrammeCard = await client.fetch(5);
|
|
61
|
+
|
|
62
|
+
// Might throw PropertyNotAvailableException
|
|
63
|
+
const cover: ICover = card.getCover();
|
|
64
|
+
|
|
65
|
+
// Safe behaviour
|
|
66
|
+
if (card.canShowCover()) {
|
|
67
|
+
const cover: ICover = card.getCover();
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Separated usage
|
|
72
|
+
|
|
73
|
+
In some cases you might want to separate the fetching of the information from
|
|
74
|
+
the usage of that information; for instance getting the information in your
|
|
75
|
+
back-end service and passing it to the front-end application for usage.
|
|
76
|
+
|
|
77
|
+
First instantiate your client class with all parameters:
|
|
78
|
+
```typescript
|
|
79
|
+
const client = new ProgrammeCardClient(
|
|
80
|
+
domainApiUrl, // The url to the Domain API endpoint
|
|
81
|
+
apiKey, // The API key provided by PLOP for your implementation
|
|
82
|
+
probabilitySeed // Number between 1 and 100 (inclusive)
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
To do this you can use the `fetchDescription()` method instead and encode it as
|
|
86
|
+
JSON:
|
|
87
|
+
```typescript
|
|
88
|
+
const card: IModelDescription = await client.fetchDescription(5);
|
|
89
|
+
const jsonData: string = JSON.stringify(card);
|
|
90
|
+
```
|
|
91
|
+
Or use the `fetchMultipleDescriptions()` function to fetch multiple descriptions:
|
|
92
|
+
```typescript
|
|
93
|
+
const cards: IModelDescription[] = await client.fetchMultipleDescriptions([5, 9, 13]);
|
|
94
|
+
const jsonData: string = JSON.stringify(cards);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
When you're ready to use the information in the models you can use the existing
|
|
98
|
+
client or instantiate a new one without parameters:
|
|
99
|
+
```typescript
|
|
100
|
+
const client = new ProgrammeCardClient();
|
|
101
|
+
```
|
|
102
|
+
After which you can use the `fromDescription()` and `fromDescriptions()`
|
|
103
|
+
functions to retrieve your models:
|
|
104
|
+
```typescript
|
|
105
|
+
const descriptions: IModelDescription[] = JSON.parse(jsonData);
|
|
106
|
+
const card: IProgrammeCard = client.fromDescription(descriptions[0]);
|
|
107
|
+
const cards: IProgrammeCard[] = client.fromDescriptions(descriptions);
|
|
108
|
+
```
|
|
109
|
+
Note that creating a client without providing the required parameters will
|
|
110
|
+
result in all network functionalities of the client being unavailable. In this
|
|
111
|
+
case the following functions will throw a `ClientException`:
|
|
112
|
+
```typescript
|
|
113
|
+
await client.fetch(1);
|
|
114
|
+
await client.fetchMultiple([5, 9, 13]);
|
|
115
|
+
await client.fetchDescription(1);
|
|
116
|
+
await client.fetchMultipleDescriptions([5, 9, 13]);
|
|
117
|
+
```
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { BadRequestException } from "./src/exceptions/bad-request-exception";
|
|
2
|
-
import { ClientException } from "./src/exceptions/client-exception";
|
|
3
|
-
import { InternalServerException } from "./src/exceptions/internal-server-exception";
|
|
4
|
-
import { NotFoundException } from "./src/exceptions/not-found-exception";
|
|
5
|
-
import { PropertyNotAvailableException } from "./src/exceptions/property-not-available-exception";
|
|
6
|
-
import { ICover } from "./src/models/programme-card/i-cover";
|
|
7
|
-
import { ILink } from "./src/models/programme-card/i-link";
|
|
8
|
-
import { IOptionalLink } from "./src/models/programme-card/i-optional-link";
|
|
9
|
-
import { ILocation } from "./src/models/programme-card/i-location";
|
|
10
|
-
import { IClickTrackingData } from "./src/models/programme-card/i-click-tracking-data";
|
|
11
|
-
import { ITracking } from "./src/models/programme-card/i-tracking";
|
|
12
|
-
import { IDuration } from "./src/models/programme-card/i-duration";
|
|
13
|
-
import { IDeadline } from "./src/models/programme-card/i-deadline";
|
|
14
|
-
import { IStartDate } from "./src/models/programme-card/i-start-date";
|
|
15
|
-
import { ITiming } from "./src/models/programme-card/i-timing";
|
|
16
|
-
import { ITrackedLink } from "./src/models/programme-card/i-tracked-link";
|
|
17
|
-
import { IProgrammeCard } from "./src/models/programme-card/i-programme-card";
|
|
18
|
-
import { ProgrammeCardClient } from "./src/models/programme-card/programme-card-client";
|
|
19
|
-
import { ITuitionValues } from "./src/models/search-projection/i-tuition-values";
|
|
20
|
-
import { IPremiumValues } from "./src/models/search-projection/i-premium-values";
|
|
21
|
-
import { IOrganisationValues } from "./src/models/search-projection/i-organisation-values";
|
|
22
|
-
import { IGeoTargetingConfiguration } from "./src/models/search-projection/i-geo-targeting-configuration";
|
|
23
|
-
import { IGeoTargetingValues } from "./src/models/search-projection/i-geo-targeting-values";
|
|
24
|
-
import { ISearchProjection } from "./src/models/search-projection/i-search-projection";
|
|
25
|
-
import { SearchProjectionClient } from "./src/models/search-projection/search-projection-client";
|
|
26
|
-
import { ILivingCost } from "./src/models/bestfit-programme/i-living-cost";
|
|
27
|
-
import { IGPARequirement } from "./src/models/bestfit-programme/i-g-p-a-requirement";
|
|
28
|
-
import { IBestFitProgramme } from "./src/models/bestfit-programme/i-best-fit-programme";
|
|
29
|
-
import { BestfitProgrammeClient } from "./src/models/bestfit-programme/bestfit-programme-client";
|
|
30
|
-
import { IDotDigitalProgramme } from "./src/models/dotdigital-programme/i-dot-digital-programme";
|
|
31
|
-
import { DotdigitalProgrammeClient } from "./src/models/dotdigital-programme/dotdigital-programme-client";
|
|
32
|
-
import { ISearchCountryFaq } from "./src/models/search-country-faq/i-search-country-faq";
|
|
33
|
-
import { PublicSearchCountryFaqClient } from "./src/models/search-country-faq/public-search-country-faq-client";
|
|
34
|
-
import { IReview } from "./src/models/dotdigital-organisation/i-review";
|
|
35
|
-
import { IDotDigitalOrganisation } from "./src/models/dotdigital-organisation/i-dot-digital-organisation";
|
|
36
|
-
import { DotdigitalOrganisationClient } from "./src/models/dotdigital-organisation/dotdigital-organisation-client";
|
|
37
|
-
import { IInternalLink } from "./src/models/common/i-internal-link";
|
|
38
|
-
import { ILogo } from "./src/models/common/i-logo";
|
|
39
|
-
import { ITuitionFee } from "./src/models/common/i-tuition-fee";
|
|
40
|
-
import { IEnglishRequirements } from "./src/models/common/i-english-requirements";
|
|
41
|
-
import { ICity } from "./src/models/common/i-city";
|
|
42
|
-
import { ICountry } from "./src/models/common/i-country";
|
|
43
|
-
import { PortalType } from "./src/types/portal-type";
|
|
44
|
-
import { PortalMap } from "./src/types/portal-map";
|
|
45
|
-
export { BadRequestException, ClientException, InternalServerException, NotFoundException, PropertyNotAvailableException, IInternalLink, ILogo, ITuitionFee, IEnglishRequirements, ICity, ICountry, ICover, ILink, IOptionalLink, ILocation, IClickTrackingData, ITracking, IDuration, IDeadline, IStartDate, ITiming, ITrackedLink, IProgrammeCard, ProgrammeCardClient, ITuitionValues, IPremiumValues, IOrganisationValues, IGeoTargetingConfiguration, IGeoTargetingValues, ISearchProjection, SearchProjectionClient, ILivingCost, IGPARequirement, IBestFitProgramme, BestfitProgrammeClient, IDotDigitalProgramme, DotdigitalProgrammeClient, ISearchCountryFaq, PublicSearchCountryFaqClient, IReview, IDotDigitalOrganisation, DotdigitalOrganisationClient, PortalMap, PortalType };
|
|
1
|
+
import { BadRequestException } from "./src/exceptions/bad-request-exception";
|
|
2
|
+
import { ClientException } from "./src/exceptions/client-exception";
|
|
3
|
+
import { InternalServerException } from "./src/exceptions/internal-server-exception";
|
|
4
|
+
import { NotFoundException } from "./src/exceptions/not-found-exception";
|
|
5
|
+
import { PropertyNotAvailableException } from "./src/exceptions/property-not-available-exception";
|
|
6
|
+
import { ICover } from "./src/models/programme-card/i-cover";
|
|
7
|
+
import { ILink } from "./src/models/programme-card/i-link";
|
|
8
|
+
import { IOptionalLink } from "./src/models/programme-card/i-optional-link";
|
|
9
|
+
import { ILocation } from "./src/models/programme-card/i-location";
|
|
10
|
+
import { IClickTrackingData } from "./src/models/programme-card/i-click-tracking-data";
|
|
11
|
+
import { ITracking } from "./src/models/programme-card/i-tracking";
|
|
12
|
+
import { IDuration } from "./src/models/programme-card/i-duration";
|
|
13
|
+
import { IDeadline } from "./src/models/programme-card/i-deadline";
|
|
14
|
+
import { IStartDate } from "./src/models/programme-card/i-start-date";
|
|
15
|
+
import { ITiming } from "./src/models/programme-card/i-timing";
|
|
16
|
+
import { ITrackedLink } from "./src/models/programme-card/i-tracked-link";
|
|
17
|
+
import { IProgrammeCard } from "./src/models/programme-card/i-programme-card";
|
|
18
|
+
import { ProgrammeCardClient } from "./src/models/programme-card/programme-card-client";
|
|
19
|
+
import { ITuitionValues } from "./src/models/search-projection/i-tuition-values";
|
|
20
|
+
import { IPremiumValues } from "./src/models/search-projection/i-premium-values";
|
|
21
|
+
import { IOrganisationValues } from "./src/models/search-projection/i-organisation-values";
|
|
22
|
+
import { IGeoTargetingConfiguration } from "./src/models/search-projection/i-geo-targeting-configuration";
|
|
23
|
+
import { IGeoTargetingValues } from "./src/models/search-projection/i-geo-targeting-values";
|
|
24
|
+
import { ISearchProjection } from "./src/models/search-projection/i-search-projection";
|
|
25
|
+
import { SearchProjectionClient } from "./src/models/search-projection/search-projection-client";
|
|
26
|
+
import { ILivingCost } from "./src/models/bestfit-programme/i-living-cost";
|
|
27
|
+
import { IGPARequirement } from "./src/models/bestfit-programme/i-g-p-a-requirement";
|
|
28
|
+
import { IBestFitProgramme } from "./src/models/bestfit-programme/i-best-fit-programme";
|
|
29
|
+
import { BestfitProgrammeClient } from "./src/models/bestfit-programme/bestfit-programme-client";
|
|
30
|
+
import { IDotDigitalProgramme } from "./src/models/dotdigital-programme/i-dot-digital-programme";
|
|
31
|
+
import { DotdigitalProgrammeClient } from "./src/models/dotdigital-programme/dotdigital-programme-client";
|
|
32
|
+
import { ISearchCountryFaq } from "./src/models/search-country-faq/i-search-country-faq";
|
|
33
|
+
import { PublicSearchCountryFaqClient } from "./src/models/search-country-faq/public-search-country-faq-client";
|
|
34
|
+
import { IReview } from "./src/models/dotdigital-organisation/i-review";
|
|
35
|
+
import { IDotDigitalOrganisation } from "./src/models/dotdigital-organisation/i-dot-digital-organisation";
|
|
36
|
+
import { DotdigitalOrganisationClient } from "./src/models/dotdigital-organisation/dotdigital-organisation-client";
|
|
37
|
+
import { IInternalLink } from "./src/models/common/i-internal-link";
|
|
38
|
+
import { ILogo } from "./src/models/common/i-logo";
|
|
39
|
+
import { ITuitionFee } from "./src/models/common/i-tuition-fee";
|
|
40
|
+
import { IEnglishRequirements } from "./src/models/common/i-english-requirements";
|
|
41
|
+
import { ICity } from "./src/models/common/i-city";
|
|
42
|
+
import { ICountry } from "./src/models/common/i-country";
|
|
43
|
+
import { PortalType } from "./src/types/portal-type";
|
|
44
|
+
import { PortalMap } from "./src/types/portal-map";
|
|
45
|
+
export { BadRequestException, ClientException, InternalServerException, NotFoundException, PropertyNotAvailableException, IInternalLink, ILogo, ITuitionFee, IEnglishRequirements, ICity, ICountry, ICover, ILink, IOptionalLink, ILocation, IClickTrackingData, ITracking, IDuration, IDeadline, IStartDate, ITiming, ITrackedLink, IProgrammeCard, ProgrammeCardClient, ITuitionValues, IPremiumValues, IOrganisationValues, IGeoTargetingConfiguration, IGeoTargetingValues, ISearchProjection, SearchProjectionClient, ILivingCost, IGPARequirement, IBestFitProgramme, BestfitProgrammeClient, IDotDigitalProgramme, DotdigitalProgrammeClient, ISearchCountryFaq, PublicSearchCountryFaqClient, IReview, IDotDigitalOrganisation, DotdigitalOrganisationClient, PortalMap, PortalType };
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PortalType = exports.DotdigitalOrganisationClient = exports.PublicSearchCountryFaqClient = exports.DotdigitalProgrammeClient = exports.BestfitProgrammeClient = exports.SearchProjectionClient = exports.ProgrammeCardClient = exports.PropertyNotAvailableException = exports.NotFoundException = exports.InternalServerException = exports.ClientException = exports.BadRequestException = void 0;
|
|
4
|
-
const bad_request_exception_1 = require("./src/exceptions/bad-request-exception");
|
|
5
|
-
Object.defineProperty(exports, "BadRequestException", { enumerable: true, get: function () { return bad_request_exception_1.BadRequestException; } });
|
|
6
|
-
const client_exception_1 = require("./src/exceptions/client-exception");
|
|
7
|
-
Object.defineProperty(exports, "ClientException", { enumerable: true, get: function () { return client_exception_1.ClientException; } });
|
|
8
|
-
const internal_server_exception_1 = require("./src/exceptions/internal-server-exception");
|
|
9
|
-
Object.defineProperty(exports, "InternalServerException", { enumerable: true, get: function () { return internal_server_exception_1.InternalServerException; } });
|
|
10
|
-
const not_found_exception_1 = require("./src/exceptions/not-found-exception");
|
|
11
|
-
Object.defineProperty(exports, "NotFoundException", { enumerable: true, get: function () { return not_found_exception_1.NotFoundException; } });
|
|
12
|
-
const property_not_available_exception_1 = require("./src/exceptions/property-not-available-exception");
|
|
13
|
-
Object.defineProperty(exports, "PropertyNotAvailableException", { enumerable: true, get: function () { return property_not_available_exception_1.PropertyNotAvailableException; } });
|
|
14
|
-
const programme_card_client_1 = require("./src/models/programme-card/programme-card-client");
|
|
15
|
-
Object.defineProperty(exports, "ProgrammeCardClient", { enumerable: true, get: function () { return programme_card_client_1.ProgrammeCardClient; } });
|
|
16
|
-
const search_projection_client_1 = require("./src/models/search-projection/search-projection-client");
|
|
17
|
-
Object.defineProperty(exports, "SearchProjectionClient", { enumerable: true, get: function () { return search_projection_client_1.SearchProjectionClient; } });
|
|
18
|
-
const bestfit_programme_client_1 = require("./src/models/bestfit-programme/bestfit-programme-client");
|
|
19
|
-
Object.defineProperty(exports, "BestfitProgrammeClient", { enumerable: true, get: function () { return bestfit_programme_client_1.BestfitProgrammeClient; } });
|
|
20
|
-
const dotdigital_programme_client_1 = require("./src/models/dotdigital-programme/dotdigital-programme-client");
|
|
21
|
-
Object.defineProperty(exports, "DotdigitalProgrammeClient", { enumerable: true, get: function () { return dotdigital_programme_client_1.DotdigitalProgrammeClient; } });
|
|
22
|
-
const public_search_country_faq_client_1 = require("./src/models/search-country-faq/public-search-country-faq-client");
|
|
23
|
-
Object.defineProperty(exports, "PublicSearchCountryFaqClient", { enumerable: true, get: function () { return public_search_country_faq_client_1.PublicSearchCountryFaqClient; } });
|
|
24
|
-
const dotdigital_organisation_client_1 = require("./src/models/dotdigital-organisation/dotdigital-organisation-client");
|
|
25
|
-
Object.defineProperty(exports, "DotdigitalOrganisationClient", { enumerable: true, get: function () { return dotdigital_organisation_client_1.DotdigitalOrganisationClient; } });
|
|
26
|
-
const portal_type_1 = require("./src/types/portal-type");
|
|
27
|
-
Object.defineProperty(exports, "PortalType", { enumerable: true, get: function () { return portal_type_1.PortalType; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PortalType = exports.DotdigitalOrganisationClient = exports.PublicSearchCountryFaqClient = exports.DotdigitalProgrammeClient = exports.BestfitProgrammeClient = exports.SearchProjectionClient = exports.ProgrammeCardClient = exports.PropertyNotAvailableException = exports.NotFoundException = exports.InternalServerException = exports.ClientException = exports.BadRequestException = void 0;
|
|
4
|
+
const bad_request_exception_1 = require("./src/exceptions/bad-request-exception");
|
|
5
|
+
Object.defineProperty(exports, "BadRequestException", { enumerable: true, get: function () { return bad_request_exception_1.BadRequestException; } });
|
|
6
|
+
const client_exception_1 = require("./src/exceptions/client-exception");
|
|
7
|
+
Object.defineProperty(exports, "ClientException", { enumerable: true, get: function () { return client_exception_1.ClientException; } });
|
|
8
|
+
const internal_server_exception_1 = require("./src/exceptions/internal-server-exception");
|
|
9
|
+
Object.defineProperty(exports, "InternalServerException", { enumerable: true, get: function () { return internal_server_exception_1.InternalServerException; } });
|
|
10
|
+
const not_found_exception_1 = require("./src/exceptions/not-found-exception");
|
|
11
|
+
Object.defineProperty(exports, "NotFoundException", { enumerable: true, get: function () { return not_found_exception_1.NotFoundException; } });
|
|
12
|
+
const property_not_available_exception_1 = require("./src/exceptions/property-not-available-exception");
|
|
13
|
+
Object.defineProperty(exports, "PropertyNotAvailableException", { enumerable: true, get: function () { return property_not_available_exception_1.PropertyNotAvailableException; } });
|
|
14
|
+
const programme_card_client_1 = require("./src/models/programme-card/programme-card-client");
|
|
15
|
+
Object.defineProperty(exports, "ProgrammeCardClient", { enumerable: true, get: function () { return programme_card_client_1.ProgrammeCardClient; } });
|
|
16
|
+
const search_projection_client_1 = require("./src/models/search-projection/search-projection-client");
|
|
17
|
+
Object.defineProperty(exports, "SearchProjectionClient", { enumerable: true, get: function () { return search_projection_client_1.SearchProjectionClient; } });
|
|
18
|
+
const bestfit_programme_client_1 = require("./src/models/bestfit-programme/bestfit-programme-client");
|
|
19
|
+
Object.defineProperty(exports, "BestfitProgrammeClient", { enumerable: true, get: function () { return bestfit_programme_client_1.BestfitProgrammeClient; } });
|
|
20
|
+
const dotdigital_programme_client_1 = require("./src/models/dotdigital-programme/dotdigital-programme-client");
|
|
21
|
+
Object.defineProperty(exports, "DotdigitalProgrammeClient", { enumerable: true, get: function () { return dotdigital_programme_client_1.DotdigitalProgrammeClient; } });
|
|
22
|
+
const public_search_country_faq_client_1 = require("./src/models/search-country-faq/public-search-country-faq-client");
|
|
23
|
+
Object.defineProperty(exports, "PublicSearchCountryFaqClient", { enumerable: true, get: function () { return public_search_country_faq_client_1.PublicSearchCountryFaqClient; } });
|
|
24
|
+
const dotdigital_organisation_client_1 = require("./src/models/dotdigital-organisation/dotdigital-organisation-client");
|
|
25
|
+
Object.defineProperty(exports, "DotdigitalOrganisationClient", { enumerable: true, get: function () { return dotdigital_organisation_client_1.DotdigitalOrganisationClient; } });
|
|
26
|
+
const portal_type_1 = require("./src/types/portal-type");
|
|
27
|
+
Object.defineProperty(exports, "PortalType", { enumerable: true, get: function () { return portal_type_1.PortalType; } });
|
|
28
28
|
//# sourceMappingURL=index.js.map
|
|
File without changes
|
package/bin/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@studyportals/domain-client",
|
|
3
|
+
"version": "3.6.0-2",
|
|
4
|
+
"description": "Responsible for fetching data from the Domain API",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"author": "StudyPortals B.V.",
|
|
7
|
+
"contributors": [
|
|
8
|
+
"braaibander <danny@studyportals.com>"
|
|
9
|
+
],
|
|
10
|
+
"license": "BSD-3-Clause",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "mocha --reporter spec \"tests/**/*.test.ts\"",
|
|
13
|
+
"coverage": "nyc mocha --reporter dot \"tests/**/*.test.ts\"",
|
|
14
|
+
"lint": "eslint . --ext .ts --max-warnings=0",
|
|
15
|
+
"pre-push": "npm run test && npm run coverage && npm run lint",
|
|
16
|
+
"prepare-dist": "npm run test && rm -fR bin && npx tsc && cp package.json bin/package.json && rm -fR bin/tests",
|
|
17
|
+
"publish-beta": "npm version prerelease --preid=beta && npm run prepare-dist && npm publish bin --tag beta",
|
|
18
|
+
"publish-major": "npm version major && npm run prepare-dist && npm publish bin",
|
|
19
|
+
"publish-minor": " npm version minor && npm run prepare-dist &&npm publish bin",
|
|
20
|
+
"publish-patch": " npm version patch && npm run prepare-dist && npm publish bin",
|
|
21
|
+
"publish-current": "npm run prepare-dist && npm publish bin"
|
|
22
|
+
},
|
|
23
|
+
"husky": {
|
|
24
|
+
"hooks": {
|
|
25
|
+
"pre-push": "npm run pre-push"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"axios": "^0.21.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@studyportals/code-style": "^1.3.1",
|
|
33
|
+
"@testdeck/mocha": "^0.1.2",
|
|
34
|
+
"@types/axios": "^0.14.0",
|
|
35
|
+
"@types/mocha": "^8.0.4",
|
|
36
|
+
"@types/moxios": "^0.4.9",
|
|
37
|
+
"@types/node": "^14.14.8",
|
|
38
|
+
"@types/reflect-metadata": "^0.1.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^4.8.1",
|
|
40
|
+
"@typescript-eslint/parser": "^4.8.1",
|
|
41
|
+
"eslint": "^7.13.0",
|
|
42
|
+
"eslint-plugin-import": "^2.22.1",
|
|
43
|
+
"eslint-plugin-mocha": "^8.0.0",
|
|
44
|
+
"husky": "^4.3.0",
|
|
45
|
+
"mocha": "^8.2.1",
|
|
46
|
+
"moxios": "^0.4.0",
|
|
47
|
+
"nyc": "^15.1.0",
|
|
48
|
+
"source-map-support": "^0.5.19",
|
|
49
|
+
"ts-node": "^9.0.0",
|
|
50
|
+
"tslint": "^6.1.3",
|
|
51
|
+
"typemoq": "^2.1.0",
|
|
52
|
+
"typescript": "^4.0.5"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IModelDescription } from "./i-model-description";
|
|
2
|
-
export declare class DomainClient {
|
|
3
|
-
readonly baseUrl: string;
|
|
4
|
-
readonly apiKey: string | undefined;
|
|
5
|
-
readonly model: string;
|
|
6
|
-
readonly version: string;
|
|
7
|
-
readonly isPublic: boolean;
|
|
8
|
-
readonly seed: number;
|
|
9
|
-
constructor(baseUrl: string, apiKey: string | undefined, model: string, version: string, isPublic: boolean, seed: number);
|
|
10
|
-
doRequest(ids: number[]): Promise<IModelDescription[]>;
|
|
11
|
-
private handleErrors;
|
|
12
|
-
private buildUrl;
|
|
13
|
-
private shouldAddPublicPrefix;
|
|
14
|
-
}
|
|
1
|
+
import { IModelDescription } from "./i-model-description";
|
|
2
|
+
export declare class DomainClient {
|
|
3
|
+
readonly baseUrl: string;
|
|
4
|
+
readonly apiKey: string | undefined;
|
|
5
|
+
readonly model: string;
|
|
6
|
+
readonly version: string;
|
|
7
|
+
readonly isPublic: boolean;
|
|
8
|
+
readonly seed: number;
|
|
9
|
+
constructor(baseUrl: string, apiKey: string | undefined, model: string, version: string, isPublic: boolean, seed: number);
|
|
10
|
+
doRequest(ids: number[]): Promise<IModelDescription[]>;
|
|
11
|
+
private handleErrors;
|
|
12
|
+
private buildUrl;
|
|
13
|
+
private shouldAddPublicPrefix;
|
|
14
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DomainClient = void 0;
|
|
4
|
-
const axios_1 = require("axios");
|
|
5
|
-
const bad_request_exception_1 = require("./exceptions/bad-request-exception");
|
|
6
|
-
const internal_server_exception_1 = require("./exceptions/internal-server-exception");
|
|
7
|
-
const not_found_exception_1 = require("./exceptions/not-found-exception");
|
|
8
|
-
class DomainClient {
|
|
9
|
-
constructor(baseUrl, apiKey, model, version, isPublic, seed) {
|
|
10
|
-
this.baseUrl = baseUrl;
|
|
11
|
-
this.apiKey = apiKey;
|
|
12
|
-
this.model = model;
|
|
13
|
-
this.version = version;
|
|
14
|
-
this.isPublic = isPublic;
|
|
15
|
-
this.seed = seed;
|
|
16
|
-
}
|
|
17
|
-
async doRequest(ids) {
|
|
18
|
-
const url = this.buildUrl(ids);
|
|
19
|
-
const config = { baseURL: this.baseUrl };
|
|
20
|
-
if (this.apiKey !== undefined) {
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
22
|
-
config["headers"] = { 'x-api-key': this.apiKey };
|
|
23
|
-
}
|
|
24
|
-
const axiosResponse = await axios_1.default.get(url, config);
|
|
25
|
-
const response = axiosResponse.data;
|
|
26
|
-
this.handleErrors(response);
|
|
27
|
-
const models = [];
|
|
28
|
-
for (const id of ids) {
|
|
29
|
-
const modelData = response.data[id];
|
|
30
|
-
if (!modelData) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
models.push(modelData);
|
|
34
|
-
}
|
|
35
|
-
return models;
|
|
36
|
-
}
|
|
37
|
-
handleErrors(response) {
|
|
38
|
-
if (!response.status) {
|
|
39
|
-
throw new internal_server_exception_1.InternalServerException(response.message);
|
|
40
|
-
}
|
|
41
|
-
if (response.status === 400) {
|
|
42
|
-
throw new bad_request_exception_1.BadRequestException(response.message);
|
|
43
|
-
}
|
|
44
|
-
if (response.status === 404) {
|
|
45
|
-
throw new not_found_exception_1.NotFoundException(response.message);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
buildUrl(ids) {
|
|
49
|
-
const publicPrefix = this.shouldAddPublicPrefix() ? 'public/' : '';
|
|
50
|
-
let query = `${publicPrefix}${this.model}/${this.version}/?seed=${this.seed}`;
|
|
51
|
-
for (const id of ids) {
|
|
52
|
-
query += `&id=${id}`;
|
|
53
|
-
}
|
|
54
|
-
return query;
|
|
55
|
-
}
|
|
56
|
-
shouldAddPublicPrefix() {
|
|
57
|
-
return this.isPublic && this.apiKey === undefined;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.DomainClient = DomainClient;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainClient = void 0;
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const bad_request_exception_1 = require("./exceptions/bad-request-exception");
|
|
6
|
+
const internal_server_exception_1 = require("./exceptions/internal-server-exception");
|
|
7
|
+
const not_found_exception_1 = require("./exceptions/not-found-exception");
|
|
8
|
+
class DomainClient {
|
|
9
|
+
constructor(baseUrl, apiKey, model, version, isPublic, seed) {
|
|
10
|
+
this.baseUrl = baseUrl;
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
this.model = model;
|
|
13
|
+
this.version = version;
|
|
14
|
+
this.isPublic = isPublic;
|
|
15
|
+
this.seed = seed;
|
|
16
|
+
}
|
|
17
|
+
async doRequest(ids) {
|
|
18
|
+
const url = this.buildUrl(ids);
|
|
19
|
+
const config = { baseURL: this.baseUrl };
|
|
20
|
+
if (this.apiKey !== undefined) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
22
|
+
config["headers"] = { 'x-api-key': this.apiKey };
|
|
23
|
+
}
|
|
24
|
+
const axiosResponse = await axios_1.default.get(url, config);
|
|
25
|
+
const response = axiosResponse.data;
|
|
26
|
+
this.handleErrors(response);
|
|
27
|
+
const models = [];
|
|
28
|
+
for (const id of ids) {
|
|
29
|
+
const modelData = response.data[id];
|
|
30
|
+
if (!modelData) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
models.push(modelData);
|
|
34
|
+
}
|
|
35
|
+
return models;
|
|
36
|
+
}
|
|
37
|
+
handleErrors(response) {
|
|
38
|
+
if (!response.status) {
|
|
39
|
+
throw new internal_server_exception_1.InternalServerException(response.message);
|
|
40
|
+
}
|
|
41
|
+
if (response.status === 400) {
|
|
42
|
+
throw new bad_request_exception_1.BadRequestException(response.message);
|
|
43
|
+
}
|
|
44
|
+
if (response.status === 404) {
|
|
45
|
+
throw new not_found_exception_1.NotFoundException(response.message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
buildUrl(ids) {
|
|
49
|
+
const publicPrefix = this.shouldAddPublicPrefix() ? 'public/' : '';
|
|
50
|
+
let query = `${publicPrefix}${this.model}/${this.version}/?seed=${this.seed}`;
|
|
51
|
+
for (const id of ids) {
|
|
52
|
+
query += `&id=${id}`;
|
|
53
|
+
}
|
|
54
|
+
return query;
|
|
55
|
+
}
|
|
56
|
+
shouldAddPublicPrefix() {
|
|
57
|
+
return this.isPublic && this.apiKey === undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.DomainClient = DomainClient;
|
|
61
61
|
//# sourceMappingURL=domain-client.js.map
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare class BadRequestException extends Error {
|
|
2
|
-
}
|
|
1
|
+
export declare class BadRequestException extends Error {
|
|
2
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BadRequestException = void 0;
|
|
4
|
-
class BadRequestException extends Error {
|
|
5
|
-
}
|
|
6
|
-
exports.BadRequestException = BadRequestException;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BadRequestException = void 0;
|
|
4
|
+
class BadRequestException extends Error {
|
|
5
|
+
}
|
|
6
|
+
exports.BadRequestException = BadRequestException;
|
|
7
7
|
//# sourceMappingURL=bad-request-exception.js.map
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare class ClientException extends Error {
|
|
2
|
-
}
|
|
1
|
+
export declare class ClientException extends Error {
|
|
2
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientException = void 0;
|
|
4
|
-
class ClientException extends Error {
|
|
5
|
-
}
|
|
6
|
-
exports.ClientException = ClientException;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientException = void 0;
|
|
4
|
+
class ClientException extends Error {
|
|
5
|
+
}
|
|
6
|
+
exports.ClientException = ClientException;
|
|
7
7
|
//# sourceMappingURL=client-exception.js.map
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare class InternalServerException extends Error {
|
|
2
|
-
}
|
|
1
|
+
export declare class InternalServerException extends Error {
|
|
2
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InternalServerException = void 0;
|
|
4
|
-
class InternalServerException extends Error {
|
|
5
|
-
}
|
|
6
|
-
exports.InternalServerException = InternalServerException;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InternalServerException = void 0;
|
|
4
|
+
class InternalServerException extends Error {
|
|
5
|
+
}
|
|
6
|
+
exports.InternalServerException = InternalServerException;
|
|
7
7
|
//# sourceMappingURL=internal-server-exception.js.map
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare class NotFoundException extends Error {
|
|
2
|
-
}
|
|
1
|
+
export declare class NotFoundException extends Error {
|
|
2
|
+
}
|