Class: Users::Profile

Inherits:
Object
  • Object
show all
Includes:
Common::Client::Concerns::ServiceStatus
Defined in:
app/services/users/profile.rb

Constant Summary collapse

HTTP_OK =
200
HTTP_SOME_ERRORS =
296

Constants included from Common::Client::Concerns::ServiceStatus

Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, session = nil) ⇒ Profile

Returns a new instance of Profile.



15
16
17
18
19
# File 'app/services/users/profile.rb', line 15

def initialize(user, session = nil)
  @user = validate!(user)
  @session = session || {}
  @scaffold = Users::Scaffold.new([], HTTP_OK)
end

Instance Attribute Details

#scaffoldObject (readonly)

Returns the value of attribute scaffold.



13
14
15
# File 'app/services/users/profile.rb', line 13

def scaffold
  @scaffold
end

#userObject (readonly)

Returns the value of attribute user.



13
14
15
# File 'app/services/users/profile.rb', line 13

def user
  @user
end

Instance Method Details

#pre_serializeStruct

Fetches and serializes all of the initialized user’s profile data that is returned in the ‘/v0/user’ endpoint.

If there are no external service errors, the status property is set to 200, and the ‘errors` property is set to nil.

If there are errors from any associated external services, the status property is set to 296, and serialized versions of the errors are added to the ‘errors` array.

Returns:

  • (Struct)

    A Struct composed of the fetched, serialized profile data.



33
34
35
36
37
# File 'app/services/users/profile.rb', line 33

def pre_serialize
  fetch_and_serialize_profile
  update_status_and_errors
  scaffold
end