Skip to content

Commit

Permalink
fixed bug with url not being built correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Niosco committed Jan 17, 2019
1 parent 4862edf commit 587aa45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
24 changes: 18 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ func New(clientID, clientSecret, ipAddress, fingerprint string, modes ...bool) *

// GetNodes returns all of the nodes
func (c *Client) GetNodes(queryParams ...string) (map[string]interface{}, error) {
return c.do("GET", path["nodes"], "", queryParams)
url := buildURL(path["nodes"])

return c.do("GET", url, "", queryParams)
}

/********** OTHER **********/
Expand All @@ -166,7 +168,9 @@ func (c *Client) GetCryptoQuotes(queryParams ...string) (map[string]interface{},

// GetInstitutions returns all of the nodes associated with a user
func (c *Client) GetInstitutions() (map[string]interface{}, error) {
return c.do("GET", path["institutions"], "", nil)
url := buildURL(path["institutions"])

return c.do("GET", url, "", nil)
}

// LocateATMs returns a list of nearby ATMs
Expand Down Expand Up @@ -194,7 +198,9 @@ func (c *Client) GetPublicKey(scope ...string) (map[string]interface{}, error) {

// GetSubscriptions returns all of the nodes associated with a user
func (c *Client) GetSubscriptions(queryParams ...string) (map[string]interface{}, error) {
return c.do("GET", path["subscriptions"], "", queryParams)
url := buildURL(path["subscriptions"])

return c.do("GET", url, "", queryParams)
}

// GetSubscription returns a single subscription
Expand All @@ -206,7 +212,9 @@ func (c *Client) GetSubscription(subscriptionID string) (map[string]interface{},

// CreateSubscription creates a subscription and returns the subscription data
func (c *Client) CreateSubscription(data string, idempotencyKey ...string) (map[string]interface{}, error) {
return c.do("POST", path["subscriptions"], data, idempotencyKey)
buildURL := path["subscriptions"]

return c.do("POST", url, data, idempotencyKey)
}

// UpdateSubscription updates an existing subscription
Expand All @@ -220,14 +228,18 @@ func (c *Client) UpdateSubscription(subscriptionID string, data string) (map[str

// GetTransactions returns all client transactions
func (c *Client) GetTransactions(queryParams ...string) (map[string]interface{}, error) {
return c.do("GET", path["transactions"], "", queryParams)
url := path["transactions"]

return c.do("GET", url, "", queryParams)
}

/********** USER **********/

// GetUsers returns a list of users
func (c *Client) GetUsers(queryParams ...string) (map[string]interface{}, error) {
return c.do("GET", path["users"], "", queryParams)
url := path["users"]

return c.do("GET", url, "", queryParams)
}

// GetUser returns a single user
Expand Down
6 changes: 2 additions & 4 deletions url.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ func buildURL(uri ...string) string {
baseURL = "https://api.synapsefi.com/" + version
}

url := baseURL

for i := range uri {
url += "/" + uri[i]
baseURL += "/" + uri[i]
}

return url
return baseURL
}
1 change: 0 additions & 1 deletion users.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func (u *User) CreateNode(data string, idempotencyKey ...string) (map[string]int

// UpdateNode updates a node
func (u *User) UpdateNode(nodeID, data string) (map[string]interface{}, error) {

url := buildURL(path["users"], u.UserID, path["nodes"], nodeID)

return u.do("PATCH", url, data, nil)
Expand Down

0 comments on commit 587aa45

Please sign in to comment.