-
Notifications
You must be signed in to change notification settings - Fork 18
/
gettyimages-api.js
130 lines (105 loc) · 3.45 KB
/
gettyimages-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
"use strict";
var Credentials = require("./lib/credentials");
var VideoDownloads = require("./lib/downloadsvideos");
var ImageDownloads = require("./lib/downloadsimages");
var Images = require("./lib/images");
var SdkException = require("./lib/sdkexception");
var SearchImages = require("./lib/searchimages");
var SearchImagesCreative = require("./lib/searchimagescreative");
var SearchImagesEditorial = require("./lib/searchimageseditorial");
var Collections = require("./lib/collections");
var Countries = require("./lib/countries");
var Events = require("./lib/events");
var Videos = require("./lib/videos");
var SearchVideos = require("./lib/searchvideos");
var SearchVideosCreative = require("./lib/searchvideoscreative");
var SearchVideosEditorial = require("./lib/searchvideoseditorial");
var CustomRequest = require("./lib/customrequest");
const _hostName = new WeakMap();
const _credentialOptions = new WeakMap();
const _credentials = new WeakMap();
class GettyImagesApi {
get credentials() {
return _credentialOptions.get(this);
}
set credentials(value) {
_credentialOptions.set(this,value);
}
get creds() {
return _credentials.get(this);
}
set creds(value) {
_credentials.set(this,value);
}
get hostName() {
return _hostName.get(this);
}
set hostName(value) {
_hostName.set(this,value);
}
constructor(credentials, hostName, authHostName) {
if (!credentials.apiKey) {
throw new SdkException("must specify an apiKey");
}
if (!hostName) {
hostName = "api.gettyimages.com";
}
if (!authHostName) {
authHostName = "authentication.gettyimages.com";
}
this.hostName = hostName;
this.credentials = credentials;
this.creds = new Credentials(credentials.apiKey, credentials.apiSecret, credentials.username, credentials.password, credentials.refresh_token, authHostName);
}
getAccessToken() {
var creds = this.creds;
if (creds.refreshToken) {
return creds.refreshAccessToken();
} else {
return creds.getAccessToken();
}
}
images() {
return new Images(this.creds, this.hostName);
}
videos() {
return new Videos(this.creds, this.hostName);
}
searchvideos() {
return new SearchVideos(this.creds, this.hostName);
}
searchvideoscreative() {
return new SearchVideosCreative(this.creds, this.hostName);
}
searchvideoseditorial() {
return new SearchVideosEditorial(this.creds, this.hostName);
}
searchimages() {
return new SearchImages(this.creds, this.hostName);
}
searchimagescreative() {
return new SearchImagesCreative(this.creds, this.hostName);
}
searchimageseditorial() {
return new SearchImagesEditorial(this.creds, this.hostName);
}
collections() {
return new Collections(this.creds, this.hostName);
}
countries() {
return new Countries(this.creds, this.hostName);
}
events() {
return new Events(this.creds, this.hostName);
}
downloadsvideos() {
return new VideoDownloads(this.creds, this.hostName);
}
downloadsimages() {
return new ImageDownloads(this.creds, this.hostName);
}
customrequest() {
return new CustomRequest(this.creds, this.hostName);
}
}
module.exports = GettyImagesApi;