catalog

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddToCartRequest

type AddToCartRequest struct {
	CatalogItemSysID string                 `json:"sysparm_id"`
	Quantity         int                    `json:"sysparm_quantity"`
	Variables        map[string]interface{} `json:"variables"`
}

AddToCartRequest represents a request to add an item to cart

type AddToCartResponse

type AddToCartResponse struct {
	Success bool   `json:"success"`
	CartID  string `json:"cart_id"`
	ItemID  string `json:"item_id"`
	Message string `json:"message"`
	Error   string `json:"error,omitempty"`
}

AddToCartResponse represents the response from adding to cart

type Cart

type Cart struct {
	Items      []CartItem `json:"items"`
	TotalPrice string     `json:"total_price"`
	Subtotal   string     `json:"subtotal"`
	Tax        string     `json:"tax"`
}

Cart represents the shopping cart

type CartItem

type CartItem struct {
	SysID            string                 `json:"sys_id"`
	CatalogItemSysID string                 `json:"cat_item"`
	Quantity         int                    `json:"quantity"`
	Price            string                 `json:"price"`
	RecurringPrice   string                 `json:"recurring_price"`
	Variables        map[string]interface{} `json:"variables"`
	ItemDetails      *CatalogItem           `json:"item_details,omitempty"`
}

CartItem represents an item in the shopping cart

type Catalog

