myle

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

myle-go

The official Go SDK of the Myle API: typed resources, one error type per error code (errors.As), auto-pagination with Go 1.23 iterators, idempotent retries, ETag / If-Match. Standard library only, Go ≥ 1.23. Generated from the API's OpenAPI document by sdk/generator (Apache-2.0).

SDK version 0.1.0, built against Myle-API-Version: 2026-11-21.

go get github.com/myleapp/myle-go
import "github.com/myleapp/myle-go"

client := myle.NewClient() // reads MYLE_API_KEY; or myle.NewClient(myle.WithAPIKey("…"))
me, err := client.Me.Get(ctx)
org := client.Organization("organization_…")

Five common tasks

List, page after page
params := &myle.ProductListParams{Status: []myle.ProductStatus{myle.ProductStatusActive}, Limit: myle.Int(200)}
for product, err := range org.Products.List(ctx, params).All() { // follows nextCursor
	if err != nil {
		return err
	}
	fmt.Println(product.Number, product.Name)
}

page, err := org.Products.List(ctx, nil).FirstPage() // one page: page.Data, page.HasMore(), page.NextPage()
firstThousand, err := org.Companies.List(ctx, &myle.CompanyListParams{Q: myle.String("gaec")}).CollectMax(1000)
Create
product, err := org.Products.Create(ctx, &myle.ProductCreateParams{
	Number:  "A0012",
	Name:    "Foin de prairie",
	VatRate: "5.5",
	Tags:    myle.Value([]string{"fourrage"}),
})

Every create sends an Idempotency-Key, generated once and reused by its retries: a create retried after a network error never creates twice. myle.IdempotencyKey("order-2026-0042") chooses it; product.LastResponse().IdempotentReplayed tells a replay.

Update only the version you read (If-Match)
product, err := org.Products.Get(ctx, "product_…")
updated, err := org.Products.Update(ctx, product.ID, &myle.ProductUpdateParams{
	Name:             myle.String("Foin de luzerne"), // sent
	AccountingNumber: myle.Null[string](),            // sent as null: cleared
	// a member left out is unchanged
}, myle.IfMatch(product)) // or myle.IfMatch(myle.ETag(`"3"`))
var stale *myle.CorePreconditionFailedError
if errors.As(err, &stale) {
	// someone changed it since: read it again
}
fmt.Println(updated.ETag())
Handle errors
_, err := org.Products.Barcodes.Create(ctx, "product_…", &myle.ProductBarcodeCreateParams{
	Value:  "3017620422003",
	Format: myle.BarcodeFormatEan13,
})
var duplicate *myle.ProductBarcodeDuplicateError
var conflict *myle.ConflictError
var apiErr *myle.APIError
var connErr *myle.ConnectionError
switch {
case errors.As(err, &duplicate): // the code's type, with its typed Context
	fmt.Println("already there:", duplicate.Context.Value)
case errors.As(err, &conflict): // its status's type
	fmt.Println(conflict.Code)
case errors.As(err, &apiErr): // any error answer
	fmt.Println(apiErr.Status, apiErr.Code, apiErr.Message, apiErr.RequestID)
case errors.As(err, &connErr): // no answer (*myle.TimeoutError for a timeout)
	fmt.Println(connErr)
}
Download an invoice's PDF
file, err := org.Invoices.DownloadPDF(ctx, "invoice_…", &myle.GetInvoicePDFParams{
	Format: myle.Value(myle.GetInvoicePDFFormatFacturx), // the Factur-X; the plain PDF by default
})
if err != nil {
	return err
}
err = file.Save(cmp.Or(file.Filename, "invoice.pdf"))

A method answering a file returns a *myle.FileDownload: Data (the bytes as received, never decoded), Filename (from Content-Disposition: filename*=UTF-8''… first, else filename, cut to its last path segment so it never names another directory; "" when the API sent none), ContentType and Response (status, headers, RequestID); Save(path) writes the bytes. It sends Accept: application/pdf, never an idempotency key nor If-Match; retries and typed errors are those of any call. The JSON Get keeps Accept: application/json.

The client

client := myle.NewClient(
	myle.WithAPIKey("…"),                     // default: MYLE_API_KEY (an organization or a user key, opaque)
	myle.WithAPIVersion("2026-11-21"),          // the Myle-API-Version sent; default: myle.APIVersion
	myle.WithBaseURL("https://api.myleapp.fr"), // default: MYLE_BASE_URL, else this
	myle.WithMaxRetries(2),                     // network errors, 429 and 5xx (when safe to repeat)
	myle.WithTimeout(60*time.Second),           // per attempt, the body included; 0 for none
	myle.WithAcceptLanguage("fr"),              // the language of error messages; English by default
	myle.WithHTTPClient(httpClient),            // a proxy, a custom transport
	myle.WithDeprecationHandler(func(n myle.DeprecationNotice) { log.Print(n) }), // nil: silent
)

Resources follow the API's paths: client.Organization(id).Products is /organizations/{id}/products, client.Me is /me. Every method takes a context.Context, the ids of its path, then its params (a pointer to its XxxParams struct, nil for none: the body's members and the list's filters together), then request options: myle.IfMatch, myle.IdempotencyKey where the operation takes them, myle.AcceptLanguage, myle.Header, myle.MaxRetries, myle.Timeout. The context bounds the whole call, retries included; its cancellation is returned as it is (context.Canceled).

Optional and null. A member of a request that may be left out is a myle.Opt[T]: its zero value is absent (not sent), myle.String("x") / myle.Int(3) / myle.Value(v) send a value, myle.Null[T]() sends null, which clears the member in a merge patch (Update). Required members are plain fields. In responses, a member that may be null is a pointer (*string, *myle.Money), a list is a slice.

Enums are open: myle.ProductStatus is a string type with known constants (myle.ProductStatusActive); a value this SDK does not know yet arrives as it is. Unknown members of an answer are ignored by the structs and kept in LastResponse().Body.

Errors

Every error answer of the API is returned as the type of its error code, which wraps the type of its HTTP status (*myle.ConflictError, *myle.NotFoundError…), which wraps *myle.APIError: errors.As matches at each level. Code is stable, Context is typed by the code, Message is the human sentence (French or English: never parse it), RequestID is what support asks for, RetryAfter is set when the API sent one. An unknown code arrives as its status's type. A network failure is a *myle.ConnectionError (*myle.TimeoutError for a timeout); a call needing a key without one returns myle.ErrMissingAPIKey before sending.

Code Status Type
core.bad-request 400 *myle.CoreBadRequestError
core.api-version-unsupported — *myle.CoreAPIVersionUnsupportedError
core.module-required 402 *myle.CoreModuleRequiredError
core.subscription-required 402 *myle.CoreSubscriptionRequiredError
core.plan-limit-reached 402 *myle.CorePlanLimitReachedError
core.not-found 404 *myle.CoreNotFoundError
core.method-not-allowed 405 *myle.CoreMethodNotAllowedError
core.not-acceptable 406 *myle.CoreNotAcceptableError
core.conflict 409 *myle.CoreConflictError
core.precondition-failed 412 *myle.CorePreconditionFailedError
core.payload-too-large 413 *myle.CorePayloadTooLargeError
core.unsupported-media-type 415 *myle.CoreUnsupportedMediaTypeError
core.validation-failed 422 *myle.CoreValidationFailedError
core.idempotency-key-reused 422 *myle.CoreIdempotencyKeyReusedError
core.idempotency-key-in-use 409 *myle.CoreIdempotencyKeyInUseError
core.rate-limited 429 *myle.CoreRateLimitedError
core.internal-error 500 *myle.CoreInternalError
core.bad-gateway 502 *myle.CoreBadGatewayError
core.unavailable 503 *myle.CoreUnavailableError
auth.credential.missing 401 *myle.AuthCredentialMissingError
auth.credential.invalid 401 *myle.AuthCredentialInvalidError
auth.credential.expired 401 *myle.AuthCredentialExpiredError
auth.credential.revoked 401 *myle.AuthCredentialRevokedError
auth.right.missing 403 *myle.AuthRightMissingError
auth.email.unconfirmed 403 *myle.AuthEmailUnconfirmedError
auth.session.refused 403 *myle.AuthSessionRefusedError
auth.api-key.organization-not-allowed 403 *myle.AuthAPIKeyOrganizationNotAllowedError
auth.session.required 403 *myle.AuthSessionRequiredError
auth.step-up.required 403 *myle.AuthStepUpRequiredError
auth.api-key.limit-reached 409 *myle.AuthAPIKeyLimitReachedError
products.barcode.duplicate 409 *myle.ProductBarcodeDuplicateError
products.barcode.outside-company-prefix 422 *myle.ProductBarcodeOutsideCompanyPrefixError
crm.company.identifier-required 422 *myle.CrmCompanyIdentifierRequiredError
crm.company.invalid-identifier 422 *myle.CrmCompanyInvalidIdentifierError
crm.company.invalid-siret 422 *myle.CrmCompanyInvalidSiretError
crm.company.accounting-number-taken 409 *myle.CrmCompanyAccountingNumberTakenError
crm.postal-address.referenced 409 *myle.CrmPostalAddressReferencedError
billing.invoice.not-a-draft 409 *myle.BillingInvoiceNotADraftError
billing.invoice.stripe-imported 409 *myle.BillingInvoiceStripeImportedError
billing.invoice.foreign-product 422 *myle.BillingInvoiceForeignProductError
billing.invoice.out-of-scope-reference 422 *myle.BillingInvoiceOutOfScopeReferenceError
billing.invoice.partial-credit-note 409 *myle.BillingInvoicePartialCreditNoteError
billing.invoice.facturx-unavailable 409 *myle.BillingInvoiceFacturxUnavailableError
billing.invoice.not-payable 409 *myle.BillingInvoiceNotPayableError
billing.invoice.already-paid 409 *myle.BillingInvoiceAlreadyPaidError
billing.invoice.credit-note-linked 409 *myle.BillingInvoiceCreditNoteLinkedError
billing.payment.not-removable 409 *myle.BillingPaymentNotRemovableError
billing.payment.stripe-collected 409 *myle.BillingPaymentStripeCollectedError
billing.invoice.not-creditable 409 *myle.BillingInvoiceNotCreditableError
billing.invoice.already-credited 409 *myle.BillingInvoiceAlreadyCreditedError
billing.invoice.deposit-deducted 409 *myle.BillingInvoiceDepositDeductedError
billing.invoice.einvoice-required 409 *myle.BillingInvoiceEinvoiceRequiredError
billing.invoice.recipient-unsubscribed — *myle.BillingInvoiceRecipientUnsubscribedError
billing.invoice.transition-refused 409 *myle.BillingInvoiceTransitionRefusedError
billing.invoice.generated-credit-note 409 *myle.BillingInvoiceGeneratedCreditNoteError
billing.invoice.not-editable 409 *myle.BillingInvoiceNotEditableError
billing.invoice.not-reinvoiceable 409 *myle.BillingInvoiceNotReinvoiceableError
billing.invoice.already-reinvoiced 409 *myle.BillingInvoiceAlreadyReinvoicedError
billing.invoice.not-a-credit-note 409 *myle.BillingInvoiceNotACreditNoteError
billing.invoice.correction-fixed 409 *myle.BillingInvoiceCorrectionFixedError
billing.invoice.not-correctable 409 *myle.BillingInvoiceNotCorrectableError
billing.invoice.not-duplicable — *myle.BillingInvoiceNotDuplicableError
quotations.quotation.transition-refused 409 *myle.QuotationQuotationTransitionRefusedError
quotations.quotation.not-extendable 409 *myle.QuotationQuotationNotExtendableError
quotations.quotation.converted 409 *myle.QuotationQuotationConvertedError
quotations.quotation.already-invoiced 409 *myle.QuotationQuotationAlreadyInvoicedError
quotations.quotation.has-deposits 409 *myle.QuotationQuotationHasDepositsError
quotations.quotation.not-editable 409 *myle.QuotationQuotationNotEditableError
quotations.quotation.foreign-product 422 *myle.QuotationQuotationForeignProductError
quotations.quotation.out-of-scope-reference 422 *myle.QuotationQuotationOutOfScopeReferenceError
quotations.quotation.recipient-unsubscribed — *myle.QuotationQuotationRecipientUnsubscribedError
orders.order.transition-refused 409 *myle.OrderOrderTransitionRefusedError
orders.order.not-deletable 409 *myle.OrderOrderNotDeletableError
orders.order.not-editable 409 *myle.OrderOrderNotEditableError
orders.order.foreign-product 422 *myle.OrderOrderForeignProductError
orders.order.out-of-scope-reference 422 *myle.OrderOrderOutOfScopeReferenceError
orders.order.already-invoiced 409 *myle.OrderOrderAlreadyInvoicedError
orders.order.has-deposits 409 *myle.OrderOrderHasDepositsError
orders.order.shop-billed 409 *myle.OrderOrderShopBilledError
orders.order.recipient-unsubscribed — *myle.OrderOrderRecipientUnsubscribedError
einvoicing.organization.paid-plan-required 402 *myle.EinvoicingOrganizationPaidPlanRequiredError
einvoicing.organization.not-subject 409 *myle.EinvoicingOrganizationNotSubjectError
einvoicing.connection.not-connected 409 *myle.EinvoicingConnectionNotConnectedError
einvoicing.routing-address.not-published 422 *myle.EinvoicingRoutingAddressNotPublishedError
einvoicing.einvoice.not-eligible 409 *myle.EinvoicingEinvoiceNotEligibleError
einvoicing.einvoice.not-retryable 409 *myle.EinvoicingEinvoiceNotRetryableError
einvoicing.einvoice.credit-note-reference-missing 409 *myle.EinvoicingEinvoiceCreditNoteReferenceMissingError
einvoicing.incoming-einvoice.already-settled 409 *myle.EinvoicingIncomingEinvoiceAlreadySettledError
einvoicing.incoming-einvoice.not-on-platform 409 *myle.EinvoicingIncomingEinvoiceNotOnPlatformError
einvoicing.incoming-einvoice.not-accepted 409 *myle.EinvoicingIncomingEinvoiceNotAcceptedError
payments.account.not-connected 409 *myle.PaymentAccountNotConnectedError
payments.account.demo 409 *myle.PaymentAccountDemoError
payments.account.suspended 409 *myle.PaymentAccountSuspendedError
payments.collection.disabled 409 *myle.PaymentCollectionDisabledError
payments.collection.paused 409 *myle.PaymentCollectionPausedError
payments.plan.collection-required 402 *myle.PaymentPlanCollectionRequiredError
payments.mandate.missing 409 *myle.PaymentMandateMissingError
payments.mandate.foreign-iban 409 *myle.PaymentMandateForeignIbanError
payments.mandate.invitations-throttled 429 *myle.PaymentMandateInvitationsThrottledError
payments.debit.not-debitable 409 *myle.PaymentDebitNotDebitableError
payments.debit.nothing-due 409 *myle.PaymentDebitNothingDueError
payments.debit.below-minimum 409 *myle.PaymentDebitBelowMinimumError
payments.debit.above-maximum 409 *myle.PaymentDebitAboveMaximumError
payments.debit.quota-reached 409 *myle.PaymentDebitQuotaReachedError
payments.refund.nothing-to-refund 409 *myle.PaymentRefundNothingToRefundError

Retries, concurrency, versions

  • Retries (WithMaxRetries, 2 by default): network errors and 5xx when the call is safe to repeat (GET, PUT, DELETE, or a write with an idempotency key); 429 always, after Retry-After (seconds or an HTTP date; one above 60 s is not waited for, the error is returned with RetryAfter); backoff with jitter.
  • Every single resource has ETag() and LastResponse(). Pass it to myle.IfMatch on Update / Delete: if someone changed it since, the call returns *myle.CorePreconditionFailedError (412) and changes nothing.
  • Each SDK release pins the contract date it was generated against (myle.APIVersion, 2026-11-21 here) and sends it as Myle-API-Version: an API change never changes what this code receives. When the API answers an operation with a deprecated behavior (Deprecation, Sunset), the deprecation handler is called once per operation (a line on the standard logger by default).

Methods

client.Rights
Method HTTP Summary
List(ctx) GET /rights List the rights
client.Products
Method HTTP Summary
Search(ctx, params) GET /products Search the products across organizations
client.Companies
Method HTTP Summary
Search(ctx, params) GET /companies Search the companies across organizations
client.Invoices
Method HTTP Summary
Search(ctx, params) GET /invoices Search the invoices across organizations
client.Quotations
Method HTTP Summary
Search(ctx, params) GET /quotations Search the quotations across organizations
client.Orders
Method HTTP Summary
Search(ctx, params) GET /orders Search the orders across organizations
client.Me
Method HTTP Summary
Get(ctx) GET /me Get the signed-in user
client.Me.APIKeys
Method HTTP Summary
List(ctx) GET /me/api-keys List my API keys
Create(ctx, params) POST /me/api-keys Create a user key
Get(ctx, apiKeyID, params) GET /me/api-keys/{apiKeyId} Get one of my API keys
Revoke(ctx, apiKeyID) DELETE /me/api-keys/{apiKeyId} Revoke one of my API keys
Update(ctx, apiKeyID, params) PATCH /me/api-keys/{apiKeyId} Change one of my API keys
Rotate(ctx, apiKeyID) POST /me/api-keys/{apiKeyId}/rotate Rotate one of my API keys
client.Organization(id)
Method HTTP Summary
Get(ctx) GET /organizations/{id} Get an organization
client.Organization(id).APIKeys
Method HTTP Summary
List(ctx) GET /organizations/{id}/api-keys List the organization's API keys
Create(ctx, params) POST /organizations/{id}/api-keys Create an organization key
Get(ctx, apiKeyID) GET /organizations/{id}/api-keys/{apiKeyId} Get one of the organization's API keys
Revoke(ctx, apiKeyID) DELETE /organizations/{id}/api-keys/{apiKeyId} Revoke one of the organization's API keys
Update(ctx, apiKeyID, params) PATCH /organizations/{id}/api-keys/{apiKeyId} Change one of the organization's API keys
Rotate(ctx, apiKeyID) POST /organizations/{id}/api-keys/{apiKeyId}/rotate Rotate one of the organization's API keys
client.Organization(id).Products
Method HTTP Summary
List(ctx, params) GET /organizations/{id}/products List the products
Create(ctx, params) POST /organizations/{id}/products Create a product
ListTags(ctx) GET /organizations/{id}/products/tags List the products' tags
Get(ctx, productID) GET /organizations/{id}/products/{productId} Get a product
Delete(ctx, productID) DELETE /organizations/{id}/products/{productId} Delete a product
Update(ctx, productID, params) PATCH /organizations/{id}/products/{productId} Change a product
GetNeighbors(ctx, productID, params) GET /organizations/{id}/products/{productId}/neighbors Get a product's neighbors in the list
client.Organization(id).Products.Barcodes
Method HTTP Summary
Create(ctx, productID, params) POST /organizations/{id}/products/{productId}/barcodes Add a barcode to a product
Get(ctx, productID, barcodeID) GET /organizations/{id}/products/{productId}/barcodes/{barcodeId} Get a barcode of a product
Delete(ctx, productID, barcodeID) DELETE /organizations/{id}/products/{productId}/barcodes/{barcodeId} Remove a barcode from a product
Update(ctx, productID, barcodeID, params) PATCH /organizations/{id}/products/{productId}/barcodes/{barcodeId} Change a barcode of a product
client.Organization(id).Companies
Method HTTP Summary
ListTags(ctx) GET /organizations/{id}/companies/tags List the companies' tags
GetNeighbors(ctx, companyID, params) GET /organizations/{id}/companies/{companyId}/neighbors Get a company's neighbors in a list
List(ctx, params) GET /organizations/{id}/companies List the companies
Create(ctx, params) POST /organizations/{id}/companies Create a company
Get(ctx, companyID) GET /organizations/{id}/companies/{companyId} Get a company
Delete(ctx, companyID) DELETE /organizations/{id}/companies/{companyId} Delete a company
Update(ctx, companyID, params) PATCH /organizations/{id}/companies/{companyId} Change a company
GetEinvoicingRouting(ctx, companyID) GET /organizations/{id}/companies/{companyId}/einvoicing-routing Get a customer's e-invoicing routing
ReplaceEinvoicingRouting(ctx, companyID, params) PUT /organizations/{id}/companies/{companyId}/einvoicing-routing Choose a customer's electronic address
GetSepaMandate(ctx, companyID) GET /organizations/{id}/companies/{companyId}/sepa-mandate Get a customer's SEPA mandate
client.Organization(id).Companies.EmailAddresses
Method HTTP Summary
Create(ctx, companyID, params) POST /organizations/{id}/companies/{companyId}/email-addresses Add an e-mail address to a company
Delete(ctx, companyID, companyEmailAddressID) DELETE /organizations/{id}/companies/{companyId}/email-addresses/{companyEmailAddressId} Remove an e-mail address from a company
Update(ctx, companyID, companyEmailAddressID, params) PATCH /organizations/{id}/companies/{companyId}/email-addresses/{companyEmailAddressId} Change an e-mail address of a company
Resubscribe(ctx, companyID, companyEmailAddressID) POST /organizations/{id}/companies/{companyId}/email-addresses/{companyEmailAddressId}/resubscribe Subscribe an e-mail address of a company again
client.Organization(id).Companies.PostalAddresses
Method HTTP Summary
Create(ctx, companyID, params) POST /organizations/{id}/companies/{companyId}/postal-addresses Add a postal address to a company
Get(ctx, companyID, postalAddressID) GET /organizations/{id}/companies/{companyId}/postal-addresses/{postalAddressId} Get a postal address of a company
Delete(ctx, companyID, postalAddressID) DELETE /organizations/{id}/companies/{companyId}/postal-addresses/{postalAddressId} Remove a postal address from a company
Update(ctx, companyID, postalAddressID, params) PATCH /organizations/{id}/companies/{companyId}/postal-addresses/{postalAddressId} Change a postal address of a company
client.Organization(id).Companies.SepaMandate
Method HTTP Summary
CreateInvitation(ctx, companyID, params) POST /organizations/{id}/companies/{companyId}/sepa-mandate/invitation Invite a customer to sign a SEPA mandate
Revoke(ctx, companyID) POST /organizations/{id}/companies/{companyId}/sepa-mandate/revoke Revoke a customer's SEPA mandate
client.Organization(id).Invoices
Method HTTP Summary
List(ctx, params) GET /organizations/{id}/invoices List the invoices
Create(ctx, params) POST /organizations/{id}/invoices Create a draft invoice
ListTags(ctx) GET /organizations/{id}/invoices/tags List the invoices' tags
GetEligibility(ctx, params) GET /organizations/{id}/invoices/eligibility Count what each batch would act on
Get(ctx, invoiceID) GET /organizations/{id}/invoices/{invoiceId} Get an invoice
DownloadPDF(ctx, invoiceID, params) GET /organizations/{id}/invoices/{invoiceId} (Accept: application/pdf) Get an invoice as a PDF file
Delete(ctx, invoiceID) DELETE /organizations/{id}/invoices/{invoiceId} Delete a draft invoice
Update(ctx, invoiceID, params) PATCH /organizations/{id}/invoices/{invoiceId} Change a draft invoice
GetNeighbors(ctx, invoiceID, params) GET /organizations/{id}/invoices/{invoiceId}/neighbors Get an invoice's neighbors in the list
Validate(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/validate Validate an invoice
BatchValidate(ctx, params) POST /organizations/{id}/invoices/batch-validate Validate several invoices
BatchShare(ctx, params) POST /organizations/{id}/invoices/batch-share Mark several invoices as handed to their customers
BatchCreatePayments(ctx, params) POST /organizations/{id}/invoices/batch-payments Record payments on several invoices
BatchCreateCreditNotes(ctx, params) POST /organizations/{id}/invoices/batch-credit-notes Cancel several invoices with credit notes
BatchDuplicate(ctx, params) POST /organizations/{id}/invoices/batch-duplicate Duplicate several invoices as drafts
Send(ctx, invoiceID, params) POST /organizations/{id}/invoices/{invoiceId}/send Send an invoice by e-mail
Edit(ctx, invoiceID, params) POST /organizations/{id}/invoices/{invoiceId}/edit Change a draft's lines, customer or description
GetEditability(ctx, invoiceID) GET /organizations/{id}/invoices/{invoiceId}/editability Tell whether a draft can still be changed
Share(ctx, invoiceID, params) POST /organizations/{id}/invoices/{invoiceId}/share Mark an invoice as handed to its customer
MarkLost(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/mark-lost Write an invoice off as lost
Unpay(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/unpay Take an invoice back to unpaid
Reinvoice(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/reinvoice Re-bill a credit note as a new draft
SetCorrectedInvoice(ctx, invoiceID, params) POST /organizations/{id}/invoices/{invoiceId}/set-corrected-invoice Name the invoice a credit note corrects
GetEinvoice(ctx, invoiceID) GET /organizations/{id}/invoices/{invoiceId}/einvoice Get an invoice's e-invoice
SubmitEinvoice(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/submit-einvoice Submit an invoice through the e-invoicing network
Debit(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/debit Debit an invoice by SEPA
Refund(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/refund Refund an invoice's Stripe payments
GetPaymentStatus(ctx, invoiceID) GET /organizations/{id}/invoices/{invoiceId}/payment-status Get an invoice's payment status
client.Organization(id).Invoices.CreditNotes
Method HTTP Summary
Create(ctx, invoiceID) POST /organizations/{id}/invoices/{invoiceId}/credit-notes Cancel an invoice with a credit note
client.Organization(id).Invoices.CorrectableInvoices
Method HTTP Summary
List(ctx, invoiceID, params) GET /organizations/{id}/invoices/{invoiceId}/correctable-invoices List the invoices a credit note can correct
client.Organization(id).Invoices.StatusHistory
Method HTTP Summary
List(ctx, invoiceID) GET /organizations/{id}/invoices/{invoiceId}/status-history List an invoice's status history
client.Organization(id).Invoices.Payments
Method HTTP Summary
List(ctx, invoiceID) GET /organizations/{id}/invoices/{invoiceId}/payments List an invoice's payments
Create(ctx, invoiceID, params) POST /organizations/{id}/invoices/{invoiceId}/payments Record a payment on an invoice
Get(ctx, invoiceID, paymentID) GET /organizations/{id}/invoices/{invoiceId}/payments/{paymentId} Get a payment of an invoice
Delete(ctx, invoiceID, paymentID) DELETE /organizations/{id}/invoices/{invoiceId}/payments/{paymentId} Remove a payment of an invoice
client.Organization(id).Quotations
Method HTTP Summary
List(ctx, params) GET /organizations/{id}/quotations List the quotations
Create(ctx, params) POST /organizations/{id}/quotations Create a quotation
ListTags(ctx) GET /organizations/{id}/quotations/tags List the quotations' tags
GetEligibility(ctx, params) GET /organizations/{id}/quotations/eligibility Count what each batch would act on
Get(ctx, quotationID) GET /organizations/{id}/quotations/{quotationId} Get a quotation
DownloadPDF(ctx, quotationID) GET /organizations/{id}/quotations/{quotationId} (Accept: application/pdf) Get a quotation as a PDF file
Delete(ctx, quotationID) DELETE /organizations/{id}/quotations/{quotationId} Delete a quotation
Update(ctx, quotationID, params) PATCH /organizations/{id}/quotations/{quotationId} Change a quotation
GetNeighbors(ctx, quotationID, params) GET /organizations/{id}/quotations/{quotationId}/neighbors Get a quotation's neighbors in the list
Edit(ctx, quotationID, params) POST /organizations/{id}/quotations/{quotationId}/edit Change a quotation's lines, customer or description
GetEditability(ctx, quotationID) GET /organizations/{id}/quotations/{quotationId}/editability Tell whether a quotation can still be changed
Share(ctx, quotationID) POST /organizations/{id}/quotations/{quotationId}/share Mark a quotation as handed to its customer
Approve(ctx, quotationID) POST /organizations/{id}/quotations/{quotationId}/approve Record that the customer accepted a quotation
BatchShare(ctx, params) POST /organizations/{id}/quotations/batch-share Mark several quotations as handed to their customers
BatchApprove(ctx, params) POST /organizations/{id}/quotations/batch-approve Record that customers accepted several quotations
BatchOrder(ctx, params) POST /organizations/{id}/quotations/batch-order Turn several accepted quotations into orders
Cancel(ctx, quotationID) POST /organizations/{id}/quotations/{quotationId}/cancel Cancel a quotation (refused or withdrawn)
Extend(ctx, quotationID, params) POST /organizations/{id}/quotations/{quotationId}/extend Extend a quotation's validity
Order(ctx, quotationID) POST /organizations/{id}/quotations/{quotationId}/order Turn an accepted quotation into an order
Invoice(ctx, quotationID) POST /organizations/{id}/quotations/{quotationId}/invoice Bill an accepted quotation
Send(ctx, quotationID, params) POST /organizations/{id}/quotations/{quotationId}/send Send a quotation by e-mail
client.Organization(id).Quotations.StatusHistory
Method HTTP Summary
List(ctx, quotationID) GET /organizations/{id}/quotations/{quotationId}/status-history List a quotation's status history
client.Organization(id).Orders
Method HTTP Summary
List(ctx, params) GET /organizations/{id}/orders List the orders
Create(ctx, params) POST /organizations/{id}/orders Create an order
ListTags(ctx) GET /organizations/{id}/orders/tags List the orders' tags
GetEligibility(ctx, params) GET /organizations/{id}/orders/eligibility Count what each batch would act on
Get(ctx, orderID) GET /organizations/{id}/orders/{orderId} Get an order
DownloadPDF(ctx, orderID) GET /organizations/{id}/orders/{orderId} (Accept: application/pdf) Get an order as a PDF file
Delete(ctx, orderID) DELETE /organizations/{id}/orders/{orderId} Delete an order
Update(ctx, orderID, params) PATCH /organizations/{id}/orders/{orderId} Change an order
GetNeighbors(ctx, orderID, params) GET /organizations/{id}/orders/{orderId}/neighbors Get an order's neighbors in the list
Edit(ctx, orderID, params) POST /organizations/{id}/orders/{orderId}/edit Change an order's lines, customer, delivery address or description
GetEditability(ctx, orderID) GET /organizations/{id}/orders/{orderId}/editability Tell whether an order can still be changed
Share(ctx, orderID) POST /organizations/{id}/orders/{orderId}/share Mark an order as handed to its customer
Approve(ctx, orderID) POST /organizations/{id}/orders/{orderId}/approve Record that the customer confirmed an order
MarkWaitingForDelivery(ctx, orderID) POST /organizations/{id}/orders/{orderId}/mark-waiting-for-delivery Mark an order as prepared, waiting for its delivery
Cancel(ctx, orderID) POST /organizations/{id}/orders/{orderId}/cancel Cancel an order
BatchShare(ctx, params) POST /organizations/{id}/orders/batch-share Mark several orders as handed to their customers
BatchApprove(ctx, params) POST /organizations/{id}/orders/batch-approve Record that customers confirmed several orders
GetStockAvailability(ctx, orderID) GET /organizations/{id}/orders/{orderId}/stock-availability List the stocks an order's goods can leave from
Deliver(ctx, orderID, params) POST /organizations/{id}/orders/{orderId}/deliver Deliver an order: make its delivery note
Invoice(ctx, orderID, params) POST /organizations/{id}/orders/{orderId}/invoice Bill an order
Send(ctx, orderID, params) POST /organizations/{id}/orders/{orderId}/send Send an order by e-mail
client.Organization(id).Orders.StatusHistory
Method HTTP Summary
List(ctx, orderID) GET /organizations/{id}/orders/{orderId}/status-history List an order's status history
client.Organization(id).DeliveryNotes
Method HTTP Summary
Get(ctx, deliveryNoteID) GET /organizations/{id}/delivery-notes/{deliveryNoteId} Get a delivery note
client.Organization(id).Einvoicing
Method HTTP Summary
Get(ctx) GET /organizations/{id}/einvoicing Get the organization's e-invoicing
Connect(ctx) POST /organizations/{id}/einvoicing/connect Start connecting the organization to SuperPDP
Disconnect(ctx) POST /organizations/{id}/einvoicing/disconnect Disconnect the organization from SuperPDP
Sync(ctx) POST /organizations/{id}/einvoicing/sync Read the verification statuses from SuperPDP
GetAddress(ctx) GET /organizations/{id}/einvoicing/address Get the organization's electronic address
ReplaceAddress(ctx, params) PUT /organizations/{id}/einvoicing/address Choose the organization's electronic address
client.Organization(id).Einvoices
Method HTTP Summary
ListOutgoingFailures(ctx) GET /organizations/{id}/einvoices/outgoing-failures List the failed submissions
client.Organization(id).IncomingEinvoices
Method HTTP Summary
List(ctx, params) GET /organizations/{id}/incoming-einvoices List the incoming e-invoices
Get(ctx, incomingEinvoiceID) GET /organizations/{id}/incoming-einvoices/{incomingEinvoiceId} Get an incoming e-invoice
DownloadPDF(ctx, incomingEinvoiceID) GET /organizations/{id}/incoming-einvoices/{incomingEinvoiceId} (Accept: application/pdf) Get an incoming e-invoice as a PDF file
DownloadXML(ctx, incomingEinvoiceID) GET /organizations/{id}/incoming-einvoices/{incomingEinvoiceId} (Accept: application/xml) Get an incoming e-invoice as a XML file
Accept(ctx, incomingEinvoiceID) POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/accept Accept an incoming e-invoice
Refuse(ctx, incomingEinvoiceID, params) POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/refuse Refuse an incoming e-invoice
Dispute(ctx, incomingEinvoiceID, params) POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/dispute Dispute an incoming e-invoice
AcceptPartially(ctx, incomingEinvoiceID, params) POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/accept-partially Accept an incoming e-invoice in part
MarkPaid(ctx, incomingEinvoiceID, params) POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/mark-paid Mark an incoming e-invoice paid
client.Organization(id).PaymentsAccount
Method HTTP Summary
Get(ctx) GET /organizations/{id}/payments-account Get the organization's Stripe account
StartOnboarding(ctx, params) POST /organizations/{id}/payments-account/onboarding Start or resume the Stripe onboarding
CreateDashboardLink(ctx) POST /organizations/{id}/payments-account/dashboard-link Open the Stripe dashboard
GetOnlinePaymentSetting(ctx) GET /organizations/{id}/payments-account/online-payment Get the online payment of invoices
ReplaceOnlinePaymentSetting(ctx, params) PUT /organizations/{id}/payments-account/online-payment Turn the online payment of invoices on or off
ListSepaFees(ctx, params) GET /organizations/{id}/payments-account/sepa-fees List the SEPA debits' fees
GetSepaQuota(ctx) GET /organizations/{id}/payments-account/sepa-quota Get the SEPA quota

Documentation

Overview

Package myle is the official Go SDK of the Myle API (https://developers.myleapp.fr): typed resources, one error type per error code, auto-pagination with iterators, idempotent retries, ETag / If-Match. Standard library only. Generated from the API's OpenAPI document by sdk/generator.

This is version 0.1.0 of the SDK, built against Myle-API-Version 2026-11-21 (APIVersion).

client := myle.NewClient() // reads MYLE_API_KEY; or myle.NewClient(myle.WithAPIKey("…"))
me, err := client.Me.Get(ctx)
org := client.Organization("organization_…")
for product, err := range org.Products.List(ctx, nil).All() {
	if err != nil {
		return err
	}
	fmt.Println(product.Number, product.Name)
}

Resources follow the API's paths: client.Organization(id).Products is /organizations/{id}/products, client.Me is /me. Every method takes a context, the ids of its path, then its params (a pointer to its XxxParams struct, nil for none), then request options (IfMatch, IdempotencyKey, AcceptLanguage, Header, MaxRetries, Timeout).

Optional members of a request are Opt values: left out unless set, myle.Null sends null (a merge patch clears the member). Members of a response that may be null are pointers.

Errors are typed: errors.As matches the error code's type (*ProductBarcodeDuplicateError), its status's (*ConflictError) and *APIError; a network failure is a *ConnectionError (*TimeoutError).

Index

Examples

Constants

View Source
const APIVersion = "2026-11-21"

APIVersion is the contract date this SDK was generated against, sent as Myle-API-Version by default.

View Source
const Version = "0.1.0"

Version is the version of this SDK, sent as Myle-Client: sdk-go/<Version>.

Variables

View Source
var ErrMissingAPIKey = errors.New("myle: no API key: pass myle.WithAPIKey to NewClient or set the MYLE_API_KEY environment variable")

ErrMissingAPIKey is returned, before anything is sent, by a call that needs a credential when the client has no API key: pass WithAPIKey or set MYLE_API_KEY.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	// Status is the HTTP status: 404, 409…
	Status int
	// Code is the error code, <module>.<area>.<reason>: products.barcode.duplicate. Stable: branch on it.
	Code string
	// Message is the human sentence of the error (the envelope's error member).
	Message string
	// RequestID is the request's id in Myle's logs (request_id, or the Myle-Request-Id header).
	RequestID string
	// RawContext is the detail of the error as received ({} when it has none); the type of a known code carries
	// it decoded, as Context.
	RawContext json.RawMessage
	// Header holds the response's headers.
	Header http.Header
	// Body is the response's body, as received.
	Body []byte
	// RetryAfter is Retry-After when the API sent one (429, 503, 409 core.idempotency-key-in-use), else nil.
	RetryAfter *time.Duration
}

APIError is an error answered by the Myle API. Branch on Code (or match the code's type with errors.As), show Message to a person (French or English, from the Accept-Language): never parse it. Give RequestID to Myle's support.

var duplicate *myle.ProductBarcodeDuplicateError
var apiErr *myle.APIError
switch {
case errors.As(err, &duplicate):
	fmt.Println("already there:", duplicate.Context.Value)
case errors.As(err, &apiErr):
	fmt.Println(apiErr.Status, apiErr.Code, apiErr.Message, apiErr.RequestID)
}
Example
package main

import (
	"context"
	"errors"
	"fmt"

	myle "github.com/myleapp/myle-go"
)

func main() {
	org := myle.NewClient().Organization("organization_…")
	_, err := org.Products.Barcodes.Create(context.Background(), "product_…", &myle.ProductBarcodeCreateParams{
		Value:  "3017620422003",
		Format: myle.BarcodeFormatEan13,
	})
	var duplicate *myle.ProductBarcodeDuplicateError
	var apiErr *myle.APIError
	switch {
	case errors.As(err, &duplicate):
		fmt.Println("already there:", duplicate.Context.Value)
	case errors.As(err, &apiErr):
		fmt.Println(apiErr.Status, apiErr.Code, apiErr.Message, apiErr.RequestID)
	}
}

func (*APIError) Error

func (e *APIError) Error() string

type APIKey

type APIKey struct {
	// The key's id (apiKey_<ulid>).
	ID string `json:"id"`
	// Always "apiKey".
	Object string `json:"object"`
	// USER or ORGANIZATION.
	Kind string `json:"kind"`
	// The key's name.
	Name string `json:"name"`
	// What can be shown of the token after its creation: its kind, the start of its id, its end.
	DisplayToken string `json:"displayToken"`
	// The organizations the key acts in: an organization key's own; for a user key, the ones it is narrowed to, or
	// null for every organization of its owner.
	OrganizationIDs []string `json:"organizationIds"`
	// An organization key's role (the role's rights apply, live), or null.
	RoleID *string `json:"roleId"`
	// An organization key's direct rights; for a user key, the list its owner's rights are narrowed to, or null for
	// every right of its owner.
	Rights []string `json:"rights"`
	// An organization key's tag scope ({category: [tags]}), or null (its role's, else none).
	TagScope any `json:"tagScope"`
	// What the key may do: an organization key's role ∪ direct rights; a user key's, in the organization of
	// ?organizationId= only, else null.
	EffectiveRights []string `json:"effectiveRights"`
	// Who did something: a person (USER) or the robot account of an organization API key (ROBOT), which acts in the
	// key's name.
	Actor Author `json:"actor"`
	// Who did something: a person (USER) or the robot account of an organization API key (ROBOT), which acts in the
	// key's name.
	CreatedBy *Author `json:"createdBy"`
	// When the key stops working (RFC 3339, UTC), or null if it never expires.
	ExpiresAt *string `json:"expiresAt"`
	// When the key was last used, to the minute (RFC 3339, UTC), or null.
	LastUsedAt *string `json:"lastUsedAt"`
	// When the key was revoked (RFC 3339, UTC), or null.
	RevokedAt *string `json:"revokedAt"`
	// Why: USER_REVOKED, ADMIN_REVOKED, OWNER_LEFT, OWNER_DEACTIVATED, EXPIRED, LEAKED; or null.
	RevokedReason *string `json:"revokedReason"`
	// The key that replaced this one by a rotation, or null.
	ReplacedByID *string `json:"replacedById"`
	// When the key was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// The full token, to send as Authorization: Bearer <token>. Only in the 201 answer of a creation or a rotation:
	// Myle never shows it again.
	Token *string `json:"token,omitempty"`
	// contains filtered or unexported fields
}

APIKey — An API key: a credential for a program. A user key (USER) acts as its owner, with the owner's live rights; an organization key (ORGANIZATION) acts as its own robot account (ROBOT), with the rights configured on it. actor is who it acts as; createdBy who created it (for a rotated key, who rotated it: always a USER), or null.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (APIKey) ETag

func (m APIKey) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (APIKey) LastResponse

func (m APIKey) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type APIKeyCreateParams

type APIKeyCreateParams struct {
	// The key's name (« Export comptable Sage »), 1 to 200 characters; also its robot account's name.
	Name string `json:"name"`
	// ONE_HOUR, THIRTY_DAYS, NINETY_DAYS, ONE_YEAR (the default) or NEVER.
	ExpiresIn Opt[string] `json:"expiresIn"`
	// One of the organization's roles, whose rights you hold all; or null.
	RoleID Opt[string] `json:"roleId"`
	// Direct rights (RightType names), added to the role's; each one you hold yourself.
	Rights Opt[[]string] `json:"rights"`
	// A tag scope ({category: [tags]}), over the role's; or null.
	TagScope Opt[any] `json:"tagScope"`
}

APIKeyCreateParams is the parameters of APIKeysService.Create (createApiKey): its body's members. A nil *APIKeyCreateParams sends none.

A new organization key, configured like a member: a role and/or direct rights, a tag scope.

A member of type Opt is left out unless set.

func (APIKeyCreateParams) MarshalJSON

func (p APIKeyCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type APIKeyUpdateParams

type APIKeyUpdateParams struct {
	// A new name, also given to its robot account.
	Name Opt[string] `json:"name"`
	// One of the organization's roles, whose rights you hold all; null for none.
	RoleID Opt[string] `json:"roleId"`
	// Its direct rights; what you change must be rights you hold; null for none.
	Rights Opt[[]string] `json:"rights"`
	// Its tag scope ({category: [tags]}); null for none (its role's).
	TagScope Opt[any] `json:"tagScope"`
}

APIKeyUpdateParams is the parameters of APIKeysService.Update (updateApiKey): its body's members. A nil *APIKeyUpdateParams sends none.

A merge patch of an organization key (RFC 7396): an absent member is unchanged.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (APIKeyUpdateParams) MarshalJSON

func (p APIKeyUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type APIKeysService

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

APIKeysService — credentials for programs: user keys act as their owner, organization keys as their own robot account, with Myle rights. Managed with a signed-in session only (/organizations/{id}/api-keys).

Reach it as client.Organization("organization_…").APIKeys.

func (*APIKeysService) Create

func (s *APIKeysService) Create(ctx context.Context, params *APIKeyCreateParams, opts ...RequestOption) (*APIKey, error)

Create — Create an organization key.

Creates a key acting as its own robot account in this organization, configured like a member: a role and/or direct rights, and a tag scope. You can only give rights you hold, and a role whose rights you hold all. Needs a passkey step-up for apiKey.create. The token is in this answer only. At most 20 active keys per organization. A replay of the same request (Idempotency-Key) answers the key without its token, which Myle never keeps.

POST /organizations/{id}/api-keys · requires API_KEYS_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new key, with its token. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *AuthAPIKeyLimitReachedError (409 auth.api-key.limit-reached): The limit of active API keys is reached (10 per user, 20 per organization); revoke one first.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
apiKey, err := org.APIKeys.Create(ctx, &myle.APIKeyCreateParams{Name: "name"})
if err != nil {
	return err
}
fmt.Println(apiKey.Name, apiKey.ETag())

func (*APIKeysService) Get

func (s *APIKeysService) Get(ctx context.Context, apiKeyID string, opts ...RequestOption) (*APIKey, error)

Get — Get one of the organization's API keys.

Returns one of the organization's keys, with its effective rights.

GET /organizations/{id}/api-keys/{apiKeyId} · requires API_KEYS_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

It answers the key. It carries its ETag().

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
apiKey, err := org.APIKeys.Get(ctx, "apiKey_…")
if err != nil {
	return err
}
fmt.Println(apiKey.Name, apiKey.ETag())

func (*APIKeysService) List

func (s *APIKeysService) List(ctx context.Context, opts ...RequestOption) *Paginator[APIKey]

List — List the organization's API keys.

Returns the organization's keys, revoked ones included, newest first.

GET /organizations/{id}/api-keys · requires API_KEYS_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

It answers a *Paginator over a single page (the organization's keys). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for apiKey, err := range org.APIKeys.List(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(apiKey.ID)
}

func (*APIKeysService) Revoke

func (s *APIKeysService) Revoke(ctx context.Context, apiKeyID string, opts ...RequestOption) error

Revoke — Revoke one of the organization's API keys.

Revokes an organization key at once and deactivates its robot account. Revoking it again changes nothing. With If-Match, refused (412) if the key changed since it was read. Allowed to an organization without an active subscription (read-only), which may always cut an access.

DELETE /organizations/{id}/api-keys/{apiKeyId} · requires API_KEYS_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the key is revoked).

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
apiKey, err := org.APIKeys.Get(ctx, "apiKey_…")
if err != nil {
	return err
}
err = org.APIKeys.Revoke(ctx, "apiKey_…", myle.IfMatch(apiKey))
if err != nil {
	return err
}

func (*APIKeysService) Rotate

func (s *APIKeysService) Rotate(ctx context.Context, apiKeyID string, opts ...RequestOption) (*APIKey, error)

Rotate — Rotate one of the organization's API keys.

Creates a new key with the same name, rights and robot account, and makes the old one expire within 24 hours. You must hold every right of the key. Needs a passkey step-up for apiKey.create. The new token is in this answer only. A replay of the same request (Idempotency-Key) answers the key without its token, which Myle never keeps.

POST /organizations/{id}/api-keys/{apiKeyId}/rotate · requires API_KEYS_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new key, with its token. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
apiKey, err := org.APIKeys.Rotate(ctx, "apiKey_…")
if err != nil {
	return err
}
fmt.Println(apiKey.Name, apiKey.ETag())

func (*APIKeysService) Update

func (s *APIKeysService) Update(ctx context.Context, apiKeyID string, params *APIKeyUpdateParams, opts ...RequestOption) (*APIKey, error)

Update — Change one of the organization's API keys.

Renames an organization key (and its robot account), or changes its role, direct rights or tag scope. What you change must be rights you hold. A revoked or expired key cannot change (409). With If-Match, refused (412) if the key changed since it was read.

PATCH /organizations/{id}/api-keys/{apiKeyId} · requires API_KEYS_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the key, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
apiKey, err := org.APIKeys.Get(ctx, "apiKey_…")
if err != nil {
	return err
}
updated, err := org.APIKeys.Update(ctx, "apiKey_…", &myle.APIKeyUpdateParams{Name: myle.String("name")}, myle.IfMatch(apiKey))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type AddressInput

type AddressInput struct {
	// Its internal name, never printed; absent for none.
	Label Opt[string] `json:"label"`
	// The line printed above the street when the recipient is not simply the company.
	RecipientLine Opt[string] `json:"recipientLine"`
	// The street.
	Line1 string `json:"line1"`
	// The postal code.
	PostalCode Opt[string] `json:"postalCode"`
	// The city.
	City Opt[string] `json:"city"`
	// The SIRET of the establishment at this address (14 digits).
	Siret Opt[string] `json:"siret"`
	// What whoever delivers there needs to know (a door code, where to leave the goods).
	DeliveryInstructions Opt[string] `json:"deliveryInstructions"`
	// Its own opening hours: the whole week, each day once, its ranges HH:mm to a later HH:mm; [] for none; absent
	// or null: none of its own, the company's apply.
	OpeningHours Opt[[]OpeningHoursDay] `json:"openingHours"`
}

AddressInput — A postal address to give a company. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (AddressInput) MarshalJSON

func (p AddressInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type AuthAPIKeyLimitReachedContext

type AuthAPIKeyLimitReachedContext struct {
	// The number of active keys allowed.
	Limit int64 `json:"limit"`
}

AuthAPIKeyLimitReachedContext — The detail of this error.

The context of an error code.

type AuthAPIKeyLimitReachedError

type AuthAPIKeyLimitReachedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context AuthAPIKeyLimitReachedContext
}

AuthAPIKeyLimitReachedError is the error code auth.api-key.limit-reached (409): The limit of active API keys is reached (10 per user, 20 per organization); revoke one first.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*AuthAPIKeyLimitReachedError) Unwrap

func (e *AuthAPIKeyLimitReachedError) Unwrap() error

Unwrap answers the *ConflictError it is.

type AuthAPIKeyOrganizationNotAllowedError

type AuthAPIKeyOrganizationNotAllowedError struct {
	*PermissionDeniedError
}

AuthAPIKeyOrganizationNotAllowedError is the error code auth.api-key.organization-not-allowed (403): The user API key sent is narrowed to other organizations than this one.

It wraps *PermissionDeniedError, which wraps *APIError: errors.As matches any of the three.

func (*AuthAPIKeyOrganizationNotAllowedError) Unwrap

Unwrap answers the *PermissionDeniedError it is.

type AuthCredentialExpiredError

type AuthCredentialExpiredError struct {
	*AuthenticationError
}

AuthCredentialExpiredError is the error code auth.credential.expired (401): The credential sent has expired.

It wraps *AuthenticationError, which wraps *APIError: errors.As matches any of the three.

func (*AuthCredentialExpiredError) Unwrap

func (e *AuthCredentialExpiredError) Unwrap() error

Unwrap answers the *AuthenticationError it is.

type AuthCredentialInvalidError

type AuthCredentialInvalidError struct {
	*AuthenticationError
}

AuthCredentialInvalidError is the error code auth.credential.invalid (401): The credential sent is not valid.

It wraps *AuthenticationError, which wraps *APIError: errors.As matches any of the three.

func (*AuthCredentialInvalidError) Unwrap

func (e *AuthCredentialInvalidError) Unwrap() error

Unwrap answers the *AuthenticationError it is.

type AuthCredentialMissingError

type AuthCredentialMissingError struct {
	*AuthenticationError
}

AuthCredentialMissingError is the error code auth.credential.missing (401): No credential was sent: send Authorization: Bearer <token>.

It wraps *AuthenticationError, which wraps *APIError: errors.As matches any of the three.

func (*AuthCredentialMissingError) Unwrap

func (e *AuthCredentialMissingError) Unwrap() error

Unwrap answers the *AuthenticationError it is.

type AuthCredentialRevokedError

type AuthCredentialRevokedError struct {
	*AuthenticationError
}

AuthCredentialRevokedError is the error code auth.credential.revoked (401): The credential sent was revoked (password change, logout everywhere).

It wraps *AuthenticationError, which wraps *APIError: errors.As matches any of the three.

func (*AuthCredentialRevokedError) Unwrap

func (e *AuthCredentialRevokedError) Unwrap() error

Unwrap answers the *AuthenticationError it is.

type AuthEmailUnconfirmedError

type AuthEmailUnconfirmedError struct {
	*PermissionDeniedError
}

AuthEmailUnconfirmedError is the error code auth.email.unconfirmed (403): The account's e-mail address is not confirmed yet.

It wraps *PermissionDeniedError, which wraps *APIError: errors.As matches any of the three.

func (*AuthEmailUnconfirmedError) Unwrap

func (e *AuthEmailUnconfirmedError) Unwrap() error

Unwrap answers the *PermissionDeniedError it is.

type AuthRightMissingContext

type AuthRightMissingContext struct {
	// The right required.
	Right string `json:"right"`
}

AuthRightMissingContext — The detail of this error.

The context of an error code.

type AuthRightMissingError

type AuthRightMissingError struct {
	*PermissionDeniedError
	// Context is the detail of the error.
	Context AuthRightMissingContext
}

AuthRightMissingError is the error code auth.right.missing (403): The caller lacks the right this operation requires in this organization.

It wraps *PermissionDeniedError, which wraps *APIError: errors.As matches any of the three.

func (*AuthRightMissingError) Unwrap

func (e *AuthRightMissingError) Unwrap() error

Unwrap answers the *PermissionDeniedError it is.

type AuthSessionRefusedError

type AuthSessionRefusedError struct {
	*PermissionDeniedError
}

AuthSessionRefusedError is the error code auth.session.refused (403): This session may not perform this operation (an application's session outside its grant, a read-only session).

It wraps *PermissionDeniedError, which wraps *APIError: errors.As matches any of the three.

func (*AuthSessionRefusedError) Unwrap

func (e *AuthSessionRefusedError) Unwrap() error

Unwrap answers the *PermissionDeniedError it is.

type AuthSessionRequiredError

type AuthSessionRequiredError struct {
	*PermissionDeniedError
}

AuthSessionRequiredError is the error code auth.session.required (403): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).

It wraps *PermissionDeniedError, which wraps *APIError: errors.As matches any of the three.

func (*AuthSessionRequiredError) Unwrap

func (e *AuthSessionRequiredError) Unwrap() error

Unwrap answers the *PermissionDeniedError it is.

type AuthStepUpRequiredContext

type AuthStepUpRequiredContext struct {
	// The action to confirm with a passkey (apiKey.create…).
	Action string `json:"action"`
}

AuthStepUpRequiredContext — The detail of this error.

The context of an error code.

type AuthStepUpRequiredError

type AuthStepUpRequiredError struct {
	*PermissionDeniedError
	// Context is the detail of the error.
	Context AuthStepUpRequiredContext
}

AuthStepUpRequiredError is the error code auth.step-up.required (403): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.

It wraps *PermissionDeniedError, which wraps *APIError: errors.As matches any of the three.

func (*AuthStepUpRequiredError) Unwrap

func (e *AuthStepUpRequiredError) Unwrap() error

Unwrap answers the *PermissionDeniedError it is.

type AuthenticationError

type AuthenticationError struct{ *APIError }

AuthenticationError is a 401: no credential, or one that is invalid, expired or revoked.

func (*AuthenticationError) Unwrap

func (e *AuthenticationError) Unwrap() error

Unwrap answers the *APIError.

type Author

type Author struct {
	// user_<uuid> for a person, robot_<uuid> for the robot account of an organization key.
	ID string `json:"id"`
	// The person's name; for a robot account, its key's name (« Export comptable Sage »).
	Name string `json:"name"`
	// USER or ROBOT; clients must tolerate new values.
	Type string `json:"type"`
	// For a ROBOT, the organization key it acts for (apiKey_<ulid>) when known; null for a USER.
	APIKeyID *string `json:"apiKeyId"`
}

Author — Who did something: a person (USER) or the robot account of an organization API key (ROBOT), which acts in the key's name.

type BadGatewayError

type BadGatewayError struct{ *InternalServerError }

BadGatewayError is a 502: a service the API relies on refused (the e-invoicing platform, Stripe…).

func (*BadGatewayError) Unwrap

func (e *BadGatewayError) Unwrap() error

Unwrap answers the *InternalServerError it is.

type BadRequestError

type BadRequestError struct{ *APIError }

BadRequestError is a 400: the request cannot be read (unreadable JSON, malformed parameter).

func (*BadRequestError) Unwrap

func (e *BadRequestError) Unwrap() error

Unwrap answers the *APIError.

type Barcode

type Barcode struct {
	// The barcode's id (barcode_<uuid>).
	ID string `json:"id"`
	// The barcode, as printed.
	Value string `json:"value"`
	// Its symbology: EAN_13, EAN_8, CODE_128 or QR_CODE. An open enum: tolerate a value you do not know.
	Format BarcodeFormat `json:"format"`
	// Whether it is the product's main barcode (at most one is).
	IsPrimary bool `json:"isPrimary"`
	// contains filtered or unexported fields
}

Barcode — A barcode of a product (EAN-13, GTIN…).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Barcode) ETag

func (m Barcode) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Barcode) LastResponse

func (m Barcode) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type BarcodeFormat

type BarcodeFormat string

BarcodeFormat is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: EAN_13, EAN_8, CODE_128, QR_CODE.

const BarcodeFormatCode128 BarcodeFormat = "CODE_128"

BarcodeFormatCode128 is "CODE_128".

const BarcodeFormatEan13 BarcodeFormat = "EAN_13"

BarcodeFormatEan13 is "EAN_13".

const BarcodeFormatEan8 BarcodeFormat = "EAN_8"

BarcodeFormatEan8 is "EAN_8".

const BarcodeFormatQrCode BarcodeFormat = "QR_CODE"

BarcodeFormatQrCode is "QR_CODE".

type BatchPaymentAllocation

type BatchPaymentAllocation struct {
	// The invoice it pays (invoice_<uuid>); each invoice once in a batch.
	InvoiceID string `json:"invoiceId"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Amount Money `json:"amount"`
}

BatchPaymentAllocation — A payment of a batch: the invoice it pays, and what was paid on it. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (BatchPaymentAllocation) MarshalJSON

func (p BatchPaymentAllocation) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type BillingInvoiceAlreadyCreditedContext

type BillingInvoiceAlreadyCreditedContext struct {
	// The credit note that cancels it (invoice_<uuid>).
	CreditNoteID string `json:"creditNoteId"`
}

BillingInvoiceAlreadyCreditedContext — The detail of this error.

The context of an error code.

type BillingInvoiceAlreadyCreditedError

type BillingInvoiceAlreadyCreditedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceAlreadyCreditedContext
}

BillingInvoiceAlreadyCreditedError is the error code billing.invoice.already-credited (409): Another member or key issued the credit note that cancels this invoice already (the caller's own is answered again, never refused). Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceAlreadyCreditedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceAlreadyPaidError

type BillingInvoiceAlreadyPaidError struct {
	*ConflictError
}

BillingInvoiceAlreadyPaidError is the error code billing.invoice.already-paid (409): The invoice is paid already: someone (Stripe, the customer's e-invoicing platform, a member) booked the money first. Read the invoice again before recording anything. Nothing was recorded.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceAlreadyPaidError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceAlreadyReinvoicedContext

type BillingInvoiceAlreadyReinvoicedContext struct {
	// The invoice that re-bills it (invoice_<uuid>).
	InvoiceID string `json:"invoiceId"`
}

BillingInvoiceAlreadyReinvoicedContext — The detail of this error.

The context of an error code.

type BillingInvoiceAlreadyReinvoicedError

type BillingInvoiceAlreadyReinvoicedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceAlreadyReinvoicedContext
}

BillingInvoiceAlreadyReinvoicedError is the error code billing.invoice.already-reinvoiced (409): Another member or key re-billed this credit note already (the caller's own draft is answered again, never refused). Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceAlreadyReinvoicedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceCorrectionFixedContext

type BillingInvoiceCorrectionFixedContext struct {
	// Why: GENERATED (issued to cancel that invoice), EINVOICED (on the e-invoicing network), DELIVERED (handed to
	// the customer with it: only the first choice is free).
	Reason string `json:"reason"`
}

BillingInvoiceCorrectionFixedContext — The detail of this error.

The context of an error code.

type BillingInvoiceCorrectionFixedError

type BillingInvoiceCorrectionFixedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceCorrectionFixedContext
}

BillingInvoiceCorrectionFixedError is the error code billing.invoice.correction-fixed (409): The invoice this credit note corrects can no longer be changed. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceCorrectionFixedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceCreditNoteLinkedError

type BillingInvoiceCreditNoteLinkedError struct {
	*ConflictError
}

BillingInvoiceCreditNoteLinkedError is the error code billing.invoice.credit-note-linked (409): A credit note cancels the invoice: its status no longer moves, and it takes no payment. Nothing was recorded.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceCreditNoteLinkedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceDepositDeductedError

type BillingInvoiceDepositDeductedError struct {
	*ConflictError
}

BillingInvoiceDepositDeductedError is the error code billing.invoice.deposit-deducted (409): A deposit invoice that another invoice has deducted (the order's final invoice, delivery-note invoices, or the credit note that settled the order) can no longer be cancelled: the balance would be wrong. Cancel those invoices first, or settle the order. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceDepositDeductedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceEinvoiceRequiredError

type BillingInvoiceEinvoiceRequiredError struct {
	*ConflictError
}

BillingInvoiceEinvoiceRequiredError is the error code billing.invoice.einvoice-required (409): The customer receives its invoices through the e-invoicing network and this one has not been submitted there yet: its legal channel is the network, not an e-mail nor a hand-over. Nothing was sent or marked.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceEinvoiceRequiredError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceFacturxUnavailableError

type BillingInvoiceFacturxUnavailableError struct {
	*ConflictError
}

BillingInvoiceFacturxUnavailableError is the error code billing.invoice.facturx-unavailable (409): A draft has no Factur-X: the Factur-X carries the legal number the validation gives.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceFacturxUnavailableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceForeignProductContext

type BillingInvoiceForeignProductContext struct {
	// The products refused (product_<uuid>), as sent.
	ProductIDs []string `json:"productIds"`
}

BillingInvoiceForeignProductContext — The detail of this error.

The context of an error code.

type BillingInvoiceForeignProductError

type BillingInvoiceForeignProductError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context BillingInvoiceForeignProductContext
}

BillingInvoiceForeignProductError is the error code billing.invoice.foreign-product (422): A line names a product of another organization: nothing was created.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceForeignProductError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type BillingInvoiceGeneratedCreditNoteError

type BillingInvoiceGeneratedCreditNoteError struct {
	*ConflictError
}

BillingInvoiceGeneratedCreditNoteError is the error code billing.invoice.generated-credit-note (409): This credit note was issued to cancel a lost invoice: it is never written off itself. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceGeneratedCreditNoteError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotACreditNoteError

type BillingInvoiceNotACreditNoteError struct {
	*ConflictError
}

BillingInvoiceNotACreditNoteError is the error code billing.invoice.not-a-credit-note (409): This invoice is no credit note (its total is not negative): it corrects no invoice. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotACreditNoteError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotADraftContext

type BillingInvoiceNotADraftContext struct {
	// The invoice's status (VALIDATED, PAID…).
	Status string `json:"status"`
}

BillingInvoiceNotADraftContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotADraftError

type BillingInvoiceNotADraftError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceNotADraftContext
}

BillingInvoiceNotADraftError is the error code billing.invoice.not-a-draft (409): The invoice is no longer a draft: a validated invoice is never changed, deleted or validated again; it is cancelled or corrected by a credit note.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotADraftError) Unwrap

func (e *BillingInvoiceNotADraftError) Unwrap() error

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotCorrectableContext

type BillingInvoiceNotCorrectableContext struct {
	// The invoice refused (invoice_<uuid>), as sent.
	InvoiceID string `json:"invoiceId"`
}

BillingInvoiceNotCorrectableContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotCorrectableError

type BillingInvoiceNotCorrectableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceNotCorrectableContext
}

BillingInvoiceNotCorrectableError is the error code billing.invoice.not-correctable (409): This credit note cannot correct that invoice: it corrects an issued invoice of the same customer, dated no later than the credit note, not cancelled already, and one the caller can see (GET …/correctable-invoices lists them). Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotCorrectableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotCreditableContext

type BillingInvoiceNotCreditableContext struct {
	// The invoice's status (VALIDATED, PAID…).
	Status string `json:"status"`
}

BillingInvoiceNotCreditableContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotCreditableError

type BillingInvoiceNotCreditableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceNotCreditableContext
}

BillingInvoiceNotCreditableError is the error code billing.invoice.not-creditable (409): Only a LOST invoice, or one the customer refused on the e-invoicing network (EINVOICE_REFUSED), is cancelled by a credit note issued here: mark it lost first. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotCreditableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotDuplicableContext

type BillingInvoiceNotDuplicableContext struct {
	// Why: CREDIT_NOTE (a credit note, generated or hand-made), OUT_OF_SCOPE_REFERENCE (its customer or a product
	// outside the caller's tag scope), CUSTOMER_NOT_FOUND (its customer is no longer on file).
	Reason string `json:"reason"`
}

BillingInvoiceNotDuplicableContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotDuplicableError

type BillingInvoiceNotDuplicableError struct {
	*APIError
	// Context is the detail of the error.
	Context BillingInvoiceNotDuplicableContext
}

BillingInvoiceNotDuplicableError is the error code billing.invoice.not-duplicable: This invoice is not copied as a new draft: a credit note is never duplicated, and a copy needs its customer and its products within the caller's tag scope, its customer still on file. Nothing was created for it.

The document names no operation answering it, so it wraps *APIError directly: its Status is the one received.

func (*BillingInvoiceNotDuplicableError) Unwrap

Unwrap answers the *APIError it is.

type BillingInvoiceNotEditableContext

type BillingInvoiceNotEditableContext struct {
	// Why: MAILED, SHARE_LINK, PUBLIC_ACCESS (read online), TRANSMITTED (sent to the e-invoicing network), PAID,
	// GENERATED_CREDIT_NOTE, SHOP (a Boutique order's), STOCK_TRACKED (its lines take from a stock: change them in
	// the web app), DELIVERY_FORMS (its lines bill delivery forms: change them, or its customer, in the web app);
	// an open list.
	Reason string `json:"reason"`
}

BillingInvoiceNotEditableContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotEditableError

type BillingInvoiceNotEditableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceNotEditableContext
}

BillingInvoiceNotEditableError is the error code billing.invoice.not-editable (409): The draft has been seen outside the organization, or settled, and is no longer changed: correct it by a credit note once validated, or delete it and create another. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotEditableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotPayableContext

type BillingInvoiceNotPayableContext struct {
	// The invoice's status (DRAFT, VALIDATED, SEPA_PENDING…).
	Status string `json:"status"`
}

BillingInvoiceNotPayableContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotPayableError

type BillingInvoiceNotPayableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceNotPayableContext
}

BillingInvoiceNotPayableError is the error code billing.invoice.not-payable (409): The invoice's status takes no payment: a draft, a validated invoice not sent yet (SHARED is the first status that does), a SEPA debit in progress or failed. Nothing was recorded.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotPayableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceNotReinvoiceableContext

type BillingInvoiceNotReinvoiceableContext struct {
	// The invoice's status (DRAFT, VALIDATED…).
	Status string `json:"status"`
}

BillingInvoiceNotReinvoiceableContext — The detail of this error.

The context of an error code.

type BillingInvoiceNotReinvoiceableError

type BillingInvoiceNotReinvoiceableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceNotReinvoiceableContext
}

BillingInvoiceNotReinvoiceableError is the error code billing.invoice.not-reinvoiceable (409): Only a credit note issued here to cancel an invoice (POST …/credit-notes), once validated, is re-billed: this invoice is no such credit note, or it is still a draft. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceNotReinvoiceableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceOutOfScopeReferenceContext

type BillingInvoiceOutOfScopeReferenceContext struct {
	// What is out of scope: company or product.
	Kind string `json:"kind"`
	// The ids refused (company_<uuid>, product_<uuid>), as sent.
	IDs []string `json:"ids"`
}

BillingInvoiceOutOfScopeReferenceContext — The detail of this error.

The context of an error code.

type BillingInvoiceOutOfScopeReferenceError

type BillingInvoiceOutOfScopeReferenceError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context BillingInvoiceOutOfScopeReferenceContext
}

BillingInvoiceOutOfScopeReferenceError is the error code billing.invoice.out-of-scope-reference (422): The invoice references a customer or products outside the caller's tag scope: nothing was created.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceOutOfScopeReferenceError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type BillingInvoicePartialCreditNoteError

type BillingInvoicePartialCreditNoteError struct {
	*ConflictError
}

BillingInvoicePartialCreditNoteError is the error code billing.invoice.partial-credit-note (409): This credit note cancels a delivery-note invoice that deducts a deposit: it must take it back whole. For a price error or a partial return, delete this draft and issue a credit note that corrects the invoice.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoicePartialCreditNoteError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceRecipientUnsubscribedContext

type BillingInvoiceRecipientUnsubscribedContext struct {
	// The address refused (companyEmailAddress_<uuid>).
	EmailAddressID string `json:"emailAddressId"`
}

BillingInvoiceRecipientUnsubscribedContext — The detail of this error.

The context of an error code.

type BillingInvoiceRecipientUnsubscribedError

type BillingInvoiceRecipientUnsubscribedError struct {
	*APIError
	// Context is the detail of the error.
	Context BillingInvoiceRecipientUnsubscribedContext
}

BillingInvoiceRecipientUnsubscribedError is the error code billing.invoice.recipient-unsubscribed: This address unsubscribed from the organization's e-mails: nothing was sent to it (in a send's per-recipient results).

The document names no operation answering it, so it wraps *APIError directly: its Status is the one received.

func (*BillingInvoiceRecipientUnsubscribedError) Unwrap

Unwrap answers the *APIError it is.

type BillingInvoiceStripeImportedError

type BillingInvoiceStripeImportedError struct {
	*ConflictError
}

BillingInvoiceStripeImportedError is the error code billing.invoice.stripe-imported (409): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceStripeImportedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingInvoiceTransitionRefusedContext

type BillingInvoiceTransitionRefusedContext struct {
	// The invoice's status (DRAFT, VALIDATED, PAID…).
	Status string `json:"status"`
	// The status asked (SHARED, LOST, UNPAID).
	To string `json:"to"`
}

BillingInvoiceTransitionRefusedContext — The detail of this error.

The context of an error code.

type BillingInvoiceTransitionRefusedError

type BillingInvoiceTransitionRefusedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingInvoiceTransitionRefusedContext
}

BillingInvoiceTransitionRefusedError is the error code billing.invoice.transition-refused (409): The invoice's status cannot move to the one asked: a draft is validated first, an invoice is shared before it is written off, a paid one is taken back to unpaid rather than shared… Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingInvoiceTransitionRefusedError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingPaymentNotRemovableContext

type BillingPaymentNotRemovableContext struct {
	// The invoice's status (LOST, SEPA_PENDING…).
	Status string `json:"status"`
}

BillingPaymentNotRemovableContext — The detail of this error.

The context of an error code.

type BillingPaymentNotRemovableError

type BillingPaymentNotRemovableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context BillingPaymentNotRemovableContext
}

BillingPaymentNotRemovableError is the error code billing.payment.not-removable (409): The invoice's status no longer lets its payments be removed: only a PAID or partially paid invoice's can. Nothing was removed.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingPaymentNotRemovableError) Unwrap

Unwrap answers the *ConflictError it is.

type BillingPaymentStripeCollectedError

type BillingPaymentStripeCollectedError struct {
	*ConflictError
}

BillingPaymentStripeCollectedError is the error code billing.payment.stripe-collected (409): The payment was collected through Stripe: it is refunded in Stripe, never removed in Myle. Nothing was removed.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*BillingPaymentStripeCollectedError) Unwrap

Unwrap answers the *ConflictError it is.

type Client

type Client struct {
	// Me — the caller: the signed-in user, or the user an API key acts as (/me).
	Me *MeService
	// Rights — the rights of the Myle permission model, which members and API keys hold (/rights).
	Rights *RightsService
	// Products — the organization's catalog: the products and services it sells, with their prices and barcodes
	// (/products).
	Products *SearchProductsService
	// Companies — the organization's customers: businesses, consumers and foreign clients, with their addresses and
	// e-mail addresses (/companies).
	Companies *SearchCompaniesService
	// Invoices — the organization's sales invoices: drafts, their validation (the legal number), their PDF and
	// Factur-X (/invoices).
	Invoices *SearchInvoicesService
	// Quotations — the organization's quotations: the offers it makes its customers, sent, accepted or refused,
	// extended, and billed as invoices (/quotations).
	Quotations *SearchQuotationsService
	// Orders — the organization's orders: what its customers order, confirmed, prepared, delivered (with the stock
	// lots the goods leave from) and billed (/orders).
	Orders *SearchOrdersService
	// contains filtered or unexported fields
}

Client is the client of the Myle API (https://api.myleapp.fr). Build it with NewClient; it is safe for concurrent use.

The API key is read from MYLE_API_KEY when not given. Every call sends Myle-API-Version (APIVersion unless WithAPIVersion says otherwise), retries what is safe to retry, and returns the type of the error code (*CoreNotFoundError…) when the API refuses.

client := myle.NewClient() // MYLE_API_KEY
org := client.Organization("organization_…")
for product, err := range org.Products.List(ctx, nil).All() {
	if err != nil {
		return err
	}
	fmt.Println(product.Name)
}

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient answers a client configured by its options: WithAPIKey, WithAPIVersion, WithBaseURL, WithMaxRetries, WithTimeout, WithAcceptLanguage, WithHTTPClient, WithHeader, WithDeprecationHandler, WithMyleClient. Nothing is sent until a call; a malformed WithAPIVersion makes every call fail before sending.

client := myle.NewClient(myle.WithAPIKey(os.Getenv("MYLE_KEY")), myle.WithMaxRetries(3))
Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	myle "github.com/myleapp/myle-go"
)

func main() {
	client := myle.NewClient(myle.WithAPIKey(os.Getenv("MYLE_API_KEY")), myle.WithMaxRetries(3))
	me, err := client.Me.Get(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(me.Email)
}

func (*Client) APIVersion

func (c *Client) APIVersion() string

APIVersion answers the Myle-API-Version this client sends.

func (*Client) Organization

func (c *Client) Organization(organizationID string) *OrganizationScope

Organization answers the resources of one organization (/organizations/{id}/…). No request is made until you call a method on it.

org := client.Organization("organization_…")
product, err := org.Products.Get(ctx, "product_…")

type ClientOption

type ClientOption func(*clientConfig)

A ClientOption configures a Client: pass any number of them to NewClient.

func WithAPIKey

func WithAPIKey(key string) ClientOption

WithAPIKey sets the API key sent as "Authorization: Bearer <key>", a user or an organization key, treated as an opaque string. Without this option the key is read from the MYLE_API_KEY environment variable; without either, only the public operations (Rights.List) can be called, every other one fails before sending.

func WithAPIVersion

func WithAPIVersion(date string) ClientOption

WithAPIVersion sets the contract date sent as Myle-API-Version (YYYY-MM-DD): the API answers with the behavior of that date. It defaults to APIVersion, the date of the document this SDK was generated from, so an API change never changes what this code receives. A malformed date makes every call fail before sending.

func WithAcceptLanguage

func WithAcceptLanguage(language string) ClientOption

WithAcceptLanguage sets the language of the error messages (fr or en, the API's default).

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL sets the API's address: MYLE_BASE_URL, else https://api.myleapp.fr.

func WithDeprecationHandler

func WithDeprecationHandler(handler func(DeprecationNotice)) ClientOption

WithDeprecationHandler sets the function called once per operation and client when the API answers that operation with a deprecated behavior (Deprecation or Sunset headers): time to move to a newer API version. By default a line is written to the standard logger; nil silences it.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient sets the http.Client the calls go through (a proxy, a custom transport, a test double). A client of its own by default. Its Timeout, if any, applies on top of WithTimeout.

func WithHeader

func WithHeader(name, value string) ClientOption

WithHeader adds a header sent with every request.

func WithMaxRetries

func WithMaxRetries(n int) ClientOption

WithMaxRetries sets how many times a failed call is retried (a network error, 429, a 5xx when the call is safe to repeat): 2 by default, 0 for none.

func WithMyleClient

func WithMyleClient(value string) ClientOption

WithMyleClient replaces the Myle-Client header ("sdk-go/<version>"), for a program built on this SDK: "<platform>/<version>", optionally followed by " (<build>)".

func WithTimeout

func WithTimeout(d time.Duration) ClientOption

WithTimeout sets the time an attempt may take, the answer's body included: 60 seconds by default, 0 for none. The context given to each call bounds the whole call, retries included.

type CompaniesService

type CompaniesService struct {
	// EmailAddresses — /organizations/{id}/companies/{companyId}/email-addresses.
	EmailAddresses *CompanyEmailAddressesService
	// PostalAddresses — /organizations/{id}/companies/{companyId}/postal-addresses.
	PostalAddresses *CompanyPostalAddressesService
	// SepaMandate — /organizations/{id}/companies/{companyId}/sepa-mandate.
	SepaMandate *CompanySepaMandateService
	// contains filtered or unexported fields
}

CompaniesService — the organization's customers: businesses, consumers and foreign clients, with their addresses and e-mail addresses (/organizations/{id}/companies).

Reach it as client.Organization("organization_…").Companies.

func (*CompaniesService) Create

func (s *CompaniesService) Create(ctx context.Context, params *CompanyCreateParams, opts ...RequestOption) (*Company, error)

Create — Create a company.

Creates a customer, with its addresses and e-mail addresses. A French business (BUSINESS_FR) needs a SIREN, a SIRET or a VAT number. Its number and its accounting number must not be another company's (409). Counts in the plan's number of companies (402 once reached). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/companies · requires COMPANIES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new company. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CrmCompanyAccountingNumberTakenError (409 crm.company.accounting-number-taken): Another company of the organization has this accounting number.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CrmCompanyIdentifierRequiredError (422 crm.company.identifier-required): A French business (type BUSINESS_FR) needs a SIREN, a SIRET or a VAT number; send one, or choose the CONSUMER or FOREIGN type.
  • *CrmCompanyInvalidIdentifierError (422 crm.company.invalid-identifier): The SIREN (9 digits, or a 14-digit SIRET) or the French VAT number (FR, a 2-digit key, the SIREN) cannot be read.
  • *CrmCompanyInvalidSiretError (422 crm.company.invalid-siret): The establishment SIRET of an address is not 14 digits.

Example:

org := client.Organization("organization_…")
company, err := org.Companies.Create(ctx, &myle.CompanyCreateParams{Number: "number", Name: "name"})
if err != nil {
	return err
}
fmt.Println(company.Name, company.ETag())

func (*CompaniesService) Delete

func (s *CompaniesService) Delete(ctx context.Context, companyID string, opts ...RequestOption) error

Delete — Delete a company.

Deletes a customer: it leaves the lists, its documents keep it. With If-Match, refused (412) if the company changed since it was read.

DELETE /organizations/{id}/companies/{companyId} · requires COMPANIES_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the company is deleted).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
company, err := org.Companies.Get(ctx, "company_…")
if err != nil {
	return err
}
err = org.Companies.Delete(ctx, "company_…", myle.IfMatch(company))
if err != nil {
	return err
}

func (*CompaniesService) Get

func (s *CompaniesService) Get(ctx context.Context, companyID string, opts ...RequestOption) (*Company, error)

Get — Get a company.

Returns a customer the caller can see; one outside its tag scope, deleted or unknown is a 404.

GET /organizations/{id}/companies/{companyId} · requires COMPANIES_LIST.

It answers the company. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
company, err := org.Companies.Get(ctx, "company_…")
if err != nil {
	return err
}
fmt.Println(company.Name, company.ETag())

func (*CompaniesService) GetEinvoicingRouting

func (s *CompaniesService) GetEinvoicingRouting(ctx context.Context, companyID string, opts ...RequestOption) (*CompanyEinvoicingRouting, error)

GetEinvoicingRouting — Get a customer's e-invoicing routing.

Returns the electronic addresses the directory publishes for the customer's SIREN, the one its invoices carry (BT-49) and where it comes from (DIRECTORY or MANUAL), and whether its invoices go through the network. Asks the directory: 502 when it does not answer. The customer must be one the caller can see.

GET /organizations/{id}/companies/{companyId}/einvoicing-routing · requires COMPANIES_LIST.

It answers the customer's routing.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
companyEinvoicingRouting, err := org.Companies.GetEinvoicingRouting(ctx, "company_…")
if err != nil {
	return err
}
fmt.Println(companyEinvoicingRouting)

func (*CompaniesService) GetNeighbors

func (s *CompaniesService) GetNeighbors(ctx context.Context, companyID string, params *CompanyGetNeighborsParams, opts ...RequestOption) (*CompanyNeighbors, error)

GetNeighbors — Get a company's neighbors in a list.

Returns the companies just before and just after this one in the list read with the same filters and sort (GET …/companies): what a « previous / next » navigation needs. A company the filters leave out has none.

GET /organizations/{id}/companies/{companyId}/neighbors · requires COMPANIES_LIST.

It answers its neighbors.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
companyNeighbors, err := org.Companies.GetNeighbors(ctx, "company_…", nil)
if err != nil {
	return err
}
fmt.Println(companyNeighbors)

func (*CompaniesService) GetSepaMandate

func (s *CompaniesService) GetSepaMandate(ctx context.Context, companyID string, opts ...RequestOption) (*SepaMandate, error)

GetSepaMandate — Get a customer's SEPA mandate.

Returns the SEPA mandate of a customer the caller can see, as Stripe holds it: ACTIVE with its reference, its page and the bank account it debits, or NONE; and whether the customer's invoices are debited automatically. Stripe is read each time.

GET /organizations/{id}/companies/{companyId}/sepa-mandate · requires STRIPE_MANDATES_MANAGE.

It answers the mandate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *PaymentAccountNotConnectedError (409 payments.account.not-connected): No Stripe account is connected to the organization: connect one first (POST …/payments-account/onboarding).
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
sepaMandate, err := org.Companies.GetSepaMandate(ctx, "company_…")
if err != nil {
	return err
}
fmt.Println(sepaMandate)

func (*CompaniesService) List

List — List the companies.

Returns the organization's customers the caller can see (its tag scope applies), filtered and sorted, one page at a time. For a synchronization: updatedAfter with the largest updatedAt already seen, sort updatedAt.

GET /organizations/{id}/companies · requires COMPANIES_LIST.

It answers a *Paginator (a page of companies): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
for company, err := range org.Companies.List(ctx, nil).All() {
	if err != nil {
		return err
	}
	fmt.Println(company.ID)
}

func (*CompaniesService) ListTags

func (s *CompaniesService) ListTags(ctx context.Context, opts ...RequestOption) *Paginator[string]

ListTags — List the companies' tags.

Returns the tags the companies the caller can see carry (its tag scope applies), sorted.

GET /organizations/{id}/companies/tags · requires COMPANIES_LIST.

It answers a *Paginator over a single page (the tags, in one page). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for tag, err := range org.Companies.ListTags(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(tag)
}

func (*CompaniesService) ReplaceEinvoicingRouting

func (s *CompaniesService) ReplaceEinvoicingRouting(ctx context.Context, companyID string, params *CompanyReplaceEinvoicingRoutingParams, opts ...RequestOption) (*CompanyEinvoicingRouting, error)

ReplaceEinvoicingRouting — Choose a customer's electronic address.

Retains one of the addresses the directory publishes for the customer (MANUAL: never overwritten by the automatic resolution), or, with null, returns to the automatic resolution. Audited on the customer.

PUT /organizations/{id}/companies/{companyId}/einvoicing-routing · requires COMPANIES_PATCH.

It answers the customer's routing, the choice retained.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *EinvoicingRoutingAddressNotPublishedError (422 einvoicing.routing-address.not-published): The directory does not publish this electronic address for the SIREN: choose one of the candidates read with GET. Nothing was written.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
companyEinvoicingRouting, err := org.Companies.ReplaceEinvoicingRouting(ctx, "company_…", &myle.CompanyReplaceEinvoicingRoutingParams{Identifier: myle.String("identifier")})
if err != nil {
	return err
}
fmt.Println(companyEinvoicingRouting)

func (*CompaniesService) Update

func (s *CompaniesService) Update(ctx context.Context, companyID string, params *CompanyUpdateParams, opts ...RequestOption) (*Company, error)

Update — Change a company.

Changes the members sent (a JSON merge patch); the others stay as they are. The identifier rules apply to the company as changed. With If-Match, refused (412) if the company changed since it was read. autoDebit (the SEPA auto-debit of its validated invoices) needs STRIPE_MANDATES_MANAGE, every other member COMPANIES_PATCH; turning it on follows the money operations' rule: the collection open, a plan with SEPA debits, a session's passkey step-up stripe.setAutoDebit (an API key holding the right needs none).

PATCH /organizations/{id}/companies/{companyId} · requires one of COMPANIES_PATCH, STRIPE_MANDATES_MANAGE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the company, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *PaymentPlanCollectionRequiredError (402 payments.plan.collection-required): The organization's plan does not carry Stripe collection (SEPA debits, mandates, auto-debit, online payment of invoices); the trial does not either. It comes with a paid plan.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CrmCompanyAccountingNumberTakenError (409 crm.company.accounting-number-taken): Another company of the organization has this accounting number.
  • *CrmPostalAddressReferencedError (409 crm.postal-address.referenced): A delivery address the request removes is still in use: nothing was written.
  • *PaymentAccountDemoError (409 payments.account.demo): A demo organization never reaches Stripe: nothing was done.
  • *PaymentCollectionDisabledError (409 payments.collection.disabled): The organization turned its Stripe collection off (in its payment settings): nothing is debited, no mandate is offered, no auto-debit is turned on until it turns it back on.
  • *PaymentCollectionPausedError (409 payments.collection.paused): The organization's Stripe collection is paused because it no longer pays for Myle: it resumes with its subscription.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CrmCompanyIdentifierRequiredError (422 crm.company.identifier-required): A French business (type BUSINESS_FR) needs a SIREN, a SIRET or a VAT number; send one, or choose the CONSUMER or FOREIGN type.
  • *CrmCompanyInvalidIdentifierError (422 crm.company.invalid-identifier): The SIREN (9 digits, or a 14-digit SIRET) or the French VAT number (FR, a 2-digit key, the SIREN) cannot be read.
  • *CrmCompanyInvalidSiretError (422 crm.company.invalid-siret): The establishment SIRET of an address is not 14 digits.

Example:

org := client.Organization("organization_…")
company, err := org.Companies.Get(ctx, "company_…")
if err != nil {
	return err
}
updated, err := org.Companies.Update(ctx, "company_…", &myle.CompanyUpdateParams{Number: myle.String("number")}, myle.IfMatch(company))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type Company

type Company struct {
	// The company's id (company_<uuid>).
	ID string `json:"id"`
	// Always "company".
	Object string `json:"object"`
	// The organization it belongs to (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// Its reference, unique among the organization's companies (C0042).
	Number string `json:"number"`
	// Its name.
	Name string `json:"name"`
	// BUSINESS_FR (a French business, with a SIREN), CONSUMER, FOREIGN (a client outside France). An open enum:
	// tolerate a value you do not know.
	Type CompanyType `json:"type"`
	// Its SIREN (9 digits), or null.
	Siren *string `json:"siren"`
	// Its VAT number, or null.
	VatNumber *string `json:"vatNumber"`
	// The accounting account its sales are booked to (411…), or null.
	AccountingNumber *string `json:"accountingNumber"`
	// Its phone number, or null.
	Phone *string `json:"phone"`
	// Its e-mail addresses.
	EmailAddresses []CompanyEmailAddress `json:"emailAddresses"`
	// Its registered office, or null when none was entered.
	HeadquartersAddress *PostalAddress `json:"headquartersAddress"`
	// Where its invoices are sent when not to its headquarters, or null.
	BillingAddress *PostalAddress `json:"billingAddress"`
	// Its delivery addresses.
	DeliveryAddresses []PostalAddress `json:"deliveryAddresses"`
	// The discount granted on its documents, in percent, a decimal string, or null.
	DiscountPercentage *string `json:"discountPercentage"`
	// Why it gets a discount, or null.
	DiscountReason *string `json:"discountReason"`
	// How often its delivery notes are invoiced automatically: MONTHLY, TEN_DAYS, DAILY, DISABLED. An open enum:
	// tolerate a value you do not know.
	InvoicingPeriod CompanyInvoicingPeriod `json:"invoicingPeriod"`
	// Its tags, sorted, managed ones included (E-FACT…).
	Tags []string `json:"tags"`
	// Its validated invoices are debited by SEPA automatically, through its mandate (the SEPA:AUTO-PRÉLÈVEMENT
	// tag).
	AutoDebit bool `json:"autoDebit"`
	// A free description, or null; read only.
	Description *string `json:"description"`
	// Whether its delivery notes show the prices.
	ShowPricesOnDeliveryNotes bool `json:"showPricesOnDeliveryNotes"`
	// Its opening hours: the days it has hours for, Monday first (a day absent is not filled in, not closed).
	OpeningHours []OpeningHoursDay `json:"openingHours"`
	// Its places (fields, sites) proposed on its documents' lines.
	Places []string `json:"places"`
	// Whether it is also one of the organization's suppliers; read only.
	IsSupplier bool `json:"isSupplier"`
	// The date of its last delivery note that is not deleted (YYYY-MM-DD), or null; read only.
	LastDeliveryNoteDate *string `json:"lastDeliveryNoteDate"`
	// When its name and headquarters were last synchronized from the French e-invoicing directory (RFC 3339, UTC),
	// or null when they are not; read only.
	DirectorySyncedAt *string `json:"directorySyncedAt"`
	// Whether the e-invoicing directory says it receives e-invoices, or null when not known; read only.
	IsEInvoiceReachable *bool `json:"isEInvoiceReachable"`
	// The legal form of a company, as the INSEE registry gives it.
	LegalForm *LegalForm `json:"legalForm"`
	// Whether it is a public body (its invoices go through Chorus Pro), from its legal form; null when not known;
	// read only.
	IsPublicBody *bool `json:"isPublicBody"`
	// Whether it has an active Boutique access; null when the caller cannot see the Boutique accesses (the Boutique
	// module off, or SHOP_ACCESS_VIEW missing) and in a search across organizations; read only.
	HasShopAccess *bool `json:"hasShopAccess"`
	// When it was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When it, its addresses or its e-mail addresses last changed (RFC 3339, UTC).
	UpdatedAt string `json:"updatedAt"`
	// contains filtered or unexported fields
}

Company — A customer of the organization: a French business, a consumer or a foreign client. headquartersAddress: its registered office, or null when none was entered; billingAddress: where its invoices are sent when not to its headquarters, or null; discountPercentage: the discount granted on its documents, in percent, a decimal string, or null.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Company) ETag

func (m Company) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Company) LastResponse

func (m Company) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type CompanyCreateParams

type CompanyCreateParams struct {
	// Its reference, unique among the organization's companies.
	Number string `json:"number"`
	// Its name.
	Name string `json:"name"`
	// BUSINESS_FR (the default; a SIREN, a SIRET or a VAT number is then required), CONSUMER, FOREIGN.
	Type Opt[string] `json:"type"`
	// Its SIREN, or a SIRET (its SIREN is kept); BUSINESS_FR only.
	Siren Opt[string] `json:"siren"`
	// Its VAT number: French (FR + key + SIREN) for BUSINESS_FR, any for FOREIGN.
	VatNumber Opt[string] `json:"vatNumber"`
	// The accounting account its sales are booked to, unique among the organization's companies.
	AccountingNumber Opt[string] `json:"accountingNumber"`
	// Its phone number.
	Phone Opt[string] `json:"phone"`
	// Its e-mail addresses.
	EmailAddresses Opt[[]EmailAddressInput] `json:"emailAddresses"`
	// Its registered office.
	HeadquartersAddress Opt[AddressInput] `json:"headquartersAddress"`
	// Where its invoices are sent, when not to its headquarters.
	BillingAddress Opt[AddressInput] `json:"billingAddress"`
	// Its delivery addresses.
	DeliveryAddresses Opt[[]AddressInput] `json:"deliveryAddresses"`
	// A decimal string from 0 to 100.
	DiscountPercentage Opt[string] `json:"discountPercentage"`
	// Why it gets a discount.
	DiscountReason Opt[string] `json:"discountReason"`
	// How often its delivery notes are invoiced: MONTHLY, TEN_DAYS, DAILY, DISABLED (the default).
	InvoicingPeriod Opt[string] `json:"invoicingPeriod"`
	// Its tags.
	Tags Opt[[]string] `json:"tags"`
	// Whether its delivery notes show the prices; false by default.
	ShowPricesOnDeliveryNotes Opt[bool] `json:"showPricesOnDeliveryNotes"`
	// Its opening hours, one entry per day; none by default.
	OpeningHours Opt[[]OpeningHoursDay] `json:"openingHours"`
}

CompanyCreateParams is the parameters of CompaniesService.Create (createCompany): its body's members. A nil *CompanyCreateParams sends none.

A new company. type: BUSINESS_FR (the default; a SIREN, a SIRET or a VAT number is then required), CONSUMER, FOREIGN. headquartersAddress: its registered office; billingAddress: where its invoices are sent, when not to its headquarters. discountPercentage: a decimal string from 0 to 100.

A member of type Opt is left out unless set.

func (CompanyCreateParams) MarshalJSON

func (p CompanyCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type CompanyEinvoicingRouting

type CompanyEinvoicingRouting struct {
	// companyEinvoicingRouting.
	Object string `json:"object"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// The address its invoices carry (BT-49), or null.
	Selected *string `json:"selected"`
	// DIRECTORY or MANUAL, or null.
	Source *string `json:"source"`
	// Candidates.
	Candidates []RoutingCandidate `json:"candidates"`
	// The base address is retained while the directory also publishes establishment addresses (alternatives: the
	// first of them): check it.
	EstablishmentWarning *EstablishmentWarning `json:"establishmentWarning"`
	// The customer's invoices go through the network.
	IsRouted bool `json:"isRouted"`
	// Why not, as codes (ORG_NOT_CONNECTED, CLIENT_NOT_INVOICABLE…); empty when routed.
	Reasons []string `json:"reasons"`
	// The directory did not answer: the verdict is unknown, not « unreachable ».
	IsDirectoryUnavailable bool `json:"isDirectoryUnavailable"`
	// contains filtered or unexported fields
}

CompanyEinvoicingRouting — A customer's e-invoicing routing: the addresses the directory publishes, the one retained (establishmentWarning, or null), the verdict.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (CompanyEinvoicingRouting) ETag

func (m CompanyEinvoicingRouting) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (CompanyEinvoicingRouting) LastResponse

func (m CompanyEinvoicingRouting) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type CompanyEmailAddress

type CompanyEmailAddress struct {
	// The address's id (companyEmailAddress_<uuid>), unique among the company's addresses.
	ID string `json:"id"`
	// Always "companyEmailAddress".
	Object string `json:"object"`
	// The e-mail address, lower-cased.
	Address string `json:"address"`
	// Its label (« Comptabilité »), or null.
	Label *string `json:"label"`
	// The documents sent to it automatically: INVOICE, DELIVERY_NOTE, ORDER, QUOTATION. An open enum: tolerate a
	// value you do not know.
	Purposes []string `json:"purposes"`
	// Whether it unsubscribed from the campaigns and grouped mailings (documents still reach it); POST
	// …/resubscribe subscribes it again.
	IsUnsubscribed bool `json:"isUnsubscribed"`
	// When it unsubscribed (RFC 3339, UTC), or null.
	UnsubscribedAt *string `json:"unsubscribedAt"`
	// contains filtered or unexported fields
}

CompanyEmailAddress — An e-mail address of a company.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (CompanyEmailAddress) ETag

func (m CompanyEmailAddress) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (CompanyEmailAddress) LastResponse

func (m CompanyEmailAddress) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type CompanyEmailAddressCreateParams

type CompanyEmailAddressCreateParams struct {
	// The e-mail address.
	Address string `json:"address"`
	// Its label.
	Label Opt[string] `json:"label"`
	// The documents to send to it automatically: INVOICE, DELIVERY_NOTE, ORDER, QUOTATION; absent for none.
	Purposes Opt[[]string] `json:"purposes"`
}

CompanyEmailAddressCreateParams is the parameters of CompanyEmailAddressesService.Create (createCompanyEmailAddress): its body's members. A nil *CompanyEmailAddressCreateParams sends none.

An e-mail address to give a company.

A member of type Opt is left out unless set.

func (CompanyEmailAddressCreateParams) MarshalJSON

func (p CompanyEmailAddressCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type CompanyEmailAddressUpdateParams

type CompanyEmailAddressUpdateParams struct {
	// A new label; null for none.
	Label Opt[string] `json:"label"`
	// The documents to send to it automatically, all of them: INVOICE, DELIVERY_NOTE, ORDER, QUOTATION; null for
	// none.
	Purposes Opt[[]string] `json:"purposes"`
}

CompanyEmailAddressUpdateParams is the parameters of CompanyEmailAddressesService.Update (updateCompanyEmailAddress): its body's members. A nil *CompanyEmailAddressUpdateParams sends none.

A merge patch of an e-mail address of a company (RFC 7396): an absent member is unchanged. The address itself is not changed here (remove it and add the new one); its subscription is given back by …/resubscribe.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (CompanyEmailAddressUpdateParams) MarshalJSON

func (p CompanyEmailAddressUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type CompanyEmailAddressesService

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

CompanyEmailAddressesService — /organizations/{id}/companies/{companyId}/email-addresses.

Reach it as client.Organization("organization_…").Companies.EmailAddresses.

func (*CompanyEmailAddressesService) Create

Create — Add an e-mail address to a company.

Adds an e-mail address to a customer, with the documents to send it automatically. An address the company already has is a conflict (409). Moves the company's version. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/companies/{companyId}/email-addresses · requires COMPANIES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the e-mail address. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
companyEmailAddress, err := org.Companies.EmailAddresses.Create(ctx, "company_…", &myle.CompanyEmailAddressCreateParams{Address: "contact@example.com"})
if err != nil {
	return err
}
fmt.Println(companyEmailAddress.ID, companyEmailAddress.ETag())

func (*CompanyEmailAddressesService) Delete

func (s *CompanyEmailAddressesService) Delete(ctx context.Context, companyID string, companyEmailAddressID string, opts ...RequestOption) error

Delete — Remove an e-mail address from a company.

Removes an e-mail address from a customer. Moves the company's version. With If-Match (the company's ETag), refused (412) if the company changed since it was read.

DELETE /organizations/{id}/companies/{companyId}/email-addresses/{companyEmailAddressId} · requires COMPANIES_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the e-mail address is removed).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
if err := org.Companies.EmailAddresses.Delete(ctx, "company_…", "companyEmailAddress_…"); err != nil {
	return err
}

func (*CompanyEmailAddressesService) Resubscribe

func (s *CompanyEmailAddressesService) Resubscribe(ctx context.Context, companyID string, companyEmailAddressID string, opts ...RequestOption) (*CompanyEmailAddress, error)

Resubscribe — Subscribe an e-mail address of a company again.

Subscribes again to the campaigns and grouped mailings an address that unsubscribed: it overrides its owner's choice, so it is audited. Moves the company's version.

POST /organizations/{id}/companies/{companyId}/email-addresses/{companyEmailAddressId}/resubscribe · requires COMPANIES_RESUBSCRIBE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the e-mail address, subscribed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
companyEmailAddress, err := org.Companies.EmailAddresses.Resubscribe(ctx, "company_…", "companyEmailAddress_…")
if err != nil {
	return err
}
fmt.Println(companyEmailAddress.ID, companyEmailAddress.ETag())

func (*CompanyEmailAddressesService) Update

func (s *CompanyEmailAddressesService) Update(ctx context.Context, companyID string, companyEmailAddressID string, params *CompanyEmailAddressUpdateParams, opts ...RequestOption) (*CompanyEmailAddress, error)

Update — Change an e-mail address of a company.

Changes the label or the purposes of an e-mail address of a customer (a JSON merge patch). Moves the company's version. With If-Match (the company's ETag), refused (412) if the company changed since it was read.

PATCH /organizations/{id}/companies/{companyId}/email-addresses/{companyEmailAddressId} · requires COMPANIES_PATCH.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the e-mail address, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
companyEmailAddress, err := org.Companies.EmailAddresses.Update(ctx, "company_…", "companyEmailAddress_…", &myle.CompanyEmailAddressUpdateParams{Label: myle.String("label")})
if err != nil {
	return err
}
fmt.Println(companyEmailAddress.ID, companyEmailAddress.ETag())

type CompanyGetNeighborsParams

type CompanyGetNeighborsParams struct {
	// Text searched in the name (accents and case ignored), the number and the SIREN.
	Q Opt[string] `json:"-"`
	// Companies carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value
	// is sent (name=a&name=b).
	Tag []string `json:"-"`
	// Companies changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// name (the default), number, createdAt, headquartersCity (the city of its headquarters, the companies without
	// one last) or updatedAt; with a leading - for descending (-name; -headquartersCity puts the companies without
	// a city first). Ties are broken by the company's id.
	Sort Opt[CompanyListSort] `json:"-"`
	// How the tag filter matches: ANY (the default), a company carrying one of the tags; ALL, a company carrying
	// every one of them.
	TagMode Opt[CompanyListTagMode] `json:"-"`
	// Leaves out the companies carrying every one of these tags (repeat it for several): one tag leaves out the
	// companies carrying it; with several, a company carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// Companies whose name (accents and case ignored), number, SIREN or VAT number contains these words, in this
	// order.
	NameOrIdentifier Opt[string] `json:"-"`
	// Companies with an address (headquarters, billing or delivery) whose label, street, postal code and city, put
	// end to end, contain this text, case ignored.
	Address Opt[string] `json:"-"`
	// Companies with an e-mail address or a phone number containing this text, case ignored.
	Contact Opt[string] `json:"-"`
	// Companies invoiced at this period: MONTHLY, TEN_DAYS, DAILY or DISABLED.
	InvoicingPeriod Opt[CompanyInvoicingPeriod] `json:"-"`
	// Companies created on or after this day (YYYY-MM-DD, UTC).
	CreatedAtFrom Opt[string] `json:"-"`
	// Companies created on or before this day (YYYY-MM-DD, UTC).
	CreatedAtTo Opt[string] `json:"-"`
	// true: companies with an invoice still to be paid (outstanding, partly paid or lost); false: those with none.
	HasUnpaidInvoices Opt[bool] `json:"-"`
	// true: companies with an active Boutique access; false: those without. Ignored when the caller cannot see the
	// Boutique accesses (hasShopAccess is null then).
	HasShopAccess Opt[bool] `json:"-"`
}

CompanyGetNeighborsParams is the parameters of CompaniesService.GetNeighbors (getCompanyNeighbors): its query parameters. A nil *CompanyGetNeighborsParams sends none.

type CompanyInvoicingPeriod

type CompanyInvoicingPeriod string

CompanyInvoicingPeriod is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: MONTHLY, TEN_DAYS, DAILY, DISABLED.

const CompanyInvoicingPeriodDaily CompanyInvoicingPeriod = "DAILY"

CompanyInvoicingPeriodDaily is "DAILY".

const CompanyInvoicingPeriodDisabled CompanyInvoicingPeriod = "DISABLED"

CompanyInvoicingPeriodDisabled is "DISABLED".

const CompanyInvoicingPeriodMonthly CompanyInvoicingPeriod = "MONTHLY"

CompanyInvoicingPeriodMonthly is "MONTHLY".

const CompanyInvoicingPeriodTenDays CompanyInvoicingPeriod = "TEN_DAYS"

CompanyInvoicingPeriodTenDays is "TEN_DAYS".

type CompanyListParams

type CompanyListParams struct {
	// Text searched in the name (accents and case ignored), the number and the SIREN.
	Q Opt[string] `json:"-"`
	// Companies carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value
	// is sent (name=a&name=b).
	Tag []string `json:"-"`
	// Companies changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// name (the default), number, createdAt, headquartersCity (the city of its headquarters, the companies without
	// one last) or updatedAt; with a leading - for descending (-name; -headquartersCity puts the companies without
	// a city first). Ties are broken by the company's id.
	Sort Opt[CompanyListSort] `json:"-"`
	// How the tag filter matches: ANY (the default), a company carrying one of the tags; ALL, a company carrying
	// every one of them.
	TagMode Opt[CompanyListTagMode] `json:"-"`
	// Leaves out the companies carrying every one of these tags (repeat it for several): one tag leaves out the
	// companies carrying it; with several, a company carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// Companies whose name (accents and case ignored), number, SIREN or VAT number contains these words, in this
	// order.
	NameOrIdentifier Opt[string] `json:"-"`
	// Companies with an address (headquarters, billing or delivery) whose label, street, postal code and city, put
	// end to end, contain this text, case ignored.
	Address Opt[string] `json:"-"`
	// Companies with an e-mail address or a phone number containing this text, case ignored.
	Contact Opt[string] `json:"-"`
	// Companies invoiced at this period: MONTHLY, TEN_DAYS, DAILY or DISABLED.
	InvoicingPeriod Opt[CompanyInvoicingPeriod] `json:"-"`
	// Companies created on or after this day (YYYY-MM-DD, UTC).
	CreatedAtFrom Opt[string] `json:"-"`
	// Companies created on or before this day (YYYY-MM-DD, UTC).
	CreatedAtTo Opt[string] `json:"-"`
	// true: companies with an invoice still to be paid (outstanding, partly paid or lost); false: those with none.
	HasUnpaidInvoices Opt[bool] `json:"-"`
	// true: companies with an active Boutique access; false: those without. Ignored when the caller cannot see the
	// Boutique accesses (hasShopAccess is null then).
	HasShopAccess Opt[bool] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of companies of the whole list with these filters (one more
	// count on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

CompanyListParams is the parameters of CompaniesService.List (listCompanies): its query parameters. A nil *CompanyListParams sends none.

type CompanyListSort

type CompanyListSort string

CompanyListSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: name, -name, number, -number, createdAt, -createdAt, headquartersCity, -headquartersCity, updatedAt, -updatedAt.

const CompanyListSortCreatedAt CompanyListSort = "createdAt"

CompanyListSortCreatedAt is "createdAt".

const CompanyListSortCreatedAtDesc CompanyListSort = "-createdAt"

CompanyListSortCreatedAtDesc is "-createdAt".

const CompanyListSortHeadquartersCity CompanyListSort = "headquartersCity"

CompanyListSortHeadquartersCity is "headquartersCity".

const CompanyListSortHeadquartersCityDesc CompanyListSort = "-headquartersCity"

CompanyListSortHeadquartersCityDesc is "-headquartersCity".

const CompanyListSortName CompanyListSort = "name"

CompanyListSortName is "name".

const CompanyListSortNameDesc CompanyListSort = "-name"

CompanyListSortNameDesc is "-name".

const CompanyListSortNumber CompanyListSort = "number"

CompanyListSortNumber is "number".

const CompanyListSortNumberDesc CompanyListSort = "-number"

CompanyListSortNumberDesc is "-number".

const CompanyListSortUpdatedAt CompanyListSort = "updatedAt"

CompanyListSortUpdatedAt is "updatedAt".

const CompanyListSortUpdatedAtDesc CompanyListSort = "-updatedAt"

CompanyListSortUpdatedAtDesc is "-updatedAt".

type CompanyListTagMode

type CompanyListTagMode string

CompanyListTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const CompanyListTagModeAll CompanyListTagMode = "ALL"

CompanyListTagModeAll is "ALL".

const CompanyListTagModeAny CompanyListTagMode = "ANY"

CompanyListTagModeAny is "ANY".

type CompanyNeighbors

type CompanyNeighbors struct {
	// The company listed just before (company_<uuid>), or null.
	Previous *string `json:"previous"`
	// The company listed just after (company_<uuid>), or null.
	Next *string `json:"next"`
	// contains filtered or unexported fields
}

CompanyNeighbors — The companies before and after one in a list read with the same filters and sort; null at either end.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (CompanyNeighbors) ETag

func (m CompanyNeighbors) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (CompanyNeighbors) LastResponse

func (m CompanyNeighbors) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type CompanyPostalAddressCreateParams

type CompanyPostalAddressCreateParams struct {
	// Its internal name, never printed; absent for none.
	Label Opt[string] `json:"label"`
	// The line printed above the street when the recipient is not simply the company.
	RecipientLine Opt[string] `json:"recipientLine"`
	// The street.
	Line1 string `json:"line1"`
	// The postal code.
	PostalCode Opt[string] `json:"postalCode"`
	// The city.
	City Opt[string] `json:"city"`
	// The SIRET of the establishment at this address (14 digits).
	Siret Opt[string] `json:"siret"`
	// What whoever delivers there needs to know (a door code, where to leave the goods).
	DeliveryInstructions Opt[string] `json:"deliveryInstructions"`
	// Its own opening hours: the whole week, each day once, its ranges HH:mm to a later HH:mm; [] for none; absent
	// or null: none of its own, the company's apply.
	OpeningHours Opt[[]OpeningHoursDay] `json:"openingHours"`
}

CompanyPostalAddressCreateParams is the parameters of CompanyPostalAddressesService.Create (createCompanyPostalAddress): its body's members. A nil *CompanyPostalAddressCreateParams sends none.

A postal address to give a company.

A member of type Opt is left out unless set.

func (CompanyPostalAddressCreateParams) MarshalJSON

func (p CompanyPostalAddressCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type CompanyPostalAddressUpdateParams

type CompanyPostalAddressUpdateParams struct {
	// A new internal name, never printed; null for none.
	Label Opt[string] `json:"label"`
	// The line printed above the street; null: addressed like the company.
	RecipientLine Opt[string] `json:"recipientLine"`
	// The street; never null.
	Line1 Opt[string] `json:"line1"`
	// The postal code; null for none.
	PostalCode Opt[string] `json:"postalCode"`
	// The city; null for none.
	City Opt[string] `json:"city"`
	// The SIRET of the establishment at this address (14 digits); null for none.
	Siret Opt[string] `json:"siret"`
	// What whoever delivers there needs to know; null for none.
	DeliveryInstructions Opt[string] `json:"deliveryInstructions"`
	// Its own opening hours, the whole week (each day once, its ranges HH:mm to a later HH:mm), [] for none; null:
	// none of its own, the company's apply.
	OpeningHours Opt[[]OpeningHoursDay] `json:"openingHours"`
}

CompanyPostalAddressUpdateParams is the parameters of CompanyPostalAddressesService.Update (updateCompanyPostalAddress): its body's members. A nil *CompanyPostalAddressUpdateParams sends none.

A merge patch of a postal address of a company (RFC 7396): an absent member is unchanged, null clears it. A new street, postal code or city locates the address again; openingHours null: none of its own, the company's apply.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (CompanyPostalAddressUpdateParams) MarshalJSON

func (p CompanyPostalAddressUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type CompanyPostalAddressesService

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

CompanyPostalAddressesService — /organizations/{id}/companies/{companyId}/postal-addresses.

Reach it as client.Organization("organization_…").Companies.PostalAddresses.

func (*CompanyPostalAddressesService) Create

Create — Add a postal address to a company.

Adds a delivery address to a customer, geocoded for the routes. Moves the company's version. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/companies/{companyId}/postal-addresses · requires COMPANIES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the postal address. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CrmCompanyInvalidSiretError (422 crm.company.invalid-siret): The establishment SIRET of an address is not 14 digits.

Example:

org := client.Organization("organization_…")
postalAddress, err := org.Companies.PostalAddresses.Create(ctx, "company_…", &myle.CompanyPostalAddressCreateParams{Line1: "line1"})
if err != nil {
	return err
}
fmt.Println(postalAddress.ID, postalAddress.ETag())

func (*CompanyPostalAddressesService) Delete

func (s *CompanyPostalAddressesService) Delete(ctx context.Context, companyID string, postalAddressID string, opts ...RequestOption) error

Delete — Remove a postal address from a company.

Removes a postal address from a customer. Refused (409) while it is the company's headquarters or billing address, or an order in progress is delivered there. Moves the company's version. With If-Match (the company's ETag), refused (412) if the company changed since it was read.

DELETE /organizations/{id}/companies/{companyId}/postal-addresses/{postalAddressId} · requires COMPANIES_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the postal address is removed).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CrmPostalAddressReferencedError (409 crm.postal-address.referenced): A delivery address the request removes is still in use: nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
postalAddress, err := org.Companies.PostalAddresses.Get(ctx, "company_…", "postalAddress_…")
if err != nil {
	return err
}
err = org.Companies.PostalAddresses.Delete(ctx, "company_…", "postalAddress_…", myle.IfMatch(postalAddress))
if err != nil {
	return err
}

func (*CompanyPostalAddressesService) Get

func (s *CompanyPostalAddressesService) Get(ctx context.Context, companyID string, postalAddressID string, opts ...RequestOption) (*PostalAddress, error)

Get — Get a postal address of a company.

Returns a postal address of a customer — its headquarters, billing or delivery address —, as the company embeds it, with the company's ETag (an address has no version of its own).

GET /organizations/{id}/companies/{companyId}/postal-addresses/{postalAddressId} · requires COMPANIES_LIST.

It answers the postal address. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
postalAddress, err := org.Companies.PostalAddresses.Get(ctx, "company_…", "postalAddress_…")
if err != nil {
	return err
}
fmt.Println(postalAddress.ID, postalAddress.ETag())

func (*CompanyPostalAddressesService) Update

func (s *CompanyPostalAddressesService) Update(ctx context.Context, companyID string, postalAddressID string, params *CompanyPostalAddressUpdateParams, opts ...RequestOption) (*PostalAddress, error)

Update — Change a postal address of a company.

Changes a postal address of a customer — its headquarters, billing or delivery address — (a JSON merge patch). A new street, postal code or city locates it again for the routes, and the customer's documents in progress follow it; a label, a SIRET, hours or instructions alone keep its location. Moves the company's version. With If-Match (the company's ETag), refused (412) if the company changed since it was read.

PATCH /organizations/{id}/companies/{companyId}/postal-addresses/{postalAddressId} · requires COMPANIES_PATCH.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the postal address, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CrmCompanyInvalidSiretError (422 crm.company.invalid-siret): The establishment SIRET of an address is not 14 digits.

Example:

org := client.Organization("organization_…")
postalAddress, err := org.Companies.PostalAddresses.Get(ctx, "company_…", "postalAddress_…")
if err != nil {
	return err
}
updated, err := org.Companies.PostalAddresses.Update(ctx, "company_…", "postalAddress_…", &myle.CompanyPostalAddressUpdateParams{Label: myle.String("label")}, myle.IfMatch(postalAddress))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type CompanyReplaceEinvoicingRoutingParams

type CompanyReplaceEinvoicingRoutingParams struct {
	// An address the directory publishes for the SIREN, or null for the automatic resolution.
	Identifier Opt[string] `json:"identifier"`
}

CompanyReplaceEinvoicingRoutingParams is the parameters of CompaniesService.ReplaceEinvoicingRouting (replaceCompanyEinvoicingRouting): its body's members. A nil *CompanyReplaceEinvoicingRoutingParams sends none.

The address to retain: one the directory publishes, or null to return to the automatic resolution.

A member of type Opt is left out unless set.

func (CompanyReplaceEinvoicingRoutingParams) MarshalJSON

func (p CompanyReplaceEinvoicingRoutingParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type CompanySepaMandateCreateInvitationParams

type CompanySepaMandateCreateInvitationParams struct {
	// Mail the invitation to the customer (true), or only answer its link (false, the default).
	SendEmail Opt[bool] `json:"sendEmail"`
	// The customer's address, which Stripe puts on the mandate; by default the customer's first e-mail address.
	Email Opt[string] `json:"email"`
	// A word of yours, in the mail (sendEmail: true), 2000 characters at most.
	Message Opt[string] `json:"message"`
}

CompanySepaMandateCreateInvitationParams is the parameters of CompanySepaMandateService.CreateInvitation (createSepaMandateInvitation): its body's members. A nil *CompanySepaMandateCreateInvitationParams sends none.

An invitation to sign a SEPA mandate: mailed to the customer (sendEmail: true), or as a link to share.

A member of type Opt is left out unless set.

func (CompanySepaMandateCreateInvitationParams) MarshalJSON

MarshalJSON writes the body: the members given, in the document's order.

type CompanySepaMandateService

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

CompanySepaMandateService — /organizations/{id}/companies/{companyId}/sepa-mandate.

Reach it as client.Organization("organization_…").Companies.SepaMandate.

func (*CompanySepaMandateService) CreateInvitation

CreateInvitation — Invite a customer to sign a SEPA mandate.

Invites a customer to sign a SEPA mandate on a page of Myle's (their bank details go to Stripe, never through the caller): sendEmail: true mails it (counted in the plan's monthly e-mail quota, logged on the customer), else the answer carries the link to share yourself. The link works once and lasts 7 days. Refused when the collection is off or paused, or the plan does not carry SEPA debits. A session passes the passkey step-up stripe.sendMandateInvitation; an API key holding the right needs none. Send an Idempotency-Key to retry safely: without it, a retry mails again.

POST /organizations/{id}/companies/{companyId}/sepa-mandate/invitation · requires STRIPE_MANDATES_MANAGE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the invitation.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *PaymentPlanCollectionRequiredError (402 payments.plan.collection-required): The organization's plan does not carry Stripe collection (SEPA debits, mandates, auto-debit, online payment of invoices); the trial does not either. It comes with a paid plan.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *PaymentCollectionDisabledError (409 payments.collection.disabled): The organization turned its Stripe collection off (in its payment settings): nothing is debited, no mandate is offered, no auto-debit is turned on until it turns it back on.
  • *PaymentCollectionPausedError (409 payments.collection.paused): The organization's Stripe collection is paused because it no longer pays for Myle: it resumes with its subscription.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
sepaMandateInvitation, err := org.Companies.SepaMandate.CreateInvitation(ctx, "company_…", &myle.CompanySepaMandateCreateInvitationParams{Email: myle.String("contact@example.com")})
if err != nil {
	return err
}
fmt.Println(sepaMandateInvitation)

func (*CompanySepaMandateService) Revoke

func (s *CompanySepaMandateService) Revoke(ctx context.Context, companyID string, opts ...RequestOption) (*SepaMandate, error)

Revoke — Revoke a customer's SEPA mandate.

Revokes a customer's SEPA mandates at Stripe (every SEPA bank account detached) and turns their auto-debit off: nothing can be debited until they sign a new one. Open even when the collection is off or paused. A session passes the passkey step-up stripe.revokeMandate; an API key holding the right needs none. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/companies/{companyId}/sepa-mandate/revoke · requires STRIPE_MANDATES_MANAGE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the mandate, revoked (NONE).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *PaymentAccountNotConnectedError (409 payments.account.not-connected): No Stripe account is connected to the organization: connect one first (POST …/payments-account/onboarding).
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
sepaMandate, err := org.Companies.SepaMandate.Revoke(ctx, "company_…")
if err != nil {
	return err
}
fmt.Println(sepaMandate)

type CompanyType

type CompanyType string

CompanyType is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: BUSINESS_FR, CONSUMER, FOREIGN.

const CompanyTypeBusinessFr CompanyType = "BUSINESS_FR"

CompanyTypeBusinessFr is "BUSINESS_FR".

const CompanyTypeConsumer CompanyType = "CONSUMER"

CompanyTypeConsumer is "CONSUMER".

const CompanyTypeForeign CompanyType = "FOREIGN"

CompanyTypeForeign is "FOREIGN".

type CompanyUpdateParams

type CompanyUpdateParams struct {
	// A new reference, unique among the organization's companies.
	Number Opt[string] `json:"number"`
	// A new name.
	Name Opt[string] `json:"name"`
	// BUSINESS_FR, CONSUMER or FOREIGN; to BUSINESS_FR, the company must have a SIREN or a VAT number.
	Type Opt[string] `json:"type"`
	// A new SIREN (or SIRET); null for none.
	Siren Opt[string] `json:"siren"`
	// A new VAT number; null for none.
	VatNumber Opt[string] `json:"vatNumber"`
	// A new accounting account; null for none.
	AccountingNumber Opt[string] `json:"accountingNumber"`
	// A new phone number; null for none.
	Phone Opt[string] `json:"phone"`
	// A new discount in percent, from 0 to 100; null for none.
	DiscountPercentage Opt[string] `json:"discountPercentage"`
	// Why it gets a discount; null for none.
	DiscountReason Opt[string] `json:"discountReason"`
	// MONTHLY, TEN_DAYS, DAILY or DISABLED; null is DISABLED.
	InvoicingPeriod Opt[string] `json:"invoicingPeriod"`
	// Its tags, all of them (managed ones are kept whatever is sent); null for none.
	Tags Opt[[]string] `json:"tags"`
	// Its delivery addresses, all of them: one with the id of an address it has changes it, one without an id is
	// added, one it has that is not sent is removed (refused, 409, while something uses it); null for none.
	DeliveryAddresses Opt[[]DeliveryAddressInput] `json:"deliveryAddresses"`
	// Debit its validated invoices by SEPA automatically (true) or not (false), through its mandate. Needs
	// STRIPE_MANDATES_MANAGE (the other members, COMPANIES_PATCH). Turning it on is refused when the collection is
	// off or paused or the plan lacks SEPA debits, and a session passes the passkey step-up stripe.setAutoDebit (an
	// API key holding the right needs none); turning it off is always possible. Applied before the other members.
	AutoDebit Opt[bool] `json:"autoDebit"`
	// Whether its delivery notes show the prices.
	ShowPricesOnDeliveryNotes Opt[bool] `json:"showPricesOnDeliveryNotes"`
	// Its opening hours, all of them, one entry per day (a day not sent has none); null for none.
	OpeningHours Opt[[]OpeningHoursDay] `json:"openingHours"`
	// Its places, all of them; null for none.
	Places Opt[[]string] `json:"places"`
}

CompanyUpdateParams is the parameters of CompaniesService.Update (updateCompany): its body's members. A nil *CompanyUpdateParams sends none.

A merge patch of a company (RFC 7396): an absent member is unchanged. Its e-mail addresses are changed under …/email-addresses, its headquarters and billing addresses are not changed here.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (CompanyUpdateParams) MarshalJSON

func (p CompanyUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type ConflictError

type ConflictError struct{ *APIError }

ConflictError is a 409: the request conflicts with the current state (a number taken, a request still running…).

func (*ConflictError) Unwrap

func (e *ConflictError) Unwrap() error

Unwrap answers the *APIError.

type ConnectionError

type ConnectionError struct {
	// Operation is the operationId of the call: getProduct.
	Operation string
	// Err is the underlying failure.
	Err error
}

ConnectionError is a request that got no answer: the network, DNS or TLS failed, or the answer was cut short. Retried automatically when the call is safe to repeat.

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

func (*ConnectionError) Unwrap

func (e *ConnectionError) Unwrap() error

Unwrap answers the underlying failure.

type CoreAPIVersionUnsupportedContext

type CoreAPIVersionUnsupportedContext struct {
	// The oldest version this endpoint supports (YYYY-MM-DD).
	Minimum string `json:"minimum"`
}

CoreAPIVersionUnsupportedContext — The detail of this error.

The context of an error code.

type CoreAPIVersionUnsupportedError

type CoreAPIVersionUnsupportedError struct {
	*APIError
	// Context is the detail of the error.
	Context CoreAPIVersionUnsupportedContext
}

CoreAPIVersionUnsupportedError is the error code core.api-version-unsupported: The Myle-API-Version asked for is not a date, or is older than the endpoint's oldest supported behavior.

The document names no operation answering it, so it wraps *APIError directly: its Status is the one received.

func (*CoreAPIVersionUnsupportedError) Unwrap

Unwrap answers the *APIError it is.

type CoreBadGatewayContext

type CoreBadGatewayContext struct {
	// The service that refused.
	Service string `json:"service"`
}

CoreBadGatewayContext — The detail of this error.

The context of an error code.

type CoreBadGatewayError

type CoreBadGatewayError struct {
	*BadGatewayError
	// Context is the detail of the error.
	Context CoreBadGatewayContext
}

CoreBadGatewayError is the error code core.bad-gateway (502): A service Myle depends on refused the operation.

It wraps *BadGatewayError, which wraps *APIError: errors.As matches any of the three.

func (*CoreBadGatewayError) Unwrap

func (e *CoreBadGatewayError) Unwrap() error

Unwrap answers the *BadGatewayError it is.

type CoreBadRequestError

type CoreBadRequestError struct {
	*BadRequestError
}

CoreBadRequestError is the error code core.bad-request (400): The request cannot be read: unreadable JSON, malformed parameter.

It wraps *BadRequestError, which wraps *APIError: errors.As matches any of the three.

func (*CoreBadRequestError) Unwrap

func (e *CoreBadRequestError) Unwrap() error

Unwrap answers the *BadRequestError it is.

type CoreConflictContext

type CoreConflictContext struct {
	// The entity concerned, by its English name (organization, invoice…).
	Kind string `json:"kind"`
	// The conflicting key.
	Name string `json:"name"`
}

CoreConflictContext — The detail of this error.

The context of an error code.

type CoreConflictError

type CoreConflictError struct {
	*ConflictError
	// Context is the detail of the error.
	Context CoreConflictContext
}

CoreConflictError is the error code core.conflict (409): The request conflicts with an existing resource.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*CoreConflictError) Unwrap

func (e *CoreConflictError) Unwrap() error

Unwrap answers the *ConflictError it is.

type CoreIdempotencyKeyInUseError

type CoreIdempotencyKeyInUseError struct {
	*ConflictError
}

CoreIdempotencyKeyInUseError is the error code core.idempotency-key-in-use (409): A request with this Idempotency-Key is still being processed; retry after the Retry-After delay.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*CoreIdempotencyKeyInUseError) Unwrap

func (e *CoreIdempotencyKeyInUseError) Unwrap() error

Unwrap answers the *ConflictError it is.

type CoreIdempotencyKeyReusedError

type CoreIdempotencyKeyReusedError struct {
	*UnprocessableEntityError
}

CoreIdempotencyKeyReusedError is the error code core.idempotency-key-reused (422): This Idempotency-Key was already used for a request with another body.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*CoreIdempotencyKeyReusedError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type CoreInternalError

type CoreInternalError struct {
	*InternalServerError
}

CoreInternalError is the error code core.internal-error (500): An unexpected error; give the request_id to support.

It wraps *InternalServerError, which wraps *APIError: errors.As matches any of the three.

func (*CoreInternalError) Unwrap

func (e *CoreInternalError) Unwrap() error

Unwrap answers the *InternalServerError it is.

type CoreMethodNotAllowedError

type CoreMethodNotAllowedError struct {
	*MethodNotAllowedError
}

CoreMethodNotAllowedError is the error code core.method-not-allowed (405): This path does not accept this method; see the Allow header.

It wraps *MethodNotAllowedError, which wraps *APIError: errors.As matches any of the three.

func (*CoreMethodNotAllowedError) Unwrap

func (e *CoreMethodNotAllowedError) Unwrap() error

Unwrap answers the *MethodNotAllowedError it is.

type CoreModuleRequiredContext

type CoreModuleRequiredContext struct {
	// The module required.
	Module string `json:"module"`
}

CoreModuleRequiredContext — The detail of this error.

The context of an error code.

type CoreModuleRequiredError

type CoreModuleRequiredError struct {
	*PaymentRequiredError
	// Context is the detail of the error.
	Context CoreModuleRequiredContext
}

CoreModuleRequiredError is the error code core.module-required (402): The organization's plan or settings lack the module this operation belongs to.

It wraps *PaymentRequiredError, which wraps *APIError: errors.As matches any of the three.

func (*CoreModuleRequiredError) Unwrap

func (e *CoreModuleRequiredError) Unwrap() error

Unwrap answers the *PaymentRequiredError it is.

type CoreNotAcceptableContext

type CoreNotAcceptableContext struct {
	// The media types this operation can answer.
	Available []string `json:"available"`
}

CoreNotAcceptableContext — The detail of this error.

The context of an error code.

type CoreNotAcceptableError

type CoreNotAcceptableError struct {
	*NotAcceptableError
	// Context is the detail of the error.
	Context CoreNotAcceptableContext
}

CoreNotAcceptableError is the error code core.not-acceptable (406): No representation of the resource matches the Accept header.

It wraps *NotAcceptableError, which wraps *APIError: errors.As matches any of the three.

func (*CoreNotAcceptableError) Unwrap

func (e *CoreNotAcceptableError) Unwrap() error

Unwrap answers the *NotAcceptableError it is.

type CoreNotFoundContext

type CoreNotFoundContext struct {
	// The entity concerned, by its English name (organization, invoice…).
	Kind string `json:"kind"`
	// The id or key sent.
	Name string `json:"name"`
}

CoreNotFoundContext — The detail of this error.

The context of an error code.

type CoreNotFoundError

type CoreNotFoundError struct {
	*NotFoundError
	// Context is the detail of the error.
	Context CoreNotFoundContext
}

CoreNotFoundError is the error code core.not-found (404): What the path names does not exist, or the caller cannot see it (the same answer for both).

It wraps *NotFoundError, which wraps *APIError: errors.As matches any of the three.

func (*CoreNotFoundError) Unwrap

func (e *CoreNotFoundError) Unwrap() error

Unwrap answers the *NotFoundError it is.

type CorePayloadTooLargeContext

type CorePayloadTooLargeContext struct {
	// The largest body accepted, in bytes.
	MaxBytes int64 `json:"maxBytes"`
}

CorePayloadTooLargeContext — The detail of this error.

The context of an error code.

type CorePayloadTooLargeError

type CorePayloadTooLargeError struct {
	*PayloadTooLargeError
	// Context is the detail of the error.
	Context CorePayloadTooLargeContext
}

CorePayloadTooLargeError is the error code core.payload-too-large (413): The request body is larger than this operation accepts.

It wraps *PayloadTooLargeError, which wraps *APIError: errors.As matches any of the three.

func (*CorePayloadTooLargeError) Unwrap

func (e *CorePayloadTooLargeError) Unwrap() error

Unwrap answers the *PayloadTooLargeError it is.

type CorePlanLimitReachedContext

type CorePlanLimitReachedContext struct {
	// The limit reached: companies, invoicesPerMonth, users or emailsPerMonth.
	Limit string `json:"limit"`
	// What the plan allows.
	Max int64 `json:"max"`
	// What the organization has (at least max).
	Current int64 `json:"current"`
}

CorePlanLimitReachedContext — The detail of this error.

The context of an error code.

type CorePlanLimitReachedError

type CorePlanLimitReachedError struct {
	*PaymentRequiredError
	// Context is the detail of the error.
	Context CorePlanLimitReachedContext
}

CorePlanLimitReachedError is the error code core.plan-limit-reached (402): The organization's plan allows no more of what this operation creates.

It wraps *PaymentRequiredError, which wraps *APIError: errors.As matches any of the three.

func (*CorePlanLimitReachedError) Unwrap

func (e *CorePlanLimitReachedError) Unwrap() error

Unwrap answers the *PaymentRequiredError it is.

type CorePreconditionFailedError

type CorePreconditionFailedError struct {
	*PreconditionFailedError
}

CorePreconditionFailedError is the error code core.precondition-failed (412): The If-Match sent is stale: the resource has changed since.

It wraps *PreconditionFailedError, which wraps *APIError: errors.As matches any of the three.

func (*CorePreconditionFailedError) Unwrap

func (e *CorePreconditionFailedError) Unwrap() error

Unwrap answers the *PreconditionFailedError it is.

type CoreRateLimitedContext

type CoreRateLimitedContext struct {
	// The rate-limit policy exceeded (read, write, export; ip or user for the per-address or per-session limit of
	// the whole application).
	Policy string `json:"policy"`
}

CoreRateLimitedContext — The detail of this error.

The context of an error code.

type CoreRateLimitedError

type CoreRateLimitedError struct {
	*RateLimitError
	// Context is the detail of the error.
	Context CoreRateLimitedContext
}

CoreRateLimitedError is the error code core.rate-limited (429): Too many requests for this policy; retry after the Retry-After delay.

It wraps *RateLimitError, which wraps *APIError: errors.As matches any of the three.

func (*CoreRateLimitedError) Unwrap

func (e *CoreRateLimitedError) Unwrap() error

Unwrap answers the *RateLimitError it is.

type CoreSubscriptionRequiredError

type CoreSubscriptionRequiredError struct {
	*PaymentRequiredError
}

CoreSubscriptionRequiredError is the error code core.subscription-required (402): The organization has no active paid subscription: it is read-only, it can read and export but not write.

It wraps *PaymentRequiredError, which wraps *APIError: errors.As matches any of the three.

func (*CoreSubscriptionRequiredError) Unwrap

Unwrap answers the *PaymentRequiredError it is.

type CoreUnavailableError

type CoreUnavailableError struct {
	*ServiceUnavailableError
}

CoreUnavailableError is the error code core.unavailable (503): Myle or one of its services is temporarily unavailable; retry later.

It wraps *ServiceUnavailableError, which wraps *APIError: errors.As matches any of the three.

func (*CoreUnavailableError) Unwrap

func (e *CoreUnavailableError) Unwrap() error

Unwrap answers the *ServiceUnavailableError it is.

type CoreUnsupportedMediaTypeError

type CoreUnsupportedMediaTypeError struct {
	*UnsupportedMediaTypeError
}

CoreUnsupportedMediaTypeError is the error code core.unsupported-media-type (415): The request body's Content-Type is not one this operation reads.

It wraps *UnsupportedMediaTypeError, which wraps *APIError: errors.As matches any of the three.

func (*CoreUnsupportedMediaTypeError) Unwrap

Unwrap answers the *UnsupportedMediaTypeError it is.

type CoreValidationFailedContext

type CoreValidationFailedContext struct {
	// Each invalid field: path (a JSON Pointer into the body, or ?<name> for a query parameter) and code.
	Fields []CoreValidationFailedContextField `json:"fields"`
}

CoreValidationFailedContext — The detail of this error.

The context of an error code.

type CoreValidationFailedContextField

type CoreValidationFailedContextField struct {
	// A JSON Pointer into the body (/lines/0/quantity), or ?<name>.
	Path string `json:"path"`
	// A kebab-case reason: required, invalid-format, too-long….
	Code string `json:"code"`
}

CoreValidationFailedContextField — One invalid field.

The context of an error code.

type CoreValidationFailedError

type CoreValidationFailedError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context CoreValidationFailedContext
}

CoreValidationFailedError is the error code core.validation-failed (422): Fields of the request are invalid.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*CoreValidationFailedError) Unwrap

func (e *CoreValidationFailedError) Unwrap() error

Unwrap answers the *UnprocessableEntityError it is.

type CorrectableInvoice

type CorrectableInvoice struct {
	// The invoice's id (invoice_<uuid>).
	ID string `json:"id"`
	// Always "invoice".
	Object string `json:"object"`
	// Its legal number.
	Number string `json:"number"`
	// Its issue date (YYYY-MM-DD).
	IssueDate string `json:"issueDate"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Total Money `json:"total"`
	// Its status (see the invoice's).
	Status string `json:"status"`
}

CorrectableInvoice — An invoice a credit note can correct: an issued invoice of the same customer. total: its total.

type CrmCompanyAccountingNumberTakenContext

type CrmCompanyAccountingNumberTakenContext struct {
	// The accounting number sent.
	AccountingNumber string `json:"accountingNumber"`
}

CrmCompanyAccountingNumberTakenContext — The detail of this error.

The context of an error code.

type CrmCompanyAccountingNumberTakenError

type CrmCompanyAccountingNumberTakenError struct {
	*ConflictError
	// Context is the detail of the error.
	Context CrmCompanyAccountingNumberTakenContext
}

CrmCompanyAccountingNumberTakenError is the error code crm.company.accounting-number-taken (409): Another company of the organization has this accounting number.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*CrmCompanyAccountingNumberTakenError) Unwrap

Unwrap answers the *ConflictError it is.

type CrmCompanyIdentifierRequiredError

type CrmCompanyIdentifierRequiredError struct {
	*UnprocessableEntityError
}

CrmCompanyIdentifierRequiredError is the error code crm.company.identifier-required (422): A French business (type BUSINESS_FR) needs a SIREN, a SIRET or a VAT number; send one, or choose the CONSUMER or FOREIGN type.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*CrmCompanyIdentifierRequiredError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type CrmCompanyInvalidIdentifierContext

type CrmCompanyInvalidIdentifierContext struct {
	// The member refused: siren or vatNumber (the VAT number wins when both are sent).
	Field string `json:"field"`
	// The value sent.
	Value string `json:"value"`
}

CrmCompanyInvalidIdentifierContext — The detail of this error.

The context of an error code.

type CrmCompanyInvalidIdentifierError

type CrmCompanyInvalidIdentifierError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context CrmCompanyInvalidIdentifierContext
}

CrmCompanyInvalidIdentifierError is the error code crm.company.invalid-identifier (422): The SIREN (9 digits, or a 14-digit SIRET) or the French VAT number (FR, a 2-digit key, the SIREN) cannot be read.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*CrmCompanyInvalidIdentifierError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type CrmCompanyInvalidSiretContext

type CrmCompanyInvalidSiretContext struct {
	// The SIRET sent.
	Siret string `json:"siret"`
}

CrmCompanyInvalidSiretContext — The detail of this error.

The context of an error code.

type CrmCompanyInvalidSiretError

type CrmCompanyInvalidSiretError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context CrmCompanyInvalidSiretContext
}

CrmCompanyInvalidSiretError is the error code crm.company.invalid-siret (422): The establishment SIRET of an address is not 14 digits.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*CrmCompanyInvalidSiretError) Unwrap

func (e *CrmCompanyInvalidSiretError) Unwrap() error

Unwrap answers the *UnprocessableEntityError it is.

type CrmPostalAddressReferencedContext

type CrmPostalAddressReferencedContext struct {
	// The address in use (postalAddress_<uuid>).
	PostalAddressID string `json:"postalAddressId"`
	// What uses it: HEADQUARTERS, BILLING, ORDERS.
	Reasons []string `json:"reasons"`
}

CrmPostalAddressReferencedContext — The detail of this error.

The context of an error code.

type CrmPostalAddressReferencedError

type CrmPostalAddressReferencedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context CrmPostalAddressReferencedContext
}

CrmPostalAddressReferencedError is the error code crm.postal-address.referenced (409): A delivery address the request removes is still in use: nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*CrmPostalAddressReferencedError) Unwrap

Unwrap answers the *ConflictError it is.

type DebitFee

type DebitFee struct {
	// An amount of money: a decimal string and its ISO 4217 currency.
	Amount Money `json:"amount"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Fee Money `json:"fee"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	StripeFee Money `json:"stripeFee"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	MyleFee Money `json:"myleFee"`
}

DebitFee — The last SEPA debit of an invoice, in EUR: amount debited, fee withheld (stripeFee, Stripe's, plus myleFee, Myle's commission incl. VAT).

type DeliveryAddressInput

type DeliveryAddressInput struct {
	// The id of one of the company's delivery addresses (postalAddress_<uuid>); absent for a new one.
	ID Opt[string] `json:"id"`
	// Its internal name, never printed.
	Label Opt[string] `json:"label"`
	// The line printed above the street; absent or null: the stored one is kept.
	RecipientLine Opt[string] `json:"recipientLine"`
	// The street.
	Line1 string `json:"line1"`
	// The postal code.
	PostalCode Opt[string] `json:"postalCode"`
	// The city.
	City Opt[string] `json:"city"`
	// The SIRET of the establishment at this address (14 digits).
	Siret Opt[string] `json:"siret"`
}

DeliveryAddressInput — A delivery address of a company, in a change of the company: with the id of one it has, it is that one. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (DeliveryAddressInput) MarshalJSON

func (p DeliveryAddressInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type DeliveryNote

type DeliveryNote struct {
	// The delivery note's id (deliveryNote_<uuid>).
	ID string `json:"id"`
	// Always "deliveryNote".
	Object string `json:"object"`
	// The organization it belongs to (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// Its number in the organization's sequence, or null.
	Number *string `json:"number"`
	// WAITING_FOR_INVOICING (to bill), INVOICED (billed), BILLED_WITH_ORDER (its order is billed on its deposits).
	// An open enum. A deleted delivery note is never returned (404).
	Status string `json:"status"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// The customer's name as the note froze it.
	CompanyName string `json:"companyName"`
	// Where the goods were delivered, as printed.
	Address string `json:"address"`
	// Its date (YYYY-MM-DD).
	DeliveryDate string `json:"deliveryDate"`
	// A description printed on it, or null.
	Description *string `json:"description"`
	// Its lines, in order.
	Lines []DeliveryNoteLine `json:"lines"`
	// The orders it was made from (order_<uuid>).
	OrderIDs []string `json:"orderIds"`
	// The invoices that billed it (invoice_<uuid>).
	InvoiceIDs []string `json:"invoiceIds"`
	// Its own tags, sorted.
	Tags []string `json:"tags"`
	// When it was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When it, its lines or its status last changed (RFC 3339, UTC).
	UpdatedAt string `json:"updatedAt"`
	// contains filtered or unexported fields
}

DeliveryNote — A delivery note (« bon de livraison »): the goods handed to a customer, with the stock lots they left from. Read alone for now: the rest of the delivery notes (list, create, send, bill) comes with their own lot.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (DeliveryNote) ETag

func (m DeliveryNote) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (DeliveryNote) LastResponse

func (m DeliveryNote) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type DeliveryNoteLine

type DeliveryNoteLine struct {
	// The line's position in the delivery note, from 0.
	Index int `json:"index"`
	// The catalog product it delivers (product_<uuid>), or null.
	ProductID *string `json:"productId"`
	// The product's reference as printed, or null.
	Number *string `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// The quantity delivered, a decimal string.
	Quantity string `json:"quantity"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate, a decimal string in percent.
	VatRate string `json:"vatRate"`
	// The line's discount in percent, a decimal string, or null.
	DiscountRate *string `json:"discountRate"`
	// The stock the goods left (stock_<uuid>), or null when none moved.
	StockID *string `json:"stockId"`
	// The lot's number (traceability code) the goods left, or null.
	LotNumber *string `json:"lotNumber"`
	// Where the goods come from, or null.
	Origin *string `json:"origin"`
	// The days until the « date limite de consommation » (DLC) printed, or null.
	UseByDays *int `json:"useByDays"`
	// The days until the « date de consommation recommandée » (DCR) printed, or null.
	ConsumeBeforeDays *int `json:"consumeBeforeDays"`
	// The days until the « date de durabilité minimale » (DDM) printed, or null.
	BestBeforeDays *int `json:"bestBeforeDays"`
}

DeliveryNoteLine — A delivery note line. unitPrice: excluding VAT, as the note prints it (the customer's discount applied).

type DeliveryNotesService

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

DeliveryNotesService — the organization's delivery notes: the goods handed to a customer, with the lots they left from (/organizations/{id}/delivery-notes).

Reach it as client.Organization("organization_…").DeliveryNotes.

func (*DeliveryNotesService) Get

func (s *DeliveryNotesService) Get(ctx context.Context, deliveryNoteID string, opts ...RequestOption) (*DeliveryNote, error)

Get — Get a delivery note.

Returns a delivery note the caller can see — one an order's delivery made (POST …/orders/{orderId}/deliver), or any other —; one outside its tag scope, deleted or unknown is a 404. The rest of the delivery notes comes with their own lot.

GET /organizations/{id}/delivery-notes/{deliveryNoteId} · requires DELIVERYFORMS_LIST.

It answers the delivery note. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
deliveryNote, err := org.DeliveryNotes.Get(ctx, "deliveryNote_…")
if err != nil {
	return err
}
fmt.Println(deliveryNote.ID, deliveryNote.ETag())

type DeprecationNotice

type DeprecationNotice struct {
	// OperationID is the operation answered with a deprecated behavior: listProducts.
	OperationID string
	// Method is its HTTP method.
	Method string
	// Path is its path template: /organizations/{id}/products.
	Path string
	// APIVersion is the Myle-API-Version the client sent.
	APIVersion string
	// Deprecation is the Deprecation header (RFC 9745, @<unix seconds>), "" when absent.
	Deprecation string
	// Sunset is the Sunset header (RFC 8594, an HTTP date): when the behavior stops being served, "" when absent.
	Sunset string
	// Link is the changelog page of the change (Link: <…>; rel="deprecation"), "" when absent.
	Link string
}

DeprecationNotice is what the deprecation handler receives (see WithDeprecationHandler).

type ETag

type ETag string

ETag is the ETag of a version of a resource you kept, for IfMatch: myle.IfMatch(myle.ETag(`"3"`)).

func (ETag) ETag

func (e ETag) ETag() string

ETag answers the ETag itself.

type Einvoice

type Einvoice struct {
	// einvoice.
	Object string `json:"object"`
	// The invoice (invoice_<uuid>).
	InvoiceID string `json:"invoiceId"`
	// The technical status (PENDING_SUBMISSION, SUBMITTED, ISSUED, RECEIVED, APPROVED, REFUSED, SUBMISSION_FAILED,
	// REJECTED…), or null when never submitted.
	Status *string `json:"status"`
	// When it was submitted, or null.
	SubmittedAt *string `json:"submittedAt"`
	// When its status last moved, or null.
	LastStatusAt *string `json:"lastStatusAt"`
	// Why the last submission failed, read.
	Failure *EinvoiceFailure `json:"failure"`
	// History.
	History []EinvoiceEvent `json:"history"`
	// Can the invoice go through the e-invoicing network.
	Eligibility EinvoiceEligibility `json:"eligibility"`
	// contains filtered or unexported fields
}

Einvoice — An invoice's e-invoice on the network: its technical status, its history, the last failure read (or null), its eligibility.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Einvoice) ETag

func (m Einvoice) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Einvoice) LastResponse

func (m Einvoice) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type EinvoiceEligibility

type EinvoiceEligibility struct {
	// It can be submitted now.
	IsEligible bool `json:"isEligible"`
	// Why not, as codes (ORG_NOT_CONNECTED, CLIENT_NOT_INVOICABLE, NOT_VALIDATED…); empty when eligible.
	Reasons []string `json:"reasons"`
	// IsEmissionEnabled.
	IsEmissionEnabled bool `json:"isEmissionEnabled"`
	// IsOrganizationConnected.
	IsOrganizationConnected bool `json:"isOrganizationConnected"`
	// IsOrganizationVerified.
	IsOrganizationVerified bool `json:"isOrganizationVerified"`
	// The customer's SIREN, or null.
	CustomerSiren *string `json:"customerSiren"`
	// The customer is reachable on the network, or null when the directory did not say.
	IsCustomerReachable *bool `json:"isCustomerReachable"`
	// The address the e-invoice carries (BT-49), or null.
	CustomerAddress *string `json:"customerAddress"`
	// Its legal channel is the network: it is not sent by e-mail.
	IsNetworkRequired bool `json:"isNetworkRequired"`
	// A credit note that names no invoice yet: name it before submitting.
	IsCreditNoteReferenceMissing bool `json:"isCreditNoteReferenceMissing"`
	// A failed submission reopened the e-mail (the PDF goes as on a customer off the network).
	IsMailAllowedAfterFailure bool `json:"isMailAllowedAfterFailure"`
	// An automatic retry is about to submit it again.
	IsAutoRetryPending bool `json:"isAutoRetryPending"`
}

EinvoiceEligibility — Can the invoice go through the e-invoicing network.

type EinvoiceEvent

type EinvoiceEvent struct {
	// The status reached (SUBMITTED, ISSUED, RECEIVED, APPROVED, REFUSED, SUBMISSION_FAILED…).
	Status string `json:"status"`
	// An instant, RFC 3339 in UTC.
	At string `json:"at"`
}

EinvoiceEvent — A step of an e-invoice's life on the network.

type EinvoiceFailure

type EinvoiceFailure struct {
	// The classified failure: ROUTING_ADDRESS_UNKNOWN, INVALID_DOCUMENT, PLATFORM_REJECTED….
	Code string `json:"code"`
	// A sentence in French, as the Myle screens show it.
	Message string `json:"message"`
	// Submitting again may succeed.
	IsRetryable bool `json:"isRetryable"`
	// Submitting again may succeed now.
	IsRetryableNow bool `json:"isRetryableNow"`
	// The automatic retries are spent.
	AreRetriesExhausted bool `json:"areRetriesExhausted"`
}

EinvoiceFailure — Why the last submission failed, read.

type EinvoicesService

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

EinvoicesService — e-invoicing through the organization's approved platform (SuperPDP): its connection and address, a customer's routing, the e-invoice of an invoice, and the e-invoices suppliers send (/organizations/{id}/einvoices).

Reach it as client.Organization("organization_…").Einvoices.

func (*EinvoicesService) ListOutgoingFailures

func (s *EinvoicesService) ListOutgoingFailures(ctx context.Context, opts ...RequestOption) *Paginator[OutgoingEinvoiceFailure]

ListOutgoingFailures — List the failed submissions.

Returns the submissions that failed and wait for an action, in the caller's tag scope, each failure read with the address the directory publishes today. A refusal of routing to a customer no longer reachable waits for nothing (its invoice goes by e-mail) and is left out. All at once: nextCursor is never present.

GET /organizations/{id}/einvoices/outgoing-failures · requires INVOICES_LIST.

It answers a *Paginator over a single page (the failed submissions). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for outgoingEinvoiceFailure, err := range org.Einvoices.ListOutgoingFailures(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(outgoingEinvoiceFailure)
}

type Einvoicing

type Einvoicing struct {
	// einvoicing.
	Object string `json:"object"`
	// The organization (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// The organization's connection to the e-invoicing platform (SuperPDP).
	Connection *EinvoicingConnection `json:"connection"`
	// Whether the organization can issue e-invoices.
	Emission EinvoicingEmission `json:"emission"`
	// The electronic address the organization's invoices carry (BT-34, 0225:<SIREN>…), or null when none is
	// retained yet.
	Address *string `json:"address"`
	// contains filtered or unexported fields
}

Einvoicing — The organization's e-invoicing: its connection (null for a caller without ORGANISATION_PATCH), whether it can emit, its electronic address.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Einvoicing) ETag

func (m Einvoicing) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Einvoicing) LastResponse

func (m Einvoicing) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type EinvoicingAddress

type EinvoicingAddress struct {
	// einvoicingAddress.
	Object string `json:"object"`
	// The organization (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// The address retained, or null.
	Selected *string `json:"selected"`
	// Where it comes from: DIRECTORY (resolved automatically) or MANUAL (a person's choice), or null.
	Source *string `json:"source"`
	// Candidates.
	Candidates []RoutingCandidate `json:"candidates"`
	// The base address is retained while the directory also publishes establishment addresses (alternatives: the
	// first of them): check it.
	EstablishmentWarning *EstablishmentWarning `json:"establishmentWarning"`
	// contains filtered or unexported fields
}

EinvoicingAddress — The organization's electronic address: what the directory publishes for its SIREN and the one retained; establishmentWarning, or null.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (EinvoicingAddress) ETag

func (m EinvoicingAddress) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (EinvoicingAddress) LastResponse

func (m EinvoicingAddress) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type EinvoicingAuthorization

type EinvoicingAuthorization struct {
	// einvoicingAuthorization.
	Object string `json:"object"`
	// SuperPDP's authorize URL: open it in the user's browser; SuperPDP returns to the Myle web app.
	AuthorizeURL string `json:"authorizeUrl"`
	// INSEE's profile of the organization when it suggests SuperPDP will refuse it: a warning, not a refusal.
	Warning *EinvoicingScopeWarning `json:"warning"`
	// contains filtered or unexported fields
}

EinvoicingAuthorization — Where to send the user to connect the organization to SuperPDP, and a warning to show before leaving (or null).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (EinvoicingAuthorization) ETag

func (m EinvoicingAuthorization) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (EinvoicingAuthorization) LastResponse

func (m EinvoicingAuthorization) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type EinvoicingConnection

type EinvoicingConnection struct {
	// NOT_CONNECTED, CONNECTED, or SIMULATED (a demo organization, connected and verified by simulation).
	Status string `json:"status"`
	// SuperPDP's verification of the company (KYB): VERIFIED, NEEDS_REVIEW, FAILED, or null when unknown.
	CompanyVerificationStatus *string `json:"companyVerificationStatus"`
	// SuperPDP's verification of the person who connected: VERIFIED, NEEDS_REVIEW, NOT_VERIFIED, or null.
	UserIdentityVerificationStatus *string `json:"userIdentityVerificationStatus"`
	// When the statuses were last read from SuperPDP (POST …/einvoicing/sync), or null.
	LastCheckedAt *string `json:"lastCheckedAt"`
	// When the organization connected, or null.
	ConnectedAt *string `json:"connectedAt"`
}

EinvoicingConnection — The organization's connection to the e-invoicing platform (SuperPDP).

type EinvoicingConnectionNotConnectedError

type EinvoicingConnectionNotConnectedError struct {
	*ConflictError
}

EinvoicingConnectionNotConnectedError is the error code einvoicing.connection.not-connected (409): The organization is not connected to the e-invoicing platform: connect it first (POST …/einvoicing/connect, with a signed-in session).

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingConnectionNotConnectedError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingEinvoiceCreditNoteReferenceMissingError

type EinvoicingEinvoiceCreditNoteReferenceMissingError struct {
	*ConflictError
}

EinvoicingEinvoiceCreditNoteReferenceMissingError is the error code einvoicing.einvoice.credit-note-reference-missing (409): A credit note goes through the network with the invoice it corrects: name it on the credit note first. Nothing was submitted.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingEinvoiceCreditNoteReferenceMissingError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingEinvoiceNotEligibleContext

type EinvoicingEinvoiceNotEligibleContext struct {
	// Why, as codes (ORG_NOT_CONNECTED, CLIENT_NOT_INVOICABLE…).
	Reasons []string `json:"reasons"`
}

EinvoicingEinvoiceNotEligibleContext — The detail of this error.

The context of an error code.

type EinvoicingEinvoiceNotEligibleError

type EinvoicingEinvoiceNotEligibleError struct {
	*ConflictError
	// Context is the detail of the error.
	Context EinvoicingEinvoiceNotEligibleContext
}

EinvoicingEinvoiceNotEligibleError is the error code einvoicing.einvoice.not-eligible (409): The invoice cannot go through the e-invoicing network now (the organization not connected or verified, the customer not reachable, the invoice not validated…): nothing was submitted. Read GET …/einvoice for the eligibility.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingEinvoiceNotEligibleError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingEinvoiceNotRetryableContext

type EinvoicingEinvoiceNotRetryableContext struct {
	// The classified failure (ROUTING_ADDRESS_UNKNOWN, INVALID_DOCUMENT…).
	FailureCode string `json:"failureCode"`
}

EinvoicingEinvoiceNotRetryableContext — The detail of this error.

The context of an error code.

type EinvoicingEinvoiceNotRetryableError

type EinvoicingEinvoiceNotRetryableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context EinvoicingEinvoiceNotRetryableContext
}

EinvoicingEinvoiceNotRetryableError is the error code einvoicing.einvoice.not-retryable (409): The last submission failed in a way submitting again cannot fix until something changes (the customer's address, the invoice's content): nothing was submitted.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingEinvoiceNotRetryableError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingEmission

type EinvoicingEmission struct {
	// Emission is open to the organization (the platform's switches, the pilot list).
	IsEnabled bool `json:"isEnabled"`
	// The organization is connected to SuperPDP.
	IsOrganizationConnected bool `json:"isOrganizationConnected"`
	// SuperPDP verified the company.
	IsOrganizationVerified bool `json:"isOrganizationVerified"`
	// All three: invoices to reachable customers go through the network.
	CanEmit bool `json:"canEmit"`
}

EinvoicingEmission — Whether the organization can issue e-invoices.

type EinvoicingIncomingEinvoiceAlreadySettledError

type EinvoicingIncomingEinvoiceAlreadySettledError struct {
	*ConflictError
}

EinvoicingIncomingEinvoiceAlreadySettledError is the error code einvoicing.incoming-einvoice.already-settled (409): The incoming e-invoice is paid already (PAYMENT_SENT): its purchase and its payment are booked, and no decision or payment walks that back. Nothing was done.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingIncomingEinvoiceAlreadySettledError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingIncomingEinvoiceNotAcceptedContext

type EinvoicingIncomingEinvoiceNotAcceptedContext struct {
	// Its status (RECEIVED, DISPUTED, REFUSED…).
	Status string `json:"status"`
}

EinvoicingIncomingEinvoiceNotAcceptedContext — The detail of this error.

The context of an error code.

type EinvoicingIncomingEinvoiceNotAcceptedError

type EinvoicingIncomingEinvoiceNotAcceptedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context EinvoicingIncomingEinvoiceNotAcceptedContext
}

EinvoicingIncomingEinvoiceNotAcceptedError is the error code einvoicing.incoming-einvoice.not-accepted (409): Only an accepted (or partially accepted) incoming e-invoice is marked paid: accept it first. Nothing was recorded.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingIncomingEinvoiceNotAcceptedError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingIncomingEinvoiceNotOnPlatformError

type EinvoicingIncomingEinvoiceNotOnPlatformError struct {
	*ConflictError
}

EinvoicingIncomingEinvoiceNotOnPlatformError is the error code einvoicing.incoming-einvoice.not-on-platform (409): The incoming e-invoice has no id on the e-invoicing platform: no decision can be sent for it. Nothing was done.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingIncomingEinvoiceNotOnPlatformError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingOrganizationNotSubjectError

type EinvoicingOrganizationNotSubjectError struct {
	*ConflictError
}

EinvoicingOrganizationNotSubjectError is the error code einvoicing.organization.not-subject (409): The organization is declared an individual or a foreign company: it is outside the mandatory e-invoicing reform, and has nothing to connect.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingOrganizationNotSubjectError) Unwrap

Unwrap answers the *ConflictError it is.

type EinvoicingOrganizationPaidPlanRequiredError

type EinvoicingOrganizationPaidPlanRequiredError struct {
	*PaymentRequiredError
}

EinvoicingOrganizationPaidPlanRequiredError is the error code einvoicing.organization.paid-plan-required (402): E-invoicing comes with a paid plan: an organization on a trial or without a paid subscription cannot connect to the e-invoicing platform, nor submit invoices unless it connected before. Nothing was done.

It wraps *PaymentRequiredError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingOrganizationPaidPlanRequiredError) Unwrap

Unwrap answers the *PaymentRequiredError it is.

type EinvoicingResourceReplaceAddressParams

type EinvoicingResourceReplaceAddressParams struct {
	// An address the directory publishes for the SIREN, or null for the automatic resolution.
	Identifier Opt[string] `json:"identifier"`
}

EinvoicingResourceReplaceAddressParams is the parameters of EinvoicingResourceService.ReplaceAddress (replaceEinvoicingAddress): its body's members. A nil *EinvoicingResourceReplaceAddressParams sends none.

The address to retain: one the directory publishes, or null to return to the automatic resolution.

A member of type Opt is left out unless set.

func (EinvoicingResourceReplaceAddressParams) MarshalJSON

func (p EinvoicingResourceReplaceAddressParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type EinvoicingResourceService

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

EinvoicingResourceService — e-invoicing through the organization's approved platform (SuperPDP): its connection and address, a customer's routing, the e-invoice of an invoice, and the e-invoices suppliers send (/organizations/{id}/einvoicing).

Reach it as client.Organization("organization_…").Einvoicing.

func (*EinvoicingResourceService) Connect

Connect — Start connecting the organization to SuperPDP.

Answers SuperPDP's authorize URL: open it in the user's browser. SuperPDP checks the company and the person on its own pages (Myle never sees identity documents), then returns to the Myle web app, which finishes the connection. Reserved to organizations on a paid plan (402), asked before the step-up. A signed-in session only, with a passkey step-up for einvoicing.connect. An organization outside the reform (an individual, a foreign company) is refused (409); a warning comes when INSEE suggests SuperPDP will refuse it.

POST /organizations/{id}/einvoicing/connect · requires ORGANISATION_PATCH · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers where to send the user.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *EinvoicingOrganizationPaidPlanRequiredError (402 einvoicing.organization.paid-plan-required): E-invoicing comes with a paid plan: an organization on a trial or without a paid subscription cannot connect to the e-invoicing platform, nor submit invoices unless it connected before. Nothing was done.
  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingOrganizationNotSubjectError (409 einvoicing.organization.not-subject): The organization is declared an individual or a foreign company: it is outside the mandatory e-invoicing reform, and has nothing to connect.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
einvoicingAuthorization, err := org.Einvoicing.Connect(ctx)
if err != nil {
	return err
}
fmt.Println(einvoicingAuthorization)

func (*EinvoicingResourceService) Disconnect

func (s *EinvoicingResourceService) Disconnect(ctx context.Context, opts ...RequestOption) (*Einvoicing, error)

Disconnect — Disconnect the organization from SuperPDP.

Revokes the organization's SuperPDP tokens and removes its connection: invoices go back to e-mail. A signed-in session only, with a passkey step-up for einvoicing.disconnect. Allowed to an organization without subscription (leaving is never refused). Answers the e-invoicing as it is now.

POST /organizations/{id}/einvoicing/disconnect · requires ORGANISATION_PATCH · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the organization's e-invoicing, disconnected.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
einvoicing, err := org.Einvoicing.Disconnect(ctx)
if err != nil {
	return err
}
fmt.Println(einvoicing)

func (*EinvoicingResourceService) Get

Get — Get the organization's e-invoicing.

Returns the organization's e-invoicing: whether it can issue e-invoices, its electronic address, and, for a caller holding ORGANISATION_PATCH, its connection to SuperPDP and the verification statuses (null otherwise). Reads the database only: POST …/einvoicing/sync reads the statuses from SuperPDP.

GET /organizations/{id}/einvoicing · requires one of ORGANISATION_PATCH, INVOICES_LIST.

It answers the organization's e-invoicing.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
einvoicing, err := org.Einvoicing.Get(ctx)
if err != nil {
	return err
}
fmt.Println(einvoicing)

func (*EinvoicingResourceService) GetAddress

GetAddress — Get the organization's electronic address.

Returns the electronic addresses the directory publishes for the organization's SIREN, each with its state on the network, and the one its invoices carry (BT-34). Asks the directory: 502 when it does not answer.

GET /organizations/{id}/einvoicing/address · requires ORGANISATION_GET.

It answers the addresses.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
einvoicingAddress, err := org.Einvoicing.GetAddress(ctx)
if err != nil {
	return err
}
fmt.Println(einvoicingAddress)

func (*EinvoicingResourceService) ReplaceAddress

ReplaceAddress — Choose the organization's electronic address.

Retains one of the addresses the directory publishes (a person's choice, never overwritten by the automatic resolution), or, with null, returns to the automatic resolution. Audited.

PUT /organizations/{id}/einvoicing/address · requires ORGANISATION_PATCH.

It answers the addresses, the choice retained.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *EinvoicingRoutingAddressNotPublishedError (422 einvoicing.routing-address.not-published): The directory does not publish this electronic address for the SIREN: choose one of the candidates read with GET. Nothing was written.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
einvoicingAddress, err := org.Einvoicing.ReplaceAddress(ctx, &myle.EinvoicingResourceReplaceAddressParams{Identifier: myle.String("identifier")})
if err != nil {
	return err
}
fmt.Println(einvoicingAddress)

func (*EinvoicingResourceService) Sync

Sync — Read the verification statuses from SuperPDP.

Reads the company's and the person's verification statuses from SuperPDP and stores a change: useful while a freshly connected organization is under review. Allowed to an organization without subscription.

POST /organizations/{id}/einvoicing/sync · requires ORGANISATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the organization's e-invoicing.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingConnectionNotConnectedError (409 einvoicing.connection.not-connected): The organization is not connected to the e-invoicing platform: connect it first (POST …/einvoicing/connect, with a signed-in session).
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
einvoicing, err := org.Einvoicing.Sync(ctx)
if err != nil {
	return err
}
fmt.Println(einvoicing)

type EinvoicingRoutingAddressNotPublishedContext

type EinvoicingRoutingAddressNotPublishedContext struct {
	// The address refused, as sent.
	Identifier string `json:"identifier"`
}

EinvoicingRoutingAddressNotPublishedContext — The detail of this error.

The context of an error code.

type EinvoicingRoutingAddressNotPublishedError

type EinvoicingRoutingAddressNotPublishedError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context EinvoicingRoutingAddressNotPublishedContext
}

EinvoicingRoutingAddressNotPublishedError is the error code einvoicing.routing-address.not-published (422): The directory does not publish this electronic address for the SIREN: choose one of the candidates read with GET. Nothing was written.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*EinvoicingRoutingAddressNotPublishedError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type EinvoicingScopeWarning

type EinvoicingScopeWarning struct {
	// Why the organization looks outside the reform (a code).
	Reason string `json:"reason"`
	// The organization's SIREN.
	Siren string `json:"siren"`
	// INSEE's legal form code, or null.
	LegalFormCode *string `json:"legalFormCode"`
	// INSEE's legal form label, or null.
	LegalFormLabel *string `json:"legalFormLabel"`
	// The activity code (APE), or null.
	ApeCode *string `json:"apeCode"`
	// The activity label, or null.
	ApeLabel *string `json:"apeLabel"`
}

EinvoicingScopeWarning — INSEE's profile of the organization when it suggests SuperPDP will refuse it: a warning, not a refusal.

type EmailAddressInput

type EmailAddressInput struct {
	// The e-mail address.
	Address string `json:"address"`
	// Its label.
	Label Opt[string] `json:"label"`
	// The documents to send to it automatically: INVOICE, DELIVERY_NOTE, ORDER, QUOTATION; absent for none.
	Purposes Opt[[]string] `json:"purposes"`
}

EmailAddressInput — An e-mail address to give a company. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (EmailAddressInput) MarshalJSON

func (p EmailAddressInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type Error

type Error interface {
	error
	// contains filtered or unexported methods
}

Error is implemented by every error this SDK returns besides the caller's own context errors (context.Canceled, context.DeadlineExceeded) and ErrMissingAPIKey.

type EstablishmentAlternative

type EstablishmentAlternative struct {
	// Identifier.
	Identifier string `json:"identifier"`
	// Its SIRET, or null.
	Siret *string `json:"siret"`
	// Its service code, or null.
	ServiceCode *string `json:"serviceCode"`
	// The establishment's name, or null.
	Name *string `json:"name"`
	// The establishment's city, or null.
	City *string `json:"city"`
	// A readable label, or null.
	Label *string `json:"label"`
}

EstablishmentAlternative — Another address of the SIREN the company's base address may not be the right one against.

type EstablishmentWarning

type EstablishmentWarning struct {
	// The base address retained.
	BaseIdentifier string `json:"baseIdentifier"`
	// How many other active addresses the directory publishes.
	Count int `json:"count"`
	// Alternatives.
	Alternatives []EstablishmentAlternative `json:"alternatives"`
}

EstablishmentWarning — The base address is retained while the directory also publishes establishment addresses (alternatives: the first of them): check it.

type FileDownload

type FileDownload struct {
	// Data holds the file's bytes, as received.
	Data []byte
	// Filename is the file's name from Content-Disposition (filename* first, else filename), cut to its
	// last path segment so it never names another directory: invoice-0001.pdf. It is "" when the API sent none
	// (an empty name, "." or ".." count as none): choose one then.
	Filename string
	// ContentType is the file's media type, from Content-Type: application/pdf.
	ContentType string
	// Response is the HTTP response the file came in: status, headers, RequestID.
	Response *Response
}

FileDownload is a file a call answered (an invoice's PDF, from InvoicesService.DownloadPDF): its bytes as received, never decoded nor parsed, with what the response said about them.

func (*FileDownload) Save

func (f *FileDownload) Save(path string) error

Save writes the bytes to path, replacing the file if there is one (mode 0644 before the umask).

err := file.Save(cmp.Or(file.Filename, "invoice.pdf"))

type GetInvoicePDFFormat

type GetInvoicePDFFormat string

GetInvoicePDFFormat is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: pdf, facturx.

const GetInvoicePDFFormatFacturx GetInvoicePDFFormat = "facturx"

GetInvoicePDFFormatFacturx is "facturx".

const GetInvoicePDFFormatPDF GetInvoicePDFFormat = "pdf"

GetInvoicePDFFormatPDF is "pdf".

type GetInvoicePDFParams

type GetInvoicePDFParams struct {
	// With Accept: application/pdf: pdf (the default) or facturx; ignored for JSON.
	Format Opt[GetInvoicePDFFormat] `json:"-"`
}

GetInvoicePDFParams is the parameters of InvoicesService.DownloadPDF (getInvoicePdf): its query parameters. A nil *GetInvoicePDFParams sends none.

type HostedLink struct {
	// Always "hostedLink".
	Object string `json:"object"`
	// The page's address, at Stripe.
	URL string `json:"url"`
	// contains filtered or unexported fields
}

HostedLink — A page hosted by Stripe, to open in a browser: it expires within minutes and works once.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (HostedLink) ETag

func (m HostedLink) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (HostedLink) LastResponse

func (m HostedLink) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type IncomingEinvoice

type IncomingEinvoice struct {
	// incomingEinvoice_<uuid>.
	ID string `json:"id"`
	// incomingEinvoice.
	Object string `json:"object"`
	// RECEIVED, MADE_AVAILABLE, IN_HAND, APPROVED, PARTIALLY_APPROVED, DISPUTED, REFUSED, PAYMENT_SENT….
	Status string `json:"status"`
	// The supplier's invoice number, or null.
	Number *string `json:"number"`
	// The invoice's date, or null.
	IssueDate *string `json:"issueDate"`
	// Its due date, or null.
	DueDate *string `json:"dueDate"`
	// The supplier who sent the e-invoice, as its document names it.
	Sender IncomingEinvoiceSender `json:"sender"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Subtotal *Money `json:"subtotal"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Total *Money `json:"total"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	AmountDue *Money `json:"amountDue"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	PrepaidAmount *Money `json:"prepaidAmount"`
	// Its CII (XML) is stored: Accept: application/xml reads it.
	HasXML bool `json:"hasXml"`
	// When it arrived.
	ReceivedAt string `json:"receivedAt"`
	// When its status last moved, or null.
	LastStatusAt *string `json:"lastStatusAt"`
}

IncomingEinvoice — An e-invoice a supplier sent the organization. subtotal: excluding VAT; total: including VAT; amountDue: what remains to pay (the net payable, or the total); prepaidAmount: paid before the invoice; each null when the document gives none.

type IncomingEinvoiceAcceptPartiallyParams

type IncomingEinvoiceAcceptPartiallyParams struct {
	// What you contest, in your words: kept in Myle's history, not sent as a code.
	Reason Opt[string] `json:"reason"`
}

IncomingEinvoiceAcceptPartiallyParams is the parameters of IncomingEinvoicesService.AcceptPartially (acceptIncomingEinvoicePartially): its body's members. A nil *IncomingEinvoiceAcceptPartiallyParams sends none.

What the buyer contests, kept in Myle: required to dispute, optional to accept in part.

A member of type Opt is left out unless set.

func (IncomingEinvoiceAcceptPartiallyParams) MarshalJSON

func (p IncomingEinvoiceAcceptPartiallyParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type IncomingEinvoiceDetail

type IncomingEinvoiceDetail struct {
	// incomingEinvoice_<uuid>.
	ID string `json:"id"`
	// incomingEinvoice.
	Object string `json:"object"`
	// RECEIVED, MADE_AVAILABLE, IN_HAND, APPROVED, PARTIALLY_APPROVED, DISPUTED, REFUSED, PAYMENT_SENT….
	Status string `json:"status"`
	// The supplier's invoice number, or null.
	Number *string `json:"number"`
	// The invoice's date, or null.
	IssueDate *string `json:"issueDate"`
	// Its due date, or null.
	DueDate *string `json:"dueDate"`
	// The supplier who sent the e-invoice, as its document names it.
	Sender IncomingEinvoiceSender `json:"sender"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Subtotal *Money `json:"subtotal"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Total *Money `json:"total"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	AmountDue *Money `json:"amountDue"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	PrepaidAmount *Money `json:"prepaidAmount"`
	// Its CII (XML) is stored: Accept: application/xml reads it.
	HasXML bool `json:"hasXml"`
	// A PDF can be shown (the sender's, or SuperPDP's render): Accept: application/pdf reads it.
	HasPDF bool `json:"hasPdf"`
	// When it arrived.
	ReceivedAt string `json:"receivedAt"`
	// When its status last moved, or null.
	LastStatusAt *string `json:"lastStatusAt"`
	// Lines.
	Lines []IncomingEinvoiceLine `json:"lines"`
	// History.
	History []IncomingEinvoiceEvent `json:"history"`
	// contains filtered or unexported fields
}

IncomingEinvoiceDetail — An e-invoice a supplier sent the organization, with its lines and its history. subtotal: excluding VAT; total: including VAT; amountDue: what remains to pay (the net payable, or the total); prepaidAmount: paid before the invoice; each null when the document gives none.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (IncomingEinvoiceDetail) ETag

func (m IncomingEinvoiceDetail) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (IncomingEinvoiceDetail) LastResponse

func (m IncomingEinvoiceDetail) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type IncomingEinvoiceDisputeParams

type IncomingEinvoiceDisputeParams struct {
	// What you contest, in your words: kept in Myle's history, not sent as a code.
	Reason Opt[string] `json:"reason"`
}

IncomingEinvoiceDisputeParams is the parameters of IncomingEinvoicesService.Dispute (disputeIncomingEinvoice): its body's members. A nil *IncomingEinvoiceDisputeParams sends none.

What the buyer contests, kept in Myle: required to dispute, optional to accept in part.

A member of type Opt is left out unless set.

func (IncomingEinvoiceDisputeParams) MarshalJSON

func (p IncomingEinvoiceDisputeParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type IncomingEinvoiceEvent

type IncomingEinvoiceEvent struct {
	// The status reached.
	Status string `json:"status"`
	// An instant, RFC 3339 in UTC.
	At string `json:"at"`
	// Who did it (user_<uuid>), or null for the platform.
	UserID *string `json:"userId"`
	// A refusal's AFNOR reason code, or null.
	ReasonCode *string `json:"reasonCode"`
	// What the buyer wrote with the decision (kept in Myle), or null.
	Note *string `json:"note"`
}

IncomingEinvoiceEvent — A step of an incoming e-invoice's life: a decision, a payment, a status the platform gave.

type IncomingEinvoiceLine

type IncomingEinvoiceLine struct {
	// The line's position, from 1 as in the document.
	Index int `json:"index"`
	// The supplier's reference, or null.
	Reference *string `json:"reference"`
	// Name.
	Name string `json:"name"`
	// A longer description, or null.
	Description *string `json:"description"`
	// The quantity, a decimal string, or null.
	Quantity *string `json:"quantity"`
	// The unit (UN/ECE rec. 20: TNE, KGM, LS…), or null.
	Unit *string `json:"unit"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	UnitPrice *Money `json:"unitPrice"`
	// The VAT rate, a decimal string in percent, or null.
	VatRate *string `json:"vatRate"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Total *Money `json:"total"`
}

IncomingEinvoiceLine — A line of an incoming e-invoice, as the supplier's document gives it. unitPrice and total: excluding VAT, null when not given.

type IncomingEinvoiceListParams

type IncomingEinvoiceListParams struct {
	// E-invoices of one of these statuses (repeat it for several): RECEIVED, APPROVED, REFUSED…. Each value is sent
	// (name=a&name=b).
	Status []IncomingEinvoiceListStatus `json:"-"`
	// Invoices dated on or after this date (YYYY-MM-DD).
	InvoiceDateFrom Opt[string] `json:"-"`
	// Invoices dated on or before this date (YYYY-MM-DD).
	InvoiceDateTo Opt[string] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
}

IncomingEinvoiceListParams is the parameters of IncomingEinvoicesService.List (listIncomingEinvoices): its query parameters. A nil *IncomingEinvoiceListParams sends none.

type IncomingEinvoiceListStatus

type IncomingEinvoiceListStatus string

IncomingEinvoiceListStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: PENDING_SUBMISSION, SUBMISSION_FAILED, SUBMITTED, ISSUED, RECEIVED, MADE_AVAILABLE, IN_HAND, APPROVED, PARTIALLY_APPROVED, DISPUTED, SUSPENDED, COMPLETED, REFUSED, PAYMENT_SENT, PAYMENT_RECEIVED, REJECTED.

const IncomingEinvoiceListStatusApproved IncomingEinvoiceListStatus = "APPROVED"

IncomingEinvoiceListStatusApproved is "APPROVED".

const IncomingEinvoiceListStatusCompleted IncomingEinvoiceListStatus = "COMPLETED"

IncomingEinvoiceListStatusCompleted is "COMPLETED".

const IncomingEinvoiceListStatusDisputed IncomingEinvoiceListStatus = "DISPUTED"

IncomingEinvoiceListStatusDisputed is "DISPUTED".

const IncomingEinvoiceListStatusInHand IncomingEinvoiceListStatus = "IN_HAND"

IncomingEinvoiceListStatusInHand is "IN_HAND".

const IncomingEinvoiceListStatusIssued IncomingEinvoiceListStatus = "ISSUED"

IncomingEinvoiceListStatusIssued is "ISSUED".

const IncomingEinvoiceListStatusMadeAvailable IncomingEinvoiceListStatus = "MADE_AVAILABLE"

IncomingEinvoiceListStatusMadeAvailable is "MADE_AVAILABLE".

const IncomingEinvoiceListStatusPartiallyApproved IncomingEinvoiceListStatus = "PARTIALLY_APPROVED"

IncomingEinvoiceListStatusPartiallyApproved is "PARTIALLY_APPROVED".

const IncomingEinvoiceListStatusPaymentReceived IncomingEinvoiceListStatus = "PAYMENT_RECEIVED"

IncomingEinvoiceListStatusPaymentReceived is "PAYMENT_RECEIVED".

const IncomingEinvoiceListStatusPaymentSent IncomingEinvoiceListStatus = "PAYMENT_SENT"

IncomingEinvoiceListStatusPaymentSent is "PAYMENT_SENT".

const IncomingEinvoiceListStatusPendingSubmission IncomingEinvoiceListStatus = "PENDING_SUBMISSION"

IncomingEinvoiceListStatusPendingSubmission is "PENDING_SUBMISSION".

const IncomingEinvoiceListStatusReceived IncomingEinvoiceListStatus = "RECEIVED"

IncomingEinvoiceListStatusReceived is "RECEIVED".

const IncomingEinvoiceListStatusRefused IncomingEinvoiceListStatus = "REFUSED"

IncomingEinvoiceListStatusRefused is "REFUSED".

const IncomingEinvoiceListStatusRejected IncomingEinvoiceListStatus = "REJECTED"

IncomingEinvoiceListStatusRejected is "REJECTED".

const IncomingEinvoiceListStatusSubmissionFailed IncomingEinvoiceListStatus = "SUBMISSION_FAILED"

IncomingEinvoiceListStatusSubmissionFailed is "SUBMISSION_FAILED".

const IncomingEinvoiceListStatusSubmitted IncomingEinvoiceListStatus = "SUBMITTED"

IncomingEinvoiceListStatusSubmitted is "SUBMITTED".

const IncomingEinvoiceListStatusSuspended IncomingEinvoiceListStatus = "SUSPENDED"

IncomingEinvoiceListStatusSuspended is "SUSPENDED".

type IncomingEinvoiceMarkPaidParams

type IncomingEinvoiceMarkPaidParams struct {
	// CASH, CHECK, TRANSFER (the default), CARD, SEPA_DIRECT_DEBIT, PAYPAL or OTHER.
	Method Opt[string] `json:"method"`
	// The payment's date (YYYY-MM-DD); today (Europe/Paris) by default.
	PaidAt Opt[string] `json:"paidAt"`
}

IncomingEinvoiceMarkPaidParams is the parameters of IncomingEinvoicesService.MarkPaid (markIncomingEinvoicePaid): its body's members. A nil *IncomingEinvoiceMarkPaidParams sends none.

How and when the supplier was paid.

A member of type Opt is left out unless set.

func (IncomingEinvoiceMarkPaidParams) MarshalJSON

func (p IncomingEinvoiceMarkPaidParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type IncomingEinvoiceRefuseParams

type IncomingEinvoiceRefuseParams struct {
	// The reason, an AFNOR code of the refusal list (MDT-113): sent to the supplier through the platform.
	ReasonCode Opt[string] `json:"reasonCode"`
	// What you write: kept in Myle's history, not sent.
	Note Opt[string] `json:"note"`
}

IncomingEinvoiceRefuseParams is the parameters of IncomingEinvoicesService.Refuse (refuseIncomingEinvoice): its body's members. A nil *IncomingEinvoiceRefuseParams sends none.

A refusal: an AFNOR reason code (MDT-113) sent to the supplier, and an optional note kept in Myle.

A member of type Opt is left out unless set.

func (IncomingEinvoiceRefuseParams) MarshalJSON

func (p IncomingEinvoiceRefuseParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type IncomingEinvoiceSender

type IncomingEinvoiceSender struct {
	// Its name, or null.
	Name *string `json:"name"`
	// Its SIREN, or null.
	Siren *string `json:"siren"`
	// Its SIRET, or null.
	Siret *string `json:"siret"`
	// Its VAT number, or null.
	VatNumber *string `json:"vatNumber"`
}

IncomingEinvoiceSender — The supplier who sent the e-invoice, as its document names it.

type IncomingEinvoicesService

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

IncomingEinvoicesService — e-invoicing through the organization's approved platform (SuperPDP): its connection and address, a customer's routing, the e-invoice of an invoice, and the e-invoices suppliers send (/organizations/{id}/incoming-einvoices).

Reach it as client.Organization("organization_…").IncomingEinvoices.

func (*IncomingEinvoicesService) Accept

func (s *IncomingEinvoicesService) Accept(ctx context.Context, incomingEinvoiceID string, opts ...RequestOption) (*IncomingEinvoiceDetail, error)

Accept — Accept an incoming e-invoice.

Tells the supplier, through the platform, that the organization accepts the invoice (fr:205), then books the purchase (unless an approved expense books it already). SuperPDP refusing the decision changes nothing (502). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/accept · requires INVOICES_RECEIVE_DECIDE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the incoming e-invoice, accepted.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingIncomingEinvoiceAlreadySettledError (409 einvoicing.incoming-einvoice.already-settled): The incoming e-invoice is paid already (PAYMENT_SENT): its purchase and its payment are booked, and no decision or payment walks that back. Nothing was done.
  • *EinvoicingIncomingEinvoiceNotOnPlatformError (409 einvoicing.incoming-einvoice.not-on-platform): The incoming e-invoice has no id on the e-invoicing platform: no decision can be sent for it. Nothing was done.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
incomingEinvoiceDetail, err := org.IncomingEinvoices.Accept(ctx, "incomingEinvoice_…")
if err != nil {
	return err
}
fmt.Println(incomingEinvoiceDetail.ID)

func (*IncomingEinvoicesService) AcceptPartially

func (s *IncomingEinvoicesService) AcceptPartially(ctx context.Context, incomingEinvoiceID string, params *IncomingEinvoiceAcceptPartiallyParams, opts ...RequestOption) (*IncomingEinvoiceDetail, error)

AcceptPartially — Accept an incoming e-invoice in part.

Tells the supplier, through the platform, that the organization accepts the invoice in part (fr:206), with an optional reason kept in Myle; the purchase is booked in full, the correction comes as the supplier's credit note. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/accept-partially · requires INVOICES_RECEIVE_DECIDE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the incoming e-invoice, accepted in part.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingIncomingEinvoiceAlreadySettledError (409 einvoicing.incoming-einvoice.already-settled): The incoming e-invoice is paid already (PAYMENT_SENT): its purchase and its payment are booked, and no decision or payment walks that back. Nothing was done.
  • *EinvoicingIncomingEinvoiceNotOnPlatformError (409 einvoicing.incoming-einvoice.not-on-platform): The incoming e-invoice has no id on the e-invoicing platform: no decision can be sent for it. Nothing was done.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
incomingEinvoiceDetail, err := org.IncomingEinvoices.AcceptPartially(ctx, "incomingEinvoice_…", &myle.IncomingEinvoiceAcceptPartiallyParams{Reason: myle.String("reason")})
if err != nil {
	return err
}
fmt.Println(incomingEinvoiceDetail.ID)

func (*IncomingEinvoicesService) Dispute

Dispute — Dispute an incoming e-invoice.

Tells the supplier, through the platform, that the organization disputes the invoice (fr:207): a reason is required (422), kept in Myle. Not final: the supplier answers. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/dispute · requires INVOICES_RECEIVE_DECIDE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the incoming e-invoice, disputed.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingIncomingEinvoiceAlreadySettledError (409 einvoicing.incoming-einvoice.already-settled): The incoming e-invoice is paid already (PAYMENT_SENT): its purchase and its payment are booked, and no decision or payment walks that back. Nothing was done.
  • *EinvoicingIncomingEinvoiceNotOnPlatformError (409 einvoicing.incoming-einvoice.not-on-platform): The incoming e-invoice has no id on the e-invoicing platform: no decision can be sent for it. Nothing was done.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
incomingEinvoiceDetail, err := org.IncomingEinvoices.Dispute(ctx, "incomingEinvoice_…", &myle.IncomingEinvoiceDisputeParams{Reason: myle.String("reason")})
if err != nil {
	return err
}
fmt.Println(incomingEinvoiceDetail.ID)

func (*IncomingEinvoicesService) DownloadPDF

func (s *IncomingEinvoicesService) DownloadPDF(ctx context.Context, incomingEinvoiceID string, opts ...RequestOption) (*FileDownload, error)

DownloadPDF — Get an incoming e-invoice as a PDF file.

Returns an e-invoice a supplier sent the organization: as JSON by default, with its lines and history; with Accept: application/pdf, the PDF its sender attached or SuperPDP's rendering (503 while SuperPDP cannot render it); with Accept: application/xml, its CII, the legal original. A representation it does not have is a 406 naming the ones it has.

GET /organizations/{id}/incoming-einvoices/{incomingEinvoiceId} · requires INVOICES_RECEIVE_LIST, with Accept: application/pdf.

It answers a *FileDownload: the bytes as received (Data, never decoded), Filename (from Content-Disposition, "" when none), ContentType and the Response; Save(path) writes it. An error answer is JSON as for any call, returned as the type of its code.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreUnavailableError (503 core.unavailable): Myle or one of its services is temporarily unavailable; retry later.

Example:

org := client.Organization("organization_…")
file, err := org.IncomingEinvoices.DownloadPDF(ctx, "incomingEinvoice_…")
if err != nil {
	return err
}
if err := file.Save(cmp.Or(file.Filename, "incoming-einvoice.pdf")); err != nil {
	return err
}

func (*IncomingEinvoicesService) DownloadXML

func (s *IncomingEinvoicesService) DownloadXML(ctx context.Context, incomingEinvoiceID string, opts ...RequestOption) (*FileDownload, error)

DownloadXML — Get an incoming e-invoice as a XML file.

Returns an e-invoice a supplier sent the organization: as JSON by default, with its lines and history; with Accept: application/pdf, the PDF its sender attached or SuperPDP's rendering (503 while SuperPDP cannot render it); with Accept: application/xml, its CII, the legal original. A representation it does not have is a 406 naming the ones it has.

GET /organizations/{id}/incoming-einvoices/{incomingEinvoiceId} · requires INVOICES_RECEIVE_LIST, with Accept: application/xml.

It answers a *FileDownload: the bytes as received (Data, never decoded), Filename (from Content-Disposition, "" when none), ContentType and the Response; Save(path) writes it. An error answer is JSON as for any call, returned as the type of its code.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreUnavailableError (503 core.unavailable): Myle or one of its services is temporarily unavailable; retry later.

Example:

org := client.Organization("organization_…")
file, err := org.IncomingEinvoices.DownloadXML(ctx, "incomingEinvoice_…")
if err != nil {
	return err
}
if err := file.Save(cmp.Or(file.Filename, "incoming-einvoice.xml")); err != nil {
	return err
}

func (*IncomingEinvoicesService) Get

func (s *IncomingEinvoicesService) Get(ctx context.Context, incomingEinvoiceID string, opts ...RequestOption) (*IncomingEinvoiceDetail, error)

Get — Get an incoming e-invoice.

Returns an e-invoice a supplier sent the organization: as JSON by default, with its lines and history; with Accept: application/pdf, the PDF its sender attached or SuperPDP's rendering (503 while SuperPDP cannot render it); with Accept: application/xml, its CII, the legal original. A representation it does not have is a 406 naming the ones it has.

The file answers have their own method: IncomingEinvoicesService.DownloadPDF, IncomingEinvoicesService.DownloadXML.

GET /organizations/{id}/incoming-einvoices/{incomingEinvoiceId} · requires INVOICES_RECEIVE_LIST.

It answers the incoming e-invoice.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreUnavailableError (503 core.unavailable): Myle or one of its services is temporarily unavailable; retry later.

Example:

org := client.Organization("organization_…")
incomingEinvoiceDetail, err := org.IncomingEinvoices.Get(ctx, "incomingEinvoice_…")
if err != nil {
	return err
}
fmt.Println(incomingEinvoiceDetail.ID)

func (*IncomingEinvoicesService) List

List — List the incoming e-invoices.

Returns the e-invoices suppliers sent the organization through the network, the newest first, filtered, one page at a time.

GET /organizations/{id}/incoming-einvoices · requires INVOICES_RECEIVE_LIST.

It answers a *Paginator (a page of incoming e-invoices): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
for incomingEinvoice, err := range org.IncomingEinvoices.List(ctx, &myle.IncomingEinvoiceListParams{Status: []myle.IncomingEinvoiceListStatus{myle.IncomingEinvoiceListStatusPendingSubmission}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(incomingEinvoice.ID)
}

func (*IncomingEinvoicesService) MarkPaid

MarkPaid — Mark an incoming e-invoice paid.

Records the payment of an accepted incoming e-invoice: the settlement booked and lettered, the status PAYMENT_SENT, the supplier told through the platform (best effort). Once only (409 the second time). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/mark-paid · requires INVOICES_RECEIVE_DECIDE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the incoming e-invoice, paid.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingIncomingEinvoiceAlreadySettledError (409 einvoicing.incoming-einvoice.already-settled): The incoming e-invoice is paid already (PAYMENT_SENT): its purchase and its payment are booked, and no decision or payment walks that back. Nothing was done.
  • *EinvoicingIncomingEinvoiceNotAcceptedError (409 einvoicing.incoming-einvoice.not-accepted): Only an accepted (or partially accepted) incoming e-invoice is marked paid: accept it first. Nothing was recorded.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
incomingEinvoiceDetail, err := org.IncomingEinvoices.MarkPaid(ctx, "incomingEinvoice_…", &myle.IncomingEinvoiceMarkPaidParams{Method: myle.String("method")})
if err != nil {
	return err
}
fmt.Println(incomingEinvoiceDetail.ID)

func (*IncomingEinvoicesService) Refuse

Refuse — Refuse an incoming e-invoice.

Tells the supplier, through the platform, that the organization refuses the invoice (fr:210), with an AFNOR reason code (422 without one, or with one outside the list); the note stays in Myle. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/incoming-einvoices/{incomingEinvoiceId}/refuse · requires INVOICES_RECEIVE_DECIDE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the incoming e-invoice, refused.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingIncomingEinvoiceAlreadySettledError (409 einvoicing.incoming-einvoice.already-settled): The incoming e-invoice is paid already (PAYMENT_SENT): its purchase and its payment are booked, and no decision or payment walks that back. Nothing was done.
  • *EinvoicingIncomingEinvoiceNotOnPlatformError (409 einvoicing.incoming-einvoice.not-on-platform): The incoming e-invoice has no id on the e-invoicing platform: no decision can be sent for it. Nothing was done.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
incomingEinvoiceDetail, err := org.IncomingEinvoices.Refuse(ctx, "incomingEinvoice_…", &myle.IncomingEinvoiceRefuseParams{ReasonCode: myle.String("reasonCode")})
if err != nil {
	return err
}
fmt.Println(incomingEinvoiceDetail.ID)

type InitialStock

type InitialStock struct {
	// The stock's name; absent or null: the product's name.
	Label Opt[string] `json:"label"`
	// The quantity in stock at once, a decimal string from 0 to 10000000, written as one « Stock initial »
	// movement; absent or "0": no movement.
	Quantity Opt[string] `json:"quantity"`
	// The lot of that quantity (declared empty without a quantity); absent or null for none.
	Lot Opt[InitialStockLot] `json:"lot"`
}

InitialStock — The stock created with a product, in the same transaction: the product is not created without it. Requires the Stocks module and STOCKS_CREATE, and STOCKLINES_CREATE for a quantity above 0. lot: the lot of that quantity (declared empty without a quantity); absent or null for none. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (InitialStock) MarshalJSON

func (p InitialStock) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InitialStockLot

type InitialStockLot struct {
	// The lot's number, as printed on the goods.
	Number string `json:"number"`
	// Its best-before date (YYYY-MM-DD); absent or null for none.
	BestBeforeDate Opt[string] `json:"bestBeforeDate"`
}

InitialStockLot — A lot of the stock created with a product. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (InitialStockLot) MarshalJSON

func (p InitialStockLot) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InternalServerError

type InternalServerError struct{ *APIError }

InternalServerError is a 500 or any other 5xx: the API failed; already retried when the call is safe to repeat.

func (*InternalServerError) Unwrap

func (e *InternalServerError) Unwrap() error

Unwrap answers the *APIError.

type Invoice

type Invoice struct {
	// The invoice's id (invoice_<uuid>).
	ID string `json:"id"`
	// Always "invoice".
	Object string `json:"object"`
	// The organization it belongs to (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// Its legal number (20261003-000171), or null while it is a DRAFT.
	Number *string `json:"number"`
	// DRAFT, VALIDATED, SHARED, UNPAID, PARTIALLY_PAID, PARTIALLY_PAID_OVERDUE, PAID, LOST, PAYMENT_ANNOUNCED,
	// SEPA_PENDING, SEPA_FAILED, SEPA_DISPUTED, EINVOICE_SUBMITTED, EINVOICE_REJECTED, EINVOICE_DISPUTED,
	// EINVOICE_REFUSED. An open enum: tolerate a value you do not know. A deleted invoice is never returned (404).
	Status InvoiceStatus `json:"status"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// The customer as the invoice froze it.
	Company InvoiceCompanySnapshot `json:"company"`
	// Its issue date (YYYY-MM-DD), or null while it is a DRAFT.
	IssueDate *string `json:"issueDate"`
	// Its due date (YYYY-MM-DD), or null while it is a DRAFT.
	DueDate *string `json:"dueDate"`
	// A description printed on it, or null.
	Description *string `json:"description"`
	// Its lines, in order.
	Lines []InvoiceLine `json:"lines"`
	// The customer's discount the invoice carries; amount: what the lines' discounts deduct, excl. VAT.
	Discount InvoiceDiscount `json:"discount"`
	// The lines' subtotals (excluding VAT, discounts deducted).
	Subtotal Money `json:"subtotal"`
	// The VAT.
	Vat Money `json:"vat"`
	// What the invoice amounts to.
	Total Money `json:"total"`
	// What remains to be paid (a credit note's total is negative).
	AmountDue Money `json:"amountDue"`
	// The delivery notes it invoices (deliveryNote_<uuid>).
	DeliveryNoteIDs []string `json:"deliveryNoteIds"`
	// The credit notes that cancel or correct it (invoice_<uuid>).
	CreditNoteIDs []string `json:"creditNoteIds"`
	// For a credit note, the invoice it cancels or corrects (invoice_<uuid>), or null.
	CorrectsInvoiceID *string `json:"correctsInvoiceId"`
	// Its own tags, sorted.
	Tags []string `json:"tags"`
	// When it was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When it, its lines, its status or its tags last changed (RFC 3339, UTC).
	UpdatedAt string `json:"updatedAt"`
	// contains filtered or unexported fields
}

Invoice — An invoice. A DRAFT has no number, issueDate nor dueDate: the validation gives them. subtotal: the lines' subtotals (excluding VAT, discounts deducted); vat: the VAT; total: what the invoice amounts to; amountDue: what remains to be paid (a credit note's total is negative). company: the customer as the invoice froze it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Invoice) ETag

func (m Invoice) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Invoice) LastResponse

func (m Invoice) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type InvoiceBatchCreateCreditNotesParams

type InvoiceBatchCreateCreditNotesParams struct {
	// Their ids (invoice_<uuid>), at least one; each invoice is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
}

InvoiceBatchCreateCreditNotesParams is the parameters of InvoicesService.BatchCreateCreditNotes (batchCreateInvoiceCreditNotes): its body's members. A nil *InvoiceBatchCreateCreditNotesParams sends none.

The invoices a batch acts on.

A member of type Opt is left out unless set.

func (InvoiceBatchCreateCreditNotesParams) MarshalJSON

func (p InvoiceBatchCreateCreditNotesParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceBatchCreatePaymentsParams

type InvoiceBatchCreatePaymentsParams struct {
	// The payments, at least one, at most 1000; each invoice once.
	Allocations []BatchPaymentAllocation `json:"allocations"`
	// How it was paid: CASH, CHECK, TRANSFER, CARD, SEPA_DIRECT_DEBIT, PAYPAL, OTHER (the default).
	Method Opt[string] `json:"method"`
	// The organization's own name for the method (« Lydia »), 60 characters at most.
	MethodLabel Opt[string] `json:"methodLabel"`
	// When it was paid (YYYY-MM-DD).
	PaidAt Opt[string] `json:"paidAt"`
	// Its reference (a transfer's label), the same on every payment of the batch.
	Reference Opt[string] `json:"reference"`
}

InvoiceBatchCreatePaymentsParams is the parameters of InvoicesService.BatchCreatePayments (batchCreateInvoicePayments): its body's members. A nil *InvoiceBatchCreatePaymentsParams sends none.

Payments to record, one per allocation, sharing one method, label, date and reference (a transfer that settles several invoices). Each allocation's amount: what was paid on that invoice, in EUR, more than 0, two decimals at most.

A member of type Opt is left out unless set.

func (InvoiceBatchCreatePaymentsParams) MarshalJSON

func (p InvoiceBatchCreatePaymentsParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceBatchDuplicateParams

type InvoiceBatchDuplicateParams struct {
	// Their ids (invoice_<uuid>), at least one; each invoice is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
}

InvoiceBatchDuplicateParams is the parameters of InvoicesService.BatchDuplicate (batchDuplicateInvoices): its body's members. A nil *InvoiceBatchDuplicateParams sends none.

The invoices a batch acts on.

A member of type Opt is left out unless set.

func (InvoiceBatchDuplicateParams) MarshalJSON

func (p InvoiceBatchDuplicateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceBatchShareParams

type InvoiceBatchShareParams struct {
	// Their ids (invoice_<uuid>), at least one; each invoice is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
	// true: handed over outside the e-invoicing network, though it is their channel (POST …/share's force=true).
	Force Opt[bool] `json:"force"`
}

InvoiceBatchShareParams is the parameters of InvoicesService.BatchShare (batchShareInvoices): its body's members. A nil *InvoiceBatchShareParams sends none.

The invoices a batch share acts on.

A member of type Opt is left out unless set.

func (InvoiceBatchShareParams) MarshalJSON

func (p InvoiceBatchShareParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceBatchValidateParams

type InvoiceBatchValidateParams struct {
	// Their ids (invoice_<uuid>), at least one; each invoice is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
}

InvoiceBatchValidateParams is the parameters of InvoicesService.BatchValidate (batchValidateInvoices): its body's members. A nil *InvoiceBatchValidateParams sends none.

The invoices a batch acts on.

A member of type Opt is left out unless set.

func (InvoiceBatchValidateParams) MarshalJSON

func (p InvoiceBatchValidateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceCompanySnapshot

type InvoiceCompanySnapshot struct {
	// The customer's legal name.
	Name string `json:"name"`
	// The address the invoice is addressed to.
	Address string `json:"address"`
	// Its billing address, when the invoice is sent there rather than to address, or null.
	BillingAddress *string `json:"billingAddress"`
	// Its headquarters address, or null.
	HeadquartersAddress *string `json:"headquartersAddress"`
	// Its SIREN, or null.
	Siren *string `json:"siren"`
	// Its VAT number, or null.
	VatNumber *string `json:"vatNumber"`
}

InvoiceCompanySnapshot — The customer as the invoice froze it at its creation: what the PDF prints, whatever the company became since.

type InvoiceCorrectableInvoiceListParams

type InvoiceCorrectableInvoiceListParams struct {
	// Invoices whose number contains this text.
	Q Opt[string] `json:"-"`
}

InvoiceCorrectableInvoiceListParams is the parameters of InvoiceCorrectableInvoicesService.List (listInvoiceCorrectableInvoices): its query parameters. A nil *InvoiceCorrectableInvoiceListParams sends none.

type InvoiceCorrectableInvoicesService

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

InvoiceCorrectableInvoicesService — /organizations/{id}/invoices/{invoiceId}/correctable-invoices.

Reach it as client.Organization("organization_…").Invoices.CorrectableInvoices.

func (*InvoiceCorrectableInvoicesService) List

List — List the invoices a credit note can correct.

Returns the invoices a credit note keyed in by hand (an invoice whose total is negative) can name as the one it corrects (POST …/set-corrected-invoice): its customer's issued invoices, not cancelled already, dated no later than it (today for a draft), in the caller's tag scope, newest first, 50 at most; q filters on their number. All at once: nextCursor is never present.

GET /organizations/{id}/invoices/{invoiceId}/correctable-invoices · requires INVOICES_LIST.

It answers a *Paginator over a single page (the invoices it can correct). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for correctableInvoice, err := range org.Invoices.CorrectableInvoices.List(ctx, "invoice_…", nil).All() {
	if err != nil {
		return err
	}
	fmt.Println(correctableInvoice.ID)
}

type InvoiceCreateParams

type InvoiceCreateParams struct {
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// A description printed on the invoice.
	Description Opt[string] `json:"description"`
	// Its lines, at least one, in order.
	Lines []InvoiceLineInput `json:"lines"`
	// Its own tags.
	Tags Opt[[]string] `json:"tags"`
}

InvoiceCreateParams is the parameters of InvoicesService.Create (createInvoice): its body's members. A nil *InvoiceCreateParams sends none.

A new draft invoice. companyId: the customer, one of the organization's companies. Each line's unitPrice is in EUR, excluding VAT; without INVOICES_CUSTOMIZE_PRICE, a catalog product's line takes its catalog price (the customer's own price if it has one) and no discount, whatever is sent.

A member of type Opt is left out unless set.

func (InvoiceCreateParams) MarshalJSON

func (p InvoiceCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceCreditNotesService

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

InvoiceCreditNotesService — /organizations/{id}/invoices/{invoiceId}/credit-notes.

Reach it as client.Organization("organization_…").Invoices.CreditNotes.

func (*InvoiceCreditNotesService) Create

func (s *InvoiceCreditNotesService) Create(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Create — Cancel an invoice with a credit note.

Issues the credit note that cancels a LOST invoice, or one the customer refused on the e-invoicing network (EINVOICE_REFUSED), whole: a DRAFT invoice mirroring its lines with negated quantities, which the invoice lists in creditNoteIds and which names it in correctsInvoiceId; the invoice keeps its status. Validate the credit note (POST …/validate) to give it its number. The same caller asking again gets the same credit note; one issued by someone else is refused (409). A deposit invoice another invoice has deducted cannot be cancelled (409). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/credit-notes · requires INVOICES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the credit note, an invoice. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceNotCreditableError (409 billing.invoice.not-creditable): Only a LOST invoice, or one the customer refused on the e-invoicing network (EINVOICE_REFUSED), is cancelled by a credit note issued here: mark it lost first. Nothing was created.
  • *BillingInvoiceAlreadyCreditedError (409 billing.invoice.already-credited): Another member or key issued the credit note that cancels this invoice already (the caller's own is answered again, never refused). Nothing was created.
  • *BillingInvoiceDepositDeductedError (409 billing.invoice.deposit-deducted): A deposit invoice that another invoice has deducted (the order's final invoice, delivery-note invoices, or the credit note that settled the order) can no longer be cancelled: the balance would be wrong. Cancel those invoices first, or settle the order. Nothing was created.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.CreditNotes.Create(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

type InvoiceDiscount

type InvoiceDiscount struct {
	// The customer's discount, a decimal string in percent, applied to the lines that carry none; or null.
	Percentage *string `json:"percentage"`
	// What the lines' discounts deduct, excl.
	Amount *Money `json:"amount"`
	// Why the customer gets it, or null.
	Reason *string `json:"reason"`
}

InvoiceDiscount — The customer's discount the invoice carries; amount: what the lines' discounts deduct, excl. VAT.

type InvoiceEditParams

type InvoiceEditParams struct {
	// The customer (company_<uuid>): the invoice takes the recipient, legal details and discount the creation would
	// give it for this customer; its lines are kept as they are, but for the customer discount: a line that carried
	// the previous customer's (or none) takes the new one's, a line's own discount stays.
	CompanyID Opt[string] `json:"companyId"`
	// A description printed on the invoice; null for none.
	Description Opt[string] `json:"description"`
	// Its lines, all of them, at least one, in order (as at the creation). Without INVOICES_CUSTOMIZE_PRICE, a new
	// catalog product's line takes its catalog price and no discount; a line kept as it was keeps its price.
	Lines Opt[[]InvoiceLineInput] `json:"lines"`
}

InvoiceEditParams is the parameters of InvoicesService.Edit (editInvoice): its body's members. A nil *InvoiceEditParams sends none.

A draft's new content: an absent member is unchanged. Lines are added, changed, removed and reordered by sending the whole list.

A member of type Opt is left out unless set.

func (InvoiceEditParams) MarshalJSON

func (p InvoiceEditParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceEditability

type InvoiceEditability struct {
	// true while the draft has not left the organization (no mail, link, online read, network, payment).
	Editable bool `json:"editable"`
	// Why it cannot, or null: NOT_DRAFT, MAILED, SHARE_LINK, PUBLIC_ACCESS (read online), TRANSMITTED (sent to the
	// e-invoicing network), PAID, GENERATED_CREDIT_NOTE, SHOP (a Boutique order's), STRIPE_IMPORTED. An open list.
	Reason *string `json:"reason"`
	// contains filtered or unexported fields
}

InvoiceEditability — Whether a draft's lines, customer and description can still be changed: editable, or reason says why not.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (InvoiceEditability) ETag

func (m InvoiceEditability) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (InvoiceEditability) LastResponse

func (m InvoiceEditability) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type InvoiceEligibility

type InvoiceEligibility struct {
	// The invoices the filters give (the caller's, drafts included, deleted ones never).
	Total int `json:"total"`
	// Validated and not handed over yet (VALIDATED, or EINVOICE_REJECTED: refused by the e-invoicing platform), the
	// invoices the web app's « Partager » acts on; batch-share also takes an UNPAID or a LOST one.
	Share int `json:"share"`
	// Drafts, for batch-validate.
	Validate int `json:"validate"`
	// LOST or EINVOICE_REFUSED with no credit note yet, for batch-credit-notes.
	CreditNote int `json:"creditNote"`
	// Every invoice but a credit note and one imported from Stripe, for batch-duplicate.
	Duplicate int `json:"duplicate"`
	// Public bodies among the customers of the drafts: validating mails them the original (Chorus Pro).
	PublicSectorDrafts *PublicSectorCustomers `json:"publicSectorDrafts"`
	// contains filtered or unexported fields
}

InvoiceEligibility — What each batch would act on among the invoices the filters give: the counts the web app shows on its batch buttons.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (InvoiceEligibility) ETag

func (m InvoiceEligibility) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (InvoiceEligibility) LastResponse

func (m InvoiceEligibility) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type InvoiceGetEligibilityParams

type InvoiceGetEligibilityParams struct {
	// Invoices of one of these statuses (repeat it for several): DRAFT, VALIDATED, UNPAID, PAID…. Each value is
	// sent (name=a&name=b).
	Status []InvoiceStatus `json:"-"`
	// Invoices of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Invoices issued on or after this date (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Invoices issued on or before this date (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Invoices due on or after this date (YYYY-MM-DD).
	DueDateFrom Opt[string] `json:"-"`
	// Invoices due on or before this date (YYYY-MM-DD).
	DueDateTo Opt[string] `json:"-"`
	// Invoices changed strictly after this instant (RFC 3339).
	UpdatedAfter Opt[string] `json:"-"`
	// Invoices carrying one of these tags (repeat it for several). Each value is sent (name=a&name=b).
	Tag []string `json:"-"`
}

InvoiceGetEligibilityParams is the parameters of InvoicesService.GetEligibility (getInvoiceEligibility): its query parameters. A nil *InvoiceGetEligibilityParams sends none.

type InvoiceGetNeighborsParams

type InvoiceGetNeighborsParams struct {
	// Invoices of one of these statuses (repeat it for several): DRAFT, VALIDATED, UNPAID, PAID…. Each value is
	// sent (name=a&name=b).
	Status []InvoiceStatus `json:"-"`
	// Invoices of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Invoices issued on or after this date (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Invoices issued on or before this date (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Invoices due on or after this date (YYYY-MM-DD).
	DueDateFrom Opt[string] `json:"-"`
	// Invoices due on or before this date (YYYY-MM-DD).
	DueDateTo Opt[string] `json:"-"`
	// Invoices changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Invoices carrying one of these tags (repeat it for several). Each value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// -createdAt (the default), createdAt, updatedAt or -updatedAt.
	Sort Opt[InvoiceListSort] `json:"-"`
}

InvoiceGetNeighborsParams is the parameters of InvoicesService.GetNeighbors (getInvoiceNeighbors): its query parameters. A nil *InvoiceGetNeighborsParams sends none.

type InvoiceLine

type InvoiceLine struct {
	// The line's position in the invoice, from 0.
	Index int `json:"index"`
	// The catalog product it sells (product_<uuid>), or null for a free line.
	ProductID *string `json:"productId"`
	// The product's reference as printed, or null.
	Number *string `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// A longer description printed under the label, or null.
	Description *string `json:"description"`
	// The quantity, a decimal string: "12.5".
	Quantity string `json:"quantity"`
	// The unit of the quantity (HOUR, HA, KM, DAY, HALF_DAY, TONNE, UNIT, FLAT), or null for a piece.
	Unit *string `json:"unit"`
	// Excluding VAT, before the discount.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate, a decimal string in percent: "20", "5.5".
	VatRate string `json:"vatRate"`
	// The line's discount, a decimal string in percent, or null.
	DiscountRate *string `json:"discountRate"`
	// Quantity × unitPrice, discount deducted, excluding VAT.
	Subtotal Money `json:"subtotal"`
	// The subtotal with its VAT.
	Total Money `json:"total"`
	// The accounting account the line is booked to (706000…), or null for the default.
	AccountingNumber *string `json:"accountingNumber"`
}

InvoiceLine — An invoice line. unitPrice: excluding VAT, before the discount; subtotal: quantity × unitPrice, discount deducted, excluding VAT; total: the subtotal with its VAT.

type InvoiceLineInput

type InvoiceLineInput struct {
	// The catalog product it sells (product_<uuid>); absent for a free line.
	ProductID Opt[string] `json:"productId"`
	// The product's reference as printed.
	Number Opt[string] `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// A longer description printed under the label.
	Description Opt[string] `json:"description"`
	// The quantity, a decimal string: "12.5".
	Quantity string `json:"quantity"`
	// The unit of the quantity: HOUR, HA, KM, DAY, HALF_DAY, TONNE, UNIT, FLAT; absent for a piece.
	Unit Opt[string] `json:"unit"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate in percent, a decimal string from 0 to 100: "20".
	VatRate string `json:"vatRate"`
	// A discount in percent, a decimal string from 0 to 100.
	DiscountRate Opt[string] `json:"discountRate"`
	// The accounting account the line is booked to; absent for the default.
	AccountingNumber Opt[string] `json:"accountingNumber"`
}

InvoiceLineInput — A line of a new invoice. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (InvoiceLineInput) MarshalJSON

func (p InvoiceLineInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceListParams

type InvoiceListParams struct {
	// Invoices of one of these statuses (repeat it for several): DRAFT, VALIDATED, UNPAID, PAID…. Each value is
	// sent (name=a&name=b).
	Status []InvoiceStatus `json:"-"`
	// Invoices of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Invoices issued on or after this date (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Invoices issued on or before this date (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Invoices due on or after this date (YYYY-MM-DD).
	DueDateFrom Opt[string] `json:"-"`
	// Invoices due on or before this date (YYYY-MM-DD).
	DueDateTo Opt[string] `json:"-"`
	// Invoices changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Invoices carrying one of these tags (repeat it for several). Each value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// -createdAt (the default), createdAt, updatedAt or -updatedAt.
	Sort Opt[InvoiceListSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
}

InvoiceListParams is the parameters of InvoicesService.List (listInvoices): its query parameters. A nil *InvoiceListParams sends none.

type InvoiceListSort

type InvoiceListSort string

InvoiceListSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: -createdAt, createdAt, updatedAt, -updatedAt.

const InvoiceListSortCreatedAt InvoiceListSort = "createdAt"

InvoiceListSortCreatedAt is "createdAt".

const InvoiceListSortCreatedAtDesc InvoiceListSort = "-createdAt"

InvoiceListSortCreatedAtDesc is "-createdAt".

const InvoiceListSortUpdatedAt InvoiceListSort = "updatedAt"

InvoiceListSortUpdatedAt is "updatedAt".

const InvoiceListSortUpdatedAtDesc InvoiceListSort = "-updatedAt"

InvoiceListSortUpdatedAtDesc is "-updatedAt".

type InvoiceNeighbors

type InvoiceNeighbors struct {
	// An invoice, in short: enough to name it and to fetch it.
	Previous *InvoiceSummary `json:"previous"`
	// An invoice, in short: enough to name it and to fetch it.
	Next *InvoiceSummary `json:"next"`
	// contains filtered or unexported fields
}

InvoiceNeighbors — An invoice's place in the invoice list: previous, the invoice right before it, and next, the invoice right after it; each null at an end of the list, both null when the filters leave the invoice out of it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (InvoiceNeighbors) ETag

func (m InvoiceNeighbors) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (InvoiceNeighbors) LastResponse

func (m InvoiceNeighbors) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type InvoicePaymentCreateParams

type InvoicePaymentCreateParams struct {
	// What was paid, in EUR, more than 0, two decimals at most; on a credit note, what was refunded.
	Amount Money `json:"amount"`
	// How it was paid: CASH, CHECK, TRANSFER, CARD, SEPA_DIRECT_DEBIT, PAYPAL, OTHER (the default).
	Method Opt[string] `json:"method"`
	// The organization's own name for the method (« Lydia »), 60 characters at most.
	MethodLabel Opt[string] `json:"methodLabel"`
	// When it was paid (YYYY-MM-DD).
	PaidAt Opt[string] `json:"paidAt"`
	// Its reference (a cheque number, a transfer's label).
	Reference Opt[string] `json:"reference"`
}

InvoicePaymentCreateParams is the parameters of InvoicePaymentsService.Create (createInvoicePayment): its body's members. A nil *InvoicePaymentCreateParams sends none.

A payment to record. amount: what was paid, in EUR, more than 0, two decimals at most; on a credit note, what was refunded.

A member of type Opt is left out unless set.

func (InvoicePaymentCreateParams) MarshalJSON

func (p InvoicePaymentCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoicePaymentsService

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

InvoicePaymentsService — /organizations/{id}/invoices/{invoiceId}/payments.

Reach it as client.Organization("organization_…").Invoices.Payments.

func (*InvoicePaymentsService) Create

func (s *InvoicePaymentsService) Create(ctx context.Context, invoiceID string, params *InvoicePaymentCreateParams, opts ...RequestOption) (*Payment, error)

Create — Record a payment on an invoice.

Records a payment on an invoice, as from the web app: the invoice moves to PARTIALLY_PAID, or PAID once nothing remains due, the payment is booked in the ledger and lettered, and an invoice that went through the e-invoicing network is reported paid there. An invoice takes payments once sent (SHARED, UNPAID, partially paid, LOST, the e-invoicing statuses…): a draft, a validated invoice not sent yet or a SEPA debit in progress is refused (409), as is a paid one or one a credit note cancels. Send an Idempotency-Key to retry safely: without it, a retry records a second payment.

POST /organizations/{id}/invoices/{invoiceId}/payments · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the payment recorded. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceNotPayableError (409 billing.invoice.not-payable): The invoice's status takes no payment: a draft, a validated invoice not sent yet (SHARED is the first status that does), a SEPA debit in progress or failed. Nothing was recorded.
  • *BillingInvoiceAlreadyPaidError (409 billing.invoice.already-paid): The invoice is paid already: someone (Stripe, the customer's e-invoicing platform, a member) booked the money first. Read the invoice again before recording anything. Nothing was recorded.
  • *BillingInvoiceCreditNoteLinkedError (409 billing.invoice.credit-note-linked): A credit note cancels the invoice: its status no longer moves, and it takes no payment. Nothing was recorded.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
payment, err := org.Invoices.Payments.Create(ctx, "invoice_…", &myle.InvoicePaymentCreateParams{Amount: myle.Money{Amount: "12.50", Currency: "EUR"}})
if err != nil {
	return err
}
fmt.Println(payment.ID, payment.ETag())

func (*InvoicePaymentsService) Delete

func (s *InvoicePaymentsService) Delete(ctx context.Context, invoiceID string, paymentID string, opts ...RequestOption) error

Delete — Remove a payment of an invoice.

Removes a payment keyed in by mistake: the invoice walks back (PAID → PARTIALLY_PAID → UNPAID) and the payment's ledger entry is reversed. Only a PAID or partially paid invoice's payments can go (409 otherwise); a payment collected through Stripe is refunded in Stripe (409). With If-Match (the invoice's ETag), refused (412) if the invoice changed since it was read.

DELETE /organizations/{id}/invoices/{invoiceId}/payments/{paymentId} · requires INVOICES_REVERT_PAID.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the payment is removed).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingPaymentNotRemovableError (409 billing.payment.not-removable): The invoice's status no longer lets its payments be removed: only a PAID or partially paid invoice's can. Nothing was removed.
  • *BillingPaymentStripeCollectedError (409 billing.payment.stripe-collected): The payment was collected through Stripe: it is refunded in Stripe, never removed in Myle. Nothing was removed.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
payment, err := org.Invoices.Payments.Get(ctx, "invoice_…", "payment_…")
if err != nil {
	return err
}
err = org.Invoices.Payments.Delete(ctx, "invoice_…", "payment_…", myle.IfMatch(payment))
if err != nil {
	return err
}

func (*InvoicePaymentsService) Get

func (s *InvoicePaymentsService) Get(ctx context.Context, invoiceID string, paymentID string, opts ...RequestOption) (*Payment, error)

Get — Get a payment of an invoice.

Returns one payment of an invoice the caller can see; a payment of another invoice is a 404. Its ETag is the invoice's: a payment recorded or removed moves it.

GET /organizations/{id}/invoices/{invoiceId}/payments/{paymentId} · requires INVOICES_LIST.

It answers the payment. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
payment, err := org.Invoices.Payments.Get(ctx, "invoice_…", "payment_…")
if err != nil {
	return err
}
fmt.Println(payment.ID, payment.ETag())

func (*InvoicePaymentsService) List

func (s *InvoicePaymentsService) List(ctx context.Context, invoiceID string, opts ...RequestOption) *Paginator[Payment]

List — List an invoice's payments.

Returns the payments recorded on an invoice the caller can see, newest first, all at once (nextCursor is never present). What remains due is the invoice's amountDue.

GET /organizations/{id}/invoices/{invoiceId}/payments · requires INVOICES_LIST.

It answers a *Paginator over a single page (the invoice's payments). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for payment, err := range org.Invoices.Payments.List(ctx, "invoice_…").All() {
	if err != nil {
		return err
	}
	fmt.Println(payment.ID)
}

type InvoiceSendParams

type InvoiceSendParams struct {
	// The recipients, at least one: ids of the customer's e-mail addresses.
	To []string `json:"to"`
}

InvoiceSendParams is the parameters of InvoicesService.Send (sendInvoice): its body's members. A nil *InvoiceSendParams sends none.

Who to send the invoice to: ids of its customer's e-mail addresses (companyEmailAddress_<uuid>, the company's emailAddresses), never a free address.

A member of type Opt is left out unless set.

func (InvoiceSendParams) MarshalJSON

func (p InvoiceSendParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceSetCorrectedInvoiceParams

type InvoiceSetCorrectedInvoiceParams struct {
	// The invoice it corrects (invoice_<uuid>): an issued invoice of the same customer, dated no later than the
	// credit note, not cancelled already (GET …/correctable-invoices lists them).
	CorrectsInvoiceID string `json:"correctsInvoiceId"`
}

InvoiceSetCorrectedInvoiceParams is the parameters of InvoicesService.SetCorrectedInvoice (setInvoiceCorrectedInvoice): its body's members. A nil *InvoiceSetCorrectedInvoiceParams sends none.

The invoice a credit note keyed in by hand corrects.

A member of type Opt is left out unless set.

func (InvoiceSetCorrectedInvoiceParams) MarshalJSON

func (p InvoiceSetCorrectedInvoiceParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoiceShareParams

type InvoiceShareParams struct {
	// true: handed over outside the e-invoicing network, though it is the invoice's channel.
	Force Opt[bool] `json:"-"`
}

InvoiceShareParams is the parameters of InvoicesService.Share (shareInvoice): its query parameters. A nil *InvoiceShareParams sends none.

type InvoiceStatus

type InvoiceStatus string

InvoiceStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: UNPAID, PAID, PARTIALLY_PAID, PARTIALLY_PAID_OVERDUE, DRAFT, VALIDATED, SHARED, LOST, SEPA_PENDING, SEPA_FAILED, SEPA_DISPUTED, EINVOICE_SUBMITTED, EINVOICE_REJECTED, EINVOICE_DISPUTED, EINVOICE_REFUSED, PAYMENT_ANNOUNCED.

const InvoiceStatusDraft InvoiceStatus = "DRAFT"

InvoiceStatusDraft is "DRAFT".

const InvoiceStatusEinvoiceDisputed InvoiceStatus = "EINVOICE_DISPUTED"

InvoiceStatusEinvoiceDisputed is "EINVOICE_DISPUTED".

const InvoiceStatusEinvoiceRefused InvoiceStatus = "EINVOICE_REFUSED"

InvoiceStatusEinvoiceRefused is "EINVOICE_REFUSED".

const InvoiceStatusEinvoiceRejected InvoiceStatus = "EINVOICE_REJECTED"

InvoiceStatusEinvoiceRejected is "EINVOICE_REJECTED".

const InvoiceStatusEinvoiceSubmitted InvoiceStatus = "EINVOICE_SUBMITTED"

InvoiceStatusEinvoiceSubmitted is "EINVOICE_SUBMITTED".

const InvoiceStatusLost InvoiceStatus = "LOST"

InvoiceStatusLost is "LOST".

const InvoiceStatusPaid InvoiceStatus = "PAID"

InvoiceStatusPaid is "PAID".

const InvoiceStatusPartiallyPaid InvoiceStatus = "PARTIALLY_PAID"

InvoiceStatusPartiallyPaid is "PARTIALLY_PAID".

const InvoiceStatusPartiallyPaidOverdue InvoiceStatus = "PARTIALLY_PAID_OVERDUE"

InvoiceStatusPartiallyPaidOverdue is "PARTIALLY_PAID_OVERDUE".

const InvoiceStatusPaymentAnnounced InvoiceStatus = "PAYMENT_ANNOUNCED"

InvoiceStatusPaymentAnnounced is "PAYMENT_ANNOUNCED".

const InvoiceStatusSepaDisputed InvoiceStatus = "SEPA_DISPUTED"

InvoiceStatusSepaDisputed is "SEPA_DISPUTED".

const InvoiceStatusSepaFailed InvoiceStatus = "SEPA_FAILED"

InvoiceStatusSepaFailed is "SEPA_FAILED".

const InvoiceStatusSepaPending InvoiceStatus = "SEPA_PENDING"

InvoiceStatusSepaPending is "SEPA_PENDING".

const InvoiceStatusShared InvoiceStatus = "SHARED"

InvoiceStatusShared is "SHARED".

const InvoiceStatusUnpaid InvoiceStatus = "UNPAID"

InvoiceStatusUnpaid is "UNPAID".

const InvoiceStatusValidated InvoiceStatus = "VALIDATED"

InvoiceStatusValidated is "VALIDATED".

type InvoiceStatusChange

type InvoiceStatusChange struct {
	// The status it took (see the invoice's).
	Status string `json:"status"`
	// When it took it (RFC 3339, UTC).
	ChangedAt string `json:"changedAt"`
	// Who did something: a person (USER) or the robot account of an organization API key (ROBOT), which acts in the
	// key's name.
	Author *Author `json:"author"`
}

InvoiceStatusChange — One status an invoice went through. author: the person or the organization key's robot that set it, or null when Myle did (the delivered e-mail, the e-invoicing network, the due date passing, a SEPA debit…).

type InvoiceStatusHistoryService

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

InvoiceStatusHistoryService — /organizations/{id}/invoices/{invoiceId}/status-history.

Reach it as client.Organization("organization_…").Invoices.StatusHistory.

func (*InvoiceStatusHistoryService) List

List — List an invoice's status history.

Returns every status an invoice went through, newest first, with when and by whom — a person, an organization key's robot, or null when Myle set it (the delivered e-mail, the e-invoicing network, the due date passing, a SEPA debit). All at once: nextCursor is never present.

GET /organizations/{id}/invoices/{invoiceId}/status-history · requires INVOICES_LIST.

It answers a *Paginator over a single page (the invoice's statuses, newest first). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for invoiceStatusChange, err := range org.Invoices.StatusHistory.List(ctx, "invoice_…").All() {
	if err != nil {
		return err
	}
	fmt.Println(invoiceStatusChange)
}

type InvoiceSummary

type InvoiceSummary struct {
	// The invoice's id (invoice_<uuid>).
	ID string `json:"id"`
	// Always "invoice".
	Object string `json:"object"`
	// Its legal number, or null for a DRAFT.
	Number *string `json:"number"`
	// Its status (see the invoice's).
	Status string `json:"status"`
	// The customer's name as the invoice froze it.
	CompanyName string `json:"companyName"`
}

InvoiceSummary — An invoice, in short: enough to name it and to fetch it.

type InvoiceUpdateParams

type InvoiceUpdateParams struct {
	// Its own tags, all of them; null for none.
	Tags Opt[[]string] `json:"tags"`
}

InvoiceUpdateParams is the parameters of InvoicesService.Update (updateInvoice): its body's members. A nil *InvoiceUpdateParams sends none.

A merge patch of a draft invoice (RFC 7396): an absent member is unchanged. Its lines, customer and description are not changed here yet.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (InvoiceUpdateParams) MarshalJSON

func (p InvoiceUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type InvoicesService

type InvoicesService struct {
	// CreditNotes — /organizations/{id}/invoices/{invoiceId}/credit-notes.
	CreditNotes *InvoiceCreditNotesService
	// CorrectableInvoices — /organizations/{id}/invoices/{invoiceId}/correctable-invoices.
	CorrectableInvoices *InvoiceCorrectableInvoicesService
	// StatusHistory — /organizations/{id}/invoices/{invoiceId}/status-history.
	StatusHistory *InvoiceStatusHistoryService
	// Payments — /organizations/{id}/invoices/{invoiceId}/payments.
	Payments *InvoicePaymentsService
	// contains filtered or unexported fields
}

InvoicesService — the organization's sales invoices: drafts, their validation (the legal number), their PDF and Factur-X (/organizations/{id}/invoices).

Reach it as client.Organization("organization_…").Invoices.

func (*InvoicesService) BatchCreateCreditNotes

BatchCreateCreditNotes — Cancel several invoices with credit notes.

Issues the credit note of several LOST (or EINVOICE_REFUSED) invoices, each as POST …/credit-notes does: a DRAFT credit note mirroring the invoice, linked both ways; the caller's own credit note answered again; one notification for the batch. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED with the credit note's id (createdId), or FAILED with its error — core.not-found, billing.invoice.not-creditable, billing.invoice.already-credited, billing.invoice.deposit-deducted, billing.invoice.stripe-imported —, the others cancelled all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/batch-credit-notes · requires INVOICES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per invoice). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResultWithCreatedID, err := range org.Invoices.BatchCreateCreditNotes(ctx, &myle.InvoiceBatchCreateCreditNotesParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResultWithCreatedID.ID)
}

func (*InvoicesService) BatchCreatePayments

BatchCreatePayments — Record payments on several invoices.

Records one payment per allocation — a transfer that settles several invoices —, each as POST …/payments does (its status, its ledger entry and lettering, the e-invoicing network told), all with the same method, date and reference; one notification for the batch. At most 1000 allocations, each invoice once (422 otherwise: two payments on one invoice are two batches). The answer is one result per allocation, in the order sent: SUCCEEDED with the payment's id (createdId), or FAILED with its error — core.not-found, billing.invoice.not-payable, billing.invoice.already-paid, billing.invoice.credit-note-linked, billing.invoice.stripe-imported —, the others recorded all the same. Send an Idempotency-Key to retry safely: without it, a retry records the payments again.

POST /organizations/{id}/invoices/batch-payments · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per allocation). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResultWithCreatedID, err := range org.Invoices.BatchCreatePayments(ctx, &myle.InvoiceBatchCreatePaymentsParams{Allocations: []myle.BatchPaymentAllocation{{InvoiceID: "invoice_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f", Amount: myle.Money{Amount: "12.50", Currency: "EUR"}}}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResultWithCreatedID.ID)
}

func (*InvoicesService) BatchDuplicate

BatchDuplicate — Duplicate several invoices as drafts.

Copies each invoice as a new DRAFT, as « Dupliquer » in the web app: the customer (its address and legal details as on file today), the description, the invoice's tags and its lines (product, label, number and account, quantity, price, VAT, origin, dates, note, barcode) at the source's prices; never its number, dates, status, payments, e-invoicing state, links, line discounts (the customer's applies), stock or delivery notes. Each copy counts in the plan's invoices of the month: 402 at the limit, before anything; under it, the batch copies what fits, in the order sent. One notification for the batch. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED with the draft's id (createdId), or FAILED with its error — core.not-found, billing.invoice.not-duplicable (a credit note, a customer or product outside the caller's tag scope, a customer no longer on file), billing.invoice.stripe-imported, core.plan-limit-reached (the month's room ran out on the way) —, the others copied all the same. Send an Idempotency-Key to retry safely: without it, a retry copies again.

POST /organizations/{id}/invoices/batch-duplicate · requires INVOICES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per invoice). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResultWithCreatedID, err := range org.Invoices.BatchDuplicate(ctx, &myle.InvoiceBatchDuplicateParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResultWithCreatedID.ID)
}

func (*InvoicesService) BatchShare

BatchShare — Mark several invoices as handed to their customers.

Declares several invoices handed to their customers, each as POST …/share does: a VALIDATED, UNPAID or LOST invoice becomes SHARED, SHARED already is answered as it is; nothing is sent, no notification. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED, or FAILED with its error — core.not-found (unknown, deleted, outside the caller's tag scope), billing.invoice.transition-refused, billing.invoice.credit-note-linked, billing.invoice.einvoice-required (the e-invoicing network is its channel; force true: handed over outside it), billing.invoice.stripe-imported —, the others shared all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/batch-share · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per invoice). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Invoices.BatchShare(ctx, &myle.InvoiceBatchShareParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*InvoicesService) BatchValidate

BatchValidate — Validate several invoices.

Validates several DRAFTs at once, each as POST …/validate does: its legal number (in the order of the ids, without gaps), its dates, then its dispatch, booking and SEPA debit; one notification for the whole batch. At most 1000 ids. The answer is one result per id, in the order sent: SUCCEEDED (validated now, or validated already by the same caller), or FAILED with its error — core.not-found (unknown, deleted, outside the caller's tag scope), billing.invoice.not-a-draft, billing.invoice.stripe-imported, billing.invoice.partial-credit-note —, the others validated all the same. Send an Idempotency-Key to retry safely; without it, a retry answers SUCCEEDED for what this caller validated.

POST /organizations/{id}/invoices/batch-validate · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per invoice). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Invoices.BatchValidate(ctx, &myle.InvoiceBatchValidateParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*InvoicesService) Create

func (s *InvoicesService) Create(ctx context.Context, params *InvoiceCreateParams, opts ...RequestOption) (*Invoice, error)

Create — Create a draft invoice.

Creates a DRAFT invoice: no number yet, nothing sent; POST …/validate gives it its legal number. Without INVOICES_CUSTOMIZE_PRICE, catalog products' lines take their catalog price and no discount. A line naming a stock-tracked product does not move a stock (only /v1's lines naming a stock do). Counts in the plan's number of invoices per month (402 once reached). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices · requires INVOICES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new invoice. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *BillingInvoiceForeignProductError (422 billing.invoice.foreign-product): A line names a product of another organization: nothing was created.
  • *BillingInvoiceOutOfScopeReferenceError (422 billing.invoice.out-of-scope-reference): The invoice references a customer or products outside the caller's tag scope: nothing was created.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Create(ctx, &myle.InvoiceCreateParams{CompanyID: "company_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f", Lines: []myle.InvoiceLineInput{{Name: "name", Quantity: "20", UnitPrice: myle.Money{Amount: "12.50", Currency: "EUR"}, VatRate: "20"}}})
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) Debit

func (s *InvoicesService) Debit(ctx context.Context, invoiceID string, opts ...RequestOption) (*PaymentStatus, error)

Debit — Debit an invoice by SEPA.

Starts the SEPA debit of what remains due on an invoice the caller can see, through its customer's mandate, as from the web app: the invoice moves to SEPA_PENDING (a VALIDATED one is shared first), the customer is told, and the payment appears in the invoice's payments once Stripe settled the debit (a few business days; SEPA_FAILED if the bank rejects it). Refused before anything moves: a demo organization, the collection off or paused, a plan without SEPA debits, no account, an account Stripe suspended, a status that takes no debit (a debit in progress included), no mandate, an amount outside the bounds, a quota reached. A session passes the passkey step-up stripe.collect (bound to the invoice); an API key holding the right needs none. Send an Idempotency-Key to retry safely: a retry never debits twice (the second meets SEPA_PENDING).

POST /organizations/{id}/invoices/{invoiceId}/debit · requires STRIPE_PAYMENTS_COLLECT.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the invoice's payment status, the debit started.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *PaymentPlanCollectionRequiredError (402 payments.plan.collection-required): The organization's plan does not carry Stripe collection (SEPA debits, mandates, auto-debit, online payment of invoices); the trial does not either. It comes with a paid plan.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *PaymentAccountDemoError (409 payments.account.demo): A demo organization never reaches Stripe: nothing was done.
  • *PaymentCollectionDisabledError (409 payments.collection.disabled): The organization turned its Stripe collection off (in its payment settings): nothing is debited, no mandate is offered, no auto-debit is turned on until it turns it back on.
  • *PaymentCollectionPausedError (409 payments.collection.paused): The organization's Stripe collection is paused because it no longer pays for Myle: it resumes with its subscription.
  • *PaymentAccountNotConnectedError (409 payments.account.not-connected): No Stripe account is connected to the organization: connect one first (POST …/payments-account/onboarding).
  • *PaymentAccountSuspendedError (409 payments.account.suspended): Stripe suspended the organization's account: debits are blocked until it is settled in the Stripe dashboard.
  • *PaymentDebitNotDebitableError (409 payments.debit.not-debitable): The invoice's status takes no debit: a draft, a paid one, a debit already in progress (SEPA_PENDING), a dispute or a refusal on the e-invoicing network. Nothing was debited.
  • *PaymentMandateMissingError (409 payments.mandate.missing): The customer has no usable SEPA mandate: send them a mandate invitation (POST …/sepa-mandate/invitation).
  • *PaymentMandateForeignIbanError (409 payments.mandate.foreign-iban): The customer's mandate is on a bank account outside France: only French IBANs are debited.
  • *PaymentDebitNothingDueError (409 payments.debit.nothing-due): Nothing remains due on the invoice: nothing was debited.
  • *PaymentDebitBelowMinimumError (409 payments.debit.below-minimum): What remains due is below the smallest SEPA debit: nothing was debited.
  • *PaymentDebitAboveMaximumError (409 payments.debit.above-maximum): What remains due is above the largest SEPA debit: nothing was debited.
  • *PaymentDebitQuotaReachedError (409 payments.debit.quota-reached): The organization's SEPA quota over the rolling window is reached, for this customer or for the whole organization: nothing was debited (GET …/payments-account/sepa-quota tells what remains).
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
paymentStatus, err := org.Invoices.Debit(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(paymentStatus)

func (*InvoicesService) Delete

func (s *InvoicesService) Delete(ctx context.Context, invoiceID string, opts ...RequestOption) error

Delete — Delete a draft invoice.

Deletes a DRAFT: the stock movements it made are undone, the documents it was linked to released. A validated invoice is never deleted (409): it is cancelled by a credit note. With If-Match, refused (412) if the invoice changed since it was read.

DELETE /organizations/{id}/invoices/{invoiceId} · requires INVOICES_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the invoice is deleted).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceNotADraftError (409 billing.invoice.not-a-draft): The invoice is no longer a draft: a validated invoice is never changed, deleted or validated again; it is cancelled or corrected by a credit note.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Get(ctx, "invoice_…")
if err != nil {
	return err
}
err = org.Invoices.Delete(ctx, "invoice_…", myle.IfMatch(invoice))
if err != nil {
	return err
}

func (*InvoicesService) DownloadPDF

func (s *InvoicesService) DownloadPDF(ctx context.Context, invoiceID string, params *GetInvoicePDFParams, opts ...RequestOption) (*FileDownload, error)

DownloadPDF — Get an invoice as a PDF file.

Returns an invoice the caller can see; one outside its tag scope, deleted or unknown is a 404. As JSON by default; with Accept: application/pdf, its PDF (the document Myle sends, drafts included), or with ?format=facturx its Factur-X (validated invoices only, 409 for a draft). An invoice of Myle's own subscriptions imported from Stripe answers Stripe's PDF.

GET /organizations/{id}/invoices/{invoiceId} · requires INVOICES_LIST, with Accept: application/pdf.

It answers a *FileDownload: the bytes as received (Data, never decoded), Filename (from Content-Disposition, "" when none), ContentType and the Response; Save(path) writes it. An error answer is JSON as for any call, returned as the type of its code.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceFacturxUnavailableError (409 billing.invoice.facturx-unavailable): A draft has no Factur-X: the Factur-X carries the legal number the validation gives.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
file, err := org.Invoices.DownloadPDF(ctx, "invoice_…", &myle.GetInvoicePDFParams{Format: myle.Value(myle.GetInvoicePDFFormatFacturx)})
if err != nil {
	return err
}
if err := file.Save(cmp.Or(file.Filename, "invoice.pdf")); err != nil {
	return err
}
Example
package main

import (
	"cmp"
	"context"
	"log"

	myle "github.com/myleapp/myle-go"
)

func main() {
	org := myle.NewClient().Organization("organization_…")
	file, err := org.Invoices.DownloadPDF(context.Background(), "invoice_…", &myle.GetInvoicePDFParams{
		Format: myle.Value(myle.GetInvoicePDFFormatFacturx),
	})
	if err != nil {
		log.Fatal(err)
	}
	if err := file.Save(cmp.Or(file.Filename, "invoice.pdf")); err != nil {
		log.Fatal(err)
	}
}

func (*InvoicesService) Edit

func (s *InvoicesService) Edit(ctx context.Context, invoiceID string, params *InvoiceEditParams, opts ...RequestOption) (*Invoice, error)

Edit — Change a draft's lines, customer or description.

Changes what a DRAFT bills, as « Modifier » in the web app: its lines (the whole list: add, change, remove and reorder them in one write), its customer, its description; an absent member is unchanged. Only while the draft has not left the organization — not mailed, shared by a link, read online, sent to the e-invoicing network, paid (GET …/editability says; 409 billing.invoice.not-editable otherwise). The write replays the creation: the price customization guard (a line kept as it was keeps its price), the tenant and tag scope guards, the totals recomputed, and a new customer's recipient, legal details and discount. A validated invoice is never changed (409): it is corrected by a credit note. A draft whose lines take from a stock (chosen with a stock lot in the web app) keeps its lines and customer there (409, reason STOCK_TRACKED); one made from delivery forms keeps its lines, linked to them, and its customer, whose forms they bill (409, reason DELIVERY_FORMS); its description still changes. A body that changes nothing writes nothing. Its tags: PATCH …/{invoiceId}. With If-Match, refused (412) if the invoice changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/edit · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the invoice, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceNotADraftError (409 billing.invoice.not-a-draft): The invoice is no longer a draft: a validated invoice is never changed, deleted or validated again; it is cancelled or corrected by a credit note.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoiceNotEditableError (409 billing.invoice.not-editable): The draft has been seen outside the organization, or settled, and is no longer changed: correct it by a credit note once validated, or delete it and create another. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *BillingInvoiceForeignProductError (422 billing.invoice.foreign-product): A line names a product of another organization: nothing was created.
  • *BillingInvoiceOutOfScopeReferenceError (422 billing.invoice.out-of-scope-reference): The invoice references a customer or products outside the caller's tag scope: nothing was created.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Edit(ctx, "invoice_…", &myle.InvoiceEditParams{CompanyID: myle.String("company_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f")})
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) Get

func (s *InvoicesService) Get(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Get — Get an invoice.

Returns an invoice the caller can see; one outside its tag scope, deleted or unknown is a 404. As JSON by default; with Accept: application/pdf, its PDF (the document Myle sends, drafts included), or with ?format=facturx its Factur-X (validated invoices only, 409 for a draft). An invoice of Myle's own subscriptions imported from Stripe answers Stripe's PDF.

The file answers have their own method: InvoicesService.DownloadPDF.

GET /organizations/{id}/invoices/{invoiceId} · requires INVOICES_LIST.

It answers the invoice. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceFacturxUnavailableError (409 billing.invoice.facturx-unavailable): A draft has no Factur-X: the Factur-X carries the legal number the validation gives.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Get(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) GetEditability

func (s *InvoicesService) GetEditability(ctx context.Context, invoiceID string, opts ...RequestOption) (*InvoiceEditability, error)

GetEditability — Tell whether a draft can still be changed.

Answers whether POST …/edit can still change the lines, the customer and the description of this draft: editable while it has not left the organization; otherwise the reason (no draft, mailed, shared by a link, read online, sent to the e-invoicing network, paid, a credit note issued to cancel an invoice, from the Boutique, imported from Stripe). The rule POST …/edit replays under the invoice's lock.

GET /organizations/{id}/invoices/{invoiceId}/editability · requires INVOICES_PATCH.

It answers whether the draft can be changed.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
invoiceEditability, err := org.Invoices.GetEditability(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoiceEditability)

func (*InvoicesService) GetEinvoice

func (s *InvoicesService) GetEinvoice(ctx context.Context, invoiceID string, opts ...RequestOption) (*Einvoice, error)

GetEinvoice — Get an invoice's e-invoice.

Returns the invoice's e-invoice on the network: its technical status and history (null and empty when it was never submitted), the last failure read, and whether it can go through the network now (its eligibility).

GET /organizations/{id}/invoices/{invoiceId}/einvoice · requires INVOICES_LIST.

It answers the e-invoice.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
einvoice, err := org.Invoices.GetEinvoice(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(einvoice)

func (*InvoicesService) GetEligibility

GetEligibility — Count what each batch would act on.

Among the invoices the filters give (the list's filters: the caller's invoices, inside its tag scope, drafts included, deleted ones never), how many each batch would act on: the counts the web app shows on its batch buttons before a batch (« Valider · 52 »), and the public bodies among the drafts' customers, whom validating mails the original (Chorus Pro).

GET /organizations/{id}/invoices/eligibility · requires INVOICES_LIST.

It answers the counts.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
invoiceEligibility, err := org.Invoices.GetEligibility(ctx, nil)
if err != nil {
	return err
}
fmt.Println(invoiceEligibility)

func (*InvoicesService) GetNeighbors

func (s *InvoicesService) GetNeighbors(ctx context.Context, invoiceID string, params *InvoiceGetNeighborsParams, opts ...RequestOption) (*InvoiceNeighbors, error)

GetNeighbors — Get an invoice's neighbors in the list.

Returns the invoices right before and right after this one in the invoice list read with the same filters and sort (the list's query parameters, without limit and cursor): next is the first invoice of the page that follows a page ending on this one, previous the one before it in that order. Each is null at an end of the list, and both are null when the filters leave the invoice out of it. The invoice must be one the caller can see (404 otherwise); its tag scope applies to the neighbors too.

GET /organizations/{id}/invoices/{invoiceId}/neighbors · requires INVOICES_LIST.

It answers the invoice's neighbors.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
invoiceNeighbors, err := org.Invoices.GetNeighbors(ctx, "invoice_…", nil)
if err != nil {
	return err
}
fmt.Println(invoiceNeighbors)

func (*InvoicesService) GetPaymentStatus

func (s *InvoicesService) GetPaymentStatus(ctx context.Context, invoiceID string, opts ...RequestOption) (*PaymentStatus, error)

GetPaymentStatus — Get an invoice's payment status.

Returns the payment status of an invoice the caller can see: its status (SEPA_PENDING while a debit is on its way), what was paid, what remains due, its payments and its last SEPA debit — what the public payment page shows its customer, without a token.

GET /organizations/{id}/invoices/{invoiceId}/payment-status · requires INVOICES_LIST.

It answers the payment status.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
paymentStatus, err := org.Invoices.GetPaymentStatus(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(paymentStatus)

func (*InvoicesService) List

List — List the invoices.

Returns the organization's invoices the caller can see (its tag scope applies), drafts included, deleted ones never, filtered and sorted, one page at a time. For a synchronization: updatedAfter with the largest updatedAt already seen, sort updatedAt.

GET /organizations/{id}/invoices · requires INVOICES_LIST.

It answers a *Paginator (a page of invoices): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
for invoice, err := range org.Invoices.List(ctx, &myle.InvoiceListParams{Status: []myle.InvoiceStatus{myle.InvoiceStatusUnpaid}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(invoice.ID)
}

func (*InvoicesService) ListTags

func (s *InvoicesService) ListTags(ctx context.Context, opts ...RequestOption) *Paginator[string]

ListTags — List the invoices' tags.

Returns the tags the organization's invoices carry, sorted: the values a tag filter of the invoice list can take. For a tag-scoped caller, only the tags of the invoices in its scope. All of them at once: nextCursor is never present.

GET /organizations/{id}/invoices/tags · requires INVOICES_LIST.

It answers a *Paginator over a single page (the tags, sorted). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for tag, err := range org.Invoices.ListTags(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(tag)
}

func (*InvoicesService) MarkLost

func (s *InvoicesService) MarkLost(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

MarkLost — Write an invoice off as lost.

Writes off an unpaid sale, as « Perdue » in the web app: a SHARED, UNPAID or partially paid invoice becomes LOST (its payments stay); POST …/credit-notes then cancels it. An invoice LOST already is answered as it is; a credit note issued to cancel an invoice is never written off itself (409). The organization is notified, the change audited with the amount. With If-Match, refused (412) if the invoice changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/mark-lost · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the invoice, lost. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoiceTransitionRefusedError (409 billing.invoice.transition-refused): The invoice's status cannot move to the one asked: a draft is validated first, an invoice is shared before it is written off, a paid one is taken back to unpaid rather than shared… Nothing was written.
  • *BillingInvoiceGeneratedCreditNoteError (409 billing.invoice.generated-credit-note): This credit note was issued to cancel a lost invoice: it is never written off itself. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.MarkLost(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) Refund

func (s *InvoicesService) Refund(ctx context.Context, invoiceID string, opts ...RequestOption) (*PaymentStatus, error)

Refund — Refund an invoice's Stripe payments.

Asks Stripe to refund, in full, every payment of the invoice it collected (a SEPA debit, an online payment). The invoice's status moves once Stripe confirms the refund: the answer is its payment status as it is. A session passes the passkey step-up stripe.refund (bound to the invoice); an API key holding the right needs none. Send an Idempotency-Key to retry safely: without it, a retry asks Stripe again.

POST /organizations/{id}/invoices/{invoiceId}/refund · requires STRIPE_PAYMENTS_COLLECT.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the invoice's payment status.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *PaymentAccountDemoError (409 payments.account.demo): A demo organization never reaches Stripe: nothing was done.
  • *PaymentAccountNotConnectedError (409 payments.account.not-connected): No Stripe account is connected to the organization: connect one first (POST …/payments-account/onboarding).
  • *PaymentRefundNothingToRefundError (409 payments.refund.nothing-to-refund): No payment of the invoice was collected through Stripe: there is nothing to refund there.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
paymentStatus, err := org.Invoices.Refund(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(paymentStatus)

func (*InvoicesService) Reinvoice

func (s *InvoicesService) Reinvoice(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Reinvoice — Re-bill a credit note as a new draft.

Re-bills the sale a credit note cancelled, as « Refacturer » in the web app: from a validated credit note issued by POST …/credit-notes, a new DRAFT invoice with its lines positive again, for the customer as it is today; the two are linked (the credit note keeps its status). Validate the draft to number it. The same caller asking again gets the same draft; one created by someone else is refused (409). Not counted in the plan's invoices per month: correcting an invoice is a legal duty. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/reinvoice · requires INVOICES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new draft invoice. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoiceNotReinvoiceableError (409 billing.invoice.not-reinvoiceable): Only a credit note issued here to cancel an invoice (POST …/credit-notes), once validated, is re-billed: this invoice is no such credit note, or it is still a draft. Nothing was created.
  • *BillingInvoiceAlreadyReinvoicedError (409 billing.invoice.already-reinvoiced): Another member or key re-billed this credit note already (the caller's own draft is answered again, never refused). Nothing was created.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Reinvoice(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) Send

func (s *InvoicesService) Send(ctx context.Context, invoiceID string, params *InvoiceSendParams, opts ...RequestOption) *Paginator[ItemResult]

Send — Send an invoice by e-mail.

Sends an invoice to some of its customer's e-mail addresses, by their ids, as from the web app: the PDF attached (a draft goes as a pro forma; an invoice the e-invoicing network delivered, as its duplicate), with the organization's letter, logged and counted in its monthly e-mail quota. Synchronous: the answer is the result per recipient, in the order sent (SUCCEEDED, or FAILED with its error: billing.invoice.recipient-unsubscribed for an address that unsubscribed, core.plan-limit-reached when the quota ran out on the way, core.internal-error when the mail could not go). Refused as a whole, sending nothing: an id that is not one of the customer's addresses (422), a quota short of the recipients (402 core.plan-limit-reached, limit emailsPerMonth), an invoice whose channel is the e-invoicing network (409). Send an Idempotency-Key to retry safely: without it, a retry sends again.

POST /organizations/{id}/invoices/{invoiceId}/send · requires INVOICES_SEND_EMAIL.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per recipient). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceEinvoiceRequiredError (409 billing.invoice.einvoice-required): The customer receives its invoices through the e-invoicing network and this one has not been submitted there yet: its legal channel is the network, not an e-mail nor a hand-over. Nothing was sent or marked.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Invoices.Send(ctx, "invoice_…", &myle.InvoiceSendParams{To: []string{"to"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*InvoicesService) SetCorrectedInvoice

func (s *InvoicesService) SetCorrectedInvoice(ctx context.Context, invoiceID string, params *InvoiceSetCorrectedInvoiceParams, opts ...RequestOption) (*Invoice, error)

SetCorrectedInvoice — Name the invoice a credit note corrects.

Names the invoice a credit note keyed in by hand corrects (its correctsInvoiceId; the invoice lists it in creditNoteIds), as « Facture d'origine » in the web app: its Factur-X and e-invoice then cite it (BT-25). A reference, not a cancellation: the invoice keeps its status and payments. Naming another replaces the first, until the credit note was handed to its customer with it (409 billing.invoice.correction-fixed, DELIVERED); never once it is on the e-invoicing network (EINVOICED), nor for a credit note issued to cancel an invoice (GENERATED). Naming the same again changes nothing. With If-Match (the credit note's ETag), refused (412) if it changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/set-corrected-invoice · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the credit note. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoiceNotACreditNoteError (409 billing.invoice.not-a-credit-note): This invoice is no credit note (its total is not negative): it corrects no invoice. Nothing was written.
  • *BillingInvoiceCorrectionFixedError (409 billing.invoice.correction-fixed): The invoice this credit note corrects can no longer be changed. Nothing was written.
  • *BillingInvoiceNotCorrectableError (409 billing.invoice.not-correctable): This credit note cannot correct that invoice: it corrects an issued invoice of the same customer, dated no later than the credit note, not cancelled already, and one the caller can see (GET …/correctable-invoices lists them). Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.SetCorrectedInvoice(ctx, "invoice_…", &myle.InvoiceSetCorrectedInvoiceParams{CorrectsInvoiceID: "invoice_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f"})
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) Share

func (s *InvoicesService) Share(ctx context.Context, invoiceID string, params *InvoiceShareParams, opts ...RequestOption) (*Invoice, error)

Share — Mark an invoice as handed to its customer.

Declares that the customer has the invoice — handed over in person, sent by your own e-mail or shop, by any channel —, as « Partager » in the web app: a VALIDATED, UNPAID or LOST invoice becomes SHARED, the first status that takes a payment (POST …/payments). Nothing is sent. An invoice SHARED already (the e-mail Myle sent was delivered) is answered as it is. While the e-invoicing network is the invoice's required channel (its customer receives e-invoices), refused (409 billing.invoice.einvoice-required) unless force=true: the invoice was really handed over outside the network. The organization is notified, the change audited. With If-Match, refused (412) if the invoice changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/share · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the invoice, shared. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoiceTransitionRefusedError (409 billing.invoice.transition-refused): The invoice's status cannot move to the one asked: a draft is validated first, an invoice is shared before it is written off, a paid one is taken back to unpaid rather than shared… Nothing was written.
  • *BillingInvoiceCreditNoteLinkedError (409 billing.invoice.credit-note-linked): A credit note cancels the invoice: its status no longer moves, and it takes no payment. Nothing was recorded.
  • *BillingInvoiceEinvoiceRequiredError (409 billing.invoice.einvoice-required): The customer receives its invoices through the e-invoicing network and this one has not been submitted there yet: its legal channel is the network, not an e-mail nor a hand-over. Nothing was sent or marked.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Share(ctx, "invoice_…", nil)
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) SubmitEinvoice

func (s *InvoicesService) SubmitEinvoice(ctx context.Context, invoiceID string, opts ...RequestOption) (*Einvoice, error)

SubmitEinvoice — Submit an invoice through the e-invoicing network.

Submits the validated invoice to SuperPDP (its e-invoice read at GET …/einvoice), or submits it again after a failure. An organization on a trial or without a paid plan that never connected is refused (402). Refused, nothing submitted: not eligible, a failure submitting again cannot fix, a credit note naming no invoice (409). SuperPDP refusing it or not answering is a 502, recorded in the invoice's history. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/submit-einvoice · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the e-invoice, submitted.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *EinvoicingOrganizationPaidPlanRequiredError (402 einvoicing.organization.paid-plan-required): E-invoicing comes with a paid plan: an organization on a trial or without a paid subscription cannot connect to the e-invoicing platform, nor submit invoices unless it connected before. Nothing was done.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *EinvoicingEinvoiceNotEligibleError (409 einvoicing.einvoice.not-eligible): The invoice cannot go through the e-invoicing network now (the organization not connected or verified, the customer not reachable, the invoice not validated…): nothing was submitted. Read GET …/einvoice for the eligibility.
  • *EinvoicingEinvoiceNotRetryableError (409 einvoicing.einvoice.not-retryable): The last submission failed in a way submitting again cannot fix until something changes (the customer's address, the invoice's content): nothing was submitted.
  • *EinvoicingEinvoiceCreditNoteReferenceMissingError (409 einvoicing.einvoice.credit-note-reference-missing): A credit note goes through the network with the invoice it corrects: name it on the credit note first. Nothing was submitted.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
einvoice, err := org.Invoices.SubmitEinvoice(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(einvoice)

func (*InvoicesService) Unpay

func (s *InvoicesService) Unpay(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Unpay — Take an invoice back to unpaid.

Takes an invoice back to UNPAID, as « Impayée » in the web app: from SHARED or LOST, or from PAID and partially paid, whose payments are then REMOVED with their ledger entries and bank matches — which needs INVOICES_REVERT_PAID (403 otherwise). A payment collected through Stripe is refunded in Stripe, never removed here (409); an invoice a credit note cancels does not move (409). UNPAID without payments is answered as it is. The organization is notified, the change audited with the number of payments removed. With If-Match, refused (412) if the invoice changed since it was read. Send an Idempotency-Key to retry safely. To remove one payment only: DELETE …/payments/{paymentId}.

POST /organizations/{id}/invoices/{invoiceId}/unpay · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the invoice, unpaid. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoiceTransitionRefusedError (409 billing.invoice.transition-refused): The invoice's status cannot move to the one asked: a draft is validated first, an invoice is shared before it is written off, a paid one is taken back to unpaid rather than shared… Nothing was written.
  • *BillingInvoiceCreditNoteLinkedError (409 billing.invoice.credit-note-linked): A credit note cancels the invoice: its status no longer moves, and it takes no payment. Nothing was recorded.
  • *BillingPaymentStripeCollectedError (409 billing.payment.stripe-collected): The payment was collected through Stripe: it is refunded in Stripe, never removed in Myle. Nothing was removed.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Unpay(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*InvoicesService) Update

func (s *InvoicesService) Update(ctx context.Context, invoiceID string, params *InvoiceUpdateParams, opts ...RequestOption) (*Invoice, error)

Update — Change a draft invoice.

Changes the members sent of a DRAFT (a JSON merge patch): its tags. A validated invoice is never changed (409): it is corrected by a credit note. With If-Match, refused (412) if the invoice changed since it was read; a change of its tags moves its ETag.

PATCH /organizations/{id}/invoices/{invoiceId} · requires INVOICES_PATCH.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the invoice, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceNotADraftError (409 billing.invoice.not-a-draft): The invoice is no longer a draft: a validated invoice is never changed, deleted or validated again; it is cancelled or corrected by a credit note.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Get(ctx, "invoice_…")
if err != nil {
	return err
}
updated, err := org.Invoices.Update(ctx, "invoice_…", nil, myle.IfMatch(invoice))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

func (*InvoicesService) Validate

func (s *InvoicesService) Validate(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Validate — Validate an invoice.

Validates a DRAFT: it gets its legal number (the organization's sequence, without gaps), its issue date (today, Paris) and its due date, and can no longer be changed or deleted. Then, as from the web app, the invoice is sent the way the customer's settings say (an e-invoice through the network, or the PDF to its addresses marked « Invoice »), booked in the sales journal, and debited if the customer chose SEPA debits. Validating again an invoice the same caller validated answers it as it is. With If-Match, refused (412) if the invoice changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/invoices/{invoiceId}/validate · requires INVOICES_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the invoice, validated. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *BillingInvoiceNotADraftError (409 billing.invoice.not-a-draft): The invoice is no longer a draft: a validated invoice is never changed, deleted or validated again; it is cancelled or corrected by a credit note.
  • *BillingInvoiceStripeImportedError (409 billing.invoice.stripe-imported): The invoice was imported from Stripe (Myle's own subscriptions): it is managed in Stripe, never written in Myle.
  • *BillingInvoicePartialCreditNoteError (409 billing.invoice.partial-credit-note): This credit note cancels a delivery-note invoice that deducts a deposit: it must take it back whole. For a price error or a partial return, delete this draft and issue a credit note that corrects the invoice.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Invoices.Validate(ctx, "invoice_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

type ItemError

type ItemError struct {
	// The error code (billing.invoice.not-a-draft…).
	Code string `json:"code"`
	// The code's context, an object.
	Context map[string]any `json:"context"`
	// What went wrong, in the request's language (Accept-Language).
	Error string `json:"error"`
}

ItemError — Why this item failed: code, context and error as in an error response, without request_id.

type ItemResult

type ItemResult struct {
	// The item's id, as sent.
	ID string `json:"id"`
	// SUCCEEDED or FAILED.
	Status ItemResultStatus `json:"status"`
	// Why this item failed: code, context and error as in an error response, without request_id.
	Error *ItemError `json:"error"`
}

ItemResult — The outcome of one item.

type ItemResultStatus

type ItemResultStatus string

ItemResultStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: SUCCEEDED, FAILED.

const ItemResultStatusFailed ItemResultStatus = "FAILED"

ItemResultStatusFailed is "FAILED".

const ItemResultStatusSucceeded ItemResultStatus = "SUCCEEDED"

ItemResultStatusSucceeded is "SUCCEEDED".

type ItemResultWithCreatedID

type ItemResultWithCreatedID struct {
	// The item's id, as sent.
	ID string `json:"id"`
	// SUCCEEDED or FAILED.
	Status ItemResultStatus `json:"status"`
	// Why this item failed: code, context and error as in an error response, without request_id.
	Error *ItemError `json:"error"`
	// What the item created (its id: the credit note, the draft, the payment), null when it failed.
	CreatedID *string `json:"createdId"`
}

ItemResultWithCreatedID — The outcome of one item, and what it created.

type LegalForm

type LegalForm struct {
	// Its code (5710 for a SAS), or null.
	Code *string `json:"code"`
	// Its name (« SAS, société par actions simplifiée »), or null.
	Label *string `json:"label"`
}

LegalForm — The legal form of a company, as the INSEE registry gives it.

type LineStock

type LineStock struct {
	// The stock (stock_<uuid>): send it as a lot's stockId.
	StockID string `json:"stockId"`
	// Its number.
	Number string `json:"number"`
	// Its name.
	Name string `json:"name"`
	// What it holds, a decimal string.
	Available string `json:"available"`
	// What it holds without a lot number, a decimal string.
	Untracked string `json:"untracked"`
	// Its lots that can still give goods.
	Lots []StockLot `json:"lots"`
}

LineStock — A stock of a line's product, and what it can give.

type LineStockAvailability

type LineStockAvailability struct {
	// The line's index: a lot's lineIndex.
	LineIndex int `json:"lineIndex"`
	// Its product (product_<uuid>), or null.
	ProductID *string `json:"productId"`
	// Its label.
	Name string `json:"name"`
	// The quantity ordered, a decimal string.
	Quantity string `json:"quantity"`
	// The stocks of its product.
	Stocks []LineStock `json:"stocks"`
}

LineStockAvailability — An order line and the stocks its goods can leave from.

type LocalizedText

type LocalizedText struct {
	// In French.
	Fr string `json:"fr"`
	// In English.
	En string `json:"en"`
}

LocalizedText — A text in French and in English.

type MeService

type MeService struct {
	// APIKeys — credentials for programs: user keys act as their owner, organization keys as their own robot
	// account, with Myle rights. Managed with a signed-in session only (/me/api-keys).
	APIKeys *MyAPIKeysService
	// contains filtered or unexported fields
}

MeService — the caller: the signed-in user, or the user an API key acts as (/me).

Reach it as client.Me.

func (*MeService) Get

func (s *MeService) Get(ctx context.Context, opts ...RequestOption) (*User, error)

Get — Get the signed-in user.

Returns the user the credential belongs to: the signed-in person for a session or a user key; for an organization key, its robot account (object robot, id robot_<uuid>).

GET /me.

It answers the signed-in user.

Example:

user, err := client.Me.Get(ctx)
if err != nil {
	return err
}
fmt.Println(user.ID)

type MethodNotAllowedError

type MethodNotAllowedError struct{ *APIError }

MethodNotAllowedError is a 405: the path does not accept this method.

func (*MethodNotAllowedError) Unwrap

func (e *MethodNotAllowedError) Unwrap() error

Unwrap answers the *APIError.

type Money

type Money struct {
	// A decimal string, never a number: "1250.00".
	Amount string `json:"amount"`
	// The ISO 4217 currency code: EUR.
	Currency string `json:"currency"`
}

Money — An amount of money: a decimal string and its ISO 4217 currency.

type MyAPIKeyCreateParams

type MyAPIKeyCreateParams struct {
	// The key's name (« Mon script d'export »), 1 to 200 characters.
	Name string `json:"name"`
	// ONE_HOUR, THIRTY_DAYS, NINETY_DAYS, ONE_YEAR (the default) or NEVER.
	ExpiresIn Opt[string] `json:"expiresIn"`
	// The organizations it may act in (organization_<uuid>), among yours; absent or null for all of them.
	OrganizationIDs Opt[[]string] `json:"organizationIds"`
	// The rights it is narrowed to (RightType names, see GET /rights); absent or null for all of yours.
	Rights Opt[[]string] `json:"rights"`
}

MyAPIKeyCreateParams is the parameters of MyAPIKeysService.Create (createMyApiKey): its body's members. A nil *MyAPIKeyCreateParams sends none.

A new user key.

A member of type Opt is left out unless set.

func (MyAPIKeyCreateParams) MarshalJSON

func (p MyAPIKeyCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type MyAPIKeyGetParams

type MyAPIKeyGetParams struct {
	// An organization to compute effectiveRights in.
	OrganizationID Opt[string] `json:"-"`
}

MyAPIKeyGetParams is the parameters of MyAPIKeysService.Get (getMyApiKey): its query parameters. A nil *MyAPIKeyGetParams sends none.

type MyAPIKeyUpdateParams

type MyAPIKeyUpdateParams struct {
	// A new name.
	Name Opt[string] `json:"name"`
	// The organizations it may act in, among yours; null for all of them.
	OrganizationIDs Opt[[]string] `json:"organizationIds"`
	// The rights it is narrowed to, never beyond yours; null for all of yours.
	Rights Opt[[]string] `json:"rights"`
}

MyAPIKeyUpdateParams is the parameters of MyAPIKeysService.Update (updateMyApiKey): its body's members. A nil *MyAPIKeyUpdateParams sends none.

A merge patch of a user key (RFC 7396): an absent member is unchanged.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (MyAPIKeyUpdateParams) MarshalJSON

func (p MyAPIKeyUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type MyAPIKeysService

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

MyAPIKeysService — credentials for programs: user keys act as their owner, organization keys as their own robot account, with Myle rights. Managed with a signed-in session only (/me/api-keys).

Reach it as client.Me.APIKeys.

func (*MyAPIKeysService) Create

func (s *MyAPIKeysService) Create(ctx context.Context, params *MyAPIKeyCreateParams, opts ...RequestOption) (*APIKey, error)

Create — Create a user key.

Creates a key acting as the signed-in user, with their live rights in every organization or in the ones listed, optionally narrowed to a list of rights. Needs a passkey step-up for apiKey.create. The token is in this answer only. At most 10 active user keys per user. A replay of the same request (Idempotency-Key) answers the key without its token, which Myle never keeps.

POST /me/api-keys · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new key, with its token. It carries its ETag().

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthAPIKeyLimitReachedError (409 auth.api-key.limit-reached): The limit of active API keys is reached (10 per user, 20 per organization); revoke one first.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

apiKey, err := client.Me.APIKeys.Create(ctx, &myle.MyAPIKeyCreateParams{Name: "name"})
if err != nil {
	return err
}
fmt.Println(apiKey.Name, apiKey.ETag())

func (*MyAPIKeysService) Get

func (s *MyAPIKeysService) Get(ctx context.Context, apiKeyID string, params *MyAPIKeyGetParams, opts ...RequestOption) (*APIKey, error)

Get — Get one of my API keys.

Returns one of the signed-in user's keys. With ?organizationId=, its effectiveRights are what it may do in that organization.

GET /me/api-keys/{apiKeyId} · a signed-in session only: API keys get 403 auth.session.required.

It answers the key. It carries its ETag().

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

apiKey, err := client.Me.APIKeys.Get(ctx, "apiKey_…", nil)
if err != nil {
	return err
}
fmt.Println(apiKey.Name, apiKey.ETag())

func (*MyAPIKeysService) List

List — List my API keys.

Returns the signed-in user's own keys (user keys), revoked ones included, newest first.

GET /me/api-keys · a signed-in session only: API keys get 403 auth.session.required.

It answers a *Paginator over a single page (the user's keys). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).

Example:

for apiKey, err := range client.Me.APIKeys.List(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(apiKey.ID)
}

func (*MyAPIKeysService) Revoke

func (s *MyAPIKeysService) Revoke(ctx context.Context, apiKeyID string, opts ...RequestOption) error

Revoke — Revoke one of my API keys.

Revokes a user key at once. Revoking a revoked key changes nothing. With If-Match, refused (412) if the key changed since it was read.

DELETE /me/api-keys/{apiKeyId} · a signed-in session only: API keys get 403 auth.session.required.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the key is revoked).

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

apiKey, err := client.Me.APIKeys.Get(ctx, "apiKey_…", nil)
if err != nil {
	return err
}
err = client.Me.APIKeys.Revoke(ctx, "apiKey_…", myle.IfMatch(apiKey))
if err != nil {
	return err
}

func (*MyAPIKeysService) Rotate

func (s *MyAPIKeysService) Rotate(ctx context.Context, apiKeyID string, opts ...RequestOption) (*APIKey, error)

Rotate — Rotate one of my API keys.

Creates a new key with the same name, organizations and rights, and makes the old one expire within 24 hours. Needs a passkey step-up for apiKey.create. The new token is in this answer only. A replay of the same request (Idempotency-Key) answers the key without its token, which Myle never keeps.

POST /me/api-keys/{apiKeyId}/rotate · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new key, with its token. It carries its ETag().

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

apiKey, err := client.Me.APIKeys.Rotate(ctx, "apiKey_…")
if err != nil {
	return err
}
fmt.Println(apiKey.Name, apiKey.ETag())

func (*MyAPIKeysService) Update

func (s *MyAPIKeysService) Update(ctx context.Context, apiKeyID string, params *MyAPIKeyUpdateParams, opts ...RequestOption) (*APIKey, error)

Update — Change one of my API keys.

Renames a user key, or narrows or widens its organizations and rights, never beyond the user's own. A revoked or expired key cannot change (409). With If-Match, refused (412) if the key changed since it was read.

PATCH /me/api-keys/{apiKeyId} · a signed-in session only: API keys get 403 auth.session.required.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the key, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

apiKey, err := client.Me.APIKeys.Get(ctx, "apiKey_…", nil)
if err != nil {
	return err
}
updated, err := client.Me.APIKeys.Update(ctx, "apiKey_…", &myle.MyAPIKeyUpdateParams{Name: myle.String("name")}, myle.IfMatch(apiKey))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type NotAcceptableError

type NotAcceptableError struct{ *APIError }

NotAcceptableError is a 406: no representation for the Accept sent.

func (*NotAcceptableError) Unwrap

func (e *NotAcceptableError) Unwrap() error

Unwrap answers the *APIError.

type NotFoundError

type NotFoundError struct{ *APIError }

NotFoundError is a 404: what the path names does not exist, or the caller cannot see it.

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

Unwrap answers the *APIError.

type OnlinePaymentSetting

type OnlinePaymentSetting struct {
	// Always "onlinePaymentSetting".
	Object string `json:"object"`
	// The organization turned the online payment of its invoices on.
	IsEnabled bool `json:"isEnabled"`
	// It is on and the account can take payments: invoices show « Pay ».
	IsActive bool `json:"isActive"`
	// A Stripe account is connected.
	IsStripeConnected bool `json:"isStripeConnected"`
	// Stripe lets the account take payments.
	ChargesEnabled bool `json:"chargesEnabled"`
	// The organization's plan carries Stripe collection.
	IsAllowedByPlan bool `json:"isAllowedByPlan"`
	// The collection is neither turned off nor paused.
	IsCollectionAllowed bool `json:"isCollectionAllowed"`
	// When the setting last changed (RFC 3339, UTC), or null.
	UpdatedAt *string `json:"updatedAt"`
	// contains filtered or unexported fields
}

OnlinePaymentSetting — The online payment of the organization's invoices (a « Pay » button on the invoice's public page).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (OnlinePaymentSetting) ETag

func (m OnlinePaymentSetting) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (OnlinePaymentSetting) LastResponse

func (m OnlinePaymentSetting) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type OpeningHoursDay

type OpeningHoursDay struct {
	// MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY or SUNDAY.
	Day OpeningHoursDayDay `json:"day"`
	// Its open ranges, in order.
	Ranges []OpeningHoursRange `json:"ranges"`
}

OpeningHoursDay — The opening hours of one day of the week.

type OpeningHoursDayDay

type OpeningHoursDayDay string

OpeningHoursDayDay is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY.

const OpeningHoursDayDayFriday OpeningHoursDayDay = "FRIDAY"

OpeningHoursDayDayFriday is "FRIDAY".

const OpeningHoursDayDayMonday OpeningHoursDayDay = "MONDAY"

OpeningHoursDayDayMonday is "MONDAY".

const OpeningHoursDayDaySaturday OpeningHoursDayDay = "SATURDAY"

OpeningHoursDayDaySaturday is "SATURDAY".

const OpeningHoursDayDaySunday OpeningHoursDayDay = "SUNDAY"

OpeningHoursDayDaySunday is "SUNDAY".

const OpeningHoursDayDayThursday OpeningHoursDayDay = "THURSDAY"

OpeningHoursDayDayThursday is "THURSDAY".

const OpeningHoursDayDayTuesday OpeningHoursDayDay = "TUESDAY"

OpeningHoursDayDayTuesday is "TUESDAY".

const OpeningHoursDayDayWednesday OpeningHoursDayDay = "WEDNESDAY"

OpeningHoursDayDayWednesday is "WEDNESDAY".

type OpeningHoursRange

type OpeningHoursRange struct {
	// When it opens (HH:mm).
	Open string `json:"open"`
	// When it closes (HH:mm), after it opens.
	Close string `json:"close"`
}

OpeningHoursRange — A time range of a day, open to close (HH:mm, the organization's local time).

type Opt

type Opt[T any] struct {
	// contains filtered or unexported fields
}

Opt is a member of a request that may be left out: absent (the zero value, not sent), null (sent as null: a merge patch clears the member) or a value. Build one with Value, String, Int, Bool, Float or Null.

params := &myle.ProductUpdateParams{
	Name:             myle.String("Foin de luzerne"), // sent
	AccountingNumber: myle.Null[string](),            // sent as null: cleared
	// UnitPrice left out: unchanged
}

func Bool

func Bool(v bool) Opt[bool]

Bool answers an Opt holding the bool v.

func Float

func Float(v float64) Opt[float64]

Float answers an Opt holding the float64 v.

func Int

func Int(v int) Opt[int]

Int answers an Opt holding the int v.

func Int64

func Int64(v int64) Opt[int64]

Int64 answers an Opt holding the int64 v.

func Null

func Null[T any]() Opt[T]

Null answers an Opt sent as null (a merge patch clears the member).

func String

func String(v string) Opt[string]

String answers an Opt holding the string v.

func Value

func Value[T any](v T) Opt[T]

Value answers an Opt holding v.

func (Opt[T]) Get

func (o Opt[T]) Get() (T, bool)

Get answers the value and true, or the zero value and false when absent or null.

func (Opt[T]) IsNull

func (o Opt[T]) IsNull() bool

IsNull tells whether the member is sent as null.

func (Opt[T]) IsSet

func (o Opt[T]) IsSet() bool

IsSet tells whether the member is sent: a value or null.

func (Opt[T]) MarshalJSON

func (o Opt[T]) MarshalJSON() ([]byte, error)

MarshalJSON writes the value, or null when absent or null (a request leaves an absent member out).

func (*Opt[T]) UnmarshalJSON

func (o *Opt[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON reads null as Null, anything else as a value.

type Order

type Order struct {
	// The order's id (order_<uuid>).
	ID string `json:"id"`
	// Always "order".
	Object string `json:"object"`
	// The organization it belongs to (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// Its number in the organization's sequence ("42"), given at its creation.
	Number string `json:"number"`
	// VALIDATED (taken, not marked shared yet), SHARED (the customer has it), APPROVED (confirmed),
	// WAITING_FOR_DELIVERY (prepared), DELIVERED (a delivery note was made from it), INVOICED (billed, or settled
	// on its deposits), CANCELED, ORDERED (older orders only). An open enum: tolerate a value you do not know. A
	// deleted order is never returned (404).
	Status OrderStatus `json:"status"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// The customer as the order froze it.
	Company OrderCompanySnapshot `json:"company"`
	// Its date (YYYY-MM-DD).
	IssueDate string `json:"issueDate"`
	// Where, when and by whom an order is delivered.
	Delivery OrderDelivery `json:"delivery"`
	// A description printed on it, or null.
	Description *string `json:"description"`
	// Its lines, in order.
	Lines []OrderLine `json:"lines"`
	// The lines' subtotals (excluding VAT, discounts deducted).
	Subtotal Money `json:"subtotal"`
	// The VAT.
	Vat Money `json:"vat"`
	// What the order amounts to.
	Total Money `json:"total"`
	// The quotations it was made from (quotation_<uuid>).
	QuotationIDs []string `json:"quotationIds"`
	// The delivery notes made from it (deliveryNote_<uuid>).
	DeliveryNoteIDs []string `json:"deliveryNoteIds"`
	// The invoices made from it, deposit and final invoices included (invoice_<uuid>).
	InvoiceIDs []string `json:"invoiceIds"`
	// true once closed on its deposits (« Solder la commande »): INVOICED, without a final invoice.
	Settled bool `json:"settled"`
	// Its own tags, sorted.
	Tags []string `json:"tags"`
	// When it was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When it, its lines, its status or its tags last changed (RFC 3339, UTC).
	UpdatedAt string `json:"updatedAt"`
	// contains filtered or unexported fields
}

Order — An order. It is born VALIDATED, with its number: there is no draft. subtotal: the lines' subtotals (excluding VAT, discounts deducted); vat: the VAT; total: what the order amounts to. company: the customer as the order froze it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Order) ETag

func (m Order) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Order) LastResponse

func (m Order) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type OrderBatchApproveParams

type OrderBatchApproveParams struct {
	// Their ids (order_<uuid>), at least one; each order is answered once, at its first place in the order sent.
	IDs []string `json:"ids"`
}

OrderBatchApproveParams is the parameters of OrdersService.BatchApprove (batchApproveOrders): its body's members. A nil *OrderBatchApproveParams sends none.

The orders a batch acts on.

A member of type Opt is left out unless set.

func (OrderBatchApproveParams) MarshalJSON

func (p OrderBatchApproveParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderBatchShareParams

type OrderBatchShareParams struct {
	// Their ids (order_<uuid>), at least one; each order is answered once, at its first place in the order sent.
	IDs []string `json:"ids"`
}

OrderBatchShareParams is the parameters of OrdersService.BatchShare (batchShareOrders): its body's members. A nil *OrderBatchShareParams sends none.

The orders a batch acts on.

A member of type Opt is left out unless set.

func (OrderBatchShareParams) MarshalJSON

func (p OrderBatchShareParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderCompanySnapshot

type OrderCompanySnapshot struct {
	// The customer's legal name.
	Name string `json:"name"`
	// The address the order is addressed to.
	Address string `json:"address"`
	// Its billing address, or null.
	BillingAddress *string `json:"billingAddress"`
	// Its headquarters address, or null.
	HeadquartersAddress *string `json:"headquartersAddress"`
	// Its SIREN, or null.
	Siren *string `json:"siren"`
	// Its VAT number, or null.
	VatNumber *string `json:"vatNumber"`
}

OrderCompanySnapshot — The customer as the order froze it at its creation (or when its customer changed): what the PDF prints, whatever the company became since.

type OrderCreateParams

type OrderCreateParams struct {
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// Its date (YYYY-MM-DD); today (Paris) when absent.
	IssueDate Opt[string] `json:"issueDate"`
	// Where, when and by whom a new order is delivered; every member optional.
	Delivery Opt[OrderDeliveryInput] `json:"delivery"`
	// A description printed on the order.
	Description Opt[string] `json:"description"`
	// Its lines, at least one, in order.
	Lines []OrderLineInput `json:"lines"`
	// Its own tags.
	Tags Opt[[]string] `json:"tags"`
}

OrderCreateParams is the parameters of OrdersService.Create (createOrder): its body's members. A nil *OrderCreateParams sends none.

A new order. companyId: the customer, one of the organization's companies. Without DELIVERYFORMS_CUSTOMIZE_PRICE, a line takes its product's catalog price (the customer's own price if it has one) and no discount, whatever is sent.

A member of type Opt is left out unless set.

func (OrderCreateParams) MarshalJSON

func (p OrderCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderDeliverParams

type OrderDeliverParams struct {
	// The lots, absent or empty for none: the document takes the order's lines as they are, no stock moved.
	Lots Opt[[]OrderLotInput] `json:"lots"`
}

OrderDeliverParams is the parameters of OrdersService.Deliver (deliverOrder): its body's members. A nil *OrderDeliverParams sends none.

The stock lots the goods leave from: for each order line, none (no stock moves for it), one, or several — one line of the document made per lot.

A member of type Opt is left out unless set.

func (OrderDeliverParams) MarshalJSON

func (p OrderDeliverParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderDelivery

type OrderDelivery struct {
	// When it is to be delivered (YYYY-MM-DD), or null; a delivery sets it to the delivery note's day.
	Date *string `json:"date"`
	// The customer's postal address it is delivered to (postalAddress_<uuid>, one of the company's
	// postalAddresses), or null.
	AddressID *string `json:"addressId"`
	// Where it is delivered, as printed (the address chosen, or a free text of older orders), or null.
	Address *string `json:"address"`
	// The member who prepares it (user_<uuid>, robot_<uuid>), or null.
	PreparerID *string `json:"preparerId"`
	// The member who delivers it (user_<uuid>, robot_<uuid>), or null.
	DelivererID *string `json:"delivererId"`
}

OrderDelivery — Where, when and by whom an order is delivered.

type OrderDeliveryInput

type OrderDeliveryInput struct {
	// When it is to be delivered (YYYY-MM-DD).
	Date Opt[string] `json:"date"`
	// The customer's postal address to deliver to (postalAddress_<uuid>, one of the company's).
	AddressID Opt[string] `json:"addressId"`
	// The member who prepares it (user_<uuid>, robot_<uuid>).
	PreparerID Opt[string] `json:"preparerId"`
	// The member who delivers it (user_<uuid>, robot_<uuid>).
	DelivererID Opt[string] `json:"delivererId"`
}

OrderDeliveryInput — Where, when and by whom a new order is delivered; every member optional. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (OrderDeliveryInput) MarshalJSON

func (p OrderDeliveryInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderEditParams

type OrderEditParams struct {
	// The customer (company_<uuid>): the order takes the recipient and legal details a creation would give it for
	// this customer, and loses its delivery address (the previous customer's) unless deliveryAddressId is sent.
	// Refused for an order made from a quotation (409, reason FROM_QUOTATION).
	CompanyID Opt[string] `json:"companyId"`
	// The customer's postal address to deliver to (postalAddress_<uuid>); null for none.
	DeliveryAddressID Opt[string] `json:"deliveryAddressId"`
	// A description printed on the order; null for none.
	Description Opt[string] `json:"description"`
	// Its lines, all of them, at least one, in order (as at the creation). Without DELIVERYFORMS_CUSTOMIZE_PRICE, a
	// new line takes its product's catalog price and no discount; a line kept as it was keeps its price.
	Lines Opt[[]OrderLineInput] `json:"lines"`
}

OrderEditParams is the parameters of OrdersService.Edit (editOrder): its body's members. A nil *OrderEditParams sends none.

An order's new content: an absent member is unchanged. Lines are added, changed, removed and reordered by sending the whole list.

A member of type Opt is left out unless set.

func (OrderEditParams) MarshalJSON

func (p OrderEditParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderEditability

type OrderEditability struct {
	// true while it is VALIDATED and has not left the organization (no mail, link, share), nor was converted or
	// placed on the Boutique.
	Editable bool `json:"editable"`
	// Why it cannot, or null: NOT_DRAFT (no longer VALIDATED), MAILED, SHARE_LINK, PUBLIC_ACCESS (read online),
	// SHARED (marked shared once), CONVERTED (a delivery note or an invoice was made from it), SHOP (a Boutique
	// order). An open list.
	Reason *string `json:"reason"`
	// contains filtered or unexported fields
}

OrderEditability — Whether an order's lines, customer and description can still be changed: editable, or reason says why not.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (OrderEditability) ETag

func (m OrderEditability) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (OrderEditability) LastResponse

func (m OrderEditability) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type OrderEligibility

type OrderEligibility struct {
	// The orders the filters give (the caller's, deleted ones never).
	Total int `json:"total"`
	// VALIDATED, for batch-share.
	Share int `json:"share"`
	// VALIDATED or SHARED, for batch-approve.
	Approve int `json:"approve"`
	// contains filtered or unexported fields
}

OrderEligibility — What each batch would act on among the orders the filters give: the counts the web app shows on its batch buttons.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (OrderEligibility) ETag

func (m OrderEligibility) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (OrderEligibility) LastResponse

func (m OrderEligibility) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type OrderGetEligibilityParams

type OrderGetEligibilityParams struct {
	// Orders of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, WAITING_FOR_DELIVERY,
	// DELIVERED, INVOICED, CANCELED, ORDERED. Each value is sent (name=a&name=b).
	Status []OrderStatus `json:"-"`
	// Orders of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Orders dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Orders dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Orders to deliver on or after this day (YYYY-MM-DD).
	DeliveryDateFrom Opt[string] `json:"-"`
	// Orders to deliver on or before this day (YYYY-MM-DD).
	DeliveryDateTo Opt[string] `json:"-"`
	// Orders one of these members prepares (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	PreparerID []string `json:"-"`
	// Orders one of these members delivers (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	DelivererID []string `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Orders changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Orders carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value is
	// sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), an order carrying one of the tags; ALL, an order carrying
	// every one of them.
	TagMode Opt[OrderListTagMode] `json:"-"`
	// Leaves out the orders carrying every one of these tags (repeat it for several): one tag leaves out the orders
	// carrying it; with several, an order carrying only some of them stays. Each value is sent (name=a&name=b).
	ExcludeTag []string `json:"-"`
}

OrderGetEligibilityParams is the parameters of OrdersService.GetEligibility (getOrderEligibility): its query parameters. A nil *OrderGetEligibilityParams sends none.

type OrderGetNeighborsParams

type OrderGetNeighborsParams struct {
	// Orders of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, WAITING_FOR_DELIVERY,
	// DELIVERED, INVOICED, CANCELED, ORDERED. Each value is sent (name=a&name=b).
	Status []OrderStatus `json:"-"`
	// Orders of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Orders dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Orders dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Orders to deliver on or after this day (YYYY-MM-DD).
	DeliveryDateFrom Opt[string] `json:"-"`
	// Orders to deliver on or before this day (YYYY-MM-DD).
	DeliveryDateTo Opt[string] `json:"-"`
	// Orders one of these members prepares (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	PreparerID []string `json:"-"`
	// Orders one of these members delivers (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	DelivererID []string `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Orders changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Orders carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value is
	// sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), an order carrying one of the tags; ALL, an order carrying
	// every one of them.
	TagMode Opt[OrderListTagMode] `json:"-"`
	// Leaves out the orders carrying every one of these tags (repeat it for several): one tag leaves out the orders
	// carrying it; with several, an order carrying only some of them stays. Each value is sent (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// -number (the default, the newest first), number, createdAt, updatedAt or issueDate; with a leading - for
	// descending. Ties are broken by the order's id.
	Sort Opt[OrderListSort] `json:"-"`
}

OrderGetNeighborsParams is the parameters of OrdersService.GetNeighbors (getOrderNeighbors): its query parameters. A nil *OrderGetNeighborsParams sends none.

type OrderInvoiceParams

type OrderInvoiceParams struct {
	// The lots, absent or empty for none: the document takes the order's lines as they are, no stock moved.
	Lots Opt[[]OrderLotInput] `json:"lots"`
}

OrderInvoiceParams is the parameters of OrdersService.Invoice (invoiceOrder): its body's members. A nil *OrderInvoiceParams sends none.

The stock lots the goods leave from: for each order line, none (no stock moves for it), one, or several — one line of the document made per lot.

A member of type Opt is left out unless set.

func (OrderInvoiceParams) MarshalJSON

func (p OrderInvoiceParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderLine

type OrderLine struct {
	// The line's position in the order, from 0.
	Index int `json:"index"`
	// The catalog product it orders (product_<uuid>), or null for a line without a product.
	ProductID *string `json:"productId"`
	// The product's reference as printed, or null.
	Number *string `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// A longer description printed under the label, or null.
	Description *string `json:"description"`
	// The quantity, a decimal string: "12.5".
	Quantity string `json:"quantity"`
	// Excluding VAT, before the discount.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate, a decimal string in percent: "20", "5.5".
	VatRate string `json:"vatRate"`
	// The line's discount in percent, a decimal string, or null.
	DiscountRate *string `json:"discountRate"`
	// A discount of a fixed amount, or null (discountRate and discountAmount add up).
	DiscountAmount *Money `json:"discountAmount"`
	// Why the line is discounted, or null.
	DiscountReason *string `json:"discountReason"`
	// Quantity × unitPrice, discounts deducted, excluding VAT.
	Subtotal Money `json:"subtotal"`
	// The subtotal with its VAT.
	Total Money `json:"total"`
	// The accounting account the line is booked to (706000…), or null for the default.
	AccountingNumber *string `json:"accountingNumber"`
}

OrderLine — An order line. unitPrice: excluding VAT, before the discount; discountAmount: a discount of a fixed amount, or null (discountRate and discountAmount add up); subtotal: quantity × unitPrice, discounts deducted, excluding VAT; total: the subtotal with its VAT.

type OrderLineInput

type OrderLineInput struct {
	// The catalog product it orders (product_<uuid>).
	ProductID string `json:"productId"`
	// The product's reference as printed.
	Number Opt[string] `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// A longer description printed under the label.
	Description Opt[string] `json:"description"`
	// The quantity, a decimal string: "12.5".
	Quantity string `json:"quantity"`
	// In EUR, excluding VAT, before the discount.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate in percent, a decimal string from 0 to 100: "20".
	VatRate string `json:"vatRate"`
	// A discount in percent, a decimal string from 0 to 100.
	DiscountRate Opt[string] `json:"discountRate"`
	// A discount of a fixed amount in EUR, excluding VAT (it adds up with discountRate).
	DiscountAmount Opt[Money] `json:"discountAmount"`
	// Why the line is discounted, printed with it.
	DiscountReason Opt[string] `json:"discountReason"`
	// The accounting account the line is booked to; absent for the default.
	AccountingNumber Opt[string] `json:"accountingNumber"`
}

OrderLineInput — A line of an order. unitPrice: in EUR, excluding VAT, before the discount; discountAmount: a discount of a fixed amount in EUR, excluding VAT (it adds up with discountRate). A line names no stock lot: the lots are chosen when the goods leave (POST …/deliver, POST …/invoice). (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (OrderLineInput) MarshalJSON

func (p OrderLineInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderListParams

type OrderListParams struct {
	// Orders of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, WAITING_FOR_DELIVERY,
	// DELIVERED, INVOICED, CANCELED, ORDERED. Each value is sent (name=a&name=b).
	Status []OrderStatus `json:"-"`
	// Orders of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Orders dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Orders dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Orders to deliver on or after this day (YYYY-MM-DD).
	DeliveryDateFrom Opt[string] `json:"-"`
	// Orders to deliver on or before this day (YYYY-MM-DD).
	DeliveryDateTo Opt[string] `json:"-"`
	// Orders one of these members prepares (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	PreparerID []string `json:"-"`
	// Orders one of these members delivers (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	DelivererID []string `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Orders changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Orders carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value is
	// sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), an order carrying one of the tags; ALL, an order carrying
	// every one of them.
	TagMode Opt[OrderListTagMode] `json:"-"`
	// Leaves out the orders carrying every one of these tags (repeat it for several): one tag leaves out the orders
	// carrying it; with several, an order carrying only some of them stays. Each value is sent (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// -number (the default, the newest first), number, createdAt, updatedAt or issueDate; with a leading - for
	// descending. Ties are broken by the order's id.
	Sort Opt[OrderListSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of orders of the whole list with these filters (one more count
	// on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

OrderListParams is the parameters of OrdersService.List (listOrders): its query parameters. A nil *OrderListParams sends none.

type OrderListSort

type OrderListSort string

OrderListSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: -number, number, -createdAt, createdAt, updatedAt, -updatedAt, -issueDate, issueDate.

const OrderListSortCreatedAt OrderListSort = "createdAt"

OrderListSortCreatedAt is "createdAt".

const OrderListSortCreatedAtDesc OrderListSort = "-createdAt"

OrderListSortCreatedAtDesc is "-createdAt".

const OrderListSortIssueDate OrderListSort = "issueDate"

OrderListSortIssueDate is "issueDate".

const OrderListSortIssueDateDesc OrderListSort = "-issueDate"

OrderListSortIssueDateDesc is "-issueDate".

const OrderListSortNumber OrderListSort = "number"

OrderListSortNumber is "number".

const OrderListSortNumberDesc OrderListSort = "-number"

OrderListSortNumberDesc is "-number".

const OrderListSortUpdatedAt OrderListSort = "updatedAt"

OrderListSortUpdatedAt is "updatedAt".

const OrderListSortUpdatedAtDesc OrderListSort = "-updatedAt"

OrderListSortUpdatedAtDesc is "-updatedAt".

type OrderListTagMode

type OrderListTagMode string

OrderListTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const OrderListTagModeAll OrderListTagMode = "ALL"

OrderListTagModeAll is "ALL".

const OrderListTagModeAny OrderListTagMode = "ANY"

OrderListTagModeAny is "ANY".

type OrderLotInput

type OrderLotInput struct {
	// The order line it serves (its index; one the order does not have: 422).
	LineIndex int `json:"lineIndex"`
	// The stock they leave (stock_<uuid>, one of the stocks GET …/stock-availability offers the line: a stock of
	// another product is a 422).
	StockID Opt[string] `json:"stockId"`
	// The lot's number (its traceability code), as GET …/stock-availability gives it.
	LotNumber Opt[string] `json:"lotNumber"`
	// Where the goods come from, printed with the line.
	Origin Opt[string] `json:"origin"`
	// The quantity leaving this lot, a decimal string above zero; the lots of a line add up to at most its quantity
	// (on an invoice, exactly it, a single lot included).
	Quantity string `json:"quantity"`
	// The days until the « date limite de consommation » (DLC) printed with the line.
	UseByDays Opt[int] `json:"useByDays"`
	// The days until the « date de consommation recommandée » (DCR) printed with the line.
	ConsumeBeforeDays Opt[int] `json:"consumeBeforeDays"`
	// The days until the « date de durabilité minimale » (DDM) printed with the line.
	BestBeforeDays Opt[int] `json:"bestBeforeDays"`
}

OrderLotInput — A stock lot the goods of an order line leave from. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (OrderLotInput) MarshalJSON

func (p OrderLotInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderNeighbors

type OrderNeighbors struct {
	// An order, in short: enough to name it and to fetch it.
	Previous *OrderSummary `json:"previous"`
	// An order, in short: enough to name it and to fetch it.
	Next *OrderSummary `json:"next"`
	// contains filtered or unexported fields
}

OrderNeighbors — An order's place in the order list: previous, the order right before it, and next, the one right after it; each null at an end of the list, both null when the filters leave the order out of it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (OrderNeighbors) ETag

func (m OrderNeighbors) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (OrderNeighbors) LastResponse

func (m OrderNeighbors) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type OrderOrderAlreadyInvoicedContext

type OrderOrderAlreadyInvoicedContext struct {
	// The invoice it made (invoice_<uuid>, perhaps deleted since), or null when its link is missing.
	InvoiceID string `json:"invoiceId"`
}

OrderOrderAlreadyInvoicedContext — The detail of this error.

The context of an error code.

type OrderOrderAlreadyInvoicedError

type OrderOrderAlreadyInvoicedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context OrderOrderAlreadyInvoicedContext
}

OrderOrderAlreadyInvoicedError is the error code orders.order.already-invoiced (409): Another member or key billed this order already (the caller's own billing is answered again), or the caller's own billing made an invoice deleted since. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderAlreadyInvoicedError) Unwrap

Unwrap answers the *ConflictError it is.

type OrderOrderForeignProductContext

type OrderOrderForeignProductContext struct {
	// The products refused (product_<uuid>).
	ProductIDs []string `json:"productIds"`
}

OrderOrderForeignProductContext — The detail of this error.

The context of an error code.

type OrderOrderForeignProductError

type OrderOrderForeignProductError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context OrderOrderForeignProductContext
}

OrderOrderForeignProductError is the error code orders.order.foreign-product (422): A line names a product of another organization: nothing was written.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderForeignProductError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type OrderOrderHasDepositsError

type OrderOrderHasDepositsError struct {
	*ConflictError
}

OrderOrderHasDepositsError is the error code orders.order.has-deposits (409): The order is billed in several times: deposit invoices were issued on it (or on the quotation it was made from), and its final invoice, which deducts them, settles it; a whole invoice would bill them twice. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderHasDepositsError) Unwrap

func (e *OrderOrderHasDepositsError) Unwrap() error

Unwrap answers the *ConflictError it is.

type OrderOrderNotDeletableContext

type OrderOrderNotDeletableContext struct {
	// The order's status: DELIVERED or INVOICED.
	Status string `json:"status"`
}

OrderOrderNotDeletableContext — The detail of this error.

The context of an error code.

type OrderOrderNotDeletableError

type OrderOrderNotDeletableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context OrderOrderNotDeletableContext
}

OrderOrderNotDeletableError is the error code orders.order.not-deletable (409): A delivered order is deleted once its delivery note is (which takes it back to WAITING_FOR_DELIVERY); a billed one never is: credit its invoice instead. Nothing was deleted.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderNotDeletableError) Unwrap

func (e *OrderOrderNotDeletableError) Unwrap() error

Unwrap answers the *ConflictError it is.

type OrderOrderNotEditableContext

type OrderOrderNotEditableContext struct {
	// Why: NOT_DRAFT (no longer VALIDATED), MAILED, SHARE_LINK, PUBLIC_ACCESS, SHARED, CONVERTED, SHOP,
	// FROM_QUOTATION (its customer only).
	Reason string `json:"reason"`
}

OrderOrderNotEditableContext — The detail of this error.

The context of an error code.

type OrderOrderNotEditableError

type OrderOrderNotEditableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context OrderOrderNotEditableContext
}

OrderOrderNotEditableError is the error code orders.order.not-editable (409): The order has left the organization (mailed, shared by a link, marked shared), was converted, comes from the Boutique or is no longer VALIDATED: its lines, customer and description are kept as the customer saw them. Or its customer cannot change: it was made from a quotation that customer accepted. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderNotEditableError) Unwrap

func (e *OrderOrderNotEditableError) Unwrap() error

Unwrap answers the *ConflictError it is.

type OrderOrderOutOfScopeReferenceContext

type OrderOrderOutOfScopeReferenceContext struct {
	// What is out of scope: company or product.
	Kind string `json:"kind"`
	// The ids refused (company_<uuid>, product_<uuid>).
	IDs []string `json:"ids"`
}

OrderOrderOutOfScopeReferenceContext — The detail of this error.

The context of an error code.

type OrderOrderOutOfScopeReferenceError

type OrderOrderOutOfScopeReferenceError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context OrderOrderOutOfScopeReferenceContext
}

OrderOrderOutOfScopeReferenceError is the error code orders.order.out-of-scope-reference (422): The order references a customer or products outside the caller's tag scope: nothing was written.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderOutOfScopeReferenceError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type OrderOrderRecipientUnsubscribedContext

type OrderOrderRecipientUnsubscribedContext struct {
	// The address refused (companyEmailAddress_<uuid>).
	EmailAddressID string `json:"emailAddressId"`
}

OrderOrderRecipientUnsubscribedContext — The detail of this error.

The context of an error code.

type OrderOrderRecipientUnsubscribedError

type OrderOrderRecipientUnsubscribedError struct {
	*APIError
	// Context is the detail of the error.
	Context OrderOrderRecipientUnsubscribedContext
}

OrderOrderRecipientUnsubscribedError is the error code orders.order.recipient-unsubscribed: This address unsubscribed from the organization's e-mails: the order was not sent to it.

The document names no operation answering it, so it wraps *APIError directly: its Status is the one received.

func (*OrderOrderRecipientUnsubscribedError) Unwrap

Unwrap answers the *APIError it is.

type OrderOrderShopBilledError

type OrderOrderShopBilledError struct {
	*ConflictError
}

OrderOrderShopBilledError is the error code orders.order.shop-billed (409): The order was placed and paid by card on the organization's Boutique: its invoice is issued when the card is charged, at the amount really charged; converting it here would bill it twice. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderShopBilledError) Unwrap

func (e *OrderOrderShopBilledError) Unwrap() error

Unwrap answers the *ConflictError it is.

type OrderOrderTransitionRefusedContext

type OrderOrderTransitionRefusedContext struct {
	// The order's status (VALIDATED, APPROVED…).
	Status string `json:"status"`
	// The status asked (SHARED, APPROVED, WAITING_FOR_DELIVERY, DELIVERED, INVOICED…).
	To string `json:"to"`
}

OrderOrderTransitionRefusedContext — The detail of this error.

The context of an error code.

type OrderOrderTransitionRefusedError

type OrderOrderTransitionRefusedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context OrderOrderTransitionRefusedContext
}

OrderOrderTransitionRefusedError is the error code orders.order.transition-refused (409): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*OrderOrderTransitionRefusedError) Unwrap

Unwrap answers the *ConflictError it is.

type OrderSendParams

type OrderSendParams struct {
	// The recipients, at least one: ids of the customer's e-mail addresses.
	To []string `json:"to"`
}

OrderSendParams is the parameters of OrdersService.Send (sendOrder): its body's members. A nil *OrderSendParams sends none.

Who to send the order to: ids of its customer's e-mail addresses (companyEmailAddress_<uuid>, the company's emailAddresses), never a free address.

A member of type Opt is left out unless set.

func (OrderSendParams) MarshalJSON

func (p OrderSendParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrderStatus

type OrderStatus string

OrderStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: APPROVED, CANCELED, INVOICED, SHARED, ORDERED, DELIVERED, VALIDATED, WAITING_FOR_DELIVERY.

const OrderStatusApproved OrderStatus = "APPROVED"

OrderStatusApproved is "APPROVED".

const OrderStatusCanceled OrderStatus = "CANCELED"

OrderStatusCanceled is "CANCELED".

const OrderStatusDelivered OrderStatus = "DELIVERED"

OrderStatusDelivered is "DELIVERED".

const OrderStatusInvoiced OrderStatus = "INVOICED"

OrderStatusInvoiced is "INVOICED".

const OrderStatusOrdered OrderStatus = "ORDERED"

OrderStatusOrdered is "ORDERED".

const OrderStatusShared OrderStatus = "SHARED"

OrderStatusShared is "SHARED".

const OrderStatusValidated OrderStatus = "VALIDATED"

OrderStatusValidated is "VALIDATED".

const OrderStatusWaitingForDelivery OrderStatus = "WAITING_FOR_DELIVERY"

OrderStatusWaitingForDelivery is "WAITING_FOR_DELIVERY".

type OrderStatusChange

type OrderStatusChange struct {
	// The status it took (see the order's).
	Status string `json:"status"`
	// When it took it (RFC 3339, UTC).
	ChangedAt string `json:"changedAt"`
	// Who did something: a person (USER) or the robot account of an organization API key (ROBOT), which acts in the
	// key's name.
	Author *Author `json:"author"`
}

OrderStatusChange — One status an order went through. author: the person or the organization key's robot that set it, or null when Myle did (its creation, the Boutique).

type OrderStatusHistoryService

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

OrderStatusHistoryService — /organizations/{id}/orders/{orderId}/status-history.

Reach it as client.Organization("organization_…").Orders.StatusHistory.

func (*OrderStatusHistoryService) List

List — List an order's status history.

Returns every status an order went through, newest first, with when and by whom — a person, an organization key's robot, or null when Myle set it (its creation). All at once: nextCursor is never present.

GET /organizations/{id}/orders/{orderId}/status-history · requires one of ORDER_LIST, QUOTATION_LIST.

It answers a *Paginator over a single page (the order's statuses, newest first). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for orderStatusChange, err := range org.Orders.StatusHistory.List(ctx, "order_…").All() {
	if err != nil {
		return err
	}
	fmt.Println(orderStatusChange)
}

type OrderSummary

type OrderSummary struct {
	// The order's id (order_<uuid>).
	ID string `json:"id"`
	// Always "order".
	Object string `json:"object"`
	// Its number.
	Number string `json:"number"`
	// Its status (see the order's).
	Status string `json:"status"`
	// The customer's name as the order froze it.
	CompanyName string `json:"companyName"`
}

OrderSummary — An order, in short: enough to name it and to fetch it.

type OrderUpdateParams

type OrderUpdateParams struct {
	// Its date (YYYY-MM-DD).
	IssueDate Opt[string] `json:"issueDate"`
	// A merge patch of an order's delivery: an absent member is unchanged, null clears it. Its address: POST
	// …/edit.
	Delivery Opt[UpdateOrderDelivery] `json:"delivery"`
	// A description printed on it; null for none.
	Description Opt[string] `json:"description"`
	// Its own tags, all of them; null for none.
	Tags Opt[[]string] `json:"tags"`
}

OrderUpdateParams is the parameters of OrdersService.Update (updateOrder): its body's members. A nil *OrderUpdateParams sends none.

A merge patch of an order (RFC 7396): an absent member is unchanged. Its lines, customer and delivery address: POST …/edit (the description here too, in any status).

A merge patch: a member left out is unchanged, myle.Null clears it.

func (OrderUpdateParams) MarshalJSON

func (p OrderUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type OrdersService

type OrdersService struct {
	// StatusHistory — /organizations/{id}/orders/{orderId}/status-history.
	StatusHistory *OrderStatusHistoryService
	// contains filtered or unexported fields
}

OrdersService — the organization's orders: what its customers order, confirmed, prepared, delivered (with the stock lots the goods leave from) and billed (/organizations/{id}/orders).

Reach it as client.Organization("organization_…").Orders.

func (*OrdersService) Approve

func (s *OrdersService) Approve(ctx context.Context, orderID string, opts ...RequestOption) (*Order, error)

Approve — Record that the customer confirmed an order.

Records the customer's yes, as « Accepter » in the web app: a VALIDATED or SHARED order becomes APPROVED, ready to be prepared. An APPROVED one is answered as it is. The change is audited. With If-Match, refused (412) if the order changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/approve · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the order, approved. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Approve(ctx, "order_…")
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) BatchApprove

func (s *OrdersService) BatchApprove(ctx context.Context, params *OrderBatchApproveParams, opts ...RequestOption) *Paginator[ItemResult]

BatchApprove — Record that customers confirmed several orders.

Records the customers' yes on several orders, each as POST …/approve does: a VALIDATED or SHARED order becomes APPROVED, APPROVED already is answered as it is. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED, or FAILED with its error — core.not-found, orders.order.transition-refused —, the others approved all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/batch-approve · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per order). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Orders.BatchApprove(ctx, &myle.OrderBatchApproveParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*OrdersService) BatchShare

func (s *OrdersService) BatchShare(ctx context.Context, params *OrderBatchShareParams, opts ...RequestOption) *Paginator[ItemResult]

BatchShare — Mark several orders as handed to their customers.

Declares several orders handed to their customers, each as POST …/share does: a VALIDATED order becomes SHARED, SHARED already is answered as it is; nothing is sent. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED, or FAILED with its error — core.not-found (unknown, deleted, outside the caller's tag scope), orders.order.transition-refused —, the others shared all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/batch-share · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per order). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Orders.BatchShare(ctx, &myle.OrderBatchShareParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*OrdersService) Cancel

func (s *OrdersService) Cancel(ctx context.Context, orderID string, opts ...RequestOption) (*Order, error)

Cancel — Cancel an order.

Cancels an order, as « Annuler » in the web app: it becomes CANCELED from any status until it is delivered or billed. A CANCELED one is answered as it is. A Boutique order not charged yet releases its card authorization and its stock reservation, and its buyer is told. The change is audited. With If-Match, refused (412) if the order changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/cancel · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the order, cancelled. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Cancel(ctx, "order_…")
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) Create

func (s *OrdersService) Create(ctx context.Context, params *OrderCreateParams, opts ...RequestOption) (*Order, error)

Create — Create an order.

Takes an order, as from the web app: born VALIDATED with its number (an order has no draft). Without DELIVERYFORMS_CUSTOMIZE_PRICE, lines take their catalog price and no discount. The organization is notified, and the order is mailed at once to the customer's addresses marked « Commande » (the company's emailAddresses with ORDER among their purposes), as the web app does. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders · requires one of ORDER_CREATE, QUOTATION_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new order. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *OrderOrderForeignProductError (422 orders.order.foreign-product): A line names a product of another organization: nothing was written.
  • *OrderOrderOutOfScopeReferenceError (422 orders.order.out-of-scope-reference): The order references a customer or products outside the caller's tag scope: nothing was written.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Create(ctx, &myle.OrderCreateParams{CompanyID: "company_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f", Lines: []myle.OrderLineInput{{ProductID: "product_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f", Name: "name", Quantity: "20", UnitPrice: myle.Money{Amount: "12.50", Currency: "EUR"}, VatRate: "20"}}})
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) Delete

func (s *OrdersService) Delete(ctx context.Context, orderID string, opts ...RequestOption) error

Delete — Delete an order.

Deletes an order, as the web app does: not a DELIVERED one (delete its delivery note first, which takes it back to WAITING_FOR_DELIVERY) nor an INVOICED one (credit its invoice): 409. The quotation it was made from goes back to APPROVED. The organization is notified (« Commande supprimée »). With If-Match, refused (412) if the order changed since it was read.

DELETE /organizations/{id}/orders/{orderId} · requires one of ORDER_DELETE, QUOTATION_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the order is deleted).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderNotDeletableError (409 orders.order.not-deletable): A delivered order is deleted once its delivery note is (which takes it back to WAITING_FOR_DELIVERY); a billed one never is: credit its invoice instead. Nothing was deleted.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Get(ctx, "order_…")
if err != nil {
	return err
}
err = org.Orders.Delete(ctx, "order_…", myle.IfMatch(order))
if err != nil {
	return err
}

func (*OrdersService) Deliver

func (s *OrdersService) Deliver(ctx context.Context, orderID string, params *OrderDeliverParams, opts ...RequestOption) (*DeliveryNote, error)

Deliver — Deliver an order: make its delivery note.

Turns a WAITING_FOR_DELIVERY order into a delivery note, as « Livrer » in the web app: the order becomes DELIVERED, its delivery date the note's day; the note takes its lines (at the order's prices; with lots, the customer's discount taken off them, as the web app does), its tags and its delivery address, linked both ways (the order lists it in deliveryNoteIds). lots: the stock lots the goods leave from, each naming its order line (lineIndex), its stock and lot number, and its quantity; several per line make one line each on the document, a line without lots is taken as ordered, and the stock movements are written. A lot's stock is one of its line's product (another: 422 on its stockId). Without lots, no stock moves. The lots of a line add up to at most what it ordered (422). An order with deposit invoices makes a note « billed with the order ». A Boutique order ends its stock reservation and, if the shop wants it, charges the card at the real amount. The organization is notified. Asking again once delivered: 409. With If-Match, refused (412) if the order changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/deliver · requires ORDER_TRANSFORM_TO_DELIVERYFORM.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the delivery note it made. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
deliveryNote, err := org.Orders.Deliver(ctx, "order_…", nil)
if err != nil {
	return err
}
fmt.Println(deliveryNote.ID, deliveryNote.ETag())

func (*OrdersService) DownloadPDF

func (s *OrdersService) DownloadPDF(ctx context.Context, orderID string, opts ...RequestOption) (*FileDownload, error)

DownloadPDF — Get an order as a PDF file.

Returns an order the caller can see; one outside its tag scope, deleted or unknown is a 404. As JSON by default; with Accept: application/pdf, its PDF (the order form Myle sends).

GET /organizations/{id}/orders/{orderId} · requires one of ORDER_LIST, QUOTATION_LIST, INVOICES_CREATE, with Accept: application/pdf.

It answers a *FileDownload: the bytes as received (Data, never decoded), Filename (from Content-Disposition, "" when none), ContentType and the Response; Save(path) writes it. An error answer is JSON as for any call, returned as the type of its code.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
file, err := org.Orders.DownloadPDF(ctx, "order_…")
if err != nil {
	return err
}
if err := file.Save(cmp.Or(file.Filename, "order.pdf")); err != nil {
	return err
}

func (*OrdersService) Edit

func (s *OrdersService) Edit(ctx context.Context, orderID string, params *OrderEditParams, opts ...RequestOption) (*Order, error)

Edit — Change an order's lines, customer, delivery address or description.

Changes what an order holds, as « Modifier » in the web app: its lines (the whole list: add, change, remove and reorder them in one write), its customer, its delivery address, its description; an absent member is unchanged. Only while it is VALIDATED and has not left the organization — not mailed (the creation mails it when the customer has an address marked « Commande »), shared by a link, marked shared, converted, nor a Boutique order (GET …/editability says; 409 orders.order.not-editable otherwise). An order made from a quotation keeps its customer (reason FROM_QUOTATION). The write replays the creation: the price customization guard (a line kept as it was keeps its price), the tenant and tag scope guards, a new customer's recipient and legal details, a delivery address of the customer's. Without lines, the stored lines are kept as they are. For a new customer, with lines or without, a line kept as it was at the previous customer's tariff takes the new customer's (a line at another price keeps it). A body that changes nothing writes nothing. With If-Match, refused (412) if the order changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/edit · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the order, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderNotEditableError (409 orders.order.not-editable): The order has left the organization (mailed, shared by a link, marked shared), was converted, comes from the Boutique or is no longer VALIDATED: its lines, customer and description are kept as the customer saw them. Or its customer cannot change: it was made from a quotation that customer accepted. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *OrderOrderForeignProductError (422 orders.order.foreign-product): A line names a product of another organization: nothing was written.
  • *OrderOrderOutOfScopeReferenceError (422 orders.order.out-of-scope-reference): The order references a customer or products outside the caller's tag scope: nothing was written.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Edit(ctx, "order_…", &myle.OrderEditParams{CompanyID: myle.String("company_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f")})
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) Get

func (s *OrdersService) Get(ctx context.Context, orderID string, opts ...RequestOption) (*Order, error)

Get — Get an order.

Returns an order the caller can see; one outside its tag scope, deleted or unknown is a 404. As JSON by default; with Accept: application/pdf, its PDF (the order form Myle sends).

The file answers have their own method: OrdersService.DownloadPDF.

GET /organizations/{id}/orders/{orderId} · requires one of ORDER_LIST, QUOTATION_LIST, INVOICES_CREATE.

It answers the order. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Get(ctx, "order_…")
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) GetEditability

func (s *OrdersService) GetEditability(ctx context.Context, orderID string, opts ...RequestOption) (*OrderEditability, error)

GetEditability — Tell whether an order can still be changed.

Answers whether POST …/edit can still change the lines, the customer and the description of this order: editable while it is VALIDATED and has not left the organization; otherwise the reason. The rule POST …/edit replays under the order's lock.

GET /organizations/{id}/orders/{orderId}/editability · requires one of ORDER_PATCH, QUOTATION_PATCH.

It answers whether the order can be changed.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
orderEditability, err := org.Orders.GetEditability(ctx, "order_…")
if err != nil {
	return err
}
fmt.Println(orderEditability)

func (*OrdersService) GetEligibility

func (s *OrdersService) GetEligibility(ctx context.Context, params *OrderGetEligibilityParams, opts ...RequestOption) (*OrderEligibility, error)

GetEligibility — Count what each batch would act on.

Among the orders the filters give (the list's filters: the caller's orders, inside its tag scope, deleted ones never), how many each batch would act on: the counts the web app shows on its batch buttons before a batch.

GET /organizations/{id}/orders/eligibility · requires ORDER_LIST.

It answers the counts.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
orderEligibility, err := org.Orders.GetEligibility(ctx, nil)
if err != nil {
	return err
}
fmt.Println(orderEligibility)

func (*OrdersService) GetNeighbors

func (s *OrdersService) GetNeighbors(ctx context.Context, orderID string, params *OrderGetNeighborsParams, opts ...RequestOption) (*OrderNeighbors, error)

GetNeighbors — Get an order's neighbors in the list.

Returns the orders right before and right after this one in the order list read with the same filters and sort (the list's query parameters, without limit, cursor and includeTotal): next is the first order of the page that follows a page ending on this one, previous the one before it in that order. Each is null at an end of the list, and both are null when the filters leave the order out of it. The order must be one the caller can see (404 otherwise); its tag scope and the list's assignment rule apply to the neighbors too.

GET /organizations/{id}/orders/{orderId}/neighbors · requires one of ORDER_LIST, QUOTATION_LIST.

It answers the order's neighbors.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
orderNeighbors, err := org.Orders.GetNeighbors(ctx, "order_…", nil)
if err != nil {
	return err
}
fmt.Println(orderNeighbors)

func (*OrdersService) GetStockAvailability

func (s *OrdersService) GetStockAvailability(ctx context.Context, orderID string, opts ...RequestOption) *Paginator[LineStockAvailability]

GetStockAvailability — List the stocks an order's goods can leave from.

For each line of an APPROVED or WAITING_FOR_DELIVERY order, the stocks of its product and, per stock, the lots that can still give goods (after reconciliation: a lot whose goods left without a number is no longer offered) and what it holds without a lot: what to choose the lots of POST …/deliver and POST …/invoice from. Another status: 409. All at once: nextCursor is never present.

GET /organizations/{id}/orders/{orderId}/stock-availability · requires DELIVERYFORMS_CREATE.

It answers a *Paginator over a single page (the order's lines and their stocks). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.

Example:

org := client.Organization("organization_…")
for lineStockAvailability, err := range org.Orders.GetStockAvailability(ctx, "order_…").All() {
	if err != nil {
		return err
	}
	fmt.Println(lineStockAvailability)
}

func (*OrdersService) Invoice

func (s *OrdersService) Invoice(ctx context.Context, orderID string, params *OrderInvoiceParams, opts ...RequestOption) (*Invoice, error)

Invoice — Bill an order.

Turns a WAITING_FOR_DELIVERY order into an invoice, as « Facturer » in the web app: a VALIDATED invoice at once, with its legal number (the organization's sequence, without gaps) and today's date, its lines and tags taken from the order (and the customer's discount), linked both ways (the order lists it in invoiceIds); the order becomes INVOICED. lots: the stock lots the goods leave from, each naming its order line (lineIndex), its stock and lot number, and its quantity; several per line make one line each on the document, a line without lots is taken as ordered, and the stock movements are written. A lot's stock is one of its line's product (another: 422 on its stockId). Without lots, no stock moves. On an invoice, a line is billed whole: its lots, one or several, add up to exactly what it ordered (422 on their quantity). Then, as from the web app, the invoice is sent the way the customer's settings say and booked. The same caller asking again gets the same invoice (409 when that invoice was deleted since); billed by someone else, 409. An order with deposit invoices is settled by its final invoice (409); a Boutique order paid by card is billed at its capture (409). Counts in the plan's invoices per month (402 once reached). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/invoice · requires ORDER_TRANSFORM_TO_INVOICE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the invoice it made. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.
  • *OrderOrderAlreadyInvoicedError (409 orders.order.already-invoiced): Another member or key billed this order already (the caller's own billing is answered again), or the caller's own billing made an invoice deleted since. Nothing was created.
  • *OrderOrderHasDepositsError (409 orders.order.has-deposits): The order is billed in several times: deposit invoices were issued on it (or on the quotation it was made from), and its final invoice, which deducts them, settles it; a whole invoice would bill them twice. Nothing was created.
  • *OrderOrderShopBilledError (409 orders.order.shop-billed): The order was placed and paid by card on the organization's Boutique: its invoice is issued when the card is charged, at the amount really charged; converting it here would bill it twice. Nothing was created.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Orders.Invoice(ctx, "order_…", nil)
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*OrdersService) List

func (s *OrdersService) List(ctx context.Context, params *OrderListParams, opts ...RequestOption) *Paginator[Order]

List — List the orders.

Returns the organization's orders the caller can see (its tag scope applies), deleted ones never, filtered and sorted, one page at a time. For a synchronization: updatedAfter with the largest updatedAt already seen, sort updatedAt. Open to ORDER_LIST, QUOTATION_LIST and INVOICES_CREATE, as the web app. A member without ORDER_LIST_ALL reads the orders they created, prepare or deliver (an organization key's robot likewise), as in the web app.

GET /organizations/{id}/orders · requires one of ORDER_LIST, QUOTATION_LIST, INVOICES_CREATE.

It answers a *Paginator (a page of orders): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
for order, err := range org.Orders.List(ctx, &myle.OrderListParams{Status: []myle.OrderStatus{myle.OrderStatusApproved}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(order.ID)
}

func (*OrdersService) ListTags

func (s *OrdersService) ListTags(ctx context.Context, opts ...RequestOption) *Paginator[string]

ListTags — List the orders' tags.

Returns the tags the organization's orders carry, sorted: the values a tag filter of the order list can take. For a tag-scoped caller, only the tags of the orders in its scope. All of them at once: nextCursor is never present.

GET /organizations/{id}/orders/tags · requires one of ORDER_LIST, QUOTATION_LIST, INVOICES_CREATE.

It answers a *Paginator over a single page (the tags, sorted). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for tag, err := range org.Orders.ListTags(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(tag)
}

func (*OrdersService) MarkWaitingForDelivery

func (s *OrdersService) MarkWaitingForDelivery(ctx context.Context, orderID string, opts ...RequestOption) (*Order, error)

MarkWaitingForDelivery — Mark an order as prepared, waiting for its delivery.

Records that the order is prepared, as « Attente de livraison » in the web app: an APPROVED order becomes WAITING_FOR_DELIVERY, the status POST …/deliver and POST …/invoice take. One WAITING_FOR_DELIVERY already is answered as it is. The change is audited. With If-Match, refused (412) if the order changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/mark-waiting-for-delivery · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the order, waiting for its delivery. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.MarkWaitingForDelivery(ctx, "order_…")
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) Send

func (s *OrdersService) Send(ctx context.Context, orderID string, params *OrderSendParams, opts ...RequestOption) *Paginator[ItemResult]

Send — Send an order by e-mail.

Sends an order form to some of its customer's e-mail addresses, by their ids, as from the web app: the PDF attached, with the organization's letter, logged and counted in its monthly e-mail quota. Nothing changes its status (POST …/share does). Synchronous: the answer is the result per recipient, in the order sent (SUCCEEDED, or FAILED with its error: orders.order.recipient-unsubscribed for an address that unsubscribed, core.plan-limit-reached when the quota ran out on the way, core.internal-error when the mail could not go). Refused as a whole, sending nothing: an id that is not one of the customer's addresses (422), a quota short of the recipients (402 core.plan-limit-reached, limit emailsPerMonth). Send an Idempotency-Key to retry safely: without it, a retry sends again.

POST /organizations/{id}/orders/{orderId}/send · requires ORDER_SEND_EMAIL.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per recipient). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Orders.Send(ctx, "order_…", &myle.OrderSendParams{To: []string{"to"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*OrdersService) Share

func (s *OrdersService) Share(ctx context.Context, orderID string, opts ...RequestOption) (*Order, error)

Share — Mark an order as handed to its customer.

Declares that the customer has the order form — handed over, sent by your own e-mail or shop, by any channel —, as « Partager » in the web app: a VALIDATED order becomes SHARED. Nothing is sent (POST …/send mails it). An order SHARED already is answered as it is. The change is audited. With If-Match, refused (412) if the order changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/orders/{orderId}/share · requires one of ORDER_PATCH, QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the order, shared. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *OrderOrderTransitionRefusedError (409 orders.order.transition-refused): The order's status does not lead to the one asked: an order is shared while VALIDATED, approved while VALIDATED or SHARED, marked waiting for delivery while APPROVED, delivered and billed while WAITING_FOR_DELIVERY, and cancelled until it is delivered. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Share(ctx, "order_…")
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*OrdersService) Update

func (s *OrdersService) Update(ctx context.Context, orderID string, params *OrderUpdateParams, opts ...RequestOption) (*Order, error)

Update — Change an order.

Changes the members sent (a JSON merge patch): its date, its delivery date, who prepares and delivers it (members of the organization: 422 otherwise), its description, its tags, whatever its status (as the web app does). Its lines, customer and delivery address: POST …/edit. A patch that changes nothing writes nothing. With If-Match, refused (412) if the order changed since it was read.

PATCH /organizations/{id}/orders/{orderId} · requires one of ORDER_PATCH, QUOTATION_PATCH.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the order, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
order, err := org.Orders.Get(ctx, "order_…")
if err != nil {
	return err
}
updated, err := org.Orders.Update(ctx, "order_…", &myle.OrderUpdateParams{IssueDate: myle.String("2026-11-21")}, myle.IfMatch(order))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type Organization

type Organization struct {
	// The organization's id (organization_<uuid>).
	ID string `json:"id"`
	// Always "organization".
	Object string `json:"object"`
	// The organization's name.
	Name string `json:"name"`
	// Its SIREN (French company number), or null.
	Siren *string `json:"siren"`
	// Its intra-community VAT number, or null.
	VatNumber *string `json:"vatNumber"`
	// When the organization was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When the organization was last changed (RFC 3339, UTC).
	UpdatedAt string `json:"updatedAt"`
	// contains filtered or unexported fields
}

Organization — An organization: a farm, a company, an association using Myle.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Organization) ETag

func (m Organization) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Organization) LastResponse

func (m Organization) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type OrganizationScope

type OrganizationScope struct {
	// ID is the organization's id (organization_…).
	ID string
	// APIKeys — credentials for programs: user keys act as their owner, organization keys as their own robot
	// account, with Myle rights. Managed with a signed-in session only (/organizations/{id}/api-keys).
	APIKeys *APIKeysService
	// Products — the organization's catalog: the products and services it sells, with their prices and barcodes
	// (/organizations/{id}/products).
	Products *ProductsService
	// Companies — the organization's customers: businesses, consumers and foreign clients, with their addresses and
	// e-mail addresses (/organizations/{id}/companies).
	Companies *CompaniesService
	// Invoices — the organization's sales invoices: drafts, their validation (the legal number), their PDF and
	// Factur-X (/organizations/{id}/invoices).
	Invoices *InvoicesService
	// Quotations — the organization's quotations: the offers it makes its customers, sent, accepted or refused,
	// extended, and billed as invoices (/organizations/{id}/quotations).
	Quotations *QuotationsService
	// Orders — the organization's orders: what its customers order, confirmed, prepared, delivered (with the stock
	// lots the goods leave from) and billed (/organizations/{id}/orders).
	Orders *OrdersService
	// DeliveryNotes — the organization's delivery notes: the goods handed to a customer, with the lots they left
	// from (/organizations/{id}/delivery-notes).
	DeliveryNotes *DeliveryNotesService
	// Einvoicing — e-invoicing through the organization's approved platform (SuperPDP): its connection and address,
	// a customer's routing, the e-invoice of an invoice, and the e-invoices suppliers send
	// (/organizations/{id}/einvoicing).
	Einvoicing *EinvoicingResourceService
	// Einvoices — e-invoicing through the organization's approved platform (SuperPDP): its connection and address,
	// a customer's routing, the e-invoice of an invoice, and the e-invoices suppliers send
	// (/organizations/{id}/einvoices).
	Einvoices *EinvoicesService
	// IncomingEinvoices — e-invoicing through the organization's approved platform (SuperPDP): its connection and
	// address, a customer's routing, the e-invoice of an invoice, and the e-invoices suppliers send
	// (/organizations/{id}/incoming-einvoices).
	IncomingEinvoices *IncomingEinvoicesService
	// PaymentsAccount — the organization's Stripe account, its customers' SEPA mandates, the debit and the refund
	// of an invoice, its payment status (/organizations/{id}/payments-account).
	PaymentsAccount *PaymentsAccountResourceService
	// contains filtered or unexported fields
}

OrganizationScope — an organization the caller is a member of (or the one of an organization key): every resource under /organizations/{id}.

Reach it as client.Organization("organization_…"): no request is made until you call a method.

func (*OrganizationScope) Get

Get — Get an organization.

Returns an organization the caller is a member of. An organization that does not exist and one the caller is not a member of get the same 404.

GET /organizations/{id}.

It answers the organization.

Errors worth handling (errors.As):

  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
organization, err := org.Get(ctx)
if err != nil {
	return err
}
fmt.Println(organization.Name)

type OutgoingEinvoiceFailure

type OutgoingEinvoiceFailure struct {
	// outgoingEinvoiceFailure.
	Object string `json:"object"`
	// The invoice (invoice_<uuid>).
	InvoiceID *string `json:"invoiceId"`
	// Its number, or null.
	InvoiceNumber *string `json:"invoiceNumber"`
	// The invoice's status (VALIDATED, UNPAID…), or null.
	InvoiceStatus *string `json:"invoiceStatus"`
	// The customer (company_<uuid>), or null.
	CompanyID *string `json:"companyId"`
	// The customer's name, or null.
	CompanyName *string `json:"companyName"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	Total *Money `json:"total"`
	// SUBMISSION_FAILED or REJECTED.
	Status string `json:"status"`
	// Why the last submission failed, read.
	Failure *EinvoiceFailure `json:"failure"`
	// An automatic retry is about to submit it again.
	IsAutoRetryPending bool `json:"isAutoRetryPending"`
	// The e-mail is open again: the PDF may go as on a customer off the network.
	IsMailAllowed bool `json:"isMailAllowed"`
	// The caller may dismiss it (the invoice reached the customer off the network).
	IsDismissible bool `json:"isDismissible"`
	// When it failed.
	FailedAt string `json:"failedAt"`
}

OutgoingEinvoiceFailure — A submission that failed and waits for an action: the invoice (its total, or null), the failure read (or null).

type Page

type Page[T any] struct {
	// Data holds the items of this page.
	Data []T
	// NextCursor is the cursor of the next page, "" on the last one.
	NextCursor string
	// contains filtered or unexported fields
}

Page is one page of a list.

func (*Page[T]) HasMore

func (p *Page[T]) HasMore() bool

HasMore tells whether another page follows.

func (*Page[T]) LastResponse

func (p *Page[T]) LastResponse() *Response

LastResponse answers the HTTP response of this page.

func (*Page[T]) NextPage

func (p *Page[T]) NextPage() (*Page[T], error)

NextPage fetches the next page; it answers nil, nil after the last one.

type Paginator

type Paginator[T any] struct {
	// contains filtered or unexported fields
}

Paginator is the items of a list, fetched a page at a time as you iterate. Nothing is sent until you iterate or ask for a page; the context given to the list method bounds every page.

for product, err := range org.Products.List(ctx, &myle.ProductListParams{Status: []myle.ProductStatus{myle.ProductStatusActive}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(product.Name)
}

func (*Paginator[T]) All

func (l *Paginator[T]) All() iter.Seq2[T, error]

All iterates over every item, across pages; an error ends the iteration after it is yielded (with a zero item).

func (*Paginator[T]) Collect

func (l *Paginator[T]) Collect() ([]T, error)

Collect answers every item, across pages.

func (*Paginator[T]) CollectMax

func (l *Paginator[T]) CollectMax(max int) ([]T, error)

CollectMax answers the first max items, fetching no more pages than needed (none when max <= 0).

func (*Paginator[T]) FirstPage

func (l *Paginator[T]) FirstPage() (*Page[T], error)

FirstPage fetches the first page (the one at the params' cursor, when given).

func (*Paginator[T]) Pages

func (l *Paginator[T]) Pages() iter.Seq2[*Page[T], error]

Pages iterates over the pages, one after the other; an error ends the iteration after it is yielded.

type PayloadTooLargeError

type PayloadTooLargeError struct{ *APIError }

PayloadTooLargeError is a 413: the body is too large.

func (*PayloadTooLargeError) Unwrap

func (e *PayloadTooLargeError) Unwrap() error

Unwrap answers the *APIError.

type Payment

type Payment struct {
	// The payment's id (payment_<uuid>).
	ID string `json:"id"`
	// Always "payment".
	Object string `json:"object"`
	// The invoice it pays (invoice_<uuid>).
	InvoiceID string `json:"invoiceId"`
	// What was paid, in EUR (on a credit note, what was refunded).
	Amount Money `json:"amount"`
	// How it was paid: CASH, CHECK, TRANSFER, CARD, SEPA_DIRECT_DEBIT, PAYPAL, OTHER. An open enum: tolerate a
	// value you do not know.
	Method PaymentMethod `json:"method"`
	// The organization's own name for the method (« Lydia »), or null.
	MethodLabel *string `json:"methodLabel"`
	// When it was paid (YYYY-MM-DD), or null when not said.
	PaidAt *string `json:"paidAt"`
	// Its reference (a cheque number, a transfer's label), or null.
	Reference *string `json:"reference"`
	// When it was recorded (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// contains filtered or unexported fields
}

Payment — A payment recorded on an invoice. amount: what was paid, in EUR (on a credit note, what was refunded).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Payment) ETag

func (m Payment) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Payment) LastResponse

func (m Payment) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type PaymentAccountDemoError

type PaymentAccountDemoError struct {
	*ConflictError
}

PaymentAccountDemoError is the error code payments.account.demo (409): A demo organization never reaches Stripe: nothing was done.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentAccountDemoError) Unwrap

func (e *PaymentAccountDemoError) Unwrap() error

Unwrap answers the *ConflictError it is.

type PaymentAccountNotConnectedError

type PaymentAccountNotConnectedError struct {
	*ConflictError
}

PaymentAccountNotConnectedError is the error code payments.account.not-connected (409): No Stripe account is connected to the organization: connect one first (POST …/payments-account/onboarding).

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentAccountNotConnectedError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentAccountSuspendedError

type PaymentAccountSuspendedError struct {
	*ConflictError
}

PaymentAccountSuspendedError is the error code payments.account.suspended (409): Stripe suspended the organization's account: debits are blocked until it is settled in the Stripe dashboard.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentAccountSuspendedError) Unwrap

func (e *PaymentAccountSuspendedError) Unwrap() error

Unwrap answers the *ConflictError it is.

type PaymentCollectionDisabledError

type PaymentCollectionDisabledError struct {
	*ConflictError
}

PaymentCollectionDisabledError is the error code payments.collection.disabled (409): The organization turned its Stripe collection off (in its payment settings): nothing is debited, no mandate is offered, no auto-debit is turned on until it turns it back on.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentCollectionDisabledError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentCollectionPausedContext

type PaymentCollectionPausedContext struct {
	// Why: NO_SUBSCRIPTION or PAYMENT_OVERDUE.
	Reason string `json:"reason"`
}

PaymentCollectionPausedContext — The detail of this error.

The context of an error code.

type PaymentCollectionPausedError

type PaymentCollectionPausedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context PaymentCollectionPausedContext
}

PaymentCollectionPausedError is the error code payments.collection.paused (409): The organization's Stripe collection is paused because it no longer pays for Myle: it resumes with its subscription.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentCollectionPausedError) Unwrap

func (e *PaymentCollectionPausedError) Unwrap() error

Unwrap answers the *ConflictError it is.

type PaymentDebitAboveMaximumContext

type PaymentDebitAboveMaximumContext struct {
	// The largest debit, a decimal amount in EUR.
	Maximum string `json:"maximum"`
}

PaymentDebitAboveMaximumContext — The detail of this error.

The context of an error code.

type PaymentDebitAboveMaximumError

type PaymentDebitAboveMaximumError struct {
	*ConflictError
	// Context is the detail of the error.
	Context PaymentDebitAboveMaximumContext
}

PaymentDebitAboveMaximumError is the error code payments.debit.above-maximum (409): What remains due is above the largest SEPA debit: nothing was debited.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentDebitAboveMaximumError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentDebitBelowMinimumContext

type PaymentDebitBelowMinimumContext struct {
	// The smallest debit, a decimal amount in EUR ("20.00").
	Minimum string `json:"minimum"`
}

PaymentDebitBelowMinimumContext — The detail of this error.

The context of an error code.

type PaymentDebitBelowMinimumError

type PaymentDebitBelowMinimumError struct {
	*ConflictError
	// Context is the detail of the error.
	Context PaymentDebitBelowMinimumContext
}

PaymentDebitBelowMinimumError is the error code payments.debit.below-minimum (409): What remains due is below the smallest SEPA debit: nothing was debited.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentDebitBelowMinimumError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentDebitNotDebitableContext

type PaymentDebitNotDebitableContext struct {
	// The invoice's status (DRAFT, PAID, SEPA_PENDING…).
	Status string `json:"status"`
}

PaymentDebitNotDebitableContext — The detail of this error.

The context of an error code.

type PaymentDebitNotDebitableError

type PaymentDebitNotDebitableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context PaymentDebitNotDebitableContext
}

PaymentDebitNotDebitableError is the error code payments.debit.not-debitable (409): The invoice's status takes no debit: a draft, a paid one, a debit already in progress (SEPA_PENDING), a dispute or a refusal on the e-invoicing network. Nothing was debited.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentDebitNotDebitableError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentDebitNothingDueError

type PaymentDebitNothingDueError struct {
	*ConflictError
}

PaymentDebitNothingDueError is the error code payments.debit.nothing-due (409): Nothing remains due on the invoice: nothing was debited.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentDebitNothingDueError) Unwrap

func (e *PaymentDebitNothingDueError) Unwrap() error

Unwrap answers the *ConflictError it is.

type PaymentDebitQuotaReachedContext

type PaymentDebitQuotaReachedContext struct {
	// Whose quota: company or organization.
	Scope string `json:"scope"`
	// What is counted: count or amount.
	Measure string `json:"measure"`
	// The quota: a number of debits, or a decimal amount in EUR.
	Limit string `json:"limit"`
	// What the window holds already, in the same unit.
	Current string `json:"current"`
	// The rolling window, in days.
	WindowDays int64 `json:"windowDays"`
}

PaymentDebitQuotaReachedContext — The detail of this error.

The context of an error code.

type PaymentDebitQuotaReachedError

type PaymentDebitQuotaReachedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context PaymentDebitQuotaReachedContext
}

PaymentDebitQuotaReachedError is the error code payments.debit.quota-reached (409): The organization's SEPA quota over the rolling window is reached, for this customer or for the whole organization: nothing was debited (GET …/payments-account/sepa-quota tells what remains).

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentDebitQuotaReachedError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentMandateForeignIbanError

type PaymentMandateForeignIbanError struct {
	*ConflictError
}

PaymentMandateForeignIbanError is the error code payments.mandate.foreign-iban (409): The customer's mandate is on a bank account outside France: only French IBANs are debited.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentMandateForeignIbanError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentMandateInvitationsThrottledError

type PaymentMandateInvitationsThrottledError struct {
	*RateLimitError
}

PaymentMandateInvitationsThrottledError is the error code payments.mandate.invitations-throttled (429): Too many mandate invitations in a row, by this caller or to this customer: retry in an hour.

It wraps *RateLimitError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentMandateInvitationsThrottledError) Unwrap

Unwrap answers the *RateLimitError it is.

type PaymentMandateMissingError

type PaymentMandateMissingError struct {
	*ConflictError
}

PaymentMandateMissingError is the error code payments.mandate.missing (409): The customer has no usable SEPA mandate: send them a mandate invitation (POST …/sepa-mandate/invitation).

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentMandateMissingError) Unwrap

func (e *PaymentMandateMissingError) Unwrap() error

Unwrap answers the *ConflictError it is.

type PaymentMethod

type PaymentMethod string

PaymentMethod is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: CASH, CHECK, TRANSFER, CARD, SEPA_DIRECT_DEBIT, PAYPAL, OTHER.

const PaymentMethodCard PaymentMethod = "CARD"

PaymentMethodCard is "CARD".

const PaymentMethodCash PaymentMethod = "CASH"

PaymentMethodCash is "CASH".

const PaymentMethodCheck PaymentMethod = "CHECK"

PaymentMethodCheck is "CHECK".

const PaymentMethodOther PaymentMethod = "OTHER"

PaymentMethodOther is "OTHER".

const PaymentMethodPaypal PaymentMethod = "PAYPAL"

PaymentMethodPaypal is "PAYPAL".

const PaymentMethodSepaDirectDebit PaymentMethod = "SEPA_DIRECT_DEBIT"

PaymentMethodSepaDirectDebit is "SEPA_DIRECT_DEBIT".

const PaymentMethodTransfer PaymentMethod = "TRANSFER"

PaymentMethodTransfer is "TRANSFER".

type PaymentPlanCollectionRequiredError

type PaymentPlanCollectionRequiredError struct {
	*PaymentRequiredError
}

PaymentPlanCollectionRequiredError is the error code payments.plan.collection-required (402): The organization's plan does not carry Stripe collection (SEPA debits, mandates, auto-debit, online payment of invoices); the trial does not either. It comes with a paid plan.

It wraps *PaymentRequiredError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentPlanCollectionRequiredError) Unwrap

Unwrap answers the *PaymentRequiredError it is.

type PaymentRefundNothingToRefundError

type PaymentRefundNothingToRefundError struct {
	*ConflictError
}

PaymentRefundNothingToRefundError is the error code payments.refund.nothing-to-refund (409): No payment of the invoice was collected through Stripe: there is nothing to refund there.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*PaymentRefundNothingToRefundError) Unwrap

Unwrap answers the *ConflictError it is.

type PaymentRequiredError

type PaymentRequiredError struct{ *APIError }

PaymentRequiredError is a 402: the organization's plan lacks a module, a subscription or room under a limit.

func (*PaymentRequiredError) Unwrap

func (e *PaymentRequiredError) Unwrap() error

Unwrap answers the *APIError.

type PaymentStatus

type PaymentStatus struct {
	// Always "paymentStatus".
	Object string `json:"object"`
	// The invoice (invoice_<uuid>).
	InvoiceID string `json:"invoiceId"`
	// The invoice's status (UNPAID, SEPA_PENDING while a debit is on its way, PAID, SEPA_FAILED, SEPA_DISPUTED…),
	// as the invoice's own status says it; an open enum.
	Status string `json:"status"`
	// When it moved to that status (RFC 3339, UTC).
	StatusChangedAt string `json:"statusChangedAt"`
	// Why the last debit failed or was disputed: the bank's code (a SEPA reason), or null.
	FailureCode *string `json:"failureCode"`
	// The bank's explanation, or null.
	FailureMessage *string `json:"failureMessage"`
	// What it asks (incl.
	Total Money `json:"total"`
	// What its payments add up to.
	Paid Money `json:"paid"`
	// What remains.
	AmountDue Money `json:"amountDue"`
	// The payments recorded on the invoice, newest first (a debit appears here once Stripe settled it).
	Payments []Payment `json:"payments"`
	// Its last SEPA debit, null when none was started (EUR).
	LastDebit *DebitFee `json:"lastDebit"`
	// contains filtered or unexported fields
}

PaymentStatus — An invoice's payment status. total: what it asks (incl. VAT); paid: what its payments add up to; amountDue: what remains; lastDebit: its last SEPA debit, null when none was started (EUR).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (PaymentStatus) ETag

func (m PaymentStatus) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (PaymentStatus) LastResponse

func (m PaymentStatus) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type PaymentsAccount

type PaymentsAccount struct {
	// Always "paymentsAccount".
	Object string `json:"object"`
	// A Stripe account is connected to the organization.
	IsConnected bool `json:"isConnected"`
	// Stripe lets the account take payments; null when none is connected.
	ChargesEnabled *bool `json:"chargesEnabled"`
	// Stripe pays the account out to its bank; null when none is connected.
	PayoutsEnabled *bool `json:"payoutsEnabled"`
	// The onboarding's details were all given to Stripe; null when none is connected.
	DetailsSubmitted *bool `json:"detailsSubmitted"`
	// The collection's state, null when no account is connected.
	Collection *PaymentsCollection `json:"collection"`
	// When Stripe closed the account for want of a subscription (connect again), else null.
	ClosedAt *string `json:"closedAt"`
	// contains filtered or unexported fields
}

PaymentsAccount — The organization's Stripe Connect account. collection: the collection's state, null when no account is connected.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (PaymentsAccount) ETag

func (m PaymentsAccount) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (PaymentsAccount) LastResponse

func (m PaymentsAccount) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type PaymentsAccountResourceListSepaFeesParams

type PaymentsAccountResourceListSepaFeesParams struct {
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
}

PaymentsAccountResourceListSepaFeesParams is the parameters of PaymentsAccountResourceService.ListSepaFees (listSepaFees): its query parameters. A nil *PaymentsAccountResourceListSepaFeesParams sends none.

type PaymentsAccountResourceReplaceOnlinePaymentSettingParams

type PaymentsAccountResourceReplaceOnlinePaymentSettingParams struct {
	// On (true) or off (false).
	IsEnabled bool `json:"isEnabled"`
}

PaymentsAccountResourceReplaceOnlinePaymentSettingParams is the parameters of PaymentsAccountResourceService.ReplaceOnlinePaymentSetting (replaceOnlinePaymentSetting): its body's members. A nil *PaymentsAccountResourceReplaceOnlinePaymentSettingParams sends none.

The online payment of invoices, on or off.

A member of type Opt is left out unless set.

func (PaymentsAccountResourceReplaceOnlinePaymentSettingParams) MarshalJSON

MarshalJSON writes the body: the members given, in the document's order.

type PaymentsAccountResourceService

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

PaymentsAccountResourceService — the organization's Stripe account, its customers' SEPA mandates, the debit and the refund of an invoice, its payment status (/organizations/{id}/payments-account).

Reach it as client.Organization("organization_…").PaymentsAccount.

func (s *PaymentsAccountResourceService) CreateDashboardLink(ctx context.Context, opts ...RequestOption) (*HostedLink, error)

CreateDashboardLink — Open the Stripe dashboard.

Answers a link to the account's Stripe Express dashboard (payouts, disputes, bank details), signed in, which the user opens in a browser; it expires within minutes and works once. A signed-in session only, with a passkey step-up (paymentsAccount.dashboardLink): an API key gets 403. Open to a read-only organization.

POST /organizations/{id}/payments-account/dashboard-link · requires STRIPE_CONNECT_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers stripe's dashboard.

Errors worth handling (errors.As):

  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *PaymentAccountNotConnectedError (409 payments.account.not-connected): No Stripe account is connected to the organization: connect one first (POST …/payments-account/onboarding).
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
hostedLink, err := org.PaymentsAccount.CreateDashboardLink(ctx)
if err != nil {
	return err
}
fmt.Println(hostedLink)

func (*PaymentsAccountResourceService) Get

Get — Get the organization's Stripe account.

Returns the organization's Stripe Connect account: whether one is connected, what Stripe lets it do (take payments, pay out), whether its onboarding is complete, and the state of its collection (turned off by the organization, or paused because it no longer pays for Myle). Stripe is read each time.

GET /organizations/{id}/payments-account · requires STRIPE_CONNECT_MANAGE.

It answers the account.

Errors worth handling (errors.As):

  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
paymentsAccount, err := org.PaymentsAccount.Get(ctx)
if err != nil {
	return err
}
fmt.Println(paymentsAccount)

func (*PaymentsAccountResourceService) GetOnlinePaymentSetting

func (s *PaymentsAccountResourceService) GetOnlinePaymentSetting(ctx context.Context, opts ...RequestOption) (*OnlinePaymentSetting, error)

GetOnlinePaymentSetting — Get the online payment of invoices.

Returns whether the organization's invoices can be paid online (a « Pay » button on their public page, through Stripe), and what that needs: the setting, a connected account taking payments, a plan carrying Stripe collection, the collection neither off nor paused.

GET /organizations/{id}/payments-account/online-payment · requires STRIPE_CONNECT_MANAGE.

It answers the setting.

Errors worth handling (errors.As):

  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
onlinePaymentSetting, err := org.PaymentsAccount.GetOnlinePaymentSetting(ctx)
if err != nil {
	return err
}
fmt.Println(onlinePaymentSetting)

func (*PaymentsAccountResourceService) GetSepaQuota

func (s *PaymentsAccountResourceService) GetSepaQuota(ctx context.Context, opts ...RequestOption) (*SepaQuota, error)

GetSepaQuota — Get the SEPA quota.

Returns the organization's SEPA quota over the rolling window (per customer and for the whole organization) and what it used, the bounds of one debit, what a debit costs, and what blocks every debit if anything does: read it before offering « Debit ».

GET /organizations/{id}/payments-account/sepa-quota · requires STRIPE_PAYMENTS_COLLECT.

It answers the quota.

Errors worth handling (errors.As):

  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
sepaQuota, err := org.PaymentsAccount.GetSepaQuota(ctx)
if err != nil {
	return err
}
fmt.Println(sepaQuota)

func (*PaymentsAccountResourceService) ListSepaFees

ListSepaFees — List the SEPA debits' fees.

Returns the fee of each SEPA debit the organization started (and Stripe's dispute fees), newest first, one page at a time: what was debited, what Stripe and Myle withheld, whether Myle invoiced its commission.

GET /organizations/{id}/payments-account/sepa-fees · requires STRIPE_PAYMENTS_COLLECT.

It answers a *Paginator (a page of fees): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for sepaFee, err := range org.PaymentsAccount.ListSepaFees(ctx, nil).All() {
	if err != nil {
		return err
	}
	fmt.Println(sepaFee)
}

func (*PaymentsAccountResourceService) ReplaceOnlinePaymentSetting

ReplaceOnlinePaymentSetting — Turn the online payment of invoices on or off.

Turns the online payment of the organization's invoices on or off, recorded in its history. Turning it on with a connected account whose plan does not carry Stripe collection is refused (402).

PUT /organizations/{id}/payments-account/online-payment · requires STRIPE_CONNECT_MANAGE.

It answers the setting, changed.

Errors worth handling (errors.As):

  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *PaymentPlanCollectionRequiredError (402 payments.plan.collection-required): The organization's plan does not carry Stripe collection (SEPA debits, mandates, auto-debit, online payment of invoices); the trial does not either. It comes with a paid plan.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
onlinePaymentSetting, err := org.PaymentsAccount.ReplaceOnlinePaymentSetting(ctx, &myle.PaymentsAccountResourceReplaceOnlinePaymentSettingParams{IsEnabled: true})
if err != nil {
	return err
}
fmt.Println(onlinePaymentSetting)

func (*PaymentsAccountResourceService) StartOnboarding

StartOnboarding — Start or resume the Stripe onboarding.

Answers the link of Stripe's onboarding, which the user opens in a browser: Stripe checks the organization's identity and bank details on its own pages (Myle never sees an identity document), then sends the user to returnUrl. Without an account, one is created first (never for a demo organization). The link expires within minutes and works once: ask a new one at refreshUrl. A signed-in session only, with a passkey step-up (paymentsAccount.onboarding): an API key gets 403.

POST /organizations/{id}/payments-account/onboarding · requires STRIPE_CONNECT_MANAGE · a signed-in session only: API keys get 403 auth.session.required.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers stripe's onboarding page.

Errors worth handling (errors.As):

  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthSessionRequiredError (403 auth.session.required): This operation accepts a signed-in session only, never an API key (keys, members, passwords, billing…).
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *AuthStepUpRequiredError (403 auth.step-up.required): This operation needs a fresh passkey proof (a WebAuthn step-up) for this action.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *PaymentAccountDemoError (409 payments.account.demo): A demo organization never reaches Stripe: nothing was done.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *CoreBadGatewayError (502 core.bad-gateway): A service Myle depends on refused the operation.

Example:

org := client.Organization("organization_…")
hostedLink, err := org.PaymentsAccount.StartOnboarding(ctx, &myle.PaymentsAccountResourceStartOnboardingParams{ReturnURL: "returnUrl", RefreshURL: "refreshUrl"})
if err != nil {
	return err
}
fmt.Println(hostedLink)

type PaymentsAccountResourceStartOnboardingParams

type PaymentsAccountResourceStartOnboardingParams struct {
	// The page Stripe returns to when the user leaves the onboarding (an absolute http(s) URL).
	ReturnURL string `json:"returnUrl"`
	// The page Stripe sends to when the link expired or was used: ask a new link there (http(s) URL).
	RefreshURL string `json:"refreshUrl"`
}

PaymentsAccountResourceStartOnboardingParams is the parameters of PaymentsAccountResourceService.StartOnboarding (startPaymentsAccountOnboarding): its body's members. A nil *PaymentsAccountResourceStartOnboardingParams sends none.

Where Stripe sends the user back once the onboarding is done, and when its link has expired.

A member of type Opt is left out unless set.

func (PaymentsAccountResourceStartOnboardingParams) MarshalJSON

MarshalJSON writes the body: the members given, in the document's order.

type PaymentsCollection

type PaymentsCollection struct {
	// The organization turned its Stripe collection off (its payment settings): nothing is debited.
	IsDisabled bool `json:"isDisabled"`
	// When it turned it off (RFC 3339, UTC), or null.
	DisabledAt *string `json:"disabledAt"`
	// The collection is paused because the organization no longer pays for Myle.
	IsPaused bool `json:"isPaused"`
	// Why it is paused: NO_SUBSCRIPTION, PAYMENT_OVERDUE (an open enum), or null.
	PauseReason *string `json:"pauseReason"`
	// While a payment of Myle is overdue but within its grace period: when the pause starts, else null.
	PausesAt *string `json:"pausesAt"`
}

PaymentsCollection — The collection of an organization whose Stripe account is connected.

type PermissionDeniedError

type PermissionDeniedError struct{ *APIError }

PermissionDeniedError is a 403: the caller may not do this (a right, a session-only operation…).

func (*PermissionDeniedError) Unwrap

func (e *PermissionDeniedError) Unwrap() error

Unwrap answers the *APIError.

type PostalAddress

type PostalAddress struct {
	// The address's id (postalAddress_<uuid>).
	ID string `json:"id"`
	// Always "postalAddress".
	Object string `json:"object"`
	// Its internal name (« Siège », « Hangar »), never printed on a document, or null.
	Label *string `json:"label"`
	// The line printed above the street when the recipient is not simply the company, or null.
	RecipientLine *string `json:"recipientLine"`
	// The street, as entered (it may hold several lines).
	Line1 string `json:"line1"`
	// The postal code, or null.
	PostalCode *string `json:"postalCode"`
	// The city, or null.
	City *string `json:"city"`
	// The SIRET of the establishment at this address, or null.
	Siret *string `json:"siret"`
	// What whoever delivers there needs to know (a door code, where to leave the goods), or null.
	DeliveryInstructions *string `json:"deliveryInstructions"`
	// Its own opening hours, the days with hours, Monday first (the company's shape), [] for none; null when it has
	// none of its own and the company's apply (a delivery reads its address's hours, else its company's).
	OpeningHours []OpeningHoursDay `json:"openingHours"`
	// Where it was located, for the routes.
	Geocode PostalAddressGeocode `json:"geocode"`
	// contains filtered or unexported fields
}

PostalAddress — A postal address of a company. openingHours: its own opening hours, the days with hours, Monday first (the company's shape), [] for none; null when it has none of its own and the company's apply (a delivery reads its address's hours, else its company's).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (PostalAddress) ETag

func (m PostalAddress) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (PostalAddress) LastResponse

func (m PostalAddress) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type PostalAddressGeocode

type PostalAddressGeocode struct {
	// EXACT (the house number), STREET, CITY (the city's center only: too rough for a route), FAILED (the geocoder
	// knows no such address: correct it), PENDING (not located yet: it will be). An open enum: tolerate a value you
	// do not know.
	Status string `json:"status"`
	// Its latitude (WGS 84), or null.
	Latitude *float64 `json:"latitude"`
	// Its longitude (WGS 84), or null.
	Longitude *float64 `json:"longitude"`
	// When it was located (RFC 3339, UTC), or null.
	GeocodedAt *string `json:"geocodedAt"`
}

PostalAddressGeocode — Where it was located, for the routes.

type PreconditionFailedError

type PreconditionFailedError struct{ *APIError }

PreconditionFailedError is a 412: the If-Match sent is stale: read the resource again, then retry with it.

func (*PreconditionFailedError) Unwrap

func (e *PreconditionFailedError) Unwrap() error

Unwrap answers the *APIError.

type Product

type Product struct {
	// The product's id (product_<uuid>).
	ID string `json:"id"`
	// Always "product".
	Object string `json:"object"`
	// The organization it belongs to (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// The product's reference in the catalog, unique among the organization's products (A0012).
	Number string `json:"number"`
	// The product's name.
	Name string `json:"name"`
	// ACTIVE. An open enum: tolerate a value you do not know. A deleted product is never returned (404).
	Status ProductStatus `json:"status"`
	// Its unit price excluding VAT, up to 4 decimals, or null when the catalog gives none.
	UnitPrice *Money `json:"unitPrice"`
	// Its purchase price excluding VAT (set by a supplier catalog import), or null.
	CostPrice *Money `json:"costPrice"`
	// The VAT rate, a decimal string in percent: "20", "5.5".
	VatRate string `json:"vatRate"`
	// The accounting account sales of this product are booked to (706000…), or null for the default.
	AccountingNumber *string `json:"accountingNumber"`
	// The product's barcodes, its main one first.
	Barcodes []Barcode `json:"barcodes"`
	// The product's tags, sorted.
	Tags []string `json:"tags"`
	// When the product was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When the product last changed (RFC 3339, UTC), its barcodes included.
	UpdatedAt string `json:"updatedAt"`
	// Who created it, a person or an organization key's robot, or null when that is not known.
	CreatedBy *Author `json:"createdBy"`
	// Where the product comes from, as its labels say (« France », « Bretagne »), in their order.
	Origins []string `json:"origins"`
	// The dates its goods carry (DLC, DCR, DDM).
	ShelfLife ShelfLife `json:"shelfLife"`
	// The weight of one unit, in grams (an integer), or null when not known; a tour's load adds it up.
	WeightGrams *int `json:"weightGrams"`
	// The volume of one unit, in milliliters (an integer), or null when not known; a tour's load adds it up.
	VolumeMilliliters *int `json:"volumeMilliliters"`
	// The coefficient its unit price was derived from its cost price with (unitPrice = costPrice × coefficient), a
	// decimal string ("1.35"), set by a supplier catalog import; null otherwise. Read-only.
	MarginCoefficient *string `json:"marginCoefficient"`
	// The supplier catalog it was imported from, a key of Myle's import profiles (pointp…); null for a product
	// created otherwise. Read-only.
	ImportSupplier *string `json:"importSupplier"`
	// contains filtered or unexported fields
}

Product — A product or a service of the organization's catalog. unitPrice: its unit price excluding VAT, up to 4 decimals, or null when the catalog gives none; costPrice: its purchase price excluding VAT (set by a supplier catalog import), or null; createdBy: who created it, a person or an organization key's robot, or null when that is not known; shelfLife: the dates its goods carry (DLC, DCR, DDM).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Product) ETag

func (m Product) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Product) LastResponse

func (m Product) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type ProductBarcodeCreateParams

type ProductBarcodeCreateParams struct {
	// The barcode, as printed: an EAN-13 or an EAN-8 with its check digit, up to 80 characters for a Code 128, up
	// to 2048 for a QR code.
	Value string `json:"value"`
	// Its symbology: EAN_13, EAN_8, CODE_128 or QR_CODE.
	Format BarcodeFormat `json:"format"`
	// Whether it becomes the product's main barcode (the previous one stops being); absent: false.
	IsPrimary Opt[bool] `json:"isPrimary"`
}

ProductBarcodeCreateParams is the parameters of ProductBarcodesService.Create (createProductBarcode): its body's members. A nil *ProductBarcodeCreateParams sends none.

A new barcode of a product.

A member of type Opt is left out unless set.

func (ProductBarcodeCreateParams) MarshalJSON

func (p ProductBarcodeCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type ProductBarcodeDuplicateContext

type ProductBarcodeDuplicateContext struct {
	// The barcode sent.
	Value string `json:"value"`
}

ProductBarcodeDuplicateContext — The detail of this error.

The context of an error code.

type ProductBarcodeDuplicateError

type ProductBarcodeDuplicateError struct {
	*ConflictError
	// Context is the detail of the error.
	Context ProductBarcodeDuplicateContext
}

ProductBarcodeDuplicateError is the error code products.barcode.duplicate (409): The product already carries this barcode (another product of the organization may carry it too).

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*ProductBarcodeDuplicateError) Unwrap

func (e *ProductBarcodeDuplicateError) Unwrap() error

Unwrap answers the *ConflictError it is.

type ProductBarcodeOutsideCompanyPrefixContext

type ProductBarcodeOutsideCompanyPrefixContext struct {
	// The organization's GS1 company prefix.
	CompanyPrefix string `json:"companyPrefix"`
}

ProductBarcodeOutsideCompanyPrefixContext — The detail of this error.

The context of an error code.

type ProductBarcodeOutsideCompanyPrefixError

type ProductBarcodeOutsideCompanyPrefixError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context ProductBarcodeOutsideCompanyPrefixContext
}

ProductBarcodeOutsideCompanyPrefixError is the error code products.barcode.outside-company-prefix (422): The organization declared its GS1 company prefix, and this EAN-13 does not start with it: register the supplier's barcode on the supplier's product, or use an internal code (restricted distribution, 200 to 299).

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*ProductBarcodeOutsideCompanyPrefixError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type ProductBarcodeUpdateParams

type ProductBarcodeUpdateParams struct {
	// true: the barcode becomes the product's main one, the previous one stops being. Only true is accepted: a
	// product's main barcode is replaced, never removed.
	IsPrimary Opt[bool] `json:"isPrimary"`
}

ProductBarcodeUpdateParams is the parameters of ProductBarcodesService.Update (updateProductBarcode): its body's members. A nil *ProductBarcodeUpdateParams sends none.

A merge patch of a barcode (RFC 7396): an absent member is unchanged.

A merge patch: a member left out is unchanged, myle.Null clears it.

func (ProductBarcodeUpdateParams) MarshalJSON

func (p ProductBarcodeUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type ProductBarcodesService

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

ProductBarcodesService — /organizations/{id}/products/{productId}/barcodes.

Reach it as client.Organization("organization_…").Products.Barcodes.

func (*ProductBarcodesService) Create

func (s *ProductBarcodesService) Create(ctx context.Context, productID string, params *ProductBarcodeCreateParams, opts ...RequestOption) (*Barcode, error)

Create — Add a barcode to a product.

Adds a barcode to a product the caller can see. The value must be valid for its format (an EAN's check digit), and, for an organization that declared its GS1 company prefix, an EAN-13 must start with it (422). A product carries a value once (409); two products may carry the same one. A new main barcode replaces the previous one. The product's version moves. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/products/{productId}/barcodes · requires ARTICLES_BARCODES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new barcode. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *ProductBarcodeDuplicateError (409 products.barcode.duplicate): The product already carries this barcode (another product of the organization may carry it too).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *ProductBarcodeOutsideCompanyPrefixError (422 products.barcode.outside-company-prefix): The organization declared its GS1 company prefix, and this EAN-13 does not start with it: register the supplier's barcode on the supplier's product, or use an internal code (restricted distribution, 200 to 299).

Example:

org := client.Organization("organization_…")
barcode, err := org.Products.Barcodes.Create(ctx, "product_…", &myle.ProductBarcodeCreateParams{Value: "value", Format: myle.BarcodeFormatEan13})
if err != nil {
	return err
}
fmt.Println(barcode.ID, barcode.ETag())

func (*ProductBarcodesService) Delete

func (s *ProductBarcodesService) Delete(ctx context.Context, productID string, barcodeID string, opts ...RequestOption) error

Delete — Remove a barcode from a product.

Removes a barcode from a product the caller can see; the documents that printed it keep it. With If-Match (the product's ETag), refused (412) if the product changed since it was read.

DELETE /organizations/{id}/products/{productId}/barcodes/{barcodeId} · requires ARTICLES_BARCODES_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the barcode is removed).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
barcode, err := org.Products.Barcodes.Get(ctx, "product_…", "barcode_…")
if err != nil {
	return err
}
err = org.Products.Barcodes.Delete(ctx, "product_…", "barcode_…", myle.IfMatch(barcode))
if err != nil {
	return err
}

func (*ProductBarcodesService) Get

func (s *ProductBarcodesService) Get(ctx context.Context, productID string, barcodeID string, opts ...RequestOption) (*Barcode, error)

Get — Get a barcode of a product.

Returns one barcode of a product the caller can see (the product embeds them all), with the product's ETag.

GET /organizations/{id}/products/{productId}/barcodes/{barcodeId} · requires ARTICLES_BARCODES_LIST.

It answers the barcode. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
barcode, err := org.Products.Barcodes.Get(ctx, "product_…", "barcode_…")
if err != nil {
	return err
}
fmt.Println(barcode.ID, barcode.ETag())

func (*ProductBarcodesService) Update

func (s *ProductBarcodesService) Update(ctx context.Context, productID string, barcodeID string, params *ProductBarcodeUpdateParams, opts ...RequestOption) (*Barcode, error)

Update — Change a barcode of a product.

Makes the barcode the product's main one ({"isPrimary": true}, a JSON merge patch); the previous main barcode stops being. Already the main one, nothing changes. With If-Match (the product's ETag), refused (412) if the product changed since it was read.

PATCH /organizations/{id}/products/{productId}/barcodes/{barcodeId} · requires ARTICLES_BARCODES_CREATE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the barcode, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
barcode, err := org.Products.Barcodes.Get(ctx, "product_…", "barcode_…")
if err != nil {
	return err
}
updated, err := org.Products.Barcodes.Update(ctx, "product_…", "barcode_…", nil, myle.IfMatch(barcode))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type ProductCreateParams

type ProductCreateParams struct {
	// Its reference in the catalog, unique among the organization's products.
	Number string `json:"number"`
	// Its name.
	Name string `json:"name"`
	// Its unit price excluding VAT, in EUR, up to 4 decimals; absent or null for none.
	UnitPrice Opt[Money] `json:"unitPrice"`
	// Its VAT rate in percent, a decimal string from 0 to 100: "20", "5.5".
	VatRate string `json:"vatRate"`
	// The accounting account its sales are booked to; absent or null for the default one.
	AccountingNumber Opt[string] `json:"accountingNumber"`
	// Its tags; absent for none.
	Tags Opt[[]string] `json:"tags"`
	// The stock to create with it (Stocks module); absent or null for none.
	InitialStock Opt[InitialStock] `json:"initialStock"`
	// Where it comes from, as its labels say (« France », « Bretagne »); absent or null for none.
	Origins Opt[[]string] `json:"origins"`
	// The dates its goods carry; absent or null: none enabled, no delay.
	ShelfLife Opt[ShelfLifeInput] `json:"shelfLife"`
	// The weight of one unit, in grams, an integer from 0; absent or null when not known.
	WeightGrams Opt[int] `json:"weightGrams"`
	// The volume of one unit, in milliliters, an integer from 0; absent or null when not known.
	VolumeMilliliters Opt[int] `json:"volumeMilliliters"`
}

ProductCreateParams is the parameters of ProductsService.Create (createProduct): its body's members. A nil *ProductCreateParams sends none.

A new product. unitPrice: its unit price excluding VAT, in EUR, up to 4 decimals; absent or null for none. initialStock: the stock to create with it (Stocks module); absent or null for none. shelfLife: the dates its goods carry; absent or null: none enabled, no delay.

A member of type Opt is left out unless set.

func (ProductCreateParams) MarshalJSON

func (p ProductCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type ProductGetNeighborsParams

type ProductGetNeighborsParams struct {
	// Text searched in the name and the number, accents and case ignored.
	Q Opt[string] `json:"-"`
	// Products of one of these statuses (repeat it for several): ACTIVE. Each value is sent (name=a&name=b).
	Status []ProductStatus `json:"-"`
	// Products carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value
	// is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a product carrying one of the tags; ALL, a product carrying
	// every one of them.
	TagMode Opt[ProductListTagMode] `json:"-"`
	// Leaves out the products carrying every one of these tags (repeat it for several): one tag leaves out the
	// products carrying it; with several, a product carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// Products carrying this barcode, exactly.
	Barcode Opt[string] `json:"-"`
	// Products changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Products whose name contains these words, in this order, accents and case ignored.
	Name Opt[string] `json:"-"`
	// Products whose number contains this text, case ignored.
	Number Opt[string] `json:"-"`
	// Products whose accounting account contains this text, case ignored.
	AccountingNumber Opt[string] `json:"-"`
	// Products created by this person (user_<uuid>) or this organization key's robot (robot_<uuid>).
	CreatedBy Opt[string] `json:"-"`
	// Products whose author's name (first name and last name) contains this text, case ignored.
	CreatedByName Opt[string] `json:"-"`
	// true: products carrying at least one barcode; false: products carrying none.
	HasBarcode Opt[bool] `json:"-"`
	// name (the default), number, accountingNumber, createdAt or updatedAt; with a leading - for descending
	// (-name). Ties are broken by the product's id.
	Sort Opt[ProductListSort] `json:"-"`
}

ProductGetNeighborsParams is the parameters of ProductsService.GetNeighbors (getProductNeighbors): its query parameters. A nil *ProductGetNeighborsParams sends none.

type ProductListParams

type ProductListParams struct {
	// Text searched in the name and the number, accents and case ignored.
	Q Opt[string] `json:"-"`
	// Products of one of these statuses (repeat it for several): ACTIVE. Each value is sent (name=a&name=b).
	Status []ProductStatus `json:"-"`
	// Products carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value
	// is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a product carrying one of the tags; ALL, a product carrying
	// every one of them.
	TagMode Opt[ProductListTagMode] `json:"-"`
	// Leaves out the products carrying every one of these tags (repeat it for several): one tag leaves out the
	// products carrying it; with several, a product carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// Products carrying this barcode, exactly.
	Barcode Opt[string] `json:"-"`
	// Products changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Products whose name contains these words, in this order, accents and case ignored.
	Name Opt[string] `json:"-"`
	// Products whose number contains this text, case ignored.
	Number Opt[string] `json:"-"`
	// Products whose accounting account contains this text, case ignored.
	AccountingNumber Opt[string] `json:"-"`
	// Products created by this person (user_<uuid>) or this organization key's robot (robot_<uuid>).
	CreatedBy Opt[string] `json:"-"`
	// Products whose author's name (first name and last name) contains this text, case ignored.
	CreatedByName Opt[string] `json:"-"`
	// true: products carrying at least one barcode; false: products carrying none.
	HasBarcode Opt[bool] `json:"-"`
	// name (the default), number, accountingNumber, createdAt or updatedAt; with a leading - for descending
	// (-name). Ties are broken by the product's id.
	Sort Opt[ProductListSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of products of the whole list with these filters (one more
	// count on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

ProductListParams is the parameters of ProductsService.List (listProducts): its query parameters. A nil *ProductListParams sends none.

type ProductListSort

type ProductListSort string

ProductListSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: name, -name, number, -number, accountingNumber, -accountingNumber, createdAt, -createdAt, updatedAt, -updatedAt.

const ProductListSortAccountingNumber ProductListSort = "accountingNumber"

ProductListSortAccountingNumber is "accountingNumber".

const ProductListSortAccountingNumberDesc ProductListSort = "-accountingNumber"

ProductListSortAccountingNumberDesc is "-accountingNumber".

const ProductListSortCreatedAt ProductListSort = "createdAt"

ProductListSortCreatedAt is "createdAt".

const ProductListSortCreatedAtDesc ProductListSort = "-createdAt"

ProductListSortCreatedAtDesc is "-createdAt".

const ProductListSortName ProductListSort = "name"

ProductListSortName is "name".

const ProductListSortNameDesc ProductListSort = "-name"

ProductListSortNameDesc is "-name".

const ProductListSortNumber ProductListSort = "number"

ProductListSortNumber is "number".

const ProductListSortNumberDesc ProductListSort = "-number"

ProductListSortNumberDesc is "-number".

const ProductListSortUpdatedAt ProductListSort = "updatedAt"

ProductListSortUpdatedAt is "updatedAt".

const ProductListSortUpdatedAtDesc ProductListSort = "-updatedAt"

ProductListSortUpdatedAtDesc is "-updatedAt".

type ProductListTagMode

type ProductListTagMode string

ProductListTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const ProductListTagModeAll ProductListTagMode = "ALL"

ProductListTagModeAll is "ALL".

const ProductListTagModeAny ProductListTagMode = "ANY"

ProductListTagModeAny is "ANY".

type ProductNeighbors

type ProductNeighbors struct {
	// A product, in short: enough to name it and to fetch it.
	Previous *ProductSummary `json:"previous"`
	// A product, in short: enough to name it and to fetch it.
	Next *ProductSummary `json:"next"`
	// contains filtered or unexported fields
}

ProductNeighbors — A product's place in the product list: previous, the product right before it, and next, the product right after it; each null at an end of the list, both null when the filters leave the product out of it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (ProductNeighbors) ETag

func (m ProductNeighbors) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (ProductNeighbors) LastResponse

func (m ProductNeighbors) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type ProductStatus

type ProductStatus string

ProductStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ACTIVE.

const ProductStatusActive ProductStatus = "ACTIVE"

ProductStatusActive is "ACTIVE".

type ProductSummary

type ProductSummary struct {
	// The product's id (product_<uuid>).
	ID string `json:"id"`
	// Always "product".
	Object string `json:"object"`
	// The product's reference in the catalog.
	Number string `json:"number"`
	// The product's name.
	Name string `json:"name"`
}

ProductSummary — A product, in short: enough to name it and to fetch it.

type ProductUpdateParams

type ProductUpdateParams struct {
	// A new reference, unique among the organization's products.
	Number Opt[string] `json:"number"`
	// A new name.
	Name Opt[string] `json:"name"`
	// A new unit price excluding VAT, in EUR; null for none.
	UnitPrice Opt[Money] `json:"unitPrice"`
	// A new VAT rate in percent, a decimal string from 0 to 100.
	VatRate Opt[string] `json:"vatRate"`
	// A new accounting account; null for the default one.
	AccountingNumber Opt[string] `json:"accountingNumber"`
	// The product's tags, all of them; null for none.
	Tags Opt[[]string] `json:"tags"`
	// The product's origins, all of them, in their order; null for none.
	Origins Opt[[]string] `json:"origins"`
	// The dates its goods carry, merged member by member (an absent date, or an absent member of a date, is
	// unchanged).
	ShelfLife Opt[ShelfLifeInput] `json:"shelfLife"`
	// A new weight of one unit, in grams, an integer from 0; null when not known.
	WeightGrams Opt[int] `json:"weightGrams"`
	// A new volume of one unit, in milliliters, an integer from 0; null when not known.
	VolumeMilliliters Opt[int] `json:"volumeMilliliters"`
}

ProductUpdateParams is the parameters of ProductsService.Update (updateProduct): its body's members. A nil *ProductUpdateParams sends none.

A merge patch of a product (RFC 7396): an absent member is unchanged. unitPrice: a new unit price excluding VAT, in EUR; null for none. shelfLife: the dates its goods carry, merged member by member (an absent date, or an absent member of a date, is unchanged).

A merge patch: a member left out is unchanged, myle.Null clears it.

func (ProductUpdateParams) MarshalJSON

func (p ProductUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type ProductsService

type ProductsService struct {
	// Barcodes — /organizations/{id}/products/{productId}/barcodes.
	Barcodes *ProductBarcodesService
	// contains filtered or unexported fields
}

ProductsService — the organization's catalog: the products and services it sells, with their prices and barcodes (/organizations/{id}/products).

Reach it as client.Organization("organization_…").Products.

func (*ProductsService) Create

func (s *ProductsService) Create(ctx context.Context, params *ProductCreateParams, opts ...RequestOption) (*Product, error)

Create — Create a product.

Creates a product in the catalog. Its number must not be used by another product (409). With initialStock, creates its stock too, in the same transaction: that requires the Stocks module (402) and STOCKS_CREATE, and STOCKLINES_CREATE for a quantity above 0 (403); the stock's reference derives from the product's. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/products · requires ARTICLES_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new product. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
product, err := org.Products.Create(ctx, &myle.ProductCreateParams{Number: "number", Name: "name", VatRate: "20"})
if err != nil {
	return err
}
fmt.Println(product.Name, product.ETag())

func (*ProductsService) Delete

func (s *ProductsService) Delete(ctx context.Context, productID string, opts ...RequestOption) error

Delete — Delete a product.

Deletes a product: it leaves the catalog, the documents that name it keep it. With If-Match, refused (412) if the product changed since it was read.

DELETE /organizations/{id}/products/{productId} · requires ARTICLES_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the product is deleted).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
product, err := org.Products.Get(ctx, "product_…")
if err != nil {
	return err
}
err = org.Products.Delete(ctx, "product_…", myle.IfMatch(product))
if err != nil {
	return err
}

func (*ProductsService) Get

func (s *ProductsService) Get(ctx context.Context, productID string, opts ...RequestOption) (*Product, error)

Get — Get a product.

Returns a product the caller can see; one outside its tag scope, deleted or unknown is a 404.

GET /organizations/{id}/products/{productId} · requires ARTICLES_LIST.

It answers the product. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
product, err := org.Products.Get(ctx, "product_…")
if err != nil {
	return err
}
fmt.Println(product.Name, product.ETag())

func (*ProductsService) GetNeighbors

func (s *ProductsService) GetNeighbors(ctx context.Context, productID string, params *ProductGetNeighborsParams, opts ...RequestOption) (*ProductNeighbors, error)

GetNeighbors — Get a product's neighbors in the list.

Returns the products right before and right after this one in the product list read with the same filters and sort (the list's query parameters, without limit, cursor and includeTotal): next is the first product of the page that follows a page ending on this one, previous the one before it in that order. Each is null at an end of the list, and both are null when the filters leave the product out of it. The product must be one the caller can see (404 otherwise); its tag scope applies to the neighbors too.

GET /organizations/{id}/products/{productId}/neighbors · requires ARTICLES_LIST.

It answers the product's neighbors.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
productNeighbors, err := org.Products.GetNeighbors(ctx, "product_…", nil)
if err != nil {
	return err
}
fmt.Println(productNeighbors)

func (*ProductsService) List

List — List the products.

Returns the organization's products the caller can see (its tag scope applies), filtered and sorted, one page at a time. For a synchronization: updatedAfter with the largest updatedAt already seen.

GET /organizations/{id}/products · requires ARTICLES_LIST.

It answers a *Paginator (a page of products): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
for product, err := range org.Products.List(ctx, &myle.ProductListParams{Status: []myle.ProductStatus{myle.ProductStatusActive}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(product.ID)
}
Example
package main

import (
	"context"
	"fmt"
	"log"

	myle "github.com/myleapp/myle-go"
)

func main() {
	org := myle.NewClient().Organization("organization_…")
	params := &myle.ProductListParams{Status: []myle.ProductStatus{myle.ProductStatusActive}}
	for product, err := range org.Products.List(context.Background(), params).All() {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(product.Number, product.Name)
	}
}

func (*ProductsService) ListTags

func (s *ProductsService) ListTags(ctx context.Context, opts ...RequestOption) *Paginator[string]

ListTags — List the products' tags.

Returns the tags the organization's products carry, sorted: the values a tag filter of the product list can take. For a tag-scoped caller, only the tags of the products in its scope. All of them at once: nextCursor is never present. Open to whoever composes a document as well (quotations, orders, delivery notes, invoices), not only to who lists the catalog.

GET /organizations/{id}/products/tags · requires one of ARTICLES_LIST, ORDER_CREATE, QUOTATION_CREATE, DELIVERYFORMS_CREATE, INVOICES_CREATE.

It answers a *Paginator over a single page (the tags, sorted). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for tag, err := range org.Products.ListTags(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(tag)
}

func (*ProductsService) Update

func (s *ProductsService) Update(ctx context.Context, productID string, params *ProductUpdateParams, opts ...RequestOption) (*Product, error)

Update — Change a product.

Changes the members sent (a JSON merge patch); the others stay as they are. With If-Match, refused (412) if the product changed since it was read. Its number must not be used by another product (409).

PATCH /organizations/{id}/products/{productId} · requires ARTICLES_PATCH.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the product, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreConflictError (409 core.conflict): The request conflicts with an existing resource.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
product, err := org.Products.Get(ctx, "product_…")
if err != nil {
	return err
}
updated, err := org.Products.Update(ctx, "product_…", &myle.ProductUpdateParams{Number: myle.String("number")}, myle.IfMatch(product))
if err != nil {
	return err
}
fmt.Println(updated.ETag())
Example
package main

import (
	"context"
	"errors"
	"fmt"
	"log"

	myle "github.com/myleapp/myle-go"
)

func main() {
	ctx := context.Background()
	org := myle.NewClient().Organization("organization_…")
	product, err := org.Products.Get(ctx, "product_…")
	if err != nil {
		log.Fatal(err)
	}
	updated, err := org.Products.Update(ctx, product.ID, &myle.ProductUpdateParams{
		Name:             myle.String("Foin de luzerne"),
		AccountingNumber: myle.Null[string](),
	}, myle.IfMatch(product))
	var stale *myle.CorePreconditionFailedError
	if errors.As(err, &stale) {
		fmt.Println("changed since: read it again")
		return
	}
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(updated.ETag())
}

type PublicSectorCustomers

type PublicSectorCustomers struct {
	// How many customers are public bodies (tag E-FACT:CHORUS).
	Count int `json:"count"`
	// Their names, sorted, 5 at most (count is not capped).
	Names []string `json:"names"`
}

PublicSectorCustomers — Public bodies among the customers of the drafts: validating mails them the original (Chorus Pro).

type Quotation

type Quotation struct {
	// The quotation's id (quotation_<uuid>).
	ID string `json:"id"`
	// Always "quotation".
	Object string `json:"object"`
	// The organization it belongs to (organization_<uuid>).
	OrganizationID string `json:"organizationId"`
	// Its number in the organization's sequence ("4101"), given at its creation.
	Number string `json:"number"`
	// VALIDATED (issued, not marked shared yet), SHARED (the customer has it), APPROVED (accepted), CANCELED
	// (refused or withdrawn), EXPIRED (its validity passed while it waited), ORDERED (an order was made from it),
	// INVOICED (billed). An open enum: tolerate a value you do not know. A deleted quotation is never returned
	// (404).
	Status QuotationStatus `json:"status"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// The customer as the quotation froze it.
	Company QuotationCompanySnapshot `json:"company"`
	// Its date (YYYY-MM-DD).
	IssueDate string `json:"issueDate"`
	// The last day it is valid (YYYY-MM-DD): the day after, a quotation still waiting becomes EXPIRED.
	ExpiryDate string `json:"expiryDate"`
	// When the work it offers starts (YYYY-MM-DD), or null.
	WorkStartDate *string `json:"workStartDate"`
	// When the work it offers ends (YYYY-MM-DD), or null.
	WorkEndDate *string `json:"workEndDate"`
	// A description printed on it, or null.
	Description *string `json:"description"`
	// Its lines, in order.
	Lines []QuotationLine `json:"lines"`
	// The lines' subtotals (excluding VAT, discounts deducted).
	Subtotal Money `json:"subtotal"`
	// The VAT.
	Vat Money `json:"vat"`
	// What the quotation amounts to.
	Total Money `json:"total"`
	// The orders made from it (order_<uuid>).
	OrderIDs []string `json:"orderIds"`
	// The invoices made from it (invoice_<uuid>).
	InvoiceIDs []string `json:"invoiceIds"`
	// Its own tags, sorted.
	Tags []string `json:"tags"`
	// When it was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// When it, its lines, its status or its tags last changed (RFC 3339, UTC).
	UpdatedAt string `json:"updatedAt"`
	// contains filtered or unexported fields
}

Quotation — A quotation. It is born VALIDATED, with its number: there is no draft. subtotal: the lines' subtotals (excluding VAT, discounts deducted); vat: the VAT; total: what the quotation amounts to. company: the customer as the quotation froze it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (Quotation) ETag

func (m Quotation) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (Quotation) LastResponse

func (m Quotation) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type QuotationBatchApproveParams

type QuotationBatchApproveParams struct {
	// Their ids (quotation_<uuid>), at least one; each quotation is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
}

QuotationBatchApproveParams is the parameters of QuotationsService.BatchApprove (batchApproveQuotations): its body's members. A nil *QuotationBatchApproveParams sends none.

The quotations a batch acts on.

A member of type Opt is left out unless set.

func (QuotationBatchApproveParams) MarshalJSON

func (p QuotationBatchApproveParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationBatchOrderParams

type QuotationBatchOrderParams struct {
	// Their ids (quotation_<uuid>), at least one; each quotation is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
}

QuotationBatchOrderParams is the parameters of QuotationsService.BatchOrder (batchOrderQuotations): its body's members. A nil *QuotationBatchOrderParams sends none.

The quotations a batch acts on.

A member of type Opt is left out unless set.

func (QuotationBatchOrderParams) MarshalJSON

func (p QuotationBatchOrderParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationBatchShareParams

type QuotationBatchShareParams struct {
	// Their ids (quotation_<uuid>), at least one; each quotation is answered once, at its first place in the order
	// sent.
	IDs []string `json:"ids"`
}

QuotationBatchShareParams is the parameters of QuotationsService.BatchShare (batchShareQuotations): its body's members. A nil *QuotationBatchShareParams sends none.

The quotations a batch acts on.

A member of type Opt is left out unless set.

func (QuotationBatchShareParams) MarshalJSON

func (p QuotationBatchShareParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationCompanySnapshot

type QuotationCompanySnapshot struct {
	// The customer's legal name.
	Name string `json:"name"`
	// The address the quotation is addressed to.
	Address string `json:"address"`
	// Its billing address, or null.
	BillingAddress *string `json:"billingAddress"`
	// Its headquarters address, or null.
	HeadquartersAddress *string `json:"headquartersAddress"`
	// Its SIREN, or null.
	Siren *string `json:"siren"`
	// Its VAT number, or null.
	VatNumber *string `json:"vatNumber"`
}

QuotationCompanySnapshot — The customer as the quotation froze it at its creation (or when its customer changed): what the PDF prints, whatever the company became since.

type QuotationCreateParams

type QuotationCreateParams struct {
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// Its date (YYYY-MM-DD); today (Paris) when absent.
	IssueDate Opt[string] `json:"issueDate"`
	// The last day it is valid (YYYY-MM-DD), on or after issueDate; absent, issueDate plus the organization's
	// validity (30 days unless set).
	ExpiryDate Opt[string] `json:"expiryDate"`
	// When the work it offers starts (YYYY-MM-DD).
	WorkStartDate Opt[string] `json:"workStartDate"`
	// When the work it offers ends (YYYY-MM-DD), on or after workStartDate.
	WorkEndDate Opt[string] `json:"workEndDate"`
	// A description printed on the quotation.
	Description Opt[string] `json:"description"`
	// Its lines, at least one, in order.
	Lines []QuotationLineInput `json:"lines"`
	// Its own tags.
	Tags Opt[[]string] `json:"tags"`
}

QuotationCreateParams is the parameters of QuotationsService.Create (createQuotation): its body's members. A nil *QuotationCreateParams sends none.

A new quotation. companyId: the customer, one of the organization's companies. Without DELIVERYFORMS_CUSTOMIZE_PRICE, a line takes its product's catalog price (the customer's own price if it has one) and no discount, whatever is sent.

A member of type Opt is left out unless set.

func (QuotationCreateParams) MarshalJSON

func (p QuotationCreateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationEditParams

type QuotationEditParams struct {
	// The customer (company_<uuid>): the quotation takes the recipient and legal details a creation would give it
	// for this customer; its lines are kept as they are (a quotation carries no customer discount).
	CompanyID Opt[string] `json:"companyId"`
	// A description printed on the quotation; null for none.
	Description Opt[string] `json:"description"`
	// Its lines, all of them, at least one, in order (as at the creation). Without DELIVERYFORMS_CUSTOMIZE_PRICE, a
	// new line takes its product's catalog price and no discount; a line kept as it was keeps its price.
	Lines Opt[[]QuotationLineInput] `json:"lines"`
}

QuotationEditParams is the parameters of QuotationsService.Edit (editQuotation): its body's members. A nil *QuotationEditParams sends none.

A quotation's new content: an absent member is unchanged. Lines are added, changed, removed and reordered by sending the whole list.

A member of type Opt is left out unless set.

func (QuotationEditParams) MarshalJSON

func (p QuotationEditParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationEditability

type QuotationEditability struct {
	// true while it is VALIDATED and has not left the organization (no mail, link, online read, share).
	Editable bool `json:"editable"`
	// Why it cannot, or null: NOT_DRAFT (no longer VALIDATED), MAILED, SHARE_LINK, PUBLIC_ACCESS (read online),
	// SHARED (marked shared once), CONVERTED (an order or an invoice was made from it). An open list.
	Reason *string `json:"reason"`
	// contains filtered or unexported fields
}

QuotationEditability — Whether a quotation's lines, customer and description can still be changed: editable, or reason says why not.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (QuotationEditability) ETag

func (m QuotationEditability) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (QuotationEditability) LastResponse

func (m QuotationEditability) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type QuotationEligibility

type QuotationEligibility struct {
	// The quotations the filters give (the caller's, deleted ones never).
	Total int `json:"total"`
	// VALIDATED, for batch-share.
	Share int `json:"share"`
	// SHARED, for batch-approve.
	Approve int `json:"approve"`
	// APPROVED, for batch-order.
	Order int `json:"order"`
	// contains filtered or unexported fields
}

QuotationEligibility — What each batch would act on among the quotations the filters give: the counts the web app shows on its batch buttons.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (QuotationEligibility) ETag

func (m QuotationEligibility) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (QuotationEligibility) LastResponse

func (m QuotationEligibility) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type QuotationExtendParams

type QuotationExtendParams struct {
	// The last day it is valid (YYYY-MM-DD), today (Paris) at the earliest; absent, today plus the organization's
	// validity (30 days unless set).
	ExpiryDate Opt[string] `json:"expiryDate"`
}

QuotationExtendParams is the parameters of QuotationsService.Extend (extendQuotation): its body's members. A nil *QuotationExtendParams sends none.

A quotation's new validity.

A member of type Opt is left out unless set.

func (QuotationExtendParams) MarshalJSON

func (p QuotationExtendParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationGetEligibilityParams

type QuotationGetEligibilityParams struct {
	// Quotations of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, CANCELED, EXPIRED,
	// ORDERED, INVOICED. Each value is sent (name=a&name=b).
	Status []QuotationStatus `json:"-"`
	// Quotations of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Quotations dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Quotations dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Quotations valid until this day or later (YYYY-MM-DD).
	ExpiryDateFrom Opt[string] `json:"-"`
	// Quotations valid until this day at the latest (YYYY-MM-DD).
	ExpiryDateTo Opt[string] `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Quotations changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Quotations carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each
	// value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a quotation carrying one of the tags; ALL, a quotation
	// carrying every one of them.
	TagMode Opt[QuotationListTagMode] `json:"-"`
	// Leaves out the quotations carrying every one of these tags (repeat it for several): one tag leaves out the
	// quotations carrying it; with several, a quotation carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
}

QuotationGetEligibilityParams is the parameters of QuotationsService.GetEligibility (getQuotationEligibility): its query parameters. A nil *QuotationGetEligibilityParams sends none.

type QuotationGetNeighborsParams

type QuotationGetNeighborsParams struct {
	// Quotations of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, CANCELED, EXPIRED,
	// ORDERED, INVOICED. Each value is sent (name=a&name=b).
	Status []QuotationStatus `json:"-"`
	// Quotations of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Quotations dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Quotations dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Quotations valid until this day or later (YYYY-MM-DD).
	ExpiryDateFrom Opt[string] `json:"-"`
	// Quotations valid until this day at the latest (YYYY-MM-DD).
	ExpiryDateTo Opt[string] `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Quotations changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Quotations carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each
	// value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a quotation carrying one of the tags; ALL, a quotation
	// carrying every one of them.
	TagMode Opt[QuotationListTagMode] `json:"-"`
	// Leaves out the quotations carrying every one of these tags (repeat it for several): one tag leaves out the
	// quotations carrying it; with several, a quotation carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// -number (the default, the newest first), number, createdAt, updatedAt or issueDate; with a leading - for
	// descending. Ties are broken by the quotation's id.
	Sort Opt[QuotationListSort] `json:"-"`
}

QuotationGetNeighborsParams is the parameters of QuotationsService.GetNeighbors (getQuotationNeighbors): its query parameters. A nil *QuotationGetNeighborsParams sends none.

type QuotationLine

type QuotationLine struct {
	// The line's position in the quotation, from 0.
	Index int `json:"index"`
	// The catalog product it offers (product_<uuid>).
	ProductID string `json:"productId"`
	// The product's reference as printed, or null.
	Number *string `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// A longer description printed under the label, or null.
	Description *string `json:"description"`
	// The quantity, a decimal string: "12.5".
	Quantity string `json:"quantity"`
	// Excluding VAT, before the discount.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate, a decimal string in percent: "20", "5.5".
	VatRate string `json:"vatRate"`
	// The line's discount in percent, a decimal string, or null.
	DiscountRate *string `json:"discountRate"`
	// A discount of a fixed amount, or null (discountRate and discountAmount add up).
	DiscountAmount *Money `json:"discountAmount"`
	// Why the line is discounted, or null.
	DiscountReason *string `json:"discountReason"`
	// Quantity × unitPrice, discounts deducted, excluding VAT.
	Subtotal Money `json:"subtotal"`
	// The subtotal with its VAT.
	Total Money `json:"total"`
	// The accounting account the line is booked to (706000…), or null for the default.
	AccountingNumber *string `json:"accountingNumber"`
}

QuotationLine — A quotation line. unitPrice: excluding VAT, before the discount; discountAmount: a discount of a fixed amount, or null (discountRate and discountAmount add up); subtotal: quantity × unitPrice, discounts deducted, excluding VAT; total: the subtotal with its VAT.

type QuotationLineInput

type QuotationLineInput struct {
	// The catalog product it offers (product_<uuid>): a quotation's lines all name one.
	ProductID string `json:"productId"`
	// The product's reference as printed.
	Number Opt[string] `json:"number"`
	// The line's label.
	Name string `json:"name"`
	// A longer description printed under the label.
	Description Opt[string] `json:"description"`
	// The quantity, a decimal string: "12.5".
	Quantity string `json:"quantity"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	UnitPrice Money `json:"unitPrice"`
	// The VAT rate in percent, a decimal string from 0 to 100: "20".
	VatRate string `json:"vatRate"`
	// A discount in percent, a decimal string from 0 to 100.
	DiscountRate Opt[string] `json:"discountRate"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	DiscountAmount Opt[Money] `json:"discountAmount"`
	// Why the line is discounted, printed with it.
	DiscountReason Opt[string] `json:"discountReason"`
	// The accounting account the line is booked to; absent for the default.
	AccountingNumber Opt[string] `json:"accountingNumber"`
}

QuotationLineInput — A line of a quotation. unitPrice: in EUR, excluding VAT, before the discount; discountAmount: a discount of a fixed amount in EUR, excluding VAT (it adds up with discountRate). (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (QuotationLineInput) MarshalJSON

func (p QuotationLineInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationListParams

type QuotationListParams struct {
	// Quotations of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, CANCELED, EXPIRED,
	// ORDERED, INVOICED. Each value is sent (name=a&name=b).
	Status []QuotationStatus `json:"-"`
	// Quotations of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Quotations dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Quotations dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Quotations valid until this day or later (YYYY-MM-DD).
	ExpiryDateFrom Opt[string] `json:"-"`
	// Quotations valid until this day at the latest (YYYY-MM-DD).
	ExpiryDateTo Opt[string] `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Quotations changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Quotations carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each
	// value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a quotation carrying one of the tags; ALL, a quotation
	// carrying every one of them.
	TagMode Opt[QuotationListTagMode] `json:"-"`
	// Leaves out the quotations carrying every one of these tags (repeat it for several): one tag leaves out the
	// quotations carrying it; with several, a quotation carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// -number (the default, the newest first), number, createdAt, updatedAt or issueDate; with a leading - for
	// descending. Ties are broken by the quotation's id.
	Sort Opt[QuotationListSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of quotations of the whole list with these filters (one more
	// count on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

QuotationListParams is the parameters of QuotationsService.List (listQuotations): its query parameters. A nil *QuotationListParams sends none.

type QuotationListSort

type QuotationListSort string

QuotationListSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: -number, number, -createdAt, createdAt, updatedAt, -updatedAt, -issueDate, issueDate.

const QuotationListSortCreatedAt QuotationListSort = "createdAt"

QuotationListSortCreatedAt is "createdAt".

const QuotationListSortCreatedAtDesc QuotationListSort = "-createdAt"

QuotationListSortCreatedAtDesc is "-createdAt".

const QuotationListSortIssueDate QuotationListSort = "issueDate"

QuotationListSortIssueDate is "issueDate".

const QuotationListSortIssueDateDesc QuotationListSort = "-issueDate"

QuotationListSortIssueDateDesc is "-issueDate".

const QuotationListSortNumber QuotationListSort = "number"

QuotationListSortNumber is "number".

const QuotationListSortNumberDesc QuotationListSort = "-number"

QuotationListSortNumberDesc is "-number".

const QuotationListSortUpdatedAt QuotationListSort = "updatedAt"

QuotationListSortUpdatedAt is "updatedAt".

const QuotationListSortUpdatedAtDesc QuotationListSort = "-updatedAt"

QuotationListSortUpdatedAtDesc is "-updatedAt".

type QuotationListTagMode

type QuotationListTagMode string

QuotationListTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const QuotationListTagModeAll QuotationListTagMode = "ALL"

QuotationListTagModeAll is "ALL".

const QuotationListTagModeAny QuotationListTagMode = "ANY"

QuotationListTagModeAny is "ANY".

type QuotationNeighbors

type QuotationNeighbors struct {
	// A quotation, in short: enough to name it and to fetch it.
	Previous *QuotationSummary `json:"previous"`
	// A quotation, in short: enough to name it and to fetch it.
	Next *QuotationSummary `json:"next"`
	// contains filtered or unexported fields
}

QuotationNeighbors — A quotation's place in the quotation list: previous, the quotation right before it, and next, the one right after it; each null at an end of the list, both null when the filters leave the quotation out of it.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (QuotationNeighbors) ETag

func (m QuotationNeighbors) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (QuotationNeighbors) LastResponse

func (m QuotationNeighbors) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type QuotationQuotationAlreadyInvoicedContext

type QuotationQuotationAlreadyInvoicedContext struct {
	// The invoice it made (invoice_<uuid>, perhaps deleted since), or null when its link is missing.
	InvoiceID string `json:"invoiceId"`
}

QuotationQuotationAlreadyInvoicedContext — The detail of this error.

The context of an error code.

type QuotationQuotationAlreadyInvoicedError

type QuotationQuotationAlreadyInvoicedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context QuotationQuotationAlreadyInvoicedContext
}

QuotationQuotationAlreadyInvoicedError is the error code quotations.quotation.already-invoiced (409): Another member, key or the nightly billing billed this quotation already (the caller's own billing is answered again), or the caller's own billing made an invoice deleted since. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationAlreadyInvoicedError) Unwrap

Unwrap answers the *ConflictError it is.

type QuotationQuotationConvertedContext

type QuotationQuotationConvertedContext struct {
	// What it made: order or invoice.
	Kind string `json:"kind"`
	// That document's id (order_<uuid>, invoice_<uuid>).
	ID string `json:"id"`
}

QuotationQuotationConvertedContext — The detail of this error.

The context of an error code.

type QuotationQuotationConvertedError

type QuotationQuotationConvertedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context QuotationQuotationConvertedContext
}

QuotationQuotationConvertedError is the error code quotations.quotation.converted (409): The quotation was converted and the order or the invoice it made still lives: delete that one first (its deletion takes the quotation back to APPROVED). Nothing was deleted.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationConvertedError) Unwrap

Unwrap answers the *ConflictError it is.

type QuotationQuotationForeignProductContext

type QuotationQuotationForeignProductContext struct {
	// The products refused (product_<uuid>).
	ProductIDs []string `json:"productIds"`
}

QuotationQuotationForeignProductContext — The detail of this error.

The context of an error code.

type QuotationQuotationForeignProductError

type QuotationQuotationForeignProductError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context QuotationQuotationForeignProductContext
}

QuotationQuotationForeignProductError is the error code quotations.quotation.foreign-product (422): A line names a product of another organization: nothing was written.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationForeignProductError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type QuotationQuotationHasDepositsError

type QuotationQuotationHasDepositsError struct {
	*ConflictError
}

QuotationQuotationHasDepositsError is the error code quotations.quotation.has-deposits (409): The quotation is billed in several times: deposit invoices were issued on it, and its final invoice, which deducts them, settles it; a whole invoice would bill them twice. Nothing was created.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationHasDepositsError) Unwrap

Unwrap answers the *ConflictError it is.

type QuotationQuotationNotEditableContext

type QuotationQuotationNotEditableContext struct {
	// Why: NOT_DRAFT (no longer VALIDATED), MAILED, SHARE_LINK, PUBLIC_ACCESS, SHARED, CONVERTED.
	Reason string `json:"reason"`
}

QuotationQuotationNotEditableContext — The detail of this error.

The context of an error code.

type QuotationQuotationNotEditableError

type QuotationQuotationNotEditableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context QuotationQuotationNotEditableContext
}

QuotationQuotationNotEditableError is the error code quotations.quotation.not-editable (409): The quotation has left the organization (mailed, shared by a link, read online, marked shared) or is no longer VALIDATED: its lines, customer and description are kept as the customer saw them; issue a new quotation. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationNotEditableError) Unwrap

Unwrap answers the *ConflictError it is.

type QuotationQuotationNotExtendableContext

type QuotationQuotationNotExtendableContext struct {
	// The quotation's status (APPROVED, CANCELED…).
	Status string `json:"status"`
}

QuotationQuotationNotExtendableContext — The detail of this error.

The context of an error code.

type QuotationQuotationNotExtendableError

type QuotationQuotationNotExtendableError struct {
	*ConflictError
	// Context is the detail of the error.
	Context QuotationQuotationNotExtendableContext
}

QuotationQuotationNotExtendableError is the error code quotations.quotation.not-extendable (409): Only a quotation still waiting for its customer's answer (VALIDATED, SHARED) or EXPIRED gets a new validity date: an approved, cancelled or converted one has had its answer. Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationNotExtendableError) Unwrap

Unwrap answers the *ConflictError it is.

type QuotationQuotationOutOfScopeReferenceContext

type QuotationQuotationOutOfScopeReferenceContext struct {
	// What is out of scope: company or product.
	Kind string `json:"kind"`
	// The ids refused (company_<uuid>, product_<uuid>).
	IDs []string `json:"ids"`
}

QuotationQuotationOutOfScopeReferenceContext — The detail of this error.

The context of an error code.

type QuotationQuotationOutOfScopeReferenceError

type QuotationQuotationOutOfScopeReferenceError struct {
	*UnprocessableEntityError
	// Context is the detail of the error.
	Context QuotationQuotationOutOfScopeReferenceContext
}

QuotationQuotationOutOfScopeReferenceError is the error code quotations.quotation.out-of-scope-reference (422): The quotation references a customer or products outside the caller's tag scope: nothing was written.

It wraps *UnprocessableEntityError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationOutOfScopeReferenceError) Unwrap

Unwrap answers the *UnprocessableEntityError it is.

type QuotationQuotationRecipientUnsubscribedContext

type QuotationQuotationRecipientUnsubscribedContext struct {
	// The address refused (companyEmailAddress_<uuid>).
	EmailAddressID string `json:"emailAddressId"`
}

QuotationQuotationRecipientUnsubscribedContext — The detail of this error.

The context of an error code.

type QuotationQuotationRecipientUnsubscribedError

type QuotationQuotationRecipientUnsubscribedError struct {
	*APIError
	// Context is the detail of the error.
	Context QuotationQuotationRecipientUnsubscribedContext
}

QuotationQuotationRecipientUnsubscribedError is the error code quotations.quotation.recipient-unsubscribed: This address unsubscribed from the organization's e-mails: the quotation was not sent to it.

The document names no operation answering it, so it wraps *APIError directly: its Status is the one received.

func (*QuotationQuotationRecipientUnsubscribedError) Unwrap

Unwrap answers the *APIError it is.

type QuotationQuotationTransitionRefusedContext

type QuotationQuotationTransitionRefusedContext struct {
	// The quotation's status (VALIDATED, SHARED, APPROVED…).
	Status string `json:"status"`
	// The status asked (SHARED, APPROVED, CANCELED, INVOICED).
	To string `json:"to"`
}

QuotationQuotationTransitionRefusedContext — The detail of this error.

The context of an error code.

type QuotationQuotationTransitionRefusedError

type QuotationQuotationTransitionRefusedError struct {
	*ConflictError
	// Context is the detail of the error.
	Context QuotationQuotationTransitionRefusedContext
}

QuotationQuotationTransitionRefusedError is the error code quotations.quotation.transition-refused (409): The quotation's status does not lead to the one asked: a quotation is shared while VALIDATED, approved while SHARED, ordered or billed while APPROVED, and cancelled unless it was converted (ORDERED, INVOICED). Nothing was written.

It wraps *ConflictError, which wraps *APIError: errors.As matches any of the three.

func (*QuotationQuotationTransitionRefusedError) Unwrap

Unwrap answers the *ConflictError it is.

type QuotationSendParams

type QuotationSendParams struct {
	// The recipients, at least one: ids of the customer's e-mail addresses.
	To []string `json:"to"`
}

QuotationSendParams is the parameters of QuotationsService.Send (sendQuotation): its body's members. A nil *QuotationSendParams sends none.

Who to send the quotation to: ids of its customer's e-mail addresses (companyEmailAddress_<uuid>, the company's emailAddresses), never a free address.

A member of type Opt is left out unless set.

func (QuotationSendParams) MarshalJSON

func (p QuotationSendParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationStatus

type QuotationStatus string

QuotationStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: APPROVED, CANCELED, INVOICED, SHARED, ORDERED, EXPIRED, VALIDATED.

const QuotationStatusApproved QuotationStatus = "APPROVED"

QuotationStatusApproved is "APPROVED".

const QuotationStatusCanceled QuotationStatus = "CANCELED"

QuotationStatusCanceled is "CANCELED".

const QuotationStatusExpired QuotationStatus = "EXPIRED"

QuotationStatusExpired is "EXPIRED".

const QuotationStatusInvoiced QuotationStatus = "INVOICED"

QuotationStatusInvoiced is "INVOICED".

const QuotationStatusOrdered QuotationStatus = "ORDERED"

QuotationStatusOrdered is "ORDERED".

const QuotationStatusShared QuotationStatus = "SHARED"

QuotationStatusShared is "SHARED".

const QuotationStatusValidated QuotationStatus = "VALIDATED"

QuotationStatusValidated is "VALIDATED".

type QuotationStatusChange

type QuotationStatusChange struct {
	// The status it took (see the quotation's).
	Status string `json:"status"`
	// When it took it (RFC 3339, UTC).
	ChangedAt string `json:"changedAt"`
	// Who did something: a person (USER) or the robot account of an organization API key (ROBOT), which acts in the
	// key's name.
	Author *Author `json:"author"`
}

QuotationStatusChange — One status a quotation went through. author: the person or the organization key's robot that set it, or null when Myle did (its creation, the customer's answer on the public page, the validity passing).

type QuotationStatusHistoryService

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

QuotationStatusHistoryService — /organizations/{id}/quotations/{quotationId}/status-history.

Reach it as client.Organization("organization_…").Quotations.StatusHistory.

func (*QuotationStatusHistoryService) List

List — List a quotation's status history.

Returns every status a quotation went through, newest first, with when and by whom — a person, an organization key's robot, or null when Myle set it (its creation, the customer's answer on the public page, the validity passing). All at once: nextCursor is never present.

GET /organizations/{id}/quotations/{quotationId}/status-history · requires QUOTATION_LIST.

It answers a *Paginator over a single page (the quotation's statuses, newest first). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for quotationStatusChange, err := range org.Quotations.StatusHistory.List(ctx, "quotation_…").All() {
	if err != nil {
		return err
	}
	fmt.Println(quotationStatusChange)
}

type QuotationSummary

type QuotationSummary struct {
	// The quotation's id (quotation_<uuid>).
	ID string `json:"id"`
	// Always "quotation".
	Object string `json:"object"`
	// Its number.
	Number string `json:"number"`
	// Its status (see the quotation's).
	Status string `json:"status"`
	// The customer's name as the quotation froze it.
	CompanyName string `json:"companyName"`
}

QuotationSummary — A quotation, in short: enough to name it and to fetch it.

type QuotationUpdateParams

type QuotationUpdateParams struct {
	// Its date (YYYY-MM-DD).
	IssueDate Opt[string] `json:"issueDate"`
	// The last day it is valid (YYYY-MM-DD), on or after issueDate. To reopen an EXPIRED one: …/extend.
	ExpiryDate Opt[string] `json:"expiryDate"`
	// When the work it offers starts (YYYY-MM-DD); null for none.
	WorkStartDate Opt[string] `json:"workStartDate"`
	// When the work it offers ends (YYYY-MM-DD), on or after workStartDate; null for none.
	WorkEndDate Opt[string] `json:"workEndDate"`
	// A description printed on it; null for none.
	Description Opt[string] `json:"description"`
	// Its own tags, all of them; null for none.
	Tags Opt[[]string] `json:"tags"`
}

QuotationUpdateParams is the parameters of QuotationsService.Update (updateQuotation): its body's members. A nil *QuotationUpdateParams sends none.

A merge patch of a quotation (RFC 7396): an absent member is unchanged. Its lines, customer and description: POST …/edit (the description here too, in any status).

A merge patch: a member left out is unchanged, myle.Null clears it.

func (QuotationUpdateParams) MarshalJSON

func (p QuotationUpdateParams) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type QuotationsService

type QuotationsService struct {
	// StatusHistory — /organizations/{id}/quotations/{quotationId}/status-history.
	StatusHistory *QuotationStatusHistoryService
	// contains filtered or unexported fields
}

QuotationsService — the organization's quotations: the offers it makes its customers, sent, accepted or refused, extended, and billed as invoices (/organizations/{id}/quotations).

Reach it as client.Organization("organization_…").Quotations.

func (*QuotationsService) Approve

func (s *QuotationsService) Approve(ctx context.Context, quotationID string, opts ...RequestOption) (*Quotation, error)

Approve — Record that the customer accepted a quotation.

Records the customer's yes, as « Accepté » in the web app: a SHARED quotation becomes APPROVED, the one status POST …/invoice bills. An APPROVED one is answered as it is. The organization is notified (« Devis accepté »), the change audited. With If-Match, refused (412) if the quotation changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/approve · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the quotation, approved. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationTransitionRefusedError (409 quotations.quotation.transition-refused): The quotation's status does not lead to the one asked: a quotation is shared while VALIDATED, approved while SHARED, ordered or billed while APPROVED, and cancelled unless it was converted (ORDERED, INVOICED). Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Approve(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) BatchApprove

BatchApprove — Record that customers accepted several quotations.

Records the customers' yes on several quotations, each as POST …/approve does: a SHARED quotation becomes APPROVED, APPROVED already is answered as it is; one notification for the batch (« N devis acceptés »). At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED, or FAILED with its error — core.not-found, quotations.quotation.transition-refused —, the others approved all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/batch-approve · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per quotation). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Quotations.BatchApprove(ctx, &myle.QuotationBatchApproveParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*QuotationsService) BatchOrder

BatchOrder — Turn several accepted quotations into orders.

Turns several quotations into orders, each as POST …/order does: an APPROVED quotation becomes ORDERED and makes its order. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED with createdId, the order it made, or FAILED with its error — core.not-found (unknown, deleted, outside the caller's tag scope), quotations.quotation.transition-refused —, the others ordered all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/batch-order · requires QUOTATION_TRANSFORM_TO_ORDER.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per quotation, with the order it made). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResultWithCreatedID, err := range org.Quotations.BatchOrder(ctx, &myle.QuotationBatchOrderParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResultWithCreatedID.ID)
}

func (*QuotationsService) BatchShare

BatchShare — Mark several quotations as handed to their customers.

Declares several quotations handed to their customers, each as POST …/share does: a VALIDATED quotation becomes SHARED, SHARED already is answered as it is; nothing is sent. At most 1000 ids, each answered once. The answer is one result per id, in the order sent: SUCCEEDED, or FAILED with its error — core.not-found (unknown, deleted, outside the caller's tag scope), quotations.quotation.transition-refused —, the others shared all the same. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/batch-share · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per quotation). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Quotations.BatchShare(ctx, &myle.QuotationBatchShareParams{IDs: []string{"ids"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*QuotationsService) Cancel

func (s *QuotationsService) Cancel(ctx context.Context, quotationID string, opts ...RequestOption) (*Quotation, error)

Cancel — Cancel a quotation (refused or withdrawn).

Records the customer's no, or withdraws the offer, as « Refusé » in the web app: the quotation becomes CANCELED, from any status but ORDERED and INVOICED (a converted quotation: cancel or delete what it made first). A CANCELED one is answered as it is. The organization is notified (« Devis refusé »), the change audited. With If-Match, refused (412) if the quotation changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/cancel · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the quotation, cancelled. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationTransitionRefusedError (409 quotations.quotation.transition-refused): The quotation's status does not lead to the one asked: a quotation is shared while VALIDATED, approved while SHARED, ordered or billed while APPROVED, and cancelled unless it was converted (ORDERED, INVOICED). Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Cancel(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) Create

Create — Create a quotation.

Creates a quotation, as from the web app: born VALIDATED with its number (a quotation has no draft), valid until expiryDate. Without DELIVERYFORMS_CUSTOMIZE_PRICE, lines take their catalog price and no discount. The organization is notified, and the quotation is mailed at once to the customer's addresses marked « Devis » (the company's emailAddresses with QUOTATION among their purposes), as the web app does. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations · requires QUOTATION_CREATE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the new quotation. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *QuotationQuotationForeignProductError (422 quotations.quotation.foreign-product): A line names a product of another organization: nothing was written.
  • *QuotationQuotationOutOfScopeReferenceError (422 quotations.quotation.out-of-scope-reference): The quotation references a customer or products outside the caller's tag scope: nothing was written.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Create(ctx, &myle.QuotationCreateParams{CompanyID: "company_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f", Lines: []myle.QuotationLineInput{{ProductID: "product_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f", Name: "name", Quantity: "20", UnitPrice: myle.Money{Amount: "12.50", Currency: "EUR"}, VatRate: "20"}}})
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) Delete

func (s *QuotationsService) Delete(ctx context.Context, quotationID string, opts ...RequestOption) error

Delete — Delete a quotation.

Deletes a quotation, whatever its status, as the web app does — but one converted (ORDERED, INVOICED) whose order or invoice still exists (409: delete that one first; a converted quotation whose document is gone is taken back to APPROVED, then deleted). With If-Match, refused (412) if the quotation changed since it was read.

DELETE /organizations/{id}/quotations/{quotationId} · requires QUOTATION_DELETE.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers nil once done (the quotation is deleted).

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationConvertedError (409 quotations.quotation.converted): The quotation was converted and the order or the invoice it made still lives: delete that one first (its deletion takes the quotation back to APPROVED). Nothing was deleted.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Get(ctx, "quotation_…")
if err != nil {
	return err
}
err = org.Quotations.Delete(ctx, "quotation_…", myle.IfMatch(quotation))
if err != nil {
	return err
}

func (*QuotationsService) DownloadPDF

func (s *QuotationsService) DownloadPDF(ctx context.Context, quotationID string, opts ...RequestOption) (*FileDownload, error)

DownloadPDF — Get a quotation as a PDF file.

Returns a quotation the caller can see; one outside its tag scope, deleted or unknown is a 404. As JSON by default; with Accept: application/pdf, its PDF (the document Myle sends, with « accepted online » when its customer signed it on its public page).

GET /organizations/{id}/quotations/{quotationId} · requires one of QUOTATION_LIST, INVOICES_CREATE, with Accept: application/pdf.

It answers a *FileDownload: the bytes as received (Data, never decoded), Filename (from Content-Disposition, "" when none), ContentType and the Response; Save(path) writes it. An error answer is JSON as for any call, returned as the type of its code.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
file, err := org.Quotations.DownloadPDF(ctx, "quotation_…")
if err != nil {
	return err
}
if err := file.Save(cmp.Or(file.Filename, "quotation.pdf")); err != nil {
	return err
}

func (*QuotationsService) Edit

func (s *QuotationsService) Edit(ctx context.Context, quotationID string, params *QuotationEditParams, opts ...RequestOption) (*Quotation, error)

Edit — Change a quotation's lines, customer or description.

Changes what a quotation offers, as « Modifier » in the web app: its lines (the whole list: add, change, remove and reorder them in one write), its customer, its description; an absent member is unchanged. Only while it is VALIDATED and has not left the organization — not mailed (the creation mails it when the customer has an address marked « Devis »), shared by a link, read online, marked shared, converted (GET …/editability says; 409 quotations.quotation.not-editable otherwise). The write replays the creation: the price customization guard (a line kept as it was keeps its price), the tenant and tag scope guards, and a new customer's recipient and legal details. Without lines, the stored lines are kept as they are (their barcodes too), except, for a new customer, the price of a line at the previous customer's tariff: it takes the new customer's, as a creation for it would (a line at another price keeps it). A body that changes nothing writes nothing. With If-Match, refused (412) if the quotation changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/edit · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the quotation, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationNotEditableError (409 quotations.quotation.not-editable): The quotation has left the organization (mailed, shared by a link, read online, marked shared) or is no longer VALIDATED: its lines, customer and description are kept as the customer saw them; issue a new quotation. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.
  • *QuotationQuotationForeignProductError (422 quotations.quotation.foreign-product): A line names a product of another organization: nothing was written.
  • *QuotationQuotationOutOfScopeReferenceError (422 quotations.quotation.out-of-scope-reference): The quotation references a customer or products outside the caller's tag scope: nothing was written.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Edit(ctx, "quotation_…", &myle.QuotationEditParams{CompanyID: myle.String("company_0193a7c2-5b1e-7c3d-9f40-1a2b3c4d5e6f")})
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) Extend

func (s *QuotationsService) Extend(ctx context.Context, quotationID string, params *QuotationExtendParams, opts ...RequestOption) (*Quotation, error)

Extend — Extend a quotation's validity.

Gives a quotation a new « valid until » date, as « Prolonger » in the web app: one still waiting for its customer (VALIDATED, SHARED) only moves its date; an EXPIRED one also gets back the status it had before expiring. Not in the past (422); an approved, cancelled or converted quotation is refused (409). Send {} for today plus the organization's validity. The change is audited. With If-Match, refused (412) if the quotation changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/extend · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the quotation, extended. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationNotExtendableError (409 quotations.quotation.not-extendable): Only a quotation still waiting for its customer's answer (VALIDATED, SHARED) or EXPIRED gets a new validity date: an approved, cancelled or converted one has had its answer. Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Extend(ctx, "quotation_…", &myle.QuotationExtendParams{ExpiryDate: myle.String("2026-11-21")})
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) Get

func (s *QuotationsService) Get(ctx context.Context, quotationID string, opts ...RequestOption) (*Quotation, error)

Get — Get a quotation.

Returns a quotation the caller can see; one outside its tag scope, deleted or unknown is a 404. As JSON by default; with Accept: application/pdf, its PDF (the document Myle sends, with « accepted online » when its customer signed it on its public page).

The file answers have their own method: QuotationsService.DownloadPDF.

GET /organizations/{id}/quotations/{quotationId} · requires one of QUOTATION_LIST, INVOICES_CREATE.

It answers the quotation. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Get(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) GetEditability

func (s *QuotationsService) GetEditability(ctx context.Context, quotationID string, opts ...RequestOption) (*QuotationEditability, error)

GetEditability — Tell whether a quotation can still be changed.

Answers whether POST …/edit can still change the lines, the customer and the description of this quotation: editable while it is VALIDATED and has not left the organization; otherwise the reason (no longer VALIDATED, mailed, shared by a link, read online, marked shared, converted). The rule POST …/edit replays under the quotation's lock.

GET /organizations/{id}/quotations/{quotationId}/editability · requires QUOTATION_PATCH.

It answers whether the quotation can be changed.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
quotationEditability, err := org.Quotations.GetEditability(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(quotationEditability)

func (*QuotationsService) GetEligibility

GetEligibility — Count what each batch would act on.

Among the quotations the filters give (the list's filters: the caller's quotations, inside its tag scope, deleted ones never), how many each batch would act on: the counts the web app shows on its batch buttons before a batch.

GET /organizations/{id}/quotations/eligibility · requires QUOTATION_LIST.

It answers the counts.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
quotationEligibility, err := org.Quotations.GetEligibility(ctx, nil)
if err != nil {
	return err
}
fmt.Println(quotationEligibility)

func (*QuotationsService) GetNeighbors

func (s *QuotationsService) GetNeighbors(ctx context.Context, quotationID string, params *QuotationGetNeighborsParams, opts ...RequestOption) (*QuotationNeighbors, error)

GetNeighbors — Get a quotation's neighbors in the list.

Returns the quotations right before and right after this one in the quotation list read with the same filters and sort (the list's query parameters, without limit, cursor and includeTotal): next is the first quotation of the page that follows a page ending on this one, previous the one before it in that order. Each is null at an end of the list, and both are null when the filters leave the quotation out of it. The quotation must be one the caller can see (404 otherwise); its tag scope applies to the neighbors too.

GET /organizations/{id}/quotations/{quotationId}/neighbors · requires QUOTATION_LIST.

It answers the quotation's neighbors.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
quotationNeighbors, err := org.Quotations.GetNeighbors(ctx, "quotation_…", nil)
if err != nil {
	return err
}
fmt.Println(quotationNeighbors)

func (*QuotationsService) Invoice

func (s *QuotationsService) Invoice(ctx context.Context, quotationID string, opts ...RequestOption) (*Invoice, error)

Invoice — Bill an accepted quotation.

Turns an APPROVED quotation into an invoice, as « Facturer » in the web app: a VALIDATED invoice at once, with its legal number (the organization's sequence, without gaps) and today's date, its lines and tags taken from the quotation (and the customer's discount), linked both ways (the quotation lists it in invoiceIds); the quotation becomes INVOICED. Then, as from the web app, the invoice is sent the way the customer's settings say (an e-invoice through the network, or the PDF to its addresses marked « Invoice ») and booked. The same caller asking again gets the same invoice (409 when that invoice was deleted since); billed by someone else, 409. A quotation with deposit invoices is settled by its final invoice (409). Counts in the plan's invoices per month (402 once reached). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/invoice · requires QUOTATION_TRANSFORM_TO_INVOICE.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the invoice it made. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationTransitionRefusedError (409 quotations.quotation.transition-refused): The quotation's status does not lead to the one asked: a quotation is shared while VALIDATED, approved while SHARED, ordered or billed while APPROVED, and cancelled unless it was converted (ORDERED, INVOICED). Nothing was written.
  • *QuotationQuotationAlreadyInvoicedError (409 quotations.quotation.already-invoiced): Another member, key or the nightly billing billed this quotation already (the caller's own billing is answered again), or the caller's own billing made an invoice deleted since. Nothing was created.
  • *QuotationQuotationHasDepositsError (409 quotations.quotation.has-deposits): The quotation is billed in several times: deposit invoices were issued on it, and its final invoice, which deducts them, settles it; a whole invoice would bill them twice. Nothing was created.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
invoice, err := org.Quotations.Invoice(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(invoice.ID, invoice.ETag())

func (*QuotationsService) List

List — List the quotations.

Returns the organization's quotations the caller can see (its tag scope applies), deleted ones never, filtered and sorted, one page at a time. For a synchronization: updatedAfter with the largest updatedAt already seen, sort updatedAt. Open to QUOTATION_LIST, and to INVOICES_CREATE (who bills a quotation reads it).

GET /organizations/{id}/quotations · requires one of QUOTATION_LIST, INVOICES_CREATE.

It answers a *Paginator (a page of quotations): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
for quotation, err := range org.Quotations.List(ctx, &myle.QuotationListParams{Status: []myle.QuotationStatus{myle.QuotationStatusApproved}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(quotation.ID)
}

func (*QuotationsService) ListTags

func (s *QuotationsService) ListTags(ctx context.Context, opts ...RequestOption) *Paginator[string]

ListTags — List the quotations' tags.

Returns the tags the organization's quotations carry, sorted: the values a tag filter of the quotation list can take. For a tag-scoped caller, only the tags of the quotations in its scope. All of them at once: nextCursor is never present.

GET /organizations/{id}/quotations/tags · requires one of QUOTATION_LIST, INVOICES_CREATE.

It answers a *Paginator over a single page (the tags, sorted). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).

Example:

org := client.Organization("organization_…")
for tag, err := range org.Quotations.ListTags(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(tag)
}

func (*QuotationsService) Order

func (s *QuotationsService) Order(ctx context.Context, quotationID string, opts ...RequestOption) (*Order, error)

Order — Turn an accepted quotation into an order.

Turns an APPROVED quotation into an order, as « Commander » in the web app: an order born VALIDATED with its number, the quotation's lines, customer, description and tags, linked both ways (the quotation lists it in orderIds, the order the quotation in quotationIds); the quotation becomes ORDERED. The quotation's deposit invoices follow the order: its final invoice deducts them. Another status: 409 (an ORDERED quotation included: asking again makes no second order). Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/order · requires QUOTATION_TRANSFORM_TO_ORDER.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers the order it made. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationTransitionRefusedError (409 quotations.quotation.transition-refused): The quotation's status does not lead to the one asked: a quotation is shared while VALIDATED, approved while SHARED, ordered or billed while APPROVED, and cancelled unless it was converted (ORDERED, INVOICED). Nothing was written.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
order, err := org.Quotations.Order(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(order.ID, order.ETag())

func (*QuotationsService) Send

func (s *QuotationsService) Send(ctx context.Context, quotationID string, params *QuotationSendParams, opts ...RequestOption) *Paginator[ItemResult]

Send — Send a quotation by e-mail.

Sends a quotation to some of its customer's e-mail addresses, by their ids, as from the web app: the PDF attached, with the organization's letter (its link to accept the quotation online), logged and counted in its monthly e-mail quota. Nothing changes its status (POST …/share does). Synchronous: the answer is the result per recipient, in the order sent (SUCCEEDED, or FAILED with its error: quotations.quotation.recipient-unsubscribed for an address that unsubscribed, core.plan-limit-reached when the quota ran out on the way, core.internal-error when the mail could not go). Refused as a whole, sending nothing: an id that is not one of the customer's addresses (422), a quota short of the recipients (402 core.plan-limit-reached, limit emailsPerMonth). Send an Idempotency-Key to retry safely: without it, a retry sends again.

POST /organizations/{id}/quotations/{quotationId}/send · requires QUOTATION_SEND_EMAIL.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

It answers a *Paginator over a single page (the result per recipient). Nothing is sent until you iterate.

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *CorePlanLimitReachedError (402 core.plan-limit-reached): The organization's plan allows no more of what this operation creates.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
for itemResult, err := range org.Quotations.Send(ctx, "quotation_…", &myle.QuotationSendParams{To: []string{"to"}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(itemResult.ID)
}

func (*QuotationsService) Share

func (s *QuotationsService) Share(ctx context.Context, quotationID string, opts ...RequestOption) (*Quotation, error)

Share — Mark a quotation as handed to its customer.

Declares that the customer has the quotation — handed over, sent by your own e-mail or shop, by any channel —, as « Partager » in the web app: a VALIDATED quotation becomes SHARED. Nothing is sent (POST …/send mails it). A quotation SHARED already is answered as it is. The change is audited. With If-Match, refused (412) if the quotation changed since it was read. Send an Idempotency-Key to retry safely.

POST /organizations/{id}/quotations/{quotationId}/share · requires QUOTATION_PATCH.

Safe to retry: an Idempotency-Key is generated for the call and reused by its retries (give your own with myle.IdempotencyKey).

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

It answers the quotation, shared. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *QuotationQuotationTransitionRefusedError (409 quotations.quotation.transition-refused): The quotation's status does not lead to the one asked: a quotation is shared while VALIDATED, approved while SHARED, ordered or billed while APPROVED, and cancelled unless it was converted (ORDERED, INVOICED). Nothing was written.
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreIdempotencyKeyReusedError (422 core.idempotency-key-reused): This Idempotency-Key was already used for a request with another body.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Share(ctx, "quotation_…")
if err != nil {
	return err
}
fmt.Println(quotation.ID, quotation.ETag())

func (*QuotationsService) Update

func (s *QuotationsService) Update(ctx context.Context, quotationID string, params *QuotationUpdateParams, opts ...RequestOption) (*Quotation, error)

Update — Change a quotation.

Changes the members sent (a JSON merge patch): its dates, its description, its tags, whatever its status (as the web app does). The expiry date ends on or after the issue date, the work on or after its start (422). To give an EXPIRED quotation back its status, POST …/extend; its lines and customer, POST …/edit. A patch that changes nothing writes nothing. With If-Match, refused (412) if the quotation changed since it was read.

PATCH /organizations/{id}/quotations/{quotationId} · requires QUOTATION_PATCH.

Pass myle.IfMatch(resource) to change only the version you read: if it changed since, the call fails with *CorePreconditionFailedError (412) and changes nothing.

A member of params left out is unchanged; myle.Null clears it.

It answers the quotation, changed. It carries its ETag().

Errors worth handling (errors.As):

  • *CoreModuleRequiredError (402 core.module-required): The organization's plan or settings lack the module this operation belongs to.
  • *CoreSubscriptionRequiredError (402 core.subscription-required): The organization has no active paid subscription: it is read-only, it can read and export but not write.
  • *AuthRightMissingError (403 auth.right.missing): The caller lacks the right this operation requires in this organization.
  • *CoreNotFoundError (404 core.not-found): What the path names does not exist, or the caller cannot see it (the same answer for both).
  • *CorePreconditionFailedError (412 core.precondition-failed): The If-Match sent is stale: the resource has changed since.
  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

org := client.Organization("organization_…")
quotation, err := org.Quotations.Get(ctx, "quotation_…")
if err != nil {
	return err
}
updated, err := org.Quotations.Update(ctx, "quotation_…", &myle.QuotationUpdateParams{IssueDate: myle.String("2026-11-21")}, myle.IfMatch(quotation))
if err != nil {
	return err
}
fmt.Println(updated.ETag())

type RateLimitError

type RateLimitError struct{ *APIError }

RateLimitError is a 429: a rate limit of the API key is reached; already retried after Retry-After up to the client's maximum.

func (*RateLimitError) Unwrap

func (e *RateLimitError) Unwrap() error

Unwrap answers the *APIError.

type RequestOption

type RequestOption func(*requestConfig)

A RequestOption adjusts one call: pass any number of them last.

func AcceptLanguage

func AcceptLanguage(language string) RequestOption

AcceptLanguage sets the language of the error message of this call (fr or en).

func Header(name, value string) RequestOption

Header adds a header to this call (a trace id).

func IdempotencyKey

func IdempotencyKey(key string) RequestOption

IdempotencyKey sets the Idempotency-Key of a call (1 to 255 visible ASCII characters, kept 24 hours by the API). One is generated per call and reused by its retries; give your own (an order number) to make a call safe to repeat across runs. Only the operations that accept an idempotency key take it: others fail before sending.

func IfMatch

func IfMatch(version Versioned) RequestOption

IfMatch makes a call conditional (If-Match): it only happens if the resource is still at the version you read. Pass the resource as a call returned it, or ETag of a version you kept. When it changed since, the call fails with a *CorePreconditionFailedError (412) and changes nothing. A resource without an ETag sends no If-Match. Only the operations that accept If-Match take it: others fail before sending.

product, err := org.Products.Get(ctx, "product_…")
// …
updated, err := org.Products.Update(ctx, product.ID, &myle.ProductUpdateParams{Name: myle.String("Foin")}, myle.IfMatch(product))

func MaxRetries

func MaxRetries(n int) RequestOption

MaxRetries sets how many times this call is retried; the client's by default.

func Timeout

func Timeout(d time.Duration) RequestOption

Timeout sets the time an attempt of this call may take (0 for none); the client's by default.

type Response

type Response struct {
	// StatusCode is the HTTP status: 200, 201…
	StatusCode int
	// Header holds the response's headers.
	Header http.Header
	// RequestID is Myle-Request-Id, the request's id in Myle's logs: give it to support.
	RequestID string
	// IdempotentReplayed is Myle-Idempotent-Replayed: true: the answer replays an earlier call with the same
	// idempotency key.
	IdempotentReplayed bool
	// Body is the body as received (JSON members this SDK does not know yet are there).
	Body []byte
}

Response is what the HTTP response of a call said, besides the resource it carried.

type Right struct {
	// The right's name, as API keys and endpoints name it (INVOICES_LIST).
	ID string `json:"id"`
	// Always "right".
	Object string `json:"object"`
	// The family of rights it belongs to (INVOICES, COMPANIES…).
	Category string `json:"category"`
	// A text in French and in English.
	Label LocalizedText `json:"label"`
	// Whether it is a sensitive right (members, money, deletion…).
	Critical bool `json:"critical"`
	// The organization module it belongs to, which the plan must carry, or null.
	Module *string `json:"module"`
}

Right — A right of the Myle permission model, which a member or an API key holds in an organization.

type RightsService

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

RightsService — the rights of the Myle permission model, which members and API keys hold (/rights).

Reach it as client.Rights.

func (*RightsService) List

func (s *RightsService) List(ctx context.Context, opts ...RequestOption) *Paginator[Right]

List — List the rights.

Returns every right of the Myle permission model a member or an API key can hold, with its French and English labels. Public: no credential is needed.

GET /rights · public: no API key needed.

It answers a *Paginator over a single page (the rights). Nothing is sent until you iterate.

Example:

for right, err := range client.Rights.List(ctx).All() {
	if err != nil {
		return err
	}
	fmt.Println(right.ID)
}

type RoutingCandidate

type RoutingCandidate struct {
	// The address: 0225:<SIREN>, 0225:<SIREN>_<SIRET>, 0225:<SIREN>_<SIRET>_<SERVICE>….
	Identifier string `json:"identifier"`
	// Active in the directory.
	IsActive bool `json:"isActive"`
	// Registered on the network, or null when unknown.
	IsReachable *bool `json:"isReachable"`
	// The establishment's SIRET the address names, or null.
	Siret *string `json:"siret"`
	// The service code the address names (DAF, FACTURES_PUBLIQUES…), or null.
	ServiceCode *string `json:"serviceCode"`
	// A readable label (the establishment, the service), or null.
	Label *string `json:"label"`
	// The address to propose first.
	IsSuggested bool `json:"isSuggested"`
	// The address retained now.
	IsSelected bool `json:"isSelected"`
}

RoutingCandidate — An electronic address the directory publishes for the SIREN.

type SearchCompaniesService

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

SearchCompaniesService — the organization's customers: businesses, consumers and foreign clients, with their addresses and e-mail addresses (/companies).

Reach it as client.Companies.

func (*SearchCompaniesService) Search

Search — Search the companies across organizations.

Returns the customers of every organization the caller may read them in — a member with COMPANIES_LIST (a user key: among the organizations it reaches, its rights narrowed; an organization key: its own), whose plan carries the « Companies » module —, each inside the caller's tag scope there. The same filters, sort and pages as an organization's list, plus organizationId; each company says its organizationId.

GET /companies.

It answers a *Paginator (a page of companies): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

for company, err := range client.Companies.Search(ctx, nil).All() {
	if err != nil {
		return err
	}
	fmt.Println(company.ID)
}

type SearchCompanySearchParams

type SearchCompanySearchParams struct {
	// Only the organizations among these (organization_<uuid>, repeat it for several); one the caller cannot read
	// adds nothing. Each value is sent (name=a&name=b).
	OrganizationID []string `json:"-"`
	// Text searched in the name (accents and case ignored), the number and the SIREN.
	Q Opt[string] `json:"-"`
	// Companies carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value
	// is sent (name=a&name=b).
	Tag []string `json:"-"`
	// Companies changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// name (the default), number, createdAt, headquartersCity (the city of its headquarters, the companies without
	// one last) or updatedAt; with a leading - for descending (-name; -headquartersCity puts the companies without
	// a city first). Ties are broken by the company's id.
	Sort Opt[SearchCompanySearchSort] `json:"-"`
	// How the tag filter matches: ANY (the default), a company carrying one of the tags; ALL, a company carrying
	// every one of them.
	TagMode Opt[SearchCompanySearchTagMode] `json:"-"`
	// Leaves out the companies carrying every one of these tags (repeat it for several): one tag leaves out the
	// companies carrying it; with several, a company carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// Companies whose name (accents and case ignored), number, SIREN or VAT number contains these words, in this
	// order.
	NameOrIdentifier Opt[string] `json:"-"`
	// Companies with an address (headquarters, billing or delivery) whose label, street, postal code and city, put
	// end to end, contain this text, case ignored.
	Address Opt[string] `json:"-"`
	// Companies with an e-mail address or a phone number containing this text, case ignored.
	Contact Opt[string] `json:"-"`
	// Companies invoiced at this period: MONTHLY, TEN_DAYS, DAILY or DISABLED.
	InvoicingPeriod Opt[CompanyInvoicingPeriod] `json:"-"`
	// Companies created on or after this day (YYYY-MM-DD, UTC).
	CreatedAtFrom Opt[string] `json:"-"`
	// Companies created on or before this day (YYYY-MM-DD, UTC).
	CreatedAtTo Opt[string] `json:"-"`
	// true: companies with an invoice still to be paid (outstanding, partly paid or lost); false: those with none.
	HasUnpaidInvoices Opt[bool] `json:"-"`
	// true: companies with an active Boutique access; false: those without. Ignored when the caller cannot see the
	// Boutique accesses (hasShopAccess is null then).
	HasShopAccess Opt[bool] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of companies of the whole list with these filters (one more
	// count on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

SearchCompanySearchParams is the parameters of SearchCompaniesService.Search (searchCompanies): its query parameters. A nil *SearchCompanySearchParams sends none.

type SearchCompanySearchSort

type SearchCompanySearchSort string

SearchCompanySearchSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: name, -name, number, -number, createdAt, -createdAt, headquartersCity, -headquartersCity, updatedAt, -updatedAt.

const SearchCompanySearchSortCreatedAt SearchCompanySearchSort = "createdAt"

SearchCompanySearchSortCreatedAt is "createdAt".

const SearchCompanySearchSortCreatedAtDesc SearchCompanySearchSort = "-createdAt"

SearchCompanySearchSortCreatedAtDesc is "-createdAt".

const SearchCompanySearchSortHeadquartersCity SearchCompanySearchSort = "headquartersCity"

SearchCompanySearchSortHeadquartersCity is "headquartersCity".

const SearchCompanySearchSortHeadquartersCityDesc SearchCompanySearchSort = "-headquartersCity"

SearchCompanySearchSortHeadquartersCityDesc is "-headquartersCity".

const SearchCompanySearchSortName SearchCompanySearchSort = "name"

SearchCompanySearchSortName is "name".

const SearchCompanySearchSortNameDesc SearchCompanySearchSort = "-name"

SearchCompanySearchSortNameDesc is "-name".

const SearchCompanySearchSortNumber SearchCompanySearchSort = "number"

SearchCompanySearchSortNumber is "number".

const SearchCompanySearchSortNumberDesc SearchCompanySearchSort = "-number"

SearchCompanySearchSortNumberDesc is "-number".

const SearchCompanySearchSortUpdatedAt SearchCompanySearchSort = "updatedAt"

SearchCompanySearchSortUpdatedAt is "updatedAt".

const SearchCompanySearchSortUpdatedAtDesc SearchCompanySearchSort = "-updatedAt"

SearchCompanySearchSortUpdatedAtDesc is "-updatedAt".

type SearchCompanySearchTagMode

type SearchCompanySearchTagMode string

SearchCompanySearchTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const SearchCompanySearchTagModeAll SearchCompanySearchTagMode = "ALL"

SearchCompanySearchTagModeAll is "ALL".

const SearchCompanySearchTagModeAny SearchCompanySearchTagMode = "ANY"

SearchCompanySearchTagModeAny is "ANY".

type SearchInvoiceSearchParams

type SearchInvoiceSearchParams struct {
	// Only the organizations among these (organization_<uuid>, repeat it for several); one the caller cannot read
	// adds nothing. Each value is sent (name=a&name=b).
	OrganizationID []string `json:"-"`
	// Invoices of one of these statuses (repeat it for several): DRAFT, VALIDATED, UNPAID, PAID…. Each value is
	// sent (name=a&name=b).
	Status []InvoiceStatus `json:"-"`
	// Invoices of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Invoices issued on or after this date (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Invoices issued on or before this date (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Invoices due on or after this date (YYYY-MM-DD).
	DueDateFrom Opt[string] `json:"-"`
	// Invoices due on or before this date (YYYY-MM-DD).
	DueDateTo Opt[string] `json:"-"`
	// Invoices changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Invoices carrying one of these tags (repeat it for several). Each value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// -createdAt (the default), createdAt, updatedAt or -updatedAt.
	Sort Opt[SearchInvoiceSearchSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
}

SearchInvoiceSearchParams is the parameters of SearchInvoicesService.Search (searchInvoices): its query parameters. A nil *SearchInvoiceSearchParams sends none.

type SearchInvoiceSearchSort

type SearchInvoiceSearchSort string

SearchInvoiceSearchSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: -createdAt, createdAt, updatedAt, -updatedAt.

const SearchInvoiceSearchSortCreatedAt SearchInvoiceSearchSort = "createdAt"

SearchInvoiceSearchSortCreatedAt is "createdAt".

const SearchInvoiceSearchSortCreatedAtDesc SearchInvoiceSearchSort = "-createdAt"

SearchInvoiceSearchSortCreatedAtDesc is "-createdAt".

const SearchInvoiceSearchSortUpdatedAt SearchInvoiceSearchSort = "updatedAt"

SearchInvoiceSearchSortUpdatedAt is "updatedAt".

const SearchInvoiceSearchSortUpdatedAtDesc SearchInvoiceSearchSort = "-updatedAt"

SearchInvoiceSearchSortUpdatedAtDesc is "-updatedAt".

type SearchInvoicesService

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

SearchInvoicesService — the organization's sales invoices: drafts, their validation (the legal number), their PDF and Factur-X (/invoices).

Reach it as client.Invoices.

func (*SearchInvoicesService) Search

Search — Search the invoices across organizations.

Returns the invoices of every organization the caller may read them in — a member with INVOICES_LIST (a user key: among the organizations it reaches, its rights narrowed; an organization key: its own), whose plan carries the « Invoices » module —, each inside the caller's tag scope there, drafts included, deleted ones never. The same filters, sort and pages as an organization's list, plus organizationId; each invoice says its organizationId.

GET /invoices.

It answers a *Paginator (a page of invoices): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

for invoice, err := range client.Invoices.Search(ctx, &myle.SearchInvoiceSearchParams{Status: []myle.InvoiceStatus{myle.InvoiceStatusUnpaid}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(invoice.ID)
}

type SearchOrderSearchParams

type SearchOrderSearchParams struct {
	// Only the organizations among these (organization_<uuid>, repeat it for several); one the caller cannot read
	// adds nothing. Each value is sent (name=a&name=b).
	OrganizationID []string `json:"-"`
	// Orders of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, WAITING_FOR_DELIVERY,
	// DELIVERED, INVOICED, CANCELED, ORDERED. Each value is sent (name=a&name=b).
	Status []OrderStatus `json:"-"`
	// Orders of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Orders dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Orders dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Orders to deliver on or after this day (YYYY-MM-DD).
	DeliveryDateFrom Opt[string] `json:"-"`
	// Orders to deliver on or before this day (YYYY-MM-DD).
	DeliveryDateTo Opt[string] `json:"-"`
	// Orders one of these members prepares (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	PreparerID []string `json:"-"`
	// Orders one of these members delivers (user_<uuid>, robot_<uuid>; repeat it for several). Each value is sent
	// (name=a&name=b).
	DelivererID []string `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Orders changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Orders carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value is
	// sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), an order carrying one of the tags; ALL, an order carrying
	// every one of them.
	TagMode Opt[SearchOrderSearchTagMode] `json:"-"`
	// Leaves out the orders carrying every one of these tags (repeat it for several): one tag leaves out the orders
	// carrying it; with several, an order carrying only some of them stays. Each value is sent (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// -number (the default, the newest first), number, createdAt, updatedAt or issueDate; with a leading - for
	// descending. Ties are broken by the order's id.
	Sort Opt[SearchOrderSearchSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of orders of the whole list with these filters (one more count
	// on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

SearchOrderSearchParams is the parameters of SearchOrdersService.Search (searchOrders): its query parameters. A nil *SearchOrderSearchParams sends none.

type SearchOrderSearchSort

type SearchOrderSearchSort string

SearchOrderSearchSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: -number, number, -createdAt, createdAt, updatedAt, -updatedAt, -issueDate, issueDate.

const SearchOrderSearchSortCreatedAt SearchOrderSearchSort = "createdAt"

SearchOrderSearchSortCreatedAt is "createdAt".

const SearchOrderSearchSortCreatedAtDesc SearchOrderSearchSort = "-createdAt"

SearchOrderSearchSortCreatedAtDesc is "-createdAt".

const SearchOrderSearchSortIssueDate SearchOrderSearchSort = "issueDate"

SearchOrderSearchSortIssueDate is "issueDate".

const SearchOrderSearchSortIssueDateDesc SearchOrderSearchSort = "-issueDate"

SearchOrderSearchSortIssueDateDesc is "-issueDate".

const SearchOrderSearchSortNumber SearchOrderSearchSort = "number"

SearchOrderSearchSortNumber is "number".

const SearchOrderSearchSortNumberDesc SearchOrderSearchSort = "-number"

SearchOrderSearchSortNumberDesc is "-number".

const SearchOrderSearchSortUpdatedAt SearchOrderSearchSort = "updatedAt"

SearchOrderSearchSortUpdatedAt is "updatedAt".

const SearchOrderSearchSortUpdatedAtDesc SearchOrderSearchSort = "-updatedAt"

SearchOrderSearchSortUpdatedAtDesc is "-updatedAt".

type SearchOrderSearchTagMode

type SearchOrderSearchTagMode string

SearchOrderSearchTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const SearchOrderSearchTagModeAll SearchOrderSearchTagMode = "ALL"

SearchOrderSearchTagModeAll is "ALL".

const SearchOrderSearchTagModeAny SearchOrderSearchTagMode = "ANY"

SearchOrderSearchTagModeAny is "ANY".

type SearchOrdersService

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

SearchOrdersService — the organization's orders: what its customers order, confirmed, prepared, delivered (with the stock lots the goods leave from) and billed (/orders).

Reach it as client.Orders.

func (*SearchOrdersService) Search

Search — Search the orders across organizations.

Returns the orders of every organization the caller may read them in — a member with ORDER_LIST, QUOTATION_LIST or INVOICES_CREATE (a user key: among the organizations it reaches, its rights narrowed; an organization key: its own), whose plan carries the « Orders » module —, each inside the caller's tag scope there and, where it lacks ORDER_LIST_ALL, among the orders it created, prepares or delivers; deleted ones never. The same filters, sort and pages as an organization's list, plus organizationId; each order says its organizationId.

GET /orders.

It answers a *Paginator (a page of orders): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

for order, err := range client.Orders.Search(ctx, &myle.SearchOrderSearchParams{Status: []myle.OrderStatus{myle.OrderStatusApproved}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(order.ID)
}

type SearchProductSearchParams

type SearchProductSearchParams struct {
	// Only the organizations among these (organization_<uuid>, repeat it for several); one the caller cannot read
	// adds nothing. Each value is sent (name=a&name=b).
	OrganizationID []string `json:"-"`
	// Text searched in the name and the number, accents and case ignored.
	Q Opt[string] `json:"-"`
	// Products of one of these statuses (repeat it for several): ACTIVE. Each value is sent (name=a&name=b).
	Status []ProductStatus `json:"-"`
	// Products carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each value
	// is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a product carrying one of the tags; ALL, a product carrying
	// every one of them.
	TagMode Opt[SearchProductSearchTagMode] `json:"-"`
	// Leaves out the products carrying every one of these tags (repeat it for several): one tag leaves out the
	// products carrying it; with several, a product carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// Products carrying this barcode, exactly.
	Barcode Opt[string] `json:"-"`
	// Products changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Products whose name contains these words, in this order, accents and case ignored.
	Name Opt[string] `json:"-"`
	// Products whose number contains this text, case ignored.
	Number Opt[string] `json:"-"`
	// Products whose accounting account contains this text, case ignored.
	AccountingNumber Opt[string] `json:"-"`
	// Products created by this person (user_<uuid>) or this organization key's robot (robot_<uuid>).
	CreatedBy Opt[string] `json:"-"`
	// Products whose author's name (first name and last name) contains this text, case ignored.
	CreatedByName Opt[string] `json:"-"`
	// true: products carrying at least one barcode; false: products carrying none.
	HasBarcode Opt[bool] `json:"-"`
	// name (the default), number, accountingNumber, createdAt or updatedAt; with a leading - for descending
	// (-name). Ties are broken by the product's id.
	Sort Opt[SearchProductSearchSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of products of the whole list with these filters (one more
	// count on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

SearchProductSearchParams is the parameters of SearchProductsService.Search (searchProducts): its query parameters. A nil *SearchProductSearchParams sends none.

type SearchProductSearchSort

type SearchProductSearchSort string

SearchProductSearchSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: name, -name, number, -number, accountingNumber, -accountingNumber, createdAt, -createdAt, updatedAt, -updatedAt.

const SearchProductSearchSortAccountingNumber SearchProductSearchSort = "accountingNumber"

SearchProductSearchSortAccountingNumber is "accountingNumber".

const SearchProductSearchSortAccountingNumberDesc SearchProductSearchSort = "-accountingNumber"

SearchProductSearchSortAccountingNumberDesc is "-accountingNumber".

const SearchProductSearchSortCreatedAt SearchProductSearchSort = "createdAt"

SearchProductSearchSortCreatedAt is "createdAt".

const SearchProductSearchSortCreatedAtDesc SearchProductSearchSort = "-createdAt"

SearchProductSearchSortCreatedAtDesc is "-createdAt".

const SearchProductSearchSortName SearchProductSearchSort = "name"

SearchProductSearchSortName is "name".

const SearchProductSearchSortNameDesc SearchProductSearchSort = "-name"

SearchProductSearchSortNameDesc is "-name".

const SearchProductSearchSortNumber SearchProductSearchSort = "number"

SearchProductSearchSortNumber is "number".

const SearchProductSearchSortNumberDesc SearchProductSearchSort = "-number"

SearchProductSearchSortNumberDesc is "-number".

const SearchProductSearchSortUpdatedAt SearchProductSearchSort = "updatedAt"

SearchProductSearchSortUpdatedAt is "updatedAt".

const SearchProductSearchSortUpdatedAtDesc SearchProductSearchSort = "-updatedAt"

SearchProductSearchSortUpdatedAtDesc is "-updatedAt".

type SearchProductSearchTagMode

type SearchProductSearchTagMode string

SearchProductSearchTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const SearchProductSearchTagModeAll SearchProductSearchTagMode = "ALL"

SearchProductSearchTagModeAll is "ALL".

const SearchProductSearchTagModeAny SearchProductSearchTagMode = "ANY"

SearchProductSearchTagModeAny is "ANY".

type SearchProductsService

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

SearchProductsService — the organization's catalog: the products and services it sells, with their prices and barcodes (/products).

Reach it as client.Products.

func (*SearchProductsService) Search

Search — Search the products across organizations.

Returns the products of every organization the caller may read them in — a member with ARTICLES_LIST (a user key: among the organizations it reaches, its rights narrowed; an organization key: its own), whose plan carries the « Products » module —, each inside the caller's tag scope there. The same filters, sort and pages as an organization's list, plus organizationId; each product says its organizationId.

GET /products.

It answers a *Paginator (a page of products): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

for product, err := range client.Products.Search(ctx, &myle.SearchProductSearchParams{Status: []myle.ProductStatus{myle.ProductStatusActive}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(product.ID)
}

type SearchQuotationSearchParams

type SearchQuotationSearchParams struct {
	// Only the organizations among these (organization_<uuid>, repeat it for several); one the caller cannot read
	// adds nothing. Each value is sent (name=a&name=b).
	OrganizationID []string `json:"-"`
	// Quotations of one of these statuses (repeat it for several): VALIDATED, SHARED, APPROVED, CANCELED, EXPIRED,
	// ORDERED, INVOICED. Each value is sent (name=a&name=b).
	Status []QuotationStatus `json:"-"`
	// Quotations of one of these customers (company_<uuid>). Each value is sent (name=a&name=b).
	CompanyID []string `json:"-"`
	// Quotations dated on or after this day (YYYY-MM-DD).
	IssueDateFrom Opt[string] `json:"-"`
	// Quotations dated on or before this day (YYYY-MM-DD).
	IssueDateTo Opt[string] `json:"-"`
	// Quotations valid until this day or later (YYYY-MM-DD).
	ExpiryDateFrom Opt[string] `json:"-"`
	// Quotations valid until this day at the latest (YYYY-MM-DD).
	ExpiryDateTo Opt[string] `json:"-"`
	// Text searched in the number and in the customer's name (accents and case ignored).
	Q Opt[string] `json:"-"`
	// Quotations changed strictly after this instant (RFC 3339): the delta of a synchronization.
	UpdatedAfter Opt[string] `json:"-"`
	// Quotations carrying one of these tags (repeat it for several); with tagMode=ALL, every one of them. Each
	// value is sent (name=a&name=b).
	Tag []string `json:"-"`
	// How the tag filter matches: ANY (the default), a quotation carrying one of the tags; ALL, a quotation
	// carrying every one of them.
	TagMode Opt[SearchQuotationSearchTagMode] `json:"-"`
	// Leaves out the quotations carrying every one of these tags (repeat it for several): one tag leaves out the
	// quotations carrying it; with several, a quotation carrying only some of them stays. Each value is sent
	// (name=a&name=b).
	ExcludeTag []string `json:"-"`
	// -number (the default, the newest first), number, createdAt, updatedAt or issueDate; with a leading - for
	// descending. Ties are broken by the quotation's id.
	Sort Opt[SearchQuotationSearchSort] `json:"-"`
	// The page size, 50 by default, 200 at most.
	Limit Opt[int] `json:"-"`
	// The nextCursor of the previous page. The paginator starts there, then follows nextCursor.
	Cursor Opt[string] `json:"-"`
	// true: the answer gives totalCount, the number of quotations of the whole list with these filters (one more
	// count on the server); absent or false: it does not.
	IncludeTotal Opt[bool] `json:"-"`
}

SearchQuotationSearchParams is the parameters of SearchQuotationsService.Search (searchQuotations): its query parameters. A nil *SearchQuotationSearchParams sends none.

type SearchQuotationSearchSort

type SearchQuotationSearchSort string

SearchQuotationSearchSort is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: -number, number, -createdAt, createdAt, updatedAt, -updatedAt, -issueDate, issueDate.

const SearchQuotationSearchSortCreatedAt SearchQuotationSearchSort = "createdAt"

SearchQuotationSearchSortCreatedAt is "createdAt".

const SearchQuotationSearchSortCreatedAtDesc SearchQuotationSearchSort = "-createdAt"

SearchQuotationSearchSortCreatedAtDesc is "-createdAt".

const SearchQuotationSearchSortIssueDate SearchQuotationSearchSort = "issueDate"

SearchQuotationSearchSortIssueDate is "issueDate".

const SearchQuotationSearchSortIssueDateDesc SearchQuotationSearchSort = "-issueDate"

SearchQuotationSearchSortIssueDateDesc is "-issueDate".

const SearchQuotationSearchSortNumber SearchQuotationSearchSort = "number"

SearchQuotationSearchSortNumber is "number".

const SearchQuotationSearchSortNumberDesc SearchQuotationSearchSort = "-number"

SearchQuotationSearchSortNumberDesc is "-number".

const SearchQuotationSearchSortUpdatedAt SearchQuotationSearchSort = "updatedAt"

SearchQuotationSearchSortUpdatedAt is "updatedAt".

const SearchQuotationSearchSortUpdatedAtDesc SearchQuotationSearchSort = "-updatedAt"

SearchQuotationSearchSortUpdatedAtDesc is "-updatedAt".

type SearchQuotationSearchTagMode

type SearchQuotationSearchTagMode string

SearchQuotationSearchTagMode is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ANY, ALL.

const SearchQuotationSearchTagModeAll SearchQuotationSearchTagMode = "ALL"

SearchQuotationSearchTagModeAll is "ALL".

const SearchQuotationSearchTagModeAny SearchQuotationSearchTagMode = "ANY"

SearchQuotationSearchTagModeAny is "ANY".

type SearchQuotationsService

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

SearchQuotationsService — the organization's quotations: the offers it makes its customers, sent, accepted or refused, extended, and billed as invoices (/quotations).

Reach it as client.Quotations.

func (*SearchQuotationsService) Search

Search — Search the quotations across organizations.

Returns the quotations of every organization the caller may read them in — a member with QUOTATION_LIST or INVOICES_CREATE (a user key: among the organizations it reaches, its rights narrowed; an organization key: its own), whose plan carries the « Quotations » module —, each inside the caller's tag scope there, deleted ones never. The same filters, sort and pages as an organization's list, plus organizationId; each quotation says its organizationId.

GET /quotations.

It answers a *Paginator (a page of quotations): range over All() for every item, page after page; FirstPage for one page; CollectMax for the first ones. Nothing is sent until then.

Errors worth handling (errors.As):

  • *CoreValidationFailedError (422 core.validation-failed): Fields of the request are invalid.

Example:

for quotation, err := range client.Quotations.Search(ctx, &myle.SearchQuotationSearchParams{Status: []myle.QuotationStatus{myle.QuotationStatusApproved}}).All() {
	if err != nil {
		return err
	}
	fmt.Println(quotation.ID)
}

type SepaBankAccount

type SepaBankAccount struct {
	// The IBAN's last four digits.
	Last4 string `json:"last4"`
	// The bank's code.
	BankCode string `json:"bankCode"`
	// The bank's country (FR).
	Country string `json:"country"`
}

SepaBankAccount — The bank account a mandate debits.

type SepaFee

type SepaFee struct {
	// Always "sepaFee".
	Object string `json:"object"`
	// The invoice debited (invoice_<uuid>).
	InvoiceID string `json:"invoiceId"`
	// SEPA_COLLECTION (a debit), STRIPE_DISPUTE_FEE (Stripe's fee on a dispute); an open enum.
	Kind string `json:"kind"`
	// What was debited.
	Amount Money `json:"amount"`
	// Everything withheld (stripeFee, Stripe's, plus myleFee, Myle's commission incl.
	Fee Money `json:"fee"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	StripeFee Money `json:"stripeFee"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	MyleFee Money `json:"myleFee"`
	// Myle invoiced its commission (the monthly commission invoice).
	IsBilled bool `json:"isBilled"`
	// When it was invoiced (RFC 3339, UTC), or null.
	BilledAt *string `json:"billedAt"`
	// When the debit started (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
}

SepaFee — The fee of one SEPA debit. amount: what was debited; fee: everything withheld (stripeFee, Stripe's, plus myleFee, Myle's commission incl. VAT); all in EUR.

type SepaFeeRates

type SepaFeeRates struct {
	// An amount of money: a decimal string and its ISO 4217 currency.
	StripeFee Money `json:"stripeFee"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	MyleFixedFee Money `json:"myleFixedFee"`
	// Myle's commission on the amount debited, in percent ("0.3"), added to its fixed part.
	MyleVariablePercentage string `json:"myleVariablePercentage"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	MyleMaxFee Money `json:"myleMaxFee"`
	// The VAT rate Myle's commission includes, in percent ("20").
	MyleVatRate string `json:"myleVatRate"`
}

SepaFeeRates — What a debit costs, in EUR: stripeFee (Stripe's, per debit), myleFixedFee plus the percentage of the amount, at most myleMaxFee (Myle's, VAT included).

type SepaMandate

type SepaMandate struct {
	// Always "sepaMandate".
	Object string `json:"object"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// ACTIVE: the customer signed a mandate the organization may debit; NONE: none (an open enum).
	Status SepaMandateStatus `json:"status"`
	// The mandate's reference, or null.
	Reference *string `json:"reference"`
	// The mandate's page at Stripe (what the customer signed), or null.
	MandateURL *string `json:"mandateUrl"`
	// When the customer accepted it (RFC 3339, UTC), or null.
	AcceptedAt *string `json:"acceptedAt"`
	// The account it debits, null when there is none.
	BankAccount *SepaBankAccount `json:"bankAccount"`
	// The customer's validated invoices are debited automatically (the SEPA:AUTO-PRÉLÈVEMENT tag); changed by PATCH
	// …/companies/{companyId} autoDebit.
	AutoDebit bool `json:"autoDebit"`
	// contains filtered or unexported fields
}

SepaMandate — A customer's SEPA mandate. bankAccount: the account it debits, null when there is none.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (SepaMandate) ETag

func (m SepaMandate) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (SepaMandate) LastResponse

func (m SepaMandate) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type SepaMandateInvitation

type SepaMandateInvitation struct {
	// Always "sepaMandateInvitation".
	Object string `json:"object"`
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// The address the invitation is for, which Stripe puts on the mandate.
	Email string `json:"email"`
	// It was mailed to that address.
	IsSent bool `json:"isSent"`
	// The link the customer signs at (single use), to share yourself; null when it was mailed.
	URL *string `json:"url"`
	// When the link expires (RFC 3339, UTC).
	ExpiresAt string `json:"expiresAt"`
	// contains filtered or unexported fields
}

SepaMandateInvitation — An invitation to sign a SEPA mandate.

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (SepaMandateInvitation) ETag

func (m SepaMandateInvitation) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (SepaMandateInvitation) LastResponse

func (m SepaMandateInvitation) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type SepaMandateStatus

type SepaMandateStatus string

SepaMandateStatus is an enum of the API, open: a value this SDK does not know yet may arrive, tolerate it. Its values: ACTIVE, NONE.

const SepaMandateStatusActive SepaMandateStatus = "ACTIVE"

SepaMandateStatusActive is "ACTIVE".

const SepaMandateStatusNone SepaMandateStatus = "NONE"

SepaMandateStatusNone is "NONE".

type SepaQuota

type SepaQuota struct {
	// Always "sepaQuota".
	Object string `json:"object"`
	// The rolling window, in days.
	WindowDays int `json:"windowDays"`
	// A quota. maxAmount: at most this much debited, in EUR.
	PerCompany SepaQuotaLimit `json:"perCompany"`
	// A quota. maxAmount: at most this much debited, in EUR.
	PerOrganization SepaQuotaLimit `json:"perOrganization"`
	// How many debits the organization made over the window.
	Count int `json:"count"`
	// What the organization was debited over it; minimumDebit, maximumDebit: the bounds of one debit (EUR).
	Amount Money `json:"amount"`
	// What each customer was debited over the window.
	Companies []SepaQuotaCompanyUsage `json:"companies"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	MinimumDebit Money `json:"minimumDebit"`
	// An amount of money: a decimal string and its ISO 4217 currency.
	MaximumDebit Money `json:"maximumDebit"`
	// What blocks every debit of the organization, whatever the invoice: DEMO, COLLECTION_PAUSED, PLAN_REQUIRED,
	// NOT_CONNECTED, COLLECTION_DISABLED, ACCOUNT_SUSPENDED (an open enum), or null.
	BlockedReason *string `json:"blockedReason"`
	// What a debit costs, in EUR: stripeFee (Stripe's, per debit), myleFixedFee plus the percentage of the amount,
	// at most myleMaxFee (Myle's, VAT included).
	Fees SepaFeeRates `json:"fees"`
	// contains filtered or unexported fields
}

SepaQuota — The organization's SEPA quota. perCompany, perOrganization: the quotas over the window; amount: what the organization was debited over it; minimumDebit, maximumDebit: the bounds of one debit (EUR).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (SepaQuota) ETag

func (m SepaQuota) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (SepaQuota) LastResponse

func (m SepaQuota) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type SepaQuotaCompanyUsage

type SepaQuotaCompanyUsage struct {
	// The customer (company_<uuid>).
	CompanyID string `json:"companyId"`
	// How many debits.
	Count int `json:"count"`
	// In EUR.
	Amount Money `json:"amount"`
}

SepaQuotaCompanyUsage — What one customer was debited. amount: in EUR.

type SepaQuotaLimit

type SepaQuotaLimit struct {
	// At most this many debits.
	MaxCount int `json:"maxCount"`
	// At most this much debited, in EUR.
	MaxAmount Money `json:"maxAmount"`
}

SepaQuotaLimit — A quota. maxAmount: at most this much debited, in EUR.

type ServiceUnavailableError

type ServiceUnavailableError struct{ *InternalServerError }

ServiceUnavailableError is a 503: the API or a service it relies on is unavailable.

func (*ServiceUnavailableError) Unwrap

func (e *ServiceUnavailableError) Unwrap() error

Unwrap answers the *InternalServerError it is.

type ShelfLife

type ShelfLife struct {
	// One of the dates a product's goods carry: whether the documents' lines give it, and its default delay.
	UseBy ShelfLifeDate `json:"useBy"`
	// One of the dates a product's goods carry: whether the documents' lines give it, and its default delay.
	ConsumeBefore ShelfLifeDate `json:"consumeBefore"`
	// One of the dates a product's goods carry: whether the documents' lines give it, and its default delay.
	BestBefore ShelfLifeDate `json:"bestBefore"`
}

ShelfLife — The dates a product's goods carry (French food labelling): useBy, the « date limite de consommation » (DLC); consumeBefore, the « date de consommation recommandée » (DCR); bestBefore, the « date de durabilité minimale » (DDM).

type ShelfLifeDate

type ShelfLifeDate struct {
	// Whether the lines of a document (quotation, order, delivery note, invoice) for this product carry this date.
	IsEnabled bool `json:"isEnabled"`
	// Its default delay in days: the date a line proposes is the document's date plus this many days; null for
	// none.
	Days *int `json:"days"`
}

ShelfLifeDate — One of the dates a product's goods carry: whether the documents' lines give it, and its default delay.

type ShelfLifeDateInput

type ShelfLifeDateInput struct {
	// Whether the lines of a document for this product carry this date.
	IsEnabled Opt[bool] `json:"isEnabled"`
	// Its default delay in days, an integer from 0: the date a line proposes is the document's date plus this many
	// days; null for none.
	Days Opt[int] `json:"days"`
}

ShelfLifeDateInput — One of a product's shelf-life dates. On a creation, an absent member takes its default (disabled, no delay); on a change (merge patch), an absent member is unchanged. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (ShelfLifeDateInput) MarshalJSON

func (p ShelfLifeDateInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type ShelfLifeInput

type ShelfLifeInput struct {
	// One of a product's shelf-life dates. On a creation, an absent member takes its default (disabled, no delay);
	// on a change (merge patch), an absent member is unchanged.
	UseBy Opt[ShelfLifeDateInput] `json:"useBy"`
	// One of a product's shelf-life dates. On a creation, an absent member takes its default (disabled, no delay);
	// on a change (merge patch), an absent member is unchanged.
	ConsumeBefore Opt[ShelfLifeDateInput] `json:"consumeBefore"`
	// One of a product's shelf-life dates. On a creation, an absent member takes its default (disabled, no delay);
	// on a change (merge patch), an absent member is unchanged.
	BestBefore Opt[ShelfLifeDateInput] `json:"bestBefore"`
}

ShelfLifeInput — The dates a product's goods carry: useBy (DLC), consumeBefore (DCR), bestBefore (DDM). An absent date is unchanged (a change) or disabled without a delay (a creation). (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (ShelfLifeInput) MarshalJSON

func (p ShelfLifeInput) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type StockLot

type StockLot struct {
	// Its number (traceability code): send it as a lot's lotNumber.
	LotNumber string `json:"lotNumber"`
	// The start of its best-before period (YYYY-MM-DD), or null.
	BestBeforeDate *string `json:"bestBeforeDate"`
	// What it can still give, a decimal string.
	Available string `json:"available"`
	// What was recorded into it, a decimal string.
	Recorded string `json:"recorded"`
}

StockLot — A lot of a stock that can still give goods.

type TimeoutError

type TimeoutError struct {
	*ConnectionError
	// Timeout is the time the attempt was given.
	Timeout time.Duration
}

TimeoutError is an attempt that got no answer within the timeout of the client or of the call.

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

func (*TimeoutError) Unwrap

func (e *TimeoutError) Unwrap() error

Unwrap answers the *ConnectionError it is.

type UnprocessableEntityError

type UnprocessableEntityError struct{ *APIError }

UnprocessableEntityError is a 422: fields of the request are invalid, or an idempotency key was reused with another body.

func (*UnprocessableEntityError) Unwrap

func (e *UnprocessableEntityError) Unwrap() error

Unwrap answers the *APIError.

type UnsupportedMediaTypeError

type UnsupportedMediaTypeError struct{ *APIError }

UnsupportedMediaTypeError is a 415: the body's media type is not accepted.

func (*UnsupportedMediaTypeError) Unwrap

func (e *UnsupportedMediaTypeError) Unwrap() error

Unwrap answers the *APIError.

type UpdateOrderDelivery

type UpdateOrderDelivery struct {
	// When it is to be delivered (YYYY-MM-DD); null for none.
	Date Opt[string] `json:"date"`
	// The member who prepares it (user_<uuid>, robot_<uuid>); null for none.
	PreparerID Opt[string] `json:"preparerId"`
	// The member who delivers it (user_<uuid>, robot_<uuid>); null for none.
	DelivererID Opt[string] `json:"delivererId"`
}

UpdateOrderDelivery — A merge patch of an order's delivery: an absent member is unchanged, null clears it. Its address: POST …/edit. (as sent in a request)

A member of type Opt is left out unless set; myle.Null sends null.

func (UpdateOrderDelivery) MarshalJSON

func (p UpdateOrderDelivery) MarshalJSON() ([]byte, error)

MarshalJSON writes the body: the members given, in the document's order.

type User

type User struct {
	// The user's id (user_<uuid>), or robot_<uuid> for an organization key's robot account.
	ID string `json:"id"`
	// "user", or "robot" for an organization key's robot account.
	Object string `json:"object"`
	// The e-mail address the user signs in with.
	Email string `json:"email"`
	// First name.
	FirstName string `json:"firstName"`
	// Last name.
	LastName string `json:"lastName"`
	// When the account was created (RFC 3339, UTC).
	CreatedAt string `json:"createdAt"`
	// contains filtered or unexported fields
}

User — The signed-in user; for an organization key, its robot account (object robot, an e-mail address that is never routable, the key's name as firstName).

A call returning it sets its ETag() (for myle.IfMatch) and LastResponse(); a member null in the answer is nil.

func (User) ETag

func (m User) ETag() string

ETag answers the ETag of this version of the resource, for IfMatch; "" when the API sent none.

func (User) LastResponse

func (m User) LastResponse() *Response

LastResponse answers the HTTP response this resource came in (nil for a resource built by hand).

type Versioned

type Versioned interface {
	// ETag answers the version's ETag, "" when unknown.
	ETag() string
}

Versioned is a version of a resource, as IfMatch takes it: a resource a call returned, or an ETag.

Jump to

Keyboard shortcuts

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