122 lines
5.8 KiB
Go
122 lines
5.8 KiB
Go
package dto
|
|
|
|
import (
|
|
"browser.local/platform/domain"
|
|
"time"
|
|
)
|
|
|
|
type GameGiftItemRequest struct {
|
|
CatalogItemKey string `json:"catalogItemKey"`
|
|
Quantity int `json:"quantity"`
|
|
}
|
|
type GameGiftItemResponse struct {
|
|
CatalogItemKey string `json:"catalogItemKey"`
|
|
Label string `json:"label"`
|
|
Quantity int `json:"quantity"`
|
|
}
|
|
type GameGiftCatalogRequest struct {
|
|
ID string `json:"id,omitempty"`
|
|
Name string `json:"name"`
|
|
GameVersion string `json:"gameVersion"`
|
|
Items []GameGiftItemRequest `json:"items"`
|
|
}
|
|
type GameGiftCatalogResponse struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
GameVersion string `json:"gameVersion"`
|
|
DraftItems []GameGiftItemResponse `json:"draftItems"`
|
|
LatestRevisionID string `json:"latestRevisionId,omitempty"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
type GameGiftCatalogListResponse struct {
|
|
Items []GameGiftCatalogResponse `json:"items"`
|
|
}
|
|
type GameGiftRevisionResponse struct {
|
|
ID string `json:"id"`
|
|
CatalogID string `json:"catalogId"`
|
|
Revision int `json:"revision"`
|
|
GameVersion string `json:"gameVersion"`
|
|
Items []GameGiftItemResponse `json:"items"`
|
|
PublishedBy string `json:"publishedBy"`
|
|
PublishedAt time.Time `json:"publishedAt"`
|
|
}
|
|
type GameGiftRevisionListResponse struct {
|
|
Items []GameGiftRevisionResponse `json:"items"`
|
|
}
|
|
type GameGiftGrantRequest struct {
|
|
RevisionID string `json:"revisionId"`
|
|
GamePlayerRecordID string `json:"gamePlayerRecordId"`
|
|
Notice string `json:"notice"`
|
|
IdempotencyKey string `json:"idempotencyKey"`
|
|
}
|
|
type GameGiftGrantResponse struct {
|
|
ID string `json:"id"`
|
|
RevisionID string `json:"revisionId"`
|
|
RevisionNumber int `json:"revisionNumber"`
|
|
GameVersion string `json:"gameVersion"`
|
|
Items []GameGiftItemResponse `json:"items"`
|
|
GamePlayerRecordID string `json:"gamePlayerRecordId"`
|
|
PlayerDisplayName string `json:"playerDisplayName"`
|
|
Notice string `json:"notice"`
|
|
RequesterID string `json:"requesterId"`
|
|
ApproverID string `json:"approverId,omitempty"`
|
|
Status string `json:"status"`
|
|
DeliverySummary string `json:"deliverySummary,omitempty"`
|
|
NotificationSummary string `json:"notificationSummary,omitempty"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
ApprovedAt time.Time `json:"approvedAt,omitempty"`
|
|
CompletedAt time.Time `json:"completedAt,omitempty"`
|
|
}
|
|
type GameGiftGrantListResponse struct {
|
|
Items []GameGiftGrantResponse `json:"items"`
|
|
}
|
|
|
|
func (r GameGiftCatalogRequest) ToDomain() domain.GameGiftCatalogRequest {
|
|
items := make([]domain.GameGiftItem, len(r.Items))
|
|
for i, item := range r.Items {
|
|
def, _ := domain.SCUMGiftItemForVersion(r.GameVersion, item.CatalogItemKey)
|
|
items[i] = domain.GameGiftItem{CatalogItemKey: item.CatalogItemKey, Label: def.Label, Quantity: item.Quantity}
|
|
}
|
|
return domain.GameGiftCatalogRequest{ID: r.ID, Name: r.Name, GameVersion: r.GameVersion, Items: items}
|
|
}
|
|
func (r GameGiftGrantRequest) ToDomain() domain.GameGiftGrantRequest {
|
|
return domain.GameGiftGrantRequest{RevisionID: r.RevisionID, GamePlayerRecordID: r.GamePlayerRecordID, Notice: r.Notice, IdempotencyKey: r.IdempotencyKey}
|
|
}
|
|
func giftItems(items []domain.GameGiftItem) []GameGiftItemResponse {
|
|
out := make([]GameGiftItemResponse, len(items))
|
|
for i, item := range items {
|
|
out[i] = GameGiftItemResponse{CatalogItemKey: item.CatalogItemKey, Label: item.Label, Quantity: item.Quantity}
|
|
}
|
|
return out
|
|
}
|
|
func GameGiftCatalogFromDomain(v domain.GameGiftCatalog) GameGiftCatalogResponse {
|
|
return GameGiftCatalogResponse{ID: v.ID, Name: v.Name, GameVersion: v.GameVersion, DraftItems: giftItems(v.DraftItems), LatestRevisionID: v.LatestRevisionID, UpdatedAt: v.UpdatedAt}
|
|
}
|
|
func GameGiftCatalogsFromDomain(v []domain.GameGiftCatalog) GameGiftCatalogListResponse {
|
|
out := make([]GameGiftCatalogResponse, len(v))
|
|
for i, x := range v {
|
|
out[i] = GameGiftCatalogFromDomain(x)
|
|
}
|
|
return GameGiftCatalogListResponse{Items: out}
|
|
}
|
|
func GameGiftRevisionFromDomain(v domain.GameGiftRevision) GameGiftRevisionResponse {
|
|
return GameGiftRevisionResponse{ID: v.ID, CatalogID: v.CatalogID, Revision: v.Revision, GameVersion: v.GameVersion, Items: giftItems(v.Items), PublishedBy: v.PublishedBy, PublishedAt: v.PublishedAt}
|
|
}
|
|
func GameGiftRevisionsFromDomain(v []domain.GameGiftRevision) GameGiftRevisionListResponse {
|
|
out := make([]GameGiftRevisionResponse, len(v))
|
|
for i, x := range v {
|
|
out[i] = GameGiftRevisionFromDomain(x)
|
|
}
|
|
return GameGiftRevisionListResponse{Items: out}
|
|
}
|
|
func GameGiftGrantFromDomain(v domain.GameGiftGrant) GameGiftGrantResponse {
|
|
return GameGiftGrantResponse{ID: v.ID, RevisionID: v.RevisionID, RevisionNumber: v.RevisionNumber, GameVersion: v.GameVersion, Items: giftItems(v.Items), GamePlayerRecordID: v.GamePlayerRecordID, PlayerDisplayName: v.PlayerDisplayName, Notice: v.Notice, RequesterID: v.RequesterID, ApproverID: v.ApproverID, Status: string(v.Status), DeliverySummary: v.DeliverySummary, NotificationSummary: v.NotificationSummary, CreatedAt: v.CreatedAt, ApprovedAt: v.ApprovedAt, CompletedAt: v.CompletedAt}
|
|
}
|
|
func GameGiftGrantsFromDomain(v []domain.GameGiftGrant) GameGiftGrantListResponse {
|
|
out := make([]GameGiftGrantResponse, len(v))
|
|
for i, x := range v {
|
|
out[i] = GameGiftGrantFromDomain(x)
|
|
}
|
|
return GameGiftGrantListResponse{Items: out}
|
|
}
|