From 676f2ae032ec67edfe1b08be637dec76db9a5adf Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Fri, 21 Feb 2020 01:56:57 +0000 Subject: [PATCH] Include chapter information in `MangaDex::Manga#to_info_json` output --- src/mangadex/api.cr | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mangadex/api.cr b/src/mangadex/api.cr index 789401c..97ac522 100644 --- a/src/mangadex/api.cr +++ b/src/mangadex/api.cr @@ -142,13 +142,22 @@ module Mangadex def initialize(@id, json_obj : JSON::Any) self.parse_json json_obj end - def to_info_json + def to_info_json(with_chapters = true) JSON.build do |json| json.object do {% for name in ["id", "title", "description", "author", "artist", "cover_url"] %} json.field {{name}}, @{{name.id}} {% end %} + if with_chapters + json.field "chapters" do + json.array do + @chapters.each do |c| + json.raw c.to_info_json + end + end + end + end end end end