Class: Cascaad::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cascaad.rb

Constant Summary collapse

BASE_URL =
'http://openapi.cascaad.com/1/supertweet'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



21
22
23
# File 'lib/cascaad.rb', line 21

def api_key
  @api_key
end

Instance Method Details

#from(domain) ⇒ Object

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cascaad.rb', line 37

def from(domain)
	raise BadRequest if @command.empty?
	raise UnsupportedDomain unless domain == 'twitter.com'

	begin
		open(api_url_for(domain)) do |response|
			JSON.parse(response.read)
		end
	rescue OpenURI::HTTPError
		raise Cascaad::BadApiKey
	end
end


32
33
34
35
# File 'lib/cascaad.rb', line 32

def related_messages(*ids)
	ids.valid_ids_required
	Client.new(@api_key, "related", ids)
end

#show_messages(*ids) ⇒ Object



27
28
29
30
# File 'lib/cascaad.rb', line 27

def show_messages(*ids)
	ids.valid_ids_required
	Client.new(@api_key, "show", ids)
end