Giter VIP home page Giter VIP logo

harvest.net's Introduction

Harvest.Net

A .Net wrapper for the Harvest API.

Installation

This library is hosted as a nuget package.

To install Harvest.Net, run the following command in the Package Manager Console

PM> Install-Package Harvest.Net

Usage

Create a client object:

HarvestRestClient client = new HarvestRestClient("example", "myusername", "mypassword");

Harvest API end points are converted to PascalCase. So example.harvestapp.com/account/who_am_i becomes

Account myAccount = client.WhoAmI();

harvest.net's People

Contributors

danieldestino avatar devfacto-build avatar hackmp avatar hanskusters avatar hbgwhite avatar igeligel avatar ithielnor avatar jasamples avatar paulirwin avatar speakben avatar versaielle 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

harvest.net's Issues

Creating payments using OAuth2 results in a 500

If you issue a CreatePayment using the following method:

HarvestRestClient _client = new HarvestRestClient(subDomain, email, password);
_client.CreatePayment(invoiceId, invoiceAmount, DateTime.Now);

That will work normally. However, if you do:

HarvestRestClient _client = new HarvestRestClient(subDomain, clientId, clientSecret, clientToken);
_client.CreatePayment(invoiceId, invoiceAmount, DateTime.Now);

That will fail with a 500 response from harvest due to the way that RestSharpFactory.cs constructs the RestClient, more specifically the ParameterType of access_token. Since access_token is set to be GetOrPost, this will result in the whole request being thrown away and the RequestBody will instead just contain access_token=<token>

According to the RestSharp documentation:

If you have GetOrPost parameters as well, they will overwrite the RequestBody โ€“ RestSharp will not combine them but it will instead throw the RequestBody parameter away.

We can test a solution to this this using reflection by setting ParameterType to QueryString:

HarvestRestClient _client = new HarvestRestClient(subDomain, clientId, clientSecret, clientToken);

var cli_field = typeof(HarvestRestClient).GetField("_client", BindingFlags.NonPublic | BindingFlags.Instance);

RestClient _iclient = (RestClient)cli_field.GetValue(_client);
_iclient.DefaultParameters.Where(p => p.Name == "access_token").First().Type = ParameterType.QueryString;

_client.CreatePayment(invoiceId, invoiceAmount, DateTime.Now);

And now it works :)

ListProjectEntries returning null - issue with access_token

I'm getting nulls when calling ListProjectEntries and using OAuth2 authentication. Looks like the issue is the way the URL is constructed when using OAuth2. Using Fiddler, I can see that the call returns a 401 error from Harvest with the following data:

{"error":"invalid_token","error_description":"The access token provided is expired, revoked, malformed or invalid for other reasons."}

The URL that gets generated for the call seems to be incorrect. The access_token parameter adds a second ? to the URL; example below (from Fiddler, edited to remove token):

/projects/removedprojectid/entries?access_token=removedaccesstoken?from=20150801&to=20150831

As you can see, there two ? in the constructed URL. Removing the second question mark and calling manually does work.

.ListProjects() Returning null

I have seen that this exact issue has been closed before, but i'm still getting the issue.

HarvestRestClient hclient= new HarvestRestClient("subdomain", "[email protected]", "password");
var projects= hclient.ListProjects();

The variable projects is null since hclient.ListProjects() returns null.

Invalid 'value' on XML returned from '/projects'

In testing our integration with Harvest.net, we're getting exceptions in the HarvestXmlDeserializer. When I inspect the actual values, I find that the EstimateMethod is being populated with the same value found in BudgetMethod. When BudgetMethod is not 'none', the deserialization is failing.

Execute Exception Handling

For the HarvestRestClient.Execute method, when response.StatusCode == System.Net.HttpStatusCode.BadRequest, I suggest throwing the response.Content which includes Harvest's error message.

Getting Data in Postman, but not in c# Code

Hi
i am developing code for a client to get time logs . when i am tring to get data from the url "https://subdomain.harvestapp.com/projects" , am getting data in post man, but when i the same
HarvestRestClient client = new HarvestRestClient("subdomain", "[email protected]", Password); and client.ListProjects(), am getting null value. am using Harvest.Net nuget package.
i am getting data for ListContacts and ListTasks, Not for ListClients, ListProjects

Please help

Thanks
Arun skaria

AUD/USD Currency on getClients()

Having a few issues with clients who are set to non-USD currencies.
Nothing is returned when the client is set to AUD, but it returns the results fine when clients are set to USD.
Any tips or tricks around this?
Thanks!

Problem with CreateDaily

I'm getting exceptions trying to use CreateDaily. The same parameters sent directly against the API using DHC work fine and return a 201:

