class Megam::Account
Attributes
api_key[RW]
approval[RW]
code[RW]
dates[RW]
email[RW]
id[RW]
json_claz[RW]
links[RW]
more[RW]
msg[RW]
msg_type[RW]
name[RW]
password[RW]
phone[RW]
registration_ip_address[RW]
some_msg[RW]
states[RW]
suspend[RW]
user_email[RW]
Public Class Methods
create(o)
click to toggle source
# File lib/megam/core/account.rb, line 161 def self.create(o) acct = from_hash(o) acct.create end
forgot(o)
click to toggle source
# File lib/megam/core/account.rb, line 189 def self.forgot(o) acct = from_hash(o) acct.forgot end
from_hash(o)
click to toggle source
# File lib/megam/core/account.rb, line 107 def self.from_hash(o) acct = new(email: o[:email], api_key: o[:api_key], host: o[:host], password_hash: o[:password_hash], org_id: o[:org_id]) acct.from_hash(o) acct end
json_create(o)
click to toggle source
# File lib/megam/core/account.rb, line 74 def self.json_create(o) acct = new() o.symbolize_keys! o = o[:results] if o.has_key?(:results) o.each { |k, v| acct.send("#{k}=", v) } acct.some_msg[:code] = @code if @code acct.some_msg[:msg_type] = @msg_type if @msg_type acct.some_msg[:msg] = @msg if @msg acct.some_msg[:more] = @more if @more acct.some_msg[:links] = @links if @links acct end
list(o)
click to toggle source
# File lib/megam/core/account.rb, line 175 def self.list(o) acct = from_hash(o) acct.list end
login(o)
click to toggle source
# File lib/megam/core/account.rb, line 151 def self.login(o) acct = from_hash(o) acct.login end
new(o={})
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/account.rb, line 19 def initialize(o={}) @id = nil @email = nil @user_email = nil @api_key = nil @name = {} @phone = {} @password = {} @states = {} @approval = {} @suspend = {} @dates = {} @some_msg = {} super({ email: o[:email], api_key: o[:api_key], host: o[:host], password_hash: o[:password_hash], org_id: o[:org_id] }) end
password_reset(o)
click to toggle source
# File lib/megam/core/account.rb, line 203 def self.password_reset(o) acct = from_hash(o) acct.password_reset end
remove(o)
click to toggle source
# File lib/megam/core/account.rb, line 194 def self.remove(o) acct = from_hash(o) acct.remove end
show(o)
click to toggle source
# File lib/megam/core/account.rb, line 170 def self.show(o) acct = from_hash(o) acct.megam_rest.get_accounts(o[:email]) end
update(o)
click to toggle source
# File lib/megam/core/account.rb, line 184 def self.update(o) acct = from_hash(o) acct.update end
Public Instance Methods
account()
click to toggle source
# File lib/megam/core/account.rb, line 37 def account self end
create()
click to toggle source
# File lib/megam/core/account.rb, line 166 def create megam_rest.post_accounts(to_hash) end
error?()
click to toggle source
# File lib/megam/core/account.rb, line 49 def error? crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error' end
expanded()
click to toggle source
Can be used by the calling classes to get the full hash
(eg: Nilavu: User model)
# File lib/megam/core/account.rb, line 93 def expanded h = Hash.new [:id, :email, :api_key, :name, :phone, :password,:states, :approval, :suspend, :registration_ip_address, :dates, :some_msg].each do |setting| if grouped = self.send("#{setting}").is_a?(Hash) self.send("#{setting}").each {|k,v| h[k.to_sym] = v} else h[setting] = self.send("#{setting}") end end h end
for_json()
click to toggle source
# File lib/megam/core/account.rb, line 57 def for_json result = { 'id' => @id, 'email' => @email, 'api_key' => @api_key, 'name' => @name, 'phone' => @phone, 'password' => @password, 'states' => @states, 'approval' => @approval, 'suspend' => @suspend, 'registration_ip_address' => @registration_ip_address, 'dates' => @dates } result end
forgot()
click to toggle source
# File lib/megam/core/account.rb, line 212 def forgot megam_rest.forgot(to_hash) end
from_hash(o)
click to toggle source
# File lib/megam/core/account.rb, line 113 def from_hash(o) @id = o[:id] if o.key?(:id) @email = o[:email] if o.key?(:email) @user_email = o[:user_email] if o.key?(:user_email) @api_key = o[:api_key] if o.key?(:api_key) @name[:first_name] = o[:first_name] if o.key?(:first_name) @name[:last_name] = o[:last_name] if o.key?(:last_name) @phone[:phone] = o[:phone] if o.key?(:phone) @phone[:phone_verified] = o[:phone_verified] if o.key?(:phone_verified) @password[:password_hash] = o[:password_hash] if o.key?(:password_hash) @password[:password_reset_key] = o[:password_reset_key] if o.key?(:password_reset_key) @password[:password_reset_sent_at] = o[:password_reset_sent_at] if o.key?(:password_reset_sent_at) @states[:authority] = o[:authority] if o.key?(:authority) @states[:active] = o[:active] if o.key?(:active) @states[:blocked] = o[:blocked] if o.key?(:blocked) @states[:staged] = o[:staged] if o.key?(:staged) @approval[:approved] = o[:approved] if o.key?(:approved) @approval[:approved_by_id] = o[:approved_by_id] if o.key?(:approved_by_id) @approval[:approved_at] = o[:approved_at] if o.key?(:approved_at) @suspend[:suspended] = o[:suspended] if o.key?(:suspended) @suspend[:suspended_at] = o[:suspend] if o.key?(:suspended_at) @suspend[:suspended_till] = o[:suspended_till] if o.key?(:suspended_till) @registration_ip_address = o[:registration_ip_address] if o.key?(:registration_ip_address) @dates[:last_posted_at] = o[:last_posted_at] if o.key?(:last_posted_at) @dates[:last_emailed_at] = o[:last_emailed_at] if o.key?(:last_emailed_at) @dates[:previous_visit_at] = o[:previous_visit_at] if o.key?(:previous_visit_at) @dates[:first_seen_at] = o[:first_seen_at] if o.key?(:first_seen_at) @dates[:created_at] = o[:created_at] if o.key?(:created_at) self end
list()
click to toggle source
# File lib/megam/core/account.rb, line 180 def list megam_rest.list_accounts end
login()
click to toggle source
# File lib/megam/core/account.rb, line 156 def login megam_rest.login(to_hash) end
password_reset()
click to toggle source
# File lib/megam/core/account.rb, line 216 def password_reset megam_rest.password_reset(to_hash) end
remove()
click to toggle source
# File lib/megam/core/account.rb, line 199 def remove megam_rest.delete_accounts(to_hash) end
to_json(*a)
click to toggle source
# File lib/megam/core/account.rb, line 53 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/account.rb, line 220 def to_s Megam::Stuff.styled_hash(to_hash) end
update()
click to toggle source
# File lib/megam/core/account.rb, line 208 def update megam_rest.update_accounts(to_hash) end
Private Instance Methods
to_hash()
click to toggle source
# File lib/megam/core/account.rb, line 226 def to_hash h = Hash.new h['json_claz'] = self.class.name h['id'] = @id h['email'] = @email h['user_email'] = @user_email h['api_key'] = @api_key h['name'] = @name h['phone'] = @phone h['password'] = @password h['states'] = @states h['approval'] = @approval h['suspend'] = @suspend h['registration_ip_address'] = @registration_ip_address h['dates'] = @dates h['some_msg'] = some_msg h end