diff --git a/samples/sample-apps/cmd/adminGetProfile.go b/samples/sample-apps/cmd/adminGetProfile.go index 8223a67da..16786e71e 100644 --- a/samples/sample-apps/cmd/adminGetProfile.go +++ b/samples/sample-apps/cmd/adminGetProfile.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -21,14 +22,19 @@ var adminGetProfile = &cobra.Command{ Long: `Admin Get user profile`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("adminGetProfile called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() profileId := cmd.Flag("profileId").Value.String() userId := cmd.Flag("userId").Value.String() - ok, err := gameProfileService.GetProfile(namespace, userId, profileId) + input := &game_profile.GetProfileParams{ + Namespace: namespace, + ProfileID: profileId, + UserID: userId, + } + ok, err := gameProfileService.GetProfile(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/adminGetUserProfiles.go b/samples/sample-apps/cmd/adminGetUserProfiles.go index 3465a7e05..d5ea2ecd6 100644 --- a/samples/sample-apps/cmd/adminGetUserProfiles.go +++ b/samples/sample-apps/cmd/adminGetUserProfiles.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -21,13 +22,17 @@ var adminGetUserProfiles = &cobra.Command{ Long: `Admin Get user profiles`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("adminGetUserProfiles called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() - ok, err := gameProfileService.GetUserProfiles(namespace, userId) + input := &game_profile.GetUserProfilesParams{ + Namespace: namespace, + UserID: userId, + } + ok, err := gameProfileService.GetUserProfiles(input) if err != nil { logrus.Error(err) return err diff --git a/samples/sample-apps/cmd/createProfile.go b/samples/sample-apps/cmd/createProfile.go index 42b71e4ff..c5e8f7931 100644 --- a/samples/sample-apps/cmd/createProfile.go +++ b/samples/sample-apps/cmd/createProfile.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,9 +23,9 @@ var createProfile = &cobra.Command{ Long: `Public Get user profiles`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("createProfile called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() @@ -34,7 +35,12 @@ var createProfile = &cobra.Command{ if err != nil { return err } - err = gameProfileService.PublicCreateProfile(namespace, userId, gameProfileRequest) + input := &game_profile.PublicCreateProfileParams{ + Body: gameProfileRequest, + Namespace: namespace, + UserID: userId, + } + err = gameProfileService.PublicCreateProfile(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/createStat.go b/samples/sample-apps/cmd/createStat.go index 6f4a9931a..8bb6353dd 100644 --- a/samples/sample-apps/cmd/createStat.go +++ b/samples/sample-apps/cmd/createStat.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,9 +23,9 @@ var createStatCmd = &cobra.Command{ Long: `Create Stat`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("createStat called") - socialService := &service.StatisticConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.StatConfigurationService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() bodyString := cmd.Flag("body").Value.String() @@ -33,7 +34,11 @@ var createStatCmd = &cobra.Command{ if errContent != nil { return errContent } - stat, err := socialService.CreateStat(namespace, body) + input := &stat_configuration.CreateStatParams{ + Body: body, + Namespace: namespace, + } + stat, err := socialService.CreateStat(input) response, err := json.MarshalIndent(stat, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/createUserSlot.go b/samples/sample-apps/cmd/createUserSlot.go index 341fa9738..9fe217f1a 100644 --- a/samples/sample-apps/cmd/createUserSlot.go +++ b/samples/sample-apps/cmd/createUserSlot.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "os" @@ -22,9 +23,9 @@ var createUserSlotCmd = &cobra.Command{ Long: `Create user slot`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("createUserSlot called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() @@ -42,7 +43,16 @@ var createUserSlotCmd = &cobra.Command{ if err != nil { return err } - err = socialService.PublicCreateUserNamespaceSlot(namespace, userId, &checksum, &customAttribute, &label, tags, file) + input := &slot.PublicCreateUserNamespaceSlotParams{ + Checksum: &checksum, + CustomAttribute: &customAttribute, + File: file, + Label: &label, + Namespace: namespace, + Tags: tags, + UserID: userId, + } + err = socialService.PublicCreateUserNamespaceSlot(input) if err != nil { return err } diff --git a/samples/sample-apps/cmd/deleteProfile.go b/samples/sample-apps/cmd/deleteProfile.go index ddced7ac3..8c6daf5c4 100644 --- a/samples/sample-apps/cmd/deleteProfile.go +++ b/samples/sample-apps/cmd/deleteProfile.go @@ -7,7 +7,8 @@ package cmd import ( "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,14 +21,19 @@ var deleteProfile = &cobra.Command{ Long: `Public Delete user profile`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("deleteProfile called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() profileId := cmd.Flag("profileId").Value.String() userId := cmd.Flag("userId").Value.String() - err := gameProfileService.PublicDeleteProfile(namespace, userId, profileId) + input := &game_profile.PublicDeleteProfileParams{ + Namespace: namespace, + ProfileID: profileId, + UserID: userId, + } + err := gameProfileService.PublicDeleteProfile(input) if err != nil { return err } diff --git a/samples/sample-apps/cmd/deleteStat.go b/samples/sample-apps/cmd/deleteStat.go index f6f7f0c82..f4e0459dd 100644 --- a/samples/sample-apps/cmd/deleteStat.go +++ b/samples/sample-apps/cmd/deleteStat.go @@ -6,7 +6,8 @@ package cmd import ( "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -18,13 +19,17 @@ var deleteStatCmd = &cobra.Command{ Short: "delete stat", Long: `delete stat`, RunE: func(cmd *cobra.Command, args []string) error { + socialService := &social.StatConfigurationService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, + } namespace := cmd.Flag("namespace").Value.String() statCode := cmd.Flag("statCode").Value.String() - socialService := &service.StatisticConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + input := &stat_configuration.DeleteStatParams{ + Namespace: namespace, + StatCode: statCode, } - err := socialService.DeleteStat(namespace, statCode) + err := socialService.DeleteStat(input) if err != nil { return err } diff --git a/samples/sample-apps/cmd/deleteUserSlot.go b/samples/sample-apps/cmd/deleteUserSlot.go index 8bbb0ebe7..c0d94b2a8 100644 --- a/samples/sample-apps/cmd/deleteUserSlot.go +++ b/samples/sample-apps/cmd/deleteUserSlot.go @@ -6,7 +6,8 @@ package cmd import ( "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -19,14 +20,19 @@ var deleteUserSlotCmd = &cobra.Command{ Long: `Delete user slot`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("deleteUserSlot called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() slotId := cmd.Flag("slotId").Value.String() - err := socialService.PublicDeleteUserNamespaceSlot(namespace, userId, slotId) + input := &slot.PublicDeleteUserNamespaceSlotParams{ + Namespace: namespace, + SlotID: slotId, + UserID: userId, + } + err := socialService.PublicDeleteUserNamespaceSlot(input) if err != nil { logrus.Error(err) return err diff --git a/samples/sample-apps/cmd/deleteUserSlotConfig.go b/samples/sample-apps/cmd/deleteUserSlotConfig.go index 789480ac1..5b58d6e85 100644 --- a/samples/sample-apps/cmd/deleteUserSlotConfig.go +++ b/samples/sample-apps/cmd/deleteUserSlotConfig.go @@ -6,7 +6,8 @@ package cmd import ( "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot_config" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -19,13 +20,17 @@ var deleteUserSlotConfigCmd = &cobra.Command{ Long: `Delete user slot config`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("deleteUserSlotConfig called") - socialService := &service.SlotConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotConfigService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() - err := socialService.DeleteUserSlotConfig(namespace, userId) + input := &slot_config.DeleteUserSlotConfigParams{ + Namespace: namespace, + UserID: userId, + } + err := socialService.DeleteUserSlotConfig(input) if err != nil { logrus.Error(err) return err diff --git a/samples/sample-apps/cmd/getProfile.go b/samples/sample-apps/cmd/getProfile.go index 3e98bd356..aa1487dfd 100644 --- a/samples/sample-apps/cmd/getProfile.go +++ b/samples/sample-apps/cmd/getProfile.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -21,14 +22,19 @@ var getProfile = &cobra.Command{ Long: `Public Get user profile`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getProfile called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() profileId := cmd.Flag("profileId").Value.String() userId := cmd.Flag("userId").Value.String() - ok, err := gameProfileService.PublicGetProfile(namespace, userId, profileId) + input := &game_profile.PublicGetProfileParams{ + Namespace: namespace, + ProfileID: profileId, + UserID: userId, + } + ok, err := gameProfileService.PublicGetProfile(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/getProfileAttribute.go b/samples/sample-apps/cmd/getProfileAttribute.go index 6f53ceb88..e963e2a29 100644 --- a/samples/sample-apps/cmd/getProfileAttribute.go +++ b/samples/sample-apps/cmd/getProfileAttribute.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -21,15 +22,21 @@ var getProfileAttribute = &cobra.Command{ Long: `Public Get profile attribute`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getProfileAttribute called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() profileId := cmd.Flag("profileId").Value.String() userId := cmd.Flag("userId").Value.String() attributeName := cmd.Flag("attributeName").Value.String() - ok, err := gameProfileService.PublicGetProfileAttribute(namespace, userId, attributeName, profileId) + input := &game_profile.PublicGetProfileAttributeParams{ + AttributeName: attributeName, + Namespace: namespace, + ProfileID: profileId, + UserID: userId, + } + ok, err := gameProfileService.PublicGetProfileAttribute(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/getStat.go b/samples/sample-apps/cmd/getStat.go index 118c05d61..bcf48f29c 100644 --- a/samples/sample-apps/cmd/getStat.go +++ b/samples/sample-apps/cmd/getStat.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,13 +21,17 @@ var getStatCmd = &cobra.Command{ Long: `Get stat`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getStat called") - socialService := &service.StatisticConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.StatConfigurationService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() statCode := cmd.Flag("statCode").Value.String() - stat, err := socialService.GetStat(namespace, statCode) + input := &stat_configuration.GetStatParams{ + Namespace: namespace, + StatCode: statCode, + } + stat, err := socialService.GetStat(input) response, err := json.MarshalIndent(stat, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/getStats.go b/samples/sample-apps/cmd/getStats.go index d984c02fc..1afdf9765 100644 --- a/samples/sample-apps/cmd/getStats.go +++ b/samples/sample-apps/cmd/getStats.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,9 +21,9 @@ var getStatsCmd = &cobra.Command{ Long: `Get stats`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getStats called") - socialService := &service.StatisticConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.StatConfigurationService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() offset, err := cmd.Flags().GetInt32("offset") @@ -33,7 +34,12 @@ var getStatsCmd = &cobra.Command{ if err != nil { return err } - stats, err := socialService.GetStats(namespace, &limit, &offset) + input := &stat_configuration.GetStatsParams{ + Limit: &limit, + Namespace: namespace, + Offset: &offset, + } + stats, err := socialService.GetStats(input) response, err := json.MarshalIndent(stats, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/getStatsByKey.go b/samples/sample-apps/cmd/getStatsByKey.go index 8dda298e5..16879e8cc 100644 --- a/samples/sample-apps/cmd/getStatsByKey.go +++ b/samples/sample-apps/cmd/getStatsByKey.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,9 +21,9 @@ var getStatsByKeywordCmd = &cobra.Command{ Long: `Get stats by keyword`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getStatsByKeyword called") - socialService := &service.StatisticConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.StatConfigurationService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() keyword := cmd.Flag("keyword").Value.String() @@ -34,7 +35,13 @@ var getStatsByKeywordCmd = &cobra.Command{ if err != nil { return err } - stats, err := socialService.QueryStats(namespace, keyword, &limit, &offset) + input := &stat_configuration.QueryStatsParams{ + Keyword: keyword, + Limit: &limit, + Namespace: namespace, + Offset: &offset, + } + stats, err := socialService.QueryStats(input) response, err := json.MarshalIndent(stats, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/getUserGameProfiles.go b/samples/sample-apps/cmd/getUserGameProfiles.go index 2c3c75c0e..cec8d076c 100644 --- a/samples/sample-apps/cmd/getUserGameProfiles.go +++ b/samples/sample-apps/cmd/getUserGameProfiles.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -21,16 +22,20 @@ var getUserGameProfiles = &cobra.Command{ Long: `Public Get user game profile`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserGameProfiles called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userIDsInput := cmd.Flag("userIDs").Value.String() var userIDs []string err := json.Unmarshal([]byte(userIDsInput), &userIDs) logrus.Info(userIDs[0]) - ok, err := gameProfileService.PublicGetUserGameProfiles(namespace, userIDs) + input := &game_profile.PublicGetUserGameProfilesParams{ + Namespace: namespace, + UserIds: userIDs, + } + ok, err := gameProfileService.PublicGetUserGameProfiles(input) if err != nil { return err } else { @@ -49,6 +54,6 @@ func init() { rootCmd.AddCommand(getUserGameProfiles) getUserGameProfiles.Flags().StringP("namespace", "n", "", "User namespace") getUserGameProfiles.MarkFlagRequired("namespace") - getUserGameProfiles.Flags().StringP( "userIDs", "u","", "Array of User ID. Example: '[\"98603754a2854b83bafde85402086956\",\"98603754a2854b83bafde8540208777\"]' ") + getUserGameProfiles.Flags().StringP("userIDs", "u", "", "Array of User ID. Example: '[\"98603754a2854b83bafde85402086956\",\"98603754a2854b83bafde8540208777\"]' ") getUserGameProfiles.MarkFlagRequired("userIDs") } diff --git a/samples/sample-apps/cmd/getUserProfiles.go b/samples/sample-apps/cmd/getUserProfiles.go index 62fad02ed..7194a2318 100644 --- a/samples/sample-apps/cmd/getUserProfiles.go +++ b/samples/sample-apps/cmd/getUserProfiles.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -21,13 +22,17 @@ var getUserProfiles = &cobra.Command{ Long: `Public Get user profiles`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserProfiles called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() - ok, err := gameProfileService.PublicGetUserProfiles(namespace, userId) + input := &game_profile.PublicGetUserProfilesParams{ + Namespace: namespace, + UserID: userId, + } + ok, err := gameProfileService.PublicGetUserProfiles(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/getUserSlotConfig.go b/samples/sample-apps/cmd/getUserSlotConfig.go index df609dd2d..533929381 100644 --- a/samples/sample-apps/cmd/getUserSlotConfig.go +++ b/samples/sample-apps/cmd/getUserSlotConfig.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot_config" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,13 +21,17 @@ var getUserSlotConfigCmd = &cobra.Command{ Long: `Get user slots namespace`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserSlotConfig called") - socialService := &service.SlotConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotConfigService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() - slots, err := socialService.GetUserSlotConfig(namespace, userId) + input := &slot_config.GetUserSlotConfigParams{ + Namespace: namespace, + UserID: userId, + } + slots, err := socialService.GetUserSlotConfig(input) response, err := json.MarshalIndent(slots, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/getUserSlotData.go b/samples/sample-apps/cmd/getUserSlotData.go index f722736d0..c7f822c04 100644 --- a/samples/sample-apps/cmd/getUserSlotData.go +++ b/samples/sample-apps/cmd/getUserSlotData.go @@ -7,7 +7,8 @@ import ( "bytes" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -22,9 +23,9 @@ var getUserSlotDataCmd = &cobra.Command{ Long: `Get user slot data`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserSlotData called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() @@ -33,7 +34,12 @@ var getUserSlotDataCmd = &cobra.Command{ logrus.Infof("Output %v", output) file, err := os.Create(output) writer := bytes.NewBuffer(nil) - _, err = socialService.GetSlotData(namespace, userId, slotId, writer) + input := &slot.GetSlotDataParams{ + Namespace: namespace, + SlotID: slotId, + UserID: userId, + } + _, err = socialService.GetSlotData(input, writer) if err != nil { logrus.Error(err) return err diff --git a/samples/sample-apps/cmd/getUserSlots.go b/samples/sample-apps/cmd/getUserSlots.go index e5e60f314..30455dc5c 100644 --- a/samples/sample-apps/cmd/getUserSlots.go +++ b/samples/sample-apps/cmd/getUserSlots.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,13 +21,17 @@ var getUserSlotsCmd = &cobra.Command{ Long: `Get user slots namespace`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserSlots called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() - slots, err := socialService.GetUserNamespaceSlots(namespace, userId) + input := &slot.GetUserNamespaceSlotsParams{ + Namespace: namespace, + UserID: userId, + } + slots, err := socialService.GetUserNamespaceSlots(input) response, err := json.MarshalIndent(slots, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/getUserSlotsPublic.go b/samples/sample-apps/cmd/getUserSlotsPublic.go index 681a1701b..f730323c7 100644 --- a/samples/sample-apps/cmd/getUserSlotsPublic.go +++ b/samples/sample-apps/cmd/getUserSlotsPublic.go @@ -7,7 +7,8 @@ import ( "bytes" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -22,9 +23,9 @@ var getUserSlotsPublicCmd = &cobra.Command{ Long: `Get user slots data public`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserSlotsPublic called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() @@ -33,7 +34,12 @@ var getUserSlotsPublicCmd = &cobra.Command{ logrus.Infof("Output %v", output) file, err := os.Create(output) writer := bytes.NewBuffer(nil) - _, err = socialService.PublicGetSlotData(namespace, userId, slotId, writer) + input := &slot.PublicGetSlotDataParams{ + Namespace: namespace, + SlotID: slotId, + UserID: userId, + } + _, err = socialService.PublicGetSlotData(input, writer) if err != nil { logrus.Error(err) return err diff --git a/samples/sample-apps/cmd/getUserSlotsPublicNamespace.go b/samples/sample-apps/cmd/getUserSlotsPublicNamespace.go index fb5d36ab7..096007fc6 100644 --- a/samples/sample-apps/cmd/getUserSlotsPublicNamespace.go +++ b/samples/sample-apps/cmd/getUserSlotsPublicNamespace.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -20,13 +21,17 @@ var getUserSlotsPublicNamespacePublicNamespaceCmd = &cobra.Command{ Long: `Get user slots public namespace`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("getUserSlotsPublicNamespace called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() - slots, err := socialService.PublicGetUserNamespaceSlots(namespace, userId) + input := &slot.PublicGetUserNamespaceSlotsParams{ + Namespace: namespace, + UserID: userId, + } + slots, err := socialService.PublicGetUserNamespaceSlots(input) response, err := json.MarshalIndent(slots, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/updateAttribute.go b/samples/sample-apps/cmd/updateAttribute.go index c2be4477f..40f090277 100644 --- a/samples/sample-apps/cmd/updateAttribute.go +++ b/samples/sample-apps/cmd/updateAttribute.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,21 +23,28 @@ var updateAttribute = &cobra.Command{ Long: `Public Update user attribute`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateAttribute called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() profileId := cmd.Flag("profileId").Value.String() attributeName := cmd.Flag("attributeName").Value.String() requestBody := cmd.Flag("body").Value.String() - var attribute *socialclientmodels.Attribute - err := json.Unmarshal([]byte(requestBody), &attribute) + var body *socialclientmodels.Attribute + err := json.Unmarshal([]byte(requestBody), &body) if err != nil { return err } - ok, err := gameProfileService.PublicUpdateAttribute(namespace, userId, attributeName, profileId, attribute) + input := &game_profile.PublicUpdateAttributeParams{ + AttributeName: attributeName, + Body: body, + Namespace: namespace, + ProfileID: profileId, + UserID: userId, + } + ok, err := gameProfileService.PublicUpdateAttribute(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/updateProfile.go b/samples/sample-apps/cmd/updateProfile.go index 23ae5b7b8..020059195 100644 --- a/samples/sample-apps/cmd/updateProfile.go +++ b/samples/sample-apps/cmd/updateProfile.go @@ -8,7 +8,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,20 +23,26 @@ var updateProfile = &cobra.Command{ Long: `Public Update profile`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateProfile called") - gameProfileService := &service.GameProfileService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + gameProfileService := &social.GameProfileService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() profileId := cmd.Flag("profileId").Value.String() requestBody := cmd.Flag("body").Value.String() - var gameProfileRequest *socialclientmodels.GameProfileRequest - err := json.Unmarshal([]byte(requestBody), &gameProfileRequest) + var body *socialclientmodels.GameProfileRequest + err := json.Unmarshal([]byte(requestBody), &body) if err != nil { return err } - ok, err := gameProfileService.PublicUpdateProfile(namespace, userId, profileId, gameProfileRequest) + input := &game_profile.PublicUpdateProfileParams{ + Body: body, + Namespace: namespace, + ProfileID: profileId, + UserID: userId, + } + ok, err := gameProfileService.PublicUpdateProfile(input) if err != nil { return err } else { diff --git a/samples/sample-apps/cmd/updateStat.go b/samples/sample-apps/cmd/updateStat.go index e0e1c58ce..d1a167604 100644 --- a/samples/sample-apps/cmd/updateStat.go +++ b/samples/sample-apps/cmd/updateStat.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,9 +23,9 @@ var updateStatCmd = &cobra.Command{ Long: `Update Stat`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateStat called") - socialService := &service.StatisticConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.StatConfigurationService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() statCode := cmd.Flag("statCode").Value.String() @@ -34,7 +35,12 @@ var updateStatCmd = &cobra.Command{ if errContent != nil { return errContent } - stat, err := socialService.UpdateStat(namespace, statCode, body) + input := &stat_configuration.UpdateStatParams{ + Body: body, + Namespace: namespace, + StatCode: statCode, + } + stat, err := socialService.UpdateStat(input) response, err := json.MarshalIndent(stat, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/updateUserSlot.go b/samples/sample-apps/cmd/updateUserSlot.go index 1be9ad489..d9c5df82f 100644 --- a/samples/sample-apps/cmd/updateUserSlot.go +++ b/samples/sample-apps/cmd/updateUserSlot.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" "os" @@ -22,9 +23,9 @@ var updateUserSlotCmd = &cobra.Command{ Long: `Update user slot`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateUserSlot called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() @@ -34,7 +35,17 @@ var updateUserSlotCmd = &cobra.Command{ if err != nil { return err } - slots, err := socialService.PublicUpdateUserNamespaceSlot(namespace, userId, slotId, nil, nil, nil, nil, file) + input := &slot.PublicUpdateUserNamespaceSlotParams{ + Checksum: nil, + CustomAttribute: nil, + File: file, + Label: nil, + Namespace: namespace, + SlotID: slotId, + Tags: nil, + UserID: userId, + } + slots, err := socialService.PublicUpdateUserNamespaceSlot(input) response, err := json.MarshalIndent(slots, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/updateUserSlotConfig.go b/samples/sample-apps/cmd/updateUserSlotConfig.go index fe06c4b83..b415d8f11 100644 --- a/samples/sample-apps/cmd/updateUserSlotConfig.go +++ b/samples/sample-apps/cmd/updateUserSlotConfig.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot_config" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,19 +23,24 @@ var updateUserSlotConfigCmd = &cobra.Command{ Long: `Update user slot config`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateUserSlotConfig called") - socialService := &service.SlotConfigService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotConfigService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() contentString := cmd.Flag("content").Value.String() - var content *socialclientmodels.SlotConfigUpdate - errContent := json.Unmarshal([]byte(contentString), &content) + var body *socialclientmodels.SlotConfigUpdate + errContent := json.Unmarshal([]byte(contentString), &body) if errContent != nil { return errContent } - slots, err := socialService.UpdateUserSlotConfig(namespace, userId, content) + input := &slot_config.UpdateUserSlotConfigParams{ + Body: body, + Namespace: namespace, + UserID: userId, + } + slots, err := socialService.UpdateUserSlotConfig(input) response, err := json.MarshalIndent(slots, "", " ") if err != nil { return err diff --git a/samples/sample-apps/cmd/updateUserSlotData.go b/samples/sample-apps/cmd/updateUserSlotData.go index fe9af6191..036ea1b3d 100644 --- a/samples/sample-apps/cmd/updateUserSlotData.go +++ b/samples/sample-apps/cmd/updateUserSlotData.go @@ -6,7 +6,8 @@ package cmd import ( "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/sample-apps/pkg/repository" "os" @@ -20,9 +21,9 @@ var updateUserSlotDataCmd = &cobra.Command{ Long: `Update user slot data`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateUserSlotData called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() @@ -32,7 +33,17 @@ var updateUserSlotDataCmd = &cobra.Command{ if err != nil { return err } - _, err = socialService.PublicUpdateUserNamespaceSlot(namespace, userId, slotId, nil, nil, nil, nil, file) + input := &slot.PublicUpdateUserNamespaceSlotParams{ + Checksum: nil, + CustomAttribute: nil, + File: file, + Label: nil, + Namespace: namespace, + SlotID: slotId, + Tags: nil, + UserID: userId, + } + _, err = socialService.PublicUpdateUserNamespaceSlot(input) if err != nil { return err } diff --git a/samples/sample-apps/cmd/updateUserSlotMetadata.go b/samples/sample-apps/cmd/updateUserSlotMetadata.go index 352e23411..16c98a25a 100644 --- a/samples/sample-apps/cmd/updateUserSlotMetadata.go +++ b/samples/sample-apps/cmd/updateUserSlotMetadata.go @@ -7,7 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/factory" - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service" + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/service/social" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" "github.com/AccelByte/sample-apps/pkg/repository" "github.com/sirupsen/logrus" @@ -22,20 +23,26 @@ var updateUserSlotMetadataCmd = &cobra.Command{ Long: `Update user slot data`, RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("updateUserSlotMetadata called") - socialService := &service.SlotService{ - SocialServiceClient: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), - TokenRepository: &repository.TokenRepositoryImpl{}, + socialService := &social.SlotService{ + Client: factory.NewSocialClient(&repository.ConfigRepositoryImpl{}), + TokenRepository: &repository.TokenRepositoryImpl{}, } namespace := cmd.Flag("namespace").Value.String() userId := cmd.Flag("userId").Value.String() slotId := cmd.Flag("slotId").Value.String() contentString := cmd.Flag("content").Value.String() - var content *socialclientmodels.SlotMetadataUpdate - errContent := json.Unmarshal([]byte(contentString), &content) + var body *socialclientmodels.SlotMetadataUpdate + errContent := json.Unmarshal([]byte(contentString), &body) if errContent != nil { return errContent } - slots, err := socialService.PublicUpdateUserNamespaceSlotMetadata(namespace, userId, slotId, content) + input := &slot.PublicUpdateUserNamespaceSlotMetadataParams{ + Body: body, + Namespace: namespace, + SlotID: slotId, + UserID: userId, + } + slots, err := socialService.PublicUpdateUserNamespaceSlotMetadata(input) response, err := json.MarshalIndent(slots, "", " ") if err != nil { return err diff --git a/services-api/pkg/service/gameProfileService.go b/services-api/pkg/service/gameProfileService.go deleted file mode 100644 index dfb263fd4..000000000 --- a/services-api/pkg/service/gameProfileService.go +++ /dev/null @@ -1,261 +0,0 @@ -package service - -import ( - "encoding/json" - - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" - "github.com/go-openapi/runtime/client" - "github.com/sirupsen/logrus" -) - -type GameProfileService struct { - SocialServiceClient *socialclient.JusticeSocialService - TokenRepository repository.TokenRepository -} - -func (s *GameProfileService) GetUserProfiles(namespace, userId string) ([]*socialclientmodels.GameProfileHeader, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.GetUserProfilesParams{ - Namespace: namespace, - UserID: userId, - } - ok, err := s.SocialServiceClient.GameProfile.GetUserProfiles(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) GetProfile(namespace, userId, profileId string) (*socialclientmodels.GameProfileInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.GetProfileParams{ - Namespace: namespace, - ProfileID: profileId, - UserID: userId, - } - ok, notFound, err := s.SocialServiceClient.GameProfile.GetProfile(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) PublicGetUserProfiles(namespace, userId string) ([]*socialclientmodels.GameProfileHeader, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.PublicGetUserProfilesParams{ - Namespace: namespace, - UserID: userId, - } - ok, err := s.SocialServiceClient.GameProfile.PublicGetUserProfiles(params, client.BearerToken(*token.AccessToken)) - - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) PublicCreateProfile(namespace, userId string, content *socialclientmodels.GameProfileRequest) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &game_profile.PublicCreateProfileParams{ - Body: content, - Namespace: namespace, - UserID: userId, - } - _, notFound, err := s.SocialServiceClient.GameProfile.PublicCreateProfile(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *GameProfileService) PublicGetProfileAttribute(namespace, userId, attributeName, profileId string) (*socialclientmodels.Attribute, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.PublicGetProfileAttributeParams{ - AttributeName: attributeName, - Namespace: namespace, - ProfileID: profileId, - UserID: userId, - } - ok, notFound, err := s.SocialServiceClient.GameProfile.PublicGetProfileAttribute(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) PublicUpdateAttribute(namespace, userId, attributeName, profileId string, content *socialclientmodels.Attribute) (*socialclientmodels.GameProfileInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.PublicUpdateAttributeParams{ - AttributeName: attributeName, - Body: content, - Namespace: namespace, - ProfileID: profileId, - UserID: userId, - } - ok, badRequest, notFound, err := s.SocialServiceClient.GameProfile.PublicUpdateAttribute(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) PublicGetProfile(namespace, userId, profileId string) (*socialclientmodels.GameProfileInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.PublicGetProfileParams{ - Namespace: namespace, - ProfileID: profileId, - UserID: userId, - } - ok, notFound, err := s.SocialServiceClient.GameProfile.PublicGetProfile(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) PublicUpdateProfile(namespace, userId, profileId string, content *socialclientmodels.GameProfileRequest) (*socialclientmodels.GameProfileInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.PublicUpdateProfileParams{ - Body: content, - Namespace: namespace, - ProfileID: profileId, - UserID: userId, - } - ok, badRequest, notFound, err := s.SocialServiceClient.GameProfile.PublicUpdateProfile(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *GameProfileService) PublicDeleteProfile(namespace, userId, profileId string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &game_profile.PublicDeleteProfileParams{ - Namespace: namespace, - ProfileID: profileId, - UserID: userId, - } - _, notFound, err := s.SocialServiceClient.GameProfile.PublicDeleteProfile(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *GameProfileService) PublicGetUserGameProfiles(namespace string, userIds []string) ([]*socialclientmodels.UserGameProfiles, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &game_profile.PublicGetUserGameProfilesParams{ - Namespace: namespace, - UserIds: userIds, - } - ok, badRequest, err := s.SocialServiceClient.GameProfile.PublicGetUserGameProfiles(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} diff --git a/services-api/pkg/service/slotConfigService.go b/services-api/pkg/service/slotConfigService.go deleted file mode 100644 index c2bdaecd1..000000000 --- a/services-api/pkg/service/slotConfigService.go +++ /dev/null @@ -1,122 +0,0 @@ -package service - -import ( - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot_config" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" - "github.com/go-openapi/runtime/client" - "github.com/sirupsen/logrus" -) - -type SlotConfigService struct { - SocialServiceClient *socialclient.JusticeSocialService - TokenRepository repository.TokenRepository -} - -func (s *SlotConfigService) GetNamespaceSlotConfig(namespace string) (*socialclientmodels.NamespaceSlotConfigInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot_config.GetNamespaceSlotConfigParams{ - Namespace: namespace, - } - ok, err := s.SocialServiceClient.SlotConfig.GetNamespaceSlotConfig(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotConfigService) UpdateNamespaceSlotConfig(namespace string, content *socialclientmodels.SlotConfigUpdate) (*socialclientmodels.NamespaceSlotConfigInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot_config.UpdateNamespaceSlotConfigParams{ - Body: content, - Namespace: namespace, - } - ok, err := s.SocialServiceClient.SlotConfig.UpdateNamespaceSlotConfig(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotConfigService) DeleteNamespaceSlotConfig(namespace string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &slot_config.DeleteNamespaceSlotConfigParams{ - Namespace: namespace, - } - _, err = s.SocialServiceClient.SlotConfig.DeleteNamespaceSlotConfig(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *SlotConfigService) GetUserSlotConfig(namespace, userId string) (*socialclientmodels.UserSlotConfigInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot_config.GetUserSlotConfigParams{ - Namespace: namespace, - UserID: userId, - } - ok, err := s.SocialServiceClient.SlotConfig.GetUserSlotConfig(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotConfigService) UpdateUserSlotConfig(namespace, userId string, content *socialclientmodels.SlotConfigUpdate) (*socialclientmodels.UserSlotConfigInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot_config.UpdateUserSlotConfigParams{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, err := s.SocialServiceClient.SlotConfig.UpdateUserSlotConfig(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotConfigService) DeleteUserSlotConfig(namespace, userId string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &slot_config.DeleteUserSlotConfigParams{ - Namespace: namespace, - UserID: userId, - } - _, err = s.SocialServiceClient.SlotConfig.DeleteUserSlotConfig(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return err - } - return nil -} diff --git a/services-api/pkg/service/slotService.go b/services-api/pkg/service/slotService.go deleted file mode 100644 index 3c756a258..000000000 --- a/services-api/pkg/service/slotService.go +++ /dev/null @@ -1,220 +0,0 @@ -package service - -import ( - "encoding/json" - "io" - - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/client" - "github.com/sirupsen/logrus" -) - -type SlotService struct { - SocialServiceClient *socialclient.JusticeSocialService - TokenRepository repository.TokenRepository -} - -func (s *SlotService) GetSlotData(namespace, userId, slotId string, writer io.Writer) (io.Writer, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot.GetSlotDataParams{ - Namespace: namespace, - SlotID: slotId, - UserID: userId, - } - ok, notFound, err := s.SocialServiceClient.Slot.GetSlotData(params, client.BearerToken(*token.AccessToken), writer) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotService) GetUserNamespaceSlots(namespace, userId string) ([]*socialclientmodels.SlotInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot.GetUserNamespaceSlotsParams{ - Namespace: namespace, - UserID: userId, - } - ok, err := s.SocialServiceClient.Slot.GetUserNamespaceSlots(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotService) PublicGetSlotData(namespace, userId, slotId string, writer io.Writer) (io.Writer, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot.PublicGetSlotDataParams{ - Namespace: namespace, - SlotID: slotId, - UserID: userId, - } - ok, notFound, err := s.SocialServiceClient.Slot.PublicGetSlotData(params, client.BearerToken(*token.AccessToken), writer) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotService) PublicUpdateUserNamespaceSlot(namespace, userId, slotId string, checksum, customAttribute, label *string, tags []string, file runtime.NamedReadCloser) (*socialclientmodels.SlotInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot.PublicUpdateUserNamespaceSlotParams{ - Checksum: checksum, - CustomAttribute: customAttribute, - File: file, - Label: label, - Namespace: namespace, - SlotID: slotId, - Tags: tags, - UserID: userId, - } - ok, badRequest, notFound, err := s.SocialServiceClient.Slot.PublicUpdateUserNamespaceSlot(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotService) PublicDeleteUserNamespaceSlot(namespace, userId, slotId string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &slot.PublicDeleteUserNamespaceSlotParams{ - Namespace: namespace, - SlotID: slotId, - UserID: userId, - } - _, notFound, err := s.SocialServiceClient.Slot.PublicDeleteUserNamespaceSlot(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *SlotService) PublicGetUserNamespaceSlots(namespace, userId string) ([]*socialclientmodels.SlotInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot.PublicGetUserNamespaceSlotsParams{ - Namespace: namespace, - UserID: userId, - } - ok, err := s.SocialServiceClient.Slot.PublicGetUserNamespaceSlots(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *SlotService) PublicCreateUserNamespaceSlot(namespace, userId string, checksum, customAttribute, label *string, tags []string, file runtime.NamedReadCloser) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &slot.PublicCreateUserNamespaceSlotParams{ - Checksum: checksum, - CustomAttribute: customAttribute, - File: file, - Label: label, - Namespace: namespace, - Tags: tags, - UserID: userId, - } - _, badRequest, conflict, err := s.SocialServiceClient.Slot.PublicCreateUserNamespaceSlot(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return badRequest - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return conflict - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *SlotService) PublicUpdateUserNamespaceSlotMetadata(namespace, userId, slotId string, content *socialclientmodels.SlotMetadataUpdate) (*socialclientmodels.SlotInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &slot.PublicUpdateUserNamespaceSlotMetadataParams{ - Body: content, - Namespace: namespace, - SlotID: slotId, - UserID: userId, - } - ok, notFound, err := s.SocialServiceClient.Slot.PublicUpdateUserNamespaceSlotMetadata(params, client.BearerToken(*token.AccessToken)) - - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} diff --git a/services-api/pkg/service/social/gameProfile.go b/services-api/pkg/service/social/gameProfile.go new file mode 100644 index 000000000..6386be880 --- /dev/null +++ b/services-api/pkg/service/social/gameProfile.go @@ -0,0 +1,207 @@ +package social + +import ( + "encoding/json" + + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/game_profile" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" + "github.com/go-openapi/runtime/client" + "github.com/sirupsen/logrus" +) + +type GameProfileService struct { + Client *socialclient.JusticeSocialService + TokenRepository repository.TokenRepository +} + +func (s *GameProfileService) GetUserProfiles(input *game_profile.GetUserProfilesParams) ([]*socialclientmodels.GameProfileHeader, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.GameProfile.GetUserProfiles(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) GetProfile(input *game_profile.GetProfileParams) (*socialclientmodels.GameProfileInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.GameProfile.GetProfile(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) PublicGetUserProfiles(input *game_profile.PublicGetUserProfilesParams) ([]*socialclientmodels.GameProfileHeader, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.GameProfile.PublicGetUserProfiles(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) PublicCreateProfile(input *game_profile.PublicCreateProfileParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, notFound, err := s.Client.GameProfile.PublicCreateProfile(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *GameProfileService) PublicGetProfileAttribute(input *game_profile.PublicGetProfileAttributeParams) (*socialclientmodels.Attribute, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.GameProfile.PublicGetProfileAttribute(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) PublicUpdateAttribute(input *game_profile.PublicUpdateAttributeParams) (*socialclientmodels.GameProfileInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, err := s.Client.GameProfile.PublicUpdateAttribute(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) PublicGetProfile(input *game_profile.PublicGetProfileParams) (*socialclientmodels.GameProfileInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.GameProfile.PublicGetProfile(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) PublicUpdateProfile(input *game_profile.PublicUpdateProfileParams) (*socialclientmodels.GameProfileInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, err := s.Client.GameProfile.PublicUpdateProfile(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *GameProfileService) PublicDeleteProfile(input *game_profile.PublicDeleteProfileParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, notFound, err := s.Client.GameProfile.PublicDeleteProfile(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *GameProfileService) PublicGetUserGameProfiles(input *game_profile.PublicGetUserGameProfilesParams) ([]*socialclientmodels.UserGameProfiles, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, err := s.Client.GameProfile.PublicGetUserGameProfiles(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} diff --git a/services-api/pkg/service/social/globalStatistic.go b/services-api/pkg/service/social/globalStatistic.go new file mode 100644 index 000000000..a78b0569c --- /dev/null +++ b/services-api/pkg/service/social/globalStatistic.go @@ -0,0 +1,33 @@ +// Copyright (c) 2021 AccelByte Inc. All Rights Reserved. +// This is licensed software from AccelByte Inc, for limitations +// and restrictions contact your company contract manager. + +package social + +import ( + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/global_statistic" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" + "github.com/go-openapi/runtime/client" + "github.com/sirupsen/logrus" +) + +type GlobalStatisticService struct { + Client *socialclient.JusticeSocialService + TokenRepository repository.TokenRepository +} + +func (s *GlobalStatisticService) GetGlobalStatItems(input *global_statistic.GetGlobalStatItemsParams) (*socialclientmodels.GlobalStatItemPagingSlicedResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.GlobalStatistic.GetGlobalStatItems(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} diff --git a/services-api/pkg/service/social/slot.go b/services-api/pkg/service/social/slot.go new file mode 100644 index 000000000..5bd015189 --- /dev/null +++ b/services-api/pkg/service/social/slot.go @@ -0,0 +1,170 @@ +package social + +import ( + "encoding/json" + "io" + + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" + "github.com/go-openapi/runtime/client" + "github.com/sirupsen/logrus" +) + +type SlotService struct { + Client *socialclient.JusticeSocialService + TokenRepository repository.TokenRepository +} + +func (s *SlotService) GetSlotData(input *slot.GetSlotDataParams, writer io.Writer) (io.Writer, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.Slot.GetSlotData(input, client.BearerToken(*token.AccessToken), writer) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotService) GetUserNamespaceSlots(input *slot.GetUserNamespaceSlotsParams) ([]*socialclientmodels.SlotInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.Slot.GetUserNamespaceSlots(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotService) PublicGetSlotData(input *slot.PublicGetSlotDataParams, writer io.Writer) (io.Writer, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.Slot.PublicGetSlotData(input, client.BearerToken(*token.AccessToken), writer) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotService) PublicUpdateUserNamespaceSlot(input *slot.PublicUpdateUserNamespaceSlotParams) (*socialclientmodels.SlotInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, err := s.Client.Slot.PublicUpdateUserNamespaceSlot(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotService) PublicDeleteUserNamespaceSlot(input *slot.PublicDeleteUserNamespaceSlotParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, notFound, err := s.Client.Slot.PublicDeleteUserNamespaceSlot(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *SlotService) PublicGetUserNamespaceSlots(input *slot.PublicGetUserNamespaceSlotsParams) ([]*socialclientmodels.SlotInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.Slot.PublicGetUserNamespaceSlots(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotService) PublicCreateUserNamespaceSlot(input *slot.PublicCreateUserNamespaceSlotParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, badRequest, conflict, err := s.Client.Slot.PublicCreateUserNamespaceSlot(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return badRequest + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return conflict + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *SlotService) PublicUpdateUserNamespaceSlotMetadata(input *slot.PublicUpdateUserNamespaceSlotMetadataParams) (*socialclientmodels.SlotInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.Slot.PublicUpdateUserNamespaceSlotMetadata(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} diff --git a/services-api/pkg/service/social/slotConfig.go b/services-api/pkg/service/social/slotConfig.go new file mode 100644 index 000000000..24b5f909a --- /dev/null +++ b/services-api/pkg/service/social/slotConfig.go @@ -0,0 +1,99 @@ +package social + +import ( + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/slot_config" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" + "github.com/go-openapi/runtime/client" + "github.com/sirupsen/logrus" +) + +type SlotConfigService struct { + Client *socialclient.JusticeSocialService + TokenRepository repository.TokenRepository +} + +func (s *SlotConfigService) GetNamespaceSlotConfig(input *slot_config.GetNamespaceSlotConfigParams) (*socialclientmodels.NamespaceSlotConfigInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.SlotConfig.GetNamespaceSlotConfig(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotConfigService) UpdateNamespaceSlotConfig(input *slot_config.UpdateNamespaceSlotConfigParams) (*socialclientmodels.NamespaceSlotConfigInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.SlotConfig.UpdateNamespaceSlotConfig(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotConfigService) DeleteNamespaceSlotConfig(input *slot_config.DeleteNamespaceSlotConfigParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, err = s.Client.SlotConfig.DeleteNamespaceSlotConfig(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *SlotConfigService) GetUserSlotConfig(input *slot_config.GetUserSlotConfigParams) (*socialclientmodels.UserSlotConfigInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.SlotConfig.GetUserSlotConfig(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotConfigService) UpdateUserSlotConfig(input *slot_config.UpdateUserSlotConfigParams) (*socialclientmodels.UserSlotConfigInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.SlotConfig.UpdateUserSlotConfig(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *SlotConfigService) DeleteUserSlotConfig(input *slot_config.DeleteUserSlotConfigParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, err = s.Client.SlotConfig.DeleteUserSlotConfig(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return err + } + return nil +} diff --git a/services-api/pkg/service/social/statConfiguration.go b/services-api/pkg/service/social/statConfiguration.go new file mode 100644 index 000000000..4c83a5696 --- /dev/null +++ b/services-api/pkg/service/social/statConfiguration.go @@ -0,0 +1,173 @@ +package social + +import ( + "encoding/json" + + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" + "github.com/go-openapi/runtime/client" + "github.com/sirupsen/logrus" +) + +type StatConfigurationService struct { + Client *socialclient.JusticeSocialService + TokenRepository repository.TokenRepository +} + +func (s *StatConfigurationService) GetStat(input *stat_configuration.GetStatParams) (*socialclientmodels.StatInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.StatConfiguration.GetStat(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *StatConfigurationService) DeleteStat(input *stat_configuration.DeleteStatParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, notFound, err := s.Client.StatConfiguration.DeleteStat(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *StatConfigurationService) UpdateStat(input *stat_configuration.UpdateStatParams) (*socialclientmodels.StatInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, notFound, err := s.Client.StatConfiguration.UpdateStat(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *StatConfigurationService) GetStats(input *stat_configuration.GetStatsParams) (*socialclientmodels.StatPagingSlicedResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.StatConfiguration.GetStats(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *StatConfigurationService) CreateStat(input *stat_configuration.CreateStatParams) (*socialclientmodels.StatInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, conflict, err := s.Client.StatConfiguration.CreateStat(input, client.BearerToken(*token.AccessToken)) + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *StatConfigurationService) QueryStats(input *stat_configuration.QueryStatsParams) (*socialclientmodels.StatPagingSlicedResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.StatConfiguration.QueryStats(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *StatConfigurationService) ExportStats(input *stat_configuration.ExportStatsParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, err = s.Client.StatConfiguration.ExportStats(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *StatConfigurationService) ImportStats(input *stat_configuration.ImportStatsParams) (*socialclientmodels.StatImportInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, err := s.Client.StatConfiguration.ImportStats(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *StatConfigurationService) PublicCreateStat(input *stat_configuration.CreateStat1Params) (*socialclientmodels.StatInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, conflict, err := s.Client.StatConfiguration.CreateStat1(input, client.BearerToken(*token.AccessToken)) + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} diff --git a/services-api/pkg/service/social/userStatistic.go b/services-api/pkg/service/social/userStatistic.go new file mode 100644 index 000000000..0bfbd4993 --- /dev/null +++ b/services-api/pkg/service/social/userStatistic.go @@ -0,0 +1,763 @@ +package social + +import ( + "encoding/json" + + "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/user_statistic" + "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" + "github.com/go-openapi/runtime/client" + "github.com/sirupsen/logrus" +) + +type UserStatisticService struct { + Client *socialclient.JusticeSocialService + TokenRepository repository.TokenRepository +} + +func (s *UserStatisticService) BulkIncUserStatItemValue(input *user_statistic.BulkIncUserStatItemValueParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkIncUserStatItemValue(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkFetchStatItems(input *user_statistic.BulkFetchStatItemsParams) ([]*socialclientmodels.UserStatItemInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkFetchStatItems(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkResetUserStatItem(input *user_statistic.BulkResetUserStatItemParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkResetUserStatItem(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkIncUserStatItemValue1(input *user_statistic.BulkIncUserStatItemValue1Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkIncUserStatItemValue1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) GetUserStatItems(input *user_statistic.GetUserStatItemsParams) (*socialclientmodels.UserStatItemPagingSlicedResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.UserStatistic.GetUserStatItems(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkCreateUserStatItems(input *user_statistic.BulkCreateUserStatItemsParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkCreateUserStatItems(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkResetUserStatItem1(input *user_statistic.BulkResetUserStatItem1Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkResetUserStatItem1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) CreateUserStatItem(input *user_statistic.CreateUserStatItemParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, notFound, conflict, err := s.Client.UserStatistic.CreateUserStatItem(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return conflict + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *UserStatisticService) DeleteUserStatItems(input *user_statistic.DeleteUserStatItemsParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, unauthorized, forbidden, notFound, err := s.Client.UserStatistic.DeleteUserStatItems(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if unauthorized != nil { + errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) + logrus.Error(string(errorMsg)) + return unauthorized + } + if forbidden != nil { + errorMsg, _ := json.Marshal(*forbidden.GetPayload()) + logrus.Error(string(errorMsg)) + return forbidden + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *UserStatisticService) ResetUserStatItemValue(input *user_statistic.ResetUserStatItemValueParams) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, err := s.Client.UserStatistic.ResetUserStatItemValue(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) IncUserStatItemValue(input *user_statistic.IncUserStatItemValueParams) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, conflict, err := s.Client.UserStatistic.IncUserStatItemValue(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicBulkIncUserStatItem(input *user_statistic.PublicBulkIncUserStatItemParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.PublicBulkIncUserStatItem(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkFetchStatItems1(input *user_statistic.BulkFetchStatItems1Params) ([]*socialclientmodels.UserStatItemInfo, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkFetchStatItems1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkResetUserStatItem2(input *user_statistic.BulkResetUserStatItem2Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkResetUserStatItem2(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicBulkIncUserStatItem1(input *user_statistic.PublicBulkIncUserStatItem1Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.PublicBulkIncUserStatItem1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicQueryUserStatItems(input *user_statistic.PublicQueryUserStatItemsParams) (*socialclientmodels.UserStatItemPagingSlicedResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, err := s.Client.UserStatistic.PublicQueryUserStatItems(input, client.BearerToken(*token.AccessToken)) + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicBulkCreateUserStatItems(input *user_statistic.PublicBulkCreateUserStatItemsParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.PublicBulkCreateUserStatItems(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkResetUserStatItem3(input *user_statistic.BulkResetUserStatItem3Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkResetUserStatItem3(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicIncUserStatItem(input *user_statistic.PublicIncUserStatItemParams) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, conflict, err := s.Client.UserStatistic.PublicIncUserStatItem(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicCreateUserStatItem(input *user_statistic.PublicCreateUserStatItemParams) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, notFound, conflict, err := s.Client.UserStatistic.PublicCreateUserStatItem(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return conflict + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *UserStatisticService) DeleteUserStatItems1(input *user_statistic.DeleteUserStatItems1Params) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, unauthorized, forbidden, notFound, err := s.Client.UserStatistic.DeleteUserStatItems1(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if forbidden != nil { + errorMsg, _ := json.Marshal(*forbidden.GetPayload()) + logrus.Error(string(errorMsg)) + return forbidden + } + if unauthorized != nil { + errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) + logrus.Error(string(errorMsg)) + return unauthorized + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *UserStatisticService) ResetUserStatItemValue1(input *user_statistic.ResetUserStatItemValue1Params) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, err := s.Client.UserStatistic.ResetUserStatItemValue1(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkUpdateUserStatItemV2(input *user_statistic.BulkUpdateUserStatItemV2Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkUpdateUserStatItemV2(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkUpdateUserStatItem(input *user_statistic.BulkUpdateUserStatItemParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkUpdateUserStatItem(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) UpdateUserStatItemValue(input *user_statistic.UpdateUserStatItemValueParams) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, conflict, unprocessableEntity, err := s.Client.UserStatistic.UpdateUserStatItemValue(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) DeleteUserStatItems2(input *user_statistic.DeleteUserStatItems2Params) error { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return err + } + _, unauthorized, forbidden, notFound, err := s.Client.UserStatistic.DeleteUserStatItems2(input, client.BearerToken(*token.AccessToken)) + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return notFound + } + if unauthorized != nil { + errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) + logrus.Error(string(errorMsg)) + return unauthorized + } + if forbidden != nil { + errorMsg, _ := json.Marshal(*forbidden.GetPayload()) + logrus.Error(string(errorMsg)) + return forbidden + } + if err != nil { + logrus.Error(err) + return err + } + return nil +} + +func (s *UserStatisticService) BulkUpdateUserStatItem1(input *user_statistic.BulkUpdateUserStatItem1Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkUpdateUserStatItem1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkUpdateUserStatItem2(input *user_statistic.BulkUpdateUserStatItem2Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkUpdateUserStatItem2(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) UpdateUserStatItemValue1(input *user_statistic.UpdateUserStatItemValue1Params) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, conflict, unprocessableEntity, err := s.Client.UserStatistic.UpdateUserStatItemValue1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkIncUserStatItem(input *user_statistic.BulkIncUserStatItemParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkIncUserStatItem(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkIncUserStatItemValue2(input *user_statistic.BulkIncUserStatItemValue2Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkIncUserStatItemValue2(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) BulkIncUserStatItem1(input *user_statistic.BulkIncUserStatItem1Params) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.BulkIncUserStatItem1(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicBulkIncUserStatItemValue(input *user_statistic.PublicBulkIncUserStatItemValueParams) ([]*socialclientmodels.BulkStatItemOperationResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, unprocessableEntity, err := s.Client.UserStatistic.PublicBulkIncUserStatItemValue(input, client.BearerToken(*token.AccessToken)) + if unprocessableEntity != nil { + errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, unprocessableEntity + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} + +func (s *UserStatisticService) PublicIncUserStatItemValue(input *user_statistic.PublicIncUserStatItemValueParams) (*socialclientmodels.StatItemIncResult, error) { + token, err := s.TokenRepository.GetToken() + if err != nil { + logrus.Error(err) + return nil, err + } + ok, badRequest, notFound, conflict, err := s.Client.UserStatistic.PublicIncUserStatItemValue(input, client.BearerToken(*token.AccessToken)) + if badRequest != nil { + errorMsg, _ := json.Marshal(*badRequest.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, badRequest + } + if notFound != nil { + errorMsg, _ := json.Marshal(*notFound.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, notFound + } + if conflict != nil { + errorMsg, _ := json.Marshal(*conflict.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, conflict + } + if err != nil { + logrus.Error(err) + return nil, err + } + return ok.GetPayload(), nil +} diff --git a/services-api/pkg/service/statisticConfigService.go b/services-api/pkg/service/statisticConfigService.go deleted file mode 100644 index 63ee8cf7c..000000000 --- a/services-api/pkg/service/statisticConfigService.go +++ /dev/null @@ -1,214 +0,0 @@ -package service - -import ( - "encoding/json" - - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/stat_configuration" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/client" - "github.com/sirupsen/logrus" -) - -type StatisticConfigService struct { - SocialServiceClient *socialclient.JusticeSocialService - TokenRepository repository.TokenRepository -} - -func (s *StatisticConfigService) GetStat(namespace, statCode string) (*socialclientmodels.StatInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.GetStatParams{ - Namespace: namespace, - StatCode: statCode, - } - ok, notFound, err := s.SocialServiceClient.StatConfiguration.GetStat(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticConfigService) DeleteStat(namespace, statCode string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &stat_configuration.DeleteStatParams{ - Namespace: namespace, - StatCode: statCode, - } - _, notFound, err := s.SocialServiceClient.StatConfiguration.DeleteStat(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticConfigService) UpdateStat(namespace, statCode string, content *socialclientmodels.StatUpdate) (*socialclientmodels.StatInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.UpdateStatParams{ - Body: content, - Namespace: namespace, - StatCode: statCode, - } - ok, notFound, err := s.SocialServiceClient.StatConfiguration.UpdateStat(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticConfigService) GetStats(namespace string, limit, offset *int32) (*socialclientmodels.StatPagingSlicedResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.GetStatsParams{ - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, err := s.SocialServiceClient.StatConfiguration.GetStats(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticConfigService) CreateStat(namespace string, content *socialclientmodels.StatCreate) (*socialclientmodels.StatInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.CreateStatParams{ - Body: content, - Namespace: namespace, - } - ok, conflict, err := s.SocialServiceClient.StatConfiguration.CreateStat(params, client.BearerToken(*token.AccessToken)) - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticConfigService) QueryStats(namespace, keyword string, limit, offset *int32) (*socialclientmodels.StatPagingSlicedResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.QueryStatsParams{ - Keyword: keyword, - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, err := s.SocialServiceClient.StatConfiguration.QueryStats(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticConfigService) ExportStats(namespace string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &stat_configuration.ExportStatsParams{ - Namespace: namespace, - } - _, err = s.SocialServiceClient.StatConfiguration.ExportStats(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticConfigService) ImportStats(namespace string, file runtime.NamedReadCloser, replaceExisting *bool) (*socialclientmodels.StatImportInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.ImportStatsParams{ - File: file, - Namespace: namespace, - ReplaceExisting: replaceExisting, - } - ok, badRequest, err := s.SocialServiceClient.StatConfiguration.ImportStats(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticConfigService) PublicCreateStat(namespace string, content *socialclientmodels.StatCreate) (*socialclientmodels.StatInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &stat_configuration.CreateStat1Params{ - Body: content, - Namespace: namespace, - } - ok, conflict, err := s.SocialServiceClient.StatConfiguration.CreateStat1(params, client.BearerToken(*token.AccessToken)) - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} diff --git a/services-api/pkg/service/statisticService.go b/services-api/pkg/service/statisticService.go deleted file mode 100644 index 70049aeba..000000000 --- a/services-api/pkg/service/statisticService.go +++ /dev/null @@ -1,954 +0,0 @@ -package service - -import ( - "encoding/json" - - "github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/global_statistic" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclient/user_statistic" - "github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels" - "github.com/go-openapi/runtime/client" - "github.com/sirupsen/logrus" -) - -type StatisticService struct { - SocialServiceClient *socialclient.JusticeSocialService - TokenRepository repository.TokenRepository -} - -func (s *StatisticService) GetGlobalStatItems(namespace string, limit, offset *int32) (*socialclientmodels.GlobalStatItemPagingSlicedResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &global_statistic.GetGlobalStatItemsParams{ - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, err := s.SocialServiceClient.GlobalStatistic.GetGlobalStatItems(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkUpdateMultipleUserStatItem(namespace string, content []*socialclientmodels.BulkUserStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkIncUserStatItemValueParams{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkIncUserStatItemValue(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkFetchStatItems(namespace, statCode, userIds string) ([]*socialclientmodels.UserStatItemInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkFetchStatItemsParams{ - Namespace: namespace, - StatCode: statCode, - UserIds: userIds, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkFetchStatItems(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkResetMultipleUserStatItem(namespace string, content []*socialclientmodels.BulkUserStatItemReset) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkResetUserStatItemParams{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkResetUserStatItem(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkUpdateUserStatItem(namespace string, content []*socialclientmodels.BulkStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkIncUserStatItemValue1Params{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkIncUserStatItemValue1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) GetUserStatItems(namespace, userId string, statCodes, tags *string, limit, offset *int32) (*socialclientmodels.UserStatItemPagingSlicedResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.GetUserStatItemsParams{ - Limit: limit, - Namespace: namespace, - Offset: offset, - StatCodes: statCodes, - Tags: tags, - UserID: userId, - } - ok, err := s.SocialServiceClient.UserStatistic.GetUserStatItems(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkCreateUserStatItems(namespace, userId string, content []*socialclientmodels.BulkStatItemCreate) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkCreateUserStatItemsParams{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkCreateUserStatItems(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkResetUserStatItem(namespace, userId string, content []*socialclientmodels.BulkStatItemReset) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkResetUserStatItem1Params{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkResetUserStatItem1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) CreateUserStatItem(namespace, userId, statCode string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &user_statistic.CreateUserStatItemParams{ - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - _, notFound, conflict, err := s.SocialServiceClient.UserStatistic.CreateUserStatItem(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return conflict - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticService) DeleteUserStatItems(namespace, userId, statCode string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &user_statistic.DeleteUserStatItemsParams{ - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - _, unauthorized, forbidden, notFound, err := s.SocialServiceClient.UserStatistic.DeleteUserStatItems(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return forbidden - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticService) ResetUserStatItemValue(namespace, statCode, userId string, additionalKey *string) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.ResetUserStatItemValueParams{ - AdditionalKey: additionalKey, - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - ok, badRequest, notFound, err := s.SocialServiceClient.UserStatistic.ResetUserStatItemValue(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) IncUserStatItemValue(namespace, statCode, userId string, content *socialclientmodels.StatItemInc) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.IncUserStatItemValueParams{ - Body: content, - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - ok, badRequest, notFound, conflict, err := s.SocialServiceClient.UserStatistic.IncUserStatItemValue(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkIncMultipleUserStatItem(namespace string, content []*socialclientmodels.BulkUserStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicBulkIncUserStatItemParams{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.PublicBulkIncUserStatItem(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkFetchStatItems(namespace, statCode, userIds string) ([]*socialclientmodels.UserStatItemInfo, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkFetchStatItems1Params{ - Namespace: namespace, - StatCode: statCode, - UserIds: userIds, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkFetchStatItems1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkResetMultipleUserStatItem(namespace string, content []*socialclientmodels.BulkUserStatItemReset) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkResetUserStatItem2Params{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkResetUserStatItem2(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkIncUserStatItem(namespace, userId string, content []*socialclientmodels.BulkStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicBulkIncUserStatItem1Params{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.PublicBulkIncUserStatItem1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicQueryUserStatItems(namespace, userId string, tags, statCodes *string, limit, offset *int32) (*socialclientmodels.UserStatItemPagingSlicedResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicQueryUserStatItemsParams{ - Limit: limit, - Namespace: namespace, - Offset: offset, - StatCodes: statCodes, - Tags: tags, - UserID: userId, - } - ok, err := s.SocialServiceClient.UserStatistic.PublicQueryUserStatItems(params, client.BearerToken(*token.AccessToken)) - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkCreateUserStatItems(namespace, userId string, content []*socialclientmodels.BulkStatItemCreate) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicBulkCreateUserStatItemsParams{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.PublicBulkCreateUserStatItems(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkResetUserStatItem(namespace, userId string, content []*socialclientmodels.BulkStatItemReset) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkResetUserStatItem3Params{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkResetUserStatItem3(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicIncUserStatItem(namespace, userId string, content *socialclientmodels.StatItemInc) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicIncUserStatItemParams{ - Body: content, - Namespace: namespace, - UserID: userId, - } - ok, badRequest, notFound, conflict, err := s.SocialServiceClient.UserStatistic.PublicIncUserStatItem(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicCreateUserStatItem(namespace, userId, statCode string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &user_statistic.PublicCreateUserStatItemParams{ - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - _, notFound, conflict, err := s.SocialServiceClient.UserStatistic.PublicCreateUserStatItem(params, client.BearerToken(*token.AccessToken)) - - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return conflict - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticService) PublicDeleteUserStatItem(namespace, userId, statCode string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &user_statistic.DeleteUserStatItems1Params{ - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - _, unauthorized, forbidden, notFound, err := s.SocialServiceClient.UserStatistic.DeleteUserStatItems1(params, client.BearerToken(*token.AccessToken)) - - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return forbidden - } - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return unauthorized - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticService) PublicResetUserStatItemValue(namespace, userId, statCode string) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.ResetUserStatItemValue1Params{ - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - ok, badRequest, notFound, err := s.SocialServiceClient.UserStatistic.ResetUserStatItemValue1(params, client.BearerToken(*token.AccessToken)) - - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkUpdateMultipleUserStatItemV2(namespace string, content []*socialclientmodels.BulkUserStatItemUpdate) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkUpdateUserStatItemV2Params{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkUpdateUserStatItemV2(params, client.BearerToken(*token.AccessToken)) - - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkUpdateUserStatItemV2(namespace string, content []*socialclientmodels.BulkStatItemUpdate) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkUpdateUserStatItemParams{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkUpdateUserStatItem(params, client.BearerToken(*token.AccessToken)) - - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) IncUserStatItemValueV2(namespace string, content *socialclientmodels.StatItemUpdate) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.UpdateUserStatItemValueParams{ - Body: content, - Namespace: namespace, - } - ok, badRequest, notFound, conflict, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.UpdateUserStatItemValue(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) DeleteUserStatItemsV2(namespace, userId, statCode string) error { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return err - } - params := &user_statistic.DeleteUserStatItems2Params{ - Namespace: namespace, - StatCode: statCode, - UserID: userId, - } - _, unauthorized, forbidden, notFound, err := s.SocialServiceClient.UserStatistic.DeleteUserStatItems2(params, client.BearerToken(*token.AccessToken)) - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return notFound - } - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return forbidden - } - if err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (s *StatisticService) PublicBulkIncMultipleUserStatItemV2(namespace string, content []*socialclientmodels.BulkUserStatItemUpdate) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkUpdateUserStatItem1Params{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkUpdateUserStatItem1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkIncUserStatItemV2(namespace string, content []*socialclientmodels.BulkStatItemUpdate) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkUpdateUserStatItem2Params{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkUpdateUserStatItem2(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicIncUserStatItemV2(namespace string, content *socialclientmodels.StatItemUpdate) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.UpdateUserStatItemValue1Params{ - Body: content, - Namespace: namespace, - } - ok, badRequest, notFound, conflict, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.UpdateUserStatItemValue1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkIncUserStatItem(namespace string, content []*socialclientmodels.BulkUserStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkIncUserStatItemParams{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkIncUserStatItem(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkIncUserStatItemValue2(namespace string, userID string, content []*socialclientmodels.BulkStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkIncUserStatItemValue2Params{ - Body: content, - Namespace: namespace, - UserID: userID, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkIncUserStatItemValue2(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) BulkIncUserStatItem1(namespace string, userID string, content []*socialclientmodels.BulkStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.BulkIncUserStatItem1Params{ - Body: content, - Namespace: namespace, - UserID: userID, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.BulkIncUserStatItem1(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicBulkIncUserStatItemValue(namespace string, content []*socialclientmodels.BulkUserStatItemInc) ([]*socialclientmodels.BulkStatItemOperationResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicBulkIncUserStatItemValueParams{ - Body: content, - Namespace: namespace, - } - ok, unprocessableEntity, err := s.SocialServiceClient.UserStatistic.PublicBulkIncUserStatItemValue(params, client.BearerToken(*token.AccessToken)) - if unprocessableEntity != nil { - errorMsg, _ := json.Marshal(*unprocessableEntity.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unprocessableEntity - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - -func (s *StatisticService) PublicIncUserStatItemValue(namespace string, statCode string, userID string, content *socialclientmodels.StatItemInc) (*socialclientmodels.StatItemIncResult, error) { - token, err := s.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - params := &user_statistic.PublicIncUserStatItemValueParams{ - Body: content, - Namespace: namespace, - StatCode: statCode, - UserID: userID, - } - ok, badRequest, notFound, conflict, err := s.SocialServiceClient.UserStatistic.PublicIncUserStatItemValue(params, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if conflict != nil { - errorMsg, _ := json.Marshal(*conflict.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, conflict - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -}