# Contact Card

## Get contact cards

`client.ContactCard.Get(ctx, query) (*ContactCardGetResponse, error)`

**get** `/v3/contact_card`

Returns the contact card for a specific phone number, or all contact cards for the
authenticated partner if no `phone_number` is provided.

### Parameters

- `query ContactCardGetParams`

  - `PhoneNumber param.Field[string]`

    E.164 phone number to filter by. If omitted, all my cards for the partner are returned.

### Returns

- `type ContactCardGetResponse struct{…}`

  - `ContactCards []ContactCardGetResponseContactCard`

    - `FirstName string`

    - `IsActive bool`

    - `PhoneNumber string`

    - `ImageURL string`

    - `LastName string`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  contactCard, err := client.ContactCard.Get(context.TODO(), linqgo.ContactCardGetParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", contactCard.ContactCards)
}
```

#### Response

```json
{
  "contact_cards": [
    {
      "phone_number": "+15551234567",
      "first_name": "John",
      "last_name": "Doe",
      "image_url": "https://cdn.linqapp.com/contact-card/example.jpg",
      "is_active": true
    }
  ]
}
```

## Setup contact card

`client.ContactCard.New(ctx, body) (*SetContactCard, error)`

**post** `/v3/contact_card`

Creates a contact card for a phone number. This endpoint is intended for initial, one-time setup only.

The contact card is stored in an inactive state first. Once it's applied successfully,
it is activated and `is_active` is returned as `true`. On failure, `is_active` is `false`.

**Note:** To update an existing contact card after setup, use `PATCH /v3/contact_card` instead.

### Parameters

- `body ContactCardNewParams`

  - `FirstName param.Field[string]`

    First name for the contact card. Required.

  - `PhoneNumber param.Field[string]`

    E.164 phone number to associate the contact card with

  - `ImageURL param.Field[string]`

    URL of the profile image to rehost on the CDN. Only re-uploaded when a new value is provided.

  - `LastName param.Field[string]`

    Last name for the contact card. Optional.

### Returns

- `type SetContactCard struct{…}`

  - `FirstName string`

    First name on the contact card

  - `IsActive bool`

    Whether the contact card was successfully applied to the device

  - `PhoneNumber string`

    The phone number the contact card is associated with

  - `ImageURL string`

    Image URL on the contact card

  - `LastName string`

    Last name on the contact card

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  setContactCard, err := client.ContactCard.New(context.TODO(), linqgo.ContactCardNewParams{
    FirstName: "Acme",
    PhoneNumber: "+15551234567",
    ImageURL: linqgo.String("https://cdn.linqapp.com/contact-card/example.jpg"),
    LastName: linqgo.String("Support"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", setContactCard.FirstName)
}
```

#### Response

```json
{
  "phone_number": "+15551234567",
  "first_name": "John",
  "last_name": "Doe",
  "image_url": "https://cdn.linqapp.com/contact-card/example.jpg",
  "is_active": true
}
```

## Update contact card

`client.ContactCard.Update(ctx, params) (*SetContactCard, error)`

**patch** `/v3/contact_card`

Partially updates an existing active contact card for a phone number.

Fetches the current active contact card and merges the provided fields.
Only fields present in the request body are updated; omitted fields retain their existing values.

Requires an active contact card to exist for the phone number.

### Parameters

- `params ContactCardUpdateParams`

  - `PhoneNumber param.Field[string]`

    Query param: E.164 phone number of the contact card to update

  - `FirstName param.Field[string]`

    Body param: Updated first name. If omitted, the existing value is kept.

  - `ImageURL param.Field[string]`

    Body param: Updated profile image URL. If omitted, the existing image is kept.

  - `LastName param.Field[string]`

    Body param: Updated last name. If omitted, the existing value is kept.

### Returns

- `type SetContactCard struct{…}`

  - `FirstName string`

    First name on the contact card

  - `IsActive bool`

    Whether the contact card was successfully applied to the device

  - `PhoneNumber string`

    The phone number the contact card is associated with

  - `ImageURL string`

    Image URL on the contact card

  - `LastName string`

    Last name on the contact card

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  setContactCard, err := client.ContactCard.Update(context.TODO(), linqgo.ContactCardUpdateParams{
    PhoneNumber: "+15551234567",
    FirstName: linqgo.String("John"),
    ImageURL: linqgo.String("https://cdn.linqapp.com/contact-card/example.jpg"),
    LastName: linqgo.String("Doe"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", setContactCard.FirstName)
}
```

#### Response

```json
{
  "phone_number": "+15551234567",
  "first_name": "John",
  "last_name": "Doe",
  "image_url": "https://cdn.linqapp.com/contact-card/example.jpg",
  "is_active": true
}
```

## Domain Types

### Set Contact Card

- `type SetContactCard struct{…}`

  - `FirstName string`

    First name on the contact card

  - `IsActive bool`

    Whether the contact card was successfully applied to the device

  - `PhoneNumber string`

    The phone number the contact card is associated with

  - `ImageURL string`

    Image URL on the contact card

  - `LastName string`

    Last name on the contact card
