Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity v3: update appUserID param location #484

Merged
merged 2 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Purchases.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
37E353851D42047D5B0A57D0 /* MockDateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37E3578BD602C7B8E2274279 /* MockDateProvider.swift */; };
37E35398FCB4931573C56CAF /* MockReceiptFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37E352B11676F7DC51559E84 /* MockReceiptFetcher.swift */; };
37E353E153F6B5C6DE54DE4B /* RCAttributionFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 37E35B99BA2A8F048F2482F8 /* RCAttributionFetcher.m */; };
37E353E6011160108235023C /* (null) in Headers */ = {isa = PBXBuildFile; settings = {ATTRIBUTES = (Private, ); }; };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was leftover from #438. it doesn't actually affect anything, but it's good to keep these things clean

37E353FA89D4F510BA73F0D3 /* RCProductInfoExtractor.m in Sources */ = {isa = PBXBuildFile; fileRef = 37E35E5C3D1B1D6814496C89 /* RCProductInfoExtractor.m */; };
37E354159288DE3D23212382 /* RCCrossPlatformSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 37E35DE721FC2A73255D505E /* RCCrossPlatformSupport.h */; settings = {ATTRIBUTES = (Private, ); }; };
37E35473E5952D7500FF4BD8 /* RCEntitlementInfo+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = 37E35B2CE711472BE58F51ED /* RCEntitlementInfo+Protected.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -1210,7 +1209,6 @@
2DC5623824EC7DF70031F69B /* RCTransaction.h in Headers */,
37E354AFE06A9723230E47B8 /* RCInMemoryCachedObject+Protected.h in Headers */,
37E35C7C3BADD6D1BBAE7129 /* RCSubscriberAttribute+Protected.h in Headers */,
37E353E6011160108235023C /* (null) in Headers */,
2DAF814E25B24243002C621E /* RCIdentityManager+Protected.h in Headers */,
37E358D3F3C7C0388FF5C2BD /* RCOfferingsFactory.h in Headers */,
37E35DB1E991055497D18044 /* RCPromotionalOffer.h in Headers */,
Expand Down
8 changes: 5 additions & 3 deletions Purchases/Networking/RCBackend.m
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,15 @@ - (void)logInWithCurrentAppUserID:(NSString *)currentAppUserID
completion:(void (^)(RCPurchaserInfo * _Nullable purchaserInfo,
BOOL created,
NSError * _Nullable error))completion {
NSString *escapedAppUserID = [self escapedAppUserID:currentAppUserID];
NSString *path = [NSString stringWithFormat:@"/subscribers/%@/identify", escapedAppUserID];
NSParameterAssert(currentAppUserID);
NSParameterAssert(newAppUserID);
NSString *path = @"/subscribers/identify";
[self.httpClient performRequest:@"POST"
serially:YES
path:path
body:@{
@"new_app_user_id": newAppUserID // TODO: confirm backend field name
@"app_user_id": currentAppUserID,
@"new_app_user_id": newAppUserID
}
headers:self.headers
completionHandler:^(NSInteger status, NSDictionary *_Nullable response, NSError *_Nullable error) {
Expand Down
6 changes: 3 additions & 3 deletions PurchasesTests/Networking/BackendTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,8 @@ class BackendTests: XCTestCase {
expect(receivedCall.path) == requestPath
expect(receivedCall.serially) == true
expect(receivedCall.HTTPMethod) == "POST"
expect(receivedCall.body as? [String: String]) == ["new_app_user_id": newAppUserID]
expect(receivedCall.body as? [String: String]) == ["new_app_user_id": newAppUserID,
"app_user_id": currentAppUserID]
expect(receivedCall.headers) == ["Authorization": "Bearer asharedsecret"]
}

Expand Down Expand Up @@ -1640,9 +1641,8 @@ private extension BackendTests {
statusCode: Int = 200,
response: [AnyHashable: Any]? = [:],
error: Error? = nil) -> String {
let escapedCurrentAppUserID = appUserID.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
let response = HTTPResponse(statusCode: statusCode, response: response, error: error)
let requestPath = ("/subscribers/" + escapedCurrentAppUserID + "/identify")
let requestPath = ("/subscribers/identify")
httpClient.mock(requestPath: requestPath, response: response)
return requestPath
}
Expand Down