Code Monkey home page Code Monkey logo

asananet's Introduction

! This project is no longer actively maintained !


AsanaNet

A .NET implementation of the Asana REST API http://developer.asana.com/

This open-source project uses the MIT license.

Using AsanaNet

To use AsanaNet, start by creating an instance of the Asana service. You can find your API key here.

 var asana = new Asana(YOUR_API_KEY, AuthenticationType.Basic, errorCallback);

All 'Get' requests are asynchronous and so must be accompanied by a callback. For example, to get the current user's information:

asana.GetMe(o =>
{
        var user = o as AsanaUser;
        Console.WriteLine("Hello, " + user.Name);
});

It is also possible to make them synchronize, by adding .Wait();.

Additionally, since the methods always return a task, you can await them within an async method, or another task.

asana.GetMe(o =>
{
        var user = o as AsanaUser;
        Console.WriteLine("Hello, " + user.Name);
}).Wait();

To get a list of workspaces the current user has access to:

asana.GetWorkspaces(o =>
{
    foreach (AsanaWorkspace workspace in o)
    {
        Console.WriteLine("Workspace: " + workspace.Name);
    }
});

To create a new task:

AsanaTask newTask1 = new AsanaTask(workspace);
newTask1.Name = "Pick up the milk!";
newTask1.Notes = "Proper semi-skimmed milk. None of that UHT rubbish.";
newTask1.Assignee = me;
newTask1.DueOn = DateTime.Now.AddHours(2);
newTask1.Save(asana);

Error callback method

The error callback method may be in the following form:

static void errorCallback(string s1, string s2, string s3)
{

}

Also, if you don't want handling anything, you can just pass an empty lambda into the constructor:

_asana = new Asana(_apiKey, AuthenticationType.Basic, (s1, s2, s3) => {});

Notes

asananet's People

Contributors

3dpros avatar acron0 avatar fabionaspolini avatar keithboynton avatar niieani avatar robertmiles3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asananet's Issues

Adding project to task while creating the task

Hi,
First of all, great work here.
I can currently manage to create a task, and assign it to myself (for testing purposes).
I want to add the task to a project while creating it, but it doesn't seem to work. That is, the project is not added to the task when I look in Asana (browser).

public void CreateTask()
{
    AsanaProject project = myProject;
    AsanaTask task = new AsanaTask(myWorkspace);

    task.Name = "Test task!";
    task.Notes = "asd asd asd asd lots of text";
    task.Assignee = me;
    task.DueOn = DateTime.Now.AddHours(4);
    task.AddProject(project, asana);
    task.Save(asana);
}

It should be noted that me, asana, myProject, and myWorkspace are correctly fetched before calling CreateTask().

I tried looking around in the source code, but I can't seem to find the reason why the project is not added to the new task.

The project has the following properties:

Archived = false
...
IsObjectLocal = false
...
Name = "<name of the project in Asana>"
...
base.Host.APIKey = "<my Asana API key>"
base.Host.AuthType = Basic
base.Host.EncodedAPIKey = "<some encoded key here>"
...
base.ID = <ID number of the project>
...

The other values represented by "..." are all null.

Attachements

There is no support for Attachements. Did you work on this already or is it sth which is worth to implement myself?

best regards

Visual Studio 2013 - Function doesn exist

Only little advice. After I opened project in VS 2013, i can not compile it, because of "Function doesn exist" in AsanaFunction.cs. You must go to NuGet package manager and install T4 package. Thats all. Now its working ;-)

Updating already existing objects and collections

Here's an example implementation of how this could be done:

niieani@6410ed0

With it, it's basically possible to do this:

        private IAsanaObjectCollection _asanaProjects;

        public async Task getProjectsWithDetails()
        {
            List<Task> ProjectDetailsWorkers = new List<Task>();
            await _asana.GetProjectsInWorkspace(_asanaWorkspace, projects =>
            {
                ProjectDetailsWorkers = projects.RefreshAll<AsanaProject>();
                _asanaProjects = projects;
            });
            Task.WaitAll(ProjectDetailsWorkers.ToArray());
        }

Which means that we get all the details of each project automatically, and we don't need to manually query for each project.
Queries will be done asynchronously and what's returned by RefreshAll<OBJECT>() or Refresh() is a Task, so we can Wait, or trigger whatever we want (a progress bar going forward for example).

Let me know what you think about it.
If you like it, we can mirror the technique across the rest of AsanaObjects.

How to get an OAuth token

Hi,

First of all, thanks for the project. also thanks for supporting OAuthToken.

Would you mind add an example of how to get an OAuth token?

Regards,
Eran

Assignee is always null

Task.Assignee is always null, even though in the Asana console it shows the task is assigned to someone. Please advise.

AsanaNet not returning data

I am doing a basic test of AsanaNet and I can't get it to return data, my arraylist count=0. Here is my controller.

public class AsanaController : Controller
{
    // GET: Asana
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult ImportFromAsana(string ApiKey)
    {
        // import information from Asana into jademgr db

        var asana = new Asana(ApiKey, AuthenticationType.Basic, errorCallback);

        ArrayList names = new ArrayList();

        asana.GetMe(o =>
        {
            var user = o as AsanaUser;
            names.Add(user);
        });

        return View(); 
    }

    private void errorCallback(string arg1, string arg2, string arg3)
    {
        throw new NotImplementedException();
    }
}

The code never goes into the error callback and I'm not sure how to debug. Thanks.

Sample Project

Hi,

First of all, thanks for putting this together! I was searching GitHub to see if someone had beat me to it.

Would you mind adding the sample project to the solution that is referenced in the solution? It would help me get up to speed a bit quicker.

Thanks again,

Chris

Creating tasks -- missing required field: workspace

Hey thanks for this -- I'm trying to implement it inside Unity, which required a couple edits to get it working with their version of .net (string.IsNullOrWhiteSpace and enum.HasFlag weren't available) but I seem to have it working for the most part. One thing I can't yet do is create a task.

What I'm attempting:

AsanaTask newTask1 = new AsanaTask(workspace);
newTask1.Name = "TASK_NAME_FROM_UNITY";
newTask1.Notes = "TASK_NOTES_FROM_UNITY";
newTask1.Assignee = me;
newTask1.DueOn = System.DateTime.Now.AddHours(2);
newTask1.Save(asana);

The error callback gives me missing required field: workspace even though I'm creating the AsanaTask with a valid workspace reference. Also, the first thing the error callback spits out (the request?) only has the name and notes

https://app.asana.com/api/1.0/tasks?name=TASK_NAME_FROM_UNITY&notes=TASK_NOTES_FROM_UNITY

But I can't seem to find why it only includes those properties

Duplicate Project function

Hi, I updated the code to support duplicating projects and I'd like to create a pull request to get it into the repo for people.

I assumed I could create a branch and then push it here to generate a pull request. Unfortunately I don't have the permission to push a new branch.

Maybe I'm going about this all wrong, could you please let me know what I need to do to create a pull request for you. Is it just that I need permission or am I being silly and missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.