Blame view

lib/syspro/singleton_api_resource.rb 661 Bytes
dc8aa5b6   Joe Weakley   Rubocop corrections
1
2
3
  # frozen_string_literal: true
  
  require_relative 'api_resource'
db76748d   Isaac Lewis   cop a bunch of St...
4
5
6
7
8
  
  module Syspro
    class SingletonAPIResource < ApiResource
      def self.resource_url
        if self == SingletonAPIResource
dc8aa5b6   Joe Weakley   Rubocop corrections
9
10
11
12
          raise(
            NotImplementedError,
            'SingletonAPIResource is an abstract class.  You should perform actions on its subclasses (Customer, etc.)' # rubocop:disable Metrics/LineLength
          )
db76748d   Isaac Lewis   cop a bunch of St...
13
        end
3d0157a5   Isaac Lewis   add logoff
14
        "/#{CGI.escape(class_name.downcase)}"
db76748d   Isaac Lewis   cop a bunch of St...
15
16
17
18
19
20
21
22
23
24
25
26
27
      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