patreon 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad676d15579d0bcd7c803e890eb2036d2100ec8b
4
- data.tar.gz: 322b087b65fd2ebbd21b6dd48a162abf173395e2
3
+ metadata.gz: 85f8e4342d5367269d2d626762f48635d644faa2
4
+ data.tar.gz: 0e4937dfd8eadf081d338027e36c49ac607e8926
5
5
  SHA512:
6
- metadata.gz: 180b08e913282461e376b555dac658b3434acfef272c6ca86d5e5c2ea05e6d48bb7de3a6dd2f805b7598b9457a14e22f35caba00ff41fb90dc2a0cce0cfdb265
7
- data.tar.gz: f167cf347b909ae43c20e8f3304807fff873225bc72e3c921e7792209bb1afa8309582e23bb7d730ffb260ddf28153058b3d62d0ed1955028c787fc96bbebe4d
6
+ metadata.gz: 688fbbca091fc34af6e0f78b85a92b0ffaad3e75f19c15206a2ce166a4c1019dd5db6f44bd6013b9b208f3dc7cfee98f3aca0ede846b3da5ce6699092d3aff52
7
+ data.tar.gz: fa8cf4c8ae5e76269dc5181e30966d7599e24baf343ba4bcf6b99db7b893aaa31303078f6ac894ff64b66448b7740be10a6272c91e36a2b527a2565199c2d705
data/.gitignore CHANGED
@@ -28,7 +28,7 @@ build/
28
28
 
29
29
  # for a library or gem, you might want to ignore these files since the code is
30
30
  # intended to run in multiple environments; otherwise, check them in:
31
- # Gemfile.lock
31
+ Gemfile.lock
32
32
  # .ruby-version
33
33
  # .ruby-gemset
34
34
 
@@ -0,0 +1,6 @@
1
+ # 0.4.0
2
+
3
+ * Stop shipping the lockfile
4
+ * Update API routes to the canonical path
5
+ * Add a debug mode to the API client
6
+ * Add User-Agent string for correct traffic attribution
data/LICENSE CHANGED
@@ -176,7 +176,7 @@
176
176
 
177
177
  END OF TERMS AND CONDITIONS
178
178
 
179
- Copyright 2015-2016 Patreon, Inc.
179
+ Copyright 2015-2018 Patreon, Inc.
180
180
 
181
181
  Licensed under the Apache License, Version 2.0 (the "License");
182
182
  you may not use this file except in compliance with the License.
data/NOTICE CHANGED
@@ -1,4 +1,4 @@
1
1
  Patreon Integration for Ruby
2
- Copyright 2015-2016 Patreon, Inc.
2
+ Copyright 2015-2018 Patreon, Inc.
3
3
 
4
4
  This product includes software developed at Patreon, Inc. (https://www.patreon.com/).
@@ -1,4 +1,4 @@
1
- require_relative 'lib/patreon'
1
+ require_relative '../lib/patreon'
2
2
  require 'uri'
3
3
  require 'cgi'
4
4
 
@@ -2,6 +2,8 @@ $: << File.dirname(__FILE__)
2
2
 
3
3
  require 'patreon/utils/jsonapi/url_util'
4
4
  require 'patreon/utils/enum'
5
+ require 'patreon/utils/client'
6
+ require 'patreon/version'
5
7
  require 'patreon/schemas'
6
8
  require 'patreon/oauth'
7
9
  require 'patreon/api'
@@ -2,6 +2,7 @@ require 'net/http'
2
2
  require 'cgi'
3
3
  require 'json'
4
4
  require 'json-api-vanilla'
5
+ require 'openssl'
5
6
 
6
7
  module Patreon
7
8
  class API
@@ -32,10 +33,19 @@ module Patreon
32
33
  private
33
34
 
34
35
  def get_json(suffix)
35
- url = URI.parse("https://www.patreon.com/api/oauth2/api/#{suffix}")
36
- req = Net::HTTP::Get.new(url.to_s)
36
+ http = Net::HTTP.new("www.patreon.com", 443)
37
+ http.use_ssl = true
38
+
39
+ # TODO: It would be nice if we verified our certs
40
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
41
+
42
+ #SECURITY HOLE
43
+ http.set_debug_output($stdout) if ENV['DEBUG']
44
+
45
+ req = Net::HTTP::Get.new("/api/oauth2/api/#{suffix}")
37
46
  req['Authorization'] = "Bearer #{@access_token}"
38
- res = Net::HTTP.start(url.host, url.port, :use_ssl => true) {|http| http.request(req)}
47
+ req['User-Agent'] = Utils::Client.user_agent_string
48
+ res = http.request(req)
39
49
  return JSON::Api::Vanilla.parse(res.body)
40
50
  end
41
51
  end
@@ -33,6 +33,7 @@ module Patreon
33
33
  url = URI.parse('https://www.patreon.com/api/oauth2/token')
34
34
  url.query = URI.encode_www_form(params)
35
35
  req = Net::HTTP::Post.new(url.to_s)
36
+ req['User-Agent'] = Utils::Client.user_agent_string
36
37
  res = Net::HTTP.start(url.host, url.port, :use_ssl => true) {|http| http.request(req)}
37
38
  JSON.parse(res.body)
38
39
  end
@@ -0,0 +1,11 @@
1
+ require 'rbconfig'
2
+
3
+ module Patreon
4
+ module Utils
5
+ module Client
6
+ def self.user_agent_string
7
+ "Patreon-Ruby, version #{Patreon::VERSION}, platform #{RbConfig::CONFIG['host']}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Patreon
2
+ VERSION = "0.4.0"
3
+ end
@@ -2,9 +2,11 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
+ require 'patreon/version'
6
+
5
7
  Gem::Specification.new do |gem|
6
8
  gem.name = "patreon"
7
- gem.version = "0.3.0"
9
+ gem.version = Patreon::VERSION
8
10
  gem.authors = ["Patreon"]
9
11
  gem.email = ["david@patreon.com"]
10
12
  gem.description = "Interact with the Patreon API via OAuth"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patreon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patreon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-api-vanilla
@@ -32,8 +32,8 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
+ - CHANGELOG.md
35
36
  - Gemfile
36
- - Gemfile.lock
37
37
  - LICENSE
38
38
  - NOTICE
39
39
  - README.md
@@ -60,8 +60,10 @@ files:
60
60
  - lib/patreon/schemas/pledge.rb
61
61
  - lib/patreon/schemas/reward.rb
62
62
  - lib/patreon/schemas/user.rb
63
+ - lib/patreon/utils/client.rb
63
64
  - lib/patreon/utils/enum.rb
64
65
  - lib/patreon/utils/jsonapi/url_util.rb
66
+ - lib/patreon/version.rb
65
67
  - patreon.gemspec
66
68
  homepage: https://github.com/Patreon/patreon-ruby
67
69
  licenses:
@@ -83,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
85
  version: '0'
84
86
  requirements: []
85
87
  rubyforge_project:
86
- rubygems_version: 2.5.1
88
+ rubygems_version: 2.6.14
87
89
  signing_key:
88
90
  specification_version: 4
89
91
  summary: Visit patreon.com/oauth2/documentation for more information.
@@ -1,13 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- json-api-vanilla (1.0.1)
5
-
6
- PLATFORMS
7
- ruby
8
-
9
- DEPENDENCIES
10
- json-api-vanilla (~> 1.0.1)
11
-
12
- BUNDLED WITH
13
- 1.15.1