archera

package
v0.0.0-...-a99bcb5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: OSL-3.0 Imports: 17 Imported by: 0 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.

Documentation

Overview

Package archera wires the explicit Archera comparison (pkg/insurance) into the server. The surface is off unless all three settings are present, and the API key is resolved lazily on the first explicit request.

Index

Constants

View Source
const (
	EnvOrgID     = "ARCHERA_ORG_ID"
	EnvPlanID    = "ARCHERA_PLAN_ID"
	EnvKeySecret = "ARCHERA_API_KEY_SECRET" // #nosec G101 -- setting name, not a credential value
)

Setting names, shared with the CLI and MCP consumers.

View Source
const (
	CandidateVendorAlternative = insurance.CandidateVendorAlternative
	CandidateUnavailable       = insurance.CandidateUnavailable
)
View Source
const (
	MatchUnavailable   = insurance.MatchUnavailable
	ResourceAssociated = insurance.ResourceAssociated

	ReasonIdentityUnproven           = insurance.ReasonIdentityUnproven
	ReasonAmbiguousLineItems         = insurance.ReasonAmbiguousLineItems
	ReasonComparisonBasisUnproven    = insurance.ReasonComparisonBasisUnproven
	ReasonCandidateBasisUnproven     = insurance.ReasonCandidateBasisUnproven
	ReasonStoredDecimalOnly          = insurance.ReasonStoredDecimalOnly
	ReasonUnavailableSourcePrecision = insurance.ReasonUnavailableSourcePrecision

	SelectOne       = insurance.SelectOne
	SelectNone      = insurance.SelectNone
	SelectAmbiguous = insurance.SelectAmbiguous
)

Variables

View Source
var ErrKeyUnavailable = errors.New("archera API key could not be resolved from " + EnvKeySecret)

ErrKeyUnavailable is returned when the API key secret cannot be resolved or yields an unusable client. The message is fixed so no vendor or secret text can reach a response.

View Source
var ErrNotConfigured = errors.New("archera comparison is not configured")

ErrNotConfigured is returned (wrapped, naming the missing settings) when an explicit request arrives and one or more settings are absent.

View Source
var ErrRecommendationIdentity = errors.New("stored recommendation identity is unavailable")

ErrRecommendationIdentity means a stored recommendation cannot be proven to be a supported savings plan.

View Source
var ErrUnrepresentable = insurance.ErrUnrepresentable

ErrUnrepresentable is returned when a vendor number has no exact finite decimal form (the DTO never rounds or converts to float).

Functions

func CleanString

func CleanString(s string) string

CleanString removes control, format and line/paragraph-separator characters from vendor text and caps it at 256 bytes on a rune boundary.

func Decimal

func Decimal(r *big.Rat) (*string, error)

Decimal renders r as the shortest exact decimal string. nil (unknown) stays nil.

func EqualRecommendationIdentity

func EqualRecommendationIdentity(r, o *RecommendationIdentity) bool

EqualRecommendationIdentity reports whether both identities are non-nil and agree on every projected field.

func ProjectContract

func ProjectContract(c *insurance.Comparison, items []insurance.LineItem) (rows []ComparisonIdentity, identities []LineItemIdentity, err error)

ProjectContract projects the published comparison and line items into the identities MatchRecommendation joins.

Types

type CandidateAssociation

type CandidateAssociation = insurance.CandidateAssociation

type CandidateIdentity

type CandidateIdentity = insurance.CandidateIdentity

type CandidateStatus

type CandidateStatus = insurance.CandidateStatus

type ComparisonDTO

type ComparisonDTO struct {
	Current               TotalsDTO         `json:"current"`
	Currency              *string           `json:"currency"`
	BasisNote             string            `json:"basis_note"`
	FetchedAt             string            `json:"fetched_at"`
	CurrencyNote          string            `json:"currency_note"`
	Title                 string            `json:"title"`
	DeltaBasisNote        string            `json:"delta_basis_note"`
	PlanID                string            `json:"plan_id"`
	NonGatingDisclosure   string            `json:"non_gating_disclosure"`
	SponsorshipDisclosure string            `json:"sponsorship_disclosure"`
	Hypotheticals         []HypotheticalDTO `json:"hypotheticals"`
	Rows                  []RowDTO          `json:"rows"`
	PremiumIncluded       bool              `json:"premium_included"`
}

