1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- import { Service , util } from '@google-cloud/common' ;
15+ import { Service , util , Metadata } from '@google-cloud/common' ;
1616import { promisifyAll } from '@google-cloud/promisify' ;
1717import arrify = require( 'arrify' ) ;
1818import * as extend from 'extend' ;
@@ -21,8 +21,6 @@ import * as is from 'is';
2121
2222const isHtml = require ( 'is-html' ) ;
2323import { DecorateRequestOptions , BodyResponseCallback } from '@google-cloud/common/build/src/util' ;
24- import * as r from 'request' ;
25- import { teenyRequest } from 'teeny-request' ;
2624
2725const PKG = require ( '../../../package.json' ) ;
2826
@@ -34,7 +32,7 @@ export interface TranslateRequest {
3432}
3533
3634export interface TranslateCallback < T extends string | string [ ] > {
37- ( err : Error | null , translations ?: T | null , apiResponse ?: r . Response ) : void ;
35+ ( err : Error | null , translations ?: T | null , apiResponse ?: Metadata ) : void ;
3836}
3937
4038export interface DetectResult {
@@ -44,7 +42,7 @@ export interface DetectResult {
4442}
4543
4644export interface DetectCallback < T extends DetectResult | DetectResult [ ] > {
47- ( err : Error | null , results ?: T | null , apiResponse ?: r . Response ) : void ;
45+ ( err : Error | null , results ?: T | null , apiResponse ?: Metadata ) : void ;
4846}
4947
5048export interface LanguageResult {
@@ -54,14 +52,13 @@ export interface LanguageResult {
5452
5553export interface GetLanguagesCallback {
5654 ( err : Error | null , results ?: LanguageResult [ ] | null ,
57- apiResponse ?: r . Response ) : void ;
55+ apiResponse ?: Metadata ) : void ;
5856}
5957
6058export interface TranslateConfig extends GoogleAuthOptions {
6159 key ?: string ;
6260 autoRetry ?: boolean ;
6361 maxRetries ?: number ;
64- request ?: typeof r ;
6562}
6663
6764/**
@@ -135,19 +132,17 @@ export class Translate extends Service {
135132 scopes : [ 'https://www.googleapis.com/auth/cloud-platform' ] ,
136133 packageJson : require ( '../../../package.json' ) ,
137134 projectIdRequired : false ,
138- requestModule : teenyRequest as typeof r ,
139135 } ;
140136
141137 super ( config , options ) ;
142138 this . options = options || { } ;
143- this . options . request = config . requestModule ;
144139 if ( this . options . key ) {
145140 this . key = this . options . key ;
146141 }
147142 }
148143
149- detect ( input : string ) : Promise < [ DetectResult , r . Response ] > ;
150- detect ( input : string [ ] ) : Promise < [ DetectResult [ ] , r . Response ] > ;
144+ detect ( input : string ) : Promise < [ DetectResult , Metadata ] > ;
145+ detect ( input : string [ ] ) : Promise < [ DetectResult [ ] , Metadata ] > ;
151146 detect ( input : string , callback : DetectCallback < DetectResult > ) : void ;
152147 detect ( input : string [ ] , callback : DetectCallback < DetectResult [ ] > ) : void ;
153148/**
@@ -236,8 +231,8 @@ export class Translate extends Service {
236231 detect (
237232 input : string | string [ ] ,
238233 callback ?: DetectCallback < DetectResult > |
239- DetectCallback < DetectResult [ ] > ) : void | Promise < [ DetectResult , r . Response ] > |
240- Promise < [ DetectResult [ ] , r . Response ] > {
234+ DetectCallback < DetectResult [ ] > ) : void | Promise < [ DetectResult , Metadata ] > |
235+ Promise < [ DetectResult [ ] , Metadata ] > {
241236 const inputIsArray = Array . isArray ( input ) ;
242237 input = arrify ( input ) ;
243238 this . request (
@@ -275,7 +270,7 @@ export class Translate extends Service {
275270 } ) ;
276271 }
277272
278- getLanguages ( target ?: string ) : Promise < [ LanguageResult [ ] , r . Response ] > ;
273+ getLanguages ( target ?: string ) : Promise < [ LanguageResult [ ] , Metadata ] > ;
279274 getLanguages ( target : string , callback : GetLanguagesCallback ) : void ;
280275 getLanguages ( callback : GetLanguagesCallback ) : void ;
281276/**
@@ -318,7 +313,7 @@ export class Translate extends Service {
318313 getLanguages (
319314 targetOrCallback ?: string | GetLanguagesCallback ,
320315 callback ?: GetLanguagesCallback ) :
321- void | Promise < [ LanguageResult [ ] , r . Response ] > {
316+ void | Promise < [ LanguageResult [ ] , Metadata ] > {
322317 let target : string ;
323318 if ( is . fn ( targetOrCallback ) ) {
324319 callback = targetOrCallback as GetLanguagesCallback ;
@@ -356,11 +351,11 @@ export class Translate extends Service {
356351 }
357352
358353 translate ( input : string , options : TranslateRequest ) :
359- Promise < [ string , r . Response ] > ;
354+ Promise < [ string , Metadata ] > ;
360355 translate ( input : string [ ] , options : TranslateRequest ) :
361- Promise < [ string [ ] , r . Response ] > ;
362- translate ( input : string , to : string ) : Promise < [ string , r . Response ] > ;
363- translate ( input : string [ ] , to : string ) : Promise < [ string [ ] , r . Response ] > ;
356+ Promise < [ string [ ] , Metadata ] > ;
357+ translate ( input : string , to : string ) : Promise < [ string , Metadata ] > ;
358+ translate ( input : string [ ] , to : string ) : Promise < [ string [ ] , Metadata ] > ;
364359 translate (
365360 input : string , options : TranslateRequest ,
366361 callback : TranslateCallback < string > ) : void ;
@@ -473,7 +468,7 @@ export class Translate extends Service {
473468 translate (
474469 inputs : string | string [ ] , optionsOrTo : string | TranslateRequest ,
475470 callback ?: TranslateCallback < string > | TranslateCallback < string [ ] > ) :
476- void | Promise < [ string , r . Response ] > | Promise < [ string [ ] , r . Response ] > {
471+ void | Promise < [ string , Metadata ] > | Promise < [ string [ ] , Metadata ] > {
477472 const inputIsArray = Array . isArray ( inputs ) ;
478473 const input = arrify ( inputs ) ;
479474 let options : TranslateRequest = { } ;
@@ -533,9 +528,6 @@ export class Translate extends Service {
533528 } ) ;
534529 }
535530
536- request ( reqOpts : DecorateRequestOptions ) : Promise < r . Response > ;
537- request ( reqOpts : DecorateRequestOptions , callback : BodyResponseCallback ) :
538- void ;
539531 /**
540532 * A custom request implementation. Requests to this API may optionally use an
541533 * API key for an application, not a bearer token from a service account. This
@@ -547,8 +539,7 @@ export class Translate extends Service {
547539 * @param {object } reqOpts - Request options that are passed to `request`.
548540 * @param {function } callback - The callback function passed to `request`.
549541 */
550- request ( reqOpts : DecorateRequestOptions , callback ?: BodyResponseCallback ) :
551- void | Promise < r . Response > {
542+ request ( reqOpts : DecorateRequestOptions , callback : BodyResponseCallback ) : void {
552543 if ( ! this . key ) {
553544 super . request ( reqOpts , callback ! ) ;
554545 return ;
0 commit comments