-
Notifications
You must be signed in to change notification settings - Fork 16
Extend SubscriberServiceRemote #837
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
Conversation
050994c
to
00c78cb
Compare
Generated by 🚫 Danger |
I'll check what's failing on CI tomorrow. |
emailAddress = try? container.decodeIfPresent(String.self, forKey: "email_address") | ||
dateSubscribed = try container.decode(Date.self, forKey: "date_subscribed") | ||
isEmailSubscriptionEnabled = try container.decode(Bool.self, forKey: "is_email_subscriber") | ||
subscriptionStatus = try? container.decodeIfPresent(String.self, forKey: "subscription_status") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I missed anything, but it looks like this part can be simplified by having a CodingKey
-conforming enum
, and let Swift synthesis the Decodable
implementation for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swift synthesis the Decodable implementation for us?
I started with it, until I discovered that a bunch of these String
fields can contain false
when empty, e.g. country: false
. So I replaced parsing for these with try? container.decodeIfPresent(String.self
. I'm not sure if there is a generalized solution in the framework – couldn't find it after a brief search.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Yeah, that caused some headaches in wordpress-rs too, which has been solved. We can potentially start using the WP.com API client in wordpress-rs, once that's implemented.
WordPressKit.zip