Class: Hubspot::Base

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
app/models/hubspot/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.collection_path(prefix_options = {}, query_options = nil) ⇒ Object



32
33
34
35
# File 'app/models/hubspot/base.rb', line 32

def collection_path(prefix_options = {}, query_options = nil)
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
  "#{prefix(prefix_options)}list.#{format.extension}#{query_string(query_options)}"
end

.connection(refresh = false) ⇒ Object

Use our own connection class



20
21
22
23
# File 'app/models/hubspot/base.rb', line 20

def connection(refresh = false)
  @connection = Hubspot::Connection.new(site, format) if @connection.nil? || refresh
  return @connection
end

.element_path(id, prefix_options = {}, query_options = nil) ⇒ Object

Set paths ====



27
28
29
30
# File 'app/models/hubspot/base.rb', line 27

def element_path(id, prefix_options = {}, query_options = nil)
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
  "#{prefix(prefix_options)}#{collection_name.singularize}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
end

Instance Method Details

#to_json(options = {}) ⇒ Object

Only serialize the attributes listed in the schema. Leads can contain much more information than can be passed back to Hubspot, therefore we need to ensure they are not serialized on save.



13
14
15
# File 'app/models/hubspot/base.rb', line 13

def to_json(options={})
  super(options.reverse_merge(:root => nil, :only => schema.keys))
end