Skip to content

Commit

Permalink
formatted using gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tzhenghao committed Jul 1, 2016
1 parent 75bf4de commit 5cd5d88
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Device.go
Expand Up @@ -46,7 +46,7 @@ func GetDevice(deviceid int) Device {
func ClaimOwnershipAndActivateDevice(simnumber int) Device {

var params Parameters
req := createPostRequest("/cellular/sim_" + strconv.Itoa(simnumber) + "/claim", params)
req := createPostRequest("/cellular/sim_"+strconv.Itoa(simnumber)+"/claim", params)

resp, err := sendRequest(req)
if err != nil {
Expand All @@ -62,7 +62,7 @@ func ClaimOwnershipAndActivateDevice(simnumber int) Device {
func PurchaseAndAssignPhoneNumberToDevice(deviceid int) Device {

var params Parameters
req := createPostRequest("/devices/" + strconv.Itoa(deviceid) + "/addnumber", params)
req := createPostRequest("/devices/"+strconv.Itoa(deviceid)+"/addnumber", params)

resp, err := sendRequest(req)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion Errors.go
Expand Up @@ -69,4 +69,3 @@ func (e Errors) Errors() []Error {
}
return out
}

2 changes: 1 addition & 1 deletion Parameters.go
@@ -1,6 +1,6 @@
package HologramGo

type Parameters struct {
items []string
items []string
values []string
}
2 changes: 1 addition & 1 deletion Placeholder.go
Expand Up @@ -2,4 +2,4 @@ package HologramGo

// This is just a placeholder for the map[string]interface{}, which is used
// when unmarshalling data from a json object.
type Placeholder map[string]interface{}
type Placeholder map[string]interface{}
20 changes: 10 additions & 10 deletions Request.go
Expand Up @@ -3,21 +3,21 @@ package HologramGo
// This file contains all HTTP Response related behavior.

import (
"encoding/json"
"fmt"
"golang.org/x/net/publicsuffix"
"net/http/cookiejar"
"io/ioutil"
"log"
"net/http"
"net/http/cookiejar"
"net/url"
"os"
"io/ioutil"
"encoding/json"
"strings"
"fmt"
"log"
)

const HOLOGRAM_REST_API_BASEURL = "https://dashboard.hologram.io/api/1"

var err error
var err error

// These two variables will store user's username and password.
var username string
Expand All @@ -44,7 +44,7 @@ func InitializeUsernameAndPassword(credentialFile string) {
// EFFECTS: Sends a HTTP request through this instance's HTTP client.
func sendRequest(req *http.Request) (response *Response, err error) {

options := cookiejar.Options {
options := cookiejar.Options{
PublicSuffixList: publicsuffix.List,
}

Expand All @@ -53,7 +53,7 @@ func sendRequest(req *http.Request) (response *Response, err error) {
log.Fatal(err)
}

client := &http.Client {
client := &http.Client{
Jar: jar,
}

Expand All @@ -68,7 +68,7 @@ func sendRequest(req *http.Request) (response *Response, err error) {
// EFFECTS: Creates and populates a HTTP GET request.
func createGetRequest(derivedUrl string) (req *http.Request) {

req, err = http.NewRequest("GET", HOLOGRAM_REST_API_BASEURL + derivedUrl, nil)
req, err = http.NewRequest("GET", HOLOGRAM_REST_API_BASEURL+derivedUrl, nil)
if err != nil {
fmt.Printf("Could not parse request: %v\n", err)
os.Exit(1)
Expand All @@ -91,7 +91,7 @@ func createPostRequest(derivedUrl string, params Parameters) (req *http.Request)

body := strings.NewReader(data.Encode())

req, err = http.NewRequest("POST", HOLOGRAM_REST_API_BASEURL + derivedUrl, body)
req, err = http.NewRequest("POST", HOLOGRAM_REST_API_BASEURL+derivedUrl, body)
fmt.Println(HOLOGRAM_REST_API_BASEURL + derivedUrl)
if err != nil {
fmt.Printf("Could not parse request: %v\n", err)
Expand Down
8 changes: 4 additions & 4 deletions Response.go
Expand Up @@ -3,11 +3,11 @@ package HologramGo
// This file contains all HTTP Response related behavior.

import (
"io"
"net/http"
"encoding/json"
"io/ioutil"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
)

Expand Down Expand Up @@ -95,7 +95,7 @@ func (response Response) parsePayload(out interface{}) (err error) {
err = *e
}
} else if statusCode == STATUS_CREATED || statusCode == STATUS_ACCEPTED ||
statusCode == STATUS_OK {
statusCode == STATUS_OK {
b, err = response.parseBody()
if err != nil {
return err
Expand Down
4 changes: 1 addition & 3 deletions User.go
Expand Up @@ -28,7 +28,7 @@ func CreateUser(id int) User {

func GetUserAccountDetails(id int) User {

req := createGetRequest("/users/" + strconv.Itoa(id));
req := createGetRequest("/users/" + strconv.Itoa(id))

resp, err := sendRequest(req)
if err != nil {
Expand All @@ -39,7 +39,6 @@ func GetUserAccountDetails(id int) User {
return unmarshallIntoObject(resp)
}


// REQUIRES: a new password from the user.
// EFFECTS: Changes the user's password
func ChangeUserPassword(password string) User {
Expand All @@ -56,7 +55,6 @@ func ChangeUserPassword(password string) User {
return unmarshallIntoObject(resp)
}


// EFFECTS: Retrieve user addresses.
func GetUserAddresses() User {

Expand Down

0 comments on commit 5cd5d88

Please sign in to comment.