Open rmontgomery429 opened 8 years ago
Sorry to hear that you are hitting performance and rate limit issues when you use the API. Unfortunately, the Ruby library has not been updated to reflect the find endpoint and does indeed fetch all the subscribers and filter them on the client side.
A workaround for you would be:
oauth = AWeber::OAuth.new(ENV['AWEBER_KEY'], ENV['AWEBER_SECRET'])
oauth.authorize_with_access('...', '...')
aweber = AWeber::Base.new(oauth)
list = aweber.account.lists.find_by_name("some_list")
if aweber.get(list.subscribers_collection_link() + '?ws.op=find&email=foo@bar.com').empty?
list.subscribers.create({ ... })
end
Please let us know if this works for you.
You can also ignore the check as the subscribers to a list are guaranteed to have distinct emails. You will get back an error response if the subscriber you are trying to add already exists.
@vrajmohan Thank you for your response. Are there any planned updates coming for this gem?
We are integrating with the Aweber API via the gem and we seem to be hitting the API Rate Limit a lot and we're only making calls like the following:
We're getting a lot of very slow queries to Aweber from code like this. I can't see where the loop is but NewRelic is reporting that there are in some cases 30-40 calls made to
/subscribers
here.36 more calls to Net::HTTP[https://api.aweber.com/1.0/accounts/.../lists/.../subscribers]: GET
Each call is also taking 1-2 seconds which is adding up to a very slow API call to get a list by a name and find a subscriber by an email. I hope those aren't looping over the subscribers when all were doing is calling
find_by_email
... right? That's not fetching all subscribers and then filtering in memory is it?I would think
find_by_name
would be a search query to the server using something like the "find" method of the API. https://labs.aweber.com/docs/reference/1.0#subscriber_collection-find