Sha256: b8cdc91b2c4abc1d5bbb33080d2b2bd4acb8e5b264374d493782bb225199936d

Contents?: true

Size: 1009 Bytes

Versions: 15

Compression:

Stored size: 1009 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}"
      Resource.new(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

15 entries across 15 versions & 1 rubygems

Version Path
loquor-1.2.0 lib/loquor/http_actions/post.rb
loquor-1.1.1 lib/loquor/http_actions/post.rb
loquor-1.1.0 lib/loquor/http_actions/post.rb
loquor-1.0.0 lib/loquor/http_actions/post.rb
loquor-0.9.0 lib/loquor/http_actions/post.rb
loquor-0.8.0 lib/loquor/http_actions/post.rb
loquor-0.7.0 lib/loquor/http_actions/post.rb
loquor-0.6.0 lib/loquor/http_actions/post.rb
loquor-0.5.4 lib/loquor/http_actions/post.rb
loquor-0.5.3 lib/loquor/http_actions/post.rb
loquor-0.5.2 lib/loquor/http_actions/post.rb
loquor-0.5.1 lib/loquor/http_actions/post.rb
loquor-0.5.0 lib/loquor/http_actions/post.rb
loquor-0.4.0 lib/loquor/http_actions/post.rb
loquor-0.3.0 lib/loquor/http_actions/post.rb