File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 11import { IdentityApiData , MPID , UserIdentities } from '@mparticle/web-sdk' ;
22import {
33 IdentityCallback ,
4+ IdentityResultBody ,
45 IIdentityResponse ,
56} from './identity-user-interfaces' ;
67import {
@@ -29,9 +30,9 @@ export interface IIdentityApiClient {
2930 getUploadUrl : ( method : IdentityAPIMethod , mpid : MPID ) => string ;
3031 getIdentityResponseFromFetch : (
3132 response : Response ,
32- responseBody : string
33+ responseBody : IdentityResultBody
3334 ) => IIdentityResponse ;
34- getIdentityResponseFromXHR : ( response : Response ) => IIdentityResponse ;
35+ getIdentityResponseFromXHR : ( response : XMLHttpRequest ) => IIdentityResponse ;
3536}
3637
3738// https://go.mparticle.com/work/SQDSDKS-6568
Original file line number Diff line number Diff line change @@ -3,13 +3,14 @@ import { sendAliasRequest } from './aliasRequestApiClient';
33import { FetchUploader , XHRUploader } from './uploaders' ;
44import { CACHE_HEADER } from './identity-utils' ;
55import { parseNumber } from './utils' ;
6+ import { IIdentityApiClient } from './identityApiClient.interfaces' ;
67
78var HTTPCodes = Constants . HTTPCodes ,
89 Messages = Constants . Messages ;
910
1011const { Modify } = Constants . IdentityMethods ;
1112
12- export default function IdentityAPIClient ( mpInstance ) {
13+ export default function IdentityAPIClient ( this : IIdentityApiClient , mpInstance ) {
1314 this . sendAliasRequest = async function ( aliasRequest , callback ) {
1415 await sendAliasRequest ( mpInstance , aliasRequest , callback ) ;
1516 } ;
@@ -74,7 +75,7 @@ export default function IdentityAPIClient(mpInstance) {
7475 responseBody
7576 ) ;
7677 } else {
77- identityResponse = this . getIdentityResponseFromXHR ( response ) ;
78+ identityResponse = this . getIdentityResponseFromXHR ( response as unknown as XMLHttpRequest ) ;
7879 }
7980
8081 verbose (
Original file line number Diff line number Diff line change 1+ import IdentityApiClient from '../../src/identityApiClient' ;
2+ import { MParticleWebSDK } from '../../src/sdkRuntimeModels' ;
3+
4+ describe ( 'Identity Api Client' , ( ) => {
5+ describe ( '#getUploadUrl' , ( ) => {
6+ it . only ( 'should generate an upload url with defaults' , ( ) => {
7+ const mockSDK = ( {
8+ _Helpers : {
9+ createServiceUrl : ( ) => 'https://identity.mparticle.com/' ,
10+ } ,
11+ _Store : {
12+ } ,
13+ _Persistence : {
14+ } ,
15+ } as unknown ) as MParticleWebSDK ;
16+
17+ const identityApiClient = new IdentityApiClient ( mockSDK ) ;
18+
19+ const url = identityApiClient . getUploadUrl ( ) ;
20+ expect ( url ) . toBe ( 'https://identity.mparticle.com/v1/identify' ) ;
21+ } ) ;
22+ } ) ;
23+ describe ( '#sendIdentityRequest' , ( ) => {
24+
25+ } ) ;
26+ } ) ;
You can’t perform that action at this time.
0 commit comments