# epx contact-assignments

> Read and change which customers are contacts of which legal entities.

## epx contact-assignments

Reads and changes contact assignments, the customers that act as contacts of a legal
entity, personal data included.
create and update ID (an upsert) send the JSON body of `--file`; delete ID sends none.

Its reads require the customermanagement.contactassignment_read scope.
Its writes require the customermanagement.contactassignment_manage scope.

**Command:** `epx contact-assignments [flags]`, `epx contact-assignments [command]`

**Flags:** only the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

**Subcommands**

- [`epx contact-assignments create`](#epx-contact-assignments-create)\
  Create one contact assignment.
- [`epx contact-assignments delete`](#epx-contact-assignments-delete)\
  Delete one contact assignment.
- [`epx contact-assignments get`](#epx-contact-assignments-get)\
  Show one contact assignment.
- [`epx contact-assignments list`](#epx-contact-assignments-list)\
  List contact assignments.
- [`epx contact-assignments update`](#epx-contact-assignments-update)\
  Upsert one contact assignment.

## epx contact-assignments create

Create one contact assignment.

Creates the contact assignment that the JSON body of `--file` describes, shaped as
[`epx contact-assignments get ID -o json`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/contact-assignments#epx-contact-assignments-get) prints one:
legalEntity and customer (required, each as `{"id": ...}` of one that exists: 400 Bad Request,
exit 1, otherwise; the customer's id, not its number), type (PRIMARY, BILLING, LOGISTICS
or CONTACT, the default) and primary (true or false).
Without an id, Emporix makes one, and answers with it; an id that exists already is a
conflict (exit 5).
A second assignment of a customer to the same legal entity is a conflict (exit 5) too.
Assigning a customer to a subsidiary also assigns it to the parent company, as a CONTACT
in an assignment of its own, which takes a delete of its own.

Changes data: on a terminal, epx asks before it sends POST. `--yes` sends without
asking (required without a terminal, or with `--file` -); `--dry-run` prints the request
instead of sending it.

Requires the customermanagement.contactassignment_manage scope.

**Command:** `epx contact-assignments create [flags]`

**Flags**

- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `--file <PATH>`\
  JSON request body in PATH, sent byte for byte (- reads standard input; sending it then needs `--yes`; required).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal, or with `--file` -).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx contact-assignments delete

Delete one contact assignment.

Deletes the contact assignment ID; it sends no body.
ID is the ID that [`epx contact-assignments list`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/contact-assignments#epx-contact-assignments-list) shows; an unknown one is not found.

Deletes data, which cannot be undone.
On a terminal, epx sends DELETE only once you type ID at its prompt.
`--yes` sends without asking (required without a terminal);
`--dry-run` prints the request instead of sending it.

Requires the customermanagement.contactassignment_manage scope.

**Command:** `epx contact-assignments delete ID [flags]`

**Flags**

- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx contact-assignments get

Show one contact assignment.

Reads contact assignments, the customers that act as contacts of a legal entity,
personal data included. CUSTOMER is the customer's id, not the NUMBER that [`epx customers get`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/customers#epx-customers-get) takes. TYPE is PRIMARY, BILLING, LOGISTICS or CONTACT; the PRIMARY column is the
assignment's primary flag, separate from the TYPE PRIMARY. Phone numbers and the legal
entity's details are only in `-o json`.

Requires the customermanagement.contactassignment_read scope.

**Command:** `epx contact-assignments get ID [flags]`

**Flags**

- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among ID, LEGAL ENTITY, CUSTOMER, NAME, EMAIL, TYPE, PRIMARY.
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx contact-assignments list

List contact assignments.

Reads contact assignments, the customers that act as contacts of a legal entity,
personal data included. CUSTOMER is the customer's id, not the NUMBER that [`epx customers get`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/customers#epx-customers-get) takes. TYPE is PRIMARY, BILLING, LOGISTICS or CONTACT; the PRIMARY column is the
assignment's primary flag, separate from the TYPE PRIMARY. Phone numbers and the legal
entity's details are only in `-o json`.

Requires the customermanagement.contactassignment_read scope.

**Command:** `epx contact-assignments list [flags]`

**Flags**

- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among ID, LEGAL ENTITY, CUSTOMER, NAME, EMAIL, TYPE, PRIMARY.
- `--limit <n>`\
  Print at most n items; paged reads stop early where they safely can (0: every item).
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.
- `--query <filter>`\
  Emporix q filter, passed as given, e.g. code:(A1,A2); space-separated conditions must all match (fields mostly as in `-o json`).
- `--sort <order>`\
  Emporix sort order, passed as given, e.g. code or name.en:desc,code; fields mostly as in `-o json` (Emporix may ignore an unknown one).
- `--stream`\
  Print items as JSON Lines as soon as they are checked, page by page on paged lists, reading up to 10000 pages where a list without it stops after 1000: a check failing on a later page exits 1 after the pages before it (excludes `-o`, `--columns` and `--no-headers`).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx contact-assignments update

Upsert one contact assignment.

Replaces the contact assignment ID with the JSON body of `--file`, shaped as create takes it
but without an id, or creates it with that id where none exists (an upsert); it requires
legalEntity and customer; a type left out becomes CONTACT, a primary left out false.
With metadata.version as [`epx contact-assignments get ID -o json`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/contact-assignments#epx-contact-assignments-get) prints it, Emporix
replaces it only if nobody changed it since, and answers 409 Conflict (exit 5) otherwise;
without metadata.version, it replaces it whatever its version.
ID is the ID that [`epx contact-assignments list`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/contact-assignments#epx-contact-assignments-list) shows.

Changes data: on a terminal, epx asks before it sends PUT. `--yes` sends without
asking (required without a terminal, or with `--file` -); `--dry-run` prints the request
instead of sending it.

Requires the customermanagement.contactassignment_manage scope.

**Command:** `epx contact-assignments update ID [flags]`

**Flags**

- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `--file <PATH>`\
  JSON request body in PATH, sent byte for byte (- reads standard input; sending it then needs `--yes`; required).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal, or with `--file` -).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).
