heyrafiki

package module
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

Heyrafiki Go SDK

Server-side Go client for the Heyrafiki API.

What this SDK is for

Use this SDK to call the Heyrafiki API from a Go service. It provides typed requests, predictable errors and idempotency support for retried writes. The platform applies access rules; clinical and financial decisions remain with the accountable people and organizations.

The client covers every operation published in the version 1 OpenAPI contract: Practitioners, Bookings, Sessions, eligibility, Coverage, pre-authorization, Claims, Claim valuation, remittance and Webhooks.

First request

package main

import (
	"context"
	"log"
	"os"

heyrafiki "github.com/heyrafiki/rafiki-go"
)

func main() {
	client, err := heyrafiki.NewClient(os.Getenv("HEYRAFIKI_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	practitioners, err := client.Practitioners.List(
		context.Background(),
		&heyrafiki.ListOptions{Limit: 5},
	)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("found %d Practitioners", len(practitioners.Data))
}

Keep API keys on the server. Sandbox keys return synthetic data.

Build and test the client directly from its public source:

git clone https://github.com/heyrafiki/rafiki-go.git
cd rafiki-go
go test -race ./...

Idempotent writes

The API contract requires a caller-owned idempotency key for replay-safe writes.

booking, err := client.Bookings.Create(ctx, heyrafiki.BookingInput{
	PractitionerID: "prc_2481",
	StartsAt:       "2026-08-12T07:00:00Z",
	EndsAt:         "2026-08-12T08:00:00Z",
	Format:         heyrafiki.CareFormatOnline,
	PaymentSource:  heyrafiki.PaymentSourceCovered,
}, heyrafiki.WriteOptions{IdempotencyKey: "booking-20260812-001"})

Reads and writes with an idempotency key use bounded retries for transport failures, 408, 429, 500, 502, 503 and 504 responses. Webhook registration and test delivery are not retried because the contract does not accept an idempotency key for those operations.

Claim valuation

Claims.Valuation reproduces what a Claim was worth at a point in time. The cutoff is explicit, and Heyrafiki includes only the facts whose business time and knowledge time both fall on or before it, so the same cutoff returns the same answer however much later you ask.

valuation, err := client.Claims.Valuation(ctx, "clm_demo_001", heyrafiki.ClaimValuationOptions{
	ValuationAt: "2026-08-12T09:00:00Z",
})
if err != nil {
	log.Fatal(err)
}

for _, event := range valuation.Events {
	log.Printf("%d %s effective %s recorded %s",
		event.Sequence, event.Type, event.EffectiveAt, event.RecordedAt)
}

EffectiveAt is when the underlying fact took effect. RecordedAt is when Heyrafiki persisted it. Amount.Outstanding is payer liability less the settlement an authorized observation confirmed, and it is nil when the contract reports it as unknown. ValuationAt must be an RFC 3339 timestamp; the SDK rejects anything else rather than sending a cutoff the API cannot reproduce.

Errors

var apiError *heyrafiki.APIError
if errors.As(err, &apiError) {
	log.Printf("status=%d code=%s request_id=%s", apiError.StatusCode, apiError.Code, apiError.RequestID)
}

Use the request ID when tracing a failed call. The SDK never adds request or response bodies to error strings.

Compatibility

  • Go 1.25 and 1.26
  • Heyrafiki API version 1
  • Bearer authentication by default; x-api-key is available through WithAuthStyle(heyrafiki.AuthAPIKey)
  • Standard library only

The SDK tracks additive changes to the published contract. Breaking API changes use a new major API version and a documented migration period.

Contract provenance

This client was reviewed against heyrafiki/contract contract 1.0.0, commit 62c32d1b99ddded0cfe0baf8ddc57bcbaa764167, on 2026-08-28. The client is handwritten; no generated source is included. See CONTRACT.md.

Develop

gofmt -w .
go test -race ./...
go vet ./...
go run golang.org/x/vuln/cmd/govulncheck@v1.1.4 ./...

Resources

License

Licensed under the Apache License 2.0.

Documentation

Overview

Package heyrafiki provides a typed, server-side client for the Heyrafiki API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Code       string
	Message    string
	RequestID  string
	Docs       string
	RetryAfter time.Duration
	// contains filtered or unexported fields
}

APIError represents the documented Heyrafiki API error envelope.

func (*APIError) Error

func (err *APIError) Error() string

func (*APIError) Unwrap

func (err *APIError) Unwrap() error

Unwrap exposes JSON decoding failures without including response bodies.

type APIInformation

type APIInformation struct {
	Object      string   `json:"object"`
	Version     string   `json:"version"`
	Environment string   `json:"environment"`
	Resources   []string `json:"resources"`
}

