44import Apollo from "./endpoints/apollo" ;
55// Contains the scraper endpoint
66import Scraper from "./endpoints/scraper" ;
7- //> Templates
8- // Contains the main template
9- import { MainTemplate } from "./templates/index" ;
107//> Sessions
118// Contains the SNEK and github session
12- import { SnekSession , GithubSession } from "./session/sessions" ;
9+ import {
10+ SnekSession ,
11+ GithubSession ,
12+ InstagramSession ,
13+ } from "./session/sessions" ;
1314//> Interfaces
1415// Contains interfaces for scraper and apollo
1516import { ScraperEndpoint , ApolloEndpoint } from "./endpoints/index" ;
16- // Contains the interface for the main template
17- import { IMainTemplate } from "./templates/index" ;
1817//#endregion
1918
2019//#region > Interfaces
@@ -64,7 +63,6 @@ class Client implements IClient {
6463/** @class A client implementation for SNEK interaction */
6564class SnekClient extends Client {
6665 gql : ApolloEndpoint ;
67- template : IMainTemplate ;
6866 session : SnekSession ;
6967
7068 /**
@@ -84,16 +82,14 @@ class SnekClient extends Client {
8482 ) {
8583 super ( { type, url, headers } ) ;
8684
87- this . template = new MainTemplate ( ) ;
8885 this . gql = new Apollo ( url , { headers } ) ;
89- this . session = new SnekSession ( "snek" , this . gql , this . template . snek ) ;
86+ this . session = new SnekSession ( "snek" , this . gql ) ;
9087 }
9188}
9289
9390/** @class A client implementation for github interaction */
9491class GithubClient extends Client {
9592 gql : ApolloEndpoint ;
96- template : IMainTemplate ;
9793 session : GithubSession ;
9894
9995 /**
@@ -113,9 +109,39 @@ class GithubClient extends Client {
113109 ) {
114110 super ( { type, url, headers } ) ;
115111
116- this . template = new MainTemplate ( ) ;
117112 this . gql = new Apollo ( url , { headers } ) ;
118- this . session = new GithubSession ( "github" , this . gql , this . template ) ;
113+ this . session = new GithubSession ( "github" , this . gql ) ;
114+ }
115+ }
116+
117+ /** @class A client implementation for instagram interaction */
118+ class InstagramClient extends Client {
119+ ep : ScraperEndpoint ;
120+ session : InstagramSession ;
121+
122+ /**
123+ * Initializes a Github client.
124+ *
125+ * @constructor
126+ * @author Nico Schett <contact@schett.net>
127+ * @param url The base URL the InstagramClient should be working on.
128+ * Default: "https://graph.instagram.com"
129+ * @param headers A object containing various request headers
130+ * @param type A type description to differ between multiple instances
131+ */
132+ constructor (
133+ accessToken : string ,
134+ url : string = "https://graph.instagram.com" ,
135+ headers : { } = { } ,
136+ type : string = "scraper"
137+ ) {
138+ super ( { type, url, headers } ) ;
139+
140+ this . ep = new Scraper ( url , {
141+ headers : { Authorization : `Bearer ${ accessToken } ` } ,
142+ } ) ;
143+
144+ this . session = new InstagramSession ( "instagram" , accessToken , this . ep ) ;
119145 }
120146}
121147
@@ -148,7 +174,7 @@ class WebClient extends Client {
148174//#endregion
149175
150176//#region > Exports
151- export { SnekClient , GithubClient , WebClient } ;
177+ export { SnekClient , GithubClient , InstagramClient , WebClient } ;
152178//#endregion
153179
154180/**
0 commit comments