class SocialShares::Google

Constants

URL

Public Instance Methods

shares!() click to toggle source
# File lib/social_shares/google.rb, line 5
def shares!
  response = post(URL, JSON.dump(params), { content_type: :json, accept: :json })

  JSON.parse(response)[0]['result']['metadata']['globalCounts']['count'].to_i
end

Private Instance Methods

params() click to toggle source
# File lib/social_shares/google.rb, line 13
def params
  [{
    'method' => 'pos.plusones.get',
    'id' => 'p',
    'jsonrpc' => '2.0',
    'key' => 'p',
    'apiVersion' => 'v1',
    'params' => {
      'nolog' => true,
      'id' => checked_url,
      'source' => 'widget',
      'userId' => '@viewer',
      'groupId' => '@self'
    }
  }]
end