type APIService

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

APIService reads API metadata.

func (*APIService) Retrieve

func (service *APIService) Retrieve(ctx context.Context) (*APIInformation, error)

Retrieve returns API version and environment information.

type ApprovedPreauthorizationDecisionInput

type ApprovedPreauthorizationDecisionInput struct {
	ApprovedAmount     int64    `json:"approved_amount"`
	ValidUntil         string   `json:"valid_until"`
	ReasonCodes        []string `json:"reason_codes"`
	PolicyReference    string   `json:"policy_reference"`
	PolicyVersion      string   `json:"policy_version"`
	EvidenceReferences []string `json:"evidence_references"`
}

type AuthStyle

type AuthStyle string

AuthStyle selects one of the authentication schemes published by the API contract.

const (
	// AuthBearer sends the credential in the Authorization header.
	AuthBearer AuthStyle = "bearer"
	// AuthAPIKey sends the credential in the x-api-key header.
	AuthAPIKey AuthStyle = "api_key"
)

type AvailabilityWindow

type AvailabilityWindow struct {
	Weekday int          `json:"weekday"`
	Start   string       `json:"start"`
	End     string       `json:"end"`
	Formats []CareFormat `json:"formats"`
}

type Booking

type Booking struct {
	ID             string        `json:"id"`
	Object         string        `json:"object"`
	SessionID      string        `json:"session_id"`
	PractitionerID string        `json:"practitioner_id"`
	StartsAt       string        `json:"starts_at"`
	EndsAt         string        `json:"ends_at"`
	Timezone       string        `json:"timezone"`
	Format         CareFormat    `json:"format"`
	Status         string        `json:"status"`
	PaymentSource  PaymentSource `json:"payment_source"`
}

type BookingInput

type BookingInput struct {
	PractitionerID string        `json:"practitioner_id"`
	StartsAt       string        `json:"starts_at"`
	EndsAt         string        `json:"ends_at"`
	Format         CareFormat    `json:"format"`
	PaymentSource  PaymentSource `json:"payment_source"`
}

type BookingList

type BookingList struct {
	Object  string    `json:"object"`
	Data    []Booking `json:"data"`
	HasMore bool      `json:"has_more"`
}

type BookingService

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

BookingService creates and reads Bookings.

func (*BookingService) Create

func (service *BookingService) Create(ctx context.Context, input BookingInput, options WriteOptions) (*Booking, error)

Create creates a Booking with a caller-owned idempotency key.

func (*BookingService) List

func (service *BookingService) List(ctx context.Context, options *ListOptions) (*BookingList, error)

List returns Bookings visible to the project.

func (*BookingService) Retrieve

func (service *BookingService) Retrieve(ctx context.Context, bookingID string) (*Booking, error)

Retrieve returns one Booking visible to the project.

type CareFormat

type CareFormat string

CareFormat identifies how a Session takes place.

const (
	CareFormatOnline   CareFormat = "online"
	CareFormatInPerson CareFormat = "in_person"
	CareFormatPhone    CareFormat = "phone"
)

type Claim

type Claim struct {
	ID                     string                    `json:"id"`
	Object                 string                    `json:"object"`
	Status                 string                    `json:"status"`
	ProviderClaimReference *string                   `json:"provider_claim_reference"`
	SubmissionVersion      int                       `json:"submission_version"`
	Amount                 ClaimAmount               `json:"amount"`
	ServicePeriod          ServicePeriod             `json:"service_period"`
	Lines                  []ClaimLine               `json:"lines"`
	InformationRequests    []ClaimInformationRequest `json:"information_requests"`
	Adjudication           *ClaimAdjudication        `json:"adjudication"`
	SubmittedAt            *string                   `json:"submitted_at"`
	UpdatedAt              string                    `json:"updated_at"`
}

type ClaimAdjudication

type ClaimAdjudication struct {
	ID          string                  `json:"id"`
	Object      string                  `json:"object"`
	Version     int                     `json:"version"`
	Decision    string                  `json:"decision"`
	Amount      ClaimAdjudicationTotal  `json:"amount"`
	ReasonCodes []string                `json:"reason_codes"`
	Policy      PolicyReference         `json:"policy"`
	Lines       []ClaimAdjudicationLine `json:"lines"`
	DecidedAt   string                  `json:"decided_at"`
}

type ClaimAdjudicationAmounts

type ClaimAdjudicationAmounts struct {
	Billed                int64 `json:"billed"`
	Allowed               int64 `json:"allowed"`
	Payer                 int64 `json:"payer"`
	PatientResponsibility int64 `json:"patient_responsibility"`
	Adjustment            int64 `json:"adjustment"`
}

