Class: ElephantDrive::ProvisioningService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/elephant-drive-service/provisioning_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from ResponseBuilder

#generate_add_customer_response, #generate_average_usage_report_response, #generate_usage_statistics

Methods included from MessageBuilder

#add_customer_message, #base_user_message, #check_username_availability_message, #customer_list_message, #deactivate_customer_message, #get_customer_list_by_reg_date_message, #modify_subscription_message, #reactivate_customer_message, #reset_password_message, #search_customer_message

Constructor Details

This class inherits a constructor from ElephantDrive::BaseService

Instance Method Details

#add_a_customer(customer) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/elephant-drive-service/provisioning_service.rb', line 6

def add_a_customer customer
  add_extractor = execute(:add_customer_with_partner_billing) {
    { message: add_customer_message(customer, @config.campaign_id), soap_action: 'http://svc.elephantdrive.com/ese/AddCustomerWithPartnerBillingCustomTrack' }
  }.ending_with(:custom_track)

  generate_add_customer_response add_extractor, generate_reset_password_token(add_extractor[:g_user_id])
end

#deactivate_customer(provisioning) ⇒ Object



20
21
22
23
24
# File 'lib/elephant-drive-service/provisioning_service.rb', line 20

def deactivate_customer provisioning
  execute! :deactivate_customer do
    deactivate_customer_message provisioning.installed_user_id
  end
end

#delete_customer(provisioning) ⇒ Object



32
33
34
35
36
# File 'lib/elephant-drive-service/provisioning_service.rb', line 32

def delete_customer provisioning
  execute! :deactivate_customer do
    deactivate_customer_message(provisioning.installed_user_id).merge('asAcctState' => 'CancelledbyAccountAdministrator')
  end
end

#get_user_usage(provisioning) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/elephant-drive-service/provisioning_service.rb', line 38

def get_user_usage provisioning
  extractor = execute :get_partner_user_usage do
    { message: base_user_message(provisioning) }
  end
  raise extractor[:state] unless extractor[:state] == 'OK'
  generate_usage_statistics extractor
end

#modify_subscription(provisioning, new_plan) ⇒ Object



14
15
16
17
18
# File 'lib/elephant-drive-service/provisioning_service.rb', line 14

def modify_subscription provisioning, new_plan
  execute! :modify_sub_with_partner_billing do
    modify_subscription_message(provisioning, new_plan)
  end
end

#reactivate_customer(provisioning) ⇒ Object



26
27
28
29
30
# File 'lib/elephant-drive-service/provisioning_service.rb', line 26

def reactivate_customer provisioning
  execute! :reactivate_customer do
    reactivate_customer_message provisioning
  end
end

#username_available?(email) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
# File 'lib/elephant-drive-service/provisioning_service.rb', line 46

def username_available? email
  extractor = execute(:check_username_availability) do
    { message: check_username_availability_message(email), soap_action: 'http://svc.elephantdrive.com/ese/SCheckUsernameAvailability' }
  end
  !extractor.starting_with(:s)[:result]
end