elleven

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

README

Unofficial Elleven SDK

Go Reference Go Version Go Report Card License

Go SDK for the Elleven ERP Third-Party API.

Covers all documented modules: Authentication, Suite (People/Customers), CRM, Service Desk, ISP/Telecom, Billing, Finance, and Third-Party Billing.


Installation

go get github.com/raykavin/elleven-go

Requires Go 1.22+. No external dependencies, uses only the Go standard library.


Quick Start

import elleven "github.com/raykavin/elleven-go"

// 1. Create the client
client, err := elleven.NewClient(elleven.Config{
    BaseURL: "http://erp.yourcompany.com",
})
if err != nil {
    log.Fatal(err)
}

// 2. Authenticate (client_credentials flow)
ctx := context.Background()
tokenResp, err := client.AuthenticateClientCredentials(ctx, elleven.ClientCredentialsRequest{
    ClientID:     "your-client-id",
    ClientSecret: "your-client-secret",
    SynData:      "your-syndata-token",
})
if err != nil {
    log.Fatal(err)
}
client.SetTokenResponse(tokenResp)

// 3. Use any resource
customers, err := client.ListCustomers(ctx, elleven.PaginationParams{Page: 1, PageSize: 20})

Configuration

client, err := elleven.NewClient(elleven.Config{
    // Required
    BaseURL: "http://erp.yourcompany.com",

    // Optional defaults shown
    APIPort:      "45715",           // port for all API calls
    AuthPort:     "45700",           // port for authentication
    Timeout:      30 * time.Second,  // per-request timeout
    MaxRetries:   3,                 // retries on 429/502/503/504
    RetryWaitMin: time.Second,       // min wait between retries
    RetryWaitMax: 30 * time.Second,  // max wait between retries (exponential cap)
    AccessToken:  "",                // pre-configure a token directly

    // Optional inject custom *http.Client (for TLS, proxies, etc.)
    HTTPClient: &http.Client{Transport: myTransport},
})

Authentication

The ERP Elleven API uses OAuth2. Three flows are supported:

Credentials come from Settings / Users / Integration User in the ERP interface.

tokenResp, err := client.AuthenticateClientCredentials(ctx, elleven.ClientCredentialsRequest{
    ClientID:     "client-id-from-erp",
    ClientSecret: "client-secret-from-erp",
    SynData:      "syndata-token",
})
client.SetTokenResponse(tokenResp)
Legacy password grant

Uses fixed platform credentials (synauth). Requires the integration user's username and password.

tokenResp, err := client.AuthenticateLegacy(ctx, elleven.LegacyAuthRequest{
    Username: "integration-user",
    Password: "password",
    SynData:  "syndata-token",
})
client.SetTokenResponse(tokenResp)
Refresh Token
newToken, err := client.RefreshToken(ctx, elleven.RefreshTokenRequest{
    RefreshToken: client.GetRefreshToken(),
})
client.SetTokenResponse(newToken)
Token lifecycle
// Check expiry before making calls
if time.Until(client.TokenExpiresAt()) < 5*time.Minute {
    // refresh proactively
}

Modules

Suite People / Customers
// Register a new person
resp, err := client.RegisterPerson(ctx, elleven.RegisterPersonRequest{
    TypeTxID: "CPF", TxID: "12345678900",
    Name: "João Silva", Email: "joao@example.com",
    Client: true, Situation: 1,
    PostalCode: "97010001", Street: "das Flores",
    Number: "123", City: "Santa Maria", State: "RS",
})

// Update contact info
resp, err := client.UpdatePerson(ctx, personID, elleven.UpdatePersonRequest{
    ID: personID,
    Email: elleven.UpdatePersonEmailRequest{Email: "new@email.com"},
    Phone: elleven.UpdatePersonPhoneRequest{CellPhone: "55999990000", CellPhoneHasWhatsapp: true},
})

// Update address
resp, err := client.UpdateCustomerAddress(ctx, clientID, elleven.UpdateAddressRequest{
    ZipCode: "97010001", PublicPlace: "Rua das Flores",
    Number: "456", City: "Santa Maria", State: "RS",
})

// List customers (paginated)
page, err := client.ListCustomers(ctx, elleven.PaginationParams{Page: 1, PageSize: 50})
fmt.Println(page.Response.TotalRecords, "total customers")

// List company locations
locs, err := client.ListLocations(ctx, elleven.PaginationParams{
    Page: 1, PageSize: 10, Filter: "matriz",
})

// Search by CPF/CNPJ
person, err := client.GetPersonByTxID(ctx, "12345678900")

// List documentation types
dtypes, err := client.ListDocumentationTypes(ctx, "", "title")

// Electronic signatures
sigs, err := client.GetElectronicSignatureByContract(ctx, contractID)
err = client.ResendElectronicSignature(ctx, elleven.ResendSignatureRequest{
    SignatureID: sigs[0].SignatureID, DispatchType: 1,
})

// Holiday check
h, err := client.IsHoliday(ctx, elleven.HolidayCheckRequest{
    Date: "2024-12-25", UF: "RS", City: "Santa Maria",
})

CRM
// Create a lead
resp, err := client.CreateLead(ctx, elleven.CreateLeadRequest{
    PersonalData: elleven.LeadPersonalData{Name: "Maria", TxID: "98765432100"},
    Contact:      elleven.LeadContact{CellPhone: "55999990000", Email: "maria@example.com"},
    Address:      elleven.LeadAddress{PostalCode: "97010001", City: "Santa Maria"},
})

// Check service coverage viability
v, err := client.VerifyViability(ctx, elleven.VerifyViabilityRequest{
    FullAddress: elleven.ViabilityAddress{
        Address: "Rua das Flores", Number: "123",
        City: "Santa Maria", State: "RS", PostalCode: "97010001",
    },
    Distance: "200",
    Lead: elleven.ViabilityPerson{Name: "João", TxID: "12345678900"},
})
fmt.Println("Has coverage:", v.Response.Viability)

// Get available contract types
ctypes, err := client.GetContractTypesAndServices(ctx)

// Get campaigns and price lists
campaigns, err := client.GetCampaignsAndPriceListServices(ctx)

// Start a new negotiation/sale
sale, err := client.StartSale(ctx, elleven.StartSaleRequest{
    TxID:             "12345678900",
    CompanyPlaceTxID: "00.000.000/0001-00",
    ContractType:     "PF - Composto",
    ServiceProducts: []elleven.SaleServiceProduct{
        {Code: "FIBER_100", Quantity: 1, Amount: 99.90},
    },
})
fmt.Println("Protocol:", sale.Response.ProtocolID)

// Cancel a negotiation
_, err = client.CancelSale(ctx, elleven.CancelSaleRequest{
    ProtocolID: sale.Response.ProtocolID, Description: "Customer gave up",
})

// Add service to contract
_, err = client.AddContractServices(ctx, elleven.AddContractServicesRequest{
    ContractNumber: "12345",
    NewServices: []elleven.NewContractService{
        {Code: "SVC_TV", Quantity: 1, Price: 29.90},
    },
})

// Remove service from contract
_, err = client.RemoveContractServices(ctx, elleven.RemoveContractServicesRequest{
    ContractNumber: "12345",
    RemoveService:  []elleven.RemoveContractItem{{ContractItem: 101}},
})

Service Desk
// Open a simple solicitation
resp, err := client.OpenSimpleSolicitation(ctx, elleven.OpenSimpleSolicitationRequest{
    Description: "No internet signal", ClientID: 123, ContractID: 456,
    ContractServiceTagID: 1,
})

// Open a detailed external solicitation
resp, err := client.OpenDetailedSolicitation(ctx, elleven.OpenDetailedSolicitationRequest{
    ClientID: 123, IncidentTypeID: 5,
    MatrixType: elleven.MatrixTypeExternal,
    Assignment: elleven.SolicitationAssignment{
        Title: "Network down", Priority: 1,
    },
})

// Maintain (update) a solicitation
_, err = client.MaintainSolicitation(ctx, elleven.MaintainSolicitationRequest{
    Protocol: "PROT-001", Report: "Technician dispatched",
})

// Add a note
_, err = client.AddNoteToSolicitation(ctx, elleven.AddNoteToSolicitationRequest{
    AssignmentID: 789, Title: "Update", Description: "Signal restored",
})

// Create progress report
_, err = client.CreateSolicitationReport(ctx, elleven.CreateSolicitationReportRequest{
    AssignmentID: 789, Protocol: 123, Progress: 75, Description: "Working on it",
})

// Upload attachment
_, err = client.UploadAttachmentToSolicitation(ctx, 123, "1.01", "photo.jpg", imageBytes)

// Download attachment
data, contentType, err := client.DownloadAttachmentFromSolicitation(ctx, attachmentID, assignmentID)

// Event-based operations (access point / client)
_, err = client.OpenSolicitationForAccessPoint(ctx, "integration-code-abc")
_, err = client.CloseSolicitationForAccessPoint(ctx, "integration-code-abc")
_, err = client.OpenSolicitationForClient(ctx, clientID)
_, err = client.CloseSolicitationForClient(ctx, clientID)

ISP / Telecom
// Update connection technical data
_, err := client.UpdateConnection(ctx, connectionID, elleven.UpdateConnectionRequest{
    Mac: "AA:BB:CC:DD:EE:FF", TechnologyType: 1,
    OltID: 5, SlotOlt: 1, PortOlt: 10,
})

// Access point status
status, err := client.GetAccessPointStatusByContract(ctx, contractID)
fmt.Println("Active:", status.Response.Active)

statuses, err := client.GetAccessPointStatusByClient(ctx, clientID)
for _, s := range statuses.Response {
    fmt.Printf("%s: active=%v\n", s.Title, s.Active)
}

// Register user traffic data
_, err = client.RegisterUserTraffic(ctx, elleven.RegisterUserTrafficRequest{
    User:          "user@provider",
    Date:          time.Now().UTC().Format(time.RFC3339),
    Download:      524288000,
    Upload:        104857600,
    TotalDownload: 10737418240,
    TotalUpload:   2147483648,
})

Billing (Faturamento)
// Create contract via billing module
contract, err := client.CreateContract(ctx, elleven.CreateContractRequest{
    ClientInformation:   elleven.ContractClientInfo{TxID: "12345678900"},
    ContractInformation: elleven.ContractInfo{
        ContractType: "PF", CompanyPlaceTxID: "00.000.000/0001-00",
        CollectionDay: 10, PaymentFormCode: "BOLETO",
    },
    ServicesInformation: []elleven.ContractServiceInfo{
        {Code: "FIBER_100", Quantity: 1, Price: 99.90},
    },
})
fmt.Println("Contract:", contract.Response.ContractNumber)

// Approve contract
approval, err := client.ApproveContract(ctx, contractID, elleven.ApproveContractRequest{
    ProportionalityType:           0,
    ChangeBeginningDateOnApproval: true,
    ApprovalDate:                  time.Now().Format(time.RFC3339),
})

// Generate sale order
_, err = client.GenerateSaleOrder(ctx, elleven.GenerateSaleOrderRequest{
    ClientTxID: "12345678900", ContractNumber: "12345",
    Items: []elleven.SaleOrderItem{{ID: "product-uuid", Quantity: 1, UnitValue: 99.90}},
})

// Create eventual (one-time) billing value
_, err = client.CreateEventualValue(ctx, elleven.CreateEventualValueRequest{
    Type: elleven.EventualValueTypeDebit, ContractID: 12345,
    Description: "Late fee", UnitAmount: 15.00, Units: 1,
    MonthYear: "2024-12-01",
})