ComparisonDTO is the platform response. No org ID is included.

func BuildComparison

func BuildComparison(c *insurance.Comparison) (*ComparisonDTO, error)

BuildComparison maps the contract type to the platform DTO. Money is exact decimal text or null; every vendor string is cleaned and capped. It returns ErrUnrepresentable when any number has no exact decimal form.

type ComparisonIdentity

type ComparisonIdentity = insurance.ComparisonIdentity

type DeltaDTO

type DeltaDTO struct {
	MonthlyNetSavings *string `json:"monthly_730h_net_savings"`
	UpfrontCost       *string `json:"upfront_one_time_cost"`
	DiscountRate      *string `json:"discount_rate"`
	BreakevenDays     *string `json:"breakeven_days"`
}

DeltaDTO is the vendor's candidate-minus-current difference.

type FinancialsDTO

type FinancialsDTO = insurance.FinancialsDTO

FinancialsDTO carries the 730-hour monthly rate block.

type HypotheticalDTO

type HypotheticalDTO struct {
	ContractTerm   *string              `json:"contract_term"`
	PaymentOption  string               `json:"payment_option"`
	Totals         TotalsDTO            `json:"totals"`
	DeltaVsCurrent HypotheticalDeltaDTO `json:"delta_vs_current"`
	LineItems      []LineItemDTO        `json:"line_items"`
}

HypotheticalDTO is a rollup for one (term, payment option) combination.

type HypotheticalDeltaDTO

type HypotheticalDeltaDTO struct {
	MonthlyNetSavings     *string `json:"monthly_730h_net_savings"`
	MonthlyCommitmentCost *string `json:"monthly_730h_commitment_cost"`
	UpfrontCost           *string `json:"upfront_one_time_cost"`
}

HypotheticalDeltaDTO compares a hypothetical rollup against the current plan.

type LineItemDTO

type LineItemDTO struct {
	ActualTerm           *string `json:"actual_term"`
	ActualPaymentOption  *string `json:"actual_payment_option"`
	ActualCommitmentType *string `json:"actual_commitment_type"`
	LineItemID           string  `json:"line_item_id"`
	Reason               string  `json:"reason"`
}

LineItemDTO is how one line item lands inside a hypothetical rollup.

type LineItemIdentity

type LineItemIdentity = insurance.LineItemIdentity

type MatchStatus

type MatchStatus = insurance.MatchStatus

type OfferDTO

type OfferDTO struct {
	Monthly              FinancialsDTO     `json:"monthly"`
	DeltaVsCurrent       DeltaDTO          `json:"delta_vs_current"`
	LeaseMenuItemID      *string           `json:"lease_menu_item_id"`
	ArcheraOfferName     *string           `json:"archera_offer_name,omitempty"`
	Region               *string           `json:"region"`
	ContractTerm         *string           `json:"contract_term"`
	PaymentOption        *string           `json:"payment_option"`
	UpfrontCost          *string           `json:"upfront_one_time_cost"`
	BreakevenDays        *string           `json:"breakeven_days"`
	DiscountRate         *string           `json:"discount_rate"`
	ProductSupport       ProductSupportDTO `json:"archera_product_support"`
	ArcheraOfferNameNote string            `json:"archera_offer_name_note,omitempty"`
	CommitmentType       string            `json:"commitment_type"`
	OfferID              string            `json:"offer_id"`
	Provider             string            `json:"provider"`
	LeaseAttached        bool              `json:"lease_attached"`
	IsCurrent            bool              `json:"is_current"`
}

OfferDTO is one offer (current or candidate) for a line item.

type ProductSupportDTO

type ProductSupportDTO struct {
	Status              string `json:"status"`
	Source              string `json:"source,omitempty"`
	Evidence            string `json:"evidence,omitempty"`
	UnderwritingAllowed string `json:"underwriting_allowance"`
	CustomerEligibility string `json:"customer_eligibility"`
}

