client

package
v1.0.1-0...-50e29ea Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

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

APIClient main client

func NewAPIClient

func NewAPIClient(authConfig *AuthConfig) *APIClient

NewAPIClient creates a new client instance

func (*APIClient) Close

func (c *APIClient) Close() error

func (*APIClient) CreateAttachment

func (c *APIClient) CreateAttachment(ctx context.Context, filePath string) (map[string]interface{}, error)

CreateAttachment creates an attachment for a case

func (*APIClient) CreateCase

func (c *APIClient) CreateCase(ctx context.Context, caseData *Case, headers ...CaseHeaders) (*Case, error)

CreateCase creates a new case with support for custom headers

func (*APIClient) EmailMessage

func (c *APIClient) EmailMessage(ctx context.Context, params EmailMessageParams) (map[string]interface{}, error)

EmailMessage creates a new email message

func (*APIClient) GetCase

func (c *APIClient) GetCase(ctx context.Context, caseID string) (*Case, error)

GetCase gets case by ID

func (*APIClient) GetCaseID

func (c *APIClient) GetCaseID() string

GetCaseID returns the current case ID

func (*APIClient) Query

func (c *APIClient) Query(ctx context.Context, soql string) (*QueryResponse, error)

Query executes a SOQL query

func (*APIClient) Request

func (c *APIClient) Request(ctx context.Context, path, method string, data interface{}, headers map[string]string) (*Response, error)

func (*APIClient) SetCaseID

func (c *APIClient) SetCaseID(caseID string)

func (*APIClient) UploadAttachment

func (c *APIClient) UploadAttachment(ctx context.Context, parentID, filePath string) (map[string]interface{}, error)

UploadAttachment uploads a file as an attachment to Salesforce

type AttachmentResponse

type AttachmentResponse struct {
	ID      string `json:"id"`
	Success bool   `json:"success"`
	Errors  []struct {
		Message   string `json:"message"`
		ErrorCode string `json:"errorCode"`
	} `json:"errors"`
}

AttachmentResponse model for Attachment API response

type AuthConfig

type AuthConfig struct {
	ClientID     string
	ClientSecret string
	RefreshToken string
	Username     string
	Password     string
	LoginURL     string
	GrantType    string
	Debug        bool
	ToEmail      string
	LogFile      string
	LogLevel     string
}

AuthConfig authentication configuration

type AuthError

type AuthError struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

AuthError model for OAuth error response

type AuthResponse

type AuthResponse struct {
	AccessToken string `json:"access_token"`
	InstanceURL string `json:"instance_url"`
	ID          string `json:"id"`
	TokenType   string `json:"token_type"`
	IssuedAt    string `json:"issued_at"`
	Signature   string `json:"signature"`
}

AuthResponse model for OAuth response

type Case

type Case struct {
	ID              string `json:"Id,omitempty"`
	CaseNumber      string `json:"CaseNumber,omitempty"`
	Subject         string `json:"Subject,omitempty"`
	Description     string `json:"Description,omitempty"`
	Status          string `json:"Status,omitempty"`
	Priority        string `json:"Priority,omitempty"`
	Origin          string `json:"Origin,omitempty"`
	RecordTypeId    string `json:"RecordTypeId,omitempty"`
	AccountId       string `json:"AccountId,omitempty"`
	ContactId       string `json:"ContactId,omitempty"`
	SuppliedName    string `json:"SuppliedName,omitempty"`
	SuppliedEmail   string `json:"SuppliedEmail,omitempty"`
	SuppliedCountry string `json:"SuppliedCountry__c,omitempty"`
	SuppliedPhone   string `json:"SuppliedPhone,omitempty"`
	IPAddress       string `json:"IP_Address__c,omitempty"`
	Severity        string `json:"Severity__c,omitempty"`
	Product         string `json:"Product__c,omitempty"`
	OperatingSystem string `json:"Operating_System__c,omitempty"`
	WebQueueEmail   string `json:"Web_Queue_Email__c,omitempty"`
	WebURL          string `json:"Web_URL__c,omitempty"`
	Type            string `json:"type,omitempty"`
}

Case model for Case object with extended fields

type CaseHeaders

type CaseHeaders struct {
	SforceAssignmentRuleHeader string `json:"Sforce-Assignment-Rule-Header,omitempty"`
	SforceEmailHeader          string `json:"Sforce-Email-Header,omitempty"`
}

CaseHeaders headers for creating Case

type EmailMessageParams

type EmailMessageParams struct {
	ParentId    string `json:"ParentId,omitempty"`
	FromAddress string `json:"FromAddress,omitempty"`
	FromName    string `json:"FromName,omitempty"`
	ToAddress   string `json:"ToAddress,omitempty"`
	Subject     string `json:"Subject,omitempty"`
	TextBody    string `json:"TextBody,omitempty"`
	Status      int    `json:"Status,omitempty"`
	Incoming    bool   `json:"Incoming,omitempty"`
}

EmailMessageParams contains parameters for creating an EmailMessage

type ErrorResponse

type ErrorResponse struct {
	Message   string   `json:"message"`
	ErrorCode string   `json:"errorCode"`
	Fields    []string `json:"fields,omitempty"`
}

ErrorResponse model for API errors

type Logger

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

func NewLogger

func NewLogger(debug bool, logFile string) *Logger

NewLogger creates a new logger with file support

func (*Logger) Close

func (l *Logger) Close() error

Close closes the log file if it's open

func (*Logger) Error

func (l *Logger) Error(message string, err error, fields ...interface{})

Error logging errors

func (*Logger) Info

func (l *Logger) Info(message string, fields ...interface{})

Info logging information

func (*Logger) Json

func (l *Logger) Json(data map[string]interface{})

Json logging in JSON format (analog Perl Logger->json)

func (*Logger) Warn

func (l *Logger) Warn(message string, fields ...interface{})

Warn logging of warnings

type QueryResponse

type QueryResponse struct {
	TotalSize int           `json:"totalSize"`
	Done      bool          `json:"done"`
	Records   []interface{} `json:"records"`
}

QueryResponse model for SOQL response

type Response

type Response struct {
	Success bool              `json:"success"`
	Code    int               `json:"code"`
	Status  string            `json:"status"`
	Data    json.RawMessage   `json:"data,omitempty"`
	Raw     string            `json:"raw,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

Jump to

Keyboard shortcuts

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