// Document management
docs, err := client.ListDocumentsByContract(ctx, "12345", documentationTypeID)
_, err = client.UploadAttachmentToContract(ctx, "12345", "1.01", "contract.pdf", pdfBytes)
data, ct, err := client.DownloadContractAttachment(ctx, attachmentID, contractID)

// Unlock a suspended contract
_, err = client.UnlockContract(ctx, "12345")

// Download DANFE (NF-e PDF)
pdfBytes, _, err := client.DownloadDANFE(ctx, documentID)

Finance (Financeiro)
// Get open invoices by CPF/CNPJ
invoices, err := client.GetOpenInvoicesByTxID(ctx, "12345678900")

// Get all invoices (any status) by CPF/CNPJ
all, err := client.GetAllInvoicesByTxID(ctx, "12345678900")

// Get open invoices by contract
billets, err := client.GetOpenInvoicesByContract(ctx, contractID)

// Download invoice PDF (boleto)
pdfBytes, _, err := client.GetInvoicePDF(ctx, invoiceID)

// Register a payment (settle an invoice)
payment, err := client.RegisterPayment(ctx, elleven.RegisterPaymentRequest{
    TransactionID:              "unique-uuid-v4",
    FinancialReceivableTitleID: invoiceID,
    PaidAmount:                 99.90,
    PaymentFormCode:            "PIX",
    ReceiptDate:                "2024-05-01",
    ClientPaidDate:             "2024-05-01",
})
fmt.Println("SynGW Transaction:", payment.Response.SynGwTransactionID)

// Consult payment processing status
status, err := client.ConsultPaymentStatus(ctx, synGWTransactionID)
fmt.Println("Status:", status.Response.Status.Label)

// Generate PIX QR Code for an invoice
pix, err := client.GeneratePix(ctx, invoiceID)
fmt.Println("PIX QR Code:", pix.Response.QRCode)
fmt.Printf("Total: R$ %.2f\n", pix.Response.TotalAmount)

// Renegotiation
info, err := client.GetRenegotiationInfo(ctx, elleven.RenegotiationInfoRequest{
    ReceivableIDs: []int{1, 2, 3}, Date: "2024-12-31",
})

result, err := client.RegisterRenegotiation(ctx, elleven.RegisterRenegotiationRequest{
    ReceivableIDs: []int{1, 2, 3},
    Parcels: []elleven.RenegotiationParcel{
        {Number: 1, ExpirationDate: "2024-12-01"},
        {Number: 2, ExpirationDate: "2025-01-01"},
    },
})

Third-Party Billing (Co-faturamento)
_, err := client.ConfirmInvoiceIssuance(ctx, elleven.ConfirmInvoiceIssuanceRequest{
    ID:        "internal-record-id",
    AccessKey: "NFe-access-key-44-chars",
    IssueDate: "2024-05-15",
})

Error Handling

All methods return a *APIError on HTTP-level failures.

_, err := client.GetPersonByTxID(ctx, "12345678900")
if err != nil {
    switch {
    case elleven.IsNotFound(err):
        // HTTP 404
    case elleven.IsUnauthorized(err):
        // HTTP 401 re-authenticate
    case elleven.IsForbidden(err):
        // HTTP 403 insufficient permissions
    case elleven.IsRateLimited(err):
        // HTTP 429 back off and retry
    case elleven.IsServerError(err):
        // HTTP 5xx transient server error
    default:
        if apiErr, ok := err.(*elleven.APIError); ok {
            fmt.Printf("Status: %d\n", apiErr.StatusCode)
            fmt.Printf("Messages: %v\n", apiErr.Messages)
            fmt.Printf("Raw body: %s\n", apiErr.RawBody)
        }
    }
}

Pagination

Paginated endpoints accept PaginationParams:

for page := 1; ; page++ {
    result, err := client.ListCustomers(ctx, elleven.PaginationParams{
        Page: page, PageSize: 100,
    })
    if err != nil {
        break
    }
    // process result.Response.Data ...
    if page >= result.Response.TotalPages {
        break
    }
}

Retry

The client automatically retries on HTTP 429, 502, 503, 504 with exponential backoff. Configure via Config.MaxRetries, RetryWaitMin, RetryWaitMax.

client, _ := elleven.NewClient(elleven.Config{
    BaseURL:      "...",
    MaxRetries:   5,
    RetryWaitMin: 500 * time.Millisecond,
    RetryWaitMax: 60 * time.Second,
})

Set MaxRetries: -1 disables retries (only the initial attempt is made). The default is MaxRetries: 3.


File Upload / Download

// Upload
fileBytes, _ := os.ReadFile("document.pdf")
_, err := client.UploadAttachmentToContract(ctx, "12345", "1.01", "document.pdf", fileBytes)

// Download
data, contentType, err := client.DownloadContractAttachment(ctx, attachmentID, contractID)
if err == nil {
    os.WriteFile("output.pdf", data, 0644)
    fmt.Println("Content-Type:", contentType)
}

Integration User Setup

  1. In the ERP, go to Settings / Users.
  2. Create a dedicated user and check the "Usuário integrador" option.
  3. Each integration system should use its own integration user for auditing.
  4. Obtain the syndata token from Suite / Settings / Parameters / Integration/Map.
  5. For client_credentials, retrieve Client Id and Client Secret from the user record.

Note: Integration users cannot log in to the ERP interface - they are API-only.


Running Tests

cd elleven-go
go test ./... -v

For integration tests against a real server:

ELLEVEN_URL=http://erp.example.com \
ELLEVEN_CLIENT_ID=... \
ELLEVEN_CLIENT_SECRET=... \
ELLEVEN_SYNDATA=... \
go test ./... -v -tags=integration

Known Ambiguities / Assumptions

# Issue Decision
1 ResendElectronicSignature is documented as GET with a JSON body Implemented as POST - GET with body is non-standard and blocked by many HTTP clients
2 GetRenegotiationInfo is documented as GET with a JSON body Implemented as GET with body to match documentation - some servers support this
3 CreateContract response uses "Success" (capital S) Mapped faithfully with json:"Success"
4 AddContractServices response uses "Sucess" (typo) Mapped faithfully with json:"Sucess" to match API
5 Customer.id field comes as string or number from the API Typed as any to handle both
6 StartSale nested objects (clientSaleInfo, activationInformation, etc.) are not fully documented Typed as any for flexibility
7 The API uses different URL variable cases ({{URL}} vs {{url}}) Treated as the same variable
8 Base URL is tenant-specific (no fixed hostname) Config.BaseURL must be provided by the caller

Endpoints Coverage

Authentication (3/3)
  • POST /connect/token - Legacy (password grant)
  • POST /connect/token - Client credentials
  • POST /connect/token - Refresh token
Suite (10/10)
  • POST /external/integrations/thirdparty/people - Register person
  • PUT /external/integrations/thirdparty/people/{id} - Update person
  • PUT /external/integrations/thirdparty/updateaddress/{id} - Update address
  • GET /external/integrations/thirdparty/getclient - List customers
  • GET /external/integrations/thirdparty/companiesplacespaged - List locations
  • GET /external/integrations/thirdparty/people/txid/{txId} - Search by CPF/CNPJ
  • GET /external/integrations/thirdparty/getdocumentationtypes - List doc types
  • GET /external/integrations/thirdparty/suite/electronicsignatures/... - Get e-signatures
  • GET→POST /external/integrations/thirdparty/suite/electronicsignatures/resend - Resend
  • POST /external/integrations/thirdparty/isholiday - Holiday check
CRM (9/9)
  • POST /external/crm/leads/create - Create lead
  • POST /external/integrations/thirdparty/crm/startsale - Start sale
  • POST /external/integrations/thirdparty/contract/addcontractservices
  • POST /external/integrations/thirdparty/contract/changecontractservices
  • POST /external/integrations/thirdparty/contract/removecontractitems
  • POST /external/integrations/thirdparty/verifyviability
  • POST /external/integrations/thirdparty/crm/cancelsale
  • GET /external/integrations/thirdparty/crm/contracttypesandservices
  • GET /external/integrations/thirdparty/crm/campaignsandpricelistservices
Service Desk (13/13)
  • POST .../opendetailedsolicitation - External (matrixType=1)
  • POST .../opendetailedsolicitation - Internal (matrixType=2)
  • POST .../opensolicitation
  • POST .../opensolicitationcrm
  • POST .../opensolicitationpopeventerror/{code}
  • POST .../solicitationmaintenance
  • POST .../closesolicitationpopeventerror/{code}
  • POST .../opensolicitationclienteventerror/{id}
  • POST .../closesolicitationclienteventerror/{id}
  • POST .../solicitationnewnote
  • POST .../projects/createsolicitationreport
  • POST .../projects/assignmentsuploads - Upload attachment
  • GET .../projects/assignmentsuploads/getfile - Download attachment
ISP / Telecom (4/4)
  • PUT /external/integrations/thirdparty/updateconnection/{id}
  • GET .../getaccesspointstatusbycontract/{id}
  • GET .../getaccesspointstatusbyclient/{id}
  • POST .../isp/authentication_contracts/traffic
Billing (9/9)
  • POST /external/billing/contracts/create
  • POST .../salerequest
  • POST .../contract/contracteventualvalues
  • GET .../getfilesbycontract/{n}/documentationtype/{id}
  • POST .../contract/contractuploads - Upload
  • POST .../contracts/unlock/{n}
  • GET .../contract/contractuploads/getfile - Download
  • PUT .../contracts/approve/{id}
  • GET .../billings/invoices/download/{id} - Download DANFE
Finance (9/9)
  • GET .../getopentitlesbytxid/{txId}
  • GET .../gettitlesbytxid/{txId}
  • GET .../getcontractbillets/{id}
  • GET .../GetBillet/{id} - PDF download
  • GET .../consultpayment
  • POST .../receivepayment
  • POST .../billings/registerpix
  • GET .../financial/getrenegotiationsinformations
  • POST .../financial/registerrenegotiations
Third-Party Billing (1/1)
  • POST .../thirdparty_billing/invoice_note/confirm

Total: 58 endpoints covered


Contributing

Contributions to elleven-go are welcome! Here are some ways you can help improve the project:

  • Report bugs and suggest features by opening issues on GitHub
  • Submit pull requests with bug fixes or new features
  • Improve documentation to help other users and developers
  • Share your custom strategies with the community

License

elleven-go is distributed under the MIT License.
For complete license terms and conditions, see the LICENSE file in the repository.


Contact

For support, collaboration, or questions about elleven-go:

Email: raykavin.meireles@gmail.com
GitHub: @raykavin

Documentation

Overview

Package elleven provides a Go SDK for the ERP Elleven Third-Party API.

The SDK covers all documented modules: authentication, Suite (people/customers), CRM, Service Desk, ISP/Telecom, Billing, Finance and Third-Party Billing.

Basic usage:

client, err := NewClient(Config{
    BaseURL: "https://erp.example.com",
})
if err != nil {
    log.Fatal(err)
}

// Authenticate
tokenResp, err := client.AuthenticateClientCredentials(ctx, ClientCredentialsRequest{
    ClientID:     "your-client-id",
    ClientSecret: "your-client-secret",
    SynData:      "your-syndata-token",
})
if err != nil {
    log.Fatal(err)
}
client.SetTokenResponse(tokenResp)

Index

Constants

