@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
@@ -8,26 +8,591 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ import * as spyglass from "./api/index.mjs";
11
12
  import { AccountClient } from "./api/resources/account/client/Client.mjs";
12
- import { IndexingClient } from "./api/resources/indexing/client/Client.mjs";
13
- import { SearchClient } from "./api/resources/search/client/Client.mjs";
14
13
  import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs";
14
+ import { mergeHeaders } from "./core/headers.mjs";
15
15
  import * as core from "./core/index.mjs";
16
+ import { mergeAdditionalBodyParameters } from "./core/requestBody.mjs";
17
+ import * as environments from "./environments.mjs";
18
+ import { handleNonStatusCodeError } from "./errors/handleNonStatusCodeError.mjs";
19
+ import * as errors from "./errors/index.mjs";
16
20
  export class Spyglass {
17
21
  constructor(options) {
18
22
  this._options = normalizeClientOptionsWithAuth(options);
19
23
  }
20
- get search() {
21
- var _a;
22
- return ((_a = this._search) !== null && _a !== void 0 ? _a : (this._search = new SearchClient(this._options)));
23
- }
24
24
  get account() {
25
25
  var _a;
26
26
  return ((_a = this._account) !== null && _a !== void 0 ? _a : (this._account = new AccountClient(this._options)));
27
27
  }
28
- get indexing() {
29
- var _a;
30
- return ((_a = this._indexing) !== null && _a !== void 0 ? _a : (this._indexing = new IndexingClient(this._options)));
28
+ /**
29
+ * Find brands.
30
+ * Search semantically with `query`, or look them up by name, id, or
31
+ * social handle. Either way, you can also narrow the results with
32
+ * filters such as product taxonomy, location, and follower count.
33
+ *
34
+ * Send one search field. Each field is its own mode:
35
+ *
36
+ * - **Query** (`query`). A natural-language brief. Runs a language model and
37
+ * ranks by relevance, so `sortBy` is ignored. Bills at least one row even
38
+ * when nothing matches.
39
+ * - **Name** (`names`). Fuzzy-matches account names (a case-insensitive contains
40
+ * match). Pass every name in one array.
41
+ * - **ID** (`brandIds`). Looks up known ids. Missing ids are omitted and listed
42
+ * in `unmatchedIds`. `limit` and `offset` are ignored.
43
+ * - **Instagram** (`igUsername`). Case-insensitive contains match on the
44
+ * handle. A leading `@` is ignored.
45
+ * - **TikTok** (`tiktokUsername`). Same match on the TikTok handle.
46
+ *
47
+ * If a request includes more than one of these fields, only the highest
48
+ * priority field is used. The rest are ignored:
49
+ *
50
+ * 1. `brandIds`
51
+ * 2. `igUsername` or `tiktokUsername` (if both are set, either handle can match)
52
+ * 3. `names`
53
+ * 4. `query`
54
+ *
55
+ * One exception: `query` together with `names` uses both. `names` narrows the
56
+ * set, and `query` ranks inside it.
57
+ *
58
+ * `limit` (default 20, max 100) caps the rows returned, and the cost, for
59
+ * every mode except ID.
60
+ *
61
+ * Limited to 120 requests per minute per user.
62
+ * 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.
63
+ * A `query` search runs a language model, so it bills a minimum of one
64
+ * row even when nothing matches.
65
+ *
66
+ * @param {spyglass.SearchBrandsRequest} request
67
+ * @param {Spyglass.RequestOptions} requestOptions - Request-specific configuration.
68
+ *
69
+ * @throws {@link spyglass.BadRequestError}
70
+ * @throws {@link spyglass.UnauthorizedError}
71
+ * @throws {@link spyglass.PaymentRequiredError}
72
+ * @throws {@link spyglass.ForbiddenError}
73
+ * @throws {@link spyglass.MethodNotAllowedError}
74
+ * @throws {@link spyglass.ContentTooLargeError}
75
+ * @throws {@link spyglass.TooManyRequestsError}
76
+ * @throws {@link spyglass.InternalServerError}
77
+ * @throws {@link errors.SpyglassError}
78
+ * @throws {@link errors.SpyglassTimeoutError}
79
+ *
80
+ * @example
81
+ * await client.searchBrands({
82
+ * names: ["Nike"],
83
+ * limit: 3
84
+ * })
85
+ */
86
+ searchBrands(request = {}, requestOptions) {
87
+ return core.HttpResponsePromise.fromPromise(this.__searchBrands(request, requestOptions));
88
+ }
89
+ __searchBrands() {
90
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
92
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
93
+ 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);
94
+ const _response = yield core.fetcher({
95
+ 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"),
96
+ method: "POST",
97
+ headers: _headers,
98
+ contentType: "application/json",
99
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
100
+ requestType: "json",
101
+ body: mergeAdditionalBodyParameters(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
102
+ 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,
103
+ 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,
104
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
105
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
106
+ logging: this._options.logging,
107
+ });
108
+ if (_response.ok) {
109
+ return { data: _response.body, rawResponse: _response.rawResponse };
110
+ }
111
+ if (_response.error.reason === "status-code") {
112
+ switch (_response.error.statusCode) {
113
+ case 400:
114
+ throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
115
+ case 401:
116
+ throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
117
+ case 402:
118
+ throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
119
+ case 403:
120
+ throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
121
+ case 405:
122
+ throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
123
+ case 413:
124
+ throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
125
+ case 429:
126
+ throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
127
+ case 500:
128
+ throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
129
+ default:
130
+ throw new errors.SpyglassError({
131
+ statusCode: _response.error.statusCode,
132
+ body: _response.error.body,
133
+ rawResponse: _response.rawResponse,
134
+ });
135
+ }
136
+ }
137
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/brands");
138
+ });
139
+ }
140
+ /**
141
+ * Find creators.
142
+ * Search semantically with `query`, or look them up by name, id, or
143
+ * social handle. Either way, you can also narrow the results with
144
+ * filters such as audience profile, location, and follower count.
145
+ *
146
+ * Send one search field. Each field is its own mode:
147
+ *
148
+ * - **Query** (`query`). A natural-language brief. Runs a language model and
149
+ * ranks by relevance, so `sortBy` is ignored. Bills at least one row even
150
+ * when nothing matches.
151
+ * - **Name** (`names`). Fuzzy-matches account names (a case-insensitive contains
152
+ * match). Pass every name in one array.
153
+ * - **ID** (`brandIds`). Looks up known ids. Missing ids are omitted and listed
154
+ * in `unmatchedIds`. `limit` and `offset` are ignored.
155
+ * - **Instagram** (`igUsername`). Case-insensitive contains match on the
156
+ * handle. A leading `@` is ignored.
157
+ * - **TikTok** (`tiktokUsername`). Same match on the TikTok handle.
158
+ *
159
+ * If a request includes more than one of these fields, only the highest
160
+ * priority field is used. The rest are ignored:
161
+ *
162
+ * 1. `brandIds`
163
+ * 2. `igUsername` or `tiktokUsername` (if both are set, either handle can match)
164
+ * 3. `names`
165
+ * 4. `query`
166
+ *
167
+ * One exception: `query` together with `names` uses both. `names` narrows the
168
+ * set, and `query` ranks inside it.
169
+ *
170
+ * `limit` (default 20, max 100) caps the rows returned, and the cost, for
171
+ * every mode except ID.
172
+ *
173
+ * Limited to 120 requests per minute per user.
174
+ * 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.
175
+ * A `query` search runs a language model, so it bills a minimum of one
176
+ * row even when nothing matches.
177
+ *
178
+ * @param {spyglass.SearchCreatorsRequest} request
179
+ * @param {Spyglass.RequestOptions} requestOptions - Request-specific configuration.
180
+ *
181
+ * @throws {@link spyglass.BadRequestError}
182
+ * @throws {@link spyglass.UnauthorizedError}
183
+ * @throws {@link spyglass.PaymentRequiredError}
184
+ * @throws {@link spyglass.ForbiddenError}
185
+ * @throws {@link spyglass.MethodNotAllowedError}
186
+ * @throws {@link spyglass.ContentTooLargeError}
187
+ * @throws {@link spyglass.TooManyRequestsError}
188
+ * @throws {@link spyglass.InternalServerError}
189
+ * @throws {@link errors.SpyglassError}
190
+ * @throws {@link errors.SpyglassTimeoutError}
191
+ *
192
+ * @example
193
+ * await client.searchCreators({
194
+ * igUsername: "charlidamelio",
195
+ * limit: 3,
196
+ * gender: "female"
197
+ * })
198
+ */
199
+ searchCreators(request = {}, requestOptions) {
200
+ return core.HttpResponsePromise.fromPromise(this.__searchCreators(request, requestOptions));
201
+ }
202
+ __searchCreators() {
203
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
204
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
205
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
206
+ 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);
207
+ const _response = yield core.fetcher({
208
+ 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"),
209
+ method: "POST",
210
+ headers: _headers,
211
+ contentType: "application/json",
212
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
213
+ requestType: "json",
214
+ body: mergeAdditionalBodyParameters(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
215
+ 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,
216
+ 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,
217
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
218
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
219
+ logging: this._options.logging,
220
+ });
221
+ if (_response.ok) {
222
+ return { data: _response.body, rawResponse: _response.rawResponse };
223
+ }
224
+ if (_response.error.reason === "status-code") {
225
+ switch (_response.error.statusCode) {
226
+ case 400:
227
+ throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
228
+ case 401:
229
+ throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
230
+ case 402:
231
+ throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
232
+ case 403:
233
+ throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
234
+ case 405:
235
+ throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
236
+ case 413:
237
+ throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
238
+ case 429:
239
+ throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
240
+ case 500:
241
+ throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
242
+ default:
243
+ throw new errors.SpyglassError({
244
+ statusCode: _response.error.statusCode,
245
+ body: _response.error.body,
246
+ rawResponse: _response.rawResponse,
247
+ });
248
+ }
249
+ }
250
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/creators");
251
+ });
252
+ }
253
+ /**
254
+ * Find taxonomy paths you can pass to POST /media as `taxonomy`.
255
+ * `query` is a product or category phrase. Each path is a string
256
+ * such as `Apparel > Footwear > Sneakers`.
257
+ *
258
+ * Limited to 120 requests per minute per user.
259
+ * This call is free and does not use credits.
260
+ *
261
+ * @param {spyglass.SearchTaxonomiesRequest} request
262
+ * @param {Spyglass.RequestOptions} requestOptions - Request-specific configuration.
263
+ *
264
+ * @throws {@link spyglass.BadRequestError}
265
+ * @throws {@link spyglass.UnauthorizedError}
266
+ * @throws {@link spyglass.PaymentRequiredError}
267
+ * @throws {@link spyglass.ForbiddenError}
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.searchTaxonomies({
276
+ * query: "running shoes"
277
+ * })
278
+ */
279
+ searchTaxonomies(request, requestOptions) {
280
+ return core.HttpResponsePromise.fromPromise(this.__searchTaxonomies(request, requestOptions));
281
+ }
282
+ __searchTaxonomies(request, requestOptions) {
283
+ return __awaiter(this, void 0, void 0, function* () {
284
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
285
+ const { query, limit } = request;
286
+ const _queryParams = {
287
+ query,
288
+ limit,
289
+ };
290
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
291
+ 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);
292
+ const _response = yield core.fetcher({
293
+ 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"),
294
+ method: "GET",
295
+ headers: _headers,
296
+ queryString: core.url
297
+ .queryBuilder()
298
+ .addMany(_queryParams)
299
+ .mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams)
300
+ .build(),
301
+ 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,
302
+ 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,
303
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
304
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
305
+ logging: this._options.logging,
306
+ });
307
+ if (_response.ok) {
308
+ return { data: _response.body, rawResponse: _response.rawResponse };
309
+ }
310
+ if (_response.error.reason === "status-code") {
311
+ switch (_response.error.statusCode) {
312
+ case 400:
313
+ throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
314
+ case 401:
315
+ throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
316
+ case 402:
317
+ throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
318
+ case 403:
319
+ throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
320
+ case 405:
321
+ throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
322
+ case 429:
323
+ throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
324
+ case 500:
325
+ throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
326
+ default:
327
+ throw new errors.SpyglassError({
328
+ statusCode: _response.error.statusCode,
329
+ body: _response.error.body,
330
+ rawResponse: _response.rawResponse,
331
+ });
332
+ }
333
+ }
334
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/taxonomies");
335
+ });
336
+ }
337
+ /**
338
+ * Return creatives. Pass `brandId` to scope to one brand or creator,
339
+ * or omit it to search the whole corpus. Without `brandId`,
340
+ * `query` is required.
341
+ *
342
+ * Limited to 120 requests per minute per user.
343
+ * 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.
344
+ * The call bills a minimum of one row even when nothing matches. In that
345
+ * case `count` is 0 but you are charged for one row.
346
+ *
347
+ * @param {spyglass.SearchMediaRequest} request
348
+ * @param {Spyglass.RequestOptions} requestOptions - Request-specific configuration.
349
+ *
350
+ * @throws {@link spyglass.BadRequestError}
351
+ * @throws {@link spyglass.UnauthorizedError}
352
+ * @throws {@link spyglass.PaymentRequiredError}
353
+ * @throws {@link spyglass.ForbiddenError}
354
+ * @throws {@link spyglass.NotFoundError}
355
+ * @throws {@link spyglass.MethodNotAllowedError}
356
+ * @throws {@link spyglass.ContentTooLargeError}
357
+ * @throws {@link spyglass.TooManyRequestsError}
358
+ * @throws {@link spyglass.InternalServerError}
359
+ * @throws {@link errors.SpyglassError}
360
+ * @throws {@link errors.SpyglassTimeoutError}
361
+ *
362
+ * @example
363
+ * await client.searchMedia({
364
+ * query: "comfort-focused video ads",
365
+ * limit: 20
366
+ * })
367
+ */
368
+ searchMedia(request = {}, requestOptions) {
369
+ return core.HttpResponsePromise.fromPromise(this.__searchMedia(request, requestOptions));
370
+ }
371
+ __searchMedia() {
372
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
373
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
374
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
375
+ 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);
376
+ const _response = yield core.fetcher({
377
+ 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"),
378
+ method: "POST",
379
+ headers: _headers,
380
+ contentType: "application/json",
381
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
382
+ requestType: "json",
383
+ body: mergeAdditionalBodyParameters(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
384
+ 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,
385
+ 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,
386
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
387
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
388
+ logging: this._options.logging,
389
+ });
390
+ if (_response.ok) {
391
+ return { data: _response.body, rawResponse: _response.rawResponse };
392
+ }
393
+ if (_response.error.reason === "status-code") {
394
+ switch (_response.error.statusCode) {
395
+ case 400:
396
+ throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
397
+ case 401:
398
+ throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
399
+ case 402:
400
+ throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
401
+ case 403:
402
+ throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
403
+ case 404:
404
+ throw new spyglass.NotFoundError(_response.error.body, _response.rawResponse);
405
+ case 405:
406
+ throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
407
+ case 413:
408
+ throw new spyglass.ContentTooLargeError(_response.error.body, _response.rawResponse);
409
+ case 429:
410
+ throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
411
+ case 500:
412
+ throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
413
+ default:
414
+ throw new errors.SpyglassError({
415
+ statusCode: _response.error.statusCode,
416
+ body: _response.error.body,
417
+ rawResponse: _response.rawResponse,
418
+ });
419
+ }
420
+ }
421
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/media");
422
+ });
423
+ }
424
+ /**
425
+ * Credits left on the API key's team, the credits included in the
426
+ * plan, and the current billing period. Granted credits count toward
427
+ * `remainingCredits` and not `planCredits`.
428
+ *
429
+ * Limited to 120 requests per minute per user.
430
+ * This call is free and does not use credits. It still responds when
431
+ * the team is out of credits.
432
+ *
433
+ * @param {Spyglass.RequestOptions} requestOptions - Request-specific configuration.
434
+ *
435
+ * @throws {@link spyglass.BadRequestError}
436
+ * @throws {@link spyglass.UnauthorizedError}
437
+ * @throws {@link spyglass.PaymentRequiredError}
438
+ * @throws {@link spyglass.ForbiddenError}
439
+ * @throws {@link spyglass.MethodNotAllowedError}
440
+ * @throws {@link spyglass.TooManyRequestsError}
441
+ * @throws {@link spyglass.InternalServerError}
442
+ * @throws {@link errors.SpyglassError}
443
+ * @throws {@link errors.SpyglassTimeoutError}
444
+ *
445
+ * @example
446
+ * await client.getCreditUsage()
447
+ */
448
+ getCreditUsage(requestOptions) {
449
+ return core.HttpResponsePromise.fromPromise(this.__getCreditUsage(requestOptions));
450
+ }
451
+ __getCreditUsage(requestOptions) {
452
+ return __awaiter(this, void 0, void 0, function* () {
453
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
454
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
455
+ 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);
456
+ const _response = yield core.fetcher({
457
+ 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, "team/credit-usage"),
458
+ method: "GET",
459
+ headers: _headers,
460
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
461
+ 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,
462
+ 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,
463
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
464
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
465
+ logging: this._options.logging,
466
+ });
467
+ if (_response.ok) {
468
+ return { data: _response.body, rawResponse: _response.rawResponse };
469
+ }
470
+ if (_response.error.reason === "status-code") {
471
+ switch (_response.error.statusCode) {
472
+ case 400:
473
+ throw new spyglass.BadRequestError(_response.error.body, _response.rawResponse);
474
+ case 401:
475
+ throw new spyglass.UnauthorizedError(_response.error.body, _response.rawResponse);
476
+ case 402:
477
+ throw new spyglass.PaymentRequiredError(_response.error.body, _response.rawResponse);
478
+ case 403:
479
+ throw new spyglass.ForbiddenError(_response.error.body, _response.rawResponse);
480
+ case 405:
481
+ throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
482
+ case 429:
483
+ throw new spyglass.TooManyRequestsError(_response.error.body, _response.rawResponse);
484
+ case 500:
485
+ throw new spyglass.InternalServerError(_response.error.body, _response.rawResponse);
486
+ default:
487
+ throw new errors.SpyglassError({
488
+ statusCode: _response.error.statusCode,
489
+ body: _response.error.body,
490
+ rawResponse: _response.rawResponse,
491
+ });
492
+ }
493
+ }
494
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/team/credit-usage");
495
+ });
496
+ }
497
+ /**
498
+ * Return public comments for specific Instagram or TikTok posts.
499
+ * Pass post URLs or the platform id. At least one of `instagramIds` or
500
+ * `tiktokIds` is required (max 20 each). `limit` is comment pages
501
+ * per post (default 1, max 20).
502
+ *
503
+ * Instagram accepts a shortcode or a post URL:
504
+ *
505
+ * - `C2xY9abcD1e`
506
+ * - `https://www.instagram.com/p/C2xY9abcD1e/`
507
+ * - `https://www.instagram.com/reel/C2xY9abcD1e/`
508
+ *
509
+ * TikTok accepts a video id or a post URL:
510
+ *
511
+ * - `7234567890123456789`
512
+ * - `https://www.tiktok.com/@nike/video/7234567890123456789`
513
+ *
514
+ * Recent posts may be scraped live; older posts with stored comments
515
+ * are served from cache.
516
+ *
517
+ * Limited to 20 requests per minute per user.
518
+ * Costs 10,000 microdollars ($0.0100) per successful page of comments returned, charged against your plan's monthly credits.
519
+ * Each comment page fetched live (`limit`, default 1) is one billed
520
+ * unit. Cached posts do not scrape and are not billed.
521
+ *
522
+ * @param {spyglass.GetCommentsRequest} request
523
+ * @param {Spyglass.RequestOptions} requestOptions - Request-specific configuration.
524
+ *
525
+ * @throws {@link spyglass.BadRequestError}
526
+ * @throws {@link spyglass.UnauthorizedError}
527
+ * @throws {@link spyglass.PaymentRequiredError}
528
+ * @throws {@link spyglass.ForbiddenError}
529
+ * @throws {@link spyglass.MethodNotAllowedError}
530
+ * @throws {@link spyglass.ContentTooLargeError}
531
+ * @throws {@link spyglass.TooManyRequestsError}
532
+ * @throws {@link spyglass.InternalServerError}
533
+ * @throws {@link errors.SpyglassError}
534
+ * @throws {@link errors.SpyglassTimeoutError}
535
+ *
536
+ * @example
537
+ * await client.getComments({
538
+ * instagramIds: ["https://www.instagram.com/p/C2xY9abcD1e/"],
539
+ * tiktokIds: ["https://www.tiktok.com/@nike/video/7234567890123456789"],
540
+ * limit: 1
541
+ * })
542
+ */
543
+ getComments(request = {}, requestOptions) {
544
+ return core.HttpResponsePromise.fromPromise(this.__getComments(request, requestOptions));
545
+ }
546
+ __getComments() {
547
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
548
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
549
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
550
+ 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);
551
+ const _response = yield core.fetcher({
552
+ 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"),
553
+ method: "POST",
554
+ headers: _headers,
555
+ contentType: "application/json",
556
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
557
+ requestType: "json",
558
+ body: mergeAdditionalBodyParameters(request, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.additionalBodyParameters),
559
+ 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,
560
+ 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,
561
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
562
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
563
+ logging: this._options.logging,
564
+ });
565
+ if (_response.ok) {
566
+ return { data: _response.body, rawResponse: _response.rawResponse };
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 405:
579
+ throw new spyglass.MethodNotAllowedError(_response.error.body, _response.rawResponse);
580
+ case 413:
581
+ throw new spyglass.ContentTooLargeError(_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, "POST", "/comments");
595
+ });
31
596
  }
