Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
refactor(): Rename package to ngs
Browse files Browse the repository at this point in the history
  • Loading branch information
taimoor-mirza committed Aug 1, 2023
1 parent 76a0166 commit 53fe58a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion message.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nozlgosdk
package ngs

import (
"encoding/json"
Expand Down
14 changes: 7 additions & 7 deletions nozl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nozlgosdk
package ngs

import (
"bytes"
Expand All @@ -8,25 +8,25 @@ import (
"net/http"
)

type Nozl struct {
type Client struct {
TenantAPIKey string
Url string
}

func (n *Nozl) SendMessage(msg *Message) ([]byte, error) {
func (c *Client) SendMessage(msg *Message) ([]byte, error) {
payload := msg.ToJson()

if payload != nil {
client := &http.Client{}
req, err := http.NewRequest("POST", n.Url, bytes.NewReader(payload))
req, err := http.NewRequest("POST", c.Url, bytes.NewReader(payload))

if err != nil {
fmt.Println(err.Error())
return nil, err
}

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", n.TenantAPIKey))
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.TenantAPIKey))

resp, err := client.Do(req)

Expand All @@ -45,7 +45,7 @@ func (n *Nozl) SendMessage(msg *Message) ([]byte, error) {
return body, nil

} else {
fmt.Println("Error: payload is empty")
return nil, errors.New("Error: payload is empty")
fmt.Println("error: payload is empty")
return nil, errors.New("error: payload is empty")
}
}

0 comments on commit 53fe58a

Please sign in to comment.