Sha256: c11a4d5d90d7e4eb95ec1222b018d41726daef7f466c97266829114ff50612a2

Contents?: true

Size: 1018 Bytes

Versions: 11

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

module Billomat
  module Actions
    # This actions sends an invoice email.
    # Recipients must be passed like this:
    #   { recipients: { to: 'bob@example.org' } }
    #
    # @example
    #   Billomat::Actions::Email.new('1235', { recipiens: { to: 'a@b.org' } })
    class Email
      # @param invoice_id [String] the invoice ID
      # @param opts [Hash] the options for this action
      # @return [Billomat::Actions::Email]
      def initialize(invoice_id, opts = {})
        @invoice_id = invoice_id
        @opts = opts
      end

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

        true
      end

      # Wraps the options
      #
      # @return [Hash] the wrapped email options
      def wrapped_data
        { email: @opts }
      end

      # @return [String] the path for the email action
      def path
        "/invoices/#{@invoice_id}/email"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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