Skip to content

Added Admin and the start of Modules#2

Merged
tiberhealth merged 9 commits intotiberhealth:mainfrom
dbagnoli:main
Apr 23, 2021
Merged

Added Admin and the start of Modules#2
tiberhealth merged 9 commits intotiberhealth:mainfrom
dbagnoli:main

Conversation

@dbagnoli
Copy link
Copy Markdown
Contributor

No description provided.

Task<IEnumerable<IAdmin>> List(long accountId, Action<IAdminList> body);
Task<IAdmin> Make(long accountId, Action<IAdminMake> admin);
Task<IAdmin> Remove(long accountId, long userId, Action<IAdminRemove> options = null);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on the concrete about the name possibilities. This API does not make or remove users, but promotes and demotes them.

internal class Admin : IAdmin
{
[JsonProperty("id")] public long Id { get; set; }
[JsonProperty("role")] public IRole Role { get; set; }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don deserialization this will fail. "Role" needs to be assigned to the Concrete so the deserializer knows what concrete to use when converting the JSON.

This is the reason we are using the explicit interface call in the next line. The IAdmin.Role => Role does the concrete back to interface conversion for the compiler.

{
internal class AdminList : IAdminList
{
[JsonProperty("user_id[]")] public int[] UserId { get; set; }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not need the [] - the serializer will notice that this is an array and add the [] automatically.


namespace CanvasApi.Client.Admins.Models
{
public interface IAdminMake
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the method is changed - the request class should also correspond.

internal class Role : IRole
{
[JsonProperty("label")] public long Label { get; set; }
[JsonProperty("base_role_type")] public IEnumerable<RoleBaseTypes> BaseRoleType { get; set; }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be tested - I do not know how the serializer handles enums.

@tiberhealth tiberhealth merged commit bb40d8f into tiberhealth:main Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants