Class: Typetalk::Api

Inherits:
Object
  • Object
show all
Includes:
Auth, Mention, Message, Notification, Topic, User, Connection
Defined in:
lib/typetalk/api.rb,
lib/typetalk/api/auth.rb,
lib/typetalk/api/user.rb,
lib/typetalk/api/topic.rb,
lib/typetalk/api/mention.rb,
lib/typetalk/api/message.rb,
lib/typetalk/api/notification.rb

Defined Under Namespace

Modules: Auth, Mention, Message, Notification, Topic, User

Instance Attribute Summary

Attributes included from Auth

#authorization_code

Instance Method Summary collapse

Methods included from Notification

#accept_team, #accept_topic, #decline_team, #decline_topic, #get_notifications, #get_notifications_status, #read_notifications

Methods included from Mention

#get_mentions, #read_mention

Methods included from Message

#get_message, #like_message, #post_message, #read_message, #remove_message, #unlike_message, #upload_attachment

Methods included from Topic

#favorite_topic, #get_topic, #get_topic_members, #get_topics, #unfavorite_topic

Methods included from User

#get_profile

Methods included from Auth

authorize_url, #get_access_token, #update_access_token

Instance Method Details

#access_tokenObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/typetalk/api.rb', line 17

def access_token
  if @access_token.nil?
    @access_token = get_access_token
    @access_token.expire_time = Time.now.to_i + @access_token.expires_in.to_i
  elsif Time.now.to_i >= @access_token.expire_time
    @access_token = update_access_token(@access_token.refresh_token)
    @access_token.expire_time = Time.now.to_i + @access_token.expires_in.to_i
  end
  @access_token.access_token
end