Class: GhostCrawl::ProfilesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ghostcrawl/client.rb

Overview

Manage identity profiles — /v1/profiles.

Instance Method Summary collapse

Constructor Details

#initialize(v1, adapter = nil) ⇒ ProfilesClient

Returns a new instance of ProfilesClient.



701
702
703
704
# File 'lib/ghostcrawl/client.rb', line 701

def initialize(v1, adapter = nil)
  @v1 = v1
  @adapter = adapter
end

Instance Method Details

#create(name:, **config) ⇒ Object

Create a new profile. Delegates to POST /v1/profiles via the generated ProfilesRequestBuilder.



720
721
722
723
# File 'lib/ghostcrawl/client.rb', line 720

def create(name:, **config)
  body = AdditionalDataBody.new({ "name" => name }.merge(config.transform_keys(&:to_s)))
  ResponseHelper.to_hash(@v1.profiles.post(body))
end

#delete(name) ⇒ Object

Delete a profile. Delegates to DELETE /v1/profiles/name via the generated builder. The endpoint answers 204 No Content; routing through ResponseHelper.void_request! avoids the Kiota JSON parser choking on the empty body.



735
736
737
# File 'lib/ghostcrawl/client.rb', line 735

def delete(name)
  ResponseHelper.void_request!(@adapter, @v1.profiles.by_name(name).to_delete_request_information(nil))
end

#get(name) ⇒ Object

Get a profile by name. Delegates to GET /v1/profiles/name via the generated builder.



714
715
716
# File 'lib/ghostcrawl/client.rb', line 714

def get(name)
  ResponseHelper.to_hash(@v1.profiles.by_name(name).get)
end

#listObject

List all profiles. Delegates to GET /v1/profiles via the generated ProfilesRequestBuilder.



708
709
710
# File 'lib/ghostcrawl/client.rb', line 708

def list
  ResponseHelper.to_hash(@v1.profiles.get)
end

#update(name, **config) ⇒ Object

Update a profile. Delegates to PUT /v1/profiles/name via the generated builder.



727
728
729
# File 'lib/ghostcrawl/client.rb', line 727

def update(name, **config)
  ResponseHelper.to_hash(@v1.profiles.by_name(name).put(AdditionalDataBody.new(config.transform_keys(&:to_s))))
end