package api

import (
	"io/ioutil"
	"net/http"
	"net/url"
)

type LinodeClient struct {
	APIKey string
}

func NewLinodeClient() *LinodeClient {
	return NewLinodeClient()
}

func NewLinodeClientWithKey(apiKey string) *LinodeClient {
	return &LinodeClient{
		APIKey: apiKey,
	}
}

func (c *LinodeClient) APICall(query string) ([]byte, error) {
	response, err := http.Get(API_ENDPOINT + "/?" + query)
	if err != nil {
		return nil, err
	}
	defer response.Body.Close()
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}
	return body, nil
}

func (c *LinodeClient) ListLinodes() ([]byte, error) {
	params := url.Values{}
	params.Add("api_key", c.APIKey)
	params.Add("api_action", "linode.list")
	return c.APICall(query)
}

package api

import (
	"io/ioutil"
	"net/http"
)

type LinodeClient struct {
	APIKey string
}

func NewLinodeClient() *LinodeClient {
	return NewLinodeClient()
}

func NewLinodeClientWithKey(apiKey string) *LinodeClient {
	return &LinodeClient{
		APIKey: apiKey,
	}
}

func (c *LinodeClient) ListLinodes() ([]byte, error) {
	response, err := http.Get(API_ENDPOINT + "/?api_key=" + c.APIKey +
		"&api_action=linode.list")
	if err != nil {
		return nil, err
	}
	defer response.Body.Close()
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}
	return body, nil
}

--- 
+++ 
@@ -3,6 +3,7 @@
 import (
 	"io/ioutil"
 	"net/http"
+	"net/url"
 )
 
 type LinodeClient struct {
@@ -19,9 +20,8 @@
 	}
 }
 
-func (c *LinodeClient) ListLinodes() ([]byte, error) {
-	response, err := http.Get(API_ENDPOINT + "/?api_key=" + c.APIKey +
-		"&api_action=linode.list")
+func (c *LinodeClient) APICall(query string) ([]byte, error) {
+	response, err := http.Get(API_ENDPOINT + "/?" + query)
 	if err != nil {
 		return nil, err
 	}
@@ -32,3 +32,10 @@
 	}
 	return body, nil
 }
+
+func (c *LinodeClient) ListLinodes() ([]byte, error) {
+	params := url.Values{}
+	params.Add("api_key", c.APIKey)
+	params.Add("api_action", "linode.list")
+	return c.APICall(query)
+}
Refactor HTTP call out of function
