@spyglasshq/sdk 0.1.2 → 0.1.3

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