Project Description
A .Net C# wrapper API for AgileZen REST API, which provides an easy to use fluent API

The wrapper uses the AgileZen REST API to retrive data from you projects.

Features
  • Read/modify access to AgileZen through REST API
  • Hides serialization and REST calls
  • Easy to use fluent API which includes Enrichments and Filters
  • Deferred execution through IEnumerable
  • Lazy load of collections
  • Interface with optional named parameter for create operations
  • Implements all List/Create/Get/Update/Delete/Add/Remove operations from the API

Configuration
Configuration is done through the application configuration file (optional):
<configuration>
    <configSections>
        <sectionGroup name="prearrangedChaos">
            <section name="zenRestConfiguration" type="PrearrangedChaos.AgileZen.Service.Rest.Configuration, PrearrangedChaos.AgileZen.Service"/>
        </sectionGroup>
    </configSections>
    <prearrangedChaos>
        <zenRestConfiguration 
            baseAddress="https://agilezen.com/api/v1/" 
            defaultApiKey="[Your_Key]" 
            defaultPageSize="100" />
    </prearrangedChaos>
</configuration>

The apiKey can be created from the settings part of the AgileZen UI.

Usage Examples
            //Setup service instance
            ZenService service = new ZenService();
            service.PageSize = 50; //Optional - default from config file
            service.ApiKey = .....; //Optional - default from config file

            //Setup variables
            int projectId = 4567;

            //Create a new story
            IStory story = service.CreateStory(
                projectId, 
                "As a user, I want to be able to log in, so I securely can view my personal information online", 
                deadline:DateTime.UtcNow.AddDays(5), 
                color: StoryColor.Red,
                ownerId: 27997,
                status: StoryStatus.Planned,
                phaseId: 124795);

            //Get story with metrics and details
            IStory existingStory = service.GetStory(projectId, story.Id, options => options.WithMetrics().WithDetails());

            //Update story
            story.Size = "8";
            service.UpdateStory(story, projectId);

            //Add tag to story
            ITag tag = service.CreateTag(projectId, "ChangeSet:4575");
            service.AddTagToStory(projectId, story.Id, tag.Id);

            //Delete story
            service.DeleteStory(projectId, story.Id);

            //Get projects with the project owner "John Doe" with member details and metrics 
            IEnumerable<IProject> projects = service.GetProjects()
                .WithMembers
                .WithMetrics
                .Filter(project => project.Owner.Is("John Doe"));

            //Get all stories where either the color is blue and it has the tag "Bug" or it has the tag "CriticalBug"
            IEnumerable<IStory> stories = service.GetStories(projectId)
                .WithTags
                .WithTasks
                .WithDetails
                .Filter(story =>
                        (story.Color.Blue & story.Tag.Is("Bug")) |
                        story.Tag.Is("CriticalBug"));


Operation Interface
    public interface IZenService
    {
        int PageSize { get; set; }

        //Get operations
        IAttachment GetAttachment(int projectId, int storyId, int attachmentId);
        IComment GetComment(int projectId, int storyId, int commentId);
        IInvite GetInvite(int projectId, int inviteId);
        IUser GetMe();
        IUser GetMe(Action<MeOptions> options);
        IPhase GetPhase(int projectId, int phaseId);
        IPhase GetPhase(int projectId, int phaseId, Action<PhaseOptions> options);
        IProject GetProject(int projectId);
        IProject GetProject(int projectId, Action<ProjectOptions> options);
        IRole GetRole(int projectId, int roleId);
        IStory GetStory(int projectId, int storyId);
        IStory GetStory(int projectId, int storyId, Action<StoryOptions> options);
        ITag GetTag(int projectId, int tagId);
        ITag GetTag(int projectId, int tagId, Action<TagOptions> options)
        ITag GetTag(int projectId, string tag);
        ITag GetTag(int projectId, string tag, Action<TagOptions> options)
        ITask GetTask(int projectId, int storyId, int taskId);

        //List operations
        IZenAttachmentEnumerable GetAttachments(int projectId, int storyId);
        IZenCommentEnumerable GetComments(int projectId, int storyId);
        IZenInviteEnumerable GetInvites(int projectId);
        IZenPhaseEnumerable GetPhases(int projectId);
        IZenProjectEnumerable GetProjects();
        IZenUserEnumerable GetProjectMembers(int projectId);
        IZenRoleEnumerable GetRoles(int projectId);
        IZenUserEnumerable GetRoleMembers(int projectId, int roleId);
        IZenStoryEnumerable GetStories(int projectId);
        IZenStoryEnumerable GetMyStories();
        IZenTagEnumerable GetStoryTags(int storyId);
        IZenTagEnumerable GetTags(int projectId);
        IZenStoryEnumerable GetTagStories(int projectId, int tagId);
        IZenStoryEnumerable GetTagStories(int projectId, string tag);
        IZenTaskEnumerable GetTasks(int projectId, int storyId);

        //Create operations
        IStory CreateStory(int projectId, string text, string details = null, string size = null, StoryColor color = StoryColor.Grey, int? phaseId = null, int? ownerId = null, 
             DateTime? deadline = null, IEnumerable<ITag> tags = null, IEnumerable<ITask> tasks = null);
        IRole CreateRole(int projectId, string name, ApiAccess access);
        ITask CreateTask(int projectId, int storyId, string text, TaskStatus status = TaskStatus.Incomplete);
        ITag CreateTag(int projectId, string name);
        IPhase CreatePhase(int projectId, string name, string description, int? index = null, int? limit = null);
        IInvite CreateInvite(int projectId, string email, int roleId);
        IComment CreateComment(int projectId, int storyId, string text);
        IAttachment CreateAttachment(int projectId, int storyId, byte attachment);

        //Add operations
        void AddUserToRole(int projectId, int roleId, int userId);
        void AddTagToStory(int projectId, int storyId, int tagId);
        void AddUserToProject(int projectId, int userId);

        //Delete operations
        void DeleteAttachment(int projectId, int storyId, int attachmentId);
        void DeleteComment(int projectId, int storyId, int commentId);
        void DeleteInvite(int projectId, int inviteId);
        void DeletePhase(int projectId, int phaseId);
        void DeleteTag(int projectId, int tagId);
        void DeleteTask(int projectId, int storyId, int tagId);
        void DeleteRole(int projectId, int roleId);
        void DeleteStory(int projectId, int storyId);

        //Remove operations
        void RemoveUserFromProject(int projectId, int userId);
        void RemoveTagFromStory(int projectId, int storyId, int tagId);
        void RemoveUserFromRole(int projectId, int roleId, int userId);

        //Update operations
        IAttachment UpdateAttachment(IAttachmentUpdater attachment, int projectId, int storyId);
        IComment UpdateComment(ICommentUpdater comment, int projectId, int storyId);
        IPhase UpdatePhase(IPhaseUpdater phase, int projectId);
        ITag UpdateTag(ITagUpdater tag, int projectId);
        ITask UpdateTask(ITaskUpdater task, int projectId, int storyId);
        IRole UpdateRole(IRoleUpdater role, int projectId);
        IStory UpdateStory(IStoryUpdater story, int projectId);
        IProject UpdateProject(IProjectUpdater project);
    }

Last edited May 25, 2012 at 9:31 PM by prearrangedchaos, version 12