articles

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package articles provides services for managing Intercom help center articles.

The Service handles public article CRUD and search. The InternalService manages internal-only articles for teammate knowledge bases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDeleteResult

func ParseDeleteResult(r *api.Result) (*api.Deleted, error)

ParseDeleteResult decodes a Result into a Deleted.

func ParseInternalListResult

func ParseInternalListResult(r *api.Result) (*api.PagedResult[InternalArticle], error)

ParseInternalListResult decodes a Result into a PagedResult[InternalArticle].

func ParseListResult

func ParseListResult(r *api.Result) (*api.PagedResult[Article], error)

ParseListResult decodes a Result into a PagedResult[Article].

Types

type Article

type Article struct {
	Type              string                        `json:"type"`
	ID                string                        `json:"id"`
	WorkspaceID       string                        `json:"workspace_id,omitempty"`
	Title             string                        `json:"title,omitempty"`
	Description       string                        `json:"description,omitempty"`
	Body              string                        `json:"body,omitempty"`
	AuthorID          int                           `json:"author_id,omitempty"`
	State             string                        `json:"state,omitempty"`
	CreatedAt         int64                         `json:"created_at,omitempty"`
	UpdatedAt         int64                         `json:"updated_at,omitempty"`
	URL               string                        `json:"url,omitempty"`
	ParentID          *int                          `json:"parent_id,omitempty"`
	ParentIDs         []int                         `json:"parent_ids,omitempty"`
	ParentType        *string                       `json:"parent_type,omitempty"`
	DefaultLocale     string                        `json:"default_locale,omitempty"`
	TranslatedContent *api.ArticleTranslatedContent `json:"translated_content,omitempty"`
	Statistics        *Statistics                   `json:"statistics,omitempty"`
}

Article represents an Intercom help center article.

func ParseCreateResult

func ParseCreateResult(r *api.Result) (*Article, error)

ParseCreateResult decodes a Result into an Article.

func ParseGetResult

func ParseGetResult(r *api.Result) (*Article, error)

ParseGetResult decodes a Result into an Article.

func ParseUpdateResult

func ParseUpdateResult(r *api.Result) (*Article, error)

ParseUpdateResult decodes a Result into an Article.

type CreateInternalRequest

type CreateInternalRequest struct {
	Title    string `json:"title"`
	Body     string `json:"body,omitempty"`
	AuthorID int    `json:"author_id"`
	OwnerID  int    `json:"owner_id"`
}

CreateInternalRequest represents the request body for creating an internal article.

type CreateRequest

type CreateRequest struct {
	Title             string                        `json:"title"`
	AuthorID          int                           `json:"author_id"`
	Description       string                        `json:"description,omitempty"`
	Body              string                        `json:"body,omitempty"`
	State             string                        `json:"state,omitempty"`
	ParentID          *int                          `json:"parent_id,omitempty"`
	ParentType        string                        `json:"parent_type,omitempty"`
	TranslatedContent *api.ArticleTranslatedContent `json:"translated_content,omitempty"`
}

CreateRequest represents the request body for creating an article.

type HighlightedTextPart

type HighlightedTextPart struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

HighlightedTextPart represents a segment of highlighted text.

type InternalArticle

type InternalArticle struct {
	Type      string `json:"type"`
	ID        string `json:"id"`
	Title     string `json:"title,omitempty"`
	Body      string `json:"body,omitempty"`
	OwnerID   int    `json:"owner_id,omitempty"`
	AuthorID  int    `json:"author_id,omitempty"`
	Locale    string `json:"locale,omitempty"`
	CreatedAt int64  `json:"created_at,omitempty"`
	UpdatedAt int64  `json:"updated_at,omitempty"`
}

InternalArticle represents an Intercom internal (team-only) article.

func ParseInternalCreateResult

func ParseInternalCreateResult(r *api.Result) (*InternalArticle, error)

