Class: Beemo::User

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/beemo/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ User

Returns a new instance of User.



6
7
8
9
10
11
12
# File 'lib/beemo/user.rb', line 6

def initialize(data)
  @name = data["name"]
  @location = data["location"]
  @uid = data["uri"].split("/").last
  @profile_pics = data["pictures"]
  @url = data["link"]
end

Instance Attribute Details

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#profile_picsObject

Returns the value of attribute profile_pics.



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

def profile_pics
  @profile_pics
end

#uidObject

Returns the value of attribute uid.



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

def uid
  @uid
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.default_headersObject



14
15
16
# File 'lib/beemo/user.rb', line 14

def self.default_headers
  {headers: {"Authorization" => "bearer #{Beemo.configuration[:access_token]}"}}
end

.search(query) ⇒ Object



23
24
25
26
27
# File 'lib/beemo/user.rb', line 23

def self.search(query)
  response = get("/users?query=#{query}", default_headers).body
  data = JSON.parse(response)
  data["data"].map {|d| new(d) }
end

.user_info(uid) ⇒ Object



18
19
20
21
# File 'lib/beemo/user.rb', line 18

def self.(uid)
  response = get("/users/#{uid}", default_headers).body
  self.new JSON.parse(response)
end