Test api support 1 7925148 4218975 5/1/2015 12:00:00 AM

I'm going to download the project and try to debug the issue. If anyone has any insight of workarounds please let me know!

C# 6 support?

I'm working on the async changes from #47 and I'm wondering if it's okay to use C# 6 features, primarily string interpolation and the nameof operator. This would require the project to be built with VS2015.

ListProjects returning null

The ListProjects call is returning a 200 status code, but null data. I've tested on DHC hitting the Harvest API directly and it's returning results.

NuGet package is not signed

Because the .dll in the NuGet package isn't signed, it's a real pain to try and use it when I need signing.

It seems that the only package dependency is RestSharp, and they maintain a signed version of their package with the name RestSharpSigned.

I would love to see this implemented!

Currency Updated

Please Change the Change the CHF Currency to [Description("Swiss Franc - CHF")]CHF then it should work.

User.IsAdmin not working.

Version 0.9 parameter was named "Admin" and pulled the correct bool.
Version 0.10 now named "IsAdmin" and is now broken, pulls false on an admin account.

DayEntry Properties Should be Int64

The UserId, ProjectId, and TaskId properties on DayEntry are int but the corresponding Id properties on the User, Project, and Task types are long. These properties on DayEntry should be changed to long accordingly.

Weekly Capacity not returned by ListUsers

User model doesn't have a property to read the WeeklyCapacity. Please let us know if this is part of another object. Thanks

See below json we got from harvest /people API call:
"user": {
"id": 885498,
"email": "[email protected]",
"created_at": "2014-12-12T16:18:54Z",
"is_admin": false,
"first_name": "test",
"last_name": "test",
"timezone": "Kyiv",
"is_contractor": false,
"telephone": "",
"is_active": true,
"has_access_to_all_future_projects": false,
"default_hourly_rate": 0,
"department": "(Ukraine) QA",
"wants_newsletter": false,
"updated_at": "2017-02-06T11:20:32Z",
"cost_rate": null,
"weekly_capacity": 144000
}

Case Sensitive Values

budget-by value, "Person" returned an error from Harvest, but "person" (lowercase) did not. I suggest converting the BudgetMethod enum to lowercase.

DayEntry Started At and Ended At

Seems DayEntry.StartedAt en EndedAt output DateTime.Now as the Date part of the DateTime instead of the actual Date the entry was tracked?

.ListExpenses() returning empty list

When I run the following code:

HarvestRestClient hclient= new HarvestRestClient("subdomain", "[email protected]", "password");
var expenses = hclient.ListExpenses();

The expenses variable contains an empty list, however there are expense records when checked on the website. When looking at the Harvest API official documentation there is no way to view all expenses, thus I just want to ask if there is a way to do this through the wrapper.

ListProjects() is returning NULL

The xml is getting returned properly from the API, however, the T Execute method in HarvestRestClient.cs is not returning any data for projects. Is there something off with the serialization?

Async Support

It would be great to have Async versions of all API methods that return Task/Task<T> to support async and await. RestSharp already supports this so it wouldn't be much work. Would likely involve a little refactoring so that the Async methods aren't full duplicates of the synchronous methods.

I'd be happy to work on this, as I have done this for other projects.

Throw a HarvestException for any 4xx or 5xx HTTP status code

Currently the HarvestRestClient only throws a HarvestException if the status code is 400 Bad Request. In the event of a different error status code, such as 503 if you've been rate limited or perhaps an unexpected 500 server error, the method just returns null and doesn't let the calling code know about the reason for the failure.

I'm submitting a PR for this shortly.

ListClients is returning null

Hi,

When I call client.ListClients() it is always returning a null value.
I have fiddler running and when the method is executed it is sending the request and responding with a list of clients in xml format.

client.ListProjects works fine. It returns a populated list of Projects. In Fiddler the request headers look exactly the same and both are returning xml.

Any ideas?

Thanks!

Currency field in Invoice

I'm trying to import invoices from harvest but response from Api have Currency field null for GBP , INR may be for others also.

Make currency deserialization more robust

Harvest seems to change the descriptive text on the currency enumeration pretty frequently. We need to make this more robust, perhaps by splitting the description into parts and deserializing based only on the acronym.

Reduce unnecessary network traffic by only fetching results upon request

Currently we automatically load resources from the Location header on PUT and POST responses. I'm thinking this is a waste, when we usually only need the ID of the new object.

As part of 2.0 I think it should only make one request and return the details of the Location header instead of requesting it.

.net core support

Are you planning to support .net core?
I know restsharp does not have .net core support yet.

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.