Sha256: 4b13801b93991031a1e9b439b1909a020299aa8329f76d39273553ed85d05e97

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Kentaa
  module Api
    class Finder
      attr_reader :config

      def initialize(config)
        @config = config
      end

      def by_object_key(object_key)
        klass, id = object_key.split("_")

        case klass
        when "Action"
          client = Kentaa::Api::Clients::Actions.new(config)
          client.get(id)
        when "Donation"
          client = Kentaa::Api::Clients::Donations.new(config)
          client.get(id)
        when "NewsletterSubscription"
          client = Kentaa::Api::Clients::NewsletterSubscriptions.new(config)
          client.get(id)
        when "Project"
          client = Kentaa::Api::Clients::Projects.new(config)
          client.get(id)
        when "Segment"
          client = Kentaa::Api::Clients::Segments.new(config)
          client.get(id)
        when "Site"
          client = Kentaa::Api::Clients::Sites.new(config)
          client.current
        when "Team"
          client = Kentaa::Api::Clients::Teams.new(config)
          client.get(id)
        when "User"
          client = Kentaa::Api::Clients::Users.new(config)
          client.get(id)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kentaa-api-0.5.0 lib/kentaa/api/finder.rb
kentaa-api-0.4.0 lib/kentaa/api/finder.rb
kentaa-api-0.3.2 lib/kentaa/api/finder.rb
kentaa-api-0.3.1 lib/kentaa/api/finder.rb
kentaa-api-0.3.0 lib/kentaa/api/finder.rb