-
Notifications
You must be signed in to change notification settings - Fork 3
Add Support Tickets + Eligibility endpoints #743
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
base: trunk
Are you sure you want to change the base?
Conversation
029a613
to
4555134
Compare
Add Swift Support Eligibility support
4555134
to
4a98907
Compare
pub id: u64, | ||
pub content: String, | ||
pub author: SupportMessageAuthor, | ||
pub role: String, |
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.
At the moment how the author
is parsed id depending on the SupportMessageAuthor
enum variant order: it's a "User" if the JSON can be parsed as an "User"; then it's a "Agent" if the JSON can be parsed as an "Agent". Would it be more correct to parse author
based on the role
value, instead of how the SupportMessageAuthor
enum type is declared?
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.
Although this would be better, it's also more tricky to do. At least, I couldn't think of an immediate solution to this except for either using a custom parser or separating the SupportMessage
type as SupportUserMessage
and SupportAgentMessage
. (which doesn't sound like a bad idea 🤔 )
Since SupportUserIdentity
and SupportAgentIdentity
don't have the same fields, I think the way it's implemented is mostly safe. I say mostly, because future changes to these types may make it unsafe as in they might be incorrectly parsed to one type as described in Tony's comment. So, maybe we should separate the message types if we can. (I haven't fully investigated this yet)
What do you think @crazytonyli?
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.
or separating the SupportMessage type as SupportUserMessage and SupportAgentMessage.
This sounds good to me 👍
#[serde(untagged)] | ||
pub enum SupportMessageAuthor { | ||
User(SupportUserIdentity), | ||
SupportAgent(SupportAgentIdentity), |
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.
Should there be an "other" variant, just in case the "role" value is some other value, like "system" messages?
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.
In order to do this, we'd need to parse it as a json value because we don't know the structure of the type.
If we know for sure that there are other types of authors, but we don't know the structure of the type, then I think this makes sense to do. Otherwise, it's probably leave it off and implement it when we need to.
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.
My concern is that the app may fail to parse the messages if the API introduces a new "author" with a different JSON schema than "user" and "agent".
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.
Let me think about this again depending on your answer to this.
My general worry is for a parsing issue to go unnoticed and introducing a fallback inherently has that problem. Ideally I'd like to have a way to not have parsing errors, but still get a notice about the unexpected fallbacks. Once we have logging implemented, it might help with that a bit.
wp_com_e2e/src/main.rs
Outdated
.test() | ||
.await?; | ||
SupportTicketsTest { client: &client }.test().await?; | ||
SupportEligibilityTest { client: &client }.test().await?; |
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.
Any reason not to use cargo to run these tests, like the existing integration tests?
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.
I'm hoping that at some point this could be run against WP.com on each commit to see if there are breaking changes, which is why I started down this path
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.
I think we'd still be able to do that with the regular cargo test setup. Is there something specific you're worried about?
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.
I can see some value in making this a binary as it'll make it easier to run it from outside of this project without setting up the toolchain.
I don't have a good grasp of the full picture of what we need for this at the moment, so I don't think it's worth changing what's already implemented. Having said that, I don't think the Testable
stuff is very useful. So, I simplified it a bit in d08e206.
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.
The implementation looks good overall, but I am not so sure about the e2e testing setup. I've brought up a question in the line comments, let's discuss where to go from there.
wp_com_e2e/src/main.rs
Outdated
.test() | ||
.await?; | ||
SupportTicketsTest { client: &client }.test().await?; | ||
SupportEligibilityTest { client: &client }.test().await?; |
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.
I think we'd still be able to do that with the regular cargo test setup. Is there something specific you're worried about?
I'm ok with whatever testing approach makes sense – if we can pre-compile a binary for Linux that uses the Rust test stuff, then I'm good with it. One other note, I guess, we'll need to be able to chain some tests together so certain actions run before others (can't be avoided for stuff like support tickets). |
Adds WP.com support tickets (ie – Zendesk) and support eligibility endpoints.
Support tickets require the ability to upload files – this PR doesn't do that because we'll need to generalize our file upload stuff. I don't think that's a blocker to this PR landing – the majority of the functionality is there.
I've also added a
wp_com_e2e
package that'll validate that the support tickets / eligibility endpoints function as expected. You can run it likecargo run --bin wp_com_e2e test --token [my_token]
. It must be a WordPress iOS token at the moment – we can consider adjusting that later though.If you run that test (or trust that I did), I think we can consider this PR working. There are also unit tests for parsing the responses, so I think we're pretty well-covered there.