ProductSupportDTO is the documentation-derived verdict for one offer. Source and Evidence appear only for a supported verdict; allowance and customer eligibility are always unknown.

type Provider

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

Provider builds the insurance client on first use. It holds the secret resolver and a *insurance.Client only, never the raw key or a Config value.

func NewProvider

func NewProvider(settings Settings, resolver secrets.Resolver, hc *http.Client) *Provider

NewProvider returns a Provider. hc must be nil in production.

func (*Provider) Client

func (p *Provider) Client(ctx context.Context) (insurance.QuoteClient, error)

Client returns the lazily built client. A failure is not cached: the next call retries. A caller whose own ctx ends, while waiting for another build or during its own, gets ctx.Err() rather than ErrKeyUnavailable.

func (*Provider) Format

func (p *Provider) Format(s fmt.State, _ rune)

Format keeps the provider's contents out of every fmt verb.

func (*Provider) PlanID

func (p *Provider) PlanID() string

PlanID is the configured Archera plan ID.

func (*Provider) Status

func (p *Provider) Status() Status

Status reports setting presence without any outbound call or secret read.

type Reason

type Reason = insurance.Reason

type RecommendationAlternativeDTO

type RecommendationAlternativeDTO = insurance.RecommendationAlternativeDTO

type RecommendationComparisonDTO

type RecommendationComparisonDTO = insurance.RecommendationComparisonDTO

func BuildRecommendationComparison

func BuildRecommendationComparison(id, planID string, rec *RecommendationIdentity, c *insurance.Comparison, items []insurance.LineItem) (*RecommendationComparisonDTO, error)

BuildRecommendationComparison matches the stored recommendation against the vendor line items and renders only the matched row. An unmatched result carries no figures. It returns ErrUnrepresentable when a rendered number has no exact decimal form.

type RecommendationIdentity

type RecommendationIdentity = insurance.RecommendationIdentity

func ProjectRecommendation

func ProjectRecommendation(r *config.RecommendationRecord) (*RecommendationIdentity, error)

ProjectRecommendation turns a stored recommendation into the identity the vendor line items are matched against.

type RecommendationMatch

type RecommendationMatch = insurance.RecommendationMatch

func MatchRecommendation

func MatchRecommendation(planID string, rec *RecommendationIdentity, rows []ComparisonIdentity, items []LineItemIdentity) (RecommendationMatch, error)

type RecommendationOfferDTO

type RecommendationOfferDTO = insurance.RecommendationOfferDTO

type RowDTO

type RowDTO struct {
	LineItemID string     `json:"line_item_id"`
	Current    OfferDTO   `json:"current"`
	Candidates []OfferDTO `json:"candidates"`
}

RowDTO is a line item's current offer plus its alternatives.

type SelectStatus

type SelectStatus = insurance.SelectStatus

func SelectLineItem

func SelectLineItem(rec *RecommendationIdentity, items []LineItemIdentity) (id string, status SelectStatus)

type Settings

type Settings struct {
	OrgID        string
	PlanID       string
	KeySecretRef string
}

Settings are the non-secret Archera settings. KeySecretRef is a reference to the secret (name, ARN or URI), not the key itself.

func SettingsFromEnv

func SettingsFromEnv() Settings

SettingsFromEnv reads the settings from the process environment.

func (Settings) Missing

func (s Settings) Missing() []string

Missing lists the names (never values) of absent settings, in a fixed order.

func (Settings) Status

func (s Settings) Status() Status

Status returns the presence-only status for the settings.

type Status

type Status struct {
	Missing    []string `json:"missing"`
	Configured bool     `json:"configured"`
}

Status reports whether the three settings are present. It resolves nothing and never carries a value.

type TotalsDTO

type TotalsDTO struct {
	FinancialsDTO
	UpfrontCost *string `json:"upfront_one_time_cost"`
}

TotalsDTO is a plan-wide rollup.

Jump to

Keyboard shortcuts

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