Sha256: e7f9b321f186a0c868f940b1406fa014bcde77c98b5361d0adbc188dc140c060

Contents?: true

Size: 979 Bytes

Versions: 25

Compression:

Stored size: 979 Bytes

Contents

module Hubspot
  #
  # HubSpot Topics API
  #
  class Topic
    TOPICS_PATH = "/blogs/v3/topics"
    TOPIC_PATH = "/blogs/v3/topics/:topic_id"

    class << self
      # Lists the topics
      # {https://developers.hubspot.com/docs/methods/blogv2/get_topics)
      # @return [Hubspot::Topic] array of topics
      def list
        response = Hubspot::Connection.get_json(TOPICS_PATH, {})
        response['objects'].map { |t| new(t) }
      end

      # Finds the details for a specific topic_id
      # {https://developers.hubspot.com/docs/methods/blogv2/get_topics_topic_id }
      # @return Hubspot::Topic
      def find_by_topic_id(id)
        response = Hubspot::Connection.get_json(TOPIC_PATH, { topic_id: id })
        new(response)
      end
    end

    attr_reader :properties

    def initialize(response_hash)
      @properties = response_hash #no need to parse anything, we have properties
    end

    def [](property)
      @properties[property]
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
hubspot-api-ruby-0.19.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.18.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.17.1 lib/hubspot/topic.rb
hubspot-api-ruby-0.17.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.16.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.15.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.14.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.13.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.12.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.11.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.10.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.9.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.8.1 lib/hubspot/topic.rb
hubspot-ruby-0.9.0 lib/hubspot/topic.rb
hubspot-api-ruby-0.8.0 lib/hubspot/topic.rb
hubspot-ruby-0.8.1 lib/hubspot/topic.rb
hubspot-ruby-0.8.0 lib/hubspot/topic.rb
hubspot-ruby-0.7.0 lib/hubspot/topic.rb
hubspot-ruby-0.6.1 lib/hubspot/topic.rb
hubspot-ruby-0.6.0 lib/hubspot/topic.rb