type ClaimAdjudicationInput

type ClaimAdjudicationInput struct {
	PolicyReference string                  `json:"policy_reference"`
	PolicyVersion   string                  `json:"policy_version"`
	ReasonCodes     []string                `json:"reason_codes"`
	EvidenceRefs    []string                `json:"evidence_refs,omitempty"`
	Lines           []ClaimAdjudicationLine `json:"lines"`
}

type ClaimAdjudicationLine

type ClaimAdjudicationLine struct {
	LineNumber  int                      `json:"line_number"`
	Amount      ClaimAdjudicationAmounts `json:"amount"`
	ReasonCodes []string                 `json:"reason_codes"`
}

type ClaimAdjudicationTotal

type ClaimAdjudicationTotal struct {
	Currency              string `json:"currency"`
	Billed                int64  `json:"billed"`
	Payer                 int64  `json:"payer"`
	PatientResponsibility int64  `json:"patient_responsibility"`
	Adjustment            int64  `json:"adjustment"`
}

type ClaimAmount

type ClaimAmount struct {
	Currency string `json:"currency"`
	Billed   int64  `json:"billed"`
	Approved *int64 `json:"approved"`
	Remitted *int64 `json:"remitted"`
	Settled  *int64 `json:"settled"`
}

type ClaimEvidenceInput

type ClaimEvidenceInput struct {
	InformationRequestID string   `json:"information_request_id"`
	EvidenceRefs         []string `json:"evidence_refs"`
}

type ClaimInformationRequest

type ClaimInformationRequest struct {
	ID                     string   `json:"id"`
	Object                 string   `json:"object"`
	ReasonCode             string   `json:"reason_code"`
	RequestedEvidenceTypes []string `json:"requested_evidence_types"`
	Status                 string   `json:"status"`
	DueAt                  *string  `json:"due_at"`
	CreatedAt              string   `json:"created_at"`
	ResolvedAt             *string  `json:"resolved_at"`
}

type ClaimInformationRequestInput

type ClaimInformationRequestInput struct {
	ReasonCode             string   `json:"reason_code"`
	RequestedEvidenceTypes []string `json:"requested_evidence_types"`
	DueAt                  *string  `json:"due_at,omitempty"`
}

type ClaimInput

type ClaimInput struct {
	EligibilityCheckID     string           `json:"eligibility_check_id"`
	PreauthorizationID     *string          `json:"preauthorization_id,omitempty"`
	SessionID              string           `json:"session_id"`
	ProviderClaimReference string           `json:"provider_claim_reference"`
	EvidenceRefs           []string         `json:"evidence_refs,omitempty"`
	Lines                  []ClaimLineInput `json:"lines"`
}

type ClaimLine

type ClaimLine struct {
	LineNumber        int     `json:"line_number"`
	CodeSystem        string  `json:"code_system"`
	CodeSystemVersion *string `json:"code_system_version"`
	ServiceCode       string  `json:"service_code"`
	Units             float64 `json:"units"`
	Amount            int64   `json:"amount"`
}

type ClaimLineInput

type ClaimLineInput struct {
	CodeSystem        string  `json:"code_system"`
	CodeSystemVersion *string `json:"code_system_version,omitempty"`
	ServiceCode       string  `json:"service_code"`
	Units             float64 `json:"units"`
	Amount            int64   `json:"amount"`
}

type ClaimList

type ClaimList struct {
	Object  string  `json:"object"`
	Data    []Claim `json:"data"`
	HasMore bool    `json:"has_more"`
}

type ClaimService

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

ClaimService creates and manages Claims.

func (*ClaimService) Adjudicate

func (service *ClaimService) Adjudicate(ctx context.Context, claimID string, input ClaimAdjudicationInput, options WriteOptions) (*Claim, error)

Adjudicate records a Claim adjudication decision.

func (*ClaimService) Create

func (service *ClaimService) Create(ctx context.Context, input ClaimInput, options WriteOptions) (*Claim, error)

Create submits a Claim with a caller-owned idempotency key.

func (*ClaimService) List

func (service *ClaimService) List(ctx context.Context, options *ListOptions) (*ClaimList, error)

List returns Claims visible to the project.

func (*ClaimService) RequestInformation

func (service *ClaimService) RequestInformation(ctx context.Context, claimID string, input ClaimInformationRequestInput, options WriteOptions) (*Claim, error)

RequestInformation records a payer request for Claim evidence.

func (*ClaimService) Retrieve

