cloudapp_api 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,73 +18,97 @@ Authentication is necessary for most actions, the only exceptions being when cre
18
18
 
19
19
  CloudApp.authenticate "email@address.com", "password"
20
20
 
21
- ## Item examples
21
+ ## Drops
22
22
 
23
- * Documentation - {CloudApp::Item}
23
+ * Documentation - {CloudApp::Drop}
24
24
 
25
25
  ---
26
26
 
27
- ### Usage via the Item class
28
- # Find a single item by it's slug
29
- item = CloudApp::Item.find "2wr4"
30
-
31
- # Get a list of all items
32
- items = CloudApp::Item.all
33
-
27
+ ### Usage via the Drop class
28
+
29
+ # Find a single drop by it's slug
30
+ @drop = CloudApp::Drop.find "2wr4"
31
+
32
+ # Get a list of all drops
33
+ @drops = CloudApp::Drop.all
34
+
34
35
  # Create a new bookmark
35
- item = CloudApp::Item.create :bookmark, :name => "CloudApp", :redirect_url => "http://getcloudapp.com"
36
-
36
+ @drop = CloudApp::Drop.create :bookmark, :name => "CloudApp", :redirect_url => "http://getcloudapp.com"
37
+
38
+ # Create multiple bookmarks
39
+ bookmarks = [
40
+ { :name => "Authur Dent", :redirect_url => "http://en.wikipedia.org/wiki/Arthur_Dent" },
41
+ { :name => "Zaphod Beeblebrox", :redirect_url => "http://en.wikipedia.org/wiki/Zaphod_Beeblebrox" }
42
+ ]
43
+ @drops = CloudApp::Drop.create :bookmarks, bookmarks
44
+
37
45
  # Upload a file
38
- item = CloudApp::Item.create :upload, :file => "/path/to/image.png"
39
-
46
+ @drop = CloudApp::Drop.create :upload, :file => "/path/to/image.png"
47
+ @drop = CloudApp::Drop.create :upload, :file => "/path/to/image.png", :private => true
48
+
40
49
  # Rename a file
41
- CloudApp::Item.update "http://my.cl.ly/items/1912565", :name => "Big Screenshot"
42
-
43
- # Set an items privacy
44
- CloudApp::Item.update "http://my.cl.ly/items/1912565", :private => true
45
-
46
- # Delete an item
47
- CloudApp::Item.delete "http://my.cl.ly/items/1912565"
48
-
49
- ### Usage via an Item instance
50
+ CloudApp::Drop.update "http://my.cl.ly/items/1912565", :name => "Big Screenshot"
51
+
52
+ # Set a drop's privacy
53
+ CloudApp::Drop.update "http://my.cl.ly/items/1912565", :private => true
54
+
55
+ # Delete a drop
56
+ CloudApp::Drop.delete "http://my.cl.ly/items/1912565"
57
+
58
+ # Recover a deleted drop
59
+ CloudApp::Drop.recover "http://my.cl.ly/items/1912565"
60
+
61
+ ### Usage via the class instance
62
+
50
63
  # Rename a file
51
- @item.update :name => "Big Screenshot"
52
-
53
- # Set an items privacy
54
- @item.update :private => true
55
-
56
- # Delete an item
57
- @tem.delete
64
+ @drop.update :name => "Big Screenshot"
65
+
66
+ # Set the drop's privacy
67
+ @drop.update :private => true
68
+
69
+ # Delete a drop
70
+ @drop.delete
71
+
72
+ # Recover a deleted drop
73
+ @drop.recover
58
74
 
59
- ## Usage via a Client instance
75
+ ## Drops via a Client instance
60
76
 
61
77
  * Documentation - {CloudApp::Client}
62
78
 
63
79
  ---
64
80
 
65
- # Create a Client instance
66
- @client = CloudApp::Client.new
81
+ # Find a single drop by it's slug
82
+ drop = @client.drop "2wr4"
67
83
 
68
- # Find a single item by it's slug
69
- item = @client.item "2wr4"
70
-
71
- # Get a list of all items
72
- items = @client.all
84
+ # Get a list of all drops
85
+ drops = @client.all
73
86
 
74
87
  # Create a new bookmark
