Class: Tightknit::Resources::Feeds

Inherits:
Object
  • Object
show all
Defined in:
lib/tightknit/resources/feeds.rb

Overview

The Feeds class provides methods for interacting with the feeds API. It allows listing feeds and retrieving posts from feeds.

Examples:

List feeds

client = Tightknit.client
feeds = client.feeds.list

Get a specific feed

client = Tightknit.client
feed = client.feeds.get("feed_id")

Get posts from a feed

client = Tightknit.client
posts = client.feeds.posts("feed_id")

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Feeds

Initialize a new Feeds resource

Parameters:



25
26
27
# File 'lib/tightknit/resources/feeds.rb', line 25

def initialize(client)
  @client = client
end

Instance Method Details

#get(feed_id) ⇒ Hash

Get a specific feed

Parameters:

  • feed_id (String)

    The ID of the feed to retrieve

Returns:

  • (Hash)

    Response containing feed data

Raises:



52
53
54
# File 'lib/tightknit/resources/feeds.rb', line 52

def get(feed_id)
  @client.get("feeds/#{feed_id}")
end

#list(options = {}) ⇒ Hash

Get a list of feeds in the community

Parameters:

  • options (Hash) (defaults to: {})

    Options for pagination

Options Hash (options):

  • :page (Integer) — default: 0

    Page number

  • :per_page (Integer) — default: 10

    Number of records per page

Returns:

  • (Hash)

    Response containing feeds data



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tightknit/resources/feeds.rb', line 35

def list(options = {})
  page = options[:page] || 0
  per_page = options[:per_page] || 10

  params = {
    page: page,
    per_page: per_page
  }

  @client.get("feeds", params)
end

#posts(feed_id, options = {}) ⇒ Hash

Get posts from a specific feed

Parameters:

  • feed_id (String)

    The ID of the feed to retrieve posts from

  • options (Hash) (defaults to: {})

    Options for pagination

Options Hash (options):

  • :page (Integer) — default: 0

    Page number

  • :per_page (Integer) — default: 10

    Number of records per page

Returns:

  • (Hash)

    Response containing posts data

Raises:



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/tightknit/resources/feeds.rb', line 64

def posts(feed_id, options = {})
  page = options[:page] || 0
  per_page = options[:per_page] || 10

  params = {
    page: page,
    per_page: per_page
  }

  @client.get("feeds/#{feed_id}/posts", params)
end