@@ -113,32 +113,16 @@ func (c *Client) DeletePerson(ctx context.Context, personID string) (*Person, er
// Name fields are encrypted client-side; the API accepts them on create but
// returns null on read.
//
-// person, err := lunatask.NewPerson().
-// WithFirstName("Ada").
-// WithLastName("Lovelace").
+// person, err := lunatask.NewPerson("Ada", "Lovelace").
// WithRelationshipStrength(lunatask.RelationshipCloseFriend).
// Create(ctx, client)
type PersonBuilder struct {
req createPersonRequest
}
-// NewPerson starts building a person entry.
-func NewPerson() *PersonBuilder {
- return &PersonBuilder{} //nolint:exhaustruct
-}
-
-// WithFirstName sets the person's first name.
-func (b *PersonBuilder) WithFirstName(name string) *PersonBuilder {
- b.req.FirstName = &name
-
- return b
-}
-
-// WithLastName sets the person's last name.
-func (b *PersonBuilder) WithLastName(name string) *PersonBuilder {
- b.req.LastName = &name
-
- return b
+// NewPerson starts building a person entry with the given name.
+func NewPerson(firstName, lastName string) *PersonBuilder {
+ return &PersonBuilder{req: createPersonRequest{FirstName: &firstName, LastName: &lastName}} //nolint:exhaustruct
}
// WithRelationshipStrength categorizes the closeness of the relationship.
@@ -171,8 +155,8 @@ func (b *PersonBuilder) WithCustomField(key string, value any) *PersonBuilder {
return b
}
-// Create sends the person to Lunatask. Returns (nil, nil) if a duplicate exists
-// with matching source/source_id.
+// Create sends the person to Lunatask.
+// Returns (nil, nil) if a duplicate exists with matching source/source_id.
func (b *PersonBuilder) Create(ctx context.Context, c *Client) (*Person, error) {
return create(ctx, c, "/people", b.req, func(r personResponse) Person { return r.Person })
}