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.



544
545
546
547
# File 'lib/ghostcrawl/client.rb', line 544

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.



563
564
565
566
# File 'lib/ghostcrawl/client.rb', line 563

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.



578
579
580
# File 'lib/ghostcrawl/client.rb', line 578

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.



557
558
559
# File 'lib/ghostcrawl/client.rb', line 557

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.



551
552
553
# File 'lib/ghostcrawl/client.rb', line 551

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.



570
571
572
# File 'lib/ghostcrawl/client.rb', line 570

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