From 744b1936b10446af7488d88304589b30ca778525 Mon Sep 17 00:00:00 2001 From: Ahmad Nurjalal Date: Thu, 28 Oct 2021 11:17:02 +0700 Subject: [PATCH] fix: adjust wrappers to the new generated code --- .../leaderboardConfigurationService.go | 33 -------- .../pkg/service/lobby/notification.go | 68 ---------------- services-api/pkg/service/lobby/party.go | 81 ------------------- .../pkg/service/platform/entitlement.go | 6 +- .../pkg/service/sessionbrowser/session.go | 14 +++- services-api/pkg/service/ugc/adminChannel.go | 32 ++++---- services-api/pkg/service/ugc/adminContent.go | 32 ++++---- services-api/pkg/service/ugc/publicChannel.go | 16 ++-- 8 files changed, 55 insertions(+), 227 deletions(-) diff --git a/services-api/pkg/service/leaderboard/leaderboardConfigurationService.go b/services-api/pkg/service/leaderboard/leaderboardConfigurationService.go index c08e37195..ec85aa273 100644 --- a/services-api/pkg/service/leaderboard/leaderboardConfigurationService.go +++ b/services-api/pkg/service/leaderboard/leaderboardConfigurationService.go @@ -124,39 +124,6 @@ func (l *LeaderboardConfigurationService) CreateLeaderboardConfigurationPublicV1 return ok.GetPayload(), nil } -func (l *LeaderboardConfigurationService) DeleteBulkLeaderboardsV1(input *leaderboard_configuration.DeleteBulkLeaderboardsV1Params) (*leaderboardclientmodels.ModelsDeleteBulkLeaderboardsResp, error) { - token, err := l.TokenRepository.GetToken() - if err != nil { - return nil, err - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := l.Client.LeaderboardConfiguration.DeleteBulkLeaderboardsV1(input, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, forbidden - } - if internalServerError != nil { - errorMsg, _ := json.Marshal(*internalServerError.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, internalServerError - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - func (l *LeaderboardConfigurationService) DeleteLeaderboardConfigurationAdminV1(input *leaderboard_configuration.DeleteLeaderboardConfigurationAdminV1Params) error { token, err := l.TokenRepository.GetToken() if err != nil { diff --git a/services-api/pkg/service/lobby/notification.go b/services-api/pkg/service/lobby/notification.go index 2bd9520cd..4cfd473a0 100644 --- a/services-api/pkg/service/lobby/notification.go +++ b/services-api/pkg/service/lobby/notification.go @@ -579,40 +579,6 @@ func (n *NotificationService) GetAllNotificationTopicsV1Admin(input *notificatio return ok.GetPayload(), nil } -func (n *NotificationService) GetAllStoredNotificationsV1(input *notification.GetAllStoredNotificationsV1Params) ([]*lobbyclientmodels.ModelGetStoredNotificationResp, error) { - token, err := n.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - ok, unauthorized, forbidden, notFound, internalServerError, err := n.Client.Notification.GetAllStoredNotificationsV1(input, client.BearerToken(*token.AccessToken)) - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, forbidden - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if internalServerError != nil { - errorMsg, _ := json.Marshal(*internalServerError.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, internalServerError - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - func (n *NotificationService) GetGameTemplate(input *notification.GetGameTemplateParams) ([]*lobbyclientmodels.ModelTemplateResponse, error) { token, err := n.TokenRepository.GetToken() if err != nil { @@ -715,40 +681,6 @@ func (n *NotificationService) GetNotificationTopicV1Admin(input *notification.Ge return ok.GetPayload(), nil } -func (n *NotificationService) GetNotifications(input *notification.GetNotificationsParams) ([]*lobbyclientmodels.ModelNotificationResponse, error) { - token, err := n.TokenRepository.GetToken() - if err != nil { - logrus.Error(err) - return nil, err - } - ok, unauthorized, forbidden, notFound, internalServerError, err := n.Client.Notification.GetNotifications(input, client.BearerToken(*token.AccessToken)) - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, forbidden - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if internalServerError != nil { - errorMsg, _ := json.Marshal(*internalServerError.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, internalServerError - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - func (n *NotificationService) GetSingleTemplateLocalizationV1Admin(input *notification.GetSingleTemplateLocalizationV1AdminParams) (*lobbyclientmodels.ModelLocalization, error) { token, err := n.TokenRepository.GetToken() if err != nil { diff --git a/services-api/pkg/service/lobby/party.go b/services-api/pkg/service/lobby/party.go index 19a5a5a8b..0dad7e2c5 100644 --- a/services-api/pkg/service/lobby/party.go +++ b/services-api/pkg/service/lobby/party.go @@ -15,44 +15,6 @@ type PartyService struct { TokenRepository repository.TokenRepository } -func (p *PartyService) AdminGetPartiesDataV1(input *party.AdminGetPartiesDataV1Params) ([]*lobbyclientmodels.ModelsPartyData, error) { - token, err := p.TokenRepository.GetToken() - if err != nil { - return nil, err - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := p.Client.Party.AdminGetPartiesDataV1(input, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, forbidden - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if internalServerError != nil { - errorMsg, _ := json.Marshal(*internalServerError.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, internalServerError - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - func (p *PartyService) AdminGetPartyDataV1(input *party.AdminGetPartyDataV1Params) (*lobbyclientmodels.ModelsPartyData, error) { token, err := p.TokenRepository.GetToken() if err != nil { @@ -129,49 +91,6 @@ func (p *PartyService) AdminGetUserPartyV1(input *party.AdminGetUserPartyV1Param return ok.GetPayload(), nil } -func (p *PartyService) AdminUpdatePartyAttributesV1(input *party.AdminUpdatePartyAttributesV1Params) (*lobbyclientmodels.ModelsPartyData, error) { - token, err := p.TokenRepository.GetToken() - if err != nil { - return nil, err - } - ok, badRequest, unauthorized, forbidden, notFound, preconditionFailed, internalServerError, err := p.Client.Party.AdminUpdatePartyAttributesV1(input, client.BearerToken(*token.AccessToken)) - if badRequest != nil { - errorMsg, _ := json.Marshal(*badRequest.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, badRequest - } - if unauthorized != nil { - errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, unauthorized - } - if forbidden != nil { - errorMsg, _ := json.Marshal(*forbidden.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, forbidden - } - if notFound != nil { - errorMsg, _ := json.Marshal(*notFound.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, notFound - } - if preconditionFailed != nil { - errorMsg, _ := json.Marshal(*preconditionFailed.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, preconditionFailed - } - if internalServerError != nil { - errorMsg, _ := json.Marshal(*internalServerError.GetPayload()) - logrus.Error(string(errorMsg)) - return nil, internalServerError - } - if err != nil { - logrus.Error(err) - return nil, err - } - return ok.GetPayload(), nil -} - func (p *PartyService) PublicGetPartyDataV1(input *party.PublicGetPartyDataV1Params) (*lobbyclientmodels.ModelsPartyData, error) { token, err := p.TokenRepository.GetToken() if err != nil { diff --git a/services-api/pkg/service/platform/entitlement.go b/services-api/pkg/service/platform/entitlement.go index 4f0e8b70d..0e601e22a 100644 --- a/services-api/pkg/service/platform/entitlement.go +++ b/services-api/pkg/service/platform/entitlement.go @@ -195,7 +195,7 @@ func (e *EntitlementService) UpdateUserEntitlement(input *entitlement.UpdateUser return userEntitlement.GetPayload(), nil } -func (e *EntitlementService) GetUserEntitlementOwnershipBySku(input *entitlement.GetUserEntitlementOwnershipBySkuParams) (*platformclientmodels.Ownership, error) { +func (e *EntitlementService) GetUserEntitlementOwnershipBySku(input *entitlement.GetUserEntitlementOwnershipBySkuParams) (*platformclientmodels.TimedOwnership, error) { accessToken, err := e.TokenRepository.GetToken() if err != nil { logrus.Error(err) @@ -449,7 +449,7 @@ func (e *EntitlementService) PublicGetMyAppEntitlementOwnershipByAppID(input *en return ownershipByAppID.GetPayload(), nil } -func (e *EntitlementService) PublicGetMyEntitlementOwnershipBySku(input *entitlement.PublicGetMyEntitlementOwnershipBySkuParams) (*platformclientmodels.Ownership, error) { +func (e *EntitlementService) PublicGetMyEntitlementOwnershipBySku(input *entitlement.PublicGetMyEntitlementOwnershipBySkuParams) (*platformclientmodels.TimedOwnership, error) { accessToken, err := e.TokenRepository.GetToken() if err != nil { logrus.Error(err) @@ -555,7 +555,7 @@ func (e *EntitlementService) PublicDeleteUserDistributionReceiver(input *entitle return nil } -func (e *EntitlementService) PublicGetUserEntitlementOwnershipBySku(input *entitlement.PublicGetUserEntitlementOwnershipBySkuParams) (*platformclientmodels.Ownership, error) { +func (e *EntitlementService) PublicGetUserEntitlementOwnershipBySku(input *entitlement.PublicGetUserEntitlementOwnershipBySkuParams) (*platformclientmodels.TimedOwnership, error) { accessToken, err := e.TokenRepository.GetToken() if err != nil { logrus.Error(err) diff --git a/services-api/pkg/service/sessionbrowser/session.go b/services-api/pkg/service/sessionbrowser/session.go index b8b7fdac4..193cf5ed7 100644 --- a/services-api/pkg/service/sessionbrowser/session.go +++ b/services-api/pkg/service/sessionbrowser/session.go @@ -52,12 +52,17 @@ func (b *SessionService) CreateSession(input *sessionBrowser.CreateSessionParams logrus.Error(err) return nil, err } - ok, badRequest, conflict, internalServer, err := b.Client.Session.CreateSession(input, client.BearerToken(*token.AccessToken)) + ok, badRequest, forbidden, conflict, internalServer, err := b.Client.Session.CreateSession(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) return nil, badRequest } + if forbidden != nil { + errorMsg, _ := json.Marshal(*forbidden.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, forbidden + } if conflict != nil { errorMsg, _ := json.Marshal(*conflict.GetPayload()) logrus.Error(string(errorMsg)) @@ -377,12 +382,17 @@ func (b *SessionService) JoinSession(input *sessionBrowser.JoinSessionParams) (* logrus.Error(err) return nil, err } - ok, badRequest, notFound, internalServer, err := b.Client.Session.JoinSession(input, client.BearerToken(*token.AccessToken)) + ok, badRequest, forbidden, notFound, internalServer, err := b.Client.Session.JoinSession(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) return nil, badRequest } + if forbidden != nil { + errorMsg, _ := json.Marshal(*forbidden.GetPayload()) + logrus.Error(string(errorMsg)) + return nil, forbidden + } if notFound != nil { errorMsg, _ := json.Marshal(*notFound.GetPayload()) logrus.Error(string(errorMsg)) diff --git a/services-api/pkg/service/ugc/adminChannel.go b/services-api/pkg/service/ugc/adminChannel.go index 1c1b063b0..f16afda12 100644 --- a/services-api/pkg/service/ugc/adminChannel.go +++ b/services-api/pkg/service/ugc/adminChannel.go @@ -50,33 +50,33 @@ func (u *AdminChannelService) AdminCreateChannel(input *nr_admin_channel.AdminCr } // AdminDeleteChannel deletes channel -func (u *AdminChannelService) AdminDeleteChannel(input *nr_admin_channel.AdminDeleteChannelParams) (*ugcclientmodels.ModelsChannelResponse, error) { +func (u *AdminChannelService) AdminDeleteChannel(input *nr_admin_channel.AdminDeleteChannelParams) error { token, err := u.TokenRepository.GetToken() if err != nil { logrus.Error(err) - return nil, err + return err } - ok, unauthorized, notFound, internalServer, err := u.Client.NrAdminChannel.AdminDeleteChannel(input, client.BearerToken(*token.AccessToken)) + _, unauthorized, notFound, internalServer, err := u.Client.NrAdminChannel.AdminDeleteChannel(input, client.BearerToken(*token.AccessToken)) if unauthorized != nil { errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) logrus.Error(string(errorMsg)) - return nil, unauthorized + return unauthorized } if notFound != nil { errorMsg, _ := json.Marshal(*notFound.GetPayload()) logrus.Error(string(errorMsg)) - return nil, notFound + return notFound } if internalServer != nil { errorMsg, _ := json.Marshal(*internalServer.GetPayload()) logrus.Error(string(errorMsg)) - return nil, internalServer + return internalServer } if err != nil { logrus.Error(err) - return nil, err + return err } - return ok.GetPayload(), nil + return nil } // AdminGetChannel gets channels @@ -145,33 +145,33 @@ func (u *AdminChannelService) AdminUpdateChannel(input *nr_admin_channel.AdminUp } // SingleAdminDeleteChannel deletes channel -func (u *AdminChannelService) SingleAdminDeleteChannel(input *nr_admin_channel.SingleAdminDeleteChannelParams) (*ugcclientmodels.ModelsChannelResponse, error) { +func (u *AdminChannelService) SingleAdminDeleteChannel(input *nr_admin_channel.SingleAdminDeleteChannelParams) error { token, err := u.TokenRepository.GetToken() if err != nil { logrus.Error(err) - return nil, err + return err } - ok, unauthorized, notFound, internalServer, err := u.Client.NrAdminChannel.SingleAdminDeleteChannel(input, client.BearerToken(*token.AccessToken)) + _, unauthorized, notFound, internalServer, err := u.Client.NrAdminChannel.SingleAdminDeleteChannel(input, client.BearerToken(*token.AccessToken)) if unauthorized != nil { errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) logrus.Error(string(errorMsg)) - return nil, unauthorized + return unauthorized } if notFound != nil { errorMsg, _ := json.Marshal(*notFound.GetPayload()) logrus.Error(string(errorMsg)) - return nil, notFound + return notFound } if internalServer != nil { errorMsg, _ := json.Marshal(*internalServer.GetPayload()) logrus.Error(string(errorMsg)) - return nil, internalServer + return internalServer } if err != nil { logrus.Error(err) - return nil, err + return err } - return ok.GetPayload(), nil + return nil } // SingleAdminGetChannel gets channel diff --git a/services-api/pkg/service/ugc/adminContent.go b/services-api/pkg/service/ugc/adminContent.go index f23b82646..6b4cdb6d4 100644 --- a/services-api/pkg/service/ugc/adminContent.go +++ b/services-api/pkg/service/ugc/adminContent.go @@ -20,33 +20,33 @@ type AdminContentService struct { } // AdminDeleteContent deletes content -func (a *AdminContentService) AdminDeleteContent(input *nr_admin_content.AdminDeleteContentParams) (*ugcclientmodels.ModelsCreateContentResponse, error) { +func (a *AdminContentService) AdminDeleteContent(input *nr_admin_content.AdminDeleteContentParams) error { token, err := a.TokenRepository.GetToken() if err != nil { logrus.Error(err) - return nil, err + return err } - created, unauthorized, notFound, internalServer, err := a.Client.NrAdminContent.AdminDeleteContent(input, client.BearerToken(*token.AccessToken)) + _, unauthorized, notFound, internalServer, err := a.Client.NrAdminContent.AdminDeleteContent(input, client.BearerToken(*token.AccessToken)) if unauthorized != nil { errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) logrus.Error(string(errorMsg)) - return nil, unauthorized + return unauthorized } if notFound != nil { errorMsg, _ := json.Marshal(*notFound.GetPayload()) logrus.Error(string(errorMsg)) - return nil, notFound + return notFound } if internalServer != nil { errorMsg, _ := json.Marshal(*internalServer.GetPayload()) logrus.Error(string(errorMsg)) - return nil, internalServer + return internalServer } if err != nil { logrus.Error(err) - return nil, err + return err } - return created.GetPayload(), nil + return nil } // AdminDownloadContentPreview gets content preview @@ -360,33 +360,33 @@ func (a *AdminContentService) AdminUploadContentS3(input *nr_admin_content.Admin } // SingleAdminDeleteContent deletes content -func (a *AdminContentService) SingleAdminDeleteContent(input *nr_admin_content.SingleAdminDeleteContentParams) (*ugcclientmodels.ModelsCreateContentResponse, error) { +func (a *AdminContentService) SingleAdminDeleteContent(input *nr_admin_content.SingleAdminDeleteContentParams) error { token, err := a.TokenRepository.GetToken() if err != nil { logrus.Error(err) - return nil, err + return err } - created, unauthorized, notFound, internalServer, err := a.Client.NrAdminContent.SingleAdminDeleteContent(input, client.BearerToken(*token.AccessToken)) + _, unauthorized, notFound, internalServer, err := a.Client.NrAdminContent.SingleAdminDeleteContent(input, client.BearerToken(*token.AccessToken)) if unauthorized != nil { errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) logrus.Error(string(errorMsg)) - return nil, unauthorized + return unauthorized } if notFound != nil { errorMsg, _ := json.Marshal(*notFound.GetPayload()) logrus.Error(string(errorMsg)) - return nil, notFound + return notFound } if internalServer != nil { errorMsg, _ := json.Marshal(*internalServer.GetPayload()) logrus.Error(string(errorMsg)) - return nil, internalServer + return internalServer } if err != nil { logrus.Error(err) - return nil, err + return err } - return created.GetPayload(), nil + return nil } // SingleAdminGetContent gets user's generated contents diff --git a/services-api/pkg/service/ugc/publicChannel.go b/services-api/pkg/service/ugc/publicChannel.go index 813a6e78d..05e046eb9 100644 --- a/services-api/pkg/service/ugc/publicChannel.go +++ b/services-api/pkg/service/ugc/publicChannel.go @@ -48,33 +48,33 @@ func (u *PublicChannelService) CreateChannel(input *nr_public_channel.CreateChan return created.GetPayload(), nil } -func (u *PublicChannelService) DeleteChannel(input *nr_public_channel.DeleteChannelParams) (*ugcclientmodels.ModelsChannelResponse, error) { +func (u *PublicChannelService) DeleteChannel(input *nr_public_channel.DeleteChannelParams) error { token, err := u.TokenRepository.GetToken() if err != nil { logrus.Error(err) - return nil, err + return err } - ok, unauthorized, notFound, internalServer, err := u.Client.NrPublicChannel.DeleteChannel(input, client.BearerToken(*token.AccessToken)) + _, unauthorized, notFound, internalServer, err := u.Client.NrPublicChannel.DeleteChannel(input, client.BearerToken(*token.AccessToken)) if unauthorized != nil { errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) logrus.Error(string(errorMsg)) - return nil, unauthorized + return unauthorized } if notFound != nil { errorMsg, _ := json.Marshal(*notFound.GetPayload()) logrus.Error(string(errorMsg)) - return nil, notFound + return notFound } if internalServer != nil { errorMsg, _ := json.Marshal(*internalServer.GetPayload()) logrus.Error(string(errorMsg)) - return nil, internalServer + return internalServer } if err != nil { logrus.Error(err) - return nil, err + return err } - return ok.GetPayload(), nil + return nil } func (u *PublicChannelService) GetChannels(input *nr_public_channel.GetChannelsParams) (*ugcclientmodels.ModelsPaginatedGetChannelResponse, error) {