From 1f9c5d4f257800db7c9f02f94dcd319963e313ec Mon Sep 17 00:00:00 2001 From: utahta Date: Thu, 23 Nov 2017 21:45:08 +0900 Subject: [PATCH] Add NotifyMessage method --- README.md | 2 ++ notify.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5acb069..6d63aad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # go-linenotify +[![GoDoc Reference](https://godoc.org/github.com/utahta/go-linenotify?status.svg)](http://godoc.org/github.com/utahta/go-linenotify) [![Build Status](https://travis-ci.org/utahta/go-linenotify.svg?branch=master)](https://travis-ci.org/utahta/go-linenotify) +[![GitHub release](https://img.shields.io/github/release/utahta/go-linenotify.svg)](https://github.com/utahta/go-linenotify/releases) Go client library for the [LINE Notify](https://notify-bot.line.me/doc/) diff --git a/notify.go b/notify.go index 763e126..beb7412 100644 --- a/notify.go +++ b/notify.go @@ -15,7 +15,7 @@ import ( ) type ( - // NotifyResponse + // NotifyResponse represents response that LINE Notify API NotifyResponse struct { Status int `json:"status"` Message string `json:"message"` @@ -24,9 +24,10 @@ type ( ) var ( - ErrNotifyInvalidAccessToken = errors.New("Invalid access token") + ErrNotifyInvalidAccessToken = errors.New("invalid access token") ) +// Notify provides convenient Notify* interface func (c *Client) Notify(token, message, imageThumbnail, imageFullsize string, image io.Reader) (*NotifyResponse, error) { if image != nil { return c.NotifyWithImage(token, message, image) @@ -34,6 +35,12 @@ func (c *Client) Notify(token, message, imageThumbnail, imageFullsize string, im return c.NotifyWithImageURL(token, message, imageThumbnail, imageFullsize) } +// NotifyMessage notify text message +func (c *Client) NotifyMessage(token, message string) (*NotifyResponse, error) { + return c.NotifyWithImageURL(token, message, "", "") +} + +// NotifyWithImage notify text message and image by binary func (c *Client) NotifyWithImage(token, message string, image io.Reader) (*NotifyResponse, error) { body, contentType, err := c.requestBodyWithImage(message, image) if err != nil { @@ -42,6 +49,7 @@ func (c *Client) NotifyWithImage(token, message string, image io.Reader) (*Notif return c.notify(token, message, body, contentType) } +// NotifyWithImageURL notify text message and image by url func (c *Client) NotifyWithImageURL(token, message, imageThumbnail, imageFullsize string) (*NotifyResponse, error) { body, contentType, err := c.requestBody(message, imageThumbnail, imageFullsize) if err != nil {