appnetkit
appnetkit copied to clipboard
Support for new APIs
App.net has released three new API's Messaging, File Storing and now Places. Would love to see these added in here.
I'm currently busy with other projects and don't really have an opportunity to write these myself, but I'd be happy to review pull requests for any of these features.
I just skimmed the documentation for each of these APIs, and here's what I think would be needed:
Messaging API
- Create ANChannel and ANMessage classes as subclasses of ANIdentifiedResource.
- Create ANDraftMessage and possibly ANDraftChannel classes as subclasses of NSObject.
- Add constants for the
public_messages
andmessages
scopes. - Create completion methods for one channel, many channels, one message, and a list of messages (see e.g.
-[ANSession completeUserRequest:withResponse:representation:error:]
to see what I'm talking about). - Write twentyish ANAuthenticatedRequest subclasses to cover the endpoints in the Messaging API.
- Write a few convenience methods for ANSession+Requests.[hm].
While you'd have to learn some things about how AppNetKit works, all of these tasks are similar to code that's already in AppNetKit for the Posts API. Reading analogous methods and classes in the AppNetKit posts API should teach you what to do to create these new classes and methods.
Places API
- Create an ANPlace class.
- At first glance, this looks like an ANIdentifiedResource, but it uses a UUID-based
factual_id
instead of an ID number. You might need to extract a superclass from ANIdentifiedResource that would separate the precise representation of the ID from the concept of a resource with an identifier, and then modify _ANIdentifiedResourceSet to treat the ID as this abstract concept instead of a concrete 64-bit integer. - You might be tempted to use NSUUID to represent the
factual_id
, but this class is only available in iOS 6 and OS X 10.8, so you should probably use a plain NSString.
- At first glance, this looks like an ANIdentifiedResource, but it uses a UUID-based
- Create completion methods for one place and many places.
- Write a couple ANAuthenticatedRequest subclasses for the endpoints in the Places API.
- Write a couple convenience methods for ANSession+Requests.[hm].
- You'd probably want to create some kind of convenience methods on ANDraft to attach a place to your draft. (This would simply create one of the "annotation replacement values" described in the place API docs from a provided ANPlace object.)
Other than the superclass issue, this would all be pretty straightforward.
Files API
- Create an ANFile class as a subclass of ANIdentifiedResource.
- Left to its own devices, the accessor for the
mime_type
would bemimeType
, but it should probably beMIMEType
. You would probably want to add a transformation in ANResource+Magic.m'sANKeyForGetterSelector()
to correct for this; there are already a few similar ones there. - It might be nice to add an accessor to get the MIME type using an Apple-friendly UTI. The relevant calls are in MobileCoreServices.framework and have the
UT
prefix.
- Left to its own devices, the accessor for the
- Create an ANDraftFile class as a subclass of NSObject.
- Likewise with the UTI thing.
- Create completion methods for one file and many files.
- Write about eight ANAuthenticatedRequest subclasses to cover the endpoints in the Files API.
- There currently isn't any support for multipart form data in AppNetKit; without that support, you can't create a file and upload its content in one operation. You could either create and upload a file in two requests, or you could implement this support, possibly by subclassing ANAuthenticatedRequest.
- Write a few convenience methods for ANSession+Requests.[hm].
- You'd probably want to create some kind of convenience methods on ANDraft to attach an uploaded file to your draft.
There are some complications here, but this could probably be done by a good programmer.
Note that it looks like @hezi is actually working on a fork with support for the Files API. You might want to coordinate with him rather than duplicating effort.
I Have a lot of what you described in the Files API section already written, just needs some refactoring. I'll probably have it complete by next week.
Maybe this issue should be split to 3 (Files, Places, Messaging) and be assigned to interested developer. I'll take Files as I've already started, but will probably get around to implement messaging.
I've just started working with the AppNetKit and still figuring out how it all works. Once I figure it out, I'll start working on implementing wither the Messages or Places API.
Hezi: Any chance when you've finished implementing the Files API you would submit it as a pull request? :)
Cheers
Any word on the messaging API? I'm planning on building a Mac OSX app sooner or later, and will probably write one and submit the PR if none exists yet.
@SirSkidmore Looking around GitHub, I see that @PhantomSunCreative's fork seems to have a couple tiny steps in this direction, but he's reusing ANPost instead of creating the new classes that would really be needed to do it properly. Unless someone has a branch they haven't pushed up yet, you're probably going to have to do it yourself. Sorry!