type Catalog struct {
	SysID       string `json:"sys_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Active      bool   `json:"active"`
	Background  string `json:"background_color"`
	Icon        string `json:"icon"`
}

Catalog represents a ServiceNow catalog

type CatalogClient

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

CatalogClient handles ServiceNow Service Catalog API operations

func NewCatalogClient

func NewCatalogClient(client *core.Client) *CatalogClient

NewCatalogClient creates a new service catalog client

func (*CatalogClient) AddToCart

func (cc *CatalogClient) AddToCart(itemSysID string, quantity int, variables map[string]interface{}) (*AddToCartResponse, error)

AddToCart adds a catalog item to the cart

func (*CatalogClient) AddToCartWithContext

func (cc *CatalogClient) AddToCartWithContext(ctx context.Context, itemSysID string, quantity int, variables map[string]interface{}) (*AddToCartResponse, error)

AddToCartWithContext adds a catalog item to the cart with context support

func (*CatalogClient) ClearCart

func (cc *CatalogClient) ClearCart() error

ClearCart removes all items from the cart

func (*CatalogClient) ClearCartWithContext

func (cc *CatalogClient) ClearCartWithContext(ctx context.Context) error

ClearCartWithContext clears the cart with context support

func (*CatalogClient) EstimatePrice

func (cc *CatalogClient) EstimatePrice(itemSysID string, quantity int, variables map[string]interface{}) (*PriceEstimate, error)

EstimatePrice estimates the price for a catalog item with given variables

func (*CatalogClient) EstimatePriceWithContext

func (cc *CatalogClient) EstimatePriceWithContext(ctx context.Context, itemSysID string, quantity int, variables map[string]interface{}) (*PriceEstimate, error)

EstimatePriceWithContext estimates price with context support

func (*CatalogClient) GetCart

func (cc *CatalogClient) GetCart() (*Cart, error)

GetCart returns the current cart contents

func (*CatalogClient) GetCartWithContext

func (cc *CatalogClient) GetCartWithContext(ctx context.Context) (*Cart, error)

GetCartWithContext returns the current cart contents with context support

func (*CatalogClient) GetCatalog

func (cc *CatalogClient) GetCatalog(sysID string) (*Catalog, error)

GetCatalog returns a specific catalog by sys_id

func (*CatalogClient) GetCatalogWithContext

func (cc *CatalogClient) GetCatalogWithContext(ctx context.Context, sysID string) (*Catalog, error)

GetCatalogWithContext returns a specific catalog by sys_id with context support

func (*CatalogClient) GetCategory

func (cc *CatalogClient) GetCategory(sysID string) (*Category, error)

GetCategory returns a specific category by sys_id

func (*CatalogClient) GetCategoryWithContext

func (cc *CatalogClient) GetCategoryWithContext(ctx context.Context, sysID string) (*Category, error)

GetCategoryWithContext returns a specific category by sys_id with context support

func (*CatalogClient) GetItem

func (cc *CatalogClient) GetItem(sysID string) (*CatalogItem, error)

GetItem returns a specific catalog item by sys_id

func (*CatalogClient) GetItemVariables

func (cc *CatalogClient) GetItemVariables(itemSysID string) ([]CatalogVariable, error)

GetItemVariables returns variables for a catalog item

func (*CatalogClient) GetItemVariablesWithContext

func (cc *CatalogClient) GetItemVariablesWithContext(ctx context.Context, itemSysID string) ([]CatalogVariable, error)

GetItemVariablesWithContext returns variables for a catalog item with context support

func (*CatalogClient) GetItemWithContext

func (cc *CatalogClient) GetItemWithContext(ctx context.Context, sysID string) (*CatalogItem, error)

GetItemWithContext returns a specific catalog item by sys_id with context support

func (*CatalogClient) GetItemWithVariables

func (cc *CatalogClient) GetItemWithVariables(sysID string) (*CatalogItem, error)

GetItemWithVariables returns a catalog item with its variables

func (*CatalogClient) GetItemWithVariablesWithContext

func (cc *CatalogClient) GetItemWithVariablesWithContext(ctx context.Context, sysID string) (*CatalogItem, error)

GetItemWithVariablesWithContext returns a catalog item with variables and context support

func (*CatalogClient) GetItemsByType

func (cc *CatalogClient) GetItemsByType(itemType string) ([]CatalogItem, error)

GetItemsByType returns catalog items of a specific type

func (*CatalogClient) GetItemsByTypeWithContext

func (cc *CatalogClient) GetItemsByTypeWithContext(ctx context.Context, itemType string) ([]CatalogItem, error)

GetItemsByTypeWithContext returns catalog items by type with context support

func (*CatalogClient) GetOrderGuides

func (cc *CatalogClient) GetOrderGuides() ([]CatalogItem, error)

GetOrderGuides returns catalog items that are order guides

func (*CatalogClient) GetOrderGuidesWithContext

func (cc *CatalogClient) GetOrderGuidesWithContext(ctx context.Context) ([]CatalogItem, error)

GetOrderGuidesWithContext returns order guides with context support

func (*CatalogClient) ListAllCategories

func (cc *CatalogClient) ListAllCategories() ([]Category, error)

ListAllCategories returns all active categories across all catalogs

func (*CatalogClient) ListAllCategoriesWithContext

func (cc *CatalogClient) ListAllCategoriesWithContext(ctx context.Context) ([]Category, error)

ListAllCategoriesWithContext returns all active categories with context support

func (*CatalogClient) ListAllItems

func (cc *CatalogClient) ListAllItems() ([]CatalogItem, error)

ListAllItems returns all active catalog items

func (*CatalogClient) ListAllItemsWithContext

func (cc *CatalogClient) ListAllItemsWithContext(ctx context.Context) ([]CatalogItem, error)

ListAllItemsWithContext returns all active catalog items with context support

func (*CatalogClient) ListCatalogs

func (cc *CatalogClient) ListCatalogs() ([]Catalog, error)

ListCatalogs returns all available catalogs

func (*CatalogClient) ListCatalogsWithContext

func (cc *CatalogClient) ListCatalogsWithContext(ctx context.Context) ([]Catalog, error)

ListCatalogsWithContext returns all available catalogs with context support

func (*CatalogClient) ListCategories

func (cc *CatalogClient) ListCategories(catalogSysID string) ([]Category, error)

ListCategories returns categories for a catalog

func (*CatalogClient) ListCategoriesWithContext

func (cc *CatalogClient) ListCategoriesWithContext(ctx context.Context, catalogSysID string) ([]Category, error)

ListCategoriesWithContext returns categories for a catalog with context support

func (*CatalogClient) ListItems

func (cc *CatalogClient) ListItems(catalogSysID string) ([]CatalogItem, error)

ListItems returns catalog items for a specific catalog

func (*CatalogClient) ListItemsByCategory

func (cc *CatalogClient) ListItemsByCategory(categorySysID string) ([]CatalogItem, error)

ListItemsByCategory returns catalog items for a specific category

func (*CatalogClient) ListItemsByCategoryWithContext

func (cc *CatalogClient) ListItemsByCategoryWithContext(ctx context.Context, categorySysID string) ([]CatalogItem, error)

ListItemsByCategoryWithContext returns catalog items by category with context support

func (*CatalogClient) ListItemsWithContext

func (cc *CatalogClient) ListItemsWithContext(ctx context.Context, catalogSysID string) ([]CatalogItem, error)

ListItemsWithContext returns catalog items with context support

func (*CatalogClient) NewRequestTracker

func (cc *CatalogClient) NewRequestTracker() *RequestTracker

NewRequestTracker creates a new request tracker

func (*CatalogClient) OrderNow

func (cc *CatalogClient) OrderNow(itemSysID string, quantity int, variables map[string]interface{}) (*OrderResult, error)

OrderNow directly orders a catalog item without using the cart

func (*CatalogClient) OrderNowWithContext

func (cc *CatalogClient) OrderNowWithContext(ctx context.Context, itemSysID string, quantity int, variables map[string]interface{}) (*OrderResult, error)

OrderNowWithContext directly orders an item with context support

func (*CatalogClient) RemoveFromCart

func (cc *CatalogClient) RemoveFromCart(cartItemSysID string) error

RemoveFromCart removes an item from the cart

func (*CatalogClient) RemoveFromCartWithContext

func (cc *CatalogClient) RemoveFromCartWithContext(ctx context.Context, cartItemSysID string) error

RemoveFromCartWithContext removes an item from the cart with context support

func (*CatalogClient) SearchCategories

func (cc *CatalogClient) SearchCategories(searchTerm string) ([]Category, error)

SearchCategories searches categories by title or description

func (*CatalogClient) SearchCategoriesWithContext

func (cc *CatalogClient) SearchCategoriesWithContext(ctx context.Context, searchTerm string) ([]Category, error)

SearchCategoriesWithContext searches categories with context support

func (*CatalogClient) SearchItems

func (cc *CatalogClient) SearchItems(searchTerm string) ([]CatalogItem, error)

SearchItems searches catalog items by name or description

func (*CatalogClient) SearchItemsWithContext

func (cc *CatalogClient) SearchItemsWithContext(ctx context.Context, searchTerm string) ([]CatalogItem, error)

SearchItemsWithContext searches catalog items with context support

func (*CatalogClient) SubmitCart

func (cc *CatalogClient) SubmitCart() (*OrderResult, error)

SubmitCart submits the current cart as an order

func (*CatalogClient) SubmitCartWithContext

func (cc *CatalogClient) SubmitCartWithContext(ctx context.Context) (*OrderResult, error)

SubmitCartWithContext submits the cart with context support

func (*CatalogClient) UpdateCartItem

func (cc *CatalogClient) UpdateCartItem(cartItemSysID string, quantity int, variables map[string]interface{}) error

UpdateCartItem updates the quantity or variables of a cart item

func (*CatalogClient) UpdateCartItemWithContext

func (cc *CatalogClient) UpdateCartItemWithContext(ctx context.Context, cartItemSysID string, quantity int, variables map[string]interface{}) error

UpdateCartItemWithContext updates cart item with context support

func (*CatalogClient) ValidateItemVariables

func (cc *CatalogClient) ValidateItemVariables(itemSysID string, variables map[string]interface{}) ([]ValidationError, error)

ValidateItemVariables validates variables for a catalog item

func (*CatalogClient) ValidateItemVariablesWithContext

func (cc *CatalogClient) ValidateItemVariablesWithContext(ctx context.Context, itemSysID string, variables map[string]interface{}) ([]ValidationError, error)

ValidateItemVariablesWithContext validates variables with context support

type CatalogItem

type CatalogItem struct {
	SysID               string                 `json:"sys_id"`
	Name                string                 `json:"name"`
	ShortDescription    string                 `json:"short_description"`
	Description         string                 `json:"description"`
	Active              bool                   `json:"active"`
	CatalogSysID        string                 `json:"sc_catalog"`
	CategorySysID       string                 `json:"category"`
	Price               string                 `json:"price"`
	RecurringPrice      string                 `json:"recurring_price"`
	Icon                string                 `json:"icon"`
	Picture             string                 `json:"picture"`
	Type                string                 `json:"type"`
	Template            string                 `json:"template"`
	Workflow            string                 `json:"workflow"`
	Variables           []CatalogVariable      `json:"variables,omitempty"`
	AvailableFor        string                 `json:"available_for"`
	OrderGuide          bool                   `json:"order_guide"`
	RequestMethod       string                 `json:"request_method"`
	ApprovalDesignation string                 `json:"approval_designation"`
	DeliveryCatalog     string                 `json:"delivery_catalog"`
	ItemDetails         map[string]interface{} `json:"item_details,omitempty"`
}

CatalogItem represents a catalog item

type CatalogTask

type CatalogTask struct {
	SysID            string    `json:"sys_id"`
	Number           string    `json:"number"`
	State            string    `json:"state"`
	RequestItemSysID string    `json:"request_item"`
	ShortDescription string    `json:"short_description"`
	Description      string    `json:"description"`
	AssignedTo       string    `json:"assigned_to"`
	AssignmentGroup  string    `json:"assignment_group"`
	OpenedBy         string    `json:"opened_by"`
	OpenedAt         time.Time `json:"opened_at"`
	DueDate          time.Time `json:"due_date"`
	ClosedAt         time.Time `json:"closed_at"`
	ClosedBy         string    `json:"closed_by"`
	Priority         string    `json:"priority"`
	WorkNotes        string    `json:"work_notes"`
	CloseNotes       string    `json:"close_notes"`
}

CatalogTask represents a ServiceNow catalog task (sc_task)

type CatalogVariable

type CatalogVariable struct {
	SysID          string                 `json:"sys_id"`
	Name           string                 `json:"name"`
	Question       string                 `json:"question"`
	Type           string                 `json:"type"`
	Mandatory      bool                   `json:"mandatory"`
	Active         bool                   `json:"active"`
	DefaultValue   string                 `json:"default_value"`
	HelpText       string                 `json:"help_text"`
	Order          int                    `json:"order"`
	ReadOnly       bool                   `json:"read_only"`
	Visible        bool                   `json:"visible"`
	ChoiceTable    string                 `json:"choice_table"`
	ChoiceField    string                 `json:"choice_field"`
	ReferenceTable string                 `json:"reference"`
	Choices        []VariableChoice       `json:"choices,omitempty"`
	Attributes     map[string]interface{} `json:"attributes,omitempty"`
}

CatalogVariable represents a catalog item variable

type Category

type Category struct {
	SysID        string `json:"sys_id"`
	Title        string `json:"title"`
	Description  string `json:"description"`
	Active       bool   `json:"active"`
	CatalogSysID string `json:"sc_catalog"`
	ParentSysID  string `json:"parent"`
	Icon         string `json:"icon"`
	Order        int    `json:"order"`
}

Category represents a catalog category

type OrderResult

type OrderResult struct {
	Success       bool          `json:"success"`
	RequestNumber string        `json:"request_number"`
	RequestSysID  string        `json:"request_sys_id"`
	RequestItems  []RequestItem `json:"request_items"`
	Message       string        `json:"message,omitempty"`
	Error         string        `json:"error,omitempty"`
}

OrderResult represents the result of submitting an order

type PriceEstimate

type PriceEstimate struct {
	ItemSysID      string                 `json:"item_sys_id"`
	Quantity       int                    `json:"quantity"`
	BasePrice      float64                `json:"base_price"`
	RecurringPrice float64                `json:"recurring_price"`
	TotalPrice     float64                `json:"total_price"`
	TotalRecurring float64                `json:"total_recurring"`
	Currency       string                 `json:"currency"`
	Variables      map[string]interface{} `json:"variables"`
	EstimatedDate  string                 `json:"estimated_date,omitempty"`
}

PriceEstimate represents a price estimation for a catalog item

type Request

type Request struct {
	SysID               string        `json:"sys_id"`
	Number              string        `json:"number"`
	State               string        `json:"state"`
	Stage               string        `json:"stage"`
	RequestedBy         string        `json:"requested_by"`
	RequestedFor        string        `json:"requested_for"`
	OpenedBy            string        `json:"opened_by"`
	OpenedAt            time.Time     `json:"opened_at"`
	Description         string        `json:"description"`
	ShortDescription    string        `json:"short_description"`
	Justification       string        `json:"justification"`
	SpecialInstructions string        `json:"special_instructions"`
	DeliveryAddress     string        `json:"delivery_address"`
	RequestedDate       time.Time     `json:"requested_date"`
	DueDate             time.Time     `json:"due_date"`
	Price               string        `json:"price"`
	Priority            string        `json:"priority"`
	Urgency             string        `json:"urgency"`
	Impact              string        `json:"impact"`
	ApprovalState       string        `json:"approval"`
	RequestItems        []RequestItem `json:"request_items,omitempty"`
}

Request represents a ServiceNow catalog request (sc_request)

type RequestItem

type RequestItem struct {
	SysID               string                 `json:"sys_id"`
	Number              string                 `json:"number"`
	State               string                 `json:"state"`
	Stage               string                 `json:"stage"`
	RequestSysID        string                 `json:"request"`
	CatalogItemSysID    string                 `json:"cat_item"`
	Quantity            int                    `json:"quantity"`
	Price               string                 `json:"price"`
	RecurringPrice      string                 `json:"recurring_price"`
	RequestedBy         string                 `json:"requested_by"`
	RequestedFor        string                 `json:"requested_for"`
	OpenedBy            string                 `json:"opened_by"`
	OpenedAt            time.Time              `json:"opened_at"`
	DueDate             time.Time              `json:"due_date"`
	Variables           map[string]interface{} `json:"variables,omitempty"`
	CatalogItem         *CatalogItem           `json:"catalog_item,omitempty"`
	Tasks               []CatalogTask          `json:"tasks,omitempty"`
	ApprovalState       string                 `json:"approval"`
	FulfillmentGroup    string                 `json:"assignment_group"`
	AssignedTo          string                 `json:"assigned_to"`
	BusinessService     string                 `json:"business_service"`
	ConfigurationItem   string                 `json:"cmdb_ci"`
	DeliveryAddress     string                 `json:"delivery_address"`
	SpecialInstructions string                 `json:"special_instructions"`
}

RequestItem represents a ServiceNow request item (sc_req_item)

type RequestTracker

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

RequestTracker provides methods for tracking catalog requests

func (*RequestTracker) GetMyRequests

func (rt *RequestTracker) GetMyRequests(limit int) ([]Request, error)

GetMyRequests returns requests for the current user

func (*RequestTracker) GetMyRequestsWithContext

func (rt *RequestTracker) GetMyRequestsWithContext(ctx context.Context, limit int) ([]Request, error)

GetMyRequestsWithContext returns user's requests with context support

func (*RequestTracker) GetRequest

func (rt *RequestTracker) GetRequest(identifier string) (*Request, error)

GetRequest returns a catalog request by number or sys_id

func (*RequestTracker) GetRequestItem

func (rt *RequestTracker) GetRequestItem(identifier string) (*RequestItem, error)

GetRequestItem returns a specific request item

func (*RequestTracker) GetRequestItemTasks

func (rt *RequestTracker) GetRequestItemTasks(requestItemIdentifier string) ([]CatalogTask, error)

GetRequestItemTasks returns tasks for a request item

func (*RequestTracker) GetRequestItemTasksWithContext

func (rt *RequestTracker) GetRequestItemTasksWithContext(ctx context.Context, requestItemIdentifier string) ([]CatalogTask, error)

GetRequestItemTasksWithContext returns tasks with context support

func (*RequestTracker) GetRequestItemWithContext

func (rt *RequestTracker) GetRequestItemWithContext(ctx context.Context, identifier string) (*RequestItem, error)

GetRequestItemWithContext returns a request item with context support

func (*RequestTracker) GetRequestItemWithTasks

func (rt *RequestTracker) GetRequestItemWithTasks(identifier string) (*RequestItem, error)

GetRequestItemWithTasks returns a request item with its tasks

func (*RequestTracker) GetRequestItemWithTasksWithContext

func (rt *RequestTracker) GetRequestItemWithTasksWithContext(ctx context.Context, identifier string) (*RequestItem, error)

GetRequestItemWithTasksWithContext returns request item with tasks and context support

func (*RequestTracker) GetRequestItems

func (rt *RequestTracker) GetRequestItems(requestIdentifier string) ([]RequestItem, error)

GetRequestItems returns request items for a request

func (*RequestTracker) GetRequestItemsWithContext

func (rt *RequestTracker) GetRequestItemsWithContext(ctx context.Context, requestIdentifier string) ([]RequestItem, error)

GetRequestItemsWithContext returns request items with context support

func (*RequestTracker) GetRequestWithContext

func (rt *RequestTracker) GetRequestWithContext(ctx context.Context, identifier string) (*Request, error)

GetRequestWithContext returns a catalog request with context support

func (*RequestTracker) GetRequestWithItems

func (rt *RequestTracker) GetRequestWithItems(identifier string) (*Request, error)

GetRequestWithItems returns a request with its request items

func (*RequestTracker) GetRequestWithItemsWithContext

func (rt *RequestTracker) GetRequestWithItemsWithContext(ctx context.Context, identifier string) (*Request, error)

GetRequestWithItemsWithContext returns a request with items and context support

func (*RequestTracker) GetRequestsByState

func (rt *RequestTracker) GetRequestsByState(state string) ([]Request, error)

GetRequestsByState returns requests in a specific state

func (*RequestTracker) GetRequestsByStateWithContext

func (rt *RequestTracker) GetRequestsByStateWithContext(ctx context.Context, state string) ([]Request, error)

GetRequestsByStateWithContext returns requests by state with context support

func (*RequestTracker) TrackRequestProgress

func (rt *RequestTracker) TrackRequestProgress(requestIdentifier string, callback func(*Request, []RequestItem)) error

TrackRequestProgress tracks the progress of a request over time

func (*RequestTracker) TrackRequestProgressWithContext

func (rt *RequestTracker) TrackRequestProgressWithContext(ctx context.Context, requestIdentifier string, callback func(*Request, []RequestItem)) error

TrackRequestProgressWithContext tracks request progress with context support

type ValidationError

type ValidationError struct {
	Variable string `json:"variable"`
	Message  string `json:"message"`
	Type     string `json:"type"`
}

ValidationError represents a variable validation error

type VariableChoice

type VariableChoice struct {
	Value     string `json:"value"`
	Text      string `json:"text"`
	Dependent string `json:"dependent,omitempty"`
	Order     int    `json:"order"`
}

VariableChoice represents a choice for a variable

Jump to

Keyboard shortcuts

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