func (service *ClaimService) Retrieve(ctx context.Context, claimID string) (*Claim, error)

Retrieve returns one Claim visible to the project.

func (*ClaimService) SubmitEvidence

func (service *ClaimService) SubmitEvidence(ctx context.Context, claimID string, input ClaimEvidenceInput, options WriteOptions) (*Claim, error)

SubmitEvidence attaches evidence references to a Claim information request.

func (*ClaimService) Valuation

func (service *ClaimService) Valuation(ctx context.Context, claimID string, options ClaimValuationOptions) (*ClaimValuation, error)

Valuation reproduces a Claim valuation from the facts known at an inclusive cutoff.

type ClaimValuation

type ClaimValuation struct {
	ID          string                `json:"id"`
	Object      string                `json:"object"`
	ClaimID     string                `json:"claim_id"`
	ValuationAt string                `json:"valuation_at"`
	Currency    string                `json:"currency"`
	Status      string                `json:"status"`
	Amount      ClaimValuationAmount  `json:"amount"`
	Policy      *PolicyReference      `json:"policy"`
	Events      []ClaimValuationEvent `json:"events"`
}

type ClaimValuationAmount

type ClaimValuationAmount struct {
	Billed                int64  `json:"billed"`
	PayerLiability        *int64 `json:"payer_liability"`
	PatientResponsibility *int64 `json:"patient_responsibility"`
	Adjustment            *int64 `json:"adjustment"`
	Remitted              int64  `json:"remitted"`
	Settled               int64  `json:"settled"`
	Outstanding           *int64 `json:"outstanding"`
}

type ClaimValuationEvent

type ClaimValuationEvent struct {
	Sequence           int      `json:"sequence"`
	Type               string   `json:"type"`
	EffectiveAt        string   `json:"effective_at"`
	RecordedAt         string   `json:"recorded_at"`
	PreviousStatus     *string  `json:"previous_status"`
	NextStatus         *string  `json:"next_status"`
	ReasonCode         *string  `json:"reason_code"`
	EvidenceReferences []string `json:"evidence_references"`
}

ClaimValuationEvent records one Claim fact with both its business time and the knowledge time at which Heyrafiki persisted it.

type ClaimValuationOptions

type ClaimValuationOptions struct {
	// ValuationAt is an inclusive RFC 3339 cutoff. Heyrafiki returns only the facts
	// whose business time and knowledge time both fall on or before it.
	ValuationAt string
}

ClaimValuationOptions supplies the knowledge cutoff required by a Claim valuation.

type Client

type Client struct {
	API               *APIService
	Practitioners     *PractitionerService
	Bookings          *BookingService
	Sessions          *SessionService
	EligibilityChecks *EligibilityCheckService
	Coverages         *CoverageService
	CoverageBatches   *CoverageBatchService
	Preauthorizations *PreauthorizationService
	Claims            *ClaimService
	Remittances       *RemittanceService
	WebhookEndpoints  *WebhookEndpointService
	// contains filtered or unexported fields
}

Client is a concurrency-safe client for the Heyrafiki API.

func NewClient

func NewClient(apiKey string, options ...Option) (*Client, error)

NewClient creates a server-side Heyrafiki API client.

type CoverageAmountLimit

type CoverageAmountLimit struct {
	Currency Currency `json:"currency"`
	Value    int64    `json:"value"`
}

type CoverageBatchInput

type CoverageBatchInput struct {
	ContractVersion         string                     `json:"contract_version"`
	BatchReference          string                     `json:"batch_reference"`
	BatchVersion            string                     `json:"batch_version"`
	SourceContractReference string                     `json:"source_contract_reference"`
	GeneratedAt             string                     `json:"generated_at"`
	Records                 []CoverageBatchRecordInput `json:"records"`
}

type CoverageBatchOptions

type CoverageBatchOptions struct {
	IdempotencyKey    string
	ArtifactReference string
}

CoverageBatchOptions supplies the replay controls required by Coverage batch ingestion.

type CoverageBatchRecordInput

type CoverageBatchRecordInput struct {
	CoverageReference     string         `json:"coverage_reference"`
	RecordVersion         string         `json:"record_version"`
	TenantReference       string         `json:"tenant_reference"`
	MemberReference       string         `json:"member_reference"`
	PlanName              string         `json:"plan_name"`
	ServiceCode           string         `json:"service_code"`
	Status                CoverageStatus `json:"status"`
	Currency              Currency       `json:"currency"`
	AmountLimit           int64          `json:"amount_limit"`
	RemainingSessions     int            `json:"remaining_sessions"`
	AuthorizationRequired bool           `json:"authorization_required"`
	CoordinationPriority  *int           `json:"coordination_priority"`
	ValidFrom             string         `json:"valid_from"`
	ValidUntil            string         `json:"valid_until"`
}

