Class: CakeMail::Client
- Inherits:
-
Object
- Object
- CakeMail::Client
- Defined in:
- lib/cakemail/client.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#admin_email ⇒ Object
Returns the value of attribute admin_email.
-
#admin_first_name ⇒ Object
Returns the value of attribute admin_first_name.
-
#admin_language ⇒ Object
Returns the value of attribute admin_language.
-
#admin_last_name ⇒ Object
Returns the value of attribute admin_last_name.
-
#admin_mobile_phone ⇒ Object
Returns the value of attribute admin_mobile_phone.
-
#admin_office_phone ⇒ Object
Returns the value of attribute admin_office_phone.
-
#admin_password ⇒ Object
Returns the value of attribute admin_password.
-
#admin_title ⇒ Object
Returns the value of attribute admin_title.
-
#city ⇒ Object
Returns the value of attribute city.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#company_name ⇒ Object
Returns the value of attribute company_name.
-
#contact_email ⇒ Object
Returns the value of attribute contact_email.
-
#contact_first_name ⇒ Object
Returns the value of attribute contact_first_name.
-
#contact_id ⇒ Object
readonly
Returns the value of attribute contact_id.
-
#contact_language ⇒ Object
Returns the value of attribute contact_language.
-
#contact_last_name ⇒ Object
Returns the value of attribute contact_last_name.
-
#contact_mobile_phone ⇒ Object
Returns the value of attribute contact_mobile_phone.
-
#contact_office_phone ⇒ Object
Returns the value of attribute contact_office_phone.
-
#contact_password ⇒ Object
Returns the value of attribute contact_password.
-
#contact_timezone_id ⇒ Object
readonly
Returns the value of attribute contact_timezone_id.
-
#contact_title ⇒ Object
Returns the value of attribute contact_title.
-
#country_id ⇒ Object
readonly
Returns the value of attribute country_id.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#fax ⇒ Object
Returns the value of attribute fax.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_activity ⇒ Object
readonly
Returns the value of attribute last_activity.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#manager_id ⇒ Object
readonly
Returns the value of attribute manager_id.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#province_id ⇒ Object
readonly
Returns the value of attribute province_id.
-
#registered_date ⇒ Object
readonly
Returns the value of attribute registered_date.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
-
.create(args) ⇒ Object
Creates a new client.
-
.get_list(args) ⇒ Object
Retrieves the list of clients.
-
.get_timezones(user) ⇒ Object
Returns the list with the supported timezones.
Instance Method Summary collapse
-
#get_info(id = @id) ⇒ Object
Returns information about a client.
-
#initialize(id, user) ⇒ Client
constructor
A new instance of Client.
- #save ⇒ Object
-
#set_info(client_id = nil) ⇒ Object
Modifies a client.
Constructor Details
#initialize(id, user) ⇒ Client
Returns a new instance of Client.
35 36 37 38 39 |
# File 'lib/cakemail/client.rb', line 35 def initialize(id, user) @user = user @id = id get_info end |
Instance Attribute Details
#address1 ⇒ Object
Returns the value of attribute address1.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def address2 @address2 end |
#admin_email ⇒ Object
Returns the value of attribute admin_email.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_email @admin_email end |
#admin_first_name ⇒ Object
Returns the value of attribute admin_first_name.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_first_name @admin_first_name end |
#admin_language ⇒ Object
Returns the value of attribute admin_language.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_language @admin_language end |
#admin_last_name ⇒ Object
Returns the value of attribute admin_last_name.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_last_name @admin_last_name end |
#admin_mobile_phone ⇒ Object
Returns the value of attribute admin_mobile_phone.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_mobile_phone @admin_mobile_phone end |
#admin_office_phone ⇒ Object
Returns the value of attribute admin_office_phone.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_office_phone @admin_office_phone end |
#admin_password ⇒ Object
Returns the value of attribute admin_password.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_password @admin_password end |
#admin_title ⇒ Object
Returns the value of attribute admin_title.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def admin_title @admin_title end |
#city ⇒ Object
Returns the value of attribute city.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def city @city end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def client_id @client_id end |
#company_name ⇒ Object
Returns the value of attribute company_name.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def company_name @company_name end |
#contact_email ⇒ Object
Returns the value of attribute contact_email.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_email @contact_email end |
#contact_first_name ⇒ Object
Returns the value of attribute contact_first_name.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_first_name @contact_first_name end |
#contact_id ⇒ Object (readonly)
Returns the value of attribute contact_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def contact_id @contact_id end |
#contact_language ⇒ Object
Returns the value of attribute contact_language.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_language @contact_language end |
#contact_last_name ⇒ Object
Returns the value of attribute contact_last_name.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_last_name @contact_last_name end |
#contact_mobile_phone ⇒ Object
Returns the value of attribute contact_mobile_phone.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_mobile_phone @contact_mobile_phone end |
#contact_office_phone ⇒ Object
Returns the value of attribute contact_office_phone.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_office_phone @contact_office_phone end |
#contact_password ⇒ Object
Returns the value of attribute contact_password.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_password @contact_password end |
#contact_timezone_id ⇒ Object (readonly)
Returns the value of attribute contact_timezone_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def contact_timezone_id @contact_timezone_id end |
#contact_title ⇒ Object
Returns the value of attribute contact_title.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def contact_title @contact_title end |
#country_id ⇒ Object (readonly)
Returns the value of attribute country_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def country_id @country_id end |
#currency ⇒ Object
Returns the value of attribute currency.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def currency @currency end |
#fax ⇒ Object
Returns the value of attribute fax.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def fax @fax end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def id @id end |
#last_activity ⇒ Object (readonly)
Returns the value of attribute last_activity.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def last_activity @last_activity end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def limit @limit end |
#manager_id ⇒ Object (readonly)
Returns the value of attribute manager_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def manager_id @manager_id end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def parent_id @parent_id end |
#phone ⇒ Object
Returns the value of attribute phone.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def phone @phone end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def postal_code @postal_code end |
#province_id ⇒ Object (readonly)
Returns the value of attribute province_id.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def province_id @province_id end |
#registered_date ⇒ Object (readonly)
Returns the value of attribute registered_date.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def registered_date @registered_date end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
28 29 30 |
# File 'lib/cakemail/client.rb', line 28 def session @session end |
#website ⇒ Object
Returns the value of attribute website.
30 31 32 |
# File 'lib/cakemail/client.rb', line 30 def website @website end |
Class Method Details
.create(args) ⇒ Object
Creates a new client.
Arguments :
-
args = { :user => required, :company_name => required, :admin_email => required, :admin_first_name => required, :admin_last_name => required, :admin_password => required, :contact_email => required, :contact_first_name => required, :contact_last_name => required, :contact_password => required, :parent_id => optional, :currency => optional, :address1 => optional, :address2 => optionall, :city => optional, :province_id => optional, :country_id => optional, :postal_code => optional, :website => optional, :phone => optional, :fax => optional, :admin_title => optional, :admin_office_phone => required, :admin_mobile_phone => optional, :admin_language => optional, :contact_title => optional, :contact_language => optional, :contact_timezone_id => optional, :contact_office_phone => optional, :contact_mobile_phone => optional }
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cakemail/client.rb', line 102 def create(args) raise ArgumentError if args.nil? or args[:user].nil? or args[:company_name].nil? or args[:admin_email].nil? or args[:admin_first_name].nil? or args[:admin_last_name].nil? or args[:admin_password].nil? or args[:contact_email].nil? or args[:contact_first_name].nil? or args[:contact_last_name].nil? or args[:contact_password].nil? = { :company_name => args[:company_name], :admin_email => args[:admin_email], :admin_first_name => args[:admin_first_name], :admin_last_name => args[:admin_last_name], :admin_password => args[:admin_password], :admin_password_confirmation => args[:admin_password_confirmation], :contact_email => args[:contact_email], :contact_first_name => args[:contact_first_name], :contact_last_name => args[:contact_last_name], :contact_password => args[:contact_password], :contact_password_confirmation => args[:contact_password_confirmation] } [:parent_id] = args[:parent_id] unless args[:parent_id].nil? [:currency] = args[:currency] unless args[:currency].nil? [:address1] = args[:address1] unless args[:address1].nil? [:address2] = args[:address2] unless args[:address2].nil? [:city] = args[:city] unless args[:city].nil? [:province_id] = args[:province_id] unless args[:province_id].nil? [:postal_code] = args[:postal_code] unless args[:postal_code].nil? [:country_id] = args[:country_id] unless args[:country_id].nil? [:website] = args[:website] unless args[:website].nil? [:phone] = args[:phone] unless args[:phone].nil? [:fax] = args[:fax] unless args[:fax].nil? [:admin_title] = args[:admin_title] unless args[:admin_title].nil? [:admin_office_phone] = args[:admin_office_phone] unless args[:admin_office_phone].nil? [:admin_mobile_phone] = args[:admin_mobile_phone] unless args[:admin_mobile_phone].nil? [:admin_language] = args[:admin_language] unless args[:admin_language].nil? [:admin_timezone_id] =args[:admin_timezone_id] unless args[:admin_timezone_id].nil? [:admin_language] = args[:admin_language] unless args[:admin_language].nil? [:contact_title] = args[:contact_title] unless args[:contact_title].nil? [:contact_language] = args[:contact_language] unless args[:contact_language].nil? [:contact_timezone_id] = args[:contact_timezone_id] unless args[:contact_timezone_id].nil? [:contact_office_phone] = args[:contact_office_phone] unless args[:contact_office_phone].nil? [:contact_mobile_phone] = args[:contact_mobile_phone] unless args[:contact_mobile_phone].nil? res = args[:user].session.request("CakeMail::API::ClassClient", "Create", ) res = args[:user].session.request("CakeMail::API::ClassClient", "Activate", { :confirmation => res['confirmation'].first }) return Client.new(id, args[:user]) end |
.get_list(args) ⇒ Object
Retrieves the list of clients.
Arguments :
-
args = { :user => required, :count => optional, :status => optional, :limit => optional, :offset => optional }
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/cakemail/client.rb', line 141 def get_list(args) raise ArgumentError if args.nil? or args[:user].nil? = { :user_key => args[:user].user_key } [:count] = args[:count] unless args[:count].nil? [:status] = args[:status] unless args[:status].nil? [:limit] = args[:limit] unless args[:limit].nil? [:offset] = args[:offset] unless args[:offset].nil? res = args[:user].session.request("CakeMail::API::ClassClient", "GetList", ) if !args[:count].nil? return res['count'].first end return res['client'] end |
.get_timezones(user) ⇒ Object
Returns the list with the supported timezones.
155 156 157 158 |
# File 'lib/cakemail/client.rb', line 155 def get_timezones(user) res = user.session.request("CakeMail::API::ClassClient", "GetTimezones", {}) res['timezone'] end |
Instance Method Details
#get_info(id = @id) ⇒ Object
Returns information about a client.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cakemail/client.rb', line 41 def get_info(id = @id) @user.session.request("CakeMail::API::ClassClient", "GetInfo", { :client_id => @id, :user_key => @user.user_key }) @registered_date = res['registered_date'].first @last_activity = res['last_activity'].first @manager_id = res['manager_id'].first @parent_id = res['parent_id'].first @contact_id = res['contact_id'].first @province_id = res['province_id'].first @country_id = res['country_id'].first @limit = res['limit'].first @status = res['status'].first @currency = res['currency'].first @company_name = res['company_name'].first @address1 = res['address1'].first @address2 = res['address2'].first @city = res['city'].first @postal_code = res['postal_code'].first @website = res['website'].first @phone = res['phone'].first @fax = res['fax'].first end |
#save ⇒ Object
63 64 65 |
# File 'lib/cakemail/client.rb', line 63 def save set_info end |
#set_info(client_id = nil) ⇒ Object
Modifies a client.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cakemail/client.rb', line 67 def set_info(client_id = nil) args = { :user_key => @user.user_key } if !client_id.nil? args[:client_id] = client_id else args[:client_id] = @id unless @id.nil? end args[:status] = @status unless @status.nil? args[:manager_id] = @manager_id unless @manager_id.nil? args[:parent_id] = @parent_id unless @parent_id.nil? args[:contact_id] = @contact_id unless @contact_id.nil? args[:company_name] = @company_name unless @company_name.nil? args[:address1] = @address1 unless @address1.nil? args[:address2] = @address2 unless @address2.nil? args[:city] = @city unless @city.nil? args[:province_id] = @province_id unless @province_id.nil? args[:postal_code] = @postal_code unless @postal_code.nil? args[:country_id] = @country_id unless @country_id.nil? args[:website] = @website unless @website.nil? args[:phone] = @phone unless @phone.nil? args[:fax] = @fax unless @fax.nil? @user.session.request("CakeMail::API::ClassClient", "SetInfo", args) end |