75
- item = @client.bookmark "http://getcloudapp.com", "CloudApp"
88
+ drop = @client.bookmark "http://getcloudapp.com", "CloudApp"
89
+
90
+ # Create multiple new bookmarks
91
+ bookmarks = [
92
+ { :name => "Authur Dent", :redirect_url => "http://en.wikipedia.org/wiki/Arthur_Dent" },
93
+ { :name => "Zaphod Beeblebrox", :redirect_url => "http://en.wikipedia.org/wiki/Zaphod_Beeblebrox" }
94
+ ]
95
+ drops = @client.bookmark bookmarks
76
96
 
77
97
  # Upload a file
78
- item = @client.upload "/path/to/image.png"
98
+ drop = @client.upload "/path/to/image.png"
99
+ drop = @client.upload "/path/to/image.png", :private => true
79
100
 
80
101
  # Rename a file
81
102
  @client.rename "2wr4", "Big Screenshot"
82
103
 
83
- # Set an items privacy
104
+ # Set a drop's privacy
84
105
  @client.privacy "2wr4", true
85
106
 
86
- # Delete an item
107
+ # Delete an drop
87
108
  @client.delete "2wr4"
109
+
110
+ # Recover a deleted drop
111
+ @client.recover "2wr4"
88
112
 
89
113
  ## Account examples
90
114
 
@@ -95,12 +119,12 @@ Authentication is necessary for most actions, the only exceptions being when cre
95
119
  # Create a CloudApp account
96
120
  @account = CloudApp::Account.create :email => "arthur@dent.com", :password => "towel"
97
121
 
98
- # Forgot password
99
- CloudApp::Account.reset :email => "arthur@dent.com"
100
-
101
- # View details of authenticated account
122
+ # View account details
102
123
  @account = CloudApp::Account.find
103
124
 
125
+ # Forgot password
126
+ CloudApp::Account.reset :email => "arthur@dent.com"
127
+
104
128
  # Change default security
105
129
  @account.update :private_items => false
106
130
 
@@ -113,6 +137,22 @@ Authentication is necessary for most actions, the only exceptions being when cre
113
137
  # Set custom domain
114
138
  @account.update :domain => "dent.com", :domain_home_page => "http://hhgproject.org"
115
139
 
140
+ # View account stats
141
+ @account.stats
142
+
143
+ ## Gift cards
144
+
145
+ * Documentation - {CloudApp::GiftCard}
146
+
147
+ ---
148
+
149
+ # View gift card details
150
+ @gift = CloudApp::GiftCard.find "ABC123"
151
+
152
+ # Apply the gift card
153
+ CloudApp::GiftCard.redeem "ABC123"
154
+ # or
155
+ @gift.redeem
116
156
 
117
157
  ## Note on Patches/Pull Requests
118
158
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/cloudapp_api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudapp_api}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Russell"]
12
- s.date = %q{2011-01-30}
12
+ s.date = %q{2011-05-01}
13
13
  s.description = %q{A simple Ruby wrapper for the CloudApp API. Uses HTTParty with a simple ActiveResource-like interface.}
14
14
  s.email = %q{aaron@gc4.co.uk}
15
15
  s.extra_rdoc_files = [
@@ -28,41 +28,51 @@ Gem::Specification.new do |s|
28
28
  "lib/cloudapp/account.rb",
29
29
  "lib/cloudapp/base.rb",
30
30
  "lib/cloudapp/client.rb",
31
+ "lib/cloudapp/core_ext.rb",
32
+ "lib/cloudapp/drop.rb",
33
+ "lib/cloudapp/gift_card.rb",
31
34
  "lib/cloudapp/httparty.rb",
32
- "lib/cloudapp/item.rb",
33
35
  "lib/cloudapp/multipart.rb",
34
36
  "lib/cloudapp_api.rb",
35
37
  "spec/cloudapp_account_spec.rb",
36
38
  "spec/cloudapp_api_spec.rb",
37
39
  "spec/cloudapp_client_spec.rb",
40
+ "spec/cloudapp_drop_spec.rb",
41
+ "spec/cloudapp_gift_card_spec.rb",
38
42
  "spec/cloudapp_item_spec.rb",
39
43
  "spec/fakeweb_helper.rb",
40
44
  "spec/spec_helper.rb",
41
45
  "spec/stubs/account/create",
42
46
  "spec/stubs/account/show",
47
+ "spec/stubs/account/stats",
43
48
  "spec/stubs/account/update",
44
- "spec/stubs/item/create",
45
- "spec/stubs/item/delete",
46
- "spec/stubs/item/index",
47
- "spec/stubs/item/new",
48
- "spec/stubs/item/show",
49
- "spec/stubs/item/update"
49
+ "spec/stubs/drop/create",
50
+ "spec/stubs/drop/delete",
51
+ "spec/stubs/drop/index",
52
+ "spec/stubs/drop/new",
53
+ "spec/stubs/drop/new-private",
54
+ "spec/stubs/drop/show",
55
+ "spec/stubs/drop/show-private",
56
+ "spec/stubs/drop/update",
57
+ "spec/stubs/gift_card/redeem",
58
+ "spec/stubs/gift_card/show"
50
59
  ]
