Sha256: f3d41bcbb67d8df85d7226a937fa62a0c463aeb4abe0f1aba73c46fa0b72c1b4

Contents?: true

Size: 637 Bytes

Versions: 21

Compression:

Stored size: 637 Bytes

Contents

class Zendesk2::Client::SearchHelpCenterArticles < Zendesk2::Client::Request
  request_path { |_| "/help_center/articles/search.json" }

  attr_reader :query

  def _mock(query, params={})
    @query = query
    setup(params)
    mock
  end

  def _real(query, params={})
    @query = query
    setup(params)
    real
  end

  def mock
    terms = Hash[query.split(" ").map { |t| t.split(":") }]

    collection = self.data[:help_center_articles].values

    results = collection.select { |v| terms.all?{ |term, condition| v[term.to_s].to_s == condition.to_s } }

    page(results, params: {"query" => query}, root: "results")
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zendesk2-1.5.3 lib/zendesk2/client/requests/search_help_center_articles.rb