Class: ContextDev::Resources::Brand

Inherits:
Object
  • Object
show all
Defined in:
lib/context_dev/resources/brand.rb,
sig/context_dev/resources/brand.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Brand

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Brand.

Parameters:



105
106
107
# File 'lib/context_dev/resources/brand.rb', line 105

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve(body:, request_options: {}) ⇒ ContextDev::Models::BrandRetrieveResponse

Retrieve logos, backdrops, colors, industry, description, and more. Provide exactly one lookup identifier in the request body: a domain, company name, email address, stock ticker, transaction descriptor, or direct URL. Note: by_direct_url fetches brand data only from the provided URL — not from the entire internet.



21
22
23
24
25
26
27
28
29
30
# File 'lib/context_dev/resources/brand.rb', line 21

def retrieve(params)
  parsed, options = ContextDev::BrandRetrieveParams.dump_request(params)
  @client.request(
    method: :post,
    path: "brand/retrieve",
    body: parsed[:body],
    model: ContextDev::Models::BrandRetrieveResponse,
    options: options
  )
end

#retrieve_simplified(domain:, max_age_ms: nil, tags: nil, theme: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::BrandRetrieveSimplifiedResponse

Some parameter documentations has been truncated, see Models::BrandRetrieveSimplifiedParams for more details.

Returns a simplified version of brand data containing only essential information: domain, title, colors, logos, and backdrops. Optimized for faster responses and reduced data transfer.

Parameters:

  • domain (String)

    Domain name to retrieve simplified brand data for

  • max_age_ms (Integer, nil)

    Maximum age in milliseconds for cached brand data before the API performs a hard

  • tags (Array<String>)

    Optional comma-separated caller-defined tags for tracking this request. Tags are

  • theme (Symbol, ContextDev::Models::BrandRetrieveSimplifiedParams::Theme)

    Optional theme preference used when selecting brand assets.

  • timeout_ms (Integer)

    Optional timeout in milliseconds for the request. If the request takes longer th

  • request_options (ContextDev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/context_dev/resources/brand.rb', line 56

def retrieve_simplified(params)
  parsed, options = ContextDev::BrandRetrieveSimplifiedParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "brand/retrieve-simplified",
    query: query.transform_keys(max_age_ms: "maxAgeMs", timeout_ms: "timeoutMS"),
    model: ContextDev::Models::BrandRetrieveSimplifiedResponse,
    options: options
  )
end

#search(query:, autocomplete: nil, query_by: nil, tags: nil, typo_tolerance: nil, request_options: {}) ⇒ ContextDev::Models::BrandSearchResponse

Some parameter documentations has been truncated, see Models::BrandSearchParams for more details.

Search indexed brands by name or domain

Parameters:

  • query (String)

    Search term, matched against the fields selected by queryBy (e.g. 'nike', 'nike.

  • autocomplete (Boolean)

    Whether the search term matches by prefix, so partial words match as they are ty

  • query_by (Array<Symbol, ContextDev::Models::BrandSearchParams::QueryBy>)

    Fields to match the search term against, as a comma-separated list or repeated p

  • tags (Array<String>)

    Optional comma-separated caller-defined tags for tracking this request. Tags are

  • typo_tolerance (Integer)

    Maximum number of typos tolerated when matching, from 0 to 2. Defaults to 0 (no

  • request_options (ContextDev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/context_dev/resources/brand.rb', line 90

def search(params)
  parsed, options = ContextDev::BrandSearchParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "brand/search",
    query: query.transform_keys(query_by: "queryBy", typo_tolerance: "typoTolerance"),
    model: ContextDev::Models::BrandSearchResponse,
    options: options
  )
end