[CustomerCenter] Add networking layer and models#1859
Conversation
| val title: String, | ||
| val type: PathType, | ||
| @SerialName("promotional_offer") val promotionalOffer: PathDetail.PromotionalOffer? = null, | ||
| @SerialName("feedback_survey") val feedbackSurvey: PathDetail.FeedbackSurvey? = null, |
There was a problem hiding this comment.
Note that this is a bit different to iOS. In iOS, there is a single detail field, which makes sense since you can only have either promotional_offer or feedback_survey. But that was trickier to deserialize and I believe it's fine to separate these 2 into separate fields. Lmk if you have concerns.
There was a problem hiding this comment.
For my understanding, in Android we could have both?
There was a problem hiding this comment.
Not right now since the flow wouldn't make much sense if both are present... Having said that, we're not currently constraining this in the backend, so it's possible to have both.
There was a problem hiding this comment.
Alright, yea I think these models should reflect the backend as closely as possible, so this is fine with me.
| @Serializable | ||
| class PromotionalOffer( | ||
| // WIP: Rename this field name to a new android id | ||
| @SerialName("ios_offer_id") val androidOfferId: String, |
There was a problem hiding this comment.
Right now I'm reading the ios_offer_id but we should read the android one before merging this.
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| typealias RCColor = PaywallColor |
There was a problem hiding this comment.
Not a big fan of these typealiases, but it's how we have it in iOS, and it kinda made sense now.
| ) | ||
|
|
||
| @Serializable | ||
| class CustomerCenterConfigData( |
There was a problem hiding this comment.
Need to write API tests for all these.
| ) | ||
|
|
||
| @Serializable | ||
| class CustomerCenterConfigData( |
There was a problem hiding this comment.
Also note that the constructors here are public, so test data can be created more easily from within the RevenueCatUI module.
| } | ||
|
|
||
| fun commonLocalizedString(key: CommonLocalizedString): String { | ||
| return localizedStrings[key.name.lowercase()] ?: key.defaultValue |
There was a problem hiding this comment.
I didn't fully like this... It means the enum name must always match the key in uppercase. Want to write a test to make sure this is setup correctly.
There was a problem hiding this comment.
In this case as well I wouldn't be opposed to having the enum just match the JSON key. (Testing would still be good, but the "rule" is simpler.)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1859 +/- ##
==========================================
- Coverage 82.83% 82.37% -0.46%
==========================================
Files 222 225 +3
Lines 7703 7900 +197
Branches 1084 1104 +20
==========================================
+ Hits 6381 6508 +127
- Misses 899 953 +54
- Partials 423 439 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| @Serializable | ||
| class Appearance( | ||
| val light: ColorInformation? = null, | ||
| val dark: ColorInformation? = null, |
There was a problem hiding this comment.
This is also different to what we have in iOS... In there, we have each color type first and each one has a light/dark color. Here, it's the opposite. This actually reflects the backend response better, and I think we can parse it as needed later, so I didn't want to try to flip it in the model.
|
I expect the new backend integration test to fail until we've given the project access to the customer center. It worked fine for a different project I tested on. |
c8163c6 to
36695b7
Compare
JayShortway
left a comment
There was a problem hiding this comment.
Nice, I think this is close! I just had some minor comments and suggestions.
There was a problem hiding this comment.
Not for this PR, and maybe not for v0, but could be good to think about some rate limiting at some point? Even something like "once per 5 seconds" could already relieve some potential stress of calling this in a while(true).
| private lateinit var backend: Backend | ||
| private lateinit var asyncBackend: Backend | ||
|
|
||
| private val expectedCustomerCenterConfigData = CustomerCenterConfigData( |
There was a problem hiding this comment.
I have never used it, but Kotest's property test framework can supposedly help with generating these test fixtures. (Not for this PR of course, just something we could look into at some point.)
| internal interface LocaleProvider { | ||
| val currentLocalesLanguageTags: String | ||
| } |
d9f9f57 to
64b023b
Compare
**This is an automatic release.** ## RevenueCat SDK ### 🐞 Bugfixes * Save SDK configuration on paywall activity so it can reconfigure automatically (#1872) via Toni Rico (@tonidero) ### 📦 Dependency Updates * Bump fastlane from 2.223.1 to 2.224.0 (#1870) via dependabot[bot] (@dependabot[bot]) * Bump fastlane-plugin-revenuecat_internal from `5b2e35c` to `3b1e7cf` (#1865) via dependabot[bot] (@dependabot[bot]) * Bump fastlane from 2.222.0 to 2.223.1 (#1860) via dependabot[bot] (@dependabot[bot]) * Bump fastlane-plugin-revenuecat_internal from `55a0455` to `5b2e35c` (#1858) via dependabot[bot] (@dependabot[bot]) ### 🔄 Other Changes * [CustomerCenter] Fix help path deserializing when unknown type (#1869) via Toni Rico (@tonidero) * [CustomerCenter] Create `CustomerCenter` composable and view model with some initial UI (#1867) via Toni Rico (@tonidero) * [CustomerCenter] Add networking layer and models (#1859) via Toni Rico (@tonidero) * [CustomerCenter] Adds SubscriptionDetailsView (#1863) via JayShortway (@JayShortway) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Description
RevenueCatto support the new CustomerCenter.X-Preferred-Localesheader.Purchases.getCustomerCenterConfigDatamethod to access the data fromRevenueCatUI