ParseInternalCreateResult decodes a Result into an InternalArticle.

func ParseInternalGetResult

func ParseInternalGetResult(r *api.Result) (*InternalArticle, error)

ParseInternalGetResult decodes a Result into an InternalArticle.

func ParseInternalUpdateResult

func ParseInternalUpdateResult(r *api.Result) (*InternalArticle, error)

ParseInternalUpdateResult decodes a Result into an InternalArticle.

type InternalDeleted

type InternalDeleted struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

InternalDeleted represents the response from deleting an internal article.

func ParseInternalDeleteResult

func ParseInternalDeleteResult(r *api.Result) (*InternalDeleted, error)

ParseInternalDeleteResult decodes a Result into an InternalDeleted.

type InternalSearchData

type InternalSearchData struct {
	InternalArticles []InternalArticle `json:"internal_articles"`
}

InternalSearchData contains the internal articles from a search.

type InternalSearchOptions

type InternalSearchOptions struct {
	FolderID string `url:"folder_id,omitempty"`
}

InternalSearchOptions specifies the query parameters for searching internal articles.

type InternalSearchResponse

type InternalSearchResponse struct {
	Type       string             `json:"type"`
	TotalCount int                `json:"total_count"`
	Data       InternalSearchData `json:"data"`
	Pages      *api.CursorPages   `json:"pages,omitempty"`
}

InternalSearchResponse represents the response from searching internal articles.

func ParseInternalSearchResult

func ParseInternalSearchResult(r *api.Result) (*InternalSearchResponse, error)

ParseInternalSearchResult decodes a Result into an InternalSearchResponse.

type InternalService

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

InternalService handles communication with the internal article related methods of the Intercom API.

func NewInternalService

func NewInternalService(c api.Caller) *InternalService

NewInternalService creates a new internal articles InternalService.

func (*InternalService) CreateRaw

func (s *InternalService) CreateRaw(ctx context.Context, body *CreateInternalRequest) (*api.Result, error)

CreateRaw creates a new internal article with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/createinternalarticle

func (*InternalService) DeleteRaw

func (s *InternalService) DeleteRaw(ctx context.Context, id string) (*api.Result, error)

DeleteRaw deletes an internal article by ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/deleteinternalarticle

func (*InternalService) GetRaw

func (s *InternalService) GetRaw(ctx context.Context, id string) (*api.Result, error)

GetRaw retrieves an internal article by ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/retrieveinternalarticle

func (*InternalService) ListAll

ListAll returns an iterator over all internal articles, handling pagination automatically.

func (*InternalService) ListRaw

func (s *InternalService) ListRaw(ctx context.Context, opts *api.ListOptions) (*api.Result, error)

ListRaw returns a single page of internal articles with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/listinternalarticles

func (*InternalService) Search

Search searches for internal articles using query parameters.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/searchinternalarticles

func (*InternalService) SearchRaw

func (s *InternalService) SearchRaw(ctx context.Context, opts *InternalSearchOptions) (*api.Result, error)

SearchRaw searches for internal articles using query parameters with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/searchinternalarticles

func (*InternalService) UpdateRaw

func (s *InternalService) UpdateRaw(ctx context.Context, id string, body *UpdateInternalRequest) (*api.Result, error)

UpdateRaw updates an existing internal article by ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/internal-articles/updateinternalarticle

type SearchData

type SearchData struct {
	Articles   []Article         `json:"articles"`
	Highlights []SearchHighlight `json:"highlights,omitempty"`
}

SearchData contains the articles and highlights from a search.

type SearchHighlight

type SearchHighlight struct {
	ArticleID        string                `json:"article_id"`
	HighlightedTitle []HighlightedTextPart `json:"highlighted_title,omitempty"`
}

SearchHighlight contains highlighted text for a search result.

type SearchOptions

