Class: Vinery::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/vinery/api.rb

Overview

Public: The unofficial interface for the Vine API. Vine requires all requests to be authenticated when accessing the API.

Examples

vinery = Vinery::API.new("username", "password")
funny_vines = vinery.tagged("funny")

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ API

Public: Initializes a new Vine API instance.

username - The String Vine username. password - The String Vine password.

Examples

vinery = Vinery::API.new("username", "password")

Returns the new Vine instance.



26
27
28
# File 'lib/vinery/api.rb', line 26

def initialize(username, password)
  (username, password)
end

Instance Method Details

#tagged(tag, query = {}) ⇒ Object

Public: fetches a list of Vines that are tagged with a certain tag.

tag - The String tag to search for. query - The Hash options used to refine the selection (default: {}).

:page - The Integer page number to paginate results (default: 1).
:size - The Integer number of results to display (default: 20).

Examples

vinery.tagged("funny")

vinery.tagged("funny", { page: 2, size: 10 })

Returns a Hash of Vines.



44
45
46
47
48
49
50
51
# File 'lib/vinery/api.rb', line 44

def tagged(tag, query = {})
  query = {
    page: 1,
    size: 20 
  }.merge!(query)

  Collection.new(get_parsed("/timelines/tags/#{tag}", query)["records"].map { |r| Record.new(r) })
end