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