469 lines
19 KiB
Go
469 lines
19 KiB
Go
package handlers
|
|
|
|
import (
|
|
"Rezina-Backend/internal/domain"
|
|
"errors"
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
"strconv"
|
|
)
|
|
|
|
func affiliateResponse(c *fiber.Ctx, data any, err error) error {
|
|
if err != nil {
|
|
if errors.Is(err, domain.ErrAffiliateInput) {
|
|
return fiber.NewError(400, "Invalid affiliate fields; check amounts, status, terms, and required notes")
|
|
}
|
|
if errors.Is(err, pgx.ErrNoRows) {
|
|
return fiber.NewError(404, "Affiliate record not found")
|
|
}
|
|
var p *pgconn.PgError
|
|
if errors.As(err, &p) {
|
|
if p.Code == "23514" || p.Code == "23505" {
|
|
return fiber.NewError(409, "Affiliate operation conflicts with current status, balance, or payment reference")
|
|
}
|
|
if p.Code == "P0002" {
|
|
return fiber.NewError(404, "Affiliate record not found")
|
|
}
|
|
}
|
|
return fiber.NewError(500, "Unable to process affiliate request")
|
|
}
|
|
return c.JSON(domain.Response{Success: true, StatusCode: 200, Message: "Affiliate request successful", Data: data})
|
|
}
|
|
func affiliateFilter(c *fiber.Ctx) (int64, error) {
|
|
raw := c.Query("user_id")
|
|
if raw == "" {
|
|
return 0, nil
|
|
}
|
|
id, e := strconv.ParseInt(raw, 10, 64)
|
|
if e != nil || id <= 0 {
|
|
return 0, fiber.NewError(400, "Invalid user_id")
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
// GetAffiliateSelf godoc
|
|
// @Summary Get my affiliate dashboard and program rules
|
|
// @Description Returns the authenticated learner application (null before applying), versioned program rules, current settings, referral counts, and separate currency balances. Approved affiliates receive a share code and, when configured, a share URL. No referred-user personal data is exposed.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateDashboard}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/affiliates/me [get]
|
|
func (h *Handler) GetAffiliateSelf(c *fiber.Ctx) error {
|
|
user, err := referralLearner(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.Self(c.Context(), user)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// ApplyAffiliate godoc
|
|
// @Summary Apply to the affiliate program
|
|
// @Description Requires an active learner, accept_terms=true, the current terms_version from GET /affiliates/me, and a 10-2000 character application. New applications are PENDING. Rejected applicants may reapply; pending, approved, or suspended accounts cannot replace their application.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateMutationData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/affiliates/apply [post]
|
|
// @Accept json
|
|
// @Param body body domain.AffiliateApplicationInput true "Request"
|
|
func (h *Handler) ApplyAffiliate(c *fiber.Ctx) error {
|
|
user, err := referralLearner(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var input domain.AffiliateApplicationInput
|
|
if err := c.BodyParser(&input); err != nil {
|
|
return fiber.NewError(400, "Invalid request body")
|
|
}
|
|
data, err := h.affiliateSvc.Apply(c.Context(), user, input)
|
|
return affiliateResponse(c, domain.AffiliateMutationData{ID: data}, err)
|
|
}
|
|
|
|
// GetAffiliateCommissions godoc
|
|
// @Summary List my affiliate commissions
|
|
// @Description Returns only the authenticated learner earnings. Status is PENDING during the holding period, AVAILABLE after maturity, RESERVED for a requested payout, PAID after payout settlement, or REVERSED. Monetary values are decimal strings and never combined across currencies.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateCommissionData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/affiliates/commissions [get]
|
|
// @Param limit query int false "Page size (1-100)"
|
|
// @Param offset query int false "Offset"
|
|
func (h *Handler) GetAffiliateCommissions(c *fiber.Ctx) error {
|
|
user, err := referralLearner(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
limit, offset, err := referralPagination(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.Commissions(c.Context(), user, limit, offset)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// GetAffiliatePayouts godoc
|
|
// @Summary List my affiliate payouts
|
|
// @Description Returns only the authenticated learner payout requests, including snapshotted beneficiary details and external transfer references. Optional status is REQUESTED, PAID, or REJECTED.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliatePayoutData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/affiliates/payouts [get]
|
|
// @Param limit query int false "Page size (1-100)"
|
|
// @Param offset query int false "Offset"
|
|
// @Param status query string false "Status filter"
|
|
func (h *Handler) GetAffiliatePayouts(c *fiber.Ctx) error {
|
|
user, err := referralLearner(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
limit, offset, err := referralPagination(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.Payouts(c.Context(), user, c.Query("status"), limit, offset)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// RequestAffiliatePayout godoc
|
|
// @Summary Request payout of available affiliate earnings
|
|
// @Description Requires an approved active affiliate. Reserves all matured available earnings in the requested currency after outstanding recovery debt. The server calculates the amount; clients cannot select an amount. One REQUESTED payout per currency is allowed. This endpoint does not transfer money.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateMutationData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/affiliates/payouts [post]
|
|
// @Accept json
|
|
// @Param body body domain.AffiliatePayoutInput true "Request"
|
|
func (h *Handler) RequestAffiliatePayout(c *fiber.Ctx) error {
|
|
user, err := referralLearner(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var input domain.AffiliatePayoutInput
|
|
if err := c.BodyParser(&input); err != nil {
|
|
return fiber.NewError(400, "Invalid request body")
|
|
}
|
|
data, err := h.affiliateSvc.RequestPayout(c.Context(), user, input)
|
|
return affiliateResponse(c, domain.AffiliateMutationData{ID: data}, err)
|
|
}
|
|
|
|
// ListAffiliates godoc
|
|
// @Summary List affiliate applications
|
|
// @Description ADMIN and SUPER_ADMIN only. Returns applications and learner contact details. Optional status is PENDING, APPROVED, REJECTED, or SUSPENDED. Lists return items, total_count, limit, and offset.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateListData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates [get]
|
|
// @Param limit query int false "Page size (1-100)"
|
|
// @Param offset query int false "Offset"
|
|
// @Param status query string false "Status filter"
|
|
func (h *Handler) ListAffiliates(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
limit, offset, err := referralPagination(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.List(c.Context(), c.Query("status"), limit, offset)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// ReviewAffiliate godoc
|
|
// @Summary Approve, reject, or suspend an affiliate
|
|
// @Description ADMIN and SUPER_ADMIN only. The path id is the affiliate learner user ID. Allowed transitions: PENDING to APPROVED or REJECTED, APPROVED to SUSPENDED, and SUSPENDED to APPROVED. A 3-2000 character review note is required. Changes are audited.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateMutationData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 404 {object} domain.ErrorResponse "Record not found"
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/{id}/review [put]
|
|
// @Param id path int true "Record ID"
|
|
// @Accept json
|
|
// @Param body body domain.AffiliateReviewInput true "Request"
|
|
func (h *Handler) ReviewAffiliate(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
|
if err != nil || id <= 0 {
|
|
return fiber.NewError(400, "Invalid record ID")
|
|
}
|
|
var input domain.AffiliateReviewInput
|
|
if err := c.BodyParser(&input); err != nil {
|
|
return fiber.NewError(400, "Invalid request body")
|
|
}
|
|
data, err := h.affiliateSvc.Review(c.Context(), id, actor, input)
|
|
return affiliateResponse(c, domain.AffiliateMutationData{ID: data}, err)
|
|
}
|
|
|
|
// GetAffiliateSettings godoc
|
|
// @Summary Get affiliate program settings
|
|
// @Description ADMIN and SUPER_ADMIN only. Returns the commission percentage, FIRST_PURCHASE or EVERY_COURSE policy, attribution window, earning hold, and learner share URL base. Initial defaults are 0 percent, FIRST_PURCHASE, 30 attribution days, and 14 holding days.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateSettings}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/settings [get]
|
|
func (h *Handler) GetAffiliateSettings(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
data, err := h.affiliateSvc.Settings(c.Context())
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// UpdateAffiliateSettings godoc
|
|
// @Summary Update affiliate program settings
|
|
// @Description ADMIN and SUPER_ADMIN only. Commission percentage is 0-100 with at most two decimals; zero disables future earnings. Attribution is 1-365 days and holding is 0-365 days. FIRST_PURCHASE rewards the first paid purchase; EVERY_COURSE rewards each distinct eligible course. Rates and holds are snapshotted on successful payment; attribution expiry is snapshotted when the code is applied. Changes are audited. Optional share_base_url must be an absolute HTTP(S) learner URL; share links append ref=CODE.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateSettings}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/settings [put]
|
|
// @Accept json
|
|
// @Param body body domain.AffiliateSettingsInput true "Request"
|
|
func (h *Handler) UpdateAffiliateSettings(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
var input domain.AffiliateSettingsInput
|
|
if err := c.BodyParser(&input); err != nil {
|
|
return fiber.NewError(400, "Invalid request body")
|
|
}
|
|
data, err := h.affiliateSvc.UpdateSettings(c.Context(), actor, input)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// ListAffiliateCommissions godoc
|
|
// @Summary List affiliate course commissions
|
|
// @Description ADMIN and SUPER_ADMIN only. Lists the course commission ledger across affiliates or for a positive user_id filter. Amount and commission_percent are decimal strings. Includes maturity, payout association, and reversal information.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateCommissionData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/commissions [get]
|
|
// @Param limit query int false "Page size (1-100)"
|
|
// @Param offset query int false "Offset"
|
|
// @Param user_id query int false "Affiliate user ID"
|
|
func (h *Handler) ListAffiliateCommissions(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
limit, offset, err := referralPagination(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
user, err := affiliateFilter(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.Commissions(c.Context(), user, limit, offset)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// ReverseAffiliateCommission godoc
|
|
// @Summary Reverse an affiliate commission
|
|
// @Description ADMIN and SUPER_ADMIN only. The path id is the commission ID. Requires a 3-2000 character reason. Reversing an earning rejects any pending payout in the same affiliate/currency and releases reservations. Already-paid earnings become recovery debt deducted from future payouts. Repeated reversal is idempotent. This does not refund the learner or revoke course access.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateMutationData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 404 {object} domain.ErrorResponse "Record not found"
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/commissions/{id}/reverse [post]
|
|
// @Param id path int true "Record ID"
|
|
// @Accept json
|
|
// @Param body body domain.AffiliateReversalInput true "Request"
|
|
func (h *Handler) ReverseAffiliateCommission(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
|
if err != nil || id <= 0 {
|
|
return fiber.NewError(400, "Invalid record ID")
|
|
}
|
|
var input domain.AffiliateReversalInput
|
|
if err := c.BodyParser(&input); err != nil {
|
|
return fiber.NewError(400, "Invalid request body")
|
|
}
|
|
data, err := h.affiliateSvc.Reverse(c.Context(), id, actor, input.Reason)
|
|
return affiliateResponse(c, domain.AffiliateMutationData{ID: data}, err)
|
|
}
|
|
|
|
// ListAffiliatePayouts godoc
|
|
// @Summary List affiliate payout requests
|
|
// @Description ADMIN and SUPER_ADMIN only. Lists payout requests and beneficiary details. Optional status is REQUESTED, PAID, or REJECTED. Optional positive user_id filters one affiliate. These sensitive records must only be shown to authorized administrators.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliatePayoutData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/payouts [get]
|
|
// @Param limit query int false "Page size (1-100)"
|
|
// @Param offset query int false "Offset"
|
|
// @Param user_id query int false "Affiliate user ID"
|
|
// @Param status query string false "Status filter"
|
|
func (h *Handler) ListAffiliatePayouts(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
limit, offset, err := referralPagination(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
user, err := affiliateFilter(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.Payouts(c.Context(), user, c.Query("status"), limit, offset)
|
|
return affiliateResponse(c, data, err)
|
|
}
|
|
|
|
// ReviewAffiliatePayout godoc
|
|
// @Summary Record an externally paid payout or reject a request
|
|
// @Description ADMIN and SUPER_ADMIN only. The path id is the payout request ID. Review a REQUESTED payout as PAID or REJECTED with a 3-2000 character note. PAID requires an already completed external transfer and a unique 3-120 character payment_reference; this API never sends money. Affiliate must still be approved and active. REJECTED releases reservations. Matching repeated reviews are idempotent; conflicting final-state reviews return 409.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateMutationData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 404 {object} domain.ErrorResponse "Record not found"
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/payouts/{id}/review [put]
|
|
// @Param id path int true "Record ID"
|
|
// @Accept json
|
|
// @Param body body domain.AffiliatePayoutReviewInput true "Request"
|
|
func (h *Handler) ReviewAffiliatePayout(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
|
if err != nil || id <= 0 {
|
|
return fiber.NewError(400, "Invalid record ID")
|
|
}
|
|
var input domain.AffiliatePayoutReviewInput
|
|
if err := c.BodyParser(&input); err != nil {
|
|
return fiber.NewError(400, "Invalid request body")
|
|
}
|
|
data, err := h.affiliateSvc.ReviewPayout(c.Context(), id, actor, input)
|
|
return affiliateResponse(c, domain.AffiliateMutationData{ID: data}, err)
|
|
}
|
|
|
|
// GetAffiliateEvents godoc
|
|
// @Summary List affiliate audit events
|
|
// @Description ADMIN and SUPER_ADMIN only. Returns newest-first application, settings, payout, and commission reversal audit events. Details contain event-specific fields without beneficiary account details. Optional positive user_id filters an affiliate. This list returns items, limit, and offset without a total_count.
|
|
// @Tags affiliates
|
|
// @Security Bearer
|
|
// @Produce json
|
|
// @Success 200 {object} domain.Response{data=domain.AffiliateEventData}
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 401 {object} domain.ErrorResponse
|
|
// @Failure 403 {object} domain.ErrorResponse
|
|
// @Failure 409 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/admin/affiliates/events [get]
|
|
// @Param limit query int false "Page size (1-100)"
|
|
// @Param offset query int false "Offset"
|
|
// @Param user_id query int false "Affiliate user ID"
|
|
func (h *Handler) GetAffiliateEvents(c *fiber.Ctx) error {
|
|
actor, err := referralAdmin(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = actor
|
|
limit, offset, err := referralPagination(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
user, err := affiliateFilter(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := h.affiliateSvc.Events(c.Context(), user, limit, offset)
|
|
return affiliateResponse(c, data, err)
|
|
}
|