View Source
const (
	DefaultLegacyClientID     = "synauth"
	DefaultLegacyClientSecret = "df956154024a425eb80f1a2fc12fef0c"
	DefaultLegacyGrantType    = "password"
	DefaultLegacyScope        = "syngw synpaygw offline_access"

	DefaultClientCredentialsGrantType = "client_credentials"
	DefaultClientCredentialsScope     = "syngw"

	DefaultRefreshTokenGrantType = "refresh_token"
)

Default OAuth2 platform constants used by the ERP Elleven legacy flows.

Variables

This section is empty.

Functions

func IsForbidden

func IsForbidden(err error) bool

IsForbidden returns true if the error is an HTTP 403 Forbidden.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is an HTTP 404 Not Found.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited returns true if the error is an HTTP 429 Too Many Requests.

func IsServerError

func IsServerError(err error) bool

IsServerError returns true if the error is an HTTP 5xx server error.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns true if the error is an HTTP 401 Unauthorized.

Types

type APIError

type APIError struct {
	// StatusCode is the HTTP status code returned by the server.
	StatusCode int
	// Messages are the API-level messages parsed from the response body.
	Messages []APIMessage
	// RawBody is the raw response body for debugging.
	RawBody []byte
}

APIError represents an error returned by the ERP Elleven API. It carries the HTTP status code, parsed API messages, and the raw response body.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

type APIMessage

type APIMessage struct {
	Message string `json:"message"`
	Code    *int   `json:"code"`
	Type    string `json:"type"` // "Success", "Error", "Warning"
}

APIMessage holds a message returned inside an API response.

type APIResponse

type APIResponse[T any] struct {
	Success          bool         `json:"success"`
	Messages         []APIMessage `json:"messages"`
	Response         T            `json:"response"`
	DataResponseType *string      `json:"dataResponseType"`
	ElapsedTime      *float64     `json:"elapsedTime"`
}

APIResponse is the standard response envelope returned by all ERP Elleven API endpoints. T is the type of the response payload.

type AccessPointStatus

type AccessPointStatus struct {
	Title         string `json:"title"`
	InMaintenance bool   `json:"inMaintenance"`
	Maintenance   any    `json:"maintenance"` // null or maintenance details
	Active        bool   `json:"active"`
}

AccessPointStatus represents the current status of an access point (e.g., OLT, POP).

type AddContractServicesRequest

type AddContractServicesRequest struct {
	ContractNumber          string               `json:"contractNumber"`
	CRMCampaignCode         string               `json:"crmCampaignCode"`
	CRMPriceListCode        string               `json:"crmPriceListCode"`
	GenerateProportionality bool                 `json:"generateProportionality"`
	NewServices             []NewContractService `json:"newServices"`
}

AddContractServicesRequest is the request body for adding services to a contract.

type AddNoteToSolicitationRequest

type AddNoteToSolicitationRequest struct {
	AssignmentID int    `json:"assignmentId"`
	PersonID     int    `json:"personId"`
	Title        string `json:"title"`
	Description  string `json:"description"`
}

AddNoteToSolicitationRequest is the request body for adding a note to a solicitation.

type ApproveContractData

type ApproveContractData struct {
	PersonUsers       []any                 `json:"personUsers"`
	Proportionalities []ProportionalityItem `json:"proportionalities"`
}

ApproveContractData is the response data for contract approval.

type ApproveContractRequest

type ApproveContractRequest struct {
	ProportionalityType           int    `json:"proportionalityType"`
	ChangeBeginningDateOnApproval bool   `json:"changeBeginningDateOnApproval"`
	ChangeLoyaltyDateOnApproval   bool   `json:"changeLoyaltyDateOnApproval"`
	ApprovalDate                  string `json:"approvalDate"` // RFC3339
}

ApproveContractRequest is the request body for approving a contract.

type ApproveContractResponse

type ApproveContractResponse struct {
	Success     bool                `json:"success"`
	Data        ApproveContractData `json:"data"`
	ElapsedTime float64             `json:"elapsedTime"`
}

ApproveContractResponse wraps the contract approval response.

type AssignmentReport

type AssignmentReport struct {
	BeginningDate string `json:"beginningDate"` // RFC3339
	FinalDate     string `json:"finalDate"`     // RFC3339
	Description   string `json:"description"`
}

AssignmentReport holds a report entry within a solicitation assignment.

type Campaign

type Campaign struct {
	Code        string              `json:"code"`
	Title       string              `json:"title"`
	Description string              `json:"description"`
	Regions     []CampaignRegion    `json:"regions"`
	PriceLists  []CampaignPriceList `json:"priceLists"`
}

Campaign represents a CRM campaign with price lists and regions.

type CampaignCity

type CampaignCity struct {
	Code string `json:"code"`
	Name string `json:"name"`
}

CampaignCity represents a city where a campaign is available.

type CampaignPriceList

type CampaignPriceList struct {
	Code        string                     `json:"code"`
	Title       string                     `json:"title"`
	Description *string                    `json:"description"`
	Products    []CampaignPriceListProduct `json:"products"`
}

CampaignPriceList represents a price list within a campaign.

type CampaignPriceListProduct

type CampaignPriceListProduct struct {
	Code        string  `json:"code"`
	Title       string  `json:"title"`
	Description *string `json:"description"`
	Price       float64 `json:"price"`
}

CampaignPriceListProduct represents a product inside a campaign price list.

type CampaignRegion

type CampaignRegion struct {
	Code   string         `json:"code"`
	Name   string         `json:"name"`
	Cities []CampaignCity `json:"cities"`
}

CampaignRegion represents a region covered by a campaign.

type CancelSaleRequest

type CancelSaleRequest struct {
	ProtocolID  int    `json:"protocolId"`
	Description string `json:"description"`
}

CancelSaleRequest is the request body for cancelling a negotiation.

type ChangeContractServicesRequest

type ChangeContractServicesRequest struct {
	ContractNumber          string                        `json:"contractNumber"`
	CRMCampaignCode         string                        `json:"crmCampaignCode"`
	CRMPriceListCode        string                        `json:"crmPriceListCode"`
	GenerateProportionality bool                          `json:"generateProportionality"`
	ChangedServices         []ContractServiceModification `json:"changedServices"`
}

ChangeContractServicesRequest is the request body for modifying contract services.

type Client

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

Client is the main ERP Elleven SDK client. It is safe for concurrent use by multiple goroutines.

Create a new Client with NewClient, then authenticate using one of the Authenticate* methods before making API calls.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates and returns a new ERP Elleven SDK client. Returns an error if the configuration is invalid.

Either BaseURL or both APIURL and AuthURL must be provided.

func (*Client) AddContractServices

AddContractServices adds one or more service products to an existing contract.

POST /external/integrations/thirdparty/contract/addcontractservices

func (*Client) AddNoteToSolicitation

func (c *Client) AddNoteToSolicitation(ctx context.Context, req AddNoteToSolicitationRequest) (*APIResponse[any], error)

AddNoteToSolicitation adds a note/comment to an existing solicitation.

POST /external/integrations/thirdparty/solicitationnewnote

func (*Client) ApproveContract

func (c *Client) ApproveContract(ctx context.Context, contractID int, req ApproveContractRequest) (*ApproveContractResponse, error)

ApproveContract approves a pending contract, optionally generating proportionalities.

PUT /external/integrations/thirdparty/contracts/approve/{contractID}

func (*Client) AuthenticateClientCredentials

func (c *Client) AuthenticateClientCredentials(ctx context.Context, req ClientCredentialsRequest) (*TokenResponse, error)

AuthenticateClientCredentials authenticates using the modern client_credentials OAuth2 flow.

The returned TokenResponse can be passed directly to client.SetTokenResponse.

func (*Client) AuthenticateLegacy

func (c *Client) AuthenticateLegacy(ctx context.Context, req LegacyAuthRequest) (*TokenResponse, error)

AuthenticateLegacy authenticates using the legacy password grant OAuth2 flow.

The returned TokenResponse can be passed directly to client.SetTokenResponse.

func (*Client) CancelSale

func (c *Client) CancelSale(ctx context.Context, req CancelSaleRequest) (*APIResponse[string], error)

CancelSale cancels an existing CRM negotiation by protocol ID.

POST /external/integrations/thirdparty/crm/cancelsale

func (*Client) ChangeContractServices

ChangeContractServices modifies existing service products on a contract.

POST /external/integrations/thirdparty/contract/changecontractservices

func (*Client) CloseSolicitationForAccessPoint

func (c *Client) CloseSolicitationForAccessPoint(ctx context.Context, integrationCode string) (*APIResponse[any], error)

CloseSolicitationForAccessPoint closes a solicitation for a specific access point.

POST /external/integrations/thirdparty/closesolicitationpopeventerror/{integrationCode}

func (*Client) CloseSolicitationForClient

func (c *Client) CloseSolicitationForClient(ctx context.Context, clientID int) (*APIResponse[any], error)

CloseSolicitationForClient closes a solicitation triggered by a client error event.

POST /external/integrations/thirdparty/closesolicitationclienteventerror/{clientID}

func (*Client) ConfirmInvoiceIssuance

func (c *Client) ConfirmInvoiceIssuance(ctx context.Context, req ConfirmInvoiceIssuanceRequest) (*APIResponse[any], error)

ConfirmInvoiceIssuance notifies the ERP that a third-party invoice was issued, providing the access key and issue date.

POST /external/integrations/thirdparty/thirdparty_billing/invoice_note/confirm

func (*Client) ConsultPaymentStatus

func (c *Client) ConsultPaymentStatus(ctx context.Context, synGWTransactionID string) (*APIResponse[PaymentStatusResult], error)

ConsultPaymentStatus checks the processing status of a payment by its SynGW transaction ID.

GET /external/integrations/thirdparty/consultpayment?syngwtransactionid={uuid}

func (*Client) CreateContract

func (c *Client) CreateContract(ctx context.Context, req CreateContractRequest) (*CreateContractResponse, error)

CreateContract creates a new contract directly via the billing module.

POST /external/billing/contracts/create

func (*Client) CreateEventualValue

func (c *Client) CreateEventualValue(ctx context.Context, req CreateEventualValueRequest) (*APIResponse[any], error)

CreateEventualValue adds a one-time credit or debit value to a contract billing period.

POST /external/integrations/thirdparty/contract/contracteventualvalues

func (*Client) CreateLead

func (c *Client) CreateLead(ctx context.Context, req CreateLeadRequest) (*APIResponse[any], error)

CreateLead creates a new CRM lead.

POST /external/crm/leads/create

func (*Client) CreateSolicitationReport

func (c *Client) CreateSolicitationReport(ctx context.Context, req CreateSolicitationReportRequest) (*APIResponse[any], error)

CreateSolicitationReport creates a progress report on a solicitation and optionally updates its status.

POST /external/integrations/thirdparty/projects/createsolicitationreport

func (*Client) DownloadAttachmentFromSolicitation

func (c *Client) DownloadAttachmentFromSolicitation(ctx context.Context, attachmentID, assignmentID int) ([]byte, string, error)

DownloadAttachmentFromSolicitation downloads a file attachment from a solicitation.

Returns the raw file bytes and the Content-Type header value.

GET /external/integrations/thirdparty/projects/assignmentsuploads/getfile

func (*Client) DownloadContractAttachment

func (c *Client) DownloadContractAttachment(ctx context.Context, attachmentID, contractID int) ([]byte, string, error)

