Sha256: 44512e07d21ff4a465bf46d8f8afc063b991be1da933192b94bac8cfaf7755d9

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

class Zendesk2::Client < Cistern::Service
  USER_AGENT = "Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM}; #{RUBY_ENGINE}) Zendesk2/#{Zendesk2::VERSION} Faraday/#{Faraday::VERSION}".freeze

  collection_path "zendesk2/client/collections"
  model_path      "zendesk2/client/models"
  request_path    "zendesk2/client/requests"

  # @fixme might be nice if cistern took care of this
  [
    [:collection, collection_path],
    [:model,      model_path],
    [:request,    request_path],
  ].each do |type, path|
    Dir[File.expand_path(File.join("../..", path, "**/*.rb"), __FILE__)].sort.each do |file|
      send(type, file.gsub(/.*#{path}\/(.*)\.rb/, "\\1"), require: file)
    end
  end

  recognizes :url, :logger, :adapter, :username, :password, :token, :jwt_token

  module Shared
    def require_parameters(_params, *requirements)
      params = Cistern::Hash.stringify_keys(_params)
      params.reject! { |_,v| Zendesk2.blank?(v) }

      if (missing = requirements - params.keys).any?
        raise ArgumentError, "missing parameters: #{missing.join(", ")}"
      else
        values = params.values_at(*requirements)
        requirements.size == 1 ? values.first : values
      end
    end
  end
end

require 'zendesk2/client/real'
require 'zendesk2/client/mock'
require 'zendesk2/client/help_center'

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
zendesk2-1.4.2 lib/zendesk2/client.rb
zendesk2-1.4.1 lib/zendesk2/client.rb
zendesk2-1.4.0 lib/zendesk2/client.rb
zendesk2-1.3.3 lib/zendesk2/client.rb
zendesk2-1.3.2 lib/zendesk2/client.rb
zendesk2-1.3.1 lib/zendesk2/client.rb
zendesk2-1.3.0 lib/zendesk2/client.rb
zendesk2-1.2.10 lib/zendesk2/client.rb
zendesk2-1.2.9 lib/zendesk2/client.rb
zendesk2-1.2.7 lib/zendesk2/client.rb
zendesk2-1.2.6 lib/zendesk2/client.rb
zendesk2-1.2.5 lib/zendesk2/client.rb