Class: Webex::User::Activation

Inherits:
Object
  • Object
show all
Includes:
Webex, Webex::User
Defined in:
lib/webex/user/activation.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 = {}) ⇒ Activation

Returns a new instance of Activation.



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

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

Instance Attribute Details

#back_urlObject

Returns the value of attribute back_url.



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

def back_url
  @back_url
end

#partner_idObject

Returns the value of attribute partner_id.



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

def partner_id
  @partner_id
end

#webex_idObject

Returns the value of attribute webex_id.



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

def webex_id
  @webex_id
end

Instance Method Details

#activateObject



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

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

#deactivateObject



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

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

#generate_params(overwrite_params = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/webex/user/activation.rb', line 25

def generate_params(overwrite_params = {})
  result = {}
  result[:AT] = overwrite_params[:api_type]
  result[:WID] = webex_id
  result[:PID] = partner_id
  result[:BU] = back_url
  result.delete_if { |k, v| v.nil? }
end