Class: ApiUserAuth::Providers::Instagram

Inherits:
Object
  • Object
show all
Defined in:
lib/api_user_auth/providers/instagram.rb

Overview

Instagram

Constant Summary collapse

API_PATH =
'https://api.instagram.com/v1/users/self/'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Instagram

Returns a new instance of Instagram.



7
8
9
10
# File 'lib/api_user_auth/providers/instagram.rb', line 7

def initialize(token)
  @token = token
  @data = {}
end

Class Method Details

.get_user(token) ⇒ Object



34
35
36
37
# File 'lib/api_user_auth/providers/instagram.rb', line 34

def self.get_user(token)
  inst = Instagram.new(token)
  inst.get_user_data
end

Instance Method Details

#api_info_urlObject



12
13
14
15
16
17
# File 'lib/api_user_auth/providers/instagram.rb', line 12

def api_info_url
  params = {
    access_token: @token
  }
  URI("#{API_PATH}?#{params.to_query}")
end

#get_user_dataObject



19
20
21
22
# File 'lib/api_user_auth/providers/instagram.rb', line 19

def get_user_data
  api_get_request
  user_data
end

#user_dataObject



24
25
26
27
28
29
30
31
32
# File 'lib/api_user_auth/providers/instagram.rb', line 24

def user_data
  {
    id: @data[:id], name: @data[:full_name],
    email: "#{@data[:username]}@instagram.com",
    provider: 'instagram',
    img_url: @data[:profile_picture],
    info: {}
  }
end