Documentation
¶
Overview ¶
Package nes is the official-style Go SDK for NES Developer APIs (e-Fatura, e-Arşiv, e-İrsaliye, e-SMM, e-MM and General/Account).
The low-level typed clients under einvoice/, earchive/, edespatch/, esmm/, emm/ and general/ are generated from the public OpenAPI specs. This root package wires them together with shared auth, environments and error handling.
Index ¶
- Constants
- func CheckResponse(resp *http.Response) error
- func EnsureOK(statusCode int, body []byte, method, rawURL string) error
- func ResponseMeta(httpResp *http.Response) (method, rawURL string)
- type APIError
- type Client
- func (c *Client) APIKeyConfigured() bool
- func (c *Client) Environment() Environment
- func (c *Client) RootURL() string
- func (c *Client) UploadEArchive(ctx context.Context, p UploadDocumentParams) (*earchive.PostV1UploadsDocumentResponse, error)
- func (c *Client) UploadEInvoice(ctx context.Context, p UploadDocumentParams) (*einvoice.PostV1UploadsDocumentResponse, error)
- type Environment
- type Option
- func WithAPIKey(key string) Option
- func WithEnvironment(env Environment) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithMaxRetries(n int) Option
- func WithRetryWait(d time.Duration) Option
- func WithRootURL(root string) Option
- func WithTimeout(d time.Duration) Option
- func WithUserAgent(ua string) Option
- type UploadDocumentParams
Constants ¶
const ( PrefixEInvoice = "/einvoice" PrefixEArchive = "/earchive" PrefixEDespatch = "/edespatch" PrefixESMM = "/esmm" PrefixEMM = "/emm" PrefixGeneral = "/general" )
API prefixes used by NES services.
const Version = "1.0.1"
Version is the SDK semantic version reported in the default User-Agent.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse returns nil for 2xx, otherwise an *APIError. On error the response body is consumed.
func ResponseMeta ¶
ResponseMeta extracts method/URL from a generated response's HTTPResponse.
Types ¶
type APIError ¶
APIError is returned when NES responds with a non-2xx status.
func NewAPIError ¶
NewAPIError builds an APIError from an HTTP response and consumes the body. Safe when resp or resp.Request is nil.
func NewAPIErrorFromParts ¶
NewAPIErrorFromParts builds an APIError when the body was already buffered (typical for oapi-codegen *WithResponse helpers).
func (*APIError) Unauthorized ¶
Unauthorized reports HTTP 401.
type Client ¶
type Client struct {
HTTPClient *http.Client
EInvoice *einvoice.ClientWithResponses
EArchive *earchive.ClientWithResponses
EDespatch *edespatch.ClientWithResponses
ESMM *esmm.ClientWithResponses
EMM *emm.ClientWithResponses
General *general.ClientWithResponses
// contains filtered or unexported fields
}
Client is the unified NES SDK entrypoint.
A Client is safe for concurrent use by multiple goroutines after construction.
func (*Client) APIKeyConfigured ¶
APIKeyConfigured reports whether an API key was provided (value is never exposed).
func (*Client) Environment ¶
func (c *Client) Environment() Environment
Environment returns the selected environment. When WithRootURL is used, the custom URL string is returned as Environment.
func (*Client) UploadEArchive ¶
func (c *Client) UploadEArchive(ctx context.Context, p UploadDocumentParams) (*earchive.PostV1UploadsDocumentResponse, error)
UploadEArchive uploads a UBL document to the e-archive API.
func (*Client) UploadEInvoice ¶
func (c *Client) UploadEInvoice(ctx context.Context, p UploadDocumentParams) (*einvoice.PostV1UploadsDocumentResponse, error)
UploadEInvoice uploads a UBL document to the e-invoice API.
type Environment ¶
type Environment string
Environment selects the NES API host.
const ( // EnvTest is the NES test/sandbox host (apitest.nes.com.tr). EnvTest Environment = "test" // EnvProduction is the NES production host (api.nes.com.tr). EnvProduction Environment = "production" )
func (Environment) RootURL ¶
func (e Environment) RootURL() string
RootURL returns the scheme+host for the environment (without API prefix).
type Option ¶
type Option func(*config)
Option configures a Client.
func WithAPIKey ¶
WithAPIKey sets the Bearer API key used for all requests.
func WithEnvironment ¶
func WithEnvironment(env Environment) Option
WithEnvironment sets Test or Production hosts.
func WithHTTPClient ¶
WithHTTPClient injects a custom http.Client (retries, tracing, etc.). When set, WithTimeout only applies if the client timeout is zero.
func WithMaxRetries ¶
WithMaxRetries enables idempotent GET retries on 429/5xx and network errors. Non-GET methods are never retried. Default is 0 (disabled).
func WithRetryWait ¶
WithRetryWait sets the base backoff between retries (exponential: wait * 2^attempt).
func WithRootURL ¶
WithRootURL overrides the host root (e.g. httptest URL or reverse proxy). Example: https://apitest.nes.com.tr
func WithTimeout ¶
WithTimeout sets the default timeout on the SDK-owned http.Client when WithHTTPClient is not provided (or when the injected client has Timeout=0).
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header.
type UploadDocumentParams ¶
type UploadDocumentParams struct {
FilePath string
FileName string
File io.Reader // optional alternative to FilePath
SenderAlias string
ReceiverAlias string
IsDirectSend bool
SourceApp string
// DocumentTemplate is the optional NES document template code.
DocumentTemplate string
// AutoSaveCompany defaults to true when nil.
AutoSaveCompany *bool
// PreviewType e.g. "None" (default).
PreviewType string
}
UploadDocumentParams are common fields for e-invoice / e-archive uploads.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package earchive provides primitives to interact with the openapi HTTP API.
|
Package earchive provides primitives to interact with the openapi HTTP API. |
|
Package edespatch provides primitives to interact with the openapi HTTP API.
|
Package edespatch provides primitives to interact with the openapi HTTP API. |
|
Package einvoice provides primitives to interact with the openapi HTTP API.
|
Package einvoice provides primitives to interact with the openapi HTTP API. |
|
Package emm provides primitives to interact with the openapi HTTP API.
|
Package emm provides primitives to interact with the openapi HTTP API. |
|
Package esmm provides primitives to interact with the openapi HTTP API.
|
Package esmm provides primitives to interact with the openapi HTTP API. |
|
examples
|
|
|
basic
command
|
|
|
Package general provides primitives to interact with the openapi HTTP API.
|
Package general provides primitives to interact with the openapi HTTP API. |