Module: IGM

Extended by:
IGM
Included in:
IGM
Defined in:
lib/igm.rb

Constant Summary collapse

INSTAGRAM_URL =
"https://api.instagram.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_id=(value) ⇒ Object (writeonly)

Sets the attribute client_id

Parameters:

  • value

    the value to set the attribute client_id to.



9
10
11
# File 'lib/igm.rb', line 9

def client_id=(value)
  @client_id = value
end

#client_secret=(value) ⇒ Object (writeonly)

Sets the attribute client_secret

Parameters:

  • value

    the value to set the attribute client_secret to.



9
10
11
# File 'lib/igm.rb', line 9

def client_secret=(value)
  @client_secret = value
end

Instance Method Details

#authorize_uri(params) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/igm.rb', line 15

def authorize_uri(params)
  params[:scope]         = params[:scope].join("+")
  params[:client_id]     = @client_id
  params[:response_type] = "code"

  query_string = params_to_query_string(params)

  "#{INSTAGRAM_URL}/oauth/authorize?#{query_string}"
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (IGM)

    the object that the method was called on



11
12
13
# File 'lib/igm.rb', line 11

def configure
  yield self
end

#get_access_token(params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/igm.rb', line 25

def get_access_token(params)
  params[:client_id]     = @client_id
  params[:client_secret] = @client_secret
  params[:grant_type]    = "authorization_code"

  response = Nestful.post("#{INSTAGRAM_URL}/oauth/access_token", params)
  response = parse_response(response)

  response[:access_token]
end

#get_user_info(token) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/igm.rb', line 36

def (token)
  response = Nestful.get("#{INSTAGRAM_URL}/v1/users/self?access_token=#{token}")

  response = parse_response(response)

  response[:data]
end