Sha256: ca5e0900cdac5f8fe5f932252b93835ba6553a064c03e3073f580fecb46ecf6f

Contents?: true

Size: 810 Bytes

Versions: 1

Compression:

Stored size: 810 Bytes

Contents

module SuperReceptionist
  class Client
    attr_reader :url

    def initialize(url)
      @url = url
    end

    def get(params = {})
      @url += "?#{URI.encode_www_form(params)}" if params.any?
      RestClient.get(@url, headers=header)
    end

    def post(params = {})
      RestClient.post(@url, params, headers=header)
    end

    def put(params = {})
      RestClient.put(@url, params, headers=header)
    end

    def delete(params = {})
      RestClient.delete(@url, params, headers=header)
    end

    private

    def header
      { 'Content-Type' => 'application/json',
        'channel' => SuperReceptionist.channel,
        'x-api-key' => SuperReceptionist.x_api_key,
        'authorization' => SuperReceptionist.authorization
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
super_receptionist-0.1.0 lib/super_receptionist/client.rb