Class: Racked
- Inherits:
-
Object
- Object
- Racked
- Defined in:
- lib/racked.rb
Instance Attribute Summary collapse
-
#secret_hash ⇒ Object
include Singleton.
-
#server_host ⇒ Object
include Singleton.
-
#user_key ⇒ Object
include Singleton.
-
#version_prefix ⇒ Object
include Singleton.
Instance Method Summary collapse
- #add_customer(options) ⇒ Object
- #add_domain(options) ⇒ Object
- #create_mailbox(options) ⇒ Object
- #delete_customer(options) ⇒ Object
- #delete_domain(options) ⇒ Object
- #delete_mailbox(options) ⇒ Object
- #get_domain_info(options) ⇒ Object
- #get_last_login(account_details_for_soap = {}, mailbox) ⇒ Object
- #get_mailbox_details(options) ⇒ Object
- #get_mailboxes(size = 50, offset = 0) ⇒ Object
-
#initialize(options) ⇒ Racked
constructor
A new instance of Racked.
- #update_mailbox(options) ⇒ Object
Constructor Details
#initialize(options) ⇒ Racked
Returns a new instance of Racked.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/racked.rb', line 37 def initialize() (, [:server_host, :version_prefix, :user_key, :secret_hash]) @server_host = [:server_host] @version_prefix = [:version_prefix] @user_key = [:user_key] @secret_hash = [:secret_hash] #read config file # @server = Server.new(MAIL_CFG["server"], MAIL_CFG["version_prefix"], MAIL_CFG["user_key"], MAIL_CFG["secret_hash"]) @server = Server.new([:server_host], [:version_prefix], [:user_key], [:secret_hash]) @server.xml_format end |
Instance Attribute Details
#secret_hash ⇒ Object
include Singleton
35 36 37 |
# File 'lib/racked.rb', line 35 def secret_hash @secret_hash end |
#server_host ⇒ Object
include Singleton
35 36 37 |
# File 'lib/racked.rb', line 35 def server_host @server_host end |
#user_key ⇒ Object
include Singleton
35 36 37 |
# File 'lib/racked.rb', line 35 def user_key @user_key end |
#version_prefix ⇒ Object
include Singleton
35 36 37 |
# File 'lib/racked.rb', line 35 def version_prefix @version_prefix end |
Instance Method Details
#add_customer(options) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/racked.rb', line 143 def add_customer() (, [:data_fields_hash]) #add a customer account response = @server.post "/customers", @data_fields_hash, @server.json_format return response end |
#add_domain(options) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/racked.rb', line 154 def add_domain() (, [:domain, :customer_number, :data_fields_hash]) #add a domain response = @server.post "/customers/#{@customer_number}/domains/#{@domain}", @data_fields_hash, @server.json_format return response end |
#create_mailbox(options) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/racked.rb', line 110 def create_mailbox() (, [:domain, :customer_number, :mailbox_type, :mailbox, :data_fields_hash]) #create a customer mailbox response = @server.post "/customers/#{@customer_number}/domains/#{@domain}/#{@mailbox_type}/mailboxes/#{@mailbox}", @data_fields_hash, @server.json_format # puts response.inspect # puts response['x-error-message'] # puts response.body.inspect return response #response = JSON.parse(response.body ) end |
#delete_customer(options) ⇒ Object
149 150 151 152 153 |
# File 'lib/racked.rb', line 149 def delete_customer() (, [:customer_number]) response = @server.delete "/customers/#{@customer_number}", @server.json_format return response end |
#delete_domain(options) ⇒ Object
160 161 162 163 164 |
# File 'lib/racked.rb', line 160 def delete_domain() (, [:domain, :customer_number]) response = @server.delete "/customers/#{@customer_number}/domains/#{@domain}", @server.json_format return response end |
#delete_mailbox(options) ⇒ Object
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/racked.rb', line 132 def delete_mailbox() #delete a customer mailbox (, [:domain, :customer_number, :mailbox_type, :mailbox]) response = @server.delete "/customers/#{@customer_number}/domains/#{@domain}/#{@mailbox_type}/mailboxes/#{@mailbox}", @server.json_format # puts response.inspect # puts response['x-error-message'] # puts response.body.inspect return response #response = JSON.parse(response.body ) end |
#get_domain_info(options) ⇒ Object
50 51 52 53 |
# File 'lib/racked.rb', line 50 def get_domain_info() (, [:domain, :customer_number]) response = @server.get "/customers/#{@customer_number}/domains/#{@domain}", @server.json_format end |
#get_last_login(account_details_for_soap = {}, mailbox) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/racked.rb', line 95 def get_last_login(account_details_for_soap = {}, mailbox) #TO DO: need to rethink (, [:mailbox]) self.account_details_for_soap([:account_details]) 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 |
#get_mailbox_details(options) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/racked.rb', line 77 def get_mailbox_details() (, [:domain, :customer_number, :mailbox_type, :mailbox]) #get mailbox details response = @server.get "/customers/#{@customer_number}/domains/#{@domain}/#{@mailbox_type}/mailboxes/" + @mailbox, @server.json_format puts response.inspect puts response['x-error-message'] # response = JSON.parse(response) puts response.code puts response.body # puts response.inspect #TO DO: error checking # returning [] do |mailboxes| # response["rsMailboxes"].each {|c| mailboxes << Mailbox.new(c) } # end return response end |
#get_mailboxes(size = 50, offset = 0) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/racked.rb', line 55 def get_mailboxes(size=50, offset=0) (, [:domain, :customer_number, :mailbox_type]) size = [:size] || 50 offset = [:offset] || 0 #get customer list response = @server.get "/customers/#{@customer_number}/domains/#{@domain}/#{@mailbox_type}/mailboxes/?size=" + size.to_s + '&offset=' + offset.to_s, @server.json_format puts response.inspect # puts response['x-error-message'] # puts response.body response = JSON.parse(response.body ) # puts response.inspect #TO DO: error checking # returning [] do |mailboxes| # response["rsMailboxes"].each {|c| mailboxes << Mailbox.new(c) } # end mailboxes = [] response["rsMailboxes"].each do |mailbox| puts 'mailbox - ' + mailbox["name"] #mailboxes << Mailbox.new(mailbox) mailboxes << mailbox end end |
#update_mailbox(options) ⇒ Object
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/racked.rb', line 121 def update_mailbox() (, [:domain, :customer_number, :mailbox_type, :mailbox, :data_fields_hash]) #update a customer mailbox response = @server.put "/customers/#{@customer_number}/domains/#{@domain}/#{@mailbox_type}/mailboxes/#{@mailbox}", @data_fields_hash, @server.json_format # puts response.inspect # puts response['x-error-message'] # puts response.body.inspect return response #response = JSON.parse(response.body ) end |