@spyglasshq/sdk 0.1.2 → 0.1.4

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