Model the API Response with a Plain Old Ruby Object
The model approach is handy when dealing with big JSON responses from remote APIs, because it helps the developer call out the parts of the response payload that are relevant to the calling module’s business logic. In this case, the Meetup responses might have dozens of bits of information about any given meetup, but your chat room users only need a few of them. The approach you’ll use to model this response payload is known as a Plain Old Ruby Object or PORO, as mentioned earlier. In other popular languages, you’ll see POJOs[31] (Java) and POCOs (C#).
Next is the initialize method of your MeetupResult class. Ruby invokes this method whenever someone calls MeetupResult.new(json_payload_goes_here) ...
Get Build Chatbot Interactions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.