Class: TwitPic::Client
- Inherits:
-
Object
- Object
- TwitPic::Client
- Defined in:
- lib/twitpic/client.rb,
lib/twitpic/api/tags.rb,
lib/twitpic/api/faces.rb,
lib/twitpic/api/media.rb,
lib/twitpic/api/users.rb,
lib/twitpic/api/events.rb,
lib/twitpic/api/places.rb,
lib/twitpic/api/upload.rb,
lib/twitpic/api/comments.rb
Overview
Added by Clipflakes
Constant Summary collapse
- @@TAGS_API =
{ :show => { :endpoint => 'tags/show', :method => :get, :required => [:tag] }, :create => { :endpoint => 'tags/create', :method => :post, :required => [:media_id, :tags] }, :delete => { :endpoint => 'tags/delete', :method => :post, :required => [:media_id, :tag_id] } }
- @@FACES_API =
{ :show => { :endpoint => 'faces/show', :method => :post, :required => [:user] }, :create => { :endpoint => 'faces/create', :method => :post, :required => [:media_id, :top_coord, :left_coord] }, :edit => { :endpoint => 'faces/edit', :method => :post, :required => [:tag_id] }, :delete => { :endpoint => 'faces/delete', :method => :post, :required => [:tag_id] } }
- @@MEDIA_API =
{ :show => { :endpoint => 'media/show', :method => :get, :required => [:id] } }
- @@USERS_API =
{ :show => { :endpoint => 'users/show', :method => :get, :required => [:username] } }
- @@EVENTS_API =
{ :show => { :endpoint => 'events/show', :method => :get, :required => [:user] } }
- @@EVENT_API =
{ :show => { :endpoint => 'event/show', :method => :get, :required => [:id] }, :create => { :endpoint => 'event/create', :method => :post, :required => [:name] }, :delete => { :endpoint => 'event/delete', :method => :post, :required => [:event_id] }, :add => { :endpoint => 'event/add', :method => :post, :required => [:media_id, :event_id] }, :remove => { :endpoint => 'event/add', :mehtod => :post, :required => [:event_id, :media_id] } }
- @@PLACE_API =
{ :show => { :endpoint => 'place/show', :method => :get, :required => [:id] } }
- @@PLACES_API =
{ :show => { :endpoint => 'places/show', :method => :get, :required => [:user] } }
- @@COMMENTS_API =
{ :show => { :endpoint => 'comments/show', :method => :get, :required => [:media_id, :page] }, :create => { :endpoint => 'comments/create', :method => :post, :required => [:media_id, :message] }, :delete => { :endpoint => 'comments/delete', :method => :post, :required => [:comment_id] } }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#write_enabled ⇒ Object
readonly
Determines whether all of the required information has been entered into the config so we know if we can make a write-enabled call or not.
Instance Method Summary collapse
- #comments(action, args) ⇒ Object
-
#configure {|@config| ... } ⇒ Object
Lets you change configuration options.
- #event(action, args) ⇒ Object
- #events(action, args) ⇒ Object
- #faces(action, args) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #media(action, args) ⇒ Object
- #place(action, args) ⇒ Object
- #places(action, args) ⇒ Object
- #tags(action, args) ⇒ Object
-
#upload(file, message) ⇒ Object
Uploads a photo to TwitPic.
- #upload_and_post(file, message) ⇒ Object
- #users(action, args) ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/twitpic/client.rb', line 6 def config @config end |
#write_enabled ⇒ Object (readonly)
Determines whether all of the required information has been entered into the config so we know if we can make a write-enabled call or not. Is this too ghetto/unsafe?
21 22 23 |
# File 'lib/twitpic/client.rb', line 21 def write_enabled @write_enabled end |
Instance Method Details
#comments(action, args) ⇒ Object
22 23 24 25 |
# File 'lib/twitpic/api/comments.rb', line 22 def comments(action, args) raise ArgumentError, "Invalid API action given" unless @@COMMENTS_API.keys.member?(action) TwitPic::API.query(self, @@COMMENTS_API[action], args) end |
#configure {|@config| ... } ⇒ Object
Lets you change configuration options
13 14 15 16 17 |
# File 'lib/twitpic/client.rb', line 13 def configure(&block) raise ArgumentError, "Block required in order to configure" unless block_given? yield @config end |
#event(action, args) ⇒ Object
47 48 49 50 |
# File 'lib/twitpic/api/events.rb', line 47 def event(action, args) raise ArgumentError, "Invalid API action given" unless @@EVENT_API.keys.member?(action) TwitPic::API.query(self, @@EVENT_API[action], args) end |
#events(action, args) ⇒ Object
42 43 44 45 |
# File 'lib/twitpic/api/events.rb', line 42 def events(action, args) raise ArgumentError, "Invalid API action given" unless @@EVENTS_API.keys.member?(action) TwitPic::API.query(self, @@EVENTS_API[action], args) end |
#faces(action, args) ⇒ Object
28 29 30 31 |
# File 'lib/twitpic/api/faces.rb', line 28 def faces(action, args) raise ArgumentError, "Invalid API action given" unless @@FACES_API.keys.member?(action) TwitPic::API.query(self, @@FACES_API[action], args) end |
#media(action, args) ⇒ Object
12 13 14 15 |
# File 'lib/twitpic/api/media.rb', line 12 def media(action, args) raise ArgumentError, "Invalid API action given" unless @@MEDIA_API.keys.member?(action) TwitPic::API.query(self, @@MEDIA_API[action], args) end |
#place(action, args) ⇒ Object
18 19 20 21 |
# File 'lib/twitpic/api/places.rb', line 18 def place(action, args) raise ArgumentError, "Invalid API action given" unless @@PLACE_API.keys.member?(action) TwitPic::API.query(self, @@PLACE_API[action], args) end |
#places(action, args) ⇒ Object
23 24 25 26 |
# File 'lib/twitpic/api/places.rb', line 23 def places(action, args) raise ArgumentError, "Invalid API action given" unless @@PLACES_API.keys.member?(action) TwitPic::API.query(self, @@PLACES_API[action], args) end |
#tags(action, args) ⇒ Object
22 23 24 25 |
# File 'lib/twitpic/api/tags.rb', line 22 def (action, args) raise ArgumentError, "Invalid API action given" unless @@TAGS_API.keys.member?(action) TwitPic::API.query(self, @@TAGS_API[action], args) end |
#upload(file, message) ⇒ Object
Uploads a photo to TwitPic
4 5 6 7 8 |
# File 'lib/twitpic/api/upload.rb', line 4 def upload(file, ) = "" unless .strip.length > 0 TwitPic::API.upload(self, file, {:message => }) end |