Sha256: 58404edfe839a6fe3432cd0d3664747a568c9b4e55bdb73c8f22a426e3f83582

Contents?: true

Size: 1.29 KB

Versions: 18

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module MyApiClient
  module Params
    # Description of Params
    class Request
      attr_reader :method, :uri, :headers, :body

      # Description of #initialize
      #
      # @param method [Symbol] describe_method_here
      # @param uri [URI] describe_uri_here
      # @param headers [Hash, nil] describe_headers_here
      # @param body [Hash, nil] describe_body_here
      def initialize(method, uri, headers, body)
        @method = method
        @uri = uri
        @headers = headers
        @body = body
      end

      # Description of #to_sawyer_args
      #
      # @return [Array<Object>] Arguments for Sawyer::Agent#call
      def to_sawyer_args
        [method, uri.to_s, body, { headers: headers }]
      end

      # Generate metadata for bugsnag.
      # Blank parameter will be omitted.
      #
      # @return [Hash] Metadata for bugsnag
      def metadata
        {
          line: "#{method.upcase} #{uri}",
          headers: headers,
          body: body,
        }.compact
      end
      alias to_bugsnag metadata

      # Returns contents as string for to be readable for human
      #
      # @return [String] Contents as string
      def inspect
        { method: method, uri: uri.to_s, headers: headers, body: body }.inspect
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
my_api_client-1.1.0 lib/my_api_client/params/request.rb
my_api_client-1.0.0 lib/my_api_client/params/request.rb
my_api_client-0.27.0 lib/my_api_client/params/request.rb
my_api_client-0.26.0 lib/my_api_client/params/request.rb
my_api_client-0.25.0 lib/my_api_client/params/request.rb
my_api_client-0.24.0 lib/my_api_client/params/request.rb
my_api_client-0.23.0 lib/my_api_client/params/request.rb
my_api_client-0.22.0 lib/my_api_client/params/request.rb
my_api_client-0.21.0 lib/my_api_client/params/request.rb
my_api_client-0.20.0 lib/my_api_client/params/request.rb
my_api_client-0.19.0 lib/my_api_client/params/request.rb
my_api_client-0.18.0 lib/my_api_client/params/request.rb
my_api_client-0.17.0 lib/my_api_client/params/request.rb
my_api_client-0.16.1 lib/my_api_client/params/request.rb
my_api_client-0.16.0 lib/my_api_client/params/request.rb
my_api_client-0.15.0 lib/my_api_client/params/request.rb
my_api_client-0.14.0 lib/my_api_client/params/request.rb
my_api_client-0.14.0.pre lib/my_api_client/params/request.rb