Sha256: bdcc491d714d90cad6cb72ffe23ec041310c09b9eda0d7a69a16267d9e3115ee

Contents?: true

Size: 443 Bytes

Versions: 2

Compression:

Stored size: 443 Bytes

Contents

module Billogram
  class Request
    attr_reader :url, :type, :params

    def initialize(type, url, params = {})
      @url = url
      @type = type
      @params = params
    end

    def content
      case type
      when :post, :put
        { body: params.to_json }
      when :get
        { query: params }
      when :delete
        {}
      end
    end

    def execute
      Billogram.client.send(type, url, content)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
billogram-0.4.2 lib/billogram/request.rb
billogram-0.4.1 lib/billogram/request.rb