type CoverageBatchResult

type CoverageBatchResult struct {
	Object         string                `json:"object"`
	BatchReference string                `json:"batch_reference"`
	ArtifactSHA256 string                `json:"artifact_sha256"`
	Total          int                   `json:"total"`
	Recorded       int                   `json:"recorded"`
	Replayed       int                   `json:"replayed"`
	Observations   []CoverageObservation `json:"observations"`
}

type CoverageBatchService

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

CoverageBatchService records replay-safe payer Coverage batches.

func (*CoverageBatchService) Record

Record stores a payer Coverage batch with replay-safe artifact controls.

type CoverageObservation

type CoverageObservation struct {
	ID                        string              `json:"id"`
	Object                    string              `json:"object"`
	CoverageID                string              `json:"coverage_id"`
	Source                    string              `json:"source"`
	SourceContractReference   string              `json:"source_contract_reference"`
	ExternalCoverageReference string              `json:"external_coverage_reference"`
	SourceVersion             string              `json:"source_version"`
	SnapshotVersion           int                 `json:"snapshot_version"`
	Status                    CoverageStatus      `json:"status"`
	ServiceCode               string              `json:"service_code"`
	AmountLimit               CoverageAmountLimit `json:"amount_limit"`
	RemainingSessions         int                 `json:"remaining_sessions"`
	AuthorizationRequired     bool                `json:"authorization_required"`
	CoordinationPriority      *int                `json:"coordination_priority"`
	ValidFrom                 string              `json:"valid_from"`
	ValidUntil                string              `json:"valid_until"`
	ObservedAt                string              `json:"observed_at"`
}

type CoverageObservationInput

type CoverageObservationInput struct {
	SourceContractReference   string         `json:"source_contract_reference"`
	ExternalCoverageReference string         `json:"external_coverage_reference"`
	SourceVersion             string         `json:"source_version"`
	TenantReference           string         `json:"tenant_reference"`
	MemberReference           string         `json:"member_reference"`
	PlanName                  string         `json:"plan_name"`
	ServiceCode               string         `json:"service_code"`
	Status                    CoverageStatus `json:"status"`
	Currency                  Currency       `json:"currency"`
	AmountLimit               int64          `json:"amount_limit"`
	RemainingSessions         int            `json:"remaining_sessions"`
	AuthorizationRequired     bool           `json:"authorization_required"`
	CoordinationPriority      *int           `json:"coordination_priority"`
	ValidFrom                 string         `json:"valid_from"`
	ValidUntil                string         `json:"valid_until"`
	ObservedAt                string         `json:"observed_at"`
	EvidenceReferences        []string       `json:"evidence_references"`
}

type CoverageService

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

CoverageService records payer Coverage observations.

func (*CoverageService) Record

Record stores a payer Coverage observation with a caller-owned idempotency key.

type CoverageStatus

type CoverageStatus string
const (
	CoverageStatusActive    CoverageStatus = "active"
	CoverageStatusPaused    CoverageStatus = "paused"
	CoverageStatusExhausted CoverageStatus = "exhausted"
	CoverageStatusExpired   CoverageStatus = "expired"
)

type Currency

type Currency string

Currency is an ISO 4217 currency accepted by the version 1 contract.

const (
	CurrencyKES Currency = "KES"
	CurrencyUSD Currency = "USD"
	CurrencyEUR Currency = "EUR"
	CurrencyGBP Currency = "GBP"
)

type DeniedPreauthorizationDecisionInput

type DeniedPreauthorizationDecisionInput struct {
	ReasonCodes        []string `json:"reason_codes"`
	PolicyReference    string   `json:"policy_reference"`
	PolicyVersion      string   `json:"policy_version"`
	EvidenceReferences []string `json:"evidence_references"`
}

type EligibilityAmount

type EligibilityAmount struct {
	Requested         int64  `json:"requested"`
	Currency          string `json:"currency"`
	MaximumPerSession *int64 `json:"maximum_per_session"`
}

type EligibilityCheck

type EligibilityCheck struct {
	ID                    string             `json:"id"`
	Object                string             `json:"object"`
	Status                string             `json:"status"`
	ReasonCodes           []string           `json:"reason_codes"`
	Service               EligibilityService `json:"service"`
	Amount                EligibilityAmount  `json:"amount"`
	AuthorizationRequired bool               `json:"authorization_required"`
	RemainingSessions     *int               `json:"remaining_sessions"`
	CoverageValidUntil    *string            `json:"coverage_valid_until"`
	CheckedAt             string             `json:"checked_at"`
}

