Yortw / tweetmoasharp

TweetSharp is a fast, clean wrapper around the Twitter API.
Other
72 stars 22 forks source link

Access to other Twitter APIs - e.g. Ads API #44

Open AdrianPell opened 8 years ago

AdrianPell commented 8 years ago

I'm working on access to the Twitter Ads API - which lives on a different endpoint (https://ads-api.twitter.com). Unless I'm totally mistaken, that doesn't seem to fit into the current model where the endpoint is in Globals.

Do you have any suggestions on how to go about this and would you be interested in a PR for this when I'm done?

Great job on keeping this alive :-)

Yortw commented 8 years ago

Pull requests are always welcome :) (Especially as my time for this project is even more limited at the moment than it has been in the past).

As far as the Ad API goes, I'm not sure if perhaps it shouldn't be in a different class to the regular TwitterService? Happy to have support in the same library (and I admit I'm not familiar with the Ad API) but it seems like it would probably have a slightly different developer audience than for the 'regular' functions? If it was a different service entirely (and presumably a different T4 template to generate it) then that might allow some of the legacy decisions to be dropped and avoid issues like the global endpoint.

Otherwise, as for the endpoint issue, yes, it's a bit of a mess. The original TweetSharp was designed like this as I haven't had the time or effort to put into fixing it. For the new media upload API's that required a different authority I modified the template so it was possibly to specify the authority on the front of each API call definition. In theory (I haven't looked at an actual implementation myself) you could use that for the Ad endpoints too.

AdrianPell commented 8 years ago

I did do some experiments in adding a TwitterAdService as a subclass of TwitterService. That works, but it's a bit of a mess and the subclass still has all the regular TwitterService methods in as well, which isn't quite what I want. So ...

I'm going to experiment with pulling a base class out of TwitterService that will let me (or anybody else for that matter) add other services in a fairly isolated manner. This might work for the media upload endpoint as well, I suppose.

Yortw commented 8 years ago

Sounds like a good plan. If it ends up being too hard perhaps we can mix them in the same class, but for now I think the separation is a good idea if we can have it. Thanks for your efforts.

AdrianPell commented 5 years ago

... and now about 2.5 years later ... I'm back and looking at this :-) Hoping to have a PR here shortly.