DownloadContractAttachment downloads a file attached to a contract.

Returns raw file bytes and Content-Type header value.

GET /external/integrations/thirdparty/contract/contractuploads/getfile

func (*Client) DownloadDANFE

func (c *Client) DownloadDANFE(ctx context.Context, documentID int) ([]byte, string, error)

DownloadDANFE downloads a DANFE (Nota Fiscal Eletrônica) PDF for a billing document.

Returns raw PDF bytes and Content-Type header value.

GET /external/integrations/thirdparty/billings/invoices/download/{documentID}

func (*Client) GeneratePix

func (c *Client) GeneratePix(ctx context.Context, receivableID int) (*APIResponse[GeneratePixResult], error)

GeneratePix generates a PIX QR code for an existing invoice (receivable).

POST /external/integrations/thirdparty/billings/registerpix?receivableId={id}

func (*Client) GenerateSaleOrder

func (c *Client) GenerateSaleOrder(ctx context.Context, req GenerateSaleOrderRequest) (*APIResponse[any], error)

GenerateSaleOrder generates a sale order for an existing contract.

POST /external/integrations/thirdparty/salerequest

func (*Client) GetAccessPointStatusByClient

func (c *Client) GetAccessPointStatusByClient(ctx context.Context, clientID int) (*APIResponse[[]AccessPointStatus], error)

GetAccessPointStatusByClient returns all access point statuses for a given client.

GET /external/integrations/thirdparty/getaccesspointstatusbyclient/{clientID}

func (*Client) GetAccessPointStatusByContract

func (c *Client) GetAccessPointStatusByContract(ctx context.Context, contractID int) (*APIResponse[AccessPointStatus], error)

GetAccessPointStatusByContract returns the access point status for a given contract.

GET /external/integrations/thirdparty/getaccesspointstatusbycontract/{contractID}

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() string

GetAccessToken returns the current access token.

func (*Client) GetAllInvoicesByTxID

func (c *Client) GetAllInvoicesByTxID(ctx context.Context, txID string) (*APIResponse[[]Invoice], error)

GetAllInvoicesByTxID returns all invoices (any status) for a CPF/CNPJ.

GET /external/integrations/thirdparty/gettitlesbytxid/{txId}

func (*Client) GetCampaignsAndPriceListServices

func (c *Client) GetCampaignsAndPriceListServices(ctx context.Context) (*APIResponse[[]Campaign], error)

GetCampaignsAndPriceListServices returns CRM campaigns with their price lists and products.

GET /external/integrations/thirdparty/crm/campaignsandpricelistservices

func (*Client) GetContractTypesAndServices

func (c *Client) GetContractTypesAndServices(ctx context.Context) (*APIResponse[[]ContractType], error)

GetContractTypesAndServices returns available contract types with their service products.

GET /external/integrations/thirdparty/crm/contracttypesandservices

func (*Client) GetElectronicSignatureByContract

func (c *Client) GetElectronicSignatureByContract(ctx context.Context, contractID int) ([]ElectronicSignatureDocument, error)

GetElectronicSignatureByContract retrieves electronic signature documents for a contract.

GET /external/integrations/thirdparty/suite/electronicsignatures/getdocumentlinktosignbycontract/{contractID}

func (*Client) GetInvoicePDF

func (c *Client) GetInvoicePDF(ctx context.Context, invoiceID int) ([]byte, string, error)

GetInvoicePDF downloads the printed billet (boleto) PDF for an invoice.

Returns raw PDF bytes and Content-Type header value.

GET /external/integrations/thirdparty/GetBillet/{invoiceID}

func (*Client) GetOpenInvoicesByContract

func (c *Client) GetOpenInvoicesByContract(ctx context.Context, contractID int) (*APIResponse[[]ContractBillet], error)

GetOpenInvoicesByContract returns open invoices for a specific contract.

GET /external/integrations/thirdparty/getcontractbillets/{contractID}

func (*Client) GetOpenInvoicesByTxID

func (c *Client) GetOpenInvoicesByTxID(ctx context.Context, txID string) (*APIResponse[[]Invoice], error)

GetOpenInvoicesByTxID returns open (unpaid) invoices for a CPF/CNPJ.

GET /external/integrations/thirdparty/getopentitlesbytxid/{txId}

func (*Client) GetPersonByTxID

func (c *Client) GetPersonByTxID(ctx context.Context, txID string) (*APIResponse[PersonDetail], error)

GetPersonByTxID searches for a person by CPF or CNPJ (txId).

GET /external/integrations/thirdparty/people/txid/{txId}

func (*Client) GetRefreshToken

func (c *Client) GetRefreshToken() string

GetRefreshToken returns the current refresh token.

func (*Client) GetRenegotiationInfo

GetRenegotiationInfo retrieves fine and interest information for a set of receivables to support building a renegotiation proposal.

GET /external/integrations/thirdparty/financial/getrenegotiationsinformations (body sent as JSON despite being a GET matches API documentation)

func (*Client) IsHoliday

IsHoliday checks whether a given date is a holiday for a specific state/city.

POST /external/integrations/thirdparty/isholiday

func (*Client) ListCustomers

func (c *Client) ListCustomers(ctx context.Context, params PaginationParams) (*APIResponse[PagedData[Customer]], error)

ListCustomers returns a paginated list of customers.

GET /external/integrations/thirdparty/getclient

func (*Client) ListDocumentationTypes

func (c *Client) ListDocumentationTypes(ctx context.Context, filter, orderBy string) (*APIResponse[PagedData[DocumentationType]], error)

ListDocumentationTypes returns available document classification types.

GET /external/integrations/thirdparty/getdocumentationtypes

func (*Client) ListDocumentsByContract

func (c *Client) ListDocumentsByContract(ctx context.Context, contractNumber string, documentationTypeID int) (*APIResponse[[]ContractDocument], error)

ListDocumentsByContract lists documents attached to a contract filtered by documentation type.

GET /external/integrations/thirdparty/getfilesbycontract/{contractNumber}/documentationtype/{documentationTypeID}

func (*Client) ListLocations

func (c *Client) ListLocations(ctx context.Context, params PaginationParams) (*APIResponse[PagedData[Location]], error)

ListLocations returns a paginated list of company locations/branches.

GET /external/integrations/thirdparty/companiesplacespaged

func (*Client) MaintainSolicitation

func (c *Client) MaintainSolicitation(ctx context.Context, req MaintainSolicitationRequest) (*APIResponse[any], error)

MaintainSolicitation updates an existing solicitation (status, type, report).

POST /external/integrations/thirdparty/solicitationmaintenance

func (*Client) OpenCRMSolicitation

func (c *Client) OpenCRMSolicitation(ctx context.Context, req OpenCRMSolicitationRequest) (*APIResponse[any], error)

OpenCRMSolicitation creates a CRM-linked solicitation.

POST /external/integrations/thirdparty/opensolicitationcrm

func (*Client) OpenDetailedSolicitation

func (c *Client) OpenDetailedSolicitation(ctx context.Context, req OpenDetailedSolicitationRequest) (*APIResponse[any], error)

OpenDetailedSolicitation creates a detailed (external or internal) solicitation.

POST /external/integrations/thirdparty/opendetailedsolicitation

func (*Client) OpenSimpleSolicitation

func (c *Client) OpenSimpleSolicitation(ctx context.Context, req OpenSimpleSolicitationRequest) (*APIResponse[any], error)

OpenSimpleSolicitation creates a basic solicitation linked to a client and contract.

POST /external/integrations/thirdparty/opensolicitation

func (*Client) OpenSolicitationForAccessPoint

func (c *Client) OpenSolicitationForAccessPoint(ctx context.Context, integrationCode string) (*APIResponse[any], error)

OpenSolicitationForAccessPoint opens a solicitation for a specific access point identified by its integration code.

POST /external/integrations/thirdparty/opensolicitationpopeventerror/{integrationCode}

func (*Client) OpenSolicitationForClient

func (c *Client) OpenSolicitationForClient(ctx context.Context, clientID int) (*APIResponse[any], error)

OpenSolicitationForClient opens a solicitation triggered by a client error event.

POST /external/integrations/thirdparty/opensolicitationclienteventerror/{clientID}

func (*Client) RefreshToken

func (c *Client) RefreshToken(ctx context.Context, req RefreshTokenRequest) (*TokenResponse, error)

RefreshToken exchanges a refresh token for a new access token.

The returned TokenResponse can be passed directly to client.SetTokenResponse.

func (*Client) RegisterPayment

RegisterPayment settles an invoice by registering a payment (receipt).

POST /external/integrations/thirdparty/receivepayment

func (*Client) RegisterPerson

RegisterPerson creates a new person/customer record in the ERP.

POST /external/integrations/thirdparty/people

func (*Client) RegisterRenegotiation

RegisterRenegotiation creates a new debt renegotiation for a set of open receivables.

POST /external/integrations/thirdparty/financial/registerrenegotiations

func (*Client) RegisterUserTraffic

func (c *Client) RegisterUserTraffic(ctx context.Context, req RegisterUserTrafficRequest) (*TrafficResponse, error)

RegisterUserTraffic records ISP user traffic data (download/upload counters).

POST /external/integrations/thirdparty/isp/authentication_contracts/traffic

func (*Client) RemoveContractServices

RemoveContractServices removes service items from an existing contract.

POST /external/integrations/thirdparty/contract/removecontractitems

func (*Client) ResendElectronicSignature

func (c *Client) ResendElectronicSignature(ctx context.Context, req ResendSignatureRequest) error

ResendElectronicSignature resends an electronic signature document notification.

NOTE: The API documentation describes this as a GET with a request body, which is non-standard. This SDK sends it as a POST for broad HTTP client compatibility.

POST /external/integrations/thirdparty/suite/electronicsignatures/resend

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(token string)

SetAccessToken sets the Bearer token used for API requests. This replaces any existing token.

func (*Client) SetTokenResponse

func (c *Client) SetTokenResponse(tr *TokenResponse)

SetTokenResponse stores a full token response (access + refresh + expiry). Call this after a successful Authenticate* call.

func (*Client) StartSale

StartSale opens a new CRM negotiation (sale) and returns a protocol ID.

POST /external/integrations/thirdparty/crm/startsale

func (*Client) TokenExpiresAt

func (c *Client) TokenExpiresAt() time.Time

TokenExpiresAt returns the time when the current access token expires. Returns zero time if no expiry is known.

func (*Client) UnlockContract

func (c *Client) UnlockContract(ctx context.Context, contractNumber string) (*APIResponse[any], error)

UnlockContract unlocks a suspended/blocked contract.

POST /external/integrations/thirdparty/contracts/unlock/{contractNumber}

func (*Client) UpdateConnection

func (c *Client) UpdateConnection(ctx context.Context, connectionID int, req UpdateConnectionRequest) (*APIResponse[bool], error)

UpdateConnection updates the technical parameters of a connection.

PUT /external/integrations/thirdparty/updateconnection/{connectionID}

func (*Client) UpdateCustomerAddress

func (c *Client) UpdateCustomerAddress(ctx context.Context, clientID int, req UpdateAddressRequest) (*APIResponse[UpdateAddressResult], error)

UpdateCustomerAddress updates the main address of a customer.

PUT /external/integrations/thirdparty/updateaddress/{clientID}

func (*Client) UpdatePerson

func (c *Client) UpdatePerson(ctx context.Context, personID int, req UpdatePersonRequest) (*APIResponse[UpdatePersonResult], error)

