class KakaoRestApi
Constants
- HOST_KAPI
- HOST_KAUTH
Attributes
admin_key[RW]
app_key[RW]
redirect_uri[RW]
Public Class Methods
new(app_key, admin_key, redirect_uri)
click to toggle source
# File lib/kakao_rest_api.rb, line 12 def initialize(app_key, admin_key, redirect_uri) self.app_key = app_key self.admin_key = admin_key self.redirect_uri = redirect_uri end
Public Instance Methods
access_token_info(access_token)
click to toggle source
# File lib/kakao_rest_api.rb, line 76 def access_token_info(access_token) KakaoUser.access_token_info access_token end
delete_my_story(access_token, id)
click to toggle source
# File lib/kakao_rest_api.rb, line 113 def delete_my_story(access_token, id) Story.delete_my_story access_token, id end
is_story_user?(access_token)
click to toggle source
# File lib/kakao_rest_api.rb, line 80 def is_story_user?(access_token) Story.story_user? access_token end
link_info(access_token, url)
click to toggle source
# File lib/kakao_rest_api.rb, line 130 def link_info(access_token, url) Story.link_info access_token, url end
login(state = nil, encode_state = false)
click to toggle source
# File lib/kakao_rest_api.rb, line 22 def login(state = nil, encode_state = false) response_type = 'code' path = "/oauth/authorize?client_id=#{app_key}&redirect_uri=#{redirect_uri}&response_type=#{response_type}" path.concat("&state=#{state}") unless state.nil? path.concat('&encode_state=true') if encode_state "#{HOST_KAUTH}#{path}" end
logout(access_token)
click to toggle source
# File lib/kakao_rest_api.rb, line 52 def logout(access_token) KakaoUser.logout access_token end
me(access_token, property_keys = [], secure_resource = false)
click to toggle source
# File lib/kakao_rest_api.rb, line 64 def me(access_token, property_keys = [], secure_resource = false) KakaoUser.me access_token, property_keys, secure_resource end
my_stories(access_token, last_id)
click to toggle source
# File lib/kakao_rest_api.rb, line 109 def my_stories(access_token, last_id) Story.my_stories access_token, last_id end
my_story(access_token, story_id)
click to toggle source
# File lib/kakao_rest_api.rb, line 105 def my_story(access_token, story_id) Story.my_story access_token, story_id end
refresh_token(refresh_token)
click to toggle source
# File lib/kakao_rest_api.rb, line 42 def refresh_token(refresh_token) query_params = { grant_type: 'refresh_token', client_id: app_key, refresh_token: refresh_token } request_url = "#{HOST_KAUTH}/oauth/token" RestClient.post(request_url, query_params) end
signup(access_token, properties = {})
click to toggle source
# File lib/kakao_rest_api.rb, line 56 def signup(access_token, properties = {}) KakaoUser.signup access_token, properties end
story_post(access_token, type, required_params, options = {})
click to toggle source
# File lib/kakao_rest_api.rb, line 88 def story_post(access_token, type, required_params, options = {}) required_params[:access_token] = access_token case type when Story::POST_TYPE_NOTE Story.post_note required_params, options when Story::POST_TYPE_IMAGE file_paths = required_params[:image_url_list] required_params[:image_url_list] = upload_multi(access_token, file_paths) Story.post_photo required_params, options when Story::POST_TYPE_LINK url = required_params[:url] required_params[:link_info] = link_info(access_token, url) Story.post_link required_params, options end end
story_profile(access_token, secure_resource = false)
click to toggle source
# File lib/kakao_rest_api.rb, line 84 def story_profile(access_token, secure_resource = false) Story.story_profile access_token, secure_resource end
talk_profile(access_token, secure_resource = false)
click to toggle source
# File lib/kakao_rest_api.rb, line 117 def talk_profile(access_token, secure_resource = false) Talk.talk_profile access_token, secure_resource end
token()
click to toggle source
# File lib/kakao_rest_api.rb, line 31 def token query_params = { grant_type: 'authorization_code', client_id: app_key, redirect_uri: redirect_uri, code: authorize_code } request_url = "#{HOST_KAUTH}/oauth/token" RestClient.post(request_url, query_params) end
unlink(access_token)
click to toggle source
# File lib/kakao_rest_api.rb, line 60 def unlink(access_token) KakaoUser.unlink access_token end
update_profile(access_token, props = {})
click to toggle source
# File lib/kakao_rest_api.rb, line 68 def update_profile(access_token, props = {}) KakaoUser.update_profile access_token, props end
upload_multi(access_token, file_paths)
click to toggle source
# File lib/kakao_rest_api.rb, line 121 def upload_multi(access_token, file_paths) files = [] file_paths.each do |path| files << File.new(path, 'rb') end Story.upload_multi access_token, files end
user_ids(limit = 100, from_id = 0, order = 'asc')
click to toggle source
# File lib/kakao_rest_api.rb, line 72 def user_ids(limit = 100, from_id = 0, order = 'asc') KakaoUser.ids admin_key, limit, from_id, order end