lib/racked.rb in racked-0.7.0 vs lib/racked.rb in racked-0.9.0

- old
+ new

@@ -1,10 +1,13 @@ # coding: utf-8 require 'json' # require './lib/racked/server.rb' #for dev +$:.unshift(File.dirname(__FILE__)) require 'racked/server.rb' #for release +require 'soap_api/mailaccountsDriver.rb' #soap client driver generated via wsdl2ruby.rb --wsdl https://admin.mailtrust.com/mailaccounts/mailaccounts.wsdl --type client + class RackMailbox attr_accessor :attributes @@ -57,11 +60,12 @@ puts 'mailbox - ' + mailbox["name"] #mailboxes << Mailbox.new(mailbox) mailboxes << mailbox end end - def get_mailbox_details(mailbox) + def get_mailbox_details(mailbox, account_details = {}) + self.check_account_details(account_details) #get mailbox details response = @server.get '/customers/856863/domains/econetmail.com/rs/mailboxes/' + mailbox, @server.json_format puts response.inspect puts response['x-error-message'] # response = JSON.parse(response) @@ -73,10 +77,22 @@ # response["rsMailboxes"].each {|c| mailboxes << Mailbox.new(c) } # end return response end + def get_last_login(account_details = {}, mailbox) + raise ArgumentError, "account_details hash must be supplied." unless !account_details.empty? + driver = UtilsSoapPort.new + # driver.wiredump_dev = STDOUT + + res = driver.GetUserLastLogin(account_details[:resellerUsername], account_details[:resellerPassword], account_details[:hostName], mailbox, account_details[:lastlogin]) + # if res[1].class == String && !res[1].empty? + # puts "yes" + # end + return res + end + def create_mailbox(msisdn_number, fields_array) #create a customer mailbox response = @server.post '/customers/856863/domains/econetmail.com/rs/mailboxes/' + msisdn_number, fields_array # puts response.inspect # puts response['x-error-message'] @@ -92,9 +108,26 @@ # puts response['x-error-message'] # puts response.body.inspect return response #response = JSON.parse(response.body ) end + + def delete_mailbox(msisdn) + #create a customer mailbox + response = @server.delete '/customers/856863/domains/econetmail.com/rs/mailboxes/' + msisdn + # puts response.inspect + # puts response['x-error-message'] + # puts response.body.inspect + return response + #response = JSON.parse(response.body ) + end + + private + def check_account_details(account_details) + raise ArgumentError, 'Argument missing! account_details[:customer_number] missing.' unless account_details[:customer_number].empty? || account_details.include?(:customer_number) + raise ArgumentError, 'Argument missing! account_details[:domain_name] missing.' unless account_details[:domain_name].empty? || account_details.include?(:domain_name) + end + end # api = Racked.instance # \ No newline at end of file