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