From ed59ddefdfe12ec37ccf1eb057f6536a1f95a733 Mon Sep 17 00:00:00 2001 From: stve Date: Tue, 10 Feb 2015 00:07:01 -0500 Subject: [PATCH] updated account implementation --- lib/instapaper/api/account.rb | 4 +++- lib/instapaper/user.rb | 6 ++++++ spec/instapaper/api/account_spec.rb | 5 ++--- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 lib/instapaper/user.rb diff --git a/lib/instapaper/api/account.rb b/lib/instapaper/api/account.rb index 597f9a0..3199d61 100644 --- a/lib/instapaper/api/account.rb +++ b/lib/instapaper/api/account.rb @@ -1,10 +1,12 @@ +require 'instapaper/user' + module Instapaper module API # Defines methods related to accounts module Account # Returns the currently logged in user. def verify_credentials - post('/api/1/account/verify_credentials') + perform_post_with_object('/api/1/account/verify_credentials', {}, Instapaper::User) end end end diff --git a/lib/instapaper/user.rb b/lib/instapaper/user.rb new file mode 100644 index 0000000..b07ead1 --- /dev/null +++ b/lib/instapaper/user.rb @@ -0,0 +1,6 @@ +require 'values' + +module Instapaper + class User < Value.new(:type, :user_id, :username) + end +end diff --git a/spec/instapaper/api/account_spec.rb b/spec/instapaper/api/account_spec.rb index 620c3b4..5c2e7b9 100644 --- a/spec/instapaper/api/account_spec.rb +++ b/spec/instapaper/api/account_spec.rb @@ -16,9 +16,8 @@ describe Instapaper::Client::Account do end it 'should return the user' do - user = client.verify_credentials.first - expect(user).to be_a Hashie::Rash - expect(user.username).to eq('TestUserOMGLOL') + user = client.verify_credentials + expect(user).to be_a Instapaper::User end end end