class SocialProfile::People::Google

Public Instance Methods

channels() click to toggle source
# File lib/social_profile/people/google.rb, line 15
def channels
  return @channels if @channels

  _channels = client.list_channels('statistics', mine: true)

  @channels = if _channels.respond_to?(:items)
    _channels
  elsif _channels.is_a?(String)
    JSON.parse(_channels, object_class: OpenStruct)
  end

  @channels
end
friends_count() click to toggle source

Get friends count

# File lib/social_profile/people/google.rb, line 9
def friends_count
  @friends_count ||= channels.items.map do |item|
    (item.statistics.subscriber_count || item.statistics.subscriberCount).to_i
  end.sum
end

Protected Instance Methods

client() click to toggle source
# File lib/social_profile/people/google.rb, line 31
def client
  return @client if @client

  @client = ::Google::Apis::YoutubeV3::YouTubeService.new
  @client.authorization = access_token

  @client
end