Class: Whatser::User

Inherits:
Resource show all
Defined in:
lib/whatser/resources/user.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#api_request, api_request, client, convert_data_to_model, from_hash_to_model, #initialize, set

Constructor Details

This class inherits a constructor from Whatser::Resource

Instance Attribute Details

#access_token=(value) ⇒ Object (writeonly)

Sets the attribute access_token

Parameters:

  • value

    the value to set the attribute access_token to.



8
9
10
# File 'lib/whatser/resources/user.rb', line 8

def access_token=(value)
  @access_token = value
end

#avatar=(value) ⇒ Object (writeonly)

Sets the attribute avatar

Parameters:

  • value

    the value to set the attribute avatar to.



6
7
8
# File 'lib/whatser/resources/user.rb', line 6

def avatar=(value)
  @avatar = value
end

#avatar_picObject

Returns the value of attribute avatar_pic.



4
5
6
# File 'lib/whatser/resources/user.rb', line 4

def avatar_pic
  @avatar_pic
end

#bioObject

Returns the value of attribute bio.



4
5
6
# File 'lib/whatser/resources/user.rb', line 4

def bio
  @bio
end

#check_ins_count=(value) ⇒ Object (writeonly)

Sets the attribute check_ins_count

Parameters:

  • value

    the value to set the attribute check_ins_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def check_ins_count=(value)
  @check_ins_count = value
end

#collections_count=(value) ⇒ Object (writeonly)

Sets the attribute collections_count

Parameters:

  • value

    the value to set the attribute collections_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def collections_count=(value)
  @collections_count = value
end

#comments_count=(value) ⇒ Object (writeonly)

Sets the attribute comments_count

Parameters:

  • value

    the value to set the attribute comments_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def comments_count=(value)
  @comments_count = value
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/whatser/resources/user.rb', line 4

def email
  @email
end

#facebook_idObject

Returns the value of attribute facebook_id.



3
4
5
# File 'lib/whatser/resources/user.rb', line 3

def facebook_id
  @facebook_id
end

#followers_count=(value) ⇒ Object (writeonly)

Sets the attribute followers_count

Parameters:

  • value

    the value to set the attribute followers_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def followers_count=(value)
  @followers_count = value
end

#follows_count=(value) ⇒ Object (writeonly)

Sets the attribute follows_count

Parameters:

  • value

    the value to set the attribute follows_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def follows_count=(value)
  @follows_count = value
end

#foursquare_idObject

Returns the value of attribute foursquare_id.



3
4
5
# File 'lib/whatser/resources/user.rb', line 3

def foursquare_id
  @foursquare_id
end

#gowalla_idObject

Returns the value of attribute gowalla_id.



3
4
5
# File 'lib/whatser/resources/user.rb', line 3

def gowalla_id
  @gowalla_id
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/whatser/resources/user.rb', line 3

def id
  @id
end

#last_login_atObject

Returns the value of attribute last_login_at.



5
6
7
# File 'lib/whatser/resources/user.rb', line 5

def 
  @last_login_at
end

#lat=(value) ⇒ Object (writeonly)

Sets the attribute lat

Parameters:

  • value

    the value to set the attribute lat to.



6
7
8
# File 'lib/whatser/resources/user.rb', line 6

def lat=(value)
  @lat = value
end

#lng=(value) ⇒ Object (writeonly)

Sets the attribute lng

Parameters:

  • value

    the value to set the attribute lng to.



6
7
8
# File 'lib/whatser/resources/user.rb', line 6

def lng=(value)
  @lng = value
end

#locationObject

Returns the value of attribute location.



4
5
6
# File 'lib/whatser/resources/user.rb', line 4

def location
  @location
end

#media_count=(value) ⇒ Object (writeonly)

Sets the attribute media_count

Parameters:

  • value

    the value to set the attribute media_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def media_count=(value)
  @media_count = value
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/whatser/resources/user.rb', line 4

def name
  @name
end

#password=(value) ⇒ Object (writeonly)

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



6
7
8
# File 'lib/whatser/resources/user.rb', line 6

def password=(value)
  @password = value
end

#poi_count=(value) ⇒ Object (writeonly)

Sets the attribute poi_count

Parameters:

  • value

    the value to set the attribute poi_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def poi_count=(value)
  @poi_count = value
end

Returns the value of attribute promoted.



5
6
7
# File 'lib/whatser/resources/user.rb', line 5

def promoted
  @promoted
end

#remote_avatar=(value) ⇒ Object (writeonly)

Sets the attribute remote_avatar

