Class: Teems::Models::Account

Inherits:
Data
  • Object
show all
Defined in:
lib/teems/models/account.rb

Overview

Represents a Teams account with authentication tokens

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, auth_token:, skype_token:, chatsvc_token: nil, presence_token: nil) ⇒ Account

Returns a new instance of Account.



7
8
9
10
11
12
13
14
15
16
# File 'lib/teems/models/account.rb', line 7

def initialize(name:, auth_token:, skype_token:, chatsvc_token: nil, presence_token: nil)
  validate_tokens!(auth_token, skype_token)
  super(
    name: name.to_s.freeze,
    auth_token: auth_token.to_s.freeze,
    skype_token: skype_token.to_s.freeze,
    chatsvc_token: chatsvc_token&.to_s&.freeze,
    presence_token: presence_token&.to_s&.freeze
  )
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token

Returns:

  • (Object)

    the current value of auth_token



6
7
8
# File 'lib/teems/models/account.rb', line 6

def auth_token
  @auth_token
end

#chatsvc_tokenObject (readonly)

Returns the value of attribute chatsvc_token

Returns:

  • (Object)

    the current value of chatsvc_token



6
7
8
# File 'lib/teems/models/account.rb', line 6

def chatsvc_token
  @chatsvc_token
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/teems/models/account.rb', line 6

def name
  @name
end

#presence_tokenObject (readonly)

Returns the value of attribute presence_token

Returns:

  • (Object)

    the current value of presence_token



6
7
8
# File 'lib/teems/models/account.rb', line 6

def presence_token
  @presence_token
end

#skype_tokenObject (readonly)

Returns the value of attribute skype_token

Returns:

  • (Object)

    the current value of skype_token



6
7
8
# File 'lib/teems/models/account.rb', line 6

def skype_token
  @skype_token
end

Instance Method Details

#chatsvc_auth_headerObject

Authorization header for chatsvcagg endpoints



29
30
31
32
33
# File 'lib/teems/models/account.rb', line 29

def chatsvc_auth_header
  return nil unless chatsvc_token

  "Bearer #{chatsvc_token}"
end

#skype_auth_headerObject

Authorization header for Skype/chat API endpoints



24
25
26
# File 'lib/teems/models/account.rb', line 24

def skype_auth_header
  "skypetoken=#{skype_token}"
end

#skype_headersObject

Headers for Skype API requests



44
45
46
47
48
49
# File 'lib/teems/models/account.rb', line 44

def skype_headers
  {
    'Authentication' => skype_auth_header,
    'Content-Type' => 'application/json'
  }
end

#teams_auth_headerObject

Authorization header for Teams API endpoints



19
20
21
# File 'lib/teems/models/account.rb', line 19

def teams_auth_header
  "Bearer #{auth_token}"
end

#teams_headersObject

Headers for Teams API requests



36
37
38
39
40
41
# File 'lib/teems/models/account.rb', line 36

def teams_headers
  {
    'Authorization' => teams_auth_header,
    'Content-Type' => 'application/json'
  }
end