Sha256: 3d88ac0bfe8a9dc66e4b554211bd0ef179ea81085f815db74ee79a2fc9d279f5

Contents?: true

Size: 799 Bytes

Versions: 7

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module Housecanary
  module API
    module Helpers
      def _perform_response(parser, connection, method, path, params = {})
        parser.perform(perform_request(method, connection, path, params))
      end

      def perform_request(method, connection, path, params)
        args = connection, path, params
        case method&.to_sym
        when :get
          perform_get(*args)
        when :post
          perform_post(*args)
        else
          raise NotImplementedError, "Method <#{method}> Not Supported"
        end
      end

      def perform_get(connection, path, params)
        connection.get(path, params: params)
      end

      def perform_post(connection, path, params)
        connection.post(path, json: params)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
housecanary-ruby-0.2.2 lib/housecanary/api/helpers.rb
housecanary-ruby-0.2.1 lib/housecanary/api/helpers.rb
housecanary-ruby-0.2.0 lib/housecanary/api/helpers.rb
housecanary-ruby-0.1.3 lib/housecanary/api/helpers.rb
housecanary-ruby-0.1.2 lib/housecanary/api/helpers.rb
housecanary-ruby-0.1.1 lib/housecanary/api/helpers.rb
housecanary-ruby-0.1.0 lib/housecanary/api/helpers.rb