lib/urbanairship.rb in urbanairship-ruby-1.0.0 vs lib/urbanairship.rb in urbanairship-ruby-1.0.1

- old
+ new

@@ -16,11 +16,11 @@ module ClassMethods attr_accessor :application_key, :application_secret, :master_secret, :logger, :request_timeout, :provider VERSION = 3 def register_device(device_token, options = {}) - body = parse_register_options(options).to_json + body = JSON.dump(parse_register_options(options)) path = device_tokens_end_point(options[:provider] || @provider) do_request(:put, "/api/#{path}/#{device_token}", :body => body, :authenticate_with => :application_secret) end @@ -34,32 +34,32 @@ do_request(:get, "/api/#{path}/#{device_token}", :authenticate_with => :application_secret) end # Schedules API def create_schedule(schedule) - do_request(:post, "/api/schedules/", :body => schedule.to_json, :authenticate_with => :master_secret) + do_request(:post, "/api/schedules/", :body => JSON.dump(schedule), :authenticate_with => :master_secret) end def schedules - do_request(:get, "/api/schedules/", :authenticate_with => :master_secret) + quest(:get, "/api/schedules/", :authenticate_with => :master_secret) end def schedule(id) do_request(:get, "/api/schedules/#{id}", :authenticate_with => :master_secret) end def update_schedule(id, schedule) - do_request(:put, "/api/schedules/#{id}", :body => schedule.to_json, :authenticate_with => :master_secret) + do_request(:put, "/api/schedules/#{id}", :body => JSON.dump(schedule), :authenticate_with => :master_secret) end def delete_schedule(id) do_request(:delete, "/api/schedules/#{id}", :authenticate_with => :master_secret) end # Push API def push(options = {}) - body = parse_push_options(options.dup).to_json + body = JSON.dump(parse_push_options(options.dup)) do_request(:post, "/api/push/", :body => body, :authenticate_with => :master_secret) end # Tags API def tags @@ -74,16 +74,18 @@ do_request(:delete, "/api/tags/#{tag}", :authenticate_with => :master_secret) end def tag_device(params) provider_field = device_tokens_end_point(params[:provider] || @provider).to_sym - do_request(:post, "/api/tags/#{params[:tag]}", :body => {provider_field => {:add => [params[:device_token]]}}.to_json, :authenticate_with => :master_secret) + body = JSON.dump({provider_field => {:add => [params[:device_token]]}}) + do_request(:post, "/api/tags/#{params[:tag]}", :body => body, :authenticate_with => :master_secret) end def untag_device(params) provider_field = device_tokens_end_point(params[:provider] || @provider).to_sym - do_request(:post, "/api/tags/#{params[:tag]}", :body => {provider_field => {:remove => [params[:device_token]]}}.to_json, :authenticate_with => :master_secret) + body = JSON.dump({provider_field => {:remove => [params[:device_token]]}}) + do_request(:post, "/api/tags/#{params[:tag]}", :body => body, :authenticate_with => :master_secret) end # Device Tokens API def tags_for_device(device_token) do_request(:get, "/api/device_tokens/#{device_token}/tags/", :authenticate_with => :master_secret) @@ -105,18 +107,18 @@ def segments do_request(:get, "/api/segments", :authenticate_with => :master_secret) end def create_segment(segment) - do_request(:post, "/api/segments", :body => segment.to_json, :authenticate_with => :master_secret) + do_request(:post, "/api/segments", :body => JSON.dump(segment), :authenticate_with => :master_secret) end def segment(id) do_request(:get, "/api/segments/#{id}", :authenticate_with => :master_secret) end def update_segment(id, segment) - do_request(:put, "/api/segments/#{id}", :body => segment.to_json, :authenticate_with => :master_secret) + do_request(:put, "/api/segments/#{id}", :body => JSON.dump(segment), :authenticate_with => :master_secret) end def delete_segment(id) do_request(:delete, "/api/segments/#{id}", :authenticate_with => :master_secret) end