type SearchOptions struct {
	Phrase       string `url:"phrase,omitempty"`
	State        string `url:"state,omitempty"`
	HelpCenterID int    `url:"help_center_id,omitempty"`
	Highlight    *bool  `url:"highlight,omitempty"`
}

SearchOptions specifies the query parameters for searching articles.

type SearchResponse

type SearchResponse struct {
	Type       string           `json:"type"`
	TotalCount int              `json:"total_count"`
	Data       SearchData       `json:"data"`
	Pages      *api.CursorPages `json:"pages,omitempty"`
}

SearchResponse represents the response from searching articles.

func ParseSearchResult

func ParseSearchResult(r *api.Result) (*SearchResponse, error)

ParseSearchResult decodes a Result into a SearchResponse.

type Service

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

Service handles communication with the article related methods of the Intercom API.

func NewService

func NewService(c api.Caller) *Service

NewService creates a new articles Service.

func (*Service) CreateRaw

func (s *Service) CreateRaw(ctx context.Context, body *CreateRequest) (*api.Result, error)

CreateRaw creates a new article and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/createarticle

func (*Service) DeleteRaw

func (s *Service) DeleteRaw(ctx context.Context, id string) (*api.Result, error)

DeleteRaw deletes an article by ID and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/deletearticle

func (*Service) GetRaw

func (s *Service) GetRaw(ctx context.Context, id string) (*api.Result, error)

GetRaw retrieves an article by ID and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/retrievearticle

func (*Service) ListAll

func (s *Service) ListAll(ctx context.Context, opts *api.ListOptions) *api.Iter[Article]

ListAll returns an iterator over all articles, handling pagination automatically.

func (*Service) ListRaw

func (s *Service) ListRaw(ctx context.Context, opts *api.ListOptions) (*api.Result, error)

ListRaw returns a single page of articles with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/listarticles

func (*Service) Search

func (s *Service) Search(ctx context.Context, opts *SearchOptions) (*SearchResponse, error)

Search searches for articles using query parameters.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/searcharticles

func (*Service) SearchRaw

func (s *Service) SearchRaw(ctx context.Context, opts *SearchOptions) (*api.Result, error)

SearchRaw searches for articles using query parameters and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/searcharticles

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, body *UpdateRequest) (*Article, error)

Update updates an existing article by ID.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/updatearticle

func (*Service) UpdateRaw

func (s *Service) UpdateRaw(ctx context.Context, id string, body *UpdateRequest) (*api.Result, error)

UpdateRaw updates an existing article by ID and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/articles/updatearticle

type Statistics

type Statistics struct {
	Type                      string  `json:"type"`
	Views                     int     `json:"views"`
	Conversations             int     `json:"conversations"`
	Reactions                 int     `json:"reactions"`
	HappyReactionPercentage   float64 `json:"happy_reaction_percentage"`
	NeutralReactionPercentage float64 `json:"neutral_reaction_percentage"`
	SadReactionPercentage     float64 `json:"sad_reaction_percentage"`
}

Statistics represents engagement statistics for an article.

type UpdateInternalRequest

type UpdateInternalRequest struct {
	Title    string `json:"title,omitempty"`
	Body     string `json:"body,omitempty"`
	AuthorID int    `json:"author_id,omitempty"`
	OwnerID  int    `json:"owner_id,omitempty"`
}

UpdateInternalRequest represents the request body for updating an internal article.

type UpdateRequest

type UpdateRequest struct {
	Title             string                        `json:"title,omitempty"`
	Description       string                        `json:"description,omitempty"`
	Body              string                        `json:"body,omitempty"`
	AuthorID          int                           `json:"author_id,omitempty"`
	State             string                        `json:"state,omitempty"`
	ParentID          string                        `json:"parent_id,omitempty"`
	ParentType        string                        `json:"parent_type,omitempty"`
	TranslatedContent *api.ArticleTranslatedContent `json:"translated_content,omitempty"`
}

UpdateRequest represents the request body for updating an article.

Jump to

Keyboard shortcuts

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