Sha256: 85b4a99f5009d15822996dfcd35a2edae160bcd7ef7b5a6d4891cb0e608b46e3

Contents?: true

Size: 715 Bytes

Versions: 5

Compression:

Stored size: 715 Bytes

Contents

module Pingpp
  class SingletonAppBasedResource < APIResource
    def self.resource_url(opts={})
      if self == SingletonAPIResource
        raise NotImplementedError.new('SingletonAPIResource is an abstract class.')
      end

      app_id = opts[:app]
      unless app_id ||= Pingpp.app_id
        raise InvalidRequestError.new("Please set app_id using Pingpp.app_id = <APP_ID>", 'app_id')
      end

      "/v1/apps/#{app_id}/#{CGI.escape(uri_object_name.downcase)}"
    end

    def resource_url(opts={})
      self.class.resource_url(opts)
    end

    def self.retrieve(params={}, opts={})
      instance = self.new(params, Util.normalize_opts(opts))
      instance.refresh
      instance
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pingpp-2.2.4 lib/pingpp/singleton_app_based_resource.rb
pingpp-2.2.3 lib/pingpp/singleton_app_based_resource.rb
pingpp-2.2.2 lib/pingpp/singleton_app_based_resource.rb
pingpp-2.2.1 lib/pingpp/singleton_app_based_resource.rb
pingpp-2.2.0 lib/pingpp/singleton_app_based_resource.rb