Sha256: 72406291d8a0210d1a4e87b7e43df61055239e772c783e82c2d69276bd6dc5c1

Contents?: true

Size: 939 Bytes

Versions: 6

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

module Cequens
  module Requests
    module GetSMSDetailsRequest
      DEFAULTS = {}.freeze

      def fire_request
        cequens_api_response = Connection.get(request[:path], request[:params], request[:body], request[:options])
        response_body = JSON.parse(cequens_api_response.body)

        Response.new(response_body)
      end

      private

      def build_get_sms_details_request
        {
          path: "sms/v1/messages/#{message_id}",
          params: {},
          body: {},
          options: options
        }
      end

      def request_params
        @request_params ||= DEFAULTS.merge(params)
      end

      def message_id
        request_params[:id]
      end

      def validate_params!
        contract = Contracts::GetSMSDetailsContract.new.call(request_params)
        raise InvalidCequensRequestError, contract.errors.to_h if contract.failure?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cequens-0.1.2 lib/cequens/requests/get_sms_details_request.rb
cequens-0.1.1 lib/cequens/requests/get_sms_details_request.rb
cequens-0.1.0 lib/cequens/requests/get_sms_details_request.rb
cequens-0.0.9 lib/cequens/requests/get_sms_details_request.rb
cequens-0.0.8 lib/cequens/requests/get_sms_details_request.rb
cequens-0.0.7 lib/cequens/requests/get_sms_details_request.rb