-
Notifications
You must be signed in to change notification settings - Fork 16
Extend SubscriberServiceRemote #837
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