51
60
  s.homepage = %q{http://github.com/aaronrussell/cloud_app}
52
61
  s.require_paths = ["lib"]
53
- s.rubygems_version = %q{1.3.7}
62
+ s.rubygems_version = %q{1.7.2}
54
63
  s.summary = %q{A simple Ruby wrapper for the CloudApp API. Uses HTTParty with a simple ActiveResource-like interface.}
55
64
  s.test_files = [
56
65
  "spec/cloudapp_account_spec.rb",
57
66
  "spec/cloudapp_api_spec.rb",
58
67
  "spec/cloudapp_client_spec.rb",
68
+ "spec/cloudapp_drop_spec.rb",
69
+ "spec/cloudapp_gift_card_spec.rb",
59
70
  "spec/cloudapp_item_spec.rb",
60
71
  "spec/fakeweb_helper.rb",
61
72
  "spec/spec_helper.rb"
62
73
  ]
63
74
 
64
75
  if s.respond_to? :specification_version then
65
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
66
76
  s.specification_version = 3
67
77
 
68
78
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -1,6 +1,6 @@
1
1
  module CloudApp
2
2
 
3
- # An ActiveResource-like interface through which to interract with the CloudApp API.
3
+ # An ActiveResource-like interface through which to interract with CloudApp accounts.
4
4
  #
5
5
  # @example Create a CloudApp account
6
6
  # CloudApp::Account.create :email => "arthur@dent.com", :password => "towel"
@@ -26,6 +26,9 @@ module CloudApp
26
26
  #
27
27
  # # Forgot password
28
28
  # CloudApp::Account.reset :email => "arthur@dent.com"
29
+ #
30
+ # # View account stats
31
+ # CloudApp::Account.stats
29
32
  #
30
33
  # @example Usage via the class instance
31
34
  # # Change default security
@@ -42,11 +45,16 @@ module CloudApp
42
45
  #
43
46
  # # Forgot password
44
47
  # @account.reset
48
+ #
49
+ # # View account stats
50
+ # @account.stats
45
51
  #
46
52
  class Account < Base
47
53
 
48
54
  # Get the basic details of the authenticated account.
55
+ #
49
56
  # Requires authentication.
57
+ #
50
58
  # @return [CloudApp::Account]
51
59
  def self.find
52
60
  res = get "/account", :digest_auth => @@auth
@@ -54,9 +62,11 @@ module CloudApp
54
62
  end
55
63
 
56
64
  # Create a CloudApp account.
57
- # @example Provide a user details param
58
- # { :email => "arthur@dent.com", :password => "towel" }
59
- # @param [Hash] of user credentials
65
+ #
66
+ # @param [Hash] opts options parameters
67
+ # @option opts [String] :email Account email address
68
+ # @option opts [String] :password Account password
69
+ # @option opts [Boolean] :accept_tos Accept CloudApp terms of service
60
70
  # @return [CloudApp::Account]
61
71
  def self.create(opts = {})
62
72
  res = post "/register", :body => {:user => opts}
@@ -64,18 +74,20 @@ module CloudApp
64
74
  end
65
75
 
66
76
  # Modify the authenticated accounts details. Can change the default security of newly
67
- # created items, the accounts email address, password, and custom domain details.
68
- # @example Options for changing default security of new items
69
- # { :private_items => false }
70
- # @example Options for changing email address
71
- # { :email => "ford@prefect.com", :current_password => "towel" }
72
- # @example Options for modifying password
73
- # { :password => "happy frood", :current_password => "towel" }
74
- # @example Options for changing custom domain
75
- # { :domain => "dent.com", :domain_home_page => "http://hhgproject.org" }
76
- # Note that to custom domains requires and account with a Pro subscription.
77
- # Requires authentication.
78
- # @param [Hash] account parameters
77
+ # created drops, the accounts email address, password, and custom domain details.
78
+ #
79
+ # Note that when changing email address or password, the current password is required.
80
+ # Also note that to change custom domains requires an account with a Pro subscription.
81
+ #
82
+ # Requires authentication
83
+ #
84
+ # @param [Hash] opts options parameters
85
+ # @option opts [Boolean] :private_items Change default security of new drops
86
+ # @option opts [String] :email Change email address
87
+ # @option opts [String] :password Change password
88
+ # @option opts [String] :current_password Current account password
89
+ # @option opts [String] :domain Set custom domain
90
+ # @option opts [String] :domain_home_page URL to redirect visitors to custom domain's root
79
91
  # @return [CloudApp::Account]
80
92
  def self.update(opts = {})
81
93
  res = put "/account", {:body => {:user => opts}, :digest_auth => @@auth}
@@ -83,20 +95,32 @@ module CloudApp
83
95
  end
84
96
 
85
97
  # Dispatch an email containing a link to reset the account's password.
86
- # @example Requires the account email address in a hash
87
- # { :email => "arthur@dent.com" }
88
- # @param [Hash] account credentials
98
+ #
99
+ # @param [Hash] opts options parameters
100
+ # @option opts [String] :email Account email address
89
101
  # @return [Boolean]
90
102
  def self.reset(opts = {})
91
103
  res = post "/reset", :body => {:user => opts}
92
104
  res.ok? ? true : res
93
105
  end
106
+
107
+ # Get the total number of drops created and total views for all drops.
108
+ #
109
+ # Requires authentication.
110
+ #
111
+ # @return [Hash]
112
+ def self.stats
113
+ res = get "/account/stats", :digest_auth => @@auth
114
+ res.ok? ? res.symbolize_keys! : res
115
+ end
94
116
 
95
117
  attr_reader :id, :email, :domain, :domain_home_page, :private_items,
96
118
  :subscribed, :alpha, :created_at, :updated_at, :activated_at
97
119
 
98
120
  # Create a new CloudApp::Account object.
121
+ #
99
122
  # Only used internally
123
+ #
100
124
  # @param [Hash] attributes
101
125
  # @param [CloudApp::Account]
102
126
  def initialize(attributes = {})
@@ -104,29 +128,39 @@ module CloudApp
104
128
  end
105
129
 
106
130
  # Modify the authenticated accounts details. Can change the default security of newly
107
- # created items, the accounts email address, password, and custom domain details.
108
- # @example Options for changing default security of new items
109
- # { :private_items => false }
110
- # @example Options for changing email address
111
- # { :email => "ford@prefect.com", :current_password => "towel" }
112
- # @example Options for modifying password
113
- # { :password => "happy frood", :current_password => "towel" }
114
- # @example Options for changing custom domain
115
- # { :domain => "dent.com", :domain_home_page => "http://hhgproject.org" }
116
- # Note that to custom domains requires and account with a Pro subscription.
117
- # Requires authentication.
118
- # @param [Hash] account parameters
131
+ # created drops, the accounts email address, password, and custom domain details.
132
+ #
133
+ # Note that when changing email address or password, the current password is required.
134
+ # Also note that to change custom domains requires an account with a Pro subscription.
135
+ #
136
+ # @param [Hash] opts options parameters
137
+ # @option opts [Boolean] :private_items Change default security of new drops
138
+ # @option opts [String] :email Change email address
139
+ # @option opts [String] :password Change password
140
+ # @option opts [String] :current_password Current account password
141
+ # @option opts [String] :domain Set custom domain
142
+ # @option opts [String] :domain_home_page URL to redirect visitors to custom domain's root
119
143
  # @return [CloudApp::Account]
120
144
  def update(opts = {})
121
145
  self.class.update opts
122
146
  end
123
147
 
124
148
  # Dispatch an email containing a link to reset the account's password.
149
+ #
150
+ # @param [Hash] opts options parameters
151
+ # @option opts [String] :email Account email address
125
152
  # @return [Boolean]
126
153
  def reset
127
154
  self.class.reset :email => self.email
128
155
  end
129
156
 
157
+ # Get the total number of drops created and total views for all drops.
158
+ #
159
+ # @return [Hash]
160
+ def stats
161
+ self.class.stats
162
+ end
163
+
130
164
  end
131
165
 
132
166
  end
data/lib/cloudapp/base.rb CHANGED
@@ -19,11 +19,11 @@ module CloudApp
19
19
 
20
20
  # Sets the authentication credentials in a class variable.
21
21
  #
22
- # @param [String] username cl.ly username
22
+ # @param [String] email cl.ly email
23
23
  # @param [String] password cl.ly password
24
24
  # @return [Hash] authentication credentials
25
- def self.authenticate(username, password)
26
- @@auth = {:username => username, :password => password}
25
+ def self.authenticate(email, password)
26
+ @@auth = {:username => email, :password => password}
27
27
  end
28
28
 
29
29
  private
@@ -6,27 +6,38 @@ module CloudApp
6
6
  # @client = CloudApp::Client.new
7
7
  # @client.authenticate "username", "password"
8
8
  #
9
- # @example Creating editing and deleting cl.ly items
10
- # # Find a single item by it's slug
11
- # item = @client.item "2wr4"
9
+ # @example Creating editing and deleting drops
10
+ # # Find a single drop by it's slug
11
+ # drop = @client.drop "2wr4"
12
12
  #
13
- # # Get a list of all items
14
- # items = @client.all
13
+ # # Get a list of all drops
14
+ # drops = @client.all
15
15
  #
16
16
  # # Create a new bookmark
17
- # item = @client.bookmark "http://getcloudapp.com", "CloudApp"
17
+ # drop = @client.bookmark "http://getcloudapp.com", "CloudApp"
18
+ #
19
+ # # Create multiple new bookmarks
20
+ # bookmarks = [
21
+ # { :name => "Authur Dent", :redirect_url => "http://en.wikipedia.org/wiki/Arthur_Dent" },
22
+ # { :name => "Zaphod Beeblebrox", :redirect_url => "http://en.wikipedia.org/wiki/Zaphod_Beeblebrox" }
23
+ # ]
24
+ # drops = @client.bookmark bookmarks
18
25
  #
19
26
  # # Upload a file
20
- # item = @client.upload "/path/to/image.png"
27
+ # drop = @client.upload "/path/to/image.png"
28
+ # drop = @client.upload "/path/to/image.png", :private => true
21
29
  #
22
30
  # # Rename a file
23
31
  # @client.rename "2wr4", "Big Screenshot"
24
32
  #
25
- # # Set an items privacy
33
+ # # Set a drop's privacy
26
34
  # @client.privacy "2wr4", true
27
35
  #
28
- # # Delete an item
36
+ # # Delete an drop
29
37
  # @client.delete "2wr4"
38
+ #
39
+ # # Recover a deleted drop
40
+ # @client.recover "2wr4"
30
41
  #
31
42
  class Client
32
43
 
@@ -55,15 +66,17 @@ module CloudApp
55
66
 
56
67
  # Get metadata about a cl.ly URL like name, type, or view count.
57
68
  #
58
- # Finds the item by it's slug id, for example "2wr4".
69
+ # Finds the drop by it's slug id, for example "2wr4".
59
70
  #
60
71
  # @param [String] id cl.ly slug id
61
- # @return [CloudApp::Item]
62
- def item(id)
63
- Item.find(id)
72
+ # @return [CloudApp::Drop]
73
+ def drop(id)
74
+ Drop.find(id)
64
75
  end
65
76
 
66
- # Page through your items.
77
+ alias_method :item, :drop
78
+
79
+ # Page through your drops.
67
80
  #
68
81
  # Requires authentication.
69
82
  #
@@ -71,72 +84,97 @@ module CloudApp
71
84
  # @option opts [Integer] :page (1) Page number starting at 1
72
85
  # @option opts [Integer] :per_page (5) Number of items per page
73
86
  # @option opts [String] :type ('image') Filter items by type (image, bookmark, text, archive, audio, video, or unknown)
74
- # @option opts [Boolean] :deleted (true) Show trashed items
75
- # @return [Array[CloudApp::Item]]
76
- def items(opts = {})
77
- Item.all(opts)
87
+ # @option opts [Boolean] :deleted (true) Show trashed drops
88
+ # @return [Array[CloudApp::Drop]]
89
+ def drops(opts = {})
90
+ Drop.all(opts)
78
91
  end
79
92
 
80
- # Create a new cl.ly item by bookmarking a link.
93
+ alias_method :items, :drops
94
+
95
+ # Create one or more new bookmark drops.
81
96
  #
82
97
  # Requires authentication.
83
98
  #
84
- # @param [String] url url to bookmark
85
- # @param [String] name name of bookmark
86
- # @return [CloudApp::Item]
87
- def bookmark(url, name = "")
88
- Item.create(:bookmark, {:name => name, :redirect_url => url})
99
+ # @overload bookmark(url, name = "")
100
+ # @param [String] url url to bookmark
101
+ # @param [String] name name of bookmark
102
+ # @overload bookmark(opts)
103
+ # @param [Array] opts array of bookmark option parameters (containing +:name+ and +:redirect_url+)
104
+ # @return [CloudApp::Drop]
105
+ def bookmark(*args)
106
+ if args[0].is_a? Array
107
+ Drop.create(:bookmarks, args)
108
+ else
109
+ name, url = args[0], (args[1] || "")
110
+ Drop.create(:bookmark, {:name => name, :redirect_url => url})
111
+ end
89
112
  end
90
113
 
91
- # Create a new cl.ly item by uploading a file.
114
+ # Create a new drop by uploading a file.
92
115
  #
93
116
  # Requires authentication.
94
117
  #
95
118
  # @param [String] file local path to file
96
- # @return [CloudApp::Item]
97
- def upload(file)
98
- Item.create(:upload, :file => file)
119
+ # @param [optional, Hash] opts options paramaters
120
+ # @option opts [Boolean] :private override the account default privacy setting
121
+ # @return [CloudApp::Drop]
122
+ def upload(file, opts = {})
123
+ Drop.create(:upload, opts.merge(:file => file))
99
124
  end
100
125
 
101
- # Change the name of an item.
126
+ # Change the name of the drop.
102
127
  #
103
- # Finds the item by it's slug id, for example "2wr4".
128
+ # Finds the drop by it's slug id, for example "2wr4".
104
129
  #
105
130
  # Requires authentication.
106
131
  #
107
- # @param [String] id cl.ly item id
108
- # @param [String] name new item name
109
- # @return [CloudApp::Item]
132
+ # @param [String] id drop id
133
+ # @param [String] name new drop name
134
+ # @return [CloudApp::Drop]
110
135
  def rename(id, name = "")
111
- item = Item.find(id)
112
- item.class == Item ? item.update(:name => name) : item
136
+ drop = Drop.find(id)
137
+ drop.class == Drop ? drop.update(:name => name) : drop
113
138
  end
114
139
 
115
- # Modify an item with a private URL to have a public URL or vice versa.
140
+ # Modify a drop with a private URL to have a public URL or vice versa.
116
141
  #
117
- # Finds the item by it's slug id, for example "2wr4".
142
+ # Finds the drop by it's slug id, for example "2wr4".
118
143
  #
119
144
  # Requires authentication.
120
145
  #
121
- # @param [String] id cl.ly item id
146
+ # @param [String] id drop id
122
147
  # @param [Boolean] privacy privacy setting
123
- # @return [CloudApp::Item]
148
+ # @return [CloudApp::Drop]
124
149
  def privacy(id, privacy = false)
125
- item = Item.find(id)
126
- item.class == Item ? item.update(:private => privacy) : item
150
+ drop = Drop.find(id)
151
+ drop.class == Drop ? drop.update(:private => privacy) : drop
127
152
  end
128
153
 
129
- # Send an item to the trash.
154
+ # Send the drop to the trash.
130
155
  #
131
- # Finds the item by it's slug id, for example "2wr4".
156
+ # Finds the drop by it's slug id, for example "2wr4".
132
157
  #
133
158
  # Requires authentication.
134
159
  #
135
- # @param [String] id cl.ly item id
136
- # @return [CloudApp::Item]
160
+ # @param [String] id drop id
161
+ # @return [CloudApp::Drop]
137
162
  def delete(id)
138
- item = Item.find(id)
139
- item.class == Item ? item.delete : item
163
+ drop = Drop.find(id)
164
+ drop.class == Drop ? drop.delete : drop
165
+ end
166
+
167
+ # Recover a deleted drop from the trash.
168
+ #
169
+ # Finds the drop by it's slug id, for example "2wr4".
170
+ #
171
+ # Requires authentication.
172
+ #
173
+ # @param [String] id drop id
174
+ # @return [CloudApp::Drop]
175
+ def recover(id)
176
+ drop = Drop.find(id)
177
+ drop.class == Drop ? drop.recover : drop
140
178
  end
141
179
 
142
180
  end
@@ -0,0 +1,16 @@
1
+ class Hash #:nodoc:
2
+
3
+ # Return a new hash with all keys converted to symbols.
4
+ def symbolize_keys
5
+ inject({}) do |options, (key, value)|
6
+ options[(key.to_sym rescue key) || key] = value
7
+ options
8
+ end
9
+ end
10
+
11
+ # Destructively convert all keys to symbols.
12
+ def symbolize_keys!
13
+ self.replace(self.symbolize_keys)
14
+ end
15
+
16
+ end