twitter-api-client
Version:
Node.js / JavaScript client for Twitter API
152 lines (151 loc) • 5.66 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TwitterClient = void 0;
var Transport_1 = __importDefault(require("./base/Transport"));
var BasicsClient_1 = __importDefault(require("./clients/BasicsClient"));
var AccountsAndUsersClient_1 = __importDefault(require("./clients/AccountsAndUsersClient"));
var TweetsClient_1 = __importDefault(require("./clients/TweetsClient"));
var DirectMessagesClient_1 = __importDefault(require("./clients/DirectMessagesClient"));
var MediaClient_1 = __importDefault(require("./clients/MediaClient"));
var TrendsClient_1 = __importDefault(require("./clients/TrendsClient"));
var GeoClient_1 = __importDefault(require("./clients/GeoClient"));
var MetricsClient_1 = __importDefault(require("./clients/MetricsClient"));
var TweetsV2Client_1 = __importDefault(require("./clients/TweetsV2Client"));
var TimelinesClient_1 = __importDefault(require("./clients/TimelinesClient"));
var UsersClient_1 = __importDefault(require("./clients/UsersClient"));
var TwitterClient = /** @class */ (function () {
/**
* Provide Twitter API Credentials and options
* @param options
*/
function TwitterClient(options) {
if (!options.apiKey) {
throw Error('API KEY needs to be provided.');
}
if (!options.apiSecret) {
throw Error('API SECRET needs to be provided.');
}
if (!options.accessToken) {
throw Error('ACCESS TOKEN needs to be provided.');
}
if (!options.accessTokenSecret) {
throw Error('ACCESS TOKEN SECRET needs to be provided.');
}
this.transport = new Transport_1.default(options);
}
Object.defineProperty(TwitterClient.prototype, "basics", {
get: function () {
if (!this.basicsClient) {
this.basicsClient = new BasicsClient_1.default(this.transport);
}
return this.basicsClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "accountsAndUsers", {
get: function () {
if (!this.accountsAndUsersClient) {
this.accountsAndUsersClient = new AccountsAndUsersClient_1.default(this.transport);
}
return this.accountsAndUsersClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "tweets", {
get: function () {
if (!this.tweetsClient) {
this.tweetsClient = new TweetsClient_1.default(this.transport);
}
return this.tweetsClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "directMessages", {
get: function () {
if (!this.directMessagesClient) {
this.directMessagesClient = new DirectMessagesClient_1.default(this.transport);
}
return this.directMessagesClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "media", {
get: function () {
if (!this.mediaClient) {
this.mediaClient = new MediaClient_1.default(this.transport);
}
return this.mediaClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "trends", {
get: function () {
if (!this.trendsClient) {
this.trendsClient = new TrendsClient_1.default(this.transport);
}
return this.trendsClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "geo", {
get: function () {
if (!this.geoClient) {
this.geoClient = new GeoClient_1.default(this.transport);
}
return this.geoClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "metrics", {
get: function () {
if (!this.metricsClient) {
this.metricsClient = new MetricsClient_1.default(this.transport);
}
return this.metricsClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "tweetsV2", {
get: function () {
if (!this.tweetsV2Client) {
this.tweetsV2Client = new TweetsV2Client_1.default(this.transport);
}
return this.tweetsV2Client;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "timelines", {
get: function () {
if (!this.timelinesClient) {
this.timelinesClient = new TimelinesClient_1.default(this.transport);
}
return this.timelinesClient;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TwitterClient.prototype, "users", {
get: function () {
if (!this.usersClient) {
this.usersClient = new UsersClient_1.default(this.transport);
}
return this.usersClient;
},
enumerable: false,
configurable: true
});
return TwitterClient;
}());
exports.TwitterClient = TwitterClient;