promotion

package
v1.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePromotion

func CreatePromotion(data *CreatePromotionParams) (*xendit.Promotion, *xendit.Error)

CreatePromotion creates new promotion.

Example
xendit.Opt.SecretKey = "examplesecretkey"

startTime := time.Now().Add(time.Hour)
endTime := startTime.Add(time.Hour)

createPromotionData := promotion.CreatePromotionParams{
	ReferenceID: "BRI_20_JAN",
	Description: "20% discount applied for all BRI cards",
	BinList: []string{
		"400000",
		"460000",
	},
	DiscountPercent:   20,
	Currency:          "IDR",
	StartTime:         &startTime,
	EndTime:           &endTime,
	ChannelCode:       "BRI",
	MinOriginalAmount: 25000,
	MaxDiscountAmount: 5000,
}

promotionResp, err := promotion.CreatePromotion(&createPromotionData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("created promotion: %+v\n", promotionResp)
Output:

func CreatePromotionWithContext

func CreatePromotionWithContext(ctx context.Context, data *CreatePromotionParams) (*xendit.Promotion, *xendit.Error)

CreatePromotionWithContext creates new promotion with context.

func DeletePromotion

func DeletePromotion(data *DeletePromotionParams) (*xendit.PromotionDeletion, *xendit.Error)

DeletePromotion deletes a promotion.

Example
xendit.Opt.SecretKey = "examplesecretkey"

deletePromotionData := promotion.DeletePromotionParams{
	PromotionID: "36ab1517-208a-4f22-b155-96fb101cb378",
}

promotionResp, err := promotion.DeletePromotion(&deletePromotionData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("deleted promotion: %+v\n", promotionResp)
Output:

func DeletePromotionWithContext

func DeletePromotionWithContext(ctx context.Context, data *DeletePromotionParams) (*xendit.PromotionDeletion, *xendit.Error)

DeletePromotionWithContext deletes a promotion with context.

func GetPromotions

func GetPromotions(data *GetPromotionsParams) ([]xendit.Promotion, *xendit.Error)

GetPromotions gets promotions.

Example
xendit.Opt.SecretKey = "examplesecretkey"

promotions, err := promotion.GetPromotions(&promotion.GetPromotionsParams{
	ReferenceID: "BRI_20_JAN",
})
if err != nil {
	log.Fatal(err)
}

fmt.Printf("retrieved promotions: %+v\n", promotions)
Output:

func GetPromotionsWithContext

func GetPromotionsWithContext(ctx context.Context, data *GetPromotionsParams) ([]xendit.Promotion, *xendit.Error)

GetPromotionsWithContext gets promotions with context.

func UpdatePromotion

func UpdatePromotion(data *UpdatePromotionParams) (*xendit.Promotion, *xendit.Error)

UpdatePromotion updates a promotion.

Example
xendit.Opt.SecretKey = "examplesecretkey"

updatePromotionData := promotion.UpdatePromotionParams{
	PromotionID: "36ab1517-208a-4f22-b155-96fb101cb378",
	Description: "20% discount applied for all BCA cards",
	BinList: []string{
		"123123",
		"456456",
	},
	DiscountPercent: 20,
	Currency:        "IDR",
	ChannelCode:     "BCA",
}

promotionResp, err := promotion.UpdatePromotion(&updatePromotionData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("updated promotion: %+v\n", promotionResp)
Output:

func UpdatePromotionWithContext

func UpdatePromotionWithContext(ctx context.Context, data *UpdatePromotionParams) (*xendit.Promotion, *xendit.Error)

UpdatePromotionWithContext updates a promotion with context.

Types

type Client

type Client struct {
	Opt          *xendit.Option
	APIRequester xendit.APIRequester
}

Client is the client used to invoke ewallet API.

func (*Client) CreatePromotion

func (c *Client) CreatePromotion(data *CreatePromotionParams) (*xendit.Promotion, *xendit.Error)

CreatePromotion creates new promotion.

func (*Client) CreatePromotionWithContext

func (c *Client) CreatePromotionWithContext(ctx context.Context, data *CreatePromotionParams) (*xendit.Promotion, *xendit.Error)

CreatePromotionWithContext creates new promotion with context.

func (*Client) DeletePromotion

func (c *Client) DeletePromotion(data *DeletePromotionParams) (*xendit.PromotionDeletion, *xendit.Error)

DeletePromotion deletes a promotion.

func (*Client) DeletePromotionWithContext

func (c *Client) DeletePromotionWithContext(ctx context.Context, data *DeletePromotionParams) (*xendit.PromotionDeletion, *xendit.Error)

DeletePromotionWithContext deletes a promotion with context.

func (*Client) GetPromotions

func (c *Client) GetPromotions(data *GetPromotionsParams) ([]xendit.Promotion, *xendit.Error)

GetPromotions gets promotions.

func (*Client) GetPromotionsWithContext

func (c *Client) GetPromotionsWithContext(ctx context.Context, data *GetPromotionsParams) ([]xendit.Promotion, *xendit.Error)

GetPromotionsWithContext gets promotions with context.

func (*Client) UpdatePromotion

func (c *Client) UpdatePromotion(data *UpdatePromotionParams) (*xendit.Promotion, *xendit.Error)

UpdatePromotion updates a promotion.

func (*Client) UpdatePromotionWithContext

func (c *Client) UpdatePromotionWithContext(ctx context.Context, data *UpdatePromotionParams) (*xendit.Promotion, *xendit.Error)

UpdatePromotionWithContext updates a promotion with context.

type CreatePromotionParams

type CreatePromotionParams struct {
	ReferenceID       string     `json:"reference_id" validate:"required"`
	Description       string     `json:"description" validate:"required"`
	PromoCode         string     `json:"promo_code,omitempty"`
	BinList           []string   `json:"bin_list,omitempty"`
	ChannelCode       string     `json:"channel_code,omitempty"`
	DiscountPercent   float64    `json:"discount_percent,omitempty"`
	DiscountAmount    float64    `json:"discount_amount,omitempty"`
	Currency          string     `json:"currency" validate:"required"`
	StartTime         *time.Time `json:"start_time" validate:"required"`
	EndTime           *time.Time `json:"end_time" validate:"required"`
	MinOriginalAmount float64    `json:"min_original_amount,omitempty"`
	MaxDiscountAmount float64    `json:"max_discount_amount,omitempty"`
}

CreatePromotionParams contains parameters for CreatePromotion.

type DeletePromotionParams

type DeletePromotionParams struct {
	PromotionID string `validate:"required"`
}

DeletePromotionParams contains parameters for DeletePromotion.

type GetPromotionsParams

type GetPromotionsParams struct {
	ReferenceID string
	Status      string
	Bin         string
	ChannelCode string
	Currency    string
}

GetPromotionsParams contains parameters for GetPromotions.

func (*GetPromotionsParams) QueryString

func (p *GetPromotionsParams) QueryString() string

QueryString creates query string from GetPromotionsParams, ignores nil values.

type UpdatePromotionParams

type UpdatePromotionParams struct {
	PromotionID       string     `json:"-" validate:"required"`
	Description       string     `json:"description,omitempty"`
	PromoCode         string     `json:"promo_code,omitempty"`
	BinList           []string   `json:"bin_list,omitempty"`
	ChannelCode       string     `json:"channel_code,omitempty"`
	DiscountPercent   float64    `json:"discount_percent,omitempty"`
	DiscountAmount    float64    `json:"discount_amount,omitempty"`
	Currency          string     `json:"currency,omitempty"`
	StartTime         *time.Time `json:"start_time,omitempty"`
	EndTime           *time.Time `json:"end_time,omitempty"`
	MinOriginalAmount float64    `json:"min_original_amount,omitempty"`
	MaxDiscountAmount float64    `json:"max_discount_amount,omitempty"`
}

UpdatePromotionParams contains parameters for UpdatePromotion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL