ExLine.Api.Coupon (ExLine v0.1.0)

Copy Markdown View Source

Coupon management API (create / list / detail / close).

This is the management API for coupon campaigns — distinct from the coupon message type (ExLine.Message.coupon/2), which sends an already-created coupon to a user.

The coupon object passed to create/2 is a map matching LINE's CouponCreateRequest; build it per the reference (required: title, visibility, timezone, startTimestamp, endTimestamp, maxUseCountPerTicket, acquisitionCondition, reward):

%{
  title: "10% off",
  visibility: "PUBLIC",
  timezone: "ASIA_TAIPEI",
  startTimestamp: 1_700_000_000_000,
  endTimestamp: 1_800_000_000_000,
  maxUseCountPerTicket: 1,
  acquisitionCondition: %{type: "normal"},
  reward: %{type: "discount", priceInfo: %{discountType: "percent", percentage: 10}}
}

Ref: https://developers.line.biz/en/docs/messaging-api/create-coupons/

Summary

Functions

Closes a coupon (stops it being acquired). Returns {:ok, _} on success.

Creates a coupon. coupon is a map matching CouponCreateRequest (see the module doc). Returns {:ok, %{"couponId" => ...}}.

Gets the detail of a single coupon.

Gets a paginated list of coupons.

Functions

close(client, coupon_id)

@spec close(ExLine.Client.t(), String.t()) ::
  {:ok, term()} | {:error, ExLine.Error.t()}

Closes a coupon (stops it being acquired). Returns {:ok, _} on success.

Ref: https://developers.line.biz/en/reference/messaging-api/#close-coupon

create(client, coupon)

@spec create(ExLine.Client.t(), map()) :: {:ok, map()} | {:error, ExLine.Error.t()}

Creates a coupon. coupon is a map matching CouponCreateRequest (see the module doc). Returns {:ok, %{"couponId" => ...}}.

Ref: https://developers.line.biz/en/reference/messaging-api/#create-coupon

get(client, coupon_id)

@spec get(ExLine.Client.t(), String.t()) :: {:ok, map()} | {:error, ExLine.Error.t()}

Gets the detail of a single coupon.

Ref: https://developers.line.biz/en/reference/messaging-api/#get-coupon-detail

list(client, opts \\ [])

@spec list(
  ExLine.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, ExLine.Error.t()}

Gets a paginated list of coupons.

opts[:status] filters by status (a list, e.g. ["RUNNING", "CLOSED"]); opts[:start] is the continuation token; opts[:limit] caps the page size.

Ref: https://developers.line.biz/en/reference/messaging-api/#get-coupon-list