gumroad 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.markdown +34 -0
- data/Rakefile +1 -0
- data/gumroad.gemspec +34 -0
- data/lib/gumroad.rb +12 -0
- data/lib/gumroad/link.rb +13 -0
- data/lib/gumroad/link_proxy.rb +24 -0
- data/lib/gumroad/session.rb +27 -0
- data/lib/gumroad/version.rb +3 -0
- metadata +66 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) Max Stoller
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Gumroad
|
2
|
+
======
|
3
|
+
|
4
|
+
Gumroad is a Ruby wrapper for the Gumroad API.
|
5
|
+
|
6
|
+
**This gem is a work in progress. Contributions are welcome.**
|
7
|
+
|
8
|
+
Authentication
|
9
|
+
--------
|
10
|
+
``` ruby
|
11
|
+
client = Gumroad.new(username, password)
|
12
|
+
```
|
13
|
+
|
14
|
+
Links
|
15
|
+
--------
|
16
|
+
``` ruby
|
17
|
+
links = client.links.all
|
18
|
+
```
|
19
|
+
|
20
|
+
``` ruby
|
21
|
+
link = client.links.find(id)
|
22
|
+
```
|
23
|
+
|
24
|
+
You now have a Gumroad::Link object. You can call methods such as `link.name` and `link.url`.
|
25
|
+
|
26
|
+
It's pretty easy to create a link.
|
27
|
+
|
28
|
+
``` ruby
|
29
|
+
client.links.create(name: 'Github', url: 'http://github.com')
|
30
|
+
```
|
31
|
+
|
32
|
+
Thanks
|
33
|
+
--------
|
34
|
+
* GroupMe's [quimby](https://github.com/groupme/quimby) gem. I took their object approach when writing this gem.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gumroad.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gumroad/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gumroad"
|
7
|
+
s.version = Gumroad::VERSION
|
8
|
+
s.authors = ["maxstoller"]
|
9
|
+
s.email = ["maxstoller@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/maxstoller/gumroad"
|
11
|
+
s.summary = %q{Gumroad API wrapper}
|
12
|
+
s.description = %q{A Ruby wrapper for the Gumroad API.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "gumroad"
|
15
|
+
|
16
|
+
s.files = [
|
17
|
+
"README.markdown",
|
18
|
+
"LICENSE",
|
19
|
+
"Gemfile",
|
20
|
+
"gumroad.gemspec",
|
21
|
+
"Rakefile",
|
22
|
+
"lib/gumroad.rb",
|
23
|
+
"lib/gumroad/session.rb",
|
24
|
+
"lib/gumroad/link.rb",
|
25
|
+
"lib/gumroad/link_proxy.rb",
|
26
|
+
"lib/gumroad/version.rb"
|
27
|
+
]
|
28
|
+
|
29
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
|
33
|
+
s.add_runtime_dependency "httparty"
|
34
|
+
end
|
data/lib/gumroad.rb
ADDED
data/lib/gumroad/link.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gumroad
|
2
|
+
class Link
|
3
|
+
attr_reader :json
|
4
|
+
attr_accessor :name, :url, :description, :user, :price_cents
|
5
|
+
|
6
|
+
def initialize(session, json)
|
7
|
+
@session = session
|
8
|
+
[:name, :url, :description, :user, :price_cents].each do |attribute|
|
9
|
+
instance_variable_set(:"@#{attribute}", json[attribute.to_s])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Gumroad
|
2
|
+
class LinkProxy
|
3
|
+
def initialize(session)
|
4
|
+
@session = session
|
5
|
+
end
|
6
|
+
|
7
|
+
def find(id)
|
8
|
+
Gumroad::Link.new(@session, @session.get("/links/#{id}")['link'])
|
9
|
+
end
|
10
|
+
|
11
|
+
def all
|
12
|
+
@session.get('/links')['links'].map do |json|
|
13
|
+
Gumroad::Link.new(@session, json)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(options={})
|
18
|
+
scoped_options = {}
|
19
|
+
options.each { |k, v| scoped_options["link[#{k.to_s}]"] = v }
|
20
|
+
json = @session.post('/links', scoped_options)
|
21
|
+
Gumroad::Link.new(@session, json['link'])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Gumroad
|
4
|
+
class Session
|
5
|
+
include HTTParty
|
6
|
+
base_uri 'https://gumroad.com/api/v1'
|
7
|
+
|
8
|
+
def initialize(email, password)
|
9
|
+
token = post('/sessions', {
|
10
|
+
email: email, password: password
|
11
|
+
})['token']
|
12
|
+
self.class.basic_auth token, ''
|
13
|
+
end
|
14
|
+
|
15
|
+
def post(path, params)
|
16
|
+
self.class.post(path, query: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(path)
|
20
|
+
self.class.get(path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def links
|
24
|
+
Gumroad::LinkProxy.new(self)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gumroad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- maxstoller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-12 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: &70098124087580 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70098124087580
|
25
|
+
description: A Ruby wrapper for the Gumroad API.
|
26
|
+
email:
|
27
|
+
- maxstoller@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- README.markdown
|
33
|
+
- LICENSE
|
34
|
+
- Gemfile
|
35
|
+
- gumroad.gemspec
|
36
|
+
- Rakefile
|
37
|
+
- lib/gumroad.rb
|
38
|
+
- lib/gumroad/session.rb
|
39
|
+
- lib/gumroad/link.rb
|
40
|
+
- lib/gumroad/link_proxy.rb
|
41
|
+
- lib/gumroad/version.rb
|
42
|
+
homepage: https://github.com/maxstoller/gumroad
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project: gumroad
|
62
|
+
rubygems_version: 1.8.6
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Gumroad API wrapper
|
66
|
+
test_files: []
|