32
597
  /**
33
598
  * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
@@ -5,20 +5,20 @@
5
5
  * limit: 20
6
6
  * }
7
7
  */
8
- export interface GetMediaRequest {
8
+ export interface SearchMediaRequest {
9
9
  /** Brand id given as a platform string or uuid */
10
- brandId?: GetMediaRequest.BrandId;
10
+ brandId?: SearchMediaRequest.BrandId;
11
11
  query?: string;
12
- channel?: GetMediaRequest.Channel.Item[];
13
- format?: GetMediaRequest.Format.Item[];
14
- duration?: GetMediaRequest.Duration.Item[];
15
- status?: GetMediaRequest.Status;
16
- categories?: GetMediaRequest.Categories.Item[];
12
+ channel?: SearchMediaRequest.Channel.Item[];
13
+ format?: SearchMediaRequest.Format.Item[];
14
+ duration?: SearchMediaRequest.Duration.Item[];
15
+ status?: SearchMediaRequest.Status;
16
+ categories?: SearchMediaRequest.Categories.Item[];
17
17
  taxonomy?: string[];
18
- funnelStage?: GetMediaRequest.FunnelStage.Item[];
19
- language?: GetMediaRequest.Language.Item[];
18
+ funnelStage?: SearchMediaRequest.FunnelStage.Item[];
19
+ language?: SearchMediaRequest.Language.Item[];
20
20
  location?: string[];
21
- datePreset?: GetMediaRequest.DatePreset;
21
+ datePreset?: SearchMediaRequest.DatePreset;
22
22
  startDate?: string;
23
23
  endDate?: string;
24
24
  minDaysRun?: number;
@@ -26,15 +26,15 @@ export interface GetMediaRequest {
26
26
  minViewCount?: number;
27
27
  maxViewCount?: number;
28
28
  landingPage?: string;
29
- landingPageMatch?: GetMediaRequest.LandingPageMatch;
29
+ landingPageMatch?: SearchMediaRequest.LandingPageMatch;
30
30
  lowImpressions?: boolean;
31
31
  partnershipAd?: boolean;
32
32
  crossposted?: boolean;
33
- sortBy?: GetMediaRequest.SortBy;
33
+ sortBy?: SearchMediaRequest.SortBy;
34
34
  limit?: number;
35
35
  offset?: number;
36
36
  }
37
- export declare namespace GetMediaRequest {
37
+ export declare namespace SearchMediaRequest {
38
38
  /**
39
39
  * Brand id given as a platform string or uuid
40
40
  */