Browse Source

Preparing for testing

Piotr Czajkowski 3 years ago
parent
commit
ee3bf97da4
1 changed files with 5 additions and 4 deletions
  1. 5 4
      bullet.go

+ 5 - 4
bullet.go

@@ -16,12 +16,13 @@ const (
 
 //Bullet client for the Pushbullet API
 type Bullet struct {
-	token string
+	token   string
+	baseURL string
 }
 
 //NewBullet creates new Bullet using provided token
 func NewBullet(token string) Bullet {
-	b := Bullet{token: token}
+	b := Bullet{token: token, baseURL: "https://api.pushbullet.com/v2/"}
 	return b
 }
 
@@ -37,11 +38,11 @@ func (b Bullet) newRequest(body io.Reader, URL string) (*http.Request, error) {
 }
 
 func (b Bullet) newRequestPush(body io.Reader) (*http.Request, error) {
-	return b.newRequest(body, "https://api.pushbullet.com/v2/pushes")
+	return b.newRequest(body, b.baseURL+"pushes")
 }
 
 func (b Bullet) newRequestUpload(body io.Reader) (*http.Request, error) {
-	return b.newRequest(body, "https://api.pushbullet.com/v2/upload-request")
+	return b.newRequest(body, b.baseURL+"upload-request")
 }
 
 func doRequest(request *http.Request) (*http.Response, error) {