Sha256: 4a0dac2dc225b2ce12d2d42bad77e340455d7ba853a0619ef77c235749ed320d

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true
module BloomRemitClient
  module Requests
    class Base
      include Virtus.model
      include ActiveModel::Validations
      include Concerns::HasBaseAuthentification

      def call
        RequestsSender.new(params).()
      end

      def params
        {
          type: type,
          body: body,
          url: {
            host: host,
            path: path,
            query_params: query_params
          }
        }
      end

      private

      def type
        raise NotImplementedError, 'For subclass only!'
      end

      def path
        raise NotImplementedError, 'For subclass only!'
      end

      def body
        return unless body_params.present?
        body_params.to_json
      end

      def body_params
        {}
      end

      def query_params
        attributes.slice(:api_secret)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bloom_remit_client-0.7.1 lib/bloom_remit_client/requests/base.rb
bloom_remit_client-0.7.0 lib/bloom_remit_client/requests/base.rb
bloom_remit_client-0.6.0 lib/bloom_remit_client/requests/base.rb