Parameters:

  • value

    the value to set the attribute remote_avatar to.



6
7
8
# File 'lib/whatser/resources/user.rb', line 6

def remote_avatar=(value)
  @remote_avatar = value
end

#taggings_count=(value) ⇒ Object (writeonly)

Sets the attribute taggings_count

Parameters:

  • value

    the value to set the attribute taggings_count to.



7
8
9
# File 'lib/whatser/resources/user.rb', line 7

def taggings_count=(value)
  @taggings_count = value
end

#twitter_idObject

Returns the value of attribute twitter_id.



3
4
5
# File 'lib/whatser/resources/user.rb', line 3

def twitter_id
  @twitter_id
end

#twitter_nameObject

Returns the value of attribute twitter_name.



4
5
6
# File 'lib/whatser/resources/user.rb', line 4

def twitter_name
  @twitter_name
end

Class Method Details

.anonymousObject



15
16
17
# File 'lib/whatser/resources/user.rb', line 15

def anonymous
  api_request :get, "/api/users/anonymous"
end

.collectors(id, params = {}) ⇒ Object



43
44
45
# File 'lib/whatser/resources/user.rb', line 43

def collectors(id, params={})
  api_request :get, "/api/poi/#{id}/collectors", {:query => params}
end

.create(params = {}) ⇒ Object



31
32
33
# File 'lib/whatser/resources/user.rb', line 31

def create(params={})
  api_request :post, "/api/users", {:body => {'user' => params} }, :auth => :key
end

.find(id, params = {}) ⇒ Object



27
28
29
# File 'lib/whatser/resources/user.rb', line 27

def find(id, params={})
  api_request :get, "/api/users/#{id}/profile", {:query => params}
end

.invite(emails) ⇒ Object



35
36
37
# File 'lib/whatser/resources/user.rb', line 35

def invite(emails)
  api_request :post, "/api/invites", {:query => {'emails' => emails} }
end

.meObject



11
12
13
# File 'lib/whatser/resources/user.rb', line 11

def me
  api_request :get, "/api/users/me"
end

.search(params = {}) ⇒ Object



19
20
21
# File 'lib/whatser/resources/user.rb', line 19

def search(params={})
  api_request :get, "/api/users/lookup", {:query => params}
end

.suggested(params = {}) ⇒ Object



23
24
25
# File 'lib/whatser/resources/user.rb', line 23

def suggested(params={})
  api_request :get, "/api/users/suggested", {:query => params}
end

.visitors(id, params = {}) ⇒ Object



39
40
41
# File 'lib/whatser/resources/user.rb', line 39

def visitors(id, params={})
  api_request :get, "/api/poi/#{id}/visitors", {:query => params}
end

Instance Method Details

#connectionObject



56
57
58
# File 'lib/whatser/resources/user.rb', line 56

def connection
  Whatser::Follow.set(self.class.client).connection(id)
end

#facebook_connected?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/whatser/resources/user.rb', line 72

def facebook_connected?
  !facebook_id.blank?
end

#followers(params = {}) ⇒ Object



60
61
62
# File 'lib/whatser/resources/user.rb', line 60

def followers(params={})
  Whatser::Follow.set(self.class.client).followers(id, params)
end

#foursquare_connected?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/whatser/resources/user.rb', line 76

def foursquare_connected?
  !foursquare_id.blank?
end

#gowalla_connected?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/whatser/resources/user.rb', line 80

def gowalla_connected?
  !gowalla_id.blank?
end

#oauth_tokenObject



68
69
70
# File 'lib/whatser/resources/user.rb', line 68

def oauth_token
  access_token
end

#saveObject



48
49
50
51
52
53
54
# File 'lib/whatser/resources/user.rb', line 48

def save
  if id.blank?
    api_request :post, "/api/users", {:body => {'user' => to_params} }, :auth => :key
  else
    api_request :put, "/api/users/me", {:body => {'user' => to_params} }
  end
end

#thanks(poi_id, params = {}) ⇒ Object



64
65
66
# File 'lib/whatser/resources/user.rb', line 64

def thanks(poi_id,params={})
  api_request :post, "/api/users/#{id}/poi/#{poi_id}/thanks", {:query => params}
end

#to_paramsObject



88
89
90
# File 'lib/whatser/resources/user.rb', line 88

def to_params
  {:name=>name,:avatar_pic=>@remote_avatar,:location=>location,:bio=>bio,:email=>email}
end

#twitter_connected?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/whatser/resources/user.rb', line 84

def twitter_connected?
  !twitter_id.blank?
end