Class: Alula::User

Inherits:
RestResource show all
Extended by:
ApiOperations::List, ApiOperations::Request, ApiOperations::Save, RelationshipAttributes, ResourceAttributes
Defined in:
lib/alula/resources/user.rb

Instance Attribute Summary

Attributes inherited from ApiResource

#dirty_attributes, #errors, #id, #link_matchers, #links, #rate_limit, #raw_data, #values

Instance Method Summary collapse

Methods included from ResourceAttributes

date_fields, extended, field, field_names, filterable_fields, get_fields, get_http_methods, get_resource_path, get_type, http_methods, param_key, read_only_attributes, resource_path, sortable_fields, type

Methods included from RelationshipAttributes

check_relationship!, extended, get_relationship, get_relationships, relationship, relationship_exists?

Methods included from ApiOperations::Request

build_and_merge_item_relationships, extended, retrieve

Methods included from ApiOperations::List

build_and_merge_list_relationships, extended, list, method_missing

Methods included from ApiOperations::Save

extended

Methods inherited from RestResource

resource_url, #resource_url

Methods inherited from ApiResource

#annotate_errors, #apply_attributes, #as_json, #as_patchable_json, build, #cache_links, class_name, #clone, #construct_from, #dirty?, #errors?, #filter_builder, #initialize, #model_name, #reconstruct_from, #refresh

Constructor Details

This class inherits a constructor from Alula::ApiResource

Instance Method Details

#hidden?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/alula/resources/user.rb', line 216

def hidden?
  hidden == '1'
end

#user_roleObject



220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/alula/resources/user.rb', line 220

def user_role
  # pre-alula api users will be u_type 32, newer ones are 96. need to differentiate
  # between account users and account owners by checking if they own themselves
  {
    2 => :system,
    4 => :station,
    8 => :dealer,
    16 => :technician,
    32 => :user,
    64 => :sub_user,
    96 => :account_user,
    320 => :local_access_user
  }[(u_type == 96 && parent_id == id ? 32 : u_type)]
end

#user_role_nameObject



235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/alula/resources/user.rb', line 235

def user_role_name
  {
    system: 'System',
    station: 'Station',
    dealer: 'Dealer',
    technician: 'Technician',
    user: 'Account Owner',
    sub_user: 'Sub-User',
    account_user: 'Account User',
    local_access_user: 'Local Access User'
  }[user_role]
end