Sha256: e85ab39c13452f4d57212a9baa8d782aca802c8e50e74ec1cc86aa40e987b677

Contents?: true

Size: 618 Bytes

Versions: 11

Compression:

Stored size: 618 Bytes

Contents

module AppleNews
  class Section
    include Resource
    include Links

    attr_reader :id, :type, :name, :is_default, :links, :created_at, :modified_at, :share_url

    def initialize(id, data = nil)
      @id = id
      @resource_path = "/sections"

      data.nil? ? hydrate! : set_read_only_properties(data)
    end

    def channel
      Channel.new(channel_link_id('channel'))
    end

    def articles(params = {})
      request = Request::Get.new("/sections/#{id}/articles")
      resp = request.call(params)
      resp['data'].map do |article|
        Article.new(article['id'])
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
apple-news-0.4.2 lib/apple-news/section.rb
apple-news-0.4.1 lib/apple-news/section.rb
apple-news-0.4.0 lib/apple-news/section.rb
apple-news-0.3.1 lib/apple-news/section.rb
apple-news-0.3.0 lib/apple-news/section.rb
apple-news-0.2.5 lib/apple-news/section.rb
apple-news-0.2.4 lib/apple-news/section.rb
apple-news-0.2.3 lib/apple-news/section.rb
apple-news-0.2.2 lib/apple-news/section.rb
apple-news-0.2.1 lib/apple-news/section.rb
apple-news-0.2.0 lib/apple-news/section.rb