Skip to content

Commit

Permalink
Added get all application users code in requestx package.
Browse files Browse the repository at this point in the history
  • Loading branch information
hetjagani committed Feb 8, 2021
1 parent e655ba7 commit 137a2a8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions requestx/application.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package requestx

import (
"errors"
"fmt"
"net/http"

"github.com/spf13/viper"
)

// AllApplicationUsers gets all the users for a application from kavach
func AllApplicationUsers(appSlug string, oID, uID uint) (*http.Response, error) {
if appSlug == "" {
return nil, errors.New("appSlug parameter cannot be empty")
}

resp, err := Request("GET", viper.GetString("kavach_url")+"/users/application?application="+appSlug, nil, map[string]string{
"X-User": fmt.Sprint(uID),
"X-Organisation": fmt.Sprint(oID),
})

if err != nil {
return nil, err
}

if resp.StatusCode > 500 {
return nil, errors.New("something went wrong")
}

return resp, nil
}

0 comments on commit 137a2a8

Please sign in to comment.