type EligibilityCheckInput

type EligibilityCheckInput struct {
	MemberReference string   `json:"member_reference"`
	ServiceCode     string   `json:"service_code"`
	ScheduledAt     string   `json:"scheduled_at"`
	Amount          int64    `json:"amount"`
	Currency        Currency `json:"currency"`
}

type EligibilityCheckService

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

EligibilityCheckService creates and reads Benefit eligibility checks.

func (*EligibilityCheckService) Create

Create checks Benefit eligibility with a caller-owned idempotency key.

func (*EligibilityCheckService) Retrieve

func (service *EligibilityCheckService) Retrieve(ctx context.Context, eligibilityCheckID string) (*EligibilityCheck, error)

Retrieve returns one eligibility check visible to the project.

type EligibilityService

type EligibilityService struct {
	Code        string `json:"code"`
	ScheduledAt string `json:"scheduled_at"`
}

type ListOptions

type ListOptions struct {
	Limit int
}

ListOptions controls paginated list operations.

type Money

type Money struct {
	Amount   int64  `json:"amount"`
	Currency string `json:"currency"`
}

Money contains an amount in the currency's minor unit.

type Option

type Option func(*clientConfig) error

Option configures a Client.

func WithAuthStyle

func WithAuthStyle(style AuthStyle) Option

WithAuthStyle selects bearer or x-api-key authentication.

func WithBaseURL

func WithBaseURL(rawURL string) Option

WithBaseURL replaces the API base URL. HTTPS is required except for loopback test servers.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient supplies the HTTP client used for all requests.

func WithMaxResponseSize

func WithMaxResponseSize(bytes int64) Option

WithMaxResponseSize limits response bodies read into memory.

func WithRetryPolicy

func WithRetryPolicy(policy RetryPolicy) Option

WithRetryPolicy replaces the default retry policy.

func WithUserAgent

func WithUserAgent(identifier string) Option

WithUserAgent appends a caller identifier to the SDK user agent.

type PaymentSource

type PaymentSource string

PaymentSource identifies how a Session is funded.

const (
	PaymentSourceSelfPay PaymentSource = "self_pay"
	PaymentSourceCovered PaymentSource = "covered"
)

type PolicyReference

type PolicyReference struct {
	Reference string `json:"reference"`
	Version   string `json:"version"`
}

type Practitioner

type Practitioner struct {
	ID         string               `json:"id"`
	Object     string               `json:"object"`
	Name       string               `json:"name"`
	Profession string               `json:"profession"`
	Location   PractitionerLocation `json:"location"`
	SessionFee Money                `json:"session_fee"`
}

type PractitionerAvailability

type PractitionerAvailability struct {
	Object         string               `json:"object"`
	PractitionerID string               `json:"practitioner_id"`
	Timezone       string               `json:"timezone"`
	WeeklyHours    []AvailabilityWindow `json:"weekly_hours"`
}

type PractitionerList

type PractitionerList struct {
	Object  string         `json:"object"`
	Data    []Practitioner `json:"data"`
	HasMore bool           `json:"has_more"`
}

type PractitionerLocation

type PractitionerLocation struct {
	City    string `json:"city"`
	Country string `json:"country"`
}

type PractitionerService

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

PractitionerService discovers Practitioners and availability.

func (*PractitionerService) Availability

func (service *PractitionerService) Availability(ctx context.Context, practitionerID string) (*PractitionerAvailability, error)

Availability returns a Practitioner's weekly availability.

func (*PractitionerService) List

func (service *PractitionerService) List(ctx context.Context, options *ListOptions) (*PractitionerList, error)

List returns visible Practitioners.

func (*PractitionerService) Retrieve

func (service *PractitionerService) Retrieve(ctx context.Context, practitionerID string) (*Practitioner, error)

Retrieve returns one visible Practitioner.

type Preauthorization

type Preauthorization struct {
	ID                 string                    `json:"id"`
	Object             string                    `json:"object"`
	EligibilityCheckID string                    `json:"eligibility_check_id"`
	BookingID          string                    `json:"booking_id"`
	Status             string                    `json:"status"`
	ReasonCodes        []string                  `json:"reason_codes"`
	Amount             PreauthorizationAmount    `json:"amount"`
	ValidUntil         *string                   `json:"valid_until"`
	CreatedAt          string                    `json:"created_at"`
	Decision           *PreauthorizationDecision `json:"decision"`
}

type PreauthorizationAmount

type PreauthorizationAmount struct {
	Requested int64  `json:"requested"`
	Approved  *int64 `json:"approved"`
	Currency  string `json:"currency"`
}

