-
Notifications
You must be signed in to change notification settings - Fork 6
/
queryItemsV2.go
114 lines (105 loc) · 4.44 KB
/
queryItemsV2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
// Code generated. DO NOT EDIT.
package item
import (
"encoding/json"
"github.com/AccelByte/accelbyte-go-sdk/platform-sdk/pkg/platformclient/item"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/platform"
"github.com/AccelByte/sample-apps/pkg/repository"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
// QueryItemsV2Cmd represents the QueryItemsV2 command
var QueryItemsV2Cmd = &cobra.Command{
Use: "queryItemsV2",
Short: "Query items V2",
Long: `Query items V2`,
RunE: func(cmd *cobra.Command, args []string) error {
itemService := &platform.ItemService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace, _ := cmd.Flags().GetString("namespace")
appType, _ := cmd.Flags().GetString("appType")
availableDate, _ := cmd.Flags().GetString("availableDate")
baseAppId, _ := cmd.Flags().GetString("baseAppId")
categoryPath, _ := cmd.Flags().GetString("categoryPath")
features, _ := cmd.Flags().GetString("features")
includeSubCategoryItem, _ := cmd.Flags().GetBool("includeSubCategoryItem")
itemName, _ := cmd.Flags().GetString("itemName")
itemStatus, _ := cmd.Flags().GetString("itemStatus")
itemTypeString := cmd.Flag("itemType").Value.String()
var itemType []string
errItemType := json.Unmarshal([]byte(itemTypeString), &itemType)
if errItemType != nil {
return errItemType
}
limit, _ := cmd.Flags().GetInt32("limit")
offset, _ := cmd.Flags().GetInt32("offset")
region, _ := cmd.Flags().GetString("region")
sectionExclusive, _ := cmd.Flags().GetBool("sectionExclusive")
sortByString := cmd.Flag("sortBy").Value.String()
var sortBy []string
errSortBy := json.Unmarshal([]byte(sortByString), &sortBy)
if errSortBy != nil {
return errSortBy
}
storeId, _ := cmd.Flags().GetString("storeId")
tags, _ := cmd.Flags().GetString("tags")
targetNamespace, _ := cmd.Flags().GetString("targetNamespace")
withTotal, _ := cmd.Flags().GetBool("withTotal")
input := &item.QueryItemsV2Params{
Namespace: namespace,
AppType: &appType,
AvailableDate: &availableDate,
BaseAppID: &baseAppId,
CategoryPath: &categoryPath,
Features: &features,
IncludeSubCategoryItem: &includeSubCategoryItem,
ItemName: &itemName,
ItemStatus: &itemStatus,
ItemType: itemType,
Limit: &limit,
Offset: &offset,
Region: ®ion,
SectionExclusive: §ionExclusive,
SortBy: sortBy,
StoreID: &storeId,
Tags: &tags,
TargetNamespace: &targetNamespace,
WithTotal: &withTotal,
}
ok, errOK := itemService.QueryItemsV2Short(input)
if errOK != nil {
logrus.Error(errOK)
return errOK
}
logrus.Infof("Response CLI success: %+v", ok)
return nil
},
}
func init() {
QueryItemsV2Cmd.Flags().String("namespace", "", "Namespace")
_ = QueryItemsV2Cmd.MarkFlagRequired("namespace")
QueryItemsV2Cmd.Flags().String("appType", "", "App type")
QueryItemsV2Cmd.Flags().String("availableDate", "", "Available date")
QueryItemsV2Cmd.Flags().String("baseAppId", "", "Base app id")
QueryItemsV2Cmd.Flags().String("categoryPath", "", "Category path")
QueryItemsV2Cmd.Flags().String("features", "", "Features")
QueryItemsV2Cmd.Flags().Bool("includeSubCategoryItem", false, "Include sub category item")
QueryItemsV2Cmd.Flags().String("itemName", "", "Item name")
QueryItemsV2Cmd.Flags().String("itemStatus", "", "Item status")
QueryItemsV2Cmd.Flags().String("itemType", "", "Item type")
QueryItemsV2Cmd.Flags().Int32("limit", 20, "Limit")
QueryItemsV2Cmd.Flags().Int32("offset", 0, "Offset")
QueryItemsV2Cmd.Flags().String("region", "", "Region")
QueryItemsV2Cmd.Flags().Bool("sectionExclusive", false, "Section exclusive")
QueryItemsV2Cmd.Flags().String("sortBy", "", "Sort by")
QueryItemsV2Cmd.Flags().String("storeId", "", "Store id")
QueryItemsV2Cmd.Flags().String("tags", "", "Tags")
QueryItemsV2Cmd.Flags().String("targetNamespace", "", "Target namespace")
QueryItemsV2Cmd.Flags().Bool("withTotal", false, "With total")
}