Class: Webex::User::Activation
- Inherits:
-
Object
- Object
- Webex::User::Activation
- Includes:
- Webex, Webex::User
- Defined in:
- lib/webex/user/activation.rb
Overview
comment
Constant Summary
Constants included from Webex::User
Constants included from Webex
Instance Attribute Summary collapse
-
#back_url ⇒ Object
Returns the value of attribute back_url.
-
#partner_id ⇒ Object
Returns the value of attribute partner_id.
-
#webex_id ⇒ Object
Returns the value of attribute webex_id.
Instance Method Summary collapse
- #activate ⇒ Object
- #deactivate ⇒ Object
- #generate_params(overwrite_params = {}) ⇒ Object
-
#initialize(attributes = {}) ⇒ Activation
constructor
A new instance of Activation.
Methods included from Webex::User
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_url ⇒ Object
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_id ⇒ Object
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_id ⇒ Object
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
#activate ⇒ Object
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 |
#deactivate ⇒ Object
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 |