Added Admin and the start of Modules#2
Conversation
Merge in changes to Enrollment Terms and adding test suite
…and added Admin to entry class
| 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); | ||
| } |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
This will need to be tested - I do not know how the serializer handles enums.
No description provided.