@experian-ecs/connected-api-sdk 1.1.1 → 1.3.0

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.
package/README.md CHANGED
@@ -102,6 +102,7 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
102
102
  at async k.fetchWithAuth (file:/stack/trace/path)
103
103
  at async file:/stack/trace/path {
104
104
  data: {
105
+ type: AUTHENTICATION_ERROR,
105
106
  dev_url: 'https://experian.com/unity/docs/UNAUTHORIZED',
106
107
  code: 'UNAUTHORIZED',
107
108
  message: 'User Not Authorized'
@@ -143,21 +144,77 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
143
144
 
144
145
  ### Credit Attributes
145
146
 
147
+ The Credit Attributes API supports both v1 and v2 endpoints with different response formats. Use the `version` parameter to specify which API version to use. Leaving blank defaults to `v1`
148
+
146
149
  * #### Retrieve attribute data for all historical reports
147
150
 
148
151
  ```tsx
152
+ // Defaults to V1
149
153
  await sdk.creditAttributes.getCreditAttributes();
154
+
155
+ // V1 API - returns array of CreditAttributes objects
156
+ await sdk.creditAttributes.getCreditAttributes({ version: 'v1' });
157
+
158
+ // V2 API - returns CreditAttributes3B object with items array
159
+ await sdk.creditAttributes.getCreditAttributes({ version: 'v2' });
160
+ ```
161
+
162
+ #### Credit Attribute version response validation
163
+
164
+ ```tsx
165
+ import { isV1GetCreditAttributesResponse, isV2GetCreditAttributesResponse } from '@experian-ecs/connected-api-sdk'
166
+
167
+ const { data, error } = await sdk.creditAttributes.getCreditAttributes({
168
+ version: 'v2'
169
+ });
170
+
171
+ if (data) {
172
+ if (isV2GetCreditAttributesResponse(data)) {
173
+ // TypeScript now knows data is CreditAttribute3B
174
+ const { items } = data;
175
+ items.forEach(item => {
176
+ console.log(`Attribute ID: ${item.id}`);
177
+ item.bureau_attributes.forEach(attribute => {
178
+ console.log(`Bureau: ${attribute.bureau}, Reported At: ${attribute.reported_at}, Categories: ${attribute.categories}, Attributes: ${attribute.attributes}`);
179
+ });
180
+ });
181
+ } else if (isV1GetCreditAttributesResponse(data)) {
182
+ // TypeScript now knows data is CreditAttribute[]
183
+ data.forEach(attribute => {
184
+ console.log(`Bureau: ${attribute.bureau}, Reported At: ${attribute.reported_at}, Categories: ${attribute.categories}, Attributes: ${attribute.attributes}`);
185
+ });
186
+ }
187
+ } else {
188
+ console.error(error);
189
+ }
150
190
  ```
151
191
 
152
192
  ### Credit Reports
153
193
 
194
+ The Credit Reports API supports both v1 and v2 endpoints with different response formats. Use the `version` parameter to specify which API version to use. Leaving blank defaults to `v1`
195
+
154
196
  * #### Retrieve all historical reports
155
197
 
156
198
  ```tsx
199
+ // Defaults to v1
157
200
  await sdk.creditReports.getReports({
158
201
  product_config_id: 'procfg_01',
159
202
  include_fields: 'report_display',
160
203
  })
204
+
205
+ // Version specific v1
206
+ await sdk.creditReports.getReports({
207
+ version: 'v1',
208
+ product_config_id: 'procfg_01',
209
+ include_fields: 'report_display',
210
+ });
211
+
212
+ // Version specific v2
213
+ await sdk.creditReports.getReports({
214
+ version: 'v2',
215
+ product_config_id: 'procfg_01',
216
+ report_date: '2025-09-01',
217
+ });
161
218
  ```
162
219
 
163
220
  * #### Retrieve a single report
@@ -167,18 +224,36 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
167
224
  id: '',
168
225
  include_fields: 'report_display',
169
226
  });
227
+
228
+ // Version specific v2
229
+ await sdk.creditReports.getReportById({
230
+ id: '1234',
231
+ version: 'v2'
232
+ });
170
233
  ```
171
234
 
172
235
  * #### Retrieve all historical report summaries
173
236
 
174
237
  ```tsx
175
238
  await sdk.creditReports.getReportMeta();
239
+
240
+ // Version specific v2
241
+ await sdk.creditReports.getReportMeta({
242
+ version: 'v2',
243
+ latest_only: true
244
+ });
176
245
  ```
177
246
 
178
247
  * #### Retrieve a single report summary
179
248
 
180
249
  ```tsx
181
250
  await sdk.creditReports.getReportMetaById({ id: '' });
251
+
252
+ // Version specific v2
253
+ await sdk.creditReports.getReportMetaById({
254
+ id: '123',
255
+ version: 'v2'
256
+ });
182
257
  ```
183
258
 
184
259
  * #### Order a new report
@@ -188,6 +263,12 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
188
263
  product_config_id: 'procfg_01',
189
264
  include_fields: 'report_display',
190
265
  });
266
+
267
+ // Version specific v2
268
+ await sdk.creditReports.orderReport({
269
+ version: 'v2',
270
+ product_config_id: 'procfg_01',
271
+ });
191
272
  ```
192
273
 
193
274
  * #### Mark a report as read
@@ -197,14 +278,30 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
197
278
  id: '',
198
279
  include_fields: 'report_display',
199
280
  });
