Sha256: f505ea36c001988b9420251a795bf2a40b322c68ad05f9006f20dc0e3f07d8c9

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

require 'faraday'

module Bearychat
  class HttpClient
    attr_accessor :conn, :url

    def initialize(url)
      self.conn = build_conn(url)
    end

    def post_json(body)
      conn.post do |req|
        req.headers['Content-Type'] = 'application/json'
        req.body = body
      end
    end

    private
    def build_conn(url)
      Faraday.new(url, ssl: {}) do |faraday|
        faraday.request  :url_encoded
        faraday.response :logger
        faraday.adapter  Faraday.default_adapter
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bearychat-1.0.0 lib/bearychat/http_client.rb