~edwardloveall/scribe

ref: 1dcded9153c482553538fdf9a4f80e7d9361b19c scribe/src/models/post_response.cr -rw-r--r-- 2.2 KiB
1dcded91Edward Loveall Update changelog to mention no DATABASE_URL 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
class PostResponse
  class Base
    include JSON::Serializable
  end

  class Root < Base
    property data : Data
  end

  class Data < Base
    property post : Post
  end

  class Post < Base
    property title : String
    property createdAt : Int64
    property creator : Creator
    property content : Content
  end

  class Creator < Base
    property name : String
    property id : String
  end

  class Content < Base
    property bodyModel : BodyModel
  end

  class BodyModel < Base
    property paragraphs : Array(Paragraph)
  end

  class Paragraph < Base
    property text : String?
    property type : ParagraphType
    property markups : Array(Markup)
    property iframe : IFrame?
    property layout : String?
    property metadata : Metadata?

    def initialize(
      @text : String?,
      @type : ParagraphType,
      @markups : Array(Markup),
      @iframe : IFrame?,
      @layout : String?,
      @metadata : Metadata?
    )
    end
  end

  enum ParagraphType
    BQ
    H2
    H3
    H4
    IFRAME
    IMG
    MIXTAPE_EMBED
    OLI
    P
    PQ
    PRE
    SECTION_CAPTION
    ULI
  end

  class Markup < Base
    property title : String?
    property type : MarkupType
    property href : String?
    property userId : String?
    property start : Int32
    property end : Int32
    property anchorType : AnchorType?

    def initialize(
      @type : MarkupType,
      @start : Int32,
      @end : Int32,
      @title : String? = nil,
      @href : String? = nil,
      @userId : String? = nil,
      @anchorType : AnchorType? = nil
    )
    end
  end

  enum MarkupType
    A
    CODE
    EM
    STRONG
  end

  enum AnchorType
    LINK
    USER
  end

  class IFrame < Base
    property mediaResource : MediaResource

    def initialize(@mediaResource : MediaResource)
    end
  end

  class MediaResource < Base
    property href : String
    property iframeSrc : String
    property iframeWidth : Int32
    property iframeHeight : Int32

    def initialize(
      @href : String,
      @iframeSrc : String,
      @iframeWidth : Int32,
      @iframeHeight : Int32
    )
    end
  end

  class Metadata < Base
    property id : String
    property originalWidth : Int32?
    property originalHeight : Int32?
  end
end