Skip to content

Commit

Permalink
Add satori function doc tags.
Browse files Browse the repository at this point in the history
Satori intergration refactor and improvements.
  • Loading branch information
sesposito committed Mar 8, 2023
1 parent b063315 commit aa72ee0
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 297 deletions.
15 changes: 0 additions & 15 deletions data/local.yml

This file was deleted.

46 changes: 45 additions & 1 deletion internal/satori/satori.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ type authenticateBody struct {
Id string `json:"id"`
}

// @group satori
// @summary Create a new identity.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @param id(type=string) The identifier of the identity.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) Authenticate(ctx context.Context, id string) error {
url := s.url.String() + "/v1/authenticate"

Expand Down Expand Up @@ -134,7 +139,13 @@ func (s *SatoriClient) Authenticate(ctx context.Context, id string) error {
}
}

func (s *SatoriClient) PropertiesList(ctx context.Context, id string) (*runtime.Properties, error) {
// @group satori
// @summary Get identity properties.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @param id(type=string) The identifier of the identity.
// @return properties(type=*runtime.Properties) The identity properties.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) PropertiesGet(ctx context.Context, id string) (*runtime.Properties, error) {
url := s.url.String() + "/v1/properties"

sessionToken, err := s.generateToken(id)
Expand Down Expand Up @@ -171,6 +182,12 @@ func (s *SatoriClient) PropertiesList(ctx context.Context, id string) (*runtime.
}
}

// @group satori
// @summary Update identity properties.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @oaram id(type=string) The identifier of the identity.
// @param properties(type=*runtime.PropertiesUpdate) The identity properties to update.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) PropertiesUpdate(ctx context.Context, id string, properties *runtime.PropertiesUpdate) error {
url := s.url.String() + "/v1/properties"

Expand Down Expand Up @@ -217,6 +234,12 @@ func (e *event) setTimestamp() {
e.TimestampPb = time.Unix(e.Timestamp, 0).Format(time.RFC3339)
}

// @group satori
// @summary Publish an event.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @oaram id(type=string) The identifier of the identity.
// @param events(type=[]*runtime.Event) An array of events to publish.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) EventsPublish(ctx context.Context, id string, events []*runtime.Event) error {
url := s.url.String() + "/v1/event"

Expand Down Expand Up @@ -258,6 +281,13 @@ func (s *SatoriClient) EventsPublish(ctx context.Context, id string, events []*r
}
}

// @group satori
// @summary List experiments.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @oaram id(type=string) The identifier of the identity.
// @param names(type=[]string, optional=true, default=[]) Optional list of experiment names to filter.
// @return experiments(type=*runtime.ExperimentList) The experiment list.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) ExperimentsList(ctx context.Context, id string, names ...string) (*runtime.ExperimentList, error) {
url := s.url.String() + "/v1/experiment"

Expand Down Expand Up @@ -303,6 +333,13 @@ func (s *SatoriClient) ExperimentsList(ctx context.Context, id string, names ...
}
}

// @group satori
// @summary List flags.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @oaram id(type=string) The identifier of the identity.
// @param names(type=[]string, optional=true, default=[]) Optional list of flag names to filter.
// @return flags(type=*runtime.FlagList) The flag list.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) FlagsList(ctx context.Context, id string, names ...string) (*runtime.FlagList, error) {
url := s.url.String() + "/v1/flag"

Expand Down Expand Up @@ -348,6 +385,13 @@ func (s *SatoriClient) FlagsList(ctx context.Context, id string, names ...string
}
}

// @group satori
// @summary List live events.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @oaram id(type=string) The identifier of the identity.
// @param names(type=[]string, optional=true, default=[]) Optional list of live event names to filter.
// @return liveEvents(type=*runtime.LiveEventsList) The live event list.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) LiveEventsList(ctx context.Context, id string, names ...string) (*runtime.LiveEventList, error) {
url := s.url.String() + "/v1/live-event"

