Blame view

lib/syspro/singleton_api_resource.rb 565 Bytes
db76748d   Isaac Lewis   cop a bunch of St...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  require_relative "api_resource"
  
  module Syspro
    class SingletonAPIResource < ApiResource
      def self.resource_url
        if self == SingletonAPIResource
          raise NotImplementedError, "SingletonAPIResource is an abstract class.  You should perform actions on its subclasses (Customer, etc.)"
        end
        "/v1/#{CGI.escape(class_name.downcase)}"
      end
  
      def resource_url
        self.class.resource_url
      end
  
      def self.retrieve(opts = {})
        instance = new(nil, Util.normalize_opts(opts))
        instance.refresh
        instance
      end
    end
  end