@spyglasshq/sdk 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/Client.d.ts +257 -6
  3. package/dist/cjs/Client.js +574 -9
  4. package/dist/cjs/api/{resources/search/client/requests/GetMediaRequest.d.ts → client/requests/SearchMediaRequest.d.ts} +13 -13
  5. package/dist/cjs/api/{resources/search/client/requests/GetMediaRequest.js → client/requests/SearchMediaRequest.js} +14 -14
  6. package/dist/cjs/api/client/requests/index.d.ts +5 -0
  7. package/dist/cjs/api/{resources/search/client → client}/requests/index.js +3 -3
  8. package/dist/cjs/api/index.d.ts +1 -0
  9. package/dist/cjs/api/index.js +1 -0
  10. package/dist/cjs/api/resources/account/client/Client.d.ts +131 -11
  11. package/dist/cjs/api/resources/account/client/Client.js +353 -14
  12. package/dist/cjs/api/resources/account/client/index.d.ts +1 -1
  13. package/dist/cjs/api/resources/account/client/index.js +15 -0
  14. package/dist/cjs/api/resources/{indexing/client/requests/IndexBrandRequest.d.ts → account/client/requests/IndexAccountRequest.d.ts} +1 -1
  15. package/dist/{esm/api/resources/indexing/client/requests/IndexBrandStatusRequest.d.mts → cjs/api/resources/account/client/requests/IndexStatusAccountRequest.d.ts} +1 -1
  16. package/dist/cjs/api/resources/{search/client/requests/GetBrandMediaInsightsRequest.d.ts → account/client/requests/InsightsAccountRequest.d.ts} +2 -2
  17. package/dist/cjs/api/resources/{search/client/requests/GetBrandLandingPagesRequest.d.ts → account/client/requests/LandingPagesAccountRequest.d.ts} +2 -2
  18. package/dist/cjs/api/resources/account/client/requests/index.d.ts +5 -0
  19. package/dist/{esm/api/resources/indexing/types/IndexBrandResponse.d.mts → cjs/api/resources/account/types/IndexAccountResponse.d.ts} +3 -3
  20. package/dist/cjs/api/resources/account/types/IndexAccountResponse.js +11 -0
  21. package/dist/cjs/api/resources/{indexing/types/IndexBrandStatusResponse.d.ts → account/types/IndexStatusAccountResponse.d.ts} +3 -3
  22. package/dist/cjs/api/resources/account/types/IndexStatusAccountResponse.js +11 -0
  23. package/dist/cjs/api/resources/account/types/InsightsAccountRequestType.d.ts +7 -0
  24. package/dist/cjs/api/resources/{search/types/GetBrandMediaInsightsRequestType.js → account/types/InsightsAccountRequestType.js} +2 -2
  25. package/dist/cjs/api/resources/{search/types/GetBrandMediaInsightsResponse.d.ts → account/types/InsightsAccountResponse.d.ts} +1 -1
  26. package/dist/cjs/api/resources/account/types/LandingPagesAccountRequestShowInactive.d.ts +5 -0
  27. package/dist/cjs/api/resources/{search/types/GetBrandLandingPagesRequestShowInactive.js → account/types/LandingPagesAccountRequestShowInactive.js} +2 -2
  28. package/dist/cjs/api/resources/{search/types/GetBrandLandingPagesResponse.d.ts → account/types/LandingPagesAccountResponse.d.ts} +3 -3
  29. package/dist/cjs/api/resources/account/types/index.d.ts +7 -1
  30. package/dist/cjs/api/resources/account/types/index.js +7 -1
  31. package/dist/cjs/api/resources/index.d.ts +1 -6
  32. package/dist/cjs/api/resources/index.js +5 -10
  33. package/dist/{esm/api/resources/search/types/GetMediaResponse.d.mts → cjs/api/types/SearchMediaResponse.d.ts} +3 -3
  34. package/dist/cjs/api/{resources/search/types/GetMediaResponse.js → types/SearchMediaResponse.js} +5 -5
  35. package/dist/cjs/api/types/index.d.ts +6 -0
  36. package/dist/cjs/api/types/index.js +6 -0
  37. package/dist/cjs/version.d.ts +1 -1
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/esm/BaseClient.mjs +2 -2
  40. package/dist/esm/Client.d.mts +257 -6
  41. package/dist/esm/Client.mjs +574 -9
  42. package/dist/esm/api/{resources/search/client/requests/GetMediaRequest.d.mts → client/requests/SearchMediaRequest.d.mts} +13 -13
  43. package/dist/esm/api/{resources/search/client/requests/GetMediaRequest.mjs → client/requests/SearchMediaRequest.mjs} +13 -13
  44. package/dist/esm/api/client/requests/index.d.mts +5 -0
  45. package/dist/esm/api/{resources/search/client → client}/requests/index.mjs +1 -1
  46. package/dist/esm/api/index.d.mts +1 -0
  47. package/dist/esm/api/index.mjs +1 -0
  48. package/dist/esm/api/resources/account/client/Client.d.mts +131 -11
  49. package/dist/esm/api/resources/account/client/Client.mjs +353 -14
  50. package/dist/esm/api/resources/account/client/index.d.mts +1 -1
  51. package/dist/esm/api/resources/account/client/index.mjs +1 -1
  52. package/dist/esm/api/resources/{indexing/client/requests/IndexBrandRequest.d.mts → account/client/requests/IndexAccountRequest.d.mts} +1 -1
  53. package/dist/{cjs/api/resources/indexing/client/requests/IndexBrandStatusRequest.d.ts → esm/api/resources/account/client/requests/IndexStatusAccountRequest.d.mts} +1 -1
  54. package/dist/esm/api/resources/{search/client/requests/GetBrandMediaInsightsRequest.d.mts → account/client/requests/InsightsAccountRequest.d.mts} +2 -2
  55. package/dist/esm/api/resources/{search/client/requests/GetBrandLandingPagesRequest.d.mts → account/client/requests/LandingPagesAccountRequest.d.mts} +2 -2
  56. package/dist/esm/api/resources/account/client/requests/index.d.mts +5 -0
  57. package/dist/{cjs/api/resources/indexing/types/IndexBrandResponse.d.ts → esm/api/resources/account/types/IndexAccountResponse.d.mts} +3 -3
  58. package/dist/esm/api/resources/account/types/IndexAccountResponse.mjs +8 -0
  59. package/dist/esm/api/resources/{indexing/types/IndexBrandStatusResponse.d.mts → account/types/IndexStatusAccountResponse.d.mts} +3 -3
  60. package/dist/esm/api/resources/account/types/IndexStatusAccountResponse.mjs +8 -0
  61. package/dist/esm/api/resources/account/types/InsightsAccountRequestType.d.mts +7 -0
  62. package/dist/esm/api/resources/{search/types/GetBrandMediaInsightsRequestType.mjs → account/types/InsightsAccountRequestType.mjs} +1 -1
  63. package/dist/esm/api/resources/{search/types/GetBrandMediaInsightsResponse.d.mts → account/types/InsightsAccountResponse.d.mts} +1 -1
  64. package/dist/esm/api/resources/account/types/LandingPagesAccountRequestShowInactive.d.mts +5 -0
  65. package/dist/esm/api/resources/{search/types/GetBrandLandingPagesRequestShowInactive.mjs → account/types/LandingPagesAccountRequestShowInactive.mjs} +1 -1
  66. package/dist/esm/api/resources/{search/types/GetBrandLandingPagesResponse.d.mts → account/types/LandingPagesAccountResponse.d.mts} +3 -3
  67. package/dist/esm/api/resources/account/types/index.d.mts +7 -1
  68. package/dist/esm/api/resources/account/types/index.mjs +7 -1
  69. package/dist/esm/api/resources/index.d.mts +1 -6
  70. package/dist/esm/api/resources/index.mjs +1 -6
  71. package/dist/{cjs/api/resources/search/types/GetMediaResponse.d.ts → esm/api/types/SearchMediaResponse.d.mts} +3 -3
  72. package/dist/esm/api/{resources/search/types/GetMediaResponse.mjs → types/SearchMediaResponse.mjs} +4 -4
  73. package/dist/esm/api/types/index.d.mts +6 -0
  74. package/dist/esm/api/types/index.mjs +6 -0
  75. package/dist/esm/version.d.mts +1 -1
  76. package/dist/esm/version.mjs +1 -1
  77. package/package.json +1 -23
  78. package/reference.md +109 -111
  79. package/dist/cjs/api/resources/indexing/client/Client.d.ts +0 -74
  80. package/dist/cjs/api/resources/indexing/client/Client.js +0 -219
  81. package/dist/cjs/api/resources/indexing/client/requests/index.d.ts +0 -2
  82. package/dist/cjs/api/resources/indexing/exports.d.ts +0 -2
  83. package/dist/cjs/api/resources/indexing/exports.js +0 -21
  84. package/dist/cjs/api/resources/indexing/index.d.ts +0 -2
  85. package/dist/cjs/api/resources/indexing/index.js +0 -18
  86. package/dist/cjs/api/resources/indexing/types/IndexBrandResponse.js +0 -11
  87. package/dist/cjs/api/resources/indexing/types/IndexBrandStatusResponse.js +0 -11
  88. package/dist/cjs/api/resources/indexing/types/index.d.ts +0 -2
  89. package/dist/cjs/api/resources/indexing/types/index.js +0 -18
  90. package/dist/cjs/api/resources/search/client/Client.d.ts +0 -337
  91. package/dist/cjs/api/resources/search/client/Client.js +0 -823
  92. package/dist/cjs/api/resources/search/client/index.d.ts +0 -1
  93. package/dist/cjs/api/resources/search/client/index.js +0 -17
  94. package/dist/cjs/api/resources/search/client/requests/index.d.ts +0 -8
  95. package/dist/cjs/api/resources/search/exports.d.ts +0 -2
  96. package/dist/cjs/api/resources/search/exports.js +0 -21
  97. package/dist/cjs/api/resources/search/index.d.ts +0 -2
  98. package/dist/cjs/api/resources/search/index.js +0 -18
  99. package/dist/cjs/api/resources/search/types/GetBrandLandingPagesRequestShowInactive.d.ts +0 -5
  100. package/dist/cjs/api/resources/search/types/GetBrandMediaInsightsRequestType.d.ts +0 -7
  101. package/dist/cjs/api/resources/search/types/index.d.ts +0 -10
  102. package/dist/cjs/api/resources/search/types/index.js +0 -26
  103. package/dist/esm/api/resources/indexing/client/Client.d.mts +0 -74
  104. package/dist/esm/api/resources/indexing/client/Client.mjs +0 -182
  105. package/dist/esm/api/resources/indexing/client/requests/index.d.mts +0 -2
  106. package/dist/esm/api/resources/indexing/exports.d.mts +0 -2
  107. package/dist/esm/api/resources/indexing/exports.mjs +0 -3
  108. package/dist/esm/api/resources/indexing/index.d.mts +0 -2
  109. package/dist/esm/api/resources/indexing/index.mjs +0 -2
  110. package/dist/esm/api/resources/indexing/types/IndexBrandResponse.mjs +0 -8
  111. package/dist/esm/api/resources/indexing/types/IndexBrandStatusResponse.mjs +0 -8
  112. package/dist/esm/api/resources/indexing/types/index.d.mts +0 -2
  113. package/dist/esm/api/resources/indexing/types/index.mjs +0 -2
  114. package/dist/esm/api/resources/search/client/Client.d.mts +0 -337
  115. package/dist/esm/api/resources/search/client/Client.mjs +0 -786
  116. package/dist/esm/api/resources/search/client/index.d.mts +0 -1
  117. package/dist/esm/api/resources/search/client/index.mjs +0 -1
  118. package/dist/esm/api/resources/search/client/requests/index.d.mts +0 -8
  119. package/dist/esm/api/resources/search/exports.d.mts +0 -2
  120. package/dist/esm/api/resources/search/exports.mjs +0 -3
  121. package/dist/esm/api/resources/search/index.d.mts +0 -2
  122. package/dist/esm/api/resources/search/index.mjs +0 -2
  123. package/dist/esm/api/resources/search/types/GetBrandLandingPagesRequestShowInactive.d.mts +0 -5
  124. package/dist/esm/api/resources/search/types/GetBrandMediaInsightsRequestType.d.mts +0 -7
  125. package/dist/esm/api/resources/search/types/index.d.mts +0 -10
  126. package/dist/esm/api/resources/search/types/index.mjs +0 -10
  127. /package/dist/cjs/api/{resources/indexing/client → client}/index.d.ts +0 -0
  128. /package/dist/cjs/api/{resources/indexing/client → client}/index.js +0 -0
  129. /package/dist/cjs/api/{resources/search/client → client}/requests/GetCommentsRequest.d.ts +0 -0
  130. /package/dist/cjs/api/{resources/search/client → client}/requests/GetCommentsRequest.js +0 -0
  131. /package/dist/cjs/api/{resources/search/client → client}/requests/SearchBrandsRequest.d.ts +0 -0
  132. /package/dist/cjs/api/{resources/search/client → client}/requests/SearchBrandsRequest.js +0 -0
  133. /package/dist/cjs/api/{resources/search/client → client}/requests/SearchCreatorsRequest.d.ts +0 -0
  134. /package/dist/cjs/api/{resources/search/client → client}/requests/SearchCreatorsRequest.js +0 -0
  135. /package/dist/cjs/api/{resources/search/client → client}/requests/SearchTaxonomiesRequest.d.ts +0 -0
  136. /package/dist/cjs/api/{resources/search/client → client}/requests/SearchTaxonomiesRequest.js +0 -0
  137. /package/dist/cjs/api/resources/{search → account}/client/requests/GetAccountRequest.d.ts +0 -0
  138. /package/dist/cjs/api/resources/{search → account}/client/requests/GetAccountRequest.js +0 -0
  139. /package/dist/cjs/api/resources/account/{types/GetCreditUsageResponse.js → client/requests/IndexAccountRequest.js} +0 -0
  140. /package/dist/cjs/api/resources/{indexing/client/requests/IndexBrandRequest.js → account/client/requests/IndexStatusAccountRequest.js} +0 -0
  141. /package/dist/cjs/api/resources/{indexing/client/requests/IndexBrandStatusRequest.js → account/client/requests/InsightsAccountRequest.js} +0 -0
  142. /package/dist/cjs/api/resources/{search/client/requests/GetBrandLandingPagesRequest.js → account/client/requests/LandingPagesAccountRequest.js} +0 -0
  143. /package/dist/cjs/api/resources/{indexing → account}/client/requests/index.js +0 -0
  144. /package/dist/cjs/api/resources/{search → account}/types/GetAccountResponse.d.ts +0 -0
  145. /package/dist/cjs/api/resources/{search → account}/types/GetAccountResponse.js +0 -0
  146. /package/dist/cjs/api/resources/{search/client/requests/GetBrandMediaInsightsRequest.js → account/types/InsightsAccountResponse.js} +0 -0
  147. /package/dist/cjs/api/resources/{search/types/GetBrandLandingPagesResponse.js → account/types/LandingPagesAccountResponse.js} +0 -0
  148. /package/dist/cjs/api/{resources/search/types → types}/GetCommentsResponse.d.ts +0 -0
  149. /package/dist/cjs/api/{resources/search/types → types}/GetCommentsResponse.js +0 -0
  150. /package/dist/cjs/api/{resources/account/types → types}/GetCreditUsageResponse.d.ts +0 -0
  151. /package/dist/cjs/api/{resources/search/types/GetBrandMediaInsightsResponse.js → types/GetCreditUsageResponse.js} +0 -0
  152. /package/dist/cjs/api/{resources/search/types → types}/SearchBrandsResponse.d.ts +0 -0
  153. /package/dist/cjs/api/{resources/search/types → types}/SearchBrandsResponse.js +0 -0
  154. /package/dist/cjs/api/{resources/search/types → types}/SearchCreatorsResponse.d.ts +0 -0
  155. /package/dist/cjs/api/{resources/search/types → types}/SearchCreatorsResponse.js +0 -0
  156. /package/dist/cjs/api/{resources/search/types → types}/SearchTaxonomiesResponse.d.ts +0 -0
  157. /package/dist/cjs/api/{resources/search/types → types}/SearchTaxonomiesResponse.js +0 -0
  158. /package/dist/esm/api/{resources/indexing/client → client}/index.d.mts +0 -0
  159. /package/dist/esm/api/{resources/indexing/client → client}/index.mjs +0 -0
  160. /package/dist/esm/api/{resources/search/client → client}/requests/GetCommentsRequest.d.mts +0 -0
  161. /package/dist/esm/api/{resources/search/client → client}/requests/GetCommentsRequest.mjs +0 -0
  162. /package/dist/esm/api/{resources/search/client → client}/requests/SearchBrandsRequest.d.mts +0 -0
  163. /package/dist/esm/api/{resources/search/client → client}/requests/SearchBrandsRequest.mjs +0 -0
  164. /package/dist/esm/api/{resources/search/client → client}/requests/SearchCreatorsRequest.d.mts +0 -0
  165. /package/dist/esm/api/{resources/search/client → client}/requests/SearchCreatorsRequest.mjs +0 -0
  166. /package/dist/esm/api/{resources/search/client → client}/requests/SearchTaxonomiesRequest.d.mts +0 -0
  167. /package/dist/esm/api/{resources/search/client → client}/requests/SearchTaxonomiesRequest.mjs +0 -0
  168. /package/dist/esm/api/resources/{search → account}/client/requests/GetAccountRequest.d.mts +0 -0
  169. /package/dist/esm/api/resources/{search → account}/client/requests/GetAccountRequest.mjs +0 -0
  170. /package/dist/esm/api/resources/account/{types/GetCreditUsageResponse.mjs → client/requests/IndexAccountRequest.mjs} +0 -0
  171. /package/dist/esm/api/resources/{indexing/client/requests/IndexBrandRequest.mjs → account/client/requests/IndexStatusAccountRequest.mjs} +0 -0
  172. /package/dist/esm/api/resources/{indexing/client/requests/IndexBrandStatusRequest.mjs → account/client/requests/InsightsAccountRequest.mjs} +0 -0
  173. /package/dist/esm/api/resources/{search/client/requests/GetBrandLandingPagesRequest.mjs → account/client/requests/LandingPagesAccountRequest.mjs} +0 -0
  174. /package/dist/esm/api/resources/{indexing → account}/client/requests/index.mjs +0 -0
  175. /package/dist/esm/api/resources/{search → account}/types/GetAccountResponse.d.mts +0 -0
  176. /package/dist/esm/api/resources/{search → account}/types/GetAccountResponse.mjs +0 -0
  177. /package/dist/esm/api/resources/{search/client/requests/GetBrandMediaInsightsRequest.mjs → account/types/InsightsAccountResponse.mjs} +0 -0
  178. /package/dist/esm/api/resources/{search/types/GetBrandLandingPagesResponse.mjs → account/types/LandingPagesAccountResponse.mjs} +0 -0
  179. /package/dist/esm/api/{resources/search/types → types}/GetCommentsResponse.d.mts +0 -0
  180. /package/dist/esm/api/{resources/search/types → types}/GetCommentsResponse.mjs +0 -0
  181. /package/dist/esm/api/{resources/account/types → types}/GetCreditUsageResponse.d.mts +0 -0
  182. /package/dist/esm/api/{resources/search/types/GetBrandMediaInsightsResponse.mjs → types/GetCreditUsageResponse.mjs} +0 -0
  183. /package/dist/esm/api/{resources/search/types → types}/SearchBrandsResponse.d.mts +0 -0
  184. /package/dist/esm/api/{resources/search/types → types}/SearchBrandsResponse.mjs +0 -0
  185. /package/dist/esm/api/{resources/search/types → types}/SearchCreatorsResponse.d.mts +0 -0
  186. /package/dist/esm/api/{resources/search/types → types}/SearchCreatorsResponse.mjs +0 -0
  187. /package/dist/esm/api/{resources/search/types → types}/SearchTaxonomiesResponse.d.mts +0 -0
  188. /package/dist/esm/api/{resources/search/types → types}/SearchTaxonomiesResponse.mjs +0 -0
