Class: KakaoUser

Inherits:
Object
  • Object
show all
Defined in:
lib/v1/kakao_user.rb

Constant Summary collapse

HOST_KAUTH =
'https://kauth.kakao.com'.freeze
HOST_KAPI =
'https://kapi.kakao.com'.freeze

Class Method Summary collapse

Class Method Details

.access_token_info(access_token) ⇒ Object



65
66
67
68
69
70
# File 'lib/v1/kakao_user.rb', line 65

def self.access_token_info(access_token)
  authorization = "Bearer #{access_token}"

  request_url = "#{HOST_KAPI}/v1/user/access_token_info"
  RestClient.get(request_url, Authorization: authorization)
end

.ids(admin_key, limit = 100, from_id = 0, order = 'asc') ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/v1/kakao_user.rb', line 54

def self.ids(admin_key, limit = 100, from_id = 0, order = 'asc')
  authorization = "KakaoAK #{admin_key}"
  params = {}
  params[:limit] = limit
  params[:from_id] = from_id if from_id > 0
  params[:order] = order

  request_url = "#{HOST_KAPI}/v1/user/ids?#{params.map{|k,v| "#{k}=#{v}"} * '&' }"
  RestClient.get(request_url, Authorization: authorization)
end

.logout(access_token) ⇒ Object



5
6
7
8
9
10
# File 'lib/v1/kakao_user.rb', line 5

def self.logout(access_token)
  authorization = "Bearer #{access_token}"

  request_url = "#{HOST_KAPI}/v1/user/logout"
  RestClient.post(request_url, nil, Authorization: authorization)
end

.me(access_token, property_keys = [], secure_resource = false, user_id = 0) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/v1/kakao_user.rb', line 30

def self.me(access_token, property_keys = [], secure_resource = false, user_id = 0)
  authorization = "Bearer #{access_token}"
  params = {
    propertyKeys: property_keys,
    secure_resource: secure_resource
  }
  if user_id > 0
    params[:target_id_type] = 'user_id'
    params[:target_id] = user_id
  end

  request_url = "#{HOST_KAPI}/v1/user/me"
  RestClient.post(request_url, params, Authorization: authorization)
end

.signup(access_token, properties = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/v1/kakao_user.rb', line 12

def self.(access_token, properties = {})
  authorization = "Bearer #{access_token}"

  query_params = {
    properties: properties.to_json
  }

  request_url = "#{HOST_KAPI}/v1/user/signup"
  RestClient.post(request_url, query_params, Authorization: authorization)
end


23
24
25
26
27
28
# File 'lib/v1/kakao_user.rb', line 23

def self.unlink(access_token)
  authorization = "Bearer #{access_token}"

  request_url = "#{HOST_KAPI}/v1/user/unlink"
  RestClient.post(request_url, nil, Authorization: authorization)
end

.update_profile(access_token, props = {}) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/v1/kakao_user.rb', line 45

def self.update_profile(access_token, props = {})
  authorization = "Bearer #{access_token}"
  params = {
    properties: props.to_json
  }
  request_url = "#{HOST_KAPI}/v1/user/update_profile"
  RestClient.post(request_url, params, Authorization: authorization)
end