Browse Source

Let's export as little as possible

Piotr Czajkowski 3 years ago
parent
commit
7340142823
2 changed files with 10 additions and 13 deletions
  1. 4 4
      bullet.go
  2. 6 9
      push.go

+ 4 - 4
bullet.go

@@ -32,8 +32,8 @@ func (b Bullet) newRequest(body io.Reader) (*http.Request, error) {
 	return request, nil
 }
 
-func (b Bullet) send(push Push) error {
-	reader, errReader := push.GetReader()
+func (b Bullet) send(push pushStruct) error {
+	reader, errReader := push.getReader()
 	if errReader != nil {
 		return errReader
 	}
@@ -66,7 +66,7 @@ func (b Bullet) send(push Push) error {
 
 //SendNote sends push note with given title and text
 func (b Bullet) SendNote(title, text string) error {
-	note := NewNotePush(title, text)
+	note := newNotePush(title, text)
 	err := b.send(note)
 
 	return err
@@ -74,7 +74,7 @@ func (b Bullet) SendNote(title, text string) error {
 
 //SendLink sends push link with given title, text and link
 func (b Bullet) SendLink(title, text, link string) error {
-	linkPush := NewLinkPush(title, text, link)
+	linkPush := newLinkPush(title, text, link)
 	err := b.send(linkPush)
 
 	return err

+ 6 - 9
push.go

@@ -5,15 +5,14 @@ import (
 	"encoding/json"
 )
 
-type Push struct {
+type pushStruct struct {
 	Type  string `json:"type"`
 	Title string `json:"title"`
 	Body  string `json:"body"`
 	Url   string `json:"url"`
 }
 
-//GetReader
-func (p Push) GetReader() (*bytes.Buffer, error) {
+func (p pushStruct) getReader() (*bytes.Buffer, error) {
 	jsonBytes, err := json.Marshal(p)
 	if err != nil {
 		return nil, err
@@ -23,14 +22,12 @@ func (p Push) GetReader() (*bytes.Buffer, error) {
 	return buffer, err
 }
 
-//NewNotePush
-func NewNotePush(title, text string) Push {
-	push := Push{Type: "note", Title: title, Body: text}
+func newNotePush(title, text string) pushStruct {
+	push := pushStruct{Type: "note", Title: title, Body: text}
 	return push
 }
 
-//NewLinkPush
-func NewLinkPush(title, text, link string) Push {
-	push := Push{Type: "note", Title: title, Body: text, Url: link}
+func newLinkPush(title, text, link string) pushStruct {
+	push := pushStruct{Type: "note", Title: title, Body: text, Url: link}
 	return push
 }