aweber / AWeber-API-Ruby-Library

DEPRECATED - Ruby interface to AWeber's API.
http://www.aweber.com
BSD 3-Clause "New" or "Revised" License
25 stars 18 forks source link

Added tags support #47

Open xkraty opened 6 years ago

xkraty commented 6 years ago

Aweber added support for tagging subscribers

masha256 commented 6 years ago

Is this feature working for you? I am trying to use it to edit tags of an existing subscriber and I always get back:

"{"error": {"status": 400, "documentation_url": "https://labs.aweber.com/docs/troubleshooting#badrequest", "message": "tags: You tried to modify a nonexistent attribute. https://labs.aweber.com/docs/troubleshooting#badrequest", "type": "BadRequestError"}}"

I am setting the tags using the 'add' and 'remove' keys of the tags attribute, as their documentation says, such as:

subscriber.tags={'add' => ['tag1','tag2']}
subscriber.save

But I get the error.

xkraty commented 6 years ago

Yeah it do work, I'm using the list collection link to patch the subscriber

url = @aweber.account.lists.find_by_id(list_id).subscribers_collection_link() + "/#{user["id"]}"
consumer = OAuth::Consumer.new(AWEBER_APP_USER, AWEBER_APP_PASSWORD, site: AWeber.auth_endpoint)
access_token = OAuth::AccessToken.new(consumer, Setting.get(AWEBER_ACCESS_TOKEN), Setting.get(AWEBER_ACCESS_SECRET))
access_token.patch(url, { tags: { add: tags } }.to_json, {"Content-Type" => "application/json"})