Module: Kippt::ReadCollectionResource

Includes:
Helpers
Included in:
ClipLikes, CollectionResource, Followers, Following, UserLikes, Users
Defined in:
lib/kippt/read_collection_resource.rb

Instance Method Summary collapse

Instance Method Details

#[](resource_id, options = {}) ⇒ Object Also known as: find

For certain objects you can get extra data by giving option ‘include_data`. For example with clips you can add `include_data: “list,via”`.



16
17
18
19
20
21
22
23
# File 'lib/kippt/read_collection_resource.rb', line 16

def [](resource_id, options = {})
  response = client.get("#{base_uri}/#{resource_id}", options)
  if response.success?
    object_class.new(response.body, client)
  else
    raise Kippt::APIError.new("Resource could not be loaded: #{response.body["message"]}")
  end
end

#collection_from_url(url) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
# File 'lib/kippt/read_collection_resource.rb', line 27

def collection_from_url(url)
  raise ArgumentError.new("The parameter URL can't be blank") if url.nil? || url == ""

  collection_class.new(client.get(url).body, client)
end

#fetch(options = {}) ⇒ Object Also known as: all

For certain objects you can get extra data by giving option ‘include_data`. For example with clips you can add `include_data: “list,via”`.



6
7
8
9
10
# File 'lib/kippt/read_collection_resource.rb', line 6

def fetch(options = {})
  validate_collection_options(options)

  collection_class.new(client.get(base_uri, options).body, client)
end