Skip to content

Commit

Permalink
Merge pull request #11 from HaiD84/discard_gift_card
Browse files Browse the repository at this point in the history
Discard gift card
  • Loading branch information
luza authored Jan 18, 2022
2 parents e864ec5 + a740163 commit 344e7bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ClientInterface interface {
DiscardTicket(ctx context.Context, req *DiscardTicketRequest) (*DiscardTicketReply, error)
GetSettings(ctx context.Context, req *GetSettingsQuery) (*GetSettingsReply, error)
ActivateGiftCard(ctx context.Context, req *ActivateGiftCardRequest) (*ActivateGiftCardReply, error)
DiscardGiftCard(ctx context.Context, req *DiscardGiftCardRequest) (*DiscardGiftCardReply, error)
GenerateGiftCard(ctx context.Context, req *GenerateGiftCardRequest) (*GenerateGiftCardReply, error)
}

Expand Down Expand Up @@ -398,6 +399,18 @@ func (c *Client) ActivateGiftCard(ctx context.Context, req *ActivateGiftCardRequ
return &resp, nil
}

func (c *Client) DiscardGiftCard(ctx context.Context, req *DiscardGiftCardRequest) (*DiscardGiftCardReply, error) {
respBody, err := c.request(ctx, "/discard-gift-card", req)
if err != nil {
return nil, err
}
var resp DiscardGiftCardReply
if err = json.Unmarshal(respBody, &resp); err != nil {
return nil, err
}
return &resp, nil
}

func (c *Client) GenerateGiftCard(ctx context.Context, req *GenerateGiftCardRequest) (*GenerateGiftCardReply, error) {
respBody, err := c.request(ctx, "/generate-gift-card", req)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions models_gift_card.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ type ActivateGiftCardReply struct {
GiftCard GiftCardReply `json:"giftCard"`
}

// DiscardGiftCardRequest request model for discard-gift-card request
type DiscardGiftCardRequest struct {
TxID string `json:"txid"`
GiftCard GiftCardQuery `json:"giftCard"`
}

// DiscardGiftCardReply response model for discard-gift-card request
type DiscardGiftCardReply struct {
}

type GenerateGiftCardRequest struct {
Code string `json:"code"`
}
Expand Down

0 comments on commit 344e7bd

Please sign in to comment.