Class: TokBoxer::User

Inherits:
Object
  • Object
show all
Defined in:
lib/TokBoxer/User.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jabberId, secret, api) ⇒ User

Returns a new instance of User.



8
9
10
11
12
13
# File 'lib/TokBoxer/User.rb', line 8

def initialize(jabberId, secret, api)
  @jabberId = jabberId
  @secret = secret
  @api = api
  self.
end

Instance Attribute Details

#jabberIdObject (readonly) Also known as: id

Returns the value of attribute jabberId.



5
6
7
# File 'lib/TokBoxer/User.rb', line 5

def jabberId
  @jabberId
end

#secretObject (readonly)

Returns the value of attribute secret.



5
6
7
# File 'lib/TokBoxer/User.rb', line 5

def secret
  @secret
end

Instance Method Details

#access_token_valid?Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/TokBoxer/User.rb', line 36

def access_token_valid?
  result = @api.validate_access_token(@jabberId, @secret)
  result['validateAccessToken'].first["isValid"].first == "true"
end

#create_call(full_name, persistent = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/TokBoxer/User.rb', line 22

def create_call(full_name,persistent=false)
  result = @api.create_call(@jabberId, full_name, persistent)
  if result['createCall'] and (createCall=result['createCall'].first)
    Call.new createCall['callerName'],
             createCall['callId'].first,
             createCall['callerJabberId'],
             createCall['persistent'],
             createCall['server'].first,
             @api
  else
    nil
  end
end

#display_nameObject



102
103
104
# File 'lib/TokBoxer/User.rb', line 102

def display_name
  info["displayName"].first
end

#is_online?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/TokBoxer/User.rb', line 98

def is_online?
  info["isOnline"].first == "true"
end

#loginObject

TODO add a method which calls get_request_token from the API to get the jabberId and secret from the email and password



18
19
20
# File 'lib/TokBoxer/User.rb', line 18

def 
  @api.(self.jabberId,self.secret)
end

#player_embed_code(messageId, width = "425", height = "344") ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/TokBoxer/User.rb', line 89

def player_embed_code(messageId, width="425", height="344")
  <<-END
  <object type="application/x-shockwave-flash" data="#{@api.api_server_url}#{API_SERVER_PLAYER_WIDGET}#{messageId}" width="#{width}" height="#{height}">
                  <param name="movie" value="#{@api.api_server_url}#{API_SERVER_PLAYER_WIDGET}#{messageId}" />
                  <param name="FlashVars" value="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}" />
   </object>
  END
end

#received_vmailsObject



65
66
67
# File 'lib/TokBoxer/User.rb', line 65

def received_vmails
  build_vmails_array("vmailRecv")
end

#recorder_embed_code(width = "322", height = "321", vmailToEmail = "") ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/TokBoxer/User.rb', line 69

def recorder_embed_code(width="322", height="321",vmailToEmail="")
  <<-END
  <object width="#{width}" height="#{height}">
    <param name="movie" value="#{@api.api_server_url}#{API_SERVER_RECORDER_WIDGET}"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowScriptAccess" value="true"></param>
    <param name="FlashVars" value="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}&offsiteAuth=true&vmailToEmail=#{vmailToEmail}"></param>
    <embed id="tbx_recorder" src="#{@api.api_server_url}#{API_SERVER_RECORDER_WIDGET}"
      type="application/x-shockwave-flash"
      allowfullscreen="true"
      allowScriptAccess="always"
      width="#{width}"
      height="#{height}"
      FlashVars="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}&offsiteAuth=true&vmailToEmail=#{vmailToEmail}"
    >
    </embed>
  </object>
  END
end

#sent_vmailsObject



61
62
63
# File 'lib/TokBoxer/User.rb', line 61

def sent_vmails
  build_vmails_array("vmailSent")
end

#showObject



114
115
116
# File 'lib/TokBoxer/User.rb', line 114

def show
  info["show"].first
end

#useridObject



110
111
112
# File 'lib/TokBoxer/User.rb', line 110

def userid
  info["userid"].first
end

#usernameObject



106
107
108
# File 'lib/TokBoxer/User.rb', line 106

def username
  info["username"].first
end

#vmailsObject



57
58
59
# File 'lib/TokBoxer/User.rb', line 57

def vmails
  build_vmails_array("all")
end