Files
purchases-ios/Tests/UnitTests/SubscriberAttributes/__Snapshots__/BackendSubscriberAttributesTests/iOS13-testPostReceiptWithSubscriberAttributesPassesErrorIfStatusCodeIsNotSuccess.1.json
T
NachoSoto e58a00b4be CustomerInfoResponseHandler: return CustomerInfo instead of error if the response was successful (#1778)
Fixes [SDKONCALL-62].
The behavior in version 3.x was that we would return a `CustomerInfo` AND the attribute errors. [The test in that version](https://github.com/RevenueCat/purchases-ios/blob/3.14.2/PurchasesTests/SubscriberAttributes/BackendSubscriberAttributesTests.swift#L370-L404) however only verified that the error was returned.

When we converted `(Value, Error)` callbacks to using `Result` (#1387), I assumed this was an error. Because of that incomplete test, we didn't notice this wasn't the desired behavior.

If the backend returns a 200, it's assumed that the errors aren't more important than the correct `CustomerInfo`.

The new implementation simply logs the attribute errors (which is now tested), and returns the `CustomerInfo`:
```
😿‼️ One or more of the attributes sent could not be saved. ["$email": "email is not in valid format"]
```

[SDKONCALL-62]: https://revenuecats.atlassian.net/browse/SDKONCALL-62?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-07-29 10:04:26 -07:00

29 lines
695 B
JSON

{
"headers" : {
"Authorization" : "Bearer the api key"
},
"request" : {
"body" : {
"app_user_id" : "abc123",
"attributes" : {
"$attConsentStatus" : {
"updated_at_ms" : 1678307200000,
"value" : "authorized"
},
"a key" : {
"updated_at_ms" : 1678307200000,
"value" : "a value"
},
"another key" : {
"updated_at_ms" : 1678307200000,
"value" : "another value"
}
},
"fetch_token" : "YW4gYXdlc29tZSByZWNlaXB0",
"is_restore" : false,
"observer_mode" : false
},
"method" : "POST",
"url" : "https://api.revenuecat.com/v1/receipts"
}
}