Skip to content

Commit

Permalink
Updated Hubspot::Company.all to use the new endpoint described at htt…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Bloomquist committed May 25, 2017
1 parent 4751be5 commit 6f51c32
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 230 deletions.
23 changes: 23 additions & 0 deletions lib/hubspot/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Hubspot
# {http://developers.hubspot.com/docs/methods/companies/companies-overview}
#
class Company
ALL_COMPANIES_PATH = "/companies/v2/companies/paged"
CREATE_COMPANY_PATH = "/companies/v2/companies/"
RECENTLY_CREATED_COMPANIES_PATH = "/companies/v2/companies/recent/created"
RECENTLY_MODIFIED_COMPANIES_PATH = "/companies/v2/companies/recent/modified"
Expand All @@ -25,6 +26,28 @@ class << self
# {http://developers.hubspot.com/docs/methods/companies/get_companies_modified}
# @return [Array] Array of Hubspot::Company records
def all(opts={})
# limit = opts.delete(:limit) { 100 }
# offset = opts.delete(:offset) { 0 }
path = ALL_COMPANIES_PATH

response = Hubspot::Connection.get_json(path, opts)

result = {}
result['companies'] = response['companies'].map { |c| new(c) }
result['offset'] = response['offset']
result['has-more'] = response['has-more']
return result
end

# Find recently created or modified companies by created date (descending)
# @param opts [Hash] Possible options are:
# recently_updated [boolean] (for querying all accounts by modified time)
# count [Integer] for pagination
# offset [Integer] for pagination
# {http://developers.hubspot.com/docs/methods/companies/get_companies_created}
# {http://developers.hubspot.com/docs/methods/companies/get_companies_modified}
# @return [Array] Array of Hubspot::Company records
def recent(opts={})
recently_updated = opts.delete(:recently_updated) { false }
# limit = opts.delete(:limit) { 20 }
# skip = opts.delete(:skip) { 0 }
Expand Down
Loading

0 comments on commit 6f51c32

Please sign in to comment.