Skip to content

Commit

Permalink
Add domain parser to client
Browse files Browse the repository at this point in the history
  • Loading branch information
swanny85 committed Dec 22, 2023
1 parent eff44a2 commit e88f514
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/fulfil/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'http'
require 'logger'
require 'fulfil/response_parser'
require 'fulfil/domain_parser'

module Fulfil
SUBDOMAIN = ENV.fetch('FULFIL_SUBDOMAIN', nil)
Expand Down Expand Up @@ -69,15 +70,17 @@ def find_many(model:, ids:, fields: nil)

def search(model:, domain:, offset: nil, limit: 100, sort: nil, fields: %w[id])
uri = URI("#{model_url(model: model)}/search_read")
body = [domain, offset, limit, sort, fields]
parsed_domain = Fulfil::DomainParser.new(domain).parsed
body = [parsed_domain, offset, limit, sort, fields]

results = request(verb: :put, endpoint: uri, json: body)
parse(results: results)
end

def count(model:, domain:)
uri = URI("#{model_url(model: model)}/search_count")
body = [domain]
parsed_domain = Fulfil::DomainParser.new(domain).parsed
body = [parsed_domain]

request(verb: :put, endpoint: uri, json: body)
end
Expand Down

0 comments on commit e88f514

Please sign in to comment.