Sha256: 1520d0014e86470a3832f8981b50daf96bd3592f2c834e20ced4d2ab42b2ea39

Contents?: true

Size: 995 Bytes

Versions: 12

Compression:

Stored size: 995 Bytes

Contents

module Loquor
  class HttpAction::Post < HttpAction
    def self.post(url, payload, deps)
      new(url, payload, deps).post
    end

    def initialize(url, payload, deps)
      super(url, deps)
      @payload = payload
    end

    def post
      @config.logger.info "Making POST request to: #{full_url}"
      response = JSON.parse(signed_request.execute)
      @config.logger.info "Signed request executed. Response: #{response}"
      response
    end

    private

    def signed_request
      signed_request = super
      p signed_request # If you take this line out - it all breaks. Yeah...
      signed_request
    end

    def request
      RestClient::Request.new(url: full_url,
                              accept: :json,
                              payload: @payload.to_json,
                              headers: {'Content-type' => 'application/json'},
                              method: :post)
    end

    def full_url
      "#{@config.endpoint}#{@url}"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
loquor-1.13.0 lib/loquor/http_actions/post.rb
loquor-1.12.0 lib/loquor/http_actions/post.rb
loquor-1.11.0 lib/loquor/http_actions/post.rb
loquor-1.10.0 lib/loquor/http_actions/post.rb
loquor-1.9.0 lib/loquor/http_actions/post.rb
loquor-1.8.0 lib/loquor/http_actions/post.rb
loquor-1.7.0 lib/loquor/http_actions/post.rb
loquor-1.6.0 lib/loquor/http_actions/post.rb
loquor-1.5.0 lib/loquor/http_actions/post.rb
loquor-1.4.0 lib/loquor/http_actions/post.rb
loquor-1.3.0 lib/loquor/http_actions/post.rb
loquor-1.2.1 lib/loquor/http_actions/post.rb