Sha256: acd8842acb822f1f13d6cbb08d1d80a145ee3ee22310473d40ef2b1b9da9a940

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

# typed: strict
# frozen_string_literal: true

module DearInventory
  class Sale < Resource
    class << self
      extend T::Sig

      # Sales
      #
      # @param params [Hash] URL query string parameters that conform to
      #   DearInventory::Parameters::Sale::Index
      sig do
        params(params: T::Hash[Symbol, T.untyped]).
          returns(DearInventory::Response)
      end
      def index(params = {})
        new.request(
          :get,
          endpoint: "index",
          model: DearInventory::Models::SalesResults,
          params: params
        )
      end

      alias call index

      # Sale
      #
      # @param params [Hash] URL query string parameters that conform to
      #   DearInventory::Parameters::Sale::Show
      sig do
        params(params: T::Hash[Symbol, T.untyped]).
          returns(DearInventory::Response)
      end
      def show(params = {})
        new.request(
          :get,
          endpoint: "show",
          model: DearInventory::Models::Sale,
          params: params
        )
      end

      # Sale
      #
      # @param params [Hash] URL query string parameters that conform to
      #   DearInventory::Parameters::Sale::Delete
      sig do
        params(params: T::Hash[Symbol, T.untyped]).
          returns(DearInventory::Response)
      end
      def delete(params = {})
        new.request(
          :delete,
          endpoint: "delete",
          model: DearInventory::Models::Sale,
          params: params
        )
      end
    end

    private

    sig { params(endpoint: T.nilable(String)).returns(String) }
    def resource_uri(endpoint)
      case endpoint
      when "index"
        "#{self.class.const_get(:URI_BASE)}/salelist"
      when "show", "delete"
        "#{self.class.const_get(:URI_BASE)}/sale"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dear_inventory-1.4.0 lib/dear_inventory/resources/sale.rb
dear_inventory-1.3.0 lib/dear_inventory/resources/sale.rb