UpdatePerson updates an existing person's contact information (email and/or phone).

PUT /external/integrations/thirdparty/people/{personID}

func (*Client) UploadAttachmentToContract

func (c *Client) UploadAttachmentToContract(
	ctx context.Context,
	contractNumber string,
	documentationTypeCode string,
	fileName string,
	fileData []byte,
) (*APIResponse[any], error)

UploadAttachmentToContract uploads a file attachment to a contract.

POST /external/integrations/thirdparty/contract/contractuploads Query params: contractNumber, documentationTypeCode

func (*Client) UploadAttachmentToSolicitation

func (c *Client) UploadAttachmentToSolicitation(
	ctx context.Context,
	protocol int,
	documentationTypeCode string,
	fileName string,
	fileData []byte,
) (*APIResponse[any], error)

UploadAttachmentToSolicitation uploads a file attachment to a solicitation.

POST /external/integrations/thirdparty/projects/assignmentsuploads Query params: protocol, documentationTypeCode

func (*Client) VerifyViability

func (c *Client) VerifyViability(ctx context.Context, req VerifyViabilityRequest) (*APIResponse[ViabilityResult], error)

VerifyViability checks whether a given address has service coverage.

POST /external/integrations/thirdparty/verifyviability

type ClientCredentialsRequest

type ClientCredentialsRequest struct {
	// GrantType defaults to "client_credentials".
	GrantType string
	// Scope defaults to "syngw".
	Scope string
	// ClientID is obtained from Settings / Users / Integration User / "Client Id".
	ClientID string
	// ClientSecret is obtained from Settings / Users / Integration User / "Client Secret".
	ClientSecret string
	// SynData is the integration token from Suite / Settings / Parameters / Integration/Map.
	SynData string
}

ClientCredentialsRequest holds credentials for the modern OAuth2 client_credentials flow.

ClientID and ClientSecret are obtained from the integration user record in Settings / Users / "Client Id" and "Client Secret" fields. GrantType and Scope default to the ERP Elleven standard values.

type Config

type Config struct {
	// BaseURL is the base URL of the ERP Elleven instance, WITHOUT port.
	// Example: "https://erp.yourcompany.com" or "http://192.168.1.10"
	//
	// Used together with APIPort and AuthPort to construct APIURL and AuthURL.
	// Ignored if APIURL (or AuthURL) is set directly.
	BaseURL string

	// APIPort is the port for all non-auth API calls. Defaults to "45715".
	// Ignored if APIURL is set directly.
	APIPort string

	// AuthPort is the port for authentication endpoints. Defaults to "45700".
	// Ignored if AuthURL is set directly.
	AuthPort string

	// APIURL is the full base URL (scheme + host + port) used for API calls.
	// When set, BaseURL and APIPort are ignored for API calls.
	// Example: "http://erp.example.com:45715"
	//
	// Useful for testing (httptest.Server) or non-standard deployments.
	APIURL string

	// AuthURL is the full base URL (scheme + host + port) used for auth calls.
	// When set, BaseURL and AuthPort are ignored for auth calls.
	// Example: "http://erp.example.com:45700"
	AuthURL string

	// AccessToken is an optional pre-configured Bearer token.
	AccessToken string

	// HTTPClient allows injecting a custom *http.Client for transport-level
	// customization (TLS, proxies, etc.). If nil, a default client is created
	// using the Timeout value.
	HTTPClient *http.Client

	// Timeout for HTTP requests. Defaults to 30 seconds.
	// Only applies when HTTPClient is nil.
	Timeout time.Duration

	// MaxRetries is the number of retry attempts for transient errors
	// (HTTP 429, 502, 503, 504).
	// 0 (zero value) → use default of 3 retries.
	// -1 → disable retries entirely (only one attempt is made).
	// Any positive value → use exactly that many retries.
	MaxRetries int

	// RetryWaitMin is the minimum wait between retries. Defaults to 1 second.
	RetryWaitMin time.Duration

	// RetryWaitMax is the maximum wait between retries (exponential cap).
	// Defaults to 30 seconds.
	RetryWaitMax time.Duration
}

Config holds all configuration options for the ERP Elleven SDK client.

type ConfirmInvoiceIssuanceRequest

type ConfirmInvoiceIssuanceRequest struct {
	// ID is the internal identifier of the invoice issuance record.
	ID string `json:"id"`
	// AccessKey is the NF-e / NFS-e access key (chave de acesso).
	AccessKey string `json:"accessKey"`
	// IssueDate is the date the invoice was issued (format: YYYY-MM-DD).
	IssueDate string `json:"issueDate"`
}

ConfirmInvoiceIssuanceRequest is the request body for confirming that a third-party invoice (nota fiscal) was issued.

type ContractActivationInfo

type ContractActivationInfo struct {
	IncidentTypeCode            string `json:"incidentTypeCode"`
	GroupInMonthlyFee           bool   `json:"groupInMonthlyFee"`
	FirstParcelDate             string `json:"firstParcelDate"` // YYYY-MM-DD
	PaymentFormCode             string `json:"paymentFormCode"`
	FinancialCollectionTypeCode string `json:"financialCollectionTypeCode"`
	PaymentConditionCode        string `json:"paymentConditionCode"`
}

ContractActivationInfo holds activation configuration for a new contract.

type ContractBillet

type ContractBillet struct {
	ID             int    `json:"id"`
	Title          string `json:"title"`
	ExpirationDate string `json:"expirationDate"`
	Parcel         int    `json:"parcel"`
	TypefulLine    string `json:"typefulLine"`
	Link           string `json:"link"`
	PixQRCode      string `json:"pixQRCode"`
}

ContractBillet represents a simplified billet as returned by GetOpenInvoicesByContract.

type ContractClientInfo

type ContractClientInfo struct {
	TxID string `json:"txId"`
}

ContractClientInfo holds the client identification fields for contract creation.

type ContractDocument

type ContractDocument struct {
	Title             string `json:"title"`
	Description       string `json:"description"`
	DocumentationType string `json:"documentationType"`
	Validity          struct {
		Begin *string `json:"begin"`
		Final *string `json:"final"`
	} `json:"validity"`
	File string `json:"file"` // URL to the file
}

ContractDocument represents a document file associated with a contract.

type ContractInfo

type ContractInfo struct {
	ContractType                string `json:"contractType"`
	CompanyPlaceTxID            string `json:"companyPlaceTxId"`
	CRMCampaignCode             string `json:"crmCampaignCode"`
	CRMPriceListCode            string `json:"crmPriceListCode"`
	PaymentFormCode             string `json:"paymentFormCode"`
	FinancialCollectionTypeCode string `json:"financialCollectionTypeCode"`
	DateManagementCode          string `json:"dateManagementCode"`
	CollectionDay               int    `json:"collectionDay"`
}

ContractInfo holds the core contract configuration fields.

type ContractIntegratorInfo

type ContractIntegratorInfo struct {
	IntegratorAlias     string `json:"integratorAlias"`
	IntegrationCode     string `json:"integrationCode"`
	IntegrationTeamCode string `json:"integrationTeamCode"`
}

ContractIntegratorInfo holds integrator metadata for contract creation.

type ContractServiceInfo

type ContractServiceInfo struct {
	Code            string  `json:"code"`
	Quantity        int     `json:"quantity"`
	Price           float64 `json:"price"`
	PaymentFormCode string  `json:"paymentFormCode"`
}

ContractServiceInfo holds a service product for contract creation.

type ContractServiceModification

type ContractServiceModification struct {
	OldContractItemID int `json:"oldContractItemId"`
	NewContractService
}

ContractServiceModification extends NewContractService with the existing item ID.

type ContractServiceOperationResult

type ContractServiceOperationResult struct {
	Success bool   `json:"Sucess"` // Note: API uses "Sucess" (typo in API)
	Message string `json:"Message"`
}

ContractServiceOperationResult is the response for contract service operations. Note: the API returns inconsistent casing (Sucess/True) mapped faithfully.

type ContractServicePhoneInfo

type ContractServicePhoneInfo struct {
	PhoneNumber     string `json:"phoneNumber"`
	PhoneNumberType int    `json:"phoneNumberType"`
	IsPortability   bool   `json:"isPortability"`
}

ContractServicePhoneInfo contains phone info for a contract service addition.

type ContractType

type ContractType struct {
	Code                        string                `json:"code"`
	Title                       string                `json:"title"`
	Description                 string                `json:"description"`
	CollectionDays              []int                 `json:"collectionDays"`
	ContractTypesServiceProduct []ContractTypeService `json:"contractTypesServiceProduct"`
}

ContractType represents a contract type with its associated service products.

type ContractTypeService

type ContractTypeService struct {
	Code        string  `json:"code"`
	Title       string  `json:"title"`
	Description *string `json:"description"`
}

ContractTypeService represents a service product inside a contract type.

type CreateContractRequest

type CreateContractRequest struct {
	ClientInformation     ContractClientInfo     `json:"clientInformation"`
	ContractInformation   ContractInfo           `json:"contractInformation"`
	ServicesInformation   []ContractServiceInfo  `json:"servicesInformation"`
	ActivationInformation ContractActivationInfo `json:"activationInformation"`
	IntegratorInformation ContractIntegratorInfo `json:"integratorInformation"`
}

CreateContractRequest is the request body for creating a contract directly via billing.

type CreateContractResponse

type CreateContractResponse struct {
	Success          bool                 `json:"Success"`
	Message          *string              `json:"message"`
	Response         CreateContractResult `json:"response"`
	DataResponseType string               `json:"dataResponseType"`
	ElapsedTime      *float64             `json:"elapsedTime"`
}

CreateContractResponse wraps the contract creation response. NOTE: This endpoint uses non-standard casing ("Success" capitalized).

type CreateContractResult

type CreateContractResult struct {
	ContractNumber       string `json:"contractNumber"`
	ActivationAssignment int    `json:"activationAssignment"`
}

CreateContractResult is the response payload when a contract is created.

type CreateEventualValueRequest

type CreateEventualValueRequest struct {
	Type                           EventualValueType `json:"type"`
	ContractID                     int               `json:"contractId"`
	ContractItemID                 int               `json:"contracItemtId"` // Note: typo from API preserved
	ContractConfigurationBillingID int               `json:"contractConfigurationBillingId"`
	ServiceProductCode             string            `json:"serviceProductCode"`
	MonthYearType                  int               `json:"monthYearType"`
	MonthYear                      string            `json:"monthYear"`        // YYYY-MM-DD
	InitialMonthYear               string            `json:"initialMonthYear"` // YYYY-MM-DD
	FinalMonthYear                 string            `json:"finalMonthYear"`   // YYYY-MM-DD
	Description                    string            `json:"description"`
	PresentInvoiceNote             bool              `json:"presentInvoiceNote"`
	UnitAmount                     float64           `json:"unitAmount"`
	Units                          int               `json:"units"`
}

CreateEventualValueRequest is the request body for creating an eventual billing value.

type CreateLeadRequest

type CreateLeadRequest struct {
	PersonalData   LeadPersonalData   `json:"personalData"`
	Contact        LeadContact        `json:"contact"`
	Address        LeadAddress        `json:"address"`
	IntegratorData LeadIntegratorData `json:"integratorData"`
}

CreateLeadRequest is the request body for creating a CRM lead.

type CreateSolicitationReportRequest

