lib/hubspot/company.rb in hubspot-ruby-0.5.0 vs lib/hubspot/company.rb in hubspot-ruby-0.6.0

- old
+ new

@@ -38,9 +38,36 @@ response = Hubspot::Connection.get_json(path, opts) response['results'].map { |c| new(c) } end + # Find all companies by created date (descending) + # 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 [Object], you can get: + # response.results for [Array] + # response.hasMore for [Boolean] + # response.offset for [Integer] + def all_with_offset(opts = {}) + recently_updated = opts.delete(:recently_updated) { false } + + path = if recently_updated + RECENTLY_MODIFIED_COMPANIES_PATH + else + RECENTLY_CREATED_COMPANIES_PATH + end + + response = Hubspot::Connection.get_json(path, opts) + response_with_offset = {} + response_with_offset['results'] = response['results'].map { |c| new(c) } + response_with_offset['hasMore'] = response['hasMore'] + response_with_offset['offset'] = response['offset'] + response_with_offset + end + # Finds a list of companies by domain # {https://developers.hubspot.com/docs/methods/companies/search_companies_by_domain} # @param domain [String] company domain to search by # @param options [Hash] Possible options are: # limit [Integer] for pagination