281
+
282
+ // Version specific v2
283
+ await sdk.creditReports.markReportAsRead({
284
+ version: 'v2',
285
+ id: '1234',
286
+ disposition: { read_status: 'READ' }
287
+ });
200
288
  ```
201
289
 
202
290
  ### Credit Scores
203
291
 
292
+ The Credit Scores API supports both v1 and v2 endpoints with different response formats. Use the `version` parameter to specify which API version to use. Leaving blank defaults to `v1`
293
+
204
294
  * #### Retrieve all historical scores
205
295
 
206
296
  ```tsx
297
+ // Defaults to V1
207
298
  await sdk.creditScores.getCreditScores();
299
+
300
+ // V1 API - returns array of CreditScore objects
301
+ await sdk.creditScores.getCreditScores({ version: 'v1' });
302
+
303
+ // V2 API - returns CreditScore3B object with items array
304
+ await sdk.creditScores.getCreditScores({ version: 'v2' });
208
305
  ```
209
306
 
210
307
  * #### Retrieve all historical scores with factors information
@@ -222,9 +319,46 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
222
319
  * #### Order a new score
223
320
 
224
321
  ```tsx
322
+ // Defaults to V1
225
323
  await sdk.creditScores.orderCreditScore({
226
324
  product_config_id: 'procfg_01'
227
325
  });
326
+
327
+ // V2 API
328
+ await sdk.creditScores.orderCreditScore({
329
+ product_config_id: 'procfg_01',
330
+ version: 'v2'
331
+ });
332
+ ```
333
+
334
+ * #### Credit Score version response validation
335
+
336
+ ```tsx
337
+ import { isV1GetCreditScoresResponse, isV2GetCreditScoresResponse } from '@experian-ecs/connected-api-sdk'
338
+
339
+ const { data, error } = await sdk.creditScores.getCreditScores({
340
+ version: 'v2'
341
+ });
342
+
343
+ if (data) {
344
+ if (isV2GetCreditScoresResponse(data)) {
345
+ // TypeScript now knows data is CreditScore3B
346
+ const { items } = data;
347
+ items.forEach(item => {
348
+ console.log(`Score ID: ${item.id}`);
349
+ item.bureau_scores.forEach(score => {
350
+ console.log(`Bureau: ${score.bureau}, Score: ${score.score}`);
351
+ });
352
+ });
353
+ } else if (isV1GetCreditScoresResponse(data)) {
354
+ // TypeScript now knows data is CreditScore[]
355
+ data.forEach(score => {
356
+ console.log(`Score ID: ${score.score_id}, Score: ${score.score}`);
357
+ });
358
+ }
359
+ } else {
360
+ console.error(error);
361
+ }
228
362
  ```
229
363
 
230
364
  ### Credit Score Planner
@@ -604,7 +738,7 @@ If using the sdk in the browser the `auth.getAccessToken` method will throw an e
604
738
 
605
739
  ### Type Guards
606
740
 
607
- For typescript users, helper utility functions are exported in order to aid with type narrowing response types that return variable response models. An example use case can be viewed for [simulating a credit score](#simulate-a-scenario---fico-only)
741
+ For typescript users, helper utility functions are exported in order to aid with type narrowing response types that return variable response models. An example use case can be viewed for [simulating a credit score](#simulate-a-scenario---fico-only) and [validating credit score responses](#credit-score-version-response-validation).
608
742
 
609
743
  * Credit Score Planner
610
744
 
@@ -628,3 +762,32 @@ For typescript users, helper utility functions are exported in order to aid with
628
762
  function isFicoScenarioVariation(variation?: ScenarioVariation): variation is FicoScenarioVariation;
629
763
  function isVantageScenarioVariation(variation?: ScenarioVariation): variation is VantageScenarioVariation;
630
764
  ```
765
+
766
+ * Credit Scores
767
+
768
+ ```tsx
769
+ function isValidApiVersion(version: string): version is ApiVersion;
770
+ function isCreditScore(data: unknown): data is CreditScore;
771
+ function isCreditScoreV2(data: unknown): data is CreditScore_V2;
772
+ function isBureauScore(data: unknown): data is BureauScore;
773
+ function isValidBureau(bureau: unknown): bureau is Bureau;
774
+ function isCreditScore3B(data: unknown): data is CreditScores_V2;
775
+ function isCreditScoreArray(data: unknown): data is CreditScore[];
776
+ function isV1GetCreditScoresResponse(data: unknown): data is GetCreditScoreResponse<'v1'>;
777
+ function isV2GetCreditScoresResponse(data: unknown): data is GetCreditScoreResponse<'v2'>;
778
+ function isV1PostCreditScoresResponse(data: unknown): data is PostCreditScoreResponse<'v1'>;
779
+ function isV2PostCreditScoresResponse(data: unknown): data is PostCreditScoreResponse<'v2'>;
780
+ ```
781
+
782
+ * Credit Attributes
783
+
784
+ ```tsx
785
+ function isCreditAttribute(data: unknown): data is CreditAttributes;
786
+ function isCreditAttributeV2(data: unknown): data is CreditAttribute_V2;
787
+ function isBureauAttribute(data: unknown): data is BureauAttribute;
788
+ function isValidBureauAttribute(bureau: unknown): bureau is Bureau;
789
+ function isCreditAttributesV2(data: unknown): data is CreditAttribute_V2;
790
+ function isCreditAttributeArray(data: unknown): data is CreditAttribute[];
791
+ function isV1GetCreditAttributesResponse(data: unknown): data is GetCreditAttributeResponse<'v1'>;
792
+ function isV2GetCreditAttributesResponse(data: unknown): data is GetCreditAttributeResponse<'v2'>;
793
+ ```