Sha256: c4d23e583eeee0a15dfc7166516d7728f3d1dea50a9f0ab77294dcc04a3ad2c5

Contents?: true

Size: 613 Bytes

Versions: 8

Compression:

Stored size: 613 Bytes

Contents

module PostmanMta
  class ApiClient
    attr_reader :response_body, :response_status

    [:get, :post, :put, :patch, :delete].each do |type|
      define_method type do |url, options = {}|
        perform_request(type.to_s.upcase, url, options)
      end
    end

    private

    def perform_request(request_type, path, options = {})
      api_request = ::PostmanMta::ApiRequest.new(request_type, path, options)
      response = api_request.perform

      @response_body = response.parsed_response
      @response_status = response.code

      { json: response_body, status: response_status }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
postman_mta-0.2.4 lib/postman_mta/api_client.rb
postman_mta-0.2.3 lib/postman_mta/api_client.rb
postman_mta-0.2.2 lib/postman_mta/api_client.rb
postman_mta-0.2.1 lib/postman_mta/api_client.rb
postman_mta-0.2.0 lib/postman_mta/api_client.rb
postman_mta-0.1.9 lib/postman_mta/api_client.rb
postman_mta-0.1.8 lib/postman_mta/api_client.rb
postman_mta-0.1.7 lib/postman_mta/api_client.rb