Skip to content
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
27 changes: 18 additions & 9 deletions fixtures/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fixtures

import (
"encoding/json"
"fmt"
)

const MarcusUserResponse = `{
Expand Down Expand Up @@ -172,14 +171,24 @@ const PaginatedResponseTmpl = `{
"schemas" : [ "urn:scim:schemas:core:1.0"]
}`

// PaginatedResponseStruct represents a paginated SCIM response
type PaginatedResponseStruct struct {
Resources []interface{} `json:"resources"`
StartIndex int `json:"startIndex"`
ItemsPerPage int `json:"itemsPerPage"`
TotalResults int `json:"totalResults"`
Schemas []string `json:"schemas"`
}

func PaginatedResponse(resources ...interface{}) string {
bytes, _ := json.Marshal(resources)
response := PaginatedResponseStruct{
Resources: resources,
StartIndex: 1,
ItemsPerPage: 50,
TotalResults: len(resources),
Schemas: []string{"urn:scim:schemas:core:1.0"},
}

return fmt.Sprintf(`{
"resources": %v,
"startIndex" : 1,
"itemsPerPage" : 50,
"totalResults" : %v,
"schemas" : [ "urn:scim:schemas:core:1.0"]
}`, string(bytes), len(resources))
bytes, _ := json.Marshal(response)
return string(bytes)
}
Loading