11import { InvalidArgumentError } from "./errors.ts" ;
22import {
33 AccountApiParameters ,
4- AccountInformation ,
54 BaseResponse ,
65 EngineParameters ,
76 GetBySearchIdParameters ,
8- Locations ,
97 LocationsApiParameters ,
108} from "./types.ts" ;
119import {
@@ -277,13 +275,12 @@ async function _getHtml(
277275 * Get a JSON response given a search ID.
278276 * - This search ID can be obtained from the `search_metadata.id` key in the response.
279277 * - Typically used together with the `async` parameter.
280- * - Accepts an optional callback.
281278 *
282- * @param {string } searchId - search ID
279+ * @param {string } searchId Search ID.
283280 * @param {object } parameters
284- * @param {string= } [parameters.api_key] - API key
285- * @param {number= } [parameters.timeout] - timeout in milliseconds
286- * @param {fn= } callback - optional callback
281+ * @param {string= } [parameters.api_key] API key.
282+ * @param {number= } [parameters.timeout] Timeout in milliseconds.
283+ * @param {fn= } callback Optional callback.
287284 * @example
288285 * const response = await getJson({ engine: "google", api_key: API_KEY, async: true, q: "coffee" });
289286 * const { id } = response.search_metadata;
@@ -319,14 +316,12 @@ export async function getJsonBySearchId(
319316 * Get a HTML response given a search ID.
320317 * - This search ID can be obtained from the `search_metadata.id` key in the response.
321318 * - Typically used together with the `async` parameter.
322- * - Accepts an optional callback.
323- * - Responds with a JSON if the search request hasn't completed.
324319 *
325- * @param {string } searchId - search ID
320+ * @param {string } searchId Search ID.
326321 * @param {object } parameters
327- * @param {string= } [parameters.api_key] - API key
328- * @param {number= } [parameters.timeout] - timeout in milliseconds
329- * @param {fn= } callback - optional callback
322+ * @param {string= } [parameters.api_key] API key.
323+ * @param {number= } [parameters.timeout] Timeout in milliseconds.
324+ * @param {fn= } callback Optional callback.
330325 * @example
331326 * const response = await getJson({ engine: "google", api_key: API_KEY, async: true, q: "coffee" });
332327 * const { id } = response.search_metadata;
@@ -359,12 +354,13 @@ export async function getHtmlBySearchId(
359354
360355/**
361356 * Get account information of an API key.
362- * https://serpapi.com/account-api
357+ *
358+ * Refer to https://serpapi.com/account-api for response examples.
363359 *
364360 * @param {object } parameters
365- * @param {string= } [parameters.api_key] - API key
366- * @param {number= } [parameters.timeout] - timeout in milliseconds
367- * @param {fn= } callback - optional callback
361+ * @param {string= } [parameters.api_key] API key.
362+ * @param {number= } [parameters.timeout] Timeout in milliseconds.
363+ * @param {fn= } callback Optional callback.
368364 * @example
369365 * // async/await
370366 * const info = await getAccount({ api_key: API_KEY });
@@ -374,27 +370,29 @@ export async function getHtmlBySearchId(
374370 */
375371export async function getAccount (
376372 parameters : AccountApiParameters = { } ,
377- callback ?: ( info : AccountInformation ) => void ,
373+ // deno-lint-ignore no-explicit-any
374+ callback ?: ( info : any ) => void ,
378375) {
379376 const key = validateApiKey ( parameters . api_key ) ;
380377 const timeout = validateTimeout ( parameters . timeout ) ;
381378 const response = await _internals . execute ( ACCOUNT_PATH , {
382379 api_key : key ,
383380 } , timeout ) ;
384- const info = JSON . parse ( response ) as AccountInformation ;
381+ const info = JSON . parse ( response ) ;
385382 callback ?.( info ) ;
386383 return info ;
387384}
388385
389386/**
390387 * Get supported locations. Does not require an API key.
391- * https://serpapi.com/locations-api
388+ *
389+ * Refer to https://serpapi.com/locations-api for response examples.
392390 *
393391 * @param {object } parameters
394- * @param {string= } [parameters.q] - query for a location
395- * @param {number= } [parameters.limit] - limit on number of locations returned
396- * @param {number= } [parameters.timeout] - timeout in milliseconds
397- * @param {fn= } callback - optional callback
392+ * @param {string= } [parameters.q] Query for a location.
393+ * @param {number= } [parameters.limit] Limit on number of locations returned.
394+ * @param {number= } [parameters.timeout] Timeout in milliseconds.
395+ * @param {fn= } callback Optional callback.
398396 * @example
399397 * // async/await
400398 * const locations = await getLocations({ limit: 3 });
@@ -404,15 +402,16 @@ export async function getAccount(
404402 */
405403export async function getLocations (
406404 parameters : LocationsApiParameters = { } ,
407- callback ?: ( locations : Locations ) => void ,
405+ // deno-lint-ignore no-explicit-any
406+ callback ?: ( locations : any ) => void ,
408407) {
409408 const timeout = validateTimeout ( parameters . timeout ) ;
410409 const response = await _internals . execute (
411410 LOCATIONS_PATH ,
412411 parameters ,
413412 timeout ,
414413 ) ;
415- const locations = JSON . parse ( response ) as Locations ;
414+ const locations = JSON . parse ( response ) ;
416415 callback ?.( locations ) ;
417416 return locations ;
418417}
0 commit comments