Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Fix bug in giphy when decoding to json (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
micnncim authored Oct 14, 2019
1 parent ca4488d commit 81f96dc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pkg/giphy/giphy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const gifURLFormat = "https://media.giphy.com/media/%s/giphy.gif"
const apiBaseURLFormat = "https://api.giphy.com/v1/%s"

type Giphy struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
GIFURL string `json:"gifurl"`
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
}

func (g *Giphy) GIFURLInMarkdownStyle() string {
return fmt.Sprintf("![](%s)", g.GIFURL)
gifURL := fmt.Sprintf(gifURLFormat, g.ID)
return fmt.Sprintf("![](%s)", gifURL)
}

type Payload struct {
Expand Down Expand Up @@ -75,9 +75,5 @@ func (c *Client) Search(q string) ([]*Giphy, error) {
return nil, err
}

data := payload.Data
for _, g := range data {
g.GIFURL = fmt.Sprintf(gifURLFormat, g.ID)
}
return data, nil
return payload.Data, nil
}

0 comments on commit 81f96dc

Please sign in to comment.