Documentation
¶
Overview ¶
Package api used for communication with the KSeF API
Index ¶
- Constants
- func FetchSessionToken(ctx context.Context, c *Client) error
- func Sign(env *gobl.Envelope, upoBytes []byte, c *Client) error
- func WithDemoURL(o *ClientOpts)
- func WithProductionURL(o *ClientOpts)
- type AuthorisationChallengeRequest
- type AuthorisationChallengeResponse
- type Client
- type ClientOptFunc
- type ClientOpts
- type ContextIdentifier
- type ErrorResponse
- type HashSHA
- type InitSessionTokenContext
- type InitSessionTokenDocumentType
- type InitSessionTokenFormCode
- type InitSessionTokenIdentifier
- type InitSessionTokenRequest
- type InitSessionTokenResponse
- type InvoiceHash
- type InvoicePayload
- type InvoiceStatusResponse
- type SendInvoiceRequest
- type SendInvoiceResponse
- type SessionStatusByReferenceResponse
- type SessionStatusResponse
- type SessionToken
- type TerminateSessionResponse
- type UPO
Constants ¶
const ( // XMLNamespace namespace setting for token initialization XML XMLNamespace = "http://ksef.mf.gov.pl/schema/gtw/svc/online/types/2021/10/01/0001" // XMLNamespace2 namespace setting for token initialization XML XMLNamespace2 = "http://ksef.mf.gov.pl/schema/gtw/svc/types/2021/10/01/0001" // XMLNamespace3 namespace setting for token initialization XML XMLNamespace3 = "http://ksef.mf.gov.pl/schema/gtw/svc/online/auth/request/2021/10/01/0001" // XSIType namespace setting for token initialization XML XSIType = "ns2:SubjectIdentifierByCompanyType" // XSINamespace namespace setting for token initialization XML XSINamespace = "http://www.w3.org/2001/XMLSchema-instance" // RootElementName root element name for token initialization XML RootElementName = "ns3:InitSessionTokenRequest" )
Variables ¶
This section is empty.
Functions ¶
func FetchSessionToken ¶
FetchSessionToken requests new session token
func WithProductionURL ¶
func WithProductionURL(o *ClientOpts)
WithProductionURL sets the client url to KSeF production
Types ¶
type AuthorisationChallengeRequest ¶
type AuthorisationChallengeRequest struct {
ContextIdentifier *ContextIdentifier `json:"contextIdentifier"`
}
AuthorisationChallengeRequest defines the structure of the token session initialization
type AuthorisationChallengeResponse ¶
type AuthorisationChallengeResponse struct { Timestamp time.Time `json:"timestamp"` Challenge string `json:"challenge"` }
AuthorisationChallengeResponse defines the authorization challenge response
type ClientOptFunc ¶
type ClientOptFunc func(*ClientOpts)
ClientOptFunc defines function for customizing the KSeF client
func WithClient ¶
func WithClient(client *resty.Client) ClientOptFunc
WithClient allows to customize the http client used for making the requests
func WithDebugClient ¶
func WithDebugClient() ClientOptFunc
WithDebugClient uses a more verbose client
func WithID ¶
func WithID(id string) ClientOptFunc
WithID allows customizing the Polish tax id number (NIP)
func WithKeyPath ¶
func WithKeyPath(keyPath string) ClientOptFunc
WithKeyPath allows customizing the public key for KSeF API authorization
func WithToken ¶
func WithToken(token string) ClientOptFunc
WithToken allows customizing the KSeF authorization token
type ClientOpts ¶
type ClientOpts struct { Client *resty.Client URL string ID string Token string SessionToken string SessionReference string KeyPath string }
ClientOpts defines the client parameters
type ContextIdentifier ¶
ContextIdentifier defines the ContextIdentifier part of the authorization challenge
type ErrorResponse ¶
type ErrorResponse struct { Exception struct { ServiceCtx string `json:"serviceCtx"` ServiceCode string `json:"serviceCode"` ServiceName string `json:"serviceName"` Timestamp string `json:"timestamp"` ReferenceNumber string `json:"referenceNumber"` ExceptionDetailList []struct { ExceptionCode int `json:"exceptionCode"` ExceptionDescription string `json:"exceptionDescription"` } `json:"exceptionDetailList"` } `json:"exception"` }
ErrorResponse parses error responses
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
Error implements the error interface
type HashSHA ¶
type HashSHA struct { Algorithm string `json:"algorithm"` Encoding string `json:"encoding"` Value string `json:"value"` }
HashSHA defines the HashSHA part of the post invoice request
type InitSessionTokenContext ¶
type InitSessionTokenContext struct { Challenge string `xml:"Challenge"` Identifier *InitSessionTokenIdentifier `xml:"Identifier"` DocumentType *InitSessionTokenDocumentType `xml:"DocumentType"` Token string `xml:"Token"` }
InitSessionTokenContext defines the Context part of the token session initialization
type InitSessionTokenDocumentType ¶
type InitSessionTokenDocumentType struct { Service string `xml:"ns2:Service"` FormCode *InitSessionTokenFormCode `xml:"ns2:FormCode"` }
InitSessionTokenDocumentType defines the DocumentType part of the token session initialization
type InitSessionTokenFormCode ¶
type InitSessionTokenFormCode struct { SystemCode string `xml:"ns2:SystemCode"` SchemaVersion string `xml:"ns2:SchemaVersion"` TargetNamespace string `xml:"ns2:TargetNamespace"` Value string `xml:"ns2:Value"` }
InitSessionTokenFormCode defines the FormCode part of the token session initialization
type InitSessionTokenIdentifier ¶
type InitSessionTokenIdentifier struct { Identifier string `xml:"ns2:Identifier"` Type string `xml:"xsi:type,attr"` Namespace string `xml:"xmlns:xsi,attr"` }
InitSessionTokenIdentifier defines the Identifier part of the token session initialization
type InitSessionTokenRequest ¶
type InitSessionTokenRequest struct { Context *InitSessionTokenContext `xml:"ns3:Context"` XMLName xml.Name XMLNamespace string `xml:"xmlns,attr"` XMLNamespace2 string `xml:"xmlns:ns2,attr"` XMLNamespace3 string `xml:"xmlns:ns3,attr"` }
InitSessionTokenRequest defines the structure of the token session initialization
type InitSessionTokenResponse ¶
type InitSessionTokenResponse struct { Timestamp string `json:"timestamp"` ReferenceNumber string `json:"referenceNumber"` SessionToken *SessionToken `json:"sessionToken"` }
InitSessionTokenResponse defines the token session initialization response structure
type InvoiceHash ¶
InvoiceHash defines the InvoiceHash part of the post invoice request
type InvoicePayload ¶
InvoicePayload defines the InvoicePayload part of the post invoice request
type InvoiceStatusResponse ¶
type InvoiceStatusResponse struct { Timestamp string `json:"timestamp"` ReferenceNumber string `json:"referenceNumber"` ProcessingCode int `json:"processingCode"` ProcessingDescription string `json:"processingDescription"` ElementReferenceNumber string `json:"elementReferenceNumber"` InvoiceStatus struct { InvoiceNumber string `json:"invoiceNumber"` KsefReferenceNumber string `json:"ksefReferenceNumber"` AcquisitionTimestamp string `json:"acquisitionTimestamp"` } `json:"invoiceStatus"` }
InvoiceStatusResponse defines the post invoice response structure
func FetchInvoiceStatus ¶
func FetchInvoiceStatus(ctx context.Context, c *Client, referenceNumber string) (*InvoiceStatusResponse, error)
FetchInvoiceStatus gets the status of the invoice being processed
type SendInvoiceRequest ¶
type SendInvoiceRequest struct { InvoiceHash *InvoiceHash `json:"invoiceHash"` InvoicePayload *InvoicePayload `json:"invoicePayload"` }
SendInvoiceRequest defines the post invoice request structure
type SendInvoiceResponse ¶
type SendInvoiceResponse struct { Timestamp string `json:"timestamp"` ReferenceNumber string `json:"referenceNumber"` ProcessingCode int `json:"processingCode"` ProcessingDescription string `json:"processingDescription"` ElementReferenceNumber string `json:"elementReferenceNumber"` }
SendInvoiceResponse defines the post invoice response structure
func SendInvoice ¶
SendInvoice puts the invoice to the KSeF API
type SessionStatusByReferenceResponse ¶
type SessionStatusByReferenceResponse struct { ProcessingCode int `json:"processingCode"` ProcessingDescription string `json:"processingDescription"` ReferenceNumber string `json:"referenceNumber"` Timestamp string `json:"timestamp"` Upo string `json:"upo"` }
SessionStatusByReferenceResponse defines the response of the session status
func GetSessionStatusByReference ¶
func GetSessionStatusByReference(ctx context.Context, c *Client) (*SessionStatusByReferenceResponse, error)
GetSessionStatusByReference gets the session status by reference number
type SessionStatusResponse ¶
type SessionStatusResponse struct { Timestamp string `json:"timestamp"` ReferenceNumber string `json:"referenceNumber"` ProcessingCode int `json:"processingCode"` ProcessingDescription string `json:"processingDescription"` NumberOfElements int `json:"numberOfElements"` PageSize int `json:"pageSize"` PageOffset int `json:"pageOffset"` InvoiceStatusList []struct { AcquisitionTimestamp string `json:"acquisitionTimestamp"` ElementReferenceNumber string `json:"elementReferenceNumber"` InvoiceNumber string `json:"invoiceNumber"` KSefReferenceNumber string `json:"ksefReferenceNumber"` ProcessingCode int `json:"processingCode"` ProcessingDescription string `json:"processingDescription"` } `json:"invoiceStatusList"` }
SessionStatusResponse defines the response of the session status
func GetSessionStatus ¶
func GetSessionStatus(ctx context.Context, c *Client) (*SessionStatusResponse, error)
GetSessionStatus gets the session status of the current session
type SessionToken ¶
type SessionToken struct { Token string `json:"token"` Context struct { ContextIdentifier struct { Type string `json:"type"` Identifier string `json:"identifier"` } `json:"contextIdentifier"` ContextName struct { Type string `json:"type"` TradeName string `json:"tradeName"` FullName string `json:"fullName"` } `json:"contextName"` CredentialsRoleList []struct { Type string `json:"type"` RoleType string `json:"roleType"` RoleDescription string `json:"roleDescription"` } `json:"credentialsRoleList"` } `json:"context"` }
SessionToken defines the session token part of the token session initialization response
type TerminateSessionResponse ¶
type TerminateSessionResponse struct { Timestamp string `json:"timestamp"` ReferenceNumber string `json:"referenceNumber"` ProcessingCode int `json:"processingCode"` ProcessingDescription string `json:"processingDescription"` }
TerminateSessionResponse defines the response of the session termination
func TerminateSession ¶
func TerminateSession(ctx context.Context, s *Client) (*TerminateSessionResponse, error)
TerminateSession ends the current session