Class: Webex::User::Partner

Inherits:
Object
  • Object
show all
Includes:
Webex, Webex::User
Defined in:
lib/webex/user/partner.rb

Overview

comment

Constant Summary

Constants included from Webex::User

PATH_URL

Constants included from Webex

CONFIGURATION, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Webex::User

#post_url

Methods included from Webex

#env_attributes!, #option_required!

Constructor Details

#initialize(attributes = {}) ⇒ Partner

Returns a new instance of Partner.



9
10
11
12
13
# File 'lib/webex/user/partner.rb', line 9

def initialize(attributes = {})
  attributes.each { |k, v| send("#{k}=", v) }
  env_attributes!
  option_required! :webex_id, :back_type, :back_url
end

Instance Attribute Details

#back_typeObject

Returns the value of attribute back_type.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def back_type
  @back_type
end

#back_urlObject

Returns the value of attribute back_url.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def back_url
  @back_url
end

#emailObject

Returns the value of attribute email.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def last_name
  @last_name
end

#new_passwordObject

Returns the value of attribute new_password.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def new_password
  @new_password
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def password
  @password
end

#sessionObject

Returns the value of attribute session.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def session
  @session
end

#ticketObject

Returns the value of attribute ticket.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def ticket
  @ticket
end

#webex_idObject

Returns the value of attribute webex_id.



7
8
9
# File 'lib/webex/user/partner.rb', line 7

def webex_id
  @webex_id
end

Instance Method Details

#generate_params(overwrite_params = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/webex/user/partner.rb', line 25

def generate_params(overwrite_params = {})
  result = {}
  result[:AT] = overwrite_params[:api_type]
  result[:WID] = webex_id
  result[:MU] = back_type
  result[:BU] = back_url

  if result[:AT] == 'LI'
    result[:TK] = ticket
    result[:PW] = password
    result[:EM] = email
    result[:SK] = session
    result[:FN] = first_name
    result[:LN] = last_name
    result[:NPW] = new_password
  end
  result.delete_if { |k, v| v.nil? }
end

#loginObject



15
16
17
18
# File 'lib/webex/user/partner.rb', line 15

def 
  res = Net::HTTP.post_form post_url, generate_params(api_type: 'LI')
  Hash[res.body.stringify_string.split('&').map! { |i| i.split('=') }]
end

#logoutObject



20
21
22
23
# File 'lib/webex/user/partner.rb', line 20

def logout
  res = Net::HTTP.post_form post_url, generate_params(api_type: 'LO')
  Hash[res.body.stringify_string.split('&').map! { |i| i.split('=') }]
end