type CreateSolicitationReportRequest struct {
	AssignmentID       int    `json:"assignmentId"`
	Protocol           int    `json:"protocol"`
	IncidentStatusID   int    `json:"incidentStatusId"`
	Description        string `json:"description"`
	Progress           int    `json:"progress"`
	Priority           int    `json:"priority"`
	NotificationTarget int    `json:"notificationTarget"`
	PrivateReport      bool   `json:"privateReport"`
}

CreateSolicitationReportRequest is the request body for creating a report on a solicitation.

type Customer

type Customer struct {
	ID                    any     `json:"id"` // API returns as string or number
	AddressComplement     string  `json:"addressComplement"`
	AddressReference      string  `json:"addressReference"`
	BirthDate             *string `json:"birthDate"`
	Candidate             bool    `json:"candidate"`
	Carrier               bool    `json:"carrier"`
	CellPhone1            string  `json:"cellPhone1"`
	City                  string  `json:"city"`
	CivilStatus           int     `json:"civilStatus"`
	Client                bool    `json:"client"`
	CodeCityID            int     `json:"codeCityId"`
	CodeCountry           string  `json:"codeCountry"`
	Collaborator          bool    `json:"collaborator"`
	Competitor            bool    `json:"competitor"`
	Country               string  `json:"country"`
	Email                 string  `json:"email"`
	EmailNfe              string  `json:"emailNfe"`
	Expert                bool    `json:"expert"`
	Gender                int     `json:"gender"`
	HouseLawyer           bool    `json:"houseLawyer"`
	Identity              string  `json:"identity"`
	MunicipalRegistration string  `json:"municipalRegistration"`
	Name                  string  `json:"name"`
	Name2                 string  `json:"name2"`
	Neighborhood          string  `json:"neighborhood"`
	Number                string  `json:"number"`
	ParentsName           string  `json:"parentsName"`
	PeopleAddressMainID   int     `json:"peopleAddressMainId"`
	Phone                 string  `json:"phone"`
	PostalCode            string  `json:"postalCode"`
	Situation             int     `json:"situation"`
	State                 string  `json:"state"`
	StateRegistration     string  `json:"stateRegistration"`
	StateRegistrationType int     `json:"stateRegistrationType"`
	Status                int     `json:"status"`
	Street                string  `json:"street"`
	StreetType            string  `json:"streetType"`
	TxID                  string  `json:"txId"`
	TxIDFormatted         string  `json:"txIdFormated"`
	TypeTxID              int     `json:"typeTxId"`
	UserID                int     `json:"userId"`
	Vendor                bool    `json:"vendor"`
}

Customer represents a full customer record returned by the list endpoint.

type DocumentationType

type DocumentationType struct {
	Active       bool        `json:"active"`
	Code         string      `json:"code"`
	ID           int         `json:"id"`
	Title        string      `json:"title"`
	Description  string      `json:"description"`
	DefaultText  string      `json:"defaultText"`
	UseType      UseTypeItem `json:"useType"`
	SynSuiteCode *string     `json:"synsuiteCode"`
}

DocumentationType represents a document type available in the ERP.

type ElectronicSignatureDocument

type ElectronicSignatureDocument struct {
	SignatureID                int     `json:"signatureId"`
	Description                string  `json:"description"`
	ContractID                 int     `json:"contractId"`
	AssignmentID               *int    `json:"assignmentId"`
	IntegrationCode            string  `json:"integrationCode"`
	PersonID                   int     `json:"personId"`
	PersonName                 string  `json:"personName"`
	IntegrationType            int     `json:"integrationType"`
	IntegrationTypeDescription string  `json:"integrationTypeDescription"`
	Status                     string  `json:"status"`
	Created                    string  `json:"created"`
	ExpirationDate             *string `json:"expirationDate"`
	LinkToSign                 string  `json:"linkToSign"`
}

ElectronicSignatureDocument represents an electronic signature document.

type EventualValueType

type EventualValueType int

EventualValueType defines the type of an eventual (one-time) billing value.

const (
	EventualValueTypeCredit EventualValueType = 0
	EventualValueTypeDebit  EventualValueType = 1
)

type GeneratePixResult

type GeneratePixResult struct {
	RegisterID     int     `json:"registerId"`
	QRCode         string  `json:"qrCode"`
	TotalAmount    float64 `json:"totalAmount"`
	InterestAmount float64 `json:"interestAmount"`
	FineAmount     float64 `json:"fineAmount"`
	TransactionID  string  `json:"transactionId"`
	HybridBillet   bool    `json:"hybridBillet"`
}

GeneratePixRequest identifies the invoice for PIX generation. Passed as a query parameter, not a body.

type GenerateSaleOrderRequest

type GenerateSaleOrderRequest struct {
	CompanyPlaceTxID          string          `json:"companyPlaceTxId"`
	ClientTxID                string          `json:"clientTxId"`
	ContractNumber            string          `json:"contractNumber"`
	PriceListID               string          `json:"priceListId"`
	FinancialCollectionTypeID string          `json:"financialCollectionTypeId"`
	PaymentConditionID        string          `json:"paymentConditionId"`
	Items                     []SaleOrderItem `json:"items"`
}

GenerateSaleOrderRequest is the request body for generating a sale order.

type HolidayCheckRequest

type HolidayCheckRequest struct {
	Date string `json:"date"` // Format: YYYY-MM-DD
	UF   string `json:"UF"`
	City string `json:"city"`
}

HolidayCheckRequest is the request body for validating if a date is a holiday.

type HolidayCheckResult

type HolidayCheckResult struct {
	IsHoliday bool   `json:"isHoliday"`
	Name      string `json:"name"`
	Date      string `json:"date"`
	City      string `json:"city"`
	Scope     string `json:"scope"`
	UF        string `json:"uf"`
}

HolidayCheckResult is the response payload for the holiday check.

type Invoice

type Invoice struct {
	ID             int           `json:"id"`
	Billet         InvoiceBillet `json:"billet"`
	Client         any           `json:"client"`
	CompanyPlace   any           `json:"companyPlace"`
	Bank           any           `json:"bank"`
	CollectionType any           `json:"collectionType"`

	// Status is only present on GetAllInvoicesByTxID (e.g. "Em aberto", "Paga", "Cancelada", "Vencida")
	Status string `json:"status,omitempty"`
}

Invoice represents a financial receivable title (invoice/fatura).

type InvoiceAmount

type InvoiceAmount struct {
	Value      float64 `json:"value"`
	FinalValue float64 `json:"finalValue"`
	Discount   float64 `json:"discount"`
	Fine       float64 `json:"fine"`
	Interest   float64 `json:"interest"`
}

InvoiceAmount holds the detailed amounts for an invoice.

type InvoiceBillet

type InvoiceBillet struct {
	BankTitleNumber *string       `json:"bankTitleNumber"`
	Barcode         *string       `json:"barcode"`
	TypefulLine     string        `json:"typefulLine"`
	PixQRCode       string        `json:"pixQRCode"`
	Title           string        `json:"title"`
	IssueDate       string        `json:"issueDate"`
	ExpirationDate  string        `json:"expirationDate"`
	ProcessingDate  string        `json:"processingDate"`
	Amount          InvoiceAmount `json:"amount"`
}

InvoiceBillet holds billet (boleto) and PIX data for an invoice.

type LeadAddress

type LeadAddress struct {
	PostalCode        string `json:"postalCode"`
	Street            string `json:"street"`
	StreetType        string `json:"streetType"`
	Number            string `json:"number"`
	Neighborhood      string `json:"neighborhood"`
	AddressComplement string `json:"addressComplement"`
	AddressReference  string `json:"addressReference"`
	CodeCityID        int    `json:"codeCityId"`
	City              string `json:"city"`
	State             string `json:"state"`
	Country           string `json:"country"`
}

LeadAddress holds address fields for a lead.

type LeadContact

type LeadContact struct {
	Phone                string `json:"phone"`
	CellPhone            string `json:"cellPhone"`
	CellPhoneHasWhatsApp bool   `json:"cellPhoneHasWhatsApp"`
	CellPhoneHasTelegram bool   `json:"cellPhoneHasTelegram"`
	Email                string `json:"email"`
	Website              string `json:"website"`
}

LeadContact holds contact information for a lead.

type LeadIntegratorData

type LeadIntegratorData struct {
	CRMContactOriginCode  string `json:"crmContactOriginCode"`
	CRMFormCode           string `json:"crmFormCode"`
	IntegratorAlias       string `json:"integratorAlias"`
	IntegrationCode       string `json:"integrationCode"`
	IntegrationTeamCode   string `json:"integrationTeamCode"`
	IntegrationSellerTxID string `json:"integrationSellerTxId"`
}

LeadIntegratorData holds integration metadata for a lead creation request.

type LeadPersonalData

type LeadPersonalData struct {
	Name        string `json:"name"`
	Name2       string `json:"name2"`
	TypeTxID    int    `json:"typeTxId"`
	TxID        string `json:"txId"`
	BirthDate   string `json:"birthDate,omitempty"` // RFC3339
	Identity    string `json:"identity"`
	CivilStatus *int   `json:"civilStatus"`
	Gender      *int   `json:"gender"`
	ParentsName string `json:"parentsName"`
}

LeadPersonalData holds personal identification fields for a lead.

type LegacyAuthRequest

type LegacyAuthRequest struct {
	// GrantType defaults to "password".
	GrantType string
	// Scope defaults to "syngw synpaygw offline_access".
	Scope string
	// ClientID defaults to "synauth".
	ClientID string
	// ClientSecret defaults to the ERP Elleven platform secret.
	ClientSecret string
	// Username is the integration user's login name.
	Username string
	// Password is the integration user's password.
	Password string
	// SynData is the integration token from Suite / Settings / Parameters / Integration/Map.
	SynData string
}

LegacyAuthRequest holds credentials for the legacy password-based OAuth2 flow.

The platform defaults (GrantType, Scope, ClientID, ClientSecret) are pre-filled with the ERP Elleven standard values. Override them only if your environment requires different values.

type Location

type Location struct {
	ID            int    `json:"id"`
	Description   string `json:"description"`
	Code          string `json:"code"`
	TxID          string `json:"txId"`
	TxIDFormatted string `json:"txIdFormated"`
	City          string `json:"city"`
	Street        string `json:"street"`
}

Location represents an ERP company location (place/branch).

type MaintainSolicitationRequest

type MaintainSolicitationRequest struct {
	Protocol                      string `json:"protocol"`
	SolicitationServiceMatrixCode string `json:"solicitationServiceMatrixCode"`
	IncidentTypeCode              string `json:"incidentTypeCode"`
	Report                        string `json:"report"`
}

MaintainSolicitationRequest is the request body for maintaining (updating) a solicitation.

type MatrixType

type MatrixType int

MatrixType distinguishes between external (1) and internal (2) solicitations.

const (
	MatrixTypeExternal MatrixType = 1
	MatrixTypeInternal MatrixType = 2
)

type NewContractService

type NewContractService struct {
	Code                          string                     `json:"code"`
	Quantity                      int                        `json:"quantity"`
	Price                         float64                    `json:"price"`
	PaymentFormCode               string                     `json:"paymentFormCode"`
	ServiceTagOption              int                        `json:"serviceTagOption"`
	ContractServiceTag            string                     `json:"contractServiceTag"`
	ContractServiceTagDescription string                     `json:"contractServiceTagDescription"`
	PhoneGroupID                  string                     `json:"phoneGroupId"`
	PhoneNumberInformations       []ContractServicePhoneInfo `json:"phoneNumberInformations,omitempty"`
}

