Skip to content

Commit

Permalink
Fix: identity v3 bugs (#260)
Browse files Browse the repository at this point in the history
* updated path of the identify endpoint to /identify

* updated path in tests as well

* made logInWith internal

* added logOutWith method

* fixed logOutWith docs
  • Loading branch information
aboedo authored Mar 4, 2021
1 parent 82cd188 commit 1527eb0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class Backend(
enqueue(object : Dispatcher.AsyncCall() {
override fun call(): HTTPClient.Result {
return httpClient.performRequest(
"/subscribers/" + encode(appUserID) + "/login",
"/subscribers/" + encode(appUserID) + "/identify",
mapOf("new_app_user_id" to newAppUserID),
authenticationHeaders
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ class BackendTest {
"new_app_user_id" to newAppUserID
)
mockResponse(
"/subscribers/$appUserID/login",
"/subscribers/$appUserID/identify",
body,
201,
null,
Expand All @@ -984,7 +984,7 @@ class BackendTest {
)
verify(exactly = 1) {
mockClient.performRequest(
"/subscribers/$appUserID/login",
"/subscribers/$appUserID/identify",
body,
any()
)
Expand All @@ -999,7 +999,7 @@ class BackendTest {
)
val resultBody = Responses.validFullPurchaserResponse
mockResponse(
"/subscribers/$appUserID/login",
"/subscribers/$appUserID/identify",
requestBody,
responseCode = 201,
clientException = null,
Expand Down Expand Up @@ -1029,7 +1029,7 @@ class BackendTest {
)
val resultBody = "{}"
mockResponse(
"/subscribers/$appUserID/login",
"/subscribers/$appUserID/identify",
requestBody,
responseCode = 201,
clientException = null,
Expand Down Expand Up @@ -1058,7 +1058,7 @@ class BackendTest {
)
val resultBody = Responses.validFullPurchaserResponse
mockResponse(
"/subscribers/$appUserID/login",
"/subscribers/$appUserID/identify",
requestBody,
responseCode = 201,
clientException = null,
Expand All @@ -1084,7 +1084,7 @@ class BackendTest {
)
val resultBody = Responses.validFullPurchaserResponse
mockResponse(
"/subscribers/$appUserID/login",
"/subscribers/$appUserID/identify",
requestBody,
responseCode = 200,
clientException = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,28 @@ fun Purchases.identifyWith(
* @param [onError] Will be called after the call has completed with an error.
*/
@Suppress("unused")
fun Purchases.logInWith(
internal fun Purchases.logInWith(
appUserID: String,
onError: ErrorFunction = ON_ERROR_STUB,
onSuccess: ReceiveLogInSuccessFunction
) {
logIn(appUserID, logInSuccessListener(onSuccess, onError))
}

/**
* Logs out the Purchases client clearing the save appUserID. This will generate a random user
* id and save it in the cache.
* @param [onSuccess] Will be called after the call has completed.
* @param [onError] Will be called after the call has completed with an error.
*/
@Suppress("unused")
internal fun Purchases.logOutWith(
onError: ErrorFunction = ON_ERROR_STUB,
onSuccess: ReceivePurchaserInfoSuccessFunction
) {
logOut(receivePurchaserInfoListener(onSuccess, onError))
}

/**
* Resets the Purchases client clearing the save appUserID. This will generate a random user
* id and save it in the cache.
Expand Down

0 comments on commit 1527eb0

Please sign in to comment.