preferences

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFields graphql.ResponseFields = `
        id
        created_at
        updated_at
        user_id
        key
        preference_items {key, value}
        `
	EmailKey = "email"
)

Variables

View Source
var (
	DefaultURL = "https://api.ctpx.secureworks.com/graphql"
)

Functions

func BuildRequest

func BuildRequest(graphqlReq *graphql.Request, bearerToken string, tenantID string) (*http.Request, error)

Types

type IPreferencesSvc

type IPreferencesSvc interface {
	CreatePreferences(*PreferencesInput, graphql.ResponseFields) (*PreferencesOutput, error)
	CreateTenantPreferences(in *PreferencesInput, rf graphql.ResponseFields) (*PreferencesOutput, error)
	GetPreferencesByKey(*PreferencesInput, graphql.ResponseFields) (*PreferencesOutput, error)
	ListTenantPreferencesByKey(in *PreferencesInput, rf graphql.ResponseFields) ([]*PreferencesOutput, error)
}

IPreferencesSvc defines what the the Preferences API can do

type PreferenceItem

type PreferenceItem struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type PreferencesInput

type PreferencesInput struct {
	BearerToken string `json:"-"`
	UserID      string
	TenantID    string
	Key         string
	Preferences map[string]interface{}
}

type PreferencesOutput

type PreferencesOutput struct {
	ID              uuid.UUID        `json:"id" db:"id"`
	CreatedAt       time.Time        `json:"created_at" db:"created_at"`
	UpdatedAt       time.Time        `json:"updated_at" db:"updated_at"`
	UserID          string           `json:"user_id" db:"user_id"`     //only used for userPreferences
	TenantID        string           `json:"tenant_id" db:"tenant_id"` // only used for tenantPreferences
	Key             string           `json:"key" db:"key"`
	PreferenceItems []PreferenceItem `json:"preference_items"`
}

type PreferencesSvc

type PreferencesSvc struct {
	// contains filtered or unexported fields
}

PreferencesSvc is the concrete implementation of the interface against the real api

func NewPreferencesSvc

func NewPreferencesSvc(c *client.Client, serviceName string) *PreferencesSvc

NewPreferenceSvc takes a client from `client` package -- see examples/preferences.go for an example

func (*PreferencesSvc) CreatePreferences

func (*PreferencesSvc) CreateTenantPreferences

func (t *PreferencesSvc) CreateTenantPreferences(in *PreferencesInput, rf graphql.ResponseFields) (*PreferencesOutput, error)

func (*PreferencesSvc) GetNotificationPreferences

func (t *PreferencesSvc) GetNotificationPreferences(in *PreferencesInput, rf graphql.ResponseFields) (*PreferencesOutput, error)

func (*PreferencesSvc) GetPreferencesByKey

func (t *PreferencesSvc) GetPreferencesByKey(in *PreferencesInput, rf graphql.ResponseFields) (*PreferencesOutput, error)

func (*PreferencesSvc) ListTenantPreferencesByKey

func (t *PreferencesSvc) ListTenantPreferencesByKey(in *PreferencesInput, rf graphql.ResponseFields) ([]*PreferencesOutput, error)

type RequestError

type RequestError struct {
	RespBody string
	Code     int
}

RequestError is a custom error type to capture a request response body and a response code

func NewRequestError

func NewRequestError(respBody io.Reader, respCode int) *RequestError

NewRequestError takes a response body and a response code and returns a custom error to the CreateNotification caller for failed request

func (*RequestError) Error

func (b *RequestError) Error() string

type UserEmail

type UserEmail struct {
	Mention             bool `json:"mention"`
	AssigneeChange      bool `json:"assignee_change"`
	AwaitingAction      bool `json:"awaiting_action"`
	GroupMention        bool `json:"group_mention"`
	GroupAssigneeChange bool `json:"group_assignee_change"`
	GroupAwaitingAction bool `json:"group_awaiting_action"`
	ExportsCSVReady     bool `json:"exports_csv_ready"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL