lib/pardot/objects/visitors.rb in ruby-pardot-1.3.2 vs lib/pardot/objects/visitors.rb in ruby-pardot-1.4.0

- old
+ new

@@ -1,45 +1,41 @@ module Pardot module Objects module Visitors - def visitors @visitors ||= Visitors.new self end - + class Visitors - - def initialize client + def initialize(client) @client = client end - - def query params - result = get "/do/query", params, "result" - result["total_results"] = result["total_results"].to_i if result["total_results"] + + def query(params) + result = get '/do/query', params, 'result' + result['total_results'] = result['total_results'].to_i if result['total_results'] result end - - def assign id, params = {} + + def assign(id, params = {}) post "/do/assign/id/#{id}", params end - - def read id, params = {} + + def read(id, params = {}) post "/do/read/id/#{id}", params end - + protected - - def get path, params = {}, result = "visitor" - response = @client.get "visitor", path, params + + def get(path, params = {}, result = 'visitor') + response = @client.get 'visitor', path, params result ? response[result] : response end - - def post path, params = {}, result = "visitor" - response = @client.post "visitor", path, params + + def post(path, params = {}, result = 'visitor') + response = @client.post 'visitor', path, params result ? response[result] : response end - end - end end end