Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation(readme) #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,24 @@ func main() {

url := "https://api.pindo.io/v1/sms/"

payload := strings.NewReader("{"to" : "+250781234567", "text" : "Hello from Pindo","sender" : "Pindo"}")
smsData := struct {
To string `json:"to"`
Text string `json:"text"`
Sender string `json:"sender"`
}{
To: "+250781234567",
Text: "Hello from Pindo",
Sender: "Pindo",
}

// Use the json package for a better conversion to prevent special characters from breaking the json
bs, err := json.Marshal(smsData)

if err != nil {
// Handle the conversion error

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably log the error? @nizigama else I'd just go with _ if we are not expecting any errors

Copy link
Author

@nizigama nizigama Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's always a good idea to log/handle errors even though in this case it's less likely to return any🙂

}

payload := strings.NewReader(string(bs))

req, _ := http.NewRequest("POST", url, payload)

Expand Down