// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package org_tangled

// schema: org.tangled.bobbin.awaitRecord

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	BobbinAwaitRecordNSID = "org.tangled.bobbin.awaitRecord"
)

// BobbinAwaitRecord_Output is the output of a org.tangled.bobbin.awaitRecord call.
type BobbinAwaitRecord_Output struct {
	// cid: CID of the revision this result is about.
	Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"`
	// detail: Opaque error message which can be more detailed than the reason.
	Detail *string `json:"detail,omitempty" cborgen:"detail,omitempty"`
	// reason: Why a rejected record will not appear.
	Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
	// status: What bobbin did with the record.
	Status string `json:"status" cborgen:"status"`
}

// BobbinAwaitRecord calls the XRPC method "org.tangled.bobbin.awaitRecord".
//
// cid: CID of the revision that was written, as returned by createRecord, putRecord or applyWrites. Omit it only when awaiting a delete, which has no CID. any other responds with whatever revision of the record settles first.
// uri: AT-URI of the record that was written.
func BobbinAwaitRecord(ctx context.Context, c util.LexClient, cid string, uri string) (*BobbinAwaitRecord_Output, error) {
	var out BobbinAwaitRecord_Output

	params := map[string]interface{}{}
	if cid != "" {
		params["cid"] = cid
	}
	params["uri"] = uri
	if err := c.LexDo(ctx, util.Query, "", "org.tangled.bobbin.awaitRecord", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
