Class: MOCO::User
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::User
- Defined in:
- lib/moco/entities.rb,
lib/moco/entities/user.rb
Overview
Represents a MOCO user (staff member)
Required attributes for create:
firstname - String, first name
lastname - String, last name
email - String, email address (used for login)
unit_id - Integer, team/unit ID
Optional attributes:
password - String, initial password (if not set, user gets welcome email)
role_id - Integer, permission role ID
active - Boolean, whether user is active
external - Boolean, true for contractors/external staff
language - String, one of: "de", "de-AT", "de-CH", "en", "it", "fr"
mobile_phone - String, mobile phone number
work_phone - String, work phone number
home_address - String, home address (use \n for line breaks)
bday - String, birthday "YYYY-MM-DD"
iban - String, bank account IBAN
tags - Array of Strings, e.g., ["Developer", "Remote"]
custom_properties - Hash, e.g., {"Start Date": "2024-01-01"}
info - String, additional notes
welcome_email - Boolean, send welcome email (default: true if no password)
avatar - Hash, { filename: "photo.jpg", base64: "..." }
Read-only attributes:
id, avatar_url, unit (Hash), role (Hash), created_at, updated_at
Example:
moco.users.create(
firstname: "John",
lastname: "Doe",
email: "[email protected]",
unit_id: 123,
language: "en",
tags: ["Developer"]
)
Instance Attribute Summary collapse
-
#firstname ⇒ Object
Returns the value of attribute firstname.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lastname ⇒ Object
Returns the value of attribute lastname.
Attributes inherited from BaseEntity
Instance Method Summary collapse
-
#activities ⇒ Object
Associations.
- #employments ⇒ Object
- #full_name ⇒ Object
- #holidays ⇒ Object
-
#performance_report ⇒ Object
Instance methods for user-specific operations.
- #presences ⇒ Object
- #to_s ⇒ Object
- #unit ⇒ Object
- #work_time_adjustments ⇒ Object
Methods inherited from BaseEntity
#==, #association, #destroy, #eql?, #has_many, #hash, #initialize, #inspect, #reload, #save, #to_h, #to_json, #update
Constructor Details
This class inherits a constructor from MOCO::BaseEntity
Instance Attribute Details
#firstname ⇒ Object
Returns the value of attribute firstname.
91 92 93 |
# File 'lib/moco/entities.rb', line 91 def firstname @firstname end |
#id ⇒ Object
Returns the value of attribute id.
91 92 93 |
# File 'lib/moco/entities.rb', line 91 def id @id end |
#lastname ⇒ Object
Returns the value of attribute lastname.
91 92 93 |
# File 'lib/moco/entities.rb', line 91 def lastname @lastname end |
Instance Method Details
#activities ⇒ Object
Associations
49 50 51 |
# File 'lib/moco/entities/user.rb', line 49 def activities has_many(:activities) end |
#employments ⇒ Object
61 62 63 |
# File 'lib/moco/entities/user.rb', line 61 def employments has_many(:employments) end |
#full_name ⇒ Object
73 74 75 |
# File 'lib/moco/entities/user.rb', line 73 def full_name "#{firstname} #{lastname}" end |
#holidays ⇒ Object
57 58 59 |
# File 'lib/moco/entities/user.rb', line 57 def holidays has_many(:holidays) end |
#performance_report ⇒ Object
Instance methods for user-specific operations
44 45 46 |
# File 'lib/moco/entities/user.rb', line 44 def performance_report client.get("users/#{id}/performance_report") end |
#presences ⇒ Object
53 54 55 |
# File 'lib/moco/entities/user.rb', line 53 def presences has_many(:presences) end |
#to_s ⇒ Object
77 78 79 |
# File 'lib/moco/entities/user.rb', line 77 def to_s full_name end |
#unit ⇒ Object
69 70 71 |
# File 'lib/moco/entities/user.rb', line 69 def unit association(:unit) end |
#work_time_adjustments ⇒ Object
65 66 67 |
# File 'lib/moco/entities/user.rb', line 65 def work_time_adjustments has_many(:work_time_adjustments) end |