Expand Down
13 changes: 8 additions & 5 deletions server/runtime_go_nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ func (n *RuntimeGoNakamaModule) StreamSendRaw(mode uint8, subject, subcontext, l
// @summary Disconnect a session.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @param sessionId(type=string) The ID of the session to be disconnected.
// @param reason(type=runtime.PresenceReason) The reason for the session disconnect.
// @param reason(type=runtime.PresenceReason, optional=true) The reason for the session disconnect.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) SessionDisconnect(ctx context.Context, sessionID string, reason ...runtime.PresenceReason) error {
sid, err := uuid.FromString(sessionID)
Expand Down Expand Up @@ -2782,7 +2782,7 @@ func (n *RuntimeGoNakamaModule) TournamentRecordsHaystack(ctx context.Context, i
// @param userId(type=string) The user ID of the owner of the receipt.
// @param receipt(type=string) Base-64 encoded receipt data returned by the purchase operation itself.
// @param persist(type=bool) Persist the purchase so that seenBefore can be computed to protect against replay attacks.
// @param passwordOverride(type=string) Override the iap.apple.shared_password provided in your configuration.
// @param passwordOverride(type=string, optional=true) Override the iap.apple.shared_password provided in your configuration.
// @return validation(*api.ValidatePurchaseResponse) The resulting successfully validated purchases. Any previously validated purchases are returned with a seenBefore flag.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) PurchaseValidateApple(ctx context.Context, userID, receipt string, persist bool, passwordOverride ...string) (*api.ValidatePurchaseResponse, error) {
Expand Down Expand Up @@ -2819,7 +2819,7 @@ func (n *RuntimeGoNakamaModule) PurchaseValidateApple(ctx context.Context, userI
// @param userId(type=string) The user ID of the owner of the receipt.
// @param receipt(type=string) JSON encoded Google receipt.
// @param persist(type=bool) Persist the purchase so that seenBefore can be computed to protect against replay attacks.
// @param overrides(type=string) Override the iap.google.client_email and iap.google.private_key provided in your configuration.
// @param overrides(type=string, optional=true) Override the iap.google.client_email and iap.google.private_key provided in your configuration.
// @return validation(*api.ValidatePurchaseResponse) The resulting successfully validated purchases. Any previously validated purchases are returned with a seenBefore flag.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) PurchaseValidateGoogle(ctx context.Context, userID, receipt string, persist bool, overrides ...struct {
Expand Down Expand Up @@ -2945,7 +2945,7 @@ func (n *RuntimeGoNakamaModule) PurchaseGetByTransactionId(ctx context.Context,
// @param userId(type=string) The user ID of the owner of the receipt.
// @param receipt(type=string) Base-64 encoded receipt data returned by the purchase operation itself.
// @param persist(type=bool) Persist the subscription.
// @param passwordOverride(type=string) Override the iap.apple.shared_password provided in your configuration.
// @param passwordOverride(type=string, optional=true) Override the iap.apple.shared_password provided in your configuration.
// @return validation(*api.ValidateSubscriptionResponse) The resulting successfully validated subscription purchase.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) SubscriptionValidateApple(ctx context.Context, userID, receipt string, persist bool, passwordOverride ...string) (*api.ValidateSubscriptionResponse, error) {
Expand Down Expand Up @@ -2982,7 +2982,7 @@ func (n *RuntimeGoNakamaModule) SubscriptionValidateApple(ctx context.Context, u
// @param userId(type=string) The user ID of the owner of the receipt.
// @param receipt(type=string) JSON encoded Google receipt.
// @param persist(type=bool) Persist the subscription.
// @param overrides(type=string) Override the iap.google.client_email and iap.google.private_key provided in your configuration.
// @param overrides(type=string, optional=true) Override the iap.google.client_email and iap.google.private_key provided in your configuration.
// @return validation(*api.ValidatePurchaseResponse) The resulting successfully validated subscription.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) SubscriptionValidateGoogle(ctx context.Context, userID, receipt string, persist bool, overrides ...struct {
Expand Down Expand Up @@ -3991,6 +3991,9 @@ func (n *RuntimeGoNakamaModule) ChannelIdBuild(ctx context.Context, senderId, ta
return channelId, nil
}

// @group satori
// @summary Get the Satori client.
// @return satori(runtime.Satori) The Satori client.
func (n *RuntimeGoNakamaModule) GetSatori() runtime.Satori {
return n.satori
}

0 comments on commit aa72ee0

Please sign in to comment.