Sha256: 68543468aff1cb27a3cb2f63c1321e6210dc68f38424d9b212cc6cc091a30b2c

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Billomat
  module Actions
    # Completes an invoice by calling the /complete path on a resource.
    class Complete
      # Returns a Complete object.
      #
      # @param invoice_id [String] the ID of the invoice
      # @param opts [Hash] the options for this request
      # @return [Billomat::Actions::Complete]
      #
      # @example
      #   Billomat::Actions::Complete('12345', { template_id: '10231' })
      def initialize(invoice_id, opts = {})
        @invoice_id = invoice_id
        @opts = opts
      end

      # Calls the gateway.
      #
      # @return [TrueClass]
      def call
        Billomat::Gateway.new(:put, path, wrapped_data).run

        true
      end

      # The given options have to be wrapped.
      #
      # @return [Hash] the payload for the complete request
      def wrapped_data
        { complete: @opts }
      end

      # @return [String] the complete path with the invoice_id
      def path
        "/invoices/#{@invoice_id}/complete"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
billomat-1.2.5 lib/billomat/actions/complete.rb
billomat-1.2.4 lib/billomat/actions/complete.rb
billomat-1.2.3 lib/billomat/actions/complete.rb
billomat-1.2.2 lib/billomat/actions/complete.rb
billomat-1.2.1 lib/billomat/actions/complete.rb
billomat-1.2.0 lib/billomat/actions/complete.rb
billomat-1.1.0 lib/billomat/actions/complete.rb
billomat-1.0.0 lib/billomat/actions/complete.rb
billomat-0.4.1 lib/billomat/actions/complete.rb
billomat-0.4.0 lib/billomat/actions/complete.rb
billomat-0.3.0 lib/billomat/actions/complete.rb