jhoerr / box-csharp-sdk-v2

A C# client for the Box API (v2).
http://developers.box.com/docs/
11 stars 15 forks source link

Class SharedLink -> Permissions lack of JsonProperty #59

Open tuanv2t opened 10 years ago

tuanv2t commented 10 years ago

A great tool.

But there's a minor error, you should add JsonProperty for Permissions of SharedLink [JsonProperty(PropertyName = "permissions")] public Permissions Permissions { get; set; }

Because if Permissions is not specified json property permissions, then when you do something like this

var client = new RestClient("https://api.box.com/2.0/files/" + fileId); RestRequest request = new RestRequest(Method.PUT); request.RequestFormat = DataFormat.Json; //request.AddHeader("Accept", "application/json"); request.AddHeader("Authorization", "Bearer " + accessToken); request.AddHeader("Content-type", "application/json"); var sharedLinkOption = new SharedLink() { Access = Model.Enum.Access.Open, Permissions = new Permissions() { CanDownload = false, CanPreview = false }, //UnsharedAt = DateTime.Now.AddYears(1) };

        request.AddBody(new { shared_link = sharedLinkOption });
        RestResponse<File> response = (RestResponse<File>)client.Execute<File>(request);
        File result = response.Data;

Although CanDownload = false but the result.Permission,CanDownload is always true because Box API doesn't know about the Permission (in json), so it should be permissions

jhoerr commented 10 years ago

Hi, thanks for opening this issue. I'd be happy to accept a pull request that fixes it.