-
Perfect, so now we just need to do that exact same thing for our statuses as well. So back inside of our terminal here,
-
let's do node ace make controller API V1 statuses, and then suffix that with a hyphen a flag to get our API methods added into there.
-
Perfect, we can clear our terminal out now and jump back into our text editor. Within our statuses controller, we could go about writing all of that yet again,
-
or we could go into, let's say our difficulties controller, and then just copy all of these methods since we have them fulfilled and everything's going to work the exact same. The only thing that we're gonna need to change
-
is difficulty over to status. Jump into our statuses controller, select all of our methods within here and give them a paste. Let's leave all of our red squigglies for now
-
as we slowly want to just convert these from destroy difficulty, for example, to instead destroy status. Do the same thing here for our validator, status destroy validator.
-
We can go ahead and command dot with our with organization metadata highlighted and add an import from our validators helpers organization for that.
-
Scroll on up and continue replacing all of these. We have our update difficulty that we will replace with update status. No longer want the difficulty validator,
-
but instead the status validator. We'll leave the text here as is, as we don't need to import anything for that. So we can just do a find and replace. Then we have our store difficulty
-
that we'll replace with our store. Oops, we're doing statuses here. So store status and then replace this yet again with our status validator. Okay, we're almost there.
-
Next we need to replace instances where we have difficulties with statuses. So we'll do command F to bring up our find and then add the dropdown so that we can get replace here
-
to replace difficulties with statuses. There's only two matches for that, but we'll replace them both, switching both of our relationship queries from our difficulties over to our statuses.
-
Then we can do the singular version here. So command F again with difficulty highlighted to replace difficulty with just status. Replace all of those. And let's give it a last scan through here
-
to make sure everything looks good looking. And so far so good. Sure enough, looks like we got it. Cool, let's give that a save. Jump back over into our API route definitions
-
and add in our router resource for our statuses using our statuses controller from our API version one
-
folder, tack on API only for that. And we're good to go. Cool, so that saved us some typing. Let's jump back into Hopscotch now and let's do something relatively similar within here.
-
So let's go ahead and right click our difficulties and let's duplicate the entire folder. So now we have a difficulties duplicate folder that contains all of the different methods that we need for our API within here.
-
Switch the folder name from difficulties duplicate to instead just be statuses. And then rather than individually creating each one of these, we can now just walk through them,
-
switch difficulties over to statuses and update them as we walk through. So let's send this off first just to make sure everything works here. And this looks correct. We are indeed getting back statuses now.
-
So not started, planned, recorded, edited and done. There are the defaults. So let's go ahead and save that one. That looks good. Actually, we do need to switch the name here.
-
So if you wanted to make these a little bit more shareable, I guess you could just do get list, but we'll go ahead and be verbose here. So get statuses, switch over to our store next. And I'm just gonna roll through and update
-
all of these names here real quick. So store status, get, switch that to status updates,
-
switch that to status and then destroy. We will switch that to status as well. Okay, cool.
-
So now we don't have to deal with any of the name updates and we just need to worry about our actual endpoint chain our statuses. So with our body, that would work just fine here as well.
-
So let's go ahead and just send that off and looks good. We get back our API test two as our response. Let's go ahead and create one more for our delete test. That has an ID of 12.
-
Perfect. Hit save on that. Let's jump now over into our get status. We should have one that has an ID of 10. We do need to switch that to statuses and let's send that off.
-
Oh, row not found. Okay. We must have deleted that one. Let me go back to my get statuses here and let's check out the ID. So we have one, two, three, four, five.
-
Those must have been ones that we deleted and worked with during the previous series. So let's try five. That should be done, I believe. And sure enough, we get back five done. Perfect.
-
So that too is working a-okay. Let's give that one a saved and move on to our update status. Within our store, I believe we created one with an ID of 12. So let's go ahead and work with 12 here.
-
With our body, let's tack on a hyphen edit just to make sure that some change occurred. Send that off and whoops, I left this as difficulties.
-
Let's switch that to statuses and try that once more. Perfect. Okay. That worked that time. Good. Give that a save. And then lastly, we now need our destroy status.
-
So we'll switch that to statuses. We'll destroy the one with the ID of 11 since we updated the one with an ID of 12. With our body, we will switch the replacement ID from 10.
-
Actually, we've confirmed that 10 does not exist. So let's make sure that we get back a validation response for that. So let's delete our statuses and perfect, we do. The selected replacement ID is invalid.
-
So our exists check has failed there. So let's now switch that to 12, which should exist. Send that off and we get back our 204 new content signaling that that succeeded.