Added support for Twitter Ads API #403
No reviewers
Labels
No labels
Bug
Enhancement
Feature Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: code/twython#403
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "nouvak/master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello!!
I added a subset of the Twitter Ads API (https://dev.twitter.com/ads/overview) to Twython.
The most commonly used functions for managing campaigns and creatives, as well as one function for the retrieval of statistics were added.
I also implemented the integration tests which I used to make sure the API works properly.
If you think patch provides an added value to Twython, I would be happy if you included it to the main branch. I tried to follow the coding style as much as possible, however if there are some issues in the code, please let me know.
Note: There is some duplication of the code in api.py and api_ads.py: for the first part, I didn't want to mess with the "api.py" stuff, so I simply created a copy of the file and adapted it to the Twitter Ads API. With minimal rewrite, those files could be merged together. This could be done later.
The code looks fine, but as you said, the ad stuff was split off into different files -- I'd rather just have the merge of the files done in this branch before merging upstream.
Is there any difference in
TwythonAdsandTwythonor did you just copy the file?You can just use the
Twythonobject fromapi.pyand delete theapi_ads.pyif so.Also, you can move all the endpoint methods from
endpoints_ads.pytoendpoints.py.Something like this:
Changing these, you might have to change some of the tests (even though they'll be skipped)
Last note, normally, I would question why the tests were written in the old form (against the real api, we moved to using
responsesand using fake API requests), but I'll accept them since they will be useful when transitioning the tests at a later date.Again, everything looks pretty solid. Just asking to merge, delete those files and rearrange code from the files mentioned :)
Hi Michael!
Sorry for a quite late response, I had some other stuff to do and didn't have time to look into this.
As suggested, I merged the "api_ads.py" file into the "api.py" file. That file wasn't just a copy-paste of the "api.py" file, but contained some changes that had to be done in order to be able to communicate with Twitter Ads API. Could you please revise the the changes I did to "api.py" and let me know if they are ok to you?
Also, I decided to keep the "endpoints_ads.py" and "endpoints.py" files separate in order to keep the functions of Twitter Ads API and Twitter API separate. If you still think I should merge them, please let me know and I'll do that. :)
Regarding the tests, I used the integration testing during the implementation of Twitter Ads API, and unfortunately didn't have time to add unit tests as well. Hope this isn't too big of a problem...
Sorry, I've been super busy. Still wanting to get this merged!
endpoints.pybut as a separate class (so, still as a MixIn)Also, I'm trying to think of a more intuitive way for someone to use the API
Instead of
Maybe extending Twython: https://gist.github.com/michaelhelmick/7cd75a4cfacf795c497d to two separate classes is best? You won't have to do that. If you can just merge the endpoints into one file. I'll merge this. I'll be making some enhancements.
I think we might have a
TwythonCorewhich holds all core stuff, thenTwythonwhich exclusively works with the Twitter REST API and thenTwythonAdsthat exclusively works with the Twitter Ads REST APIOk, I combined the Ads endpoints into the endpoints.py file.
As for the TwythonCore, Twython and TwythonAds idea, I think it definitely makes sense! :)
At first, I also had the functionality split to Twython and TwythonAds classes, but had to remove them
when merging the code. So having the common code in TwythonCore and API-specific functionality in Twython and TwythonAds classes would be perfect. :)
But if I understood you correctly you will do those things, right?
am i need do apply 3 leves ads api application first?
Nice PR. 👍 I also like the idea of TwythonCore and TwythonAds. But we should merge this PR then do another one for that.
Hi @nouvak,
So, I'm starting to tackle this and I was wondering, do you find a use case where a use will need to authenticate with Twitter then use Twitter Ads?
Do you think it would make more sense to keep the auth stuff in
Twythonclass and then have them do Ad stuff withTwythonAds?i.e.
Hi Mike!
Hmm, I'm not sure if I understood your question completely.
Current, we don't have a separate TwythonAds class, because we agreed the Twitter Ads functionality should be added to the Twython class.
Were you planning on creating a separate TwythonAds class?
@nouvak in your previous comment, you said:
In response to my gist.
I was planning on creating separate classes.
Oh I see. I totally forgot about your intention to separate the the Twython and TwythonAd class.
With regards to your question about authentication functionality, I would implement it in a separate class that would then be used by both, Twython and TwythonAd class.
The design I would implement:
This is just a suggestion: you are free to do the implementation the way it makes the most sense to you.
As this is old and out of sync... if anyone wants to tackle getting it up and running be my guest.
Yes
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.