diff --git a/adminapi/users.go b/adminapi/users.go index ed1b84f..e62dbfd 100644 --- a/adminapi/users.go +++ b/adminapi/users.go @@ -55,6 +55,13 @@ type Users interface { // // If the user already exists, this is a no-op. ImportAccount(ctx context.Context, userId string, input *UserImportAccountInput) (*adminv1.User, error) + // Report a user action. + // + // If the `@` user identifier syntax is + // used and the user doesn't exist, they will be imported. + // + // By default, the action is processed asynchronously. + ReportAction(ctx context.Context, userId string, input *UserReportActionInput) (*adminv1.ReportUserActionResponse, error) // Create a User API session. CreateApiSession(ctx context.Context, userId string, input *UserCreateApiSessionInput) (*adminv1.CreateApiSessionResponse, error) // Create a Portal session. @@ -730,6 +737,54 @@ func (n *usersImpl) ImportAccount(ctx context.Context, userId string, input *Use return model, nil } +// UserReportActionInput is the input param for the ReportAction method. +type UserReportActionInput struct { + // The type of action. + Action string + // Process the user action synchronously. + // + // Otherwise the action is processed in the background and errors + // won't be returned. + Wait bool +} + +func (n *usersImpl) ReportAction(ctx context.Context, userId string, input *UserReportActionInput) (*adminv1.ReportUserActionResponse, error) { + req := internal.NewRequest( + "admin.users.reportAction", + "POST", + fmt.Sprintf("/admin/v1/users/%s:reportAction", + url.PathEscape(userId), + ), + ) + + body := map[string]any{} + + if input != nil { + if !internal.IsEmpty(input.Action) { + body["action"] = input.Action + } + if !internal.IsEmpty(input.Wait) { + body["wait"] = input.Wait + } + } + + req.SetBody(body) + + res, err := n.transport.Execute(ctx, req) + if err != nil { + return nil, err + } + + model := &adminv1.ReportUserActionResponse{} + + err = res.DecodeBody(&model) + if err != nil { + return nil, err + } + + return model, nil +} + // UserCreateApiSessionInput is the input param for the CreateApiSession method. type UserCreateApiSessionInput struct { } diff --git a/adminv1/builtin_email_connection.go b/adminv1/builtin_email_connection.go index 2442690..6a1fce5 100644 --- a/adminv1/builtin_email_connection.go +++ b/adminv1/builtin_email_connection.go @@ -4,6 +4,4 @@ package adminv1 // The builtin email specific connection data. type BuiltinEmailConnection struct { - // The allowed email list. - AllowedEmails []string `json:"allowedEmails"` } diff --git a/adminv1/postmark_connection.go b/adminv1/postmark_connection.go index b3d9935..11df216 100644 --- a/adminv1/postmark_connection.go +++ b/adminv1/postmark_connection.go @@ -21,6 +21,4 @@ type PostmarkConnection struct { From *commonv1.Email `json:"from"` // The reply to email address. ReplyTo *commonv1.Email `json:"replyTo"` - // The allowed email list. - AllowedEmails []string `json:"allowedEmails"` } diff --git a/adminv1/report_user_action_response.go b/adminv1/report_user_action_response.go new file mode 100644 index 0000000..f98f130 --- /dev/null +++ b/adminv1/report_user_action_response.go @@ -0,0 +1,7 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +// Response message for ReportUserAction. +type ReportUserActionResponse struct { +} diff --git a/internal/constants.go b/internal/constants.go index 5b1303e..1b2101e 100644 --- a/internal/constants.go +++ b/internal/constants.go @@ -9,8 +9,8 @@ import ( const ( ApiBaseUrl = "https://api.userhub.com" ApiVersion = "2025-05-01" - UserAgent = "UserHub-Go/0.8.0" - Version = "0.8.0" + UserAgent = "UserHub-Go/0.8.1" + Version = "0.8.1" AuthHeader = "Authorization" ApiKeyHeader = "UserHub-Api-Key"