# `Polarex.Discounts`
[🔗](https://github.com/giusdp/polarex/blob/main/lib/polarex/operations/discounts.ex#L1)

Provides API endpoints related to discounts

# `discounts_create`

```elixir
@spec discounts_create(
  body :: Polarex.DiscountFixedCreate.t() | Polarex.DiscountPercentageCreate.t(),
  opts :: keyword()
) ::
  {:ok,
   Polarex.DiscountFixedOnceForeverDuration.t()
   | Polarex.DiscountFixedRepeatDuration.t()
   | Polarex.DiscountPercentageOnceForeverDuration.t()
   | Polarex.DiscountPercentageRepeatDuration.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Create Discount

Create a discount.

**Scopes**: `discounts:write`

## Request Body

**Content Types**: `application/json`

# `discounts_delete`

```elixir
@spec discounts_delete(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Delete Discount

Delete a discount.

**Scopes**: `discounts:write`

# `discounts_get`

```elixir
@spec discounts_get(id :: String.t(), opts :: keyword()) ::
  {:ok,
   Polarex.DiscountFixedOnceForeverDuration.t()
   | Polarex.DiscountFixedRepeatDuration.t()
   | Polarex.DiscountPercentageOnceForeverDuration.t()
   | Polarex.DiscountPercentageRepeatDuration.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Discount

Get a discount by ID.

**Scopes**: `discounts:read` `discounts:write`

# `discounts_list`

```elixir
@spec discounts_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceDiscount.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Discounts

List discounts.

**Scopes**: `discounts:read` `discounts:write`

## Options

  * `organization_id`: Filter by organization ID.
  * `query`: Filter by name.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign `-` before the criteria name to sort by descending order.

# `discounts_update`

```elixir
@spec discounts_update(
  id :: String.t(),
  body :: Polarex.DiscountUpdate.t(),
  opts :: keyword()
) ::
  {:ok,
   Polarex.DiscountFixedOnceForeverDuration.t()
   | Polarex.DiscountFixedRepeatDuration.t()
   | Polarex.DiscountPercentageOnceForeverDuration.t()
   | Polarex.DiscountPercentageRepeatDuration.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Update Discount

Update a discount.

**Scopes**: `discounts:write`

## Request Body

**Content Types**: `application/json`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
