gumroad-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba4f6a0a280f92ea8ddb1576fa3fb1bc2285fb78
4
+ data.tar.gz: 09008106e7ea2383f6e694504a04bcfe65461da6
5
+ SHA512:
6
+ metadata.gz: b40055f28ef0f2b3c2640dbb84048ea8e59ff5ca8799121d2973901b4916c45ac4c9ac2ebac77eecf3bac8166b3d23a434fb72c47e8687448f7e4313afec2406
7
+ data.tar.gz: 27d6c1429348dd8559a759d6802b6c5420010bc4e260f461900729d92879db4eb4074b9c2b0daea2940a9ca4a29fc5a846cf4932513314d3c304416da6f19456
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gumroad-sdk.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Evan Marsland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Gumroad-Sdk
2
+
3
+ A robust ruby interface to the Gumroad API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gumroad-sdk'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gumroad-sdk
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'gumroad_sdk'
25
+
26
+ Gumroad.set_token('<YOUR API ACCESS TOKEN'>)
27
+
28
+ products = Gumroad::Product.all
29
+ product = Gumroad::Product.find('some id')
30
+
31
+ ```
32
+
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gumroad-sdk.
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
48
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gumroad/sdk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gumroad/sdk/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gumroad-sdk"
8
+ spec.version = Gumroad::Sdk::VERSION
9
+ spec.authors = ["Evan Marsland"]
10
+ spec.email = ["ERmarsland@gmail.com"]
11
+
12
+ spec.summary = %q{Gem to interface with the gumroad api}
13
+ spec.description = %q{Gem to interface with the gumroad api}
14
+ spec.homepage = "https://github.com/emars/gumroadk-sdk"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "vcr"
26
+ spec.add_development_dependency "webmock"
27
+
28
+ spec.add_dependency "faraday"
29
+ spec.add_dependency "json"
30
+ end
@@ -0,0 +1,138 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ API_ROOT = 'https://api.gumroad.com/v2/products'
5
+
6
+ module Gumroad
7
+ class Product
8
+ attr_reader :id,
9
+ :formatted_price,
10
+ :view_count,
11
+ :sales_count,
12
+ :sales_usd_cents,
13
+ :deleted
14
+
15
+ attr_accessor :name,
16
+ :file,
17
+ :price,
18
+ :description,
19
+ :preview_url,
20
+ :countries_available,
21
+ :max_purchase_count,
22
+ :customizable_price,
23
+ :webhook,
24
+ :require_shipping,
25
+ :shown_on_profile,
26
+ :custom_recipt,
27
+ :custom_summary,
28
+ :custom_permalink,
29
+ :is_recurring_billing,
30
+ :subscription_duration
31
+
32
+ def initialize(attributes)
33
+ @id = attributes['id']
34
+ @custom_receipt = attributes['custom_receipt']
35
+ @custom_summary = attributes['custom_summary']
36
+ @custom_fields = attributes['custom_fields']
37
+ @customizable_price = attributes['customizable_price']
38
+ @deleted = attributes['deleted']
39
+ @max_purchase_count = attributes['max_purchase_count']
40
+ @name = attributes['name']
41
+ @require_shipping = attributes['require_shipping']
42
+ @subscription_duration = attributes['subscription_duration']
43
+ @custom_permalink = attributes['custom_permalink']
44
+ @published = attributes['published']
45
+ @url = attributes['url']
46
+ @webhook = attributes['webhook']
47
+ @price = attributes['price']
48
+ @custom_product_type = attributes['custom_product_type']
49
+ @countries_available = attributes['countries_available']
50
+ @short_url = attributes['short_url']
51
+ @formatted_price = attributes['formatted_price']
52
+ @description = attributes['description']
53
+ @preview_url = attributes['preview_url']
54
+ @file_info = attributes['file_info']
55
+ @shown_on_profile = attributes['shown_on_profile']
56
+ @view_count = attributes['view_count']
57
+ @sales_count = attributes['sales_count']
58
+ @sales_usd_cents = attributes['sales_usd_cents']
59
+ end
60
+
61
+ def save
62
+ response = Faraday.put("#{API_ROOT}/#{@id}", serialize)
63
+ data = JSON.parse(response.body)
64
+ new(data['product'])
65
+ end
66
+
67
+ def delete
68
+ data = { access_token: Gumroad.get_token }
69
+ response = Faraday.delete("#{API_ROOT}/#{@id}", data)
70
+ JSON.parse(response.body)
71
+ end
72
+
73
+ def offer_codes
74
+ end
75
+
76
+ def offer_code
77
+ end
78
+
79
+ def create_offer_code(data)
80
+ end
81
+
82
+ def variant
83
+ end
84
+
85
+ def create_variant
86
+ end
87
+
88
+ def custom_fields
89
+ end
90
+
91
+ def custom_field(id)
92
+ end
93
+
94
+ def create_custom_field
95
+ end
96
+
97
+ def self.create(file, data)
98
+ data['access_token'] = Gumroad.get_token
99
+ response = Faraday.post("#{API_ROOT}", data)
100
+ data = JSON.parse(response.body)
101
+ new(data['product'])
102
+ end
103
+
104
+ def self.all
105
+ response = Faraday.get("#{API_ROOT}", {'access_token' => Gumroad.get_token})
106
+ data = JSON.parse(response.body)
107
+ data['products'].map { |attributes| new(attributes) }
108
+ end
109
+
110
+ def self.find(id)
111
+ response = Faraday.get("#{API_ROOT}/#{id}", {'access_token' => Gumroad.get_token})
112
+ data = JSON.parse(response.body)
113
+ new(data['product'])
114
+ end
115
+
116
+ private
117
+ def serialize
118
+ {
119
+ access_token: Gumroad.get_token,
120
+ name: @name,
121
+ file: @file,
122
+ price: @price,
123
+ description: @description,
124
+ countries_available: @countries_available,
125
+ max_purchases_count: @max_purchases_count,
126
+ customizable_price: @customizable_price,
127
+ webhook: @webhook,
128
+ require_shipping: @require_shipping,
129
+ shown_on_profile: @shown_on_profile,
130
+ custom_receipt: @custom_receipt,
131
+ custom_summary: @custom_summary,
132
+ custom_permalink: @custom_permalink,
133
+ is_recurring_billing: @is_recurring_billing,
134
+ subscription_duration: @subsription_duration
135
+ }
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,14 @@
1
+ require "gumroad/sdk/version"
2
+
3
+ module Gumroad
4
+ def self.get_token
5
+ @@token
6
+ end
7
+
8
+ def self.set_token(token)
9
+ @@token = token
10
+ end
11
+
12
+ module Sdk
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Gumroad
2
+ module Sdk
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ API_ROOT = 'https://api.gumroad.com/v2/user'
5
+
6
+ module Gumroad
7
+ class User
8
+ attr_reader :name, :id, :bio, :email
9
+
10
+ def initialize(attrs)
11
+ @name = attrs['name']
12
+ @id = attrs['id']
13
+ @bio = attrs['bio']
14
+ @email = attrs['email']
15
+ end
16
+
17
+ def self.get
18
+ response = Faraday.get("#{API_ROOT}", {'access_token' => Gumroad.token})
19
+ attrs = JSON.parse(response.body)
20
+ new(attrs['user'])
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ require "gumroad/sdk/version"
2
+ require "gumroad/product"
3
+
4
+ module Gumroad
5
+ def self.get_token
6
+ unless @@token
7
+ raise "No Token"
8
+ end
9
+ @@token
10
+ end
11
+
12
+ def self.set_token(token)
13
+ @@token = token
14
+ end
15
+ end
data/lib/lib/gummy.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "gummy/version"
2
+ require "gummy/product"
3
+
4
+ module Gummy
5
+ def self.set_token(token)
6
+ @@token = token
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ API_ROOT = 'https://api.gumroad.com/v2/products'
5
+
6
+ module Gummy
7
+ class Product
8
+ attr_accessor :id, :description, :name
9
+
10
+ def initialize(attributes)
11
+ #@description = attributes["description"]
12
+ end
13
+
14
+ def self.all
15
+ response = Faraday.get("#{API_ROOT}", {'access_token' => Gummy.token})
16
+ cars = JSON.parse(response.body)
17
+ cars.map { |attributes| new(attributes) }
18
+ end
19
+
20
+ def self.find(id)
21
+ response = Faraday.get("#{API_ROOT}/#{id}", {'access_token' => Gummy.token})
22
+ attributes = JSON.parse(response.body)
23
+ new(attributes)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Gummy
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gumroad-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Evan Marsland
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Gem to interface with the gumroad api
112
+ email:
113
+ - ERmarsland@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/setup
127
+ - gumroad-sdk.gemspec
128
+ - lib/gumroad/product.rb
129
+ - lib/gumroad/sdk.rb
130
+ - lib/gumroad/sdk/version.rb
131
+ - lib/gumroad/user.rb
132
+ - lib/gumroad_sdk.rb
133
+ - lib/lib/gummy.rb
134
+ - lib/lib/gummy/product.rb
135
+ - lib/lib/gummy/version.rb
136
+ homepage: https://github.com/emars/gumroadk-sdk
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Gem to interface with the gumroad api
160
+ test_files: []