Class: SoapboxApi::UsersPosts

Inherits:
Object
  • Object
show all
Defined in:
lib/soapbox_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ UsersPosts

Returns a new instance of UsersPosts.



10
11
12
# File 'lib/soapbox_api.rb', line 10

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/soapbox_api.rb', line 8

def token
  @token
end

Instance Method Details

#fetch_postsObject



14
15
16
17
18
# File 'lib/soapbox_api.rb', line 14

def fetch_posts
  result = JSON.parse(Nokogiri::HTML(open('http://localhost:3000/api/fetch_posts.json?consumer_key=' + token[:consumer_key] + '&consumer_secret=' + token[:consumer_secret])))
  raise "401: Not authorized" if (result.empty?)
  result
end