You’ve built the request line’s shows slice and followed one request through every layer of it. The rest of the request line is yours to build, with no walkthrough this time. Gloria has written down what she needs, and the station’s checks say when it’s done.
In this lesson, you’ll read Gloria’s brief and the calls that check it and see which parts of the finished API the exercises’ tests and the mentor will look at. Keep this lesson open while you build.
Read Gloria’s Brief
Listeners send Gloria song requests by text or through the station’s request form, and right now she copies them onto paper. Her brief names three resources:
- Shows: The broadcasts you built in the slice.
- Requests: A listener’s
name, either thephonethey texted from or theformIdthe request form gave them, thesong, and theartist. The server adds theid, theshowIdfrom the path, andplayed, which starts asfalse. - The do-not-play list: Songs the station won’t air, each a
songand anartist. The station edits it in the data file, and the API only reads it.
She adds three rules:
- One request per listener per show: The same
phoneorformIdgets one request for each show, played or not. This rule has to hold even when a double tap sends two at once. Check for the duplicate inside thestore.change()that saves the request, as your slice’s queue did for two shows. - Nothing from the do-not-play list: A song and artist that match an entry, ignoring upper and lower case and spaces around them, are refused.
- A request can be marked played: That way, Gloria knows which ones she’s done.
Fields in a POST body are strings. A phone is 7 to 15 digits with an optional + in front, and a request has exactly one of phone and formId. A name, song, or artist that’s blank after trimming is refused, as are an empty formId and any field the brief doesn’t name.