Skip to content

Commit

Permalink
refactor: social sdk wrapper and sample-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rulisastra committed Oct 15, 2021
1 parent 7961ffd commit bcaaa1d
Show file tree
Hide file tree
Showing 39 changed files with 1,772 additions and 1,920 deletions.
16 changes: 11 additions & 5 deletions samples/sample-apps/cmd/adminGetProfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
15 changes: 10 additions & 5 deletions samples/sample-apps/cmd/adminGetUserProfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
16 changes: 11 additions & 5 deletions samples/sample-apps/cmd/createProfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand All @@ -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 {
Expand Down
15 changes: 10 additions & 5 deletions samples/sample-apps/cmd/createStat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand All @@ -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
Expand Down
20 changes: 15 additions & 5 deletions samples/sample-apps/cmd/createUserSlot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand All @@ -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
}
Expand Down
16 changes: 11 additions & 5 deletions samples/sample-apps/cmd/deleteProfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down
15 changes: 10 additions & 5 deletions samples/sample-apps/cmd/deleteStat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down
16 changes: 11 additions & 5 deletions samples/sample-apps/cmd/deleteUserSlot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions samples/sample-apps/cmd/deleteUserSlotConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
16 changes: 11 additions & 5 deletions samples/sample-apps/cmd/getProfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
17 changes: 12 additions & 5 deletions samples/sample-apps/cmd/getProfileAttribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit bcaaa1d

Please sign in to comment.