NewContractService describes a service to be added to a contract.

type OpenCRMSolicitationRequest

type OpenCRMSolicitationRequest struct {
	Description          string `json:"description"`
	ContractID           int    `json:"contractId"`
	ContractServiceTagID int    `json:"contractServiceTagId"`
}

OpenCRMSolicitationRequest is the request body for opening a CRM-linked solicitation.

type OpenDetailedSolicitationRequest

type OpenDetailedSolicitationRequest struct {
	IncidentStatusID             int                    `json:"incidentStatusId"`
	PersonID                     int                    `json:"personId"`
	ClientID                     int                    `json:"clientId"`
	IncidentTypeID               int                    `json:"incidentTypeId"`
	ContractServiceTagID         int                    `json:"contractServiceTagId"`
	CatalogServiceID             int                    `json:"catalogServiceId"`
	ServiceLevelAgreementID      int                    `json:"serviceLevelAgreementId"`
	CatalogServiceItemID         int                    `json:"catalogServiceItemId"`
	CatalogServiceItemClassID    int                    `json:"catalogServiceItemClassId"`
	MatrixType                   MatrixType             `json:"matrixType"`
	Assignment                   SolicitationAssignment `json:"assignment"`
	ContractServiceTagCategory   string                 `json:"contractServiceTagCategory"`
	SolicitationServiceCategory1 string                 `json:"solicitationServiceCategory1"`
	SolicitationServiceCategory2 string                 `json:"solicitationServiceCategory2"`
	SolicitationServiceCategory3 string                 `json:"solicitationServiceCategory3"`
	SolicitationServiceCategory4 string                 `json:"solicitationServiceCategory4"`
	SolicitationServiceCategory5 string                 `json:"solicitationServiceCategory5"`

	// Internal solicitation fields (MatrixTypeInternal only)
	TeamCode                      string `json:"teamCode,omitempty"`
	AuthenticationAccessPointCode string `json:"authenticationAccessPointCode,omitempty"`
}

OpenDetailedSolicitationRequest is the request body for creating a detailed solicitation.

Use MatrixType = MatrixTypeExternal (1) for client-facing solicitations. Use MatrixType = MatrixTypeInternal (2) for internal solicitations (also requires TeamCode and AuthenticationAccessPointCode fields via the extended request).

type OpenSimpleSolicitationRequest

type OpenSimpleSolicitationRequest struct {
	Description          string `json:"description"`
	ClientID             int    `json:"clientId"`
	ContractID           int    `json:"contractId"`
	ContractServiceTagID int    `json:"contractServiceTagId"`
	Close                bool   `json:"close"`
}

OpenSimpleSolicitationRequest is the request body for opening a simple solicitation.

type PagedData

type PagedData[T any] struct {
	Data         []T `json:"data"`
	TotalRecords int `json:"totalRecords"`
	Page         int `json:"page"`
	PageSize     int `json:"pageSize"`
	TotalPages   int `json:"totalPages"`
}

PagedData wraps paginated list responses from the API.

type PaginationParams

type PaginationParams struct {
	Page     int
	PageSize int
	Filter   string
	OrderBy  string
}

PaginationParams holds common query parameters for paginated endpoints.

type PaymentStatus

type PaymentStatus struct {
	Value int    `json:"value"`
	Label string `json:"label"`
}

PaymentStatus holds the status label and value for a payment.

type PaymentStatusResult

type PaymentStatusResult struct {
	IntegratorTransactionID string        `json:"integratorTransactionId"`
	Status                  PaymentStatus `json:"status"`
	Processed               string        `json:"processed"`
	Message                 string        `json:"message"`
}

PaymentStatusResult is the response payload for ConsultPaymentStatus.

type PersonAddress

type PersonAddress struct {
	StreetType        string `json:"streetType"`
	Street            string `json:"street"`
	Number            string `json:"number"`
	AddressComplement string `json:"addressComplement"`
	Neighborhood      string `json:"neighborhood"`
	City              string `json:"city"`
	CodeCityID        int    `json:"codeCityId"`
	AddressReference  string `json:"addressReference"`
	State             string `json:"state"`
	PostalCode        string `json:"postalCode"`
	Longitude         string `json:"longitude"`
	Latitude          string `json:"latitude"`
}

PersonAddress represents the main address of a person.

type PersonDetail

type PersonDetail struct {
	ID          int           `json:"id"`
	Name        string        `json:"name"`
	Name2       string        `json:"name2"`
	TxID        string        `json:"txId"`
	Email       string        `json:"email"`
	Status      int           `json:"status"`
	Phone       string        `json:"phone"`
	BirthDate   string        `json:"birthDate"`
	CellPhone   string        `json:"cellPhone"`
	MainAddress PersonAddress `json:"mainAddress"`
	Titles      []PersonTitle `json:"titles"`
}

PersonDetail is the full person detail returned by the search-by-txid endpoint.

type PersonTitle

type PersonTitle struct {
	ID     int         `json:"id"`
	Billet TitleBillet `json:"billet"`
}

PersonTitle represents a billing title associated with a person.

type ProportionalityItem

type ProportionalityItem struct {
	Description        string  `json:"description"`
	Amount             float64 `json:"amount"`
	Competence         string  `json:"competence"`
	ServiceDescription string  `json:"serviceDescription"`
	Type               int     `json:"type"`
	CompetenceType     int     `json:"competenceType"`
}

ProportionalityItem represents a proportionality entry from a contract approval.

type RefreshTokenRequest

type RefreshTokenRequest struct {
	// GrantType defaults to "refresh_token".
	GrantType string
	// ClientID defaults to "synauth".
	ClientID string
	// ClientSecret defaults to the ERP Elleven platform secret.
	ClientSecret string
	// RefreshToken is the token obtained from a previous authentication response.
	RefreshToken string
}

RefreshTokenRequest holds the data needed to refresh an existing access token.

GrantType, ClientID and ClientSecret default to the ERP Elleven legacy platform values. Override them only if your environment requires different values.

type RegisterPaymentRequest

type RegisterPaymentRequest struct {
	// TransactionID is a unique GUID for this payment transaction (idempotency key).
	TransactionID              string  `json:"transactionId"`
	FinancialReceivableTitleID int     `json:"financialReceivableTitleId"`
	PaidAmount                 float64 `json:"paidAmount"`
	Message                    string  `json:"message"`
	BankAccountCode            string  `json:"BankAccountCode"`
	PaymentFormCode            string  `json:"PaymentFormCode"`
	ReceiptDate                string  `json:"ReceiptDate"`    // YYYY-MM-DD
	ClientPaidDate             string  `json:"ClientPaidDate"` // YYYY-MM-DD
}

RegisterPaymentRequest is the request body for settling an invoice payment.

type RegisterPaymentResult

type RegisterPaymentResult struct {
	SynGwTransactionID string `json:"synGwTransactionId"`
}

RegisterPaymentResult is the response payload for a successful payment registration.

type RegisterPersonRequest

type RegisterPersonRequest struct {
	TypeTxID          string `json:"typeTxId"`
	TxID              string `json:"txId"`
	Name              string `json:"name"`
	Email             string `json:"email"`
	Client            bool   `json:"client"`
	Situation         int    `json:"situation"`
	StreetType        string `json:"streetType"`
	PostalCode        string `json:"postalCode"`
	Street            string `json:"street"`
	Number            string `json:"number"`
	AddressComplement string `json:"addressComplement"`
	AddressReference  string `json:"addressReference"`
	Neighborhood      string `json:"neighborhood"`
	City              string `json:"city"`
	CodeCityID        int    `json:"codeCityId"`
	State             string `json:"state"`
	CodeCountry       string `json:"codeCountry"`
}

RegisterPersonRequest is the request body for registering a new person/customer.

type RegisterPersonResult

type RegisterPersonResult struct{}

RegisterPersonResult is the response payload when a person is registered.

type RegisterRenegotiationRequest

type RegisterRenegotiationRequest struct {
	ReceivableIDs               []int                 `json:"receivableIds"`
	Discount                    float64               `json:"discount"`
	Fine                        float64               `json:"fine"`
	Interest                    float64               `json:"interest"`
	FinancialCollectionTypeCode any                   `json:"financialCollectionTypeCode"` // int or string per API
	Observation                 string                `json:"observation"`
	BillingInvoiceAntecipated   bool                  `json:"billingInvoiceAntecipad"`
	Parcels                     []RenegotiationParcel `json:"parcels"`
}

RegisterRenegotiationRequest is the request body for registering a debt renegotiation.

type RegisterRenegotiationResult

type RegisterRenegotiationResult struct {
	Parcels []RenegotiationResultParcel `json:"parcels"`
}

RegisterRenegotiationResult is the response payload after a renegotiation is registered.

type RegisterUserTrafficRequest

type RegisterUserTrafficRequest struct {
	// User is the PPPoE/IPoE username (e.g., "client@provider").
	User string `json:"user"`
	// Date is the timestamp for the traffic record (RFC3339).
	Date string `json:"date"`
	// Download is the current session download in bytes.
	Download int64 `json:"download"`
	// Upload is the current session upload in bytes.
	Upload int64 `json:"upload"`
	// TotalDownload is the total accumulated download in bytes.
	TotalDownload int64 `json:"totalDownload"`
	// TotalUpload is the total accumulated upload in bytes.
	TotalUpload int64 `json:"totalUpload"`
}

RegisterUserTrafficRequest is the request body for registering ISP user traffic data.

type RegisterUserTrafficResult

type RegisterUserTrafficResult struct {
	User          string `json:"user"`
	Date          string `json:"date"`
	Download      int64  `json:"download"`
	Upload        int64  `json:"upload"`
	TotalDownload int64  `json:"totalDownload"`
	TotalUpload   int64  `json:"totalUpload"`
}

RegisterUserTrafficResult is the response payload for traffic registration.

type RemoveContractItem

type RemoveContractItem struct {
	ContractItem int `json:"contractItem"`
}

RemoveContractItem identifies a contract item by its ID for removal.

type RemoveContractServicesRequest

type RemoveContractServicesRequest struct {
	ContractNumber string               `json:"contractNumber"`
	RemoveService  []RemoveContractItem `json:"removeService"`
}

RemoveContractServicesRequest is the request body for removing services from a contract.

type RenegotiationInfoRequest

type RenegotiationInfoRequest struct {
	ReceivableIDs []int  `json:"receivableIds"`
	Date          string `json:"date"` // YYYY-MM-DD
}

RenegotiationInfoRequest is the request body for getting renegotiation information.

type RenegotiationInfoResult

type RenegotiationInfoResult struct {
	TotalFine     float64                   `json:"totalFine"`
	TotalInterest float64                   `json:"totalInterest"`
	Receivables   []RenegotiationReceivable `json:"receivables"`
	Date          string                    `json:"date"`
}

RenegotiationInfoResult is the response payload for renegotiation information.

type RenegotiationParcel

type RenegotiationParcel struct {
	Number         int      `json:"number"`
	Amount         *float64 `json:"amount"`         // Nullable: API allows null for calculated amounts
	ExpirationDate string   `json:"expirationDate"` // YYYY-MM-DD
}

RenegotiationParcel describes a single installment in a renegotiation.

type RenegotiationReceivable

type RenegotiationReceivable struct {
	ID       int     `json:"id"`
	Title    string  `json:"title"`
	Fine     float64 `json:"fine"`
	Interest float64 `json:"interest"`
}

RenegotiationReceivable represents a single receivable in a renegotiation.

