mirror of
https://github.com/SphericalKat/medium.rip.git
synced 2026-10-21 01:34:22 +00:00
feat: add method to fetch response from medium API
Signed-off-by: Sphericalkat <amolele@gmail.com>
This commit is contained in:
1 parent
83154587d8
commit
6117c82d32
2 files changed
+170
No files matched your search
@@ -0,0 +1,78 @@
|
||||
package entities
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func UnmarshalMediumResponse(data []byte) (MediumResponse, error) {
|
||||
var r MediumResponse
|
||||
err := json.Unmarshal(data, &r)
|
||||
return r, err
|
||||
}
|
||||
|
||||
func (r *MediumResponse) Marshal() ([]byte, error) {
|
||||
return json.Marshal(r)
|
||||
}
|
||||
|
||||
type MediumResponse struct {
|
||||
Data Data `json:"data"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
Post Post `json:"post"`
|
||||
}
|
||||
|
||||
type Post struct {
|
||||
Title string `json:"title"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
Creator Creator `json:"creator"`
|
||||
Content Content `json:"content"`
|
||||
}
|
||||
|
||||
type Content struct {
|
||||
BodyModel BodyModel `json:"bodyModel"`
|
||||
}
|
||||
|
||||
type BodyModel struct {
|
||||
Paragraphs []Paragraph `json:"paragraphs"`
|
||||
}
|
||||
|
||||
type Paragraph struct {
|
||||
Name string `json:"name"`
|
||||
Text string `json:"text"`
|
||||
Type Type `json:"type"`
|
||||
Href interface{} `json:"href"`
|
||||
Layout *string `json:"layout"`
|
||||
Markups []Markup `json:"markups"`
|
||||
Iframe interface{} `json:"iframe"`
|
||||
Metadata *Metadata `json:"metadata"`
|
||||
}
|
||||
|
||||
type Markup struct {
|
||||
Title *string `json:"title"`
|
||||
Type string `json:"type"`
|
||||
Href *string `json:"href"`
|
||||
UserID interface{} `json:"userId"`
|
||||
Start int64 `json:"start"`
|
||||
End int64 `json:"end"`
|
||||
AnchorType *string `json:"anchorType"`
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
ID string `json:"id"`
|
||||
OriginalWidth int64 `json:"originalWidth"`
|
||||
OriginalHeight int64 `json:"originalHeight"`
|
||||
}
|
||||
|
||||
type Creator struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Type string
|
||||
|
||||
const (
|
||||
H3 Type = "H3"
|
||||
H4 Type = "H4"
|
||||
Img Type = "IMG"
|
||||
P Type = "P"
|
||||
Pre Type = "PRE"
|
||||
)
|
||||
Reference in new issue
Block a user