From d5ce6c98ef95a40b46c67ea4c802a05ab7f249d9 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 22 Jun 2017 23:20:04 -0500 Subject: [PATCH] tumblr: add tumblr api client. --- Gemfile | 1 + Gemfile.lock | 3 +++ app/logical/tumblr_api_client.rb | 9 +++++++++ 3 files changed, 13 insertions(+) create mode 100644 app/logical/tumblr_api_client.rb diff --git a/Gemfile b/Gemfile index e4178086a..dc59a76af 100644 --- a/Gemfile +++ b/Gemfile @@ -45,6 +45,7 @@ gem 'daemons' gem 'oauth2' gem 'bootsnap' gem 'addressable' +gem 'httparty' # needed for looser jpeg header compat gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes" diff --git a/Gemfile.lock b/Gemfile.lock index 45f0286b8..c641d8c14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -166,6 +166,8 @@ GEM domain_name (~> 0.5) http-form_data (1.0.2) http_parser.rb (0.6.0) + httparty (0.15.5) + multi_xml (>= 0.5.2) httpclient (2.8.0) hurley (0.2) i18n (0.8.1) @@ -412,6 +414,7 @@ DEPENDENCIES gctools google-api-client highline + httparty mechanize memcache-client memcache_mock diff --git a/app/logical/tumblr_api_client.rb b/app/logical/tumblr_api_client.rb new file mode 100644 index 000000000..61b0892ee --- /dev/null +++ b/app/logical/tumblr_api_client.rb @@ -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