Skip to content

Commit

Permalink
Added account level sanitizer fetch API
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwajitparasar-bsft committed Sep 15, 2022
1 parent 417cdb2 commit 872be62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/apollo/clients/accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def initialize(account)
@account = account
end

def sanitizer
handle_request("sanitizers/account/#{@account}", :get)
end

def run_sanitizer(type:, document:, sanitizer: nil)
handle_request("sanitize/accounts/#{@account}/types/#{type}", :get, body: {
document: document,
Expand Down
7 changes: 6 additions & 1 deletion lib/apollo/models/sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ def type_mapping(key:nil, value:nil)
end

def fetch
if @index.nil?
if !@index.nil?
Apollo.indices.for_index(@index).sanitizer
elsif !@account.nil?
Apollo.accounts.for_account(@account).sanitizer(
type: type,
document: document,
sanitizer: self)
else
Apollo.indices.for_index(:default).sanitizer
end
Expand Down

0 comments on commit 872be62

Please sign in to comment.