Subversion Repository Public Repository

insightly-api

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using RestSharp;
using TS.Insightly.API.Contract;
using TS.Insightly.API.Interface;

namespace TS.Insightly.API.Controller
{
    /// <summary>
    /// API access to projects.
    /// </summary>
    internal class ProjectController : ControllerBase, IProjectController
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectController"/> class.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        public ProjectController(string apiKey)
            : base(apiKey)
        {

        }

        /// <summary>
        /// Gets the project for the unique organisation ID.
        /// Note that the Id is not the Id shown for the project in the web browser, but
        /// the project Id that is unique to insightly.
        /// </summary>
        /// <param name="projectId">The project unique identifier.</param>
        /// <returns>The project for the given id.</returns>
        public Project GetProject(int projectId)
        {
            var request = new RestRequest(Method.GET);
            request.RequestFormat = DataFormat.Json;
            request.Resource = String.Format("projects/{0}", projectId);

            return Execute<Project>(request);
        }

        /// <summary>
        /// Gets projects.
        /// </summary>
        /// <param name="fullDetails">if set to <c>true</c> return full details.</param>
        /// <returns>All projects.</returns>
        public List<Project> GetProjects(bool fullDetails)
        {
            var request = new RestRequest(Method.GET);
            request.RequestFormat = DataFormat.Json;
            request.Resource = fullDetails ? "projects" : "projects?brief=true";

            return Execute<List<Project>>(request);
        }
    }
}

Commits for insightly-api/trunk/Insightly/Controller/ProjectController.cs

Diff revisions: vs.
Revision Author Commited Message
15 HadleyHope picture HadleyHope Tue 01 Oct, 2013 13:47:15 +0000

Refactored, added Ninject to load controllers for each part of the API.
InsightlyAPI class is now a true facade for the API.