Skip to content

gravataLonga/api-call

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test Coverage Status Go Report Card

Read documentation here.

How to use

Create configuration

apiCall := apicall.New(
    WithBaseUrl("https://www.google.pt"),
)

Tip: You can create your own method for configuration, you only need to implement Option type.

Handler Response

response, err := apiCall.Send("GET", "/users/list", nil)  
if err != nil {
    panic("An error happen")
}

if !response.IsOk() {
    panic("Unable to success response")
}

fmt.Println(response) // response is apicall.BaseStandard struct

Bind your own structure to response

response, err := apiCall.Send("POST", "/get-users", nil)
if err != nil {
    panic("An error happen")
}

if !response.IsOk() {
    panic("Unable to success response")
}

type User struct {
    Name string
    Email string
}

var users []User
err = response.GetItems(&users)

for index, user := range users {
    fmt.Println(user.Name)
}

About

Golang Client Library - convert from PHP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages