Class: Kippt::FollowRelationship

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, user) ⇒ FollowRelationship

Returns a new instance of FollowRelationship.



4
5
6
7
# File 'lib/kippt/follow_relationship.rb', line 4

def initialize(client, user)
  @client = client
  @user   = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



2
3
4
# File 'lib/kippt/follow_relationship.rb', line 2

def user
  @user
end

Instance Method Details

#followObject



19
20
21
22
23
24
25
26
27
# File 'lib/kippt/follow_relationship.rb', line 19

def follow
  response = update_following(true)

  if response.success?
    true
  else
    raise Kippt::APIError.new("Problem with following: #{response.body["message"]}")
  end
end

#following?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/kippt/follow_relationship.rb', line 9

def following?
  response = client.get("users/#{user.id}/relationship/")

  if response.success?
    response.body["following"]
  else
    raise Kippt::APIError.new("Resource could not be loaded: #{response.body["message"]}")
  end
end

#unfollowObject



29
30
31
32
33
34
35
36
37
# File 'lib/kippt/follow_relationship.rb', line 29

def unfollow
  response = update_following(false)

  if response.success?
    true
  else
    raise Kippt::APIError.new("Problem with unfollowing: #{response.body["message"]}")
  end
end