type RenegotiationResultParcel

type RenegotiationResultParcel struct {
	ID             int     `json:"id"`
	Title          string  `json:"title"`
	ExpirationDate string  `json:"expirationDate"`
	Amount         float64 `json:"amount"`
}

RenegotiationResultParcel is a single parcel in the renegotiation result.

type ResendSignatureRequest

type ResendSignatureRequest struct {
	AssignmentID int `json:"assignmentId"`
	SignatureID  int `json:"signatureId"`
	DispatchType int `json:"dispatchType"`
}

ResendSignatureRequest is the request body for resending an electronic signature.

NOTE: The API documentation shows this endpoint as GET with a body, which is non-standard HTTP. This SDK implements it as POST for compatibility with all HTTP clients.

type SaleOrderItem

type SaleOrderItem struct {
	ID        string  `json:"id"`
	Quantity  int     `json:"quantity"`
	UnitValue float64 `json:"unitValue"`
}

SaleOrderItem represents a single line item in a sale order.

type SaleServicePhoneInfo

type SaleServicePhoneInfo struct {
	PhoneNumber     string `json:"PhoneNumber"`
	PhoneNumberType string `json:"PhoneNumberType"`
	IsPortability   bool   `json:"IsPortability"`
}

SaleServicePhoneInfo contains phone number details for a service product.

type SaleServiceProduct

type SaleServiceProduct struct {
	Code                    string                 `json:"code"`
	Quantity                int                    `json:"quantity"`
	Amount                  float64                `json:"amount"`
	PaymentFormCode         string                 `json:"paymentFormCode"`
	PhoneGroupID            string                 `json:"phoneGroupId"`
	PhoneNumberInformations []SaleServicePhoneInfo `json:"PhoneNumberInformations,omitempty"`
}

SaleServiceProduct describes a service product to be included in a sale.

type SimpleResponse

type SimpleResponse struct {
	Success  bool         `json:"success"`
	Messages []APIMessage `json:"messages"`
}

SimpleResponse wraps responses that only return a success flag and messages.

type SolicitationAssignment

type SolicitationAssignment struct {
	Title          string           `json:"title"`
	Description    string           `json:"description"`
	Priority       int              `json:"priority"`
	BeginningDate  string           `json:"beginningDate"` // RFC3339
	FinalDate      string           `json:"finalDate"`     // RFC3339
	Report         AssignmentReport `json:"report"`
	CompanyPlaceID int              `json:"companyPlaceId"`
}

SolicitationAssignment holds the task/assignment details for a solicitation.

type StartSaleRequest

type StartSaleRequest struct {
	TxID                                  string               `json:"txId"`
	CompanyPlaceTxID                      string               `json:"companyPlaceTxId"`
	ThirdSellerTxID                       string               `json:"thirdSellerTxId"`
	ResponsibleSellerTxID                 string               `json:"responsibleSellerTxId"`
	TeamCode                              string               `json:"TeamCode"`
	ContractType                          string               `json:"contractType"`
	CRMCampaignCode                       string               `json:"crmCampaignCode"`
	CRMPriceListCode                      string               `json:"crmPriceListCode"`
	ContractPaymentFormCode               string               `json:"contractPaymentFormCode"`
	ContractFinancialCollectionTypeCode   string               `json:"contractFinancialCollectionTypeCode"`
	ContractDateManagementCode            string               `json:"contractDateManagementCode"`
	ContractCollectionDay                 string               `json:"contractCollectionDay"`
	ActivationIncidentTypeCode            string               `json:"activationIncidentTypeCode"`
	ActivationGroupInMonthlyFee           bool                 `json:"activationGroupInMonthlyFee"`
	ActivationFirstParcelDate             string               `json:"activationFirstParcelDate"` // YYYY-MM-DD
	ActivationPaymentFormCode             string               `json:"activationPaymentFormCode"`
	ActivationFinancialCollectionTypeCode string               `json:"activationFinancialCollectionTypeCode"`
	ActivationPaymentConditionCode        string               `json:"activationPaymentConditionCode"`
	ServiceProducts                       []SaleServiceProduct `json:"serviceProducts"`

	// ClientSaleInfo, ActivationInformation, IntegratorInformation, GainInformation
	// are flexible objects. Pass nil or a custom struct as needed.
	ClientSaleInfo        any    `json:"clientSaleInfo,omitempty"`
	ActivationInformation any    `json:"activationInformation,omitempty"`
	IntegratorInformation any    `json:"integratorInformation,omitempty"`
	GainInformation       any    `json:"gainInformation,omitempty"`
	Contacts              []any  `json:"contacts,omitempty"`
	Observations          string `json:"observations"`
}

StartSaleRequest is the request body for opening a new negotiation (sale).

This is one of the most complex endpoints in the API. Fields not shown in the documentation as structured objects are modelled as map[string]any to allow flexibility until the API provides a full schema.

type StartSaleResult

type StartSaleResult struct {
	ProtocolID int `json:"protocolId"`
}

StartSaleResult is the response payload for a new sale/negotiation.

type TitleAmount

type TitleAmount struct {
	Value      float64 `json:"value"`
	FinalValue float64 `json:"finalValue"`
	Discount   float64 `json:"discount"`
	Fine       float64 `json:"fine"`
	Interest   float64 `json:"interest"`
}

TitleAmount represents the financial amounts in a title/invoice.

type TitleBillet

type TitleBillet struct {
	BankTitleNumber *string     `json:"bankTitleNumber"`
	Balance         float64     `json:"balance"`
	Title           string      `json:"title"`
	IssueDate       string      `json:"issueDate"`
	ExpirationDate  string      `json:"expirationDate"`
	ProcessingDate  string      `json:"processingDate"`
	Amount          TitleAmount `json:"amount"`
}

TitleBillet represents a billing billet inside a title.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
}

TokenResponse is returned by all authentication endpoints.

type TrafficResponse

type TrafficResponse struct {
	Success     bool                      `json:"success"`
	Data        RegisterUserTrafficResult `json:"data"`
	Messages    []APIMessage              `json:"messages"`
	ElapsedTime float64                   `json:"elapsedTime"`
}

TrafficResponse wraps the traffic registration response.

type UpdateAddressRequest

type UpdateAddressRequest struct {
	ID              int     `json:"id"`
	City            string  `json:"city"`
	Complement      string  `json:"complement"`
	IBGECode        string  `json:"ibgeCode"`
	Neighborhood    string  `json:"neighborhood"`
	Number          string  `json:"number"`
	PeopleAddressID int     `json:"peopleAddressId"`
	PublicPlace     string  `json:"publicPlace"`
	Reference       string  `json:"reference"`
	State           string  `json:"state"`
	ZipCode         string  `json:"zipCode"`
	PropertyType    *string `json:"propertyType"`
	Lat             string  `json:"lat"`
	Lng             string  `json:"lng"`
}

UpdateAddressRequest is the request body for updating a customer's address.

type UpdateAddressResult

type UpdateAddressResult struct {
	PeopleAddressID int    `json:"peopleAddressId"`
	Message         string `json:"message"`
}

UpdateAddressResult is the response payload for address update.

type UpdateConnectionRequest

type UpdateConnectionRequest struct {
	ID                          int    `json:"id"`
	FiberMac                    string `json:"fiberMac"`
	Mac                         string `json:"mac"`
	Password                    string `json:"password"`
	EquipmentType               int    `json:"equipmentType"`
	OltID                       int    `json:"oltId"`
	SlotOlt                     int    `json:"slotOlt"`
	PortOlt                     int    `json:"portOlt"`
	EquipmentSerialNumber       string `json:"equipmentSerialNumber"`
	IPType                      int    `json:"ipType"`
	EquipmentUser               string `json:"equipmentUser"`
	EquipmentPassword           string `json:"equipmentPassword"`
	AuthenticationSplitterID    int    `json:"authenticationSplitterId"`
	Port                        int    `json:"port"`
	WifiName                    string `json:"wifiName"`
	WifiPassword                string `json:"wifiPassword"`
	TechnologyType              int    `json:"technologyType"`
	AuthenticationAccessPointID int    `json:"authenticationAccessPointId"`
	UpdateConnectionParameter   bool   `json:"updateConnectionParameter"`
	ShouldMacUpdate             bool   `json:"shouldMacUpdate"`
	User                        string `json:"user"`
	IsIPoE                      bool   `json:"isIPoE"`
	Complement                  string `json:"complement"`
}

UpdateConnectionRequest is the request body for updating a connection's technical data.

type UpdatePersonEmailRequest

type UpdatePersonEmailRequest struct {
	Email    string `json:"email"`
	EmailNfe string `json:"emailNfe"`
}

UpdatePersonEmailRequest contains email fields for person update.

type UpdatePersonPhoneRequest

type UpdatePersonPhoneRequest struct {
	Phone                string `json:"phone"`
	CellPhone            string `json:"cellPhone"`
	CellPhoneHasWhatsapp bool   `json:"cellPhoneHasWhatsapp"`
}

UpdatePersonPhoneRequest contains phone fields for person update.

type UpdatePersonRequest

type UpdatePersonRequest struct {
	ID    int                      `json:"id"`
	Email UpdatePersonEmailRequest `json:"email,omitempty"`
	Phone UpdatePersonPhoneRequest `json:"phone,omitempty"`
}

UpdatePersonRequest is the request body for updating a person's contact info.

type UpdatePersonResult

type UpdatePersonResult struct {
	PeopleAddressID int    `json:"peopleAddressId"`
	Message         string `json:"message"`
}

UpdatePersonResult is the response payload for person update.

type UseTypeItem

type UseTypeItem struct {
	Value int    `json:"value"`
	Label string `json:"label"`
}

UseTypeItem is a labeled enum value.

type VerifyViabilityRequest

type VerifyViabilityRequest struct {
	FullAddress ViabilityAddress  `json:"fullAddress"`
	Distance    string            `json:"distance"`
	Lead        ViabilityPerson   `json:"lead"`
	Seller      ViabilityPerson   `json:"seller"`
	Campaign    ViabilityCampaign `json:"campaign"`
}

VerifyViabilityRequest is the request body for checking address coverage viability.

type ViabilityAddress

type ViabilityAddress struct {
	Address      string `json:"address"`
	Number       string `json:"number"`
	Neighborhood string `json:"neighborhood"`
	City         string `json:"city"`
	State        string `json:"state"`
	PostalCode   string `json:"postalCode"`
}

ViabilityAddress holds address fields for a viability check.

type ViabilityCampaign

type ViabilityCampaign struct {
	ID          string `json:"id"`
	Description string `json:"description"`
}

ViabilityCampaign holds campaign reference data for a viability check.

type ViabilityPerson

type ViabilityPerson struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	TxIDType string `json:"txIdType"`
	TxID     string `json:"txId"`
	Phone    string `json:"phone"`
}

ViabilityPerson holds person reference data for a viability check.

type ViabilityResult

type ViabilityResult struct {
	Viability bool `json:"viability"`
	CTOs      int  `json:"ctos"`
	Ports     int  `json:"ports"`
}

ViabilityResult is the response payload for a viability check.

Directories

Path Synopsis
Package main demonstrates the complete usage of the elleven Go SDK.
Package main demonstrates the complete usage of the elleven Go SDK.
internal
retry
Package retry provides exponential backoff utilities for the elleven SDK.
Package retry provides exponential backoff utilities for the elleven SDK.

Jump to

Keyboard shortcuts

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