gumroad 0.0.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -1
- data/lib/gumroad/link.rb +12 -2
- data/lib/gumroad/link_proxy.rb +2 -4
- data/lib/gumroad/session.rb +8 -0
- data/lib/gumroad/version.rb +1 -1
- metadata +4 -4
data/README.markdown
CHANGED
@@ -11,6 +11,11 @@ Authentication
|
|
11
11
|
client = Gumroad.new(username, password)
|
12
12
|
```
|
13
13
|
|
14
|
+
If you feel the need to, you can revoke the session.
|
15
|
+
``` ruby
|
16
|
+
client.destroy
|
17
|
+
```
|
18
|
+
|
14
19
|
Links
|
15
20
|
--------
|
16
21
|
``` ruby
|
@@ -26,7 +31,7 @@ You now have a Gumroad::Link object. You can call methods such as `link.name` an
|
|
26
31
|
It's pretty easy to create a link.
|
27
32
|
|
28
33
|
``` ruby
|
29
|
-
client.links.create(name: '
|
34
|
+
client.links.create(name: '@maxstoller', url: 'http://twitter.com/maxstoller', description: 'A link to @maxstoller.', price: '100')
|
30
35
|
```
|
31
36
|
|
32
37
|
Thanks
|
data/lib/gumroad/link.rb
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
module Gumroad
|
2
2
|
class Link
|
3
3
|
attr_reader :json
|
4
|
-
attr_accessor :name, :url, :description, :
|
4
|
+
attr_accessor :id, :name, :url, :description, :price
|
5
5
|
|
6
6
|
def initialize(session, json)
|
7
7
|
@session = session
|
8
|
-
[:name, :url, :description, :
|
8
|
+
[:id, :name, :url, :description, :price].each do |attribute|
|
9
9
|
instance_variable_set(:"@#{attribute}", json[attribute.to_s])
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def save
|
14
|
+
params = {name: name, url: url, description: description, price: price}
|
15
|
+
json = @session.post("/links", params)['link']
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
@session.delete("/links/#{id}")
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
data/lib/gumroad/link_proxy.rb
CHANGED
@@ -14,10 +14,8 @@ module Gumroad
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def create(
|
18
|
-
|
19
|
-
options.each { |k, v| scoped_options["link[#{k.to_s}]"] = v }
|
20
|
-
json = @session.post('/links', scoped_options)
|
17
|
+
def create(params={})
|
18
|
+
json = @session.post('/links', params)
|
21
19
|
Gumroad::Link.new(@session, json['link'])
|
22
20
|
end
|
23
21
|
end
|
data/lib/gumroad/session.rb
CHANGED
@@ -12,6 +12,10 @@ module Gumroad
|
|
12
12
|
self.class.basic_auth token, ''
|
13
13
|
end
|
14
14
|
|
15
|
+
def destroy
|
16
|
+
delete('/sessions')
|
17
|
+
end
|
18
|
+
|
15
19
|
def post(path, params)
|
16
20
|
self.class.post(path, query: params)
|
17
21
|
end
|
@@ -20,6 +24,10 @@ module Gumroad
|
|
20
24
|
self.class.get(path)
|
21
25
|
end
|
22
26
|
|
27
|
+
def delete(path)
|
28
|
+
self.class.delete(path)
|
29
|
+
end
|
30
|
+
|
23
31
|
def links
|
24
32
|
Gumroad::LinkProxy.new(self)
|
25
33
|
end
|
data/lib/gumroad/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gumroad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-14 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70180085319780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70180085319780
|
25
25
|
description: A Ruby wrapper for the Gumroad API.
|
26
26
|
email:
|
27
27
|
- maxstoller@gmail.com
|