Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository Contents API #649

Merged
merged 23 commits into from
Jan 2, 2015
Merged

Repository Contents API #649

merged 23 commits into from
Jan 2, 2015

Conversation

haacked
Copy link
Contributor

@haacked haacked commented Dec 31, 2014

This incorporates and supersedes #434

I took a slightly different approach. In the interest of keeping close to the API, there's only one method called GetContents that maps to the "Get contents" API. I was able to accomplish this by changing the serializer a bit. When it's trying to deserialize a JSON object into an IEnumerable<T> but the JSON text is clearly a T and not an array, I simply wrap the json text with square brackets turning it into an array of one item and then deserialize it.

The other bit I had to do is when creating content, the text of the content needs to be base64 encoded. Also, when requesting content, the data is base64 encoded. So I changed the serializer to handle this transparently by simply applying the SerializeAsBase64 attribute. So the consumer of the client doesn't have to worry about this.

@@ -80,6 +79,7 @@ public interface IObservableRepositoriesClient
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the property below now is called Content instead of Contents, maybe these should be changed as well? 😄

@haacked
Copy link
Contributor Author

haacked commented Dec 31, 2014

Because we're pre 1.0, I'm inclined to just remove these methods rather than obsolete them.

@haacked
Copy link
Contributor Author

haacked commented Dec 31, 2014

Could someone try this out? I think it's ready to merge. 🍰

@shiftkey shiftkey self-assigned this Dec 31, 2014
@shiftkey
Copy link
Member

I'll have a look at this when I'm back on the grid tomorrow ✌️

/// </summary>
public string Content
{
get { return EncodedContent.FromBase64String(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this guard against null for EncodedContent?

@shiftkey
Copy link
Member

shiftkey commented Jan 2, 2015

Code and tests look pretty great. Just a few nagging questions 🤘

@haacked haacked force-pushed the haacked/repository-contents branch from 0b329f2 to ca1ab1e Compare January 2, 2015 09:15
@haacked haacked force-pushed the haacked/repository-contents branch from ca1ab1e to d769125 Compare January 2, 2015 09:16
@haacked
Copy link
Contributor Author

haacked commented Jan 2, 2015

Something keeps fucking with the whitespace. I suspect it's the documentation rewriter. Anyways, this should be good I hope. I'm up too late again. 😄 so I'm going to sleep and hope the build is green.

📦

shiftkey added a commit that referenced this pull request Jan 2, 2015
@shiftkey shiftkey merged commit d442d97 into master Jan 2, 2015
@shiftkey
Copy link
Member

shiftkey commented Jan 2, 2015

@shiftkey shiftkey deleted the haacked/repository-contents branch January 2, 2015 10:29
This was referenced Mar 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants