Skip to content

Commit

Permalink
Refactored tag_device and untag_device methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsliwa committed Jun 20, 2013
1 parent 624d7ea commit bcc201f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/urbanairship.rb
Expand Up @@ -79,13 +79,12 @@ def tags_for_device(device_token)
do_request(:get, "/api/device_tokens/#{device_token}/tags/", :authenticate_with => :master_secret)
end

def tag_device(params, action = :add)
device_tokens = (device_token = params[:device_token]).is_a?(Array) ? device_token : [device_token]
do_request(:post, "/api/tags/#{params[:tag]}", :body => {:device_tokens => {action => device_tokens}}.to_json, :authenticate_with => :master_secret)
def tag_device(params)
do_request(:post, "/api/tags/#{params[:tag]}", :body => {:device_tokens => {:add => [params[:device_token]]}}.to_json, :authenticate_with => :master_secret)
end

def untag_device(params)
tag_device(params, :remove)
do_request(:post, "/api/tags/#{params[:tag]}", :body => {:device_tokens => {:remove => [params[:device_token]]}}.to_json, :authenticate_with => :master_secret)
end

def device_tokens_count
Expand Down

0 comments on commit bcc201f

Please sign in to comment.