Skip to content

Commit

Permalink
added logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Niosco committed Mar 27, 2019
1 parent 0b9d647 commit 9d3ed7f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func New(clientID, clientSecret, fingerprint, ipAddress string, modes ...bool) *
}
}

log.info("Building new client...")
return &Client{
ClientID: clientID,
ClientSecret: clientSecret,
Expand All @@ -147,6 +148,7 @@ func New(clientID, clientSecret, fingerprint, ipAddress string, modes ...bool) *
func (c *Client) GetNodes(queryParams ...string) (map[string]interface{}, error) {
url := buildURL(path["nodes"])

log.info("Getting list of nodes...")
return c.do("GET", url, "", queryParams)
}

Expand All @@ -156,27 +158,31 @@ func (c *Client) GetNodes(queryParams ...string) (map[string]interface{}, error)
func (c *Client) GetCryptoMarketData() (map[string]interface{}, error) {
url := buildURL(path["nodes"], "crypto-market-watch")

log.info("Getting crypto market data...")
return c.do("GET", url, "", nil)
}

// GetCryptoQuotes returns all of the quotes for crypto currencies
func (c *Client) GetCryptoQuotes(queryParams ...string) (map[string]interface{}, error) {
url := buildURL(path["nodes"], "crypto-quotes")

log.info("Getting crypto market quotes...")
return c.do("GET", url, "", queryParams)
}

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

log.info("Getting list of institutions...")
return c.do("GET", url, "", nil)
}

// LocateATMs returns a list of nearby ATMs
func (c *Client) LocateATMs(queryParams ...string) (map[string]interface{}, error) {
url := buildURL(path["nodes"], "atms")

log.info("Getting list of ATMs...")
return c.do("GET", url, "", queryParams)
}

Expand All @@ -191,13 +197,15 @@ func (c *Client) GetPublicKey(scope ...string) (map[string]interface{}, error) {

url += defaultScope

log.info("Getting public key...")
return c.do("GET", url, "", nil)
}

// GetWebhookLogs returns all of the webhooks sent to a specific client
func (c *Client) GetWebhookLogs() (map[string]interface{}, error) {
url := buildURL(path["subscriptions"], "logs")

log.info("Getting webhook logs...")
return c.do("GET", url, "", nil)
}

Expand All @@ -207,27 +215,31 @@ func (c *Client) GetWebhookLogs() (map[string]interface{}, error) {
func (c *Client) GetSubscriptions(queryParams ...string) (map[string]interface{}, error) {
url := buildURL(path["subscriptions"])

log.info("Getting list of subscriptions...")
return c.do("GET", url, "", queryParams)
}

// GetSubscription returns a single subscription
func (c *Client) GetSubscription(subscriptionID string) (map[string]interface{}, error) {
url := buildURL(path["subscriptions"], subscriptionID)

log.info("Getting subscription...")
return c.do("GET", url, "", nil)
}

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

log.info("Creating subscription...")
return c.do("POST", url, data, idempotencyKey)
}

// UpdateSubscription updates an existing subscription
func (c *Client) UpdateSubscription(subscriptionID string, data string) (map[string]interface{}, error) {
url := buildURL(path["subscriptions"], subscriptionID)

log.info("Updating subscription...")
return c.do("PATCH", url, data, nil)
}

Expand All @@ -237,6 +249,7 @@ func (c *Client) UpdateSubscription(subscriptionID string, data string) (map[str
func (c *Client) GetTransactions(queryParams ...string) (map[string]interface{}, error) {
url := buildURL(path["transactions"])

log.info("Getting list of transactions...")
return c.do("GET", url, "", queryParams)
}

Expand All @@ -246,6 +259,7 @@ func (c *Client) GetTransactions(queryParams ...string) (map[string]interface{},
func (c *Client) GetUsers(queryParams ...string) (map[string]interface{}, error) {
url := buildURL(path["users"])

log.info("Getting list of users...")
return c.do("GET", url, "", queryParams)
}

Expand All @@ -262,6 +276,7 @@ func (c *Client) GetUser(userID, fingerprint, ipAddress string, queryParams ...s
user.request = user.request.updateRequest(c.ClientID, c.ClientSecret, fingerprint, ipAddress)
user.Response = res

log.info("Getting user...")
return &user, err
}

Expand All @@ -280,5 +295,6 @@ func (c *Client) CreateUser(data, fingerprint, ipAddress string, idempotencyKey
user.request = user.request.updateRequest(c.ClientID, c.ClientSecret, fingerprint, ipAddress)
user.Response = res

log.info("Creating user...")
return &user, err
}
4 changes: 4 additions & 0 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (req *Request) Get(url string, params []string) ([]byte, error) {
return body, handleHTTPError(body)
}

log.info("GET", res.Status, url)
return body, nil
}

Expand Down Expand Up @@ -88,6 +89,7 @@ func (req *Request) Post(url, data string, params []string) ([]byte, error) {
return body, handleHTTPError(body)
}

log.info("POST", res.Status, url)
return body, nil
}

Expand Down Expand Up @@ -115,6 +117,7 @@ func (req *Request) Patch(url, data string, params []string) ([]byte, error) {
return body, handleHTTPError(body)
}

log.info("PATCH", res.Status, url)
return body, nil
}

Expand All @@ -135,5 +138,6 @@ func (req *Request) Delete(url string) ([]byte, error) {
return body, handleHTTPError(body)
}

log.info("DELETE", res.Status, url)
return body, nil
}
Loading

0 comments on commit 9d3ed7f

Please sign in to comment.