class Passfort::Endpoint::Profiles

Public Class Methods

new(client) click to toggle source
# File lib/passfort/endpoint/profiles.rb, line 8
def initialize(client)
  @client = client
end

Public Instance Methods

collected_data(id) click to toggle source
# File lib/passfort/endpoint/profiles.rb, line 25
def collected_data(id)
  collected_data = @client.get("/profiles/#{id}/collected_data")
  resource_class(collected_data["entity_type"]).new(collected_data)
end
create(role:, collected_data: {}) click to toggle source
# File lib/passfort/endpoint/profiles.rb, line 12
def create(role:, collected_data: {})
  profile = @client.post(
    "/profiles",
    body: { role: role, collected_data: collected_data },
  )
  ::Passfort::Resource::Profile.new(profile)
end
find(id) click to toggle source
# File lib/passfort/endpoint/profiles.rb, line 20
def find(id)
  profile = @client.get("/profiles/#{id}")
  ::Passfort::Resource::Profile.new(profile)
end
update_collected_data(id, data) click to toggle source
# File lib/passfort/endpoint/profiles.rb, line 30
def update_collected_data(id, data)
  collected_data = @client.post("/profiles/#{id}/collected_data", body: data)
  resource_class(collected_data["entity_type"]).new(collected_data)
end

Private Instance Methods

resource_class(entity_type) click to toggle source
# File lib/passfort/endpoint/profiles.rb, line 37
def resource_class(entity_type)
  case entity_type
  when Passfort::EntityType::COMPANY then ::Passfort::Resource::CompanyData
  when Passfort::EntityType::INDIVIDUAL then ::Passfort::Resource::IndividualData
  else raise ArgumentError, "Invalid entity type #{entity_type.inspect}"
  end
end