Class: Latitude::API::Resources::UserProfile

Inherits:
SingletonAPIResource show all
Defined in:
lib/latitude/api/resources/user_profile.rb

Constant Summary

Constants inherited from APIResource

APIResource::READ_ONLY_ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#id, #meta, #path_params, #raw_data, #type

Class Method Summary collapse

Methods inherited from SingletonAPIResource

instance_url, #resource_url

Methods inherited from APIResource

#==, #[], #[]=, #as_json, #attributes, #changed?, class_url, config_source, construct_from, #delete, execute_request, extract_path_params, #hash, id_prefix, #initialize, #inspect, instance_url, #method_missing, path_param_keys, #refresh, resource_path, resource_type, #resource_url, #respond_to_missing?, #save, #to_h, #unsaved_attributes, with_config, #write_attribute

Methods included from Attributes::ClassMethods

#attribute, #attribute_specs

Methods included from Attributes::InstanceMethods

#attribute_spec, #read_attribute, #wrap_attribute

Constructor Details

This class inherits a constructor from Latitude::API::APIResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Latitude::API::APIResource

Instance Attribute Details

#created_atTime (readonly)

Returns:

  • (Time)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#emailString

Returns:

  • (String)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#first_nameString

Returns:

  • (String)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#last_login_atTime

Returns:

  • (Time)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#last_nameString

Returns:

  • (String)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#mfa_enabledBoolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#roleLatitude::API::Objects::Role



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

#updated_atTime (readonly)

Returns:

  • (Time)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/latitude/api/resources/user_profile.rb', line 22

class UserProfile < SingletonAPIResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :email, :string
  attribute :mfa_enabled, :boolean
  attribute :created_at, :time, read_only: true
  attribute :updated_at, :time, read_only: true
  attribute :last_login_at, :time
  attribute :role, Objects::Role

  resource_type "users"
  resource_path "/user/profile"

  class << self
    def retrieve(opts = {})
      parsed = execute_request(method: :get, path: resource_path, opts: opts)
      construct_from(parsed, opts: opts)
    end

    def update(id, params = {}, opts = {})
      body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
      parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                               body: body, opts: opts)
      construct_from(parsed, opts: opts)
    end
  end
end

Class Method Details

.retrieve(opts = {}) ⇒ Object



36
37
38
39
# File 'lib/latitude/api/resources/user_profile.rb', line 36

def retrieve(opts = {})
  parsed = execute_request(method: :get, path: resource_path, opts: opts)
  construct_from(parsed, opts: opts)
end

.update(id, params = {}, opts = {}) ⇒ Object



41
42
43
44
45
46
# File 'lib/latitude/api/resources/user_profile.rb', line 41

def update(id, params = {}, opts = {})
  body = JSONAPI.encode(type: resource_type, id: id, attributes: params)
  parsed = execute_request(method: :patch, path: "#{resource_path}/#{URI.encode_www_form_component(id)}",
                           body: body, opts: opts)
  construct_from(parsed, opts: opts)
end