Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Company.all to use the newer Hubspot endpoint #76

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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