type PreauthorizationDecision

type PreauthorizationDecision struct {
	ID                 string          `json:"id"`
	Object             string          `json:"object"`
	Version            int             `json:"version"`
	Outcome            string          `json:"outcome"`
	ReasonCodes        []string        `json:"reason_codes"`
	Policy             PolicyReference `json:"policy"`
	AuthorityReference string          `json:"authority_reference"`
	EvidenceReferences []string        `json:"evidence_references"`
	DecidedAt          string          `json:"decided_at"`
}

type PreauthorizationDecisionInput

type PreauthorizationDecisionInput interface {
	// contains filtered or unexported methods
}

PreauthorizationDecisionInput is implemented by the approved and denied decision variants.

type PreauthorizationInput

type PreauthorizationInput struct {
	EligibilityCheckID string `json:"eligibility_check_id"`
	BookingID          string `json:"booking_id"`
}

type PreauthorizationService

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

PreauthorizationService creates, reads and decides pre-authorizations.

func (*PreauthorizationService) Create

Create requests pre-authorization with a caller-owned idempotency key.

func (*PreauthorizationService) Decide

func (service *PreauthorizationService) Decide(ctx context.Context, preauthorizationID string, input PreauthorizationDecisionInput, options WriteOptions) (*Preauthorization, error)

Decide records an approved or denied pre-authorization decision.

func (*PreauthorizationService) Retrieve

func (service *PreauthorizationService) Retrieve(ctx context.Context, preauthorizationID string) (*Preauthorization, error)

Retrieve returns one pre-authorization visible to the project.

type Remittance

type Remittance struct {
	ID             string                 `json:"id"`
	Object         string                 `json:"object"`
	Status         string                 `json:"status"`
	PayerReference string                 `json:"payer_reference"`
	Amount         RemittanceAmount       `json:"amount"`
	Allocations    []RemittanceAllocation `json:"allocations"`
	ReceivedAt     string                 `json:"received_at"`
	ReconciledAt   *string                `json:"reconciled_at"`
}

type RemittanceAllocation

type RemittanceAllocation struct {
	ClaimID     string   `json:"claim_id"`
	PaidAmount  int64    `json:"paid_amount"`
	ReasonCodes []string `json:"reason_codes"`
}

type RemittanceAllocationInput

type RemittanceAllocationInput struct {
	ClaimID     string   `json:"claim_id"`
	PaidAmount  int64    `json:"paid_amount"`
	ReasonCodes []string `json:"reason_codes,omitempty"`
}

type RemittanceAmount

type RemittanceAmount struct {
	Currency string `json:"currency"`
	Paid     int64  `json:"paid"`
}

type RemittanceInput

type RemittanceInput struct {
	PayerReference string                      `json:"payer_reference"`
	Currency       Currency                    `json:"currency"`
	ReceivedAt     string                      `json:"received_at"`
	Allocations    []RemittanceAllocationInput `json:"allocations"`
}

type RemittanceList

type RemittanceList struct {
	Object  string       `json:"object"`
	Data    []Remittance `json:"data"`
	HasMore bool         `json:"has_more"`
}

type RemittanceService

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

RemittanceService creates and reads remittance advice.

func (*RemittanceService) Create

func (service *RemittanceService) Create(ctx context.Context, input RemittanceInput, options WriteOptions) (*Remittance, error)

Create records remittance advice with a caller-owned idempotency key.

func (*RemittanceService) List

func (service *RemittanceService) List(ctx context.Context, options *ListOptions) (*RemittanceList, error)

List returns remittances visible to the project.

func (*RemittanceService) Retrieve

func (service *RemittanceService) Retrieve(ctx context.Context, remittanceID string) (*Remittance, error)

Retrieve returns one remittance visible to the project.

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts int
	BaseDelay   time.Duration
	MaxDelay    time.Duration
}

RetryPolicy controls bounded retries for reads and writes protected by an idempotency key.

func DefaultRetryPolicy

func DefaultRetryPolicy() RetryPolicy

DefaultRetryPolicy returns the SDK's bounded exponential-backoff policy.

type ServicePeriod

type ServicePeriod struct {
	StartsAt string `json:"starts_at"`
	EndsAt   string `json:"ends_at"`
}

type Session

type Session struct {
	ID             string        `json:"id"`
	Object         string        `json:"object"`
	PractitionerID string        `json:"practitioner_id"`
	StartsAt       string        `json:"starts_at"`
	EndsAt         string        `json:"ends_at"`
	Timezone       string        `json:"timezone"`
	Format         CareFormat    `json:"format"`
	Status         string        `json:"status"`
	PaymentSource  PaymentSource `json:"payment_source"`
}