@@ -1,823 +0,0 @@
1
- "use strict";
2
- // This file was auto-generated by Fern from our API Definition.
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.SearchClient = void 0;
47
- const BaseClient_js_1 = require("../../../../BaseClient.js");
48
- const headers_js_1 = require("../../../../core/headers.js");
49
- const core = __importStar(require("../../../../core/index.js"));
50
- const requestBody_js_1 = require("../../../../core/requestBody.js");
51
- const environments = __importStar(require("../../../../environments.js"));
52
- const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
53
- const errors = __importStar(require("../../../../errors/index.js"));
54
- const spyglass = __importStar(require("../../../index.js"));
55
- /**
56
- * Search accounts, ads, and related data.
57
- */
58
- class SearchClient {
59
- constructor(options) {
60
- this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
61
- }
62
- /**
63
- * Find brands.
64
- * Search semantically with `query`, or look them up by name, id, or
65
- * social handle. Either way, you can also narrow the results with
66
- * filters such as product taxonomy, location, and follower count.
67
- *
68
- * Send one search field. Each field is its own mode:
69
- *
70
- * - **Query** (`query`). A natural-language brief. Runs a language model and
71
- * ranks by relevance, so `sortBy` is ignored. Bills at least one row even
72
- * when nothing matches.
73
- * - **Name** (`names`). Fuzzy-matches account names (a case-insensitive contains
74
- * match). Pass every name in one array.
75
- * - **ID** (`brandIds`). Looks up known ids. Missing ids are omitted and listed
76
- * in `unmatchedIds`. `limit` and `offset` are ignored.
77
- * - **Instagram** (`igUsername`). Case-insensitive contains match on the
78
- * handle. A leading `@` is ignored.
79
- * - **TikTok** (`tiktokUsername`). Same match on the TikTok handle.
80
- *
81
- * If a request includes more than one of these fields, only the highest
82
- * priority field is used. The rest are ignored:
83
- *
84
- * 1. `brandIds`
85
- * 2. `igUsername` or `tiktokUsername` (if both are set, either handle can match)
86
- * 3. `names`
87
- * 4. `query`
88
- *
89
- * One exception: `query` together with `names` uses both. `names` narrows the
90
- * set, and `query` ranks inside it.
91
- *
92
- * `limit` (default 20, max 100) caps the rows returned, and the cost, for
93
- * every mode except ID.
94
- *
95
- * Limited to 120 requests per minute per user.
96
- * Costs 2,000 microdollars ($0.0020) per brand returned, charged against your plan's monthly credits. The count field is what you were charged for.
97
- * A `query` search runs a language model, so it bills a minimum of one
98
- * row even when nothing matches.
99
- *
100
- * @param {spyglass.SearchBrandsRequest} request
101
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
102
- *
103
- * @throws {@link spyglass.BadRequestError}
104
- * @throws {@link spyglass.UnauthorizedError}
105
- * @throws {@link spyglass.PaymentRequiredError}
106
- * @throws {@link spyglass.ForbiddenError}
107
- * @throws {@link spyglass.MethodNotAllowedError}
108
- * @throws {@link spyglass.ContentTooLargeError}
109
- * @throws {@link spyglass.TooManyRequestsError}
110
- * @throws {@link spyglass.InternalServerError}
111
- * @throws {@link errors.SpyglassError}
112
- * @throws {@link errors.SpyglassTimeoutError}
113
- *
114
- * @example
115
- * await client.search.brands({
116
- * names: ["Nike"],
117
- * limit: 3
118
- * })
119
- */
120
- brands(request = {}, requestOptions) {
121
- return core.HttpResponsePromise.fromPromise(this.__brands(request, requestOptions));
122
- }
123
- __brands() {
124
- return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
125
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
126
- const _authRequest = yield this._options.authProvider.getAuthRequest();
127
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
128
- const _response = yield core.fetcher({
129
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, "brands"),
130
- method: "POST",
131
- headers: _headers,
132
- contentType: "application/json",
133
- queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
134
- requestType: "json",
135
- body: (0, requestBody_js_1.mergeAdditionalBodyParameters)(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
136
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
137
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
138
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
139
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
140
- logging: this._options.logging,
141
- });
142
- if (_response.ok) {
143
- return { data: _response.body, rawResponse: _response.rawResponse };
144
- }
145
- if (_response.error.reason === "status-code") {
146
- switch (_response.error.statusCode) {
147
- case 400:
148
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
149
- case 401:
150
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
151
- case 402:
152
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
153
- case 403:
154
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
155
- case 405:
156
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
157
- case 413:
158
- throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
159
- case 429:
160
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
161
- case 500:
162
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
163
- default:
164
- throw new errors.SpyglassError({
165
- statusCode: _response.error.statusCode,
166
- body: _response.error.body,
167
- rawResponse: _response.rawResponse,
168
- });
169
- }
170
- }
171
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/brands");
172
- });
173
- }
174
- /**
175
- * Find creators.
176
- * Search semantically with `query`, or look them up by name, id, or
177
- * social handle. Either way, you can also narrow the results with
178
- * filters such as audience profile, location, and follower count.
179
- *
180
- * Send one search field. Each field is its own mode:
181
- *
182
- * - **Query** (`query`). A natural-language brief. Runs a language model and
183
- * ranks by relevance, so `sortBy` is ignored. Bills at least one row even
184
- * when nothing matches.
185
- * - **Name** (`names`). Fuzzy-matches account names (a case-insensitive contains
186
- * match). Pass every name in one array.
187
- * - **ID** (`brandIds`). Looks up known ids. Missing ids are omitted and listed
188
- * in `unmatchedIds`. `limit` and `offset` are ignored.
189
- * - **Instagram** (`igUsername`). Case-insensitive contains match on the
190
- * handle. A leading `@` is ignored.
191
- * - **TikTok** (`tiktokUsername`). Same match on the TikTok handle.
192
- *
193
- * If a request includes more than one of these fields, only the highest
194
- * priority field is used. The rest are ignored:
195
- *
196
- * 1. `brandIds`
197
- * 2. `igUsername` or `tiktokUsername` (if both are set, either handle can match)
198
- * 3. `names`
199
- * 4. `query`
200
- *
201
- * One exception: `query` together with `names` uses both. `names` narrows the
202
- * set, and `query` ranks inside it.
203
- *
204
- * `limit` (default 20, max 100) caps the rows returned, and the cost, for
205
- * every mode except ID.
206
- *
207
- * Limited to 120 requests per minute per user.
208
- * Costs 2,000 microdollars ($0.0020) per creator returned, charged against your plan's monthly credits. The count field is what you were charged for.
209
- * A `query` search runs a language model, so it bills a minimum of one
210
- * row even when nothing matches.
211
- *
212
- * @param {spyglass.SearchCreatorsRequest} request
213
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
214
- *
215
- * @throws {@link spyglass.BadRequestError}
216
- * @throws {@link spyglass.UnauthorizedError}
217
- * @throws {@link spyglass.PaymentRequiredError}
218
- * @throws {@link spyglass.ForbiddenError}
219
- * @throws {@link spyglass.MethodNotAllowedError}
220
- * @throws {@link spyglass.ContentTooLargeError}
221
- * @throws {@link spyglass.TooManyRequestsError}
222
- * @throws {@link spyglass.InternalServerError}
223
- * @throws {@link errors.SpyglassError}
224
- * @throws {@link errors.SpyglassTimeoutError}
225
- *
226
- * @example
227
- * await client.search.creators({
228
- * igUsername: "charlidamelio",
229
- * limit: 3,
230
- * gender: "female"
231
- * })
232
- */
233
- creators(request = {}, requestOptions) {
234
- return core.HttpResponsePromise.fromPromise(this.__creators(request, requestOptions));
235
- }
236
- __creators() {
237
- return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
238
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
239
- const _authRequest = yield this._options.authProvider.getAuthRequest();
240
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
241
- const _response = yield core.fetcher({
242
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, "creators"),
243
- method: "POST",
244
- headers: _headers,
245
- contentType: "application/json",
246
- queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
247
- requestType: "json",
248
- body: (0, requestBody_js_1.mergeAdditionalBodyParameters)(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
249
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
250
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
251
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
252
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
253
- logging: this._options.logging,
254
- });
255
- if (_response.ok) {
256
- return { data: _response.body, rawResponse: _response.rawResponse };
257
- }
258
- if (_response.error.reason === "status-code") {
259
- switch (_response.error.statusCode) {
260
- case 400:
261
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
262
- case 401:
263
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
264
- case 402:
265
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
266
- case 403:
267
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
268
- case 405:
269
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
270
- case 413:
271
- throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
272
- case 429:
273
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
274
- case 500:
275
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
276
- default:
277
- throw new errors.SpyglassError({
278
- statusCode: _response.error.statusCode,
279
- body: _response.error.body,
280
- rawResponse: _response.rawResponse,
281
- });
282
- }
283
- }
284
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/creators");
285
- });
286
- }
287
- /**
288
- * Fetch a single brand or creator by id. The `type` field tells you
289
- * which one you got: `BRAND` or `CREATOR`, and the creator-only fields
290
- * (`gender`, `ageRange`, ...) are present only on `CREATOR`.
291
- *
292
- * Limited to 120 requests per minute per user.
293
- * Costs 2,000 microdollars ($0.0020) per account returned, charged against your plan's monthly credits.
294
- * An id that matches nothing returns 404 and is free.
295
- *
296
- * @param {spyglass.GetAccountRequest} request
297
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
298
- *
299
- * @throws {@link spyglass.BadRequestError}
300
- * @throws {@link spyglass.UnauthorizedError}
301
- * @throws {@link spyglass.PaymentRequiredError}
302
- * @throws {@link spyglass.ForbiddenError}
303
- * @throws {@link spyglass.NotFoundError}
304
- * @throws {@link spyglass.MethodNotAllowedError}
305
- * @throws {@link spyglass.TooManyRequestsError}
306
- * @throws {@link spyglass.InternalServerError}
307
- * @throws {@link errors.SpyglassError}
308
- * @throws {@link errors.SpyglassTimeoutError}
309
- *
310
- * @example
311
- * await client.search.getAccount({
312
- * id: "id"
313
- * })
314
- */
315
- getAccount(request, requestOptions) {
316
- return core.HttpResponsePromise.fromPromise(this.__getAccount(request, requestOptions));
317
- }
318
- __getAccount(request, requestOptions) {
319
- return __awaiter(this, void 0, void 0, function* () {
320
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
321
- const { id } = request;
322
- const _authRequest = yield this._options.authProvider.getAuthRequest();
323
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
324
- const _response = yield core.fetcher({
325
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, `account/${core.url.encodePathParam(id, errors.SpyglassError)}`),
326
- method: "GET",
327
- headers: _headers,
328
- queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
329
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
330
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
331
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
332
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
333
- logging: this._options.logging,
334
- });
335
- if (_response.ok) {
336
- return { data: _response.body, rawResponse: _response.rawResponse };
337
- }
338
- if (_response.error.reason === "status-code") {
339
- switch (_response.error.statusCode) {
340
- case 400:
341
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
342
- case 401:
343
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
344
- case 402:
345
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
346
- case 403:
347
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
348
- case 404:
349
- throw new spyglass.NotFoundError(_response.error.body, _response.rawResponse);
350
- case 405:
351
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
352
- case 429:
353
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
354
- case 500:
355
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
356
- default:
357
- throw new errors.SpyglassError({
358
- statusCode: _response.error.statusCode,
359
- body: _response.error.body,
360
- rawResponse: _response.rawResponse,
361
- });
362
- }
363
- }
364
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/account/{id}");
365
- });
366
- }
367
- /**
368
- * Find taxonomy paths you can pass to POST /media as `taxonomy`.
369
- * `query` is a product or category phrase. Each path is a string
370
- * such as `Apparel > Footwear > Sneakers`.
371
- *
372
- * Limited to 120 requests per minute per user.
373
- * This call is free and does not use credits.
374
- *
375
- * @param {spyglass.SearchTaxonomiesRequest} request
376
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
377
- *
378
- * @throws {@link spyglass.BadRequestError}
379
- * @throws {@link spyglass.UnauthorizedError}
380
- * @throws {@link spyglass.PaymentRequiredError}
381
- * @throws {@link spyglass.ForbiddenError}
382
- * @throws {@link spyglass.MethodNotAllowedError}
383
- * @throws {@link spyglass.TooManyRequestsError}
384
- * @throws {@link spyglass.InternalServerError}
385
- * @throws {@link errors.SpyglassError}
386
- * @throws {@link errors.SpyglassTimeoutError}
387
- *
388
- * @example
389
- * await client.search.taxonomies({
390
- * query: "running shoes"
391
- * })
392
- */
393
- taxonomies(request, requestOptions) {
394
- return core.HttpResponsePromise.fromPromise(this.__taxonomies(request, requestOptions));
395
- }
396
- __taxonomies(request, requestOptions) {
397
- return __awaiter(this, void 0, void 0, function* () {
398
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
399
- const { query, limit } = request;
400
- const _queryParams = {
401
- query,
402
- limit,
403
- };
404
- const _authRequest = yield this._options.authProvider.getAuthRequest();
405
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
406
- const _response = yield core.fetcher({
407
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, "taxonomies"),
408
- method: "GET",
409
- headers: _headers,
410
- queryString: core.url
411
- .queryBuilder()
412
- .addMany(_queryParams)
413
- .mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams)
414
- .build(),
415
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
416
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
417
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
418
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
419
- logging: this._options.logging,
420
- });
421
- if (_response.ok) {
422
- return { data: _response.body, rawResponse: _response.rawResponse };
423
- }
424
- if (_response.error.reason === "status-code") {
425
- switch (_response.error.statusCode) {
426
- case 400:
427
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
428
- case 401:
429
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
430
- case 402:
431
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
432
- case 403:
433
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
434
- case 405:
435
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
436
- case 429:
437
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
438
- case 500:
439
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
440
- default:
441
- throw new errors.SpyglassError({
442
- statusCode: _response.error.statusCode,
443
- body: _response.error.body,
444
- rawResponse: _response.rawResponse,
445
- });
446
- }
447
- }
448
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/taxonomies");
449
- });
450
- }
451
- /**
452
- * Return creatives. Pass `brandId` to scope to one brand or creator,
453
- * or omit it to search the whole corpus. Without `brandId`,
454
- * `query` is required.
455
- *
456
- * Limited to 120 requests per minute per user.
457
- * Costs 1,000 microdollars ($0.0010) per creative returned, charged against your plan's monthly credits. The count field is what you were charged for.
458
- * The call bills a minimum of one row even when nothing matches. In that
459
- * case `count` is 0 but you are charged for one row.
460
- *
461
- * @param {spyglass.GetMediaRequest} request
462
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
463
- *
464
- * @throws {@link spyglass.BadRequestError}
465
- * @throws {@link spyglass.UnauthorizedError}
466
- * @throws {@link spyglass.PaymentRequiredError}
467
- * @throws {@link spyglass.ForbiddenError}
468
- * @throws {@link spyglass.NotFoundError}
469
- * @throws {@link spyglass.MethodNotAllowedError}
470
- * @throws {@link spyglass.ContentTooLargeError}
471
- * @throws {@link spyglass.TooManyRequestsError}
472
- * @throws {@link spyglass.InternalServerError}
473
- * @throws {@link errors.SpyglassError}
474
- * @throws {@link errors.SpyglassTimeoutError}
475
- *
476
- * @example
477
- * await client.search.getMedia({
478
- * query: "comfort-focused video ads",
479
- * limit: 20
480
- * })
481
- */
482
- getMedia(request = {}, requestOptions) {
483
- return core.HttpResponsePromise.fromPromise(this.__getMedia(request, requestOptions));
484
- }
485
- __getMedia() {
486
- return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
487
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
488
- const _authRequest = yield this._options.authProvider.getAuthRequest();
489
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
490
- const _response = yield core.fetcher({
491
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, "media"),
492
- method: "POST",
493
- headers: _headers,
494
- contentType: "application/json",
495
- queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
496
- requestType: "json",
497
- body: (0, requestBody_js_1.mergeAdditionalBodyParameters)(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
498
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
499
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
500
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
501
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
502
- logging: this._options.logging,
503
- });
504
- if (_response.ok) {
505
- return { data: _response.body, rawResponse: _response.rawResponse };
506
- }
507
- if (_response.error.reason === "status-code") {
508
- switch (_response.error.statusCode) {
509
- case 400:
510
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
511
- case 401:
512
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
513
- case 402:
514
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
515
- case 403:
516
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
517
- case 404:
518
- throw new spyglass.NotFoundError(_response.error.body, _response.rawResponse);
519
- case 405:
520
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
521
- case 413:
522
- throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
523
- case 429:
524
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
525
- case 500:
526
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
527
- default:
528
- throw new errors.SpyglassError({
529
- statusCode: _response.error.statusCode,
530
- body: _response.error.body,
531
- rawResponse: _response.rawResponse,
532
- });
533
- }
534
- }
535
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/media");
536
- });
537
- }
538
- /**
539
- * Return clustered creative themes for an account. `MEDIA_MIX` returns a
540
- * breakdown by media type; the other types return weekly buckets plus
541
- * ranked totals, highest first.
542
- *
543
- * `maxDaysBack` filters both the weekly bucket series and ranked
544
- * `totals` to creatives that started within the requested window.
545
- *
546
- * Limited to 120 requests per minute per user.
547
- * Costs 1,000 microdollars ($0.0010) per cluster returned, charged against your plan's monthly credits. The count field is what you were charged for.
548
- *
549
- * @param {spyglass.GetBrandMediaInsightsRequest} request
550
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
551
- *
552
- * @throws {@link spyglass.BadRequestError}
553
- * @throws {@link spyglass.UnauthorizedError}
554
- * @throws {@link spyglass.PaymentRequiredError}
555
- * @throws {@link spyglass.ForbiddenError}
556
- * @throws {@link spyglass.NotFoundError}
557
- * @throws {@link spyglass.MethodNotAllowedError}
558
- * @throws {@link spyglass.TooManyRequestsError}
559
- * @throws {@link spyglass.InternalServerError}
560
- * @throws {@link errors.SpyglassError}
561
- * @throws {@link errors.SpyglassTimeoutError}
562
- *
563
- * @example
564
- * await client.search.getBrandMediaInsights({
565
- * id: "id",
566
- * type: "HOOK"
567
- * })
568
- */
569
- getBrandMediaInsights(request, requestOptions) {
570
- return core.HttpResponsePromise.fromPromise(this.__getBrandMediaInsights(request, requestOptions));
571
- }
572
- __getBrandMediaInsights(request, requestOptions) {
573
- return __awaiter(this, void 0, void 0, function* () {
574
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
575
- const { id, type: type_, maxDaysBack, limit } = request;
576
- const _queryParams = {
577
- type: type_,
578
- maxDaysBack,
579
- limit,
580
- };
581
- const _authRequest = yield this._options.authProvider.getAuthRequest();
582
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
583
- const _response = yield core.fetcher({
584
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, `account/${core.url.encodePathParam(id, errors.SpyglassError)}/insights`),
585
- method: "GET",
586
- headers: _headers,
587
- queryString: core.url
588
- .queryBuilder()
589
- .addMany(_queryParams)
590
- .mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams)
591
- .build(),
592
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
593
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
594
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
595
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
596
- logging: this._options.logging,
597
- });
598
- if (_response.ok) {
599
- return {
600
- data: _response.body,
601
- rawResponse: _response.rawResponse,
602
- };
603
- }
604
- if (_response.error.reason === "status-code") {
605
- switch (_response.error.statusCode) {
606
- case 400:
607
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
608
- case 401:
609
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
610
- case 402:
611
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
612
- case 403:
613
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
614
- case 404:
615
- throw new spyglass.NotFoundError(_response.error.body, _response.rawResponse);
616
- case 405:
617
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
618
- case 429:
619
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
620
- case 500:
621
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
622
- default:
623
- throw new errors.SpyglassError({
624
- statusCode: _response.error.statusCode,
625
- body: _response.error.body,
626
- rawResponse: _response.rawResponse,
627
- });
628
- }
629
- }
630
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/account/{id}/insights");
631
- });
632
- }
633
- /**
634
- * Return the landing-page URLs a brand sends ad traffic to, ranked by
635
- * how often they appear across its ads.
636
- *
637
- * Limited to 120 requests per minute per user.
638
- * Costs 5,000 microdollars ($0.0050) per landing page returned, charged against your plan's monthly credits. The count field is what you were charged for.
639
- *
640
- * @param {spyglass.GetBrandLandingPagesRequest} request
641
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
642
- *
643
- * @throws {@link spyglass.BadRequestError}
644
- * @throws {@link spyglass.UnauthorizedError}
645
- * @throws {@link spyglass.PaymentRequiredError}
646
- * @throws {@link spyglass.ForbiddenError}
647
- * @throws {@link spyglass.NotFoundError}
648
- * @throws {@link spyglass.MethodNotAllowedError}
649
- * @throws {@link spyglass.TooManyRequestsError}
650
- * @throws {@link spyglass.InternalServerError}
651
- * @throws {@link errors.SpyglassError}
652
- * @throws {@link errors.SpyglassTimeoutError}
653
- *
654
- * @example
655
- * await client.search.getBrandLandingPages({
656
- * id: "id"
657
- * })
658
- */
659
- getBrandLandingPages(request, requestOptions) {
660
- return core.HttpResponsePromise.fromPromise(this.__getBrandLandingPages(request, requestOptions));
661
- }
662
- __getBrandLandingPages(request, requestOptions) {
663
- return __awaiter(this, void 0, void 0, function* () {
664
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
665
- const { id, showInactive, limit } = request;
666
- const _queryParams = {
667
- showInactive: showInactive != null ? showInactive : undefined,
668
- limit,
669
- };
670
- const _authRequest = yield this._options.authProvider.getAuthRequest();
671
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
672
- const _response = yield core.fetcher({
673
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, `account/${core.url.encodePathParam(id, errors.SpyglassError)}/landing-pages`),
674
- method: "GET",
675
- headers: _headers,
676
- queryString: core.url
677
- .queryBuilder()
678
- .addMany(_queryParams)
679
- .mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams)
680
- .build(),
681
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
682
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
683
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
684
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
685
- logging: this._options.logging,
686
- });
687
- if (_response.ok) {
688
- return {
689
- data: _response.body,
690
- rawResponse: _response.rawResponse,
691
- };
692
- }
693
- if (_response.error.reason === "status-code") {
694
- switch (_response.error.statusCode) {
695
- case 400:
696
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
697
- case 401:
698
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
699
- case 402:
700
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
701
- case 403:
702
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
703
- case 404:
704
- throw new spyglass.NotFoundError(_response.error.body, _response.rawResponse);
705
- case 405:
706
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
707
- case 429:
708
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
709
- case 500:
710
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
711
- default:
712
- throw new errors.SpyglassError({
713
- statusCode: _response.error.statusCode,
714
- body: _response.error.body,
715
- rawResponse: _response.rawResponse,
716
- });
717
- }
718
- }
719
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/account/{id}/landing-pages");
720
- });
721
- }
722
- /**
723
- * Return public comments for specific Instagram or TikTok posts.
724
- * Pass post URLs or the platform id. At least one of `instagramIds` or
725
- * `tiktokIds` is required (max 20 each). `limit` is comment pages
726
- * per post (default 1, max 20).
727
- *
728
- * Instagram accepts a shortcode or a post URL:
729
- *
730
- * - `C2xY9abcD1e`
731
- * - `https://www.instagram.com/p/C2xY9abcD1e/`
732
- * - `https://www.instagram.com/reel/C2xY9abcD1e/`
733
- *
734
- * TikTok accepts a video id or a post URL:
735
- *
736
- * - `7234567890123456789`
737
- * - `https://www.tiktok.com/@nike/video/7234567890123456789`
738
- *
739
- * Recent posts may be scraped live; older posts with stored comments
740
- * are served from cache.
741
- *
742
- * Limited to 20 requests per minute per user.
743
- * Costs 10,000 microdollars ($0.0100) per successful page of comments returned, charged against your plan's monthly credits.
744
- * Each comment page fetched live (`limit`, default 1) is one billed
745
- * unit. Cached posts do not scrape and are not billed.
746
- *
747
- * @param {spyglass.GetCommentsRequest} request
748
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
749
- *
750
- * @throws {@link spyglass.BadRequestError}
751
- * @throws {@link spyglass.UnauthorizedError}
752
- * @throws {@link spyglass.PaymentRequiredError}
753
- * @throws {@link spyglass.ForbiddenError}
754
- * @throws {@link spyglass.MethodNotAllowedError}
755
- * @throws {@link spyglass.ContentTooLargeError}
756
- * @throws {@link spyglass.TooManyRequestsError}
757
- * @throws {@link spyglass.InternalServerError}
758
- * @throws {@link errors.SpyglassError}
759
- * @throws {@link errors.SpyglassTimeoutError}
760
- *
761
- * @example
762
- * await client.search.getComments({
763
- * instagramIds: ["https://www.instagram.com/p/C2xY9abcD1e/"],
764
- * tiktokIds: ["https://www.tiktok.com/@nike/video/7234567890123456789"],
765
- * limit: 1
766
- * })
767
- */
768
- getComments(request = {}, requestOptions) {
769
- return core.HttpResponsePromise.fromPromise(this.__getComments(request, requestOptions));
770
- }
771
- __getComments() {
772
- return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
773
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
774
- const _authRequest = yield this._options.authProvider.getAuthRequest();
775
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
776
- const _response = yield core.fetcher({
777
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SpyglassEnvironment.Default, "comments"),
778
- method: "POST",
779
- headers: _headers,
780
- contentType: "application/json",
781
- queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
782
- requestType: "json",
783
- body: (0, requestBody_js_1.mergeAdditionalBodyParameters)(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
784
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
785
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
786
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
787
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
788
- logging: this._options.logging,
789
- });
790
- if (_response.ok) {
791
- return { data: _response.body, rawResponse: _response.rawResponse };
792
- }
793
- if (_response.error.reason === "status-code") {
794
- switch (_response.error.statusCode) {
795
- case 400:
796
- throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
797
- case 401:
798
- throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
799
- case 402:
800
- throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
801
- case 403:
802
- throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
803
- case 405:
804
- throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
805
- case 413:
806
- throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
807
- case 429:
808
- throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
809
- case 500:
810
- throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
811
- default:
812
- throw new errors.SpyglassError({
813
- statusCode: _response.error.statusCode,
814
- body: _response.error.body,
815
- rawResponse: _response.rawResponse,
816
- });
817
- }
818
- }
819
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/comments");
820
- });
821
- }
822
- }
823
- exports.SearchClient = SearchClient;