Sha256: 212b7bf42ff0bcb09fc35f1de650a71523b6edcbb64248c5f4faa312cd818bdc

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

require 'httparty'

module Messenger

  class Web

    # URL format:
    #     http://example.com
    #
    # The body of the message is posted as the body of the request, not the query.
    def self.send(url, body, options={})
      response = HTTParty.post(url, options.merge(:body => body))
      [success?(response), response]
    end

  private

    def self.success?(response)
      case response.code
      when 200, 201: true
      else
        false
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
messenger-0.0.3 lib/messenger/web.rb
messenger-0.0.2 lib/messenger/web.rb