type SessionList

type SessionList struct {
	Object  string    `json:"object"`
	Data    []Session `json:"data"`
	HasMore bool      `json:"has_more"`
}

type SessionService

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

SessionService reads Sessions.

func (*SessionService) List

func (service *SessionService) List(ctx context.Context, options *ListOptions) (*SessionList, error)

List returns Sessions visible to the project.

func (*SessionService) Retrieve

func (service *SessionService) Retrieve(ctx context.Context, sessionID string) (*Session, error)

Retrieve returns one Session visible to the project.

type WebhookDelivery

type WebhookDelivery struct {
	ID             string `json:"id"`
	Object         string `json:"object"`
	Delivered      bool   `json:"delivered"`
	Attempts       int    `json:"attempts"`
	ResponseStatus *int   `json:"response_status"`
}

type WebhookEndpoint

type WebhookEndpoint struct {
	ID         string         `json:"id"`
	Object     string         `json:"object"`
	URL        string         `json:"url"`
	Events     []WebhookEvent `json:"events"`
	Status     string         `json:"status"`
	CreatedAt  string         `json:"created_at"`
	DisabledAt *string        `json:"disabled_at"`
}

type WebhookEndpointInput

type WebhookEndpointInput struct {
	URL    string         `json:"url"`
	Events []WebhookEvent `json:"events"`
}

type WebhookEndpointList

type WebhookEndpointList struct {
	Object  string            `json:"object"`
	Data    []WebhookEndpoint `json:"data"`
	HasMore bool              `json:"has_more"`
}

type WebhookEndpointService

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

WebhookEndpointService manages Webhook endpoints and test deliveries.

func (*WebhookEndpointService) Create

Create registers a Webhook endpoint and returns its signing secret once.

func (*WebhookEndpointService) Disable

func (service *WebhookEndpointService) Disable(ctx context.Context, endpointID string) (*WebhookEndpoint, error)

Disable disables a Webhook endpoint.

func (*WebhookEndpointService) List

List returns Webhook endpoints visible to the project.

func (*WebhookEndpointService) Retrieve

func (service *WebhookEndpointService) Retrieve(ctx context.Context, endpointID string) (*WebhookEndpoint, error)

Retrieve returns one Webhook endpoint visible to the project.

func (*WebhookEndpointService) SendTest

func (service *WebhookEndpointService) SendTest(ctx context.Context, endpointID string) (*WebhookDelivery, error)

SendTest sends a contract-defined test event to a Webhook endpoint.

type WebhookEndpointWithSecret

type WebhookEndpointWithSecret struct {
	ID            string         `json:"id"`
	Object        string         `json:"object"`
	URL           string         `json:"url"`
	Events        []WebhookEvent `json:"events"`
	Status        string         `json:"status"`
	CreatedAt     string         `json:"created_at"`
	DisabledAt    *string        `json:"disabled_at"`
	SigningSecret string         `json:"signing_secret"`
}

type WebhookEvent

type WebhookEvent string
const (
	WebhookSandboxPing               WebhookEvent = "sandbox.ping"
	WebhookPreauthorizationRequested WebhookEvent = "preauthorization.requested"
	WebhookPreauthorizationApproved  WebhookEvent = "preauthorization.approved"
	WebhookPreauthorizationDenied    WebhookEvent = "preauthorization.denied"
	WebhookPreauthorizationExpired   WebhookEvent = "preauthorization.expired"
	WebhookClaimSubmitted            WebhookEvent = "claim.submitted"
	WebhookClaimInformationRequested WebhookEvent = "claim.information_requested"
	WebhookClaimResubmitted          WebhookEvent = "claim.resubmitted"
	WebhookClaimApproved             WebhookEvent = "claim.approved"
	WebhookClaimPartiallyApproved    WebhookEvent = "claim.partially_approved"
	WebhookClaimDenied               WebhookEvent = "claim.denied"
	WebhookClaimSettled              WebhookEvent = "claim.settled"
	WebhookRemittanceReconciled      WebhookEvent = "remittance.reconciled"
)

type WriteOptions

type WriteOptions struct {
	IdempotencyKey string
}

WriteOptions supplies the caller-owned idempotency key required by a write operation.

Directories

Path Synopsis
examples
covered-care command
Command covered-care demonstrates the typed eligibility and Booking flow with caller-owned idempotency keys.
Command covered-care demonstrates the typed eligibility and Booking flow with caller-owned idempotency keys.

Jump to

Keyboard shortcuts

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