module MnoEnterprise::Concerns::Models::Organization
Schema Information¶ ↑
Endpoint:
- /v1/organizations - /v1/users/:user_id/organizations id :integer not null, primary key uid :string(255) name :string(255) created_at :datetime not null updated_at :datetime not null account_frozen :boolean default(FALSE) free_trial_end_at :datetime soa_enabled :boolean default(TRUE) mails :text logo :string(255) latitude :float default(0.0) longitude :float default(0.0) geo_country_code :string(255) geo_state_code :string(255) geo_city :string(255) geo_tz :string(255) geo_currency :string(255) meta_data :text industry :string(255) size :string(255)
Public Instance Methods
add_user(user,role = 'Member')
click to toggle source
Add a user to the organization with the provided role TODO: specs
# File lib/mno_enterprise/concerns/models/organization.rb, line 90 def add_user(user,role = 'Member') self.users.create(id: user.id, role: role) end
has_credit_card_details?()
click to toggle source
# File lib/mno_enterprise/concerns/models/organization.rb, line 127 def has_credit_card_details? credit_card.persisted? end
last_invoice()
click to toggle source
# File lib/mno_enterprise/concerns/models/organization.rb, line 94 def last_invoice inv = self.raw_last_invoice inv.id ? inv : nil end
members(show_staged=false)
click to toggle source
¶ ↑
Instance methods
¶ ↑
Return the list of users + active invites TODO: specs @params [Boolean] show_staged Also displayed staged invites (ie: not sent)
# File lib/mno_enterprise/concerns/models/organization.rb, line 83 def members(show_staged=false) invites = show_staged ? self.org_invites.active_or_staged : self.org_invites.active [self.users, invites.to_a].flatten end
payment_restriction()
click to toggle source
# File lib/mno_enterprise/concerns/models/organization.rb, line 123 def payment_restriction meta_data && meta_data['payment_restriction'] end
remove_user(user)
click to toggle source
Remove a user from the organization TODO: specs
# File lib/mno_enterprise/concerns/models/organization.rb, line 105 def remove_user(user) self.users.destroy(id: user.id) end
to_audit_event()
click to toggle source
# File lib/mno_enterprise/concerns/models/organization.rb, line 115 def to_audit_event { id: id, uid: uid, name: name } end
update_user(user, role = 'Member')
click to toggle source
Change a user role in the organization TODO: specs
# File lib/mno_enterprise/concerns/models/organization.rb, line 111 def update_user(user, role = 'Member') self.users.update(id: user.id, role: role) end