tumblr: add tumblr api client.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -45,6 +45,7 @@ gem 'daemons'
|
|||||||
gem 'oauth2'
|
gem 'oauth2'
|
||||||
gem 'bootsnap'
|
gem 'bootsnap'
|
||||||
gem 'addressable'
|
gem 'addressable'
|
||||||
|
gem 'httparty'
|
||||||
|
|
||||||
# needed for looser jpeg header compat
|
# needed for looser jpeg header compat
|
||||||
gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes"
|
gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes"
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ GEM
|
|||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http-form_data (1.0.2)
|
http-form_data (1.0.2)
|
||||||
http_parser.rb (0.6.0)
|
http_parser.rb (0.6.0)
|
||||||
|
httparty (0.15.5)
|
||||||
|
multi_xml (>= 0.5.2)
|
||||||
httpclient (2.8.0)
|
httpclient (2.8.0)
|
||||||
hurley (0.2)
|
hurley (0.2)
|
||||||
i18n (0.8.1)
|
i18n (0.8.1)
|
||||||
@@ -412,6 +414,7 @@ DEPENDENCIES
|
|||||||
gctools
|
gctools
|
||||||
google-api-client
|
google-api-client
|
||||||
highline
|
highline
|
||||||
|
httparty
|
||||||
mechanize
|
mechanize
|
||||||
memcache-client
|
memcache-client
|
||||||
memcache_mock
|
memcache_mock
|
||||||
|
|||||||
9
app/logical/tumblr_api_client.rb
Normal file
9
app/logical/tumblr_api_client.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class TumblrApiClient < Struct.new(:api_key)
|
||||||
|
include HTTParty
|
||||||
|
base_uri "https://api.tumblr.com/v2/blog/"
|
||||||
|
|
||||||
|
def posts(blog_name, post_id)
|
||||||
|
response = self.class.get("/#{blog_name}/posts", query: { id: post_id, api_key: api_key })
|
||||||
|
response.parsed_response.with_indifferent_access[:response]
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user