Sha256: f2d14e85431498b80aecb012bf36b32724321b77828cf6679a0320aba05505ef

Contents?: true

Size: 873 Bytes

Versions: 7

Compression:

Stored size: 873 Bytes

Contents

module KrakenClient
  module Requests
    class Post < Base

      def call(url, endpoint_name, options)
        super

        @url           = url
        @endpoint_name = endpoint_name

        response       = HTTParty.post(url, params(options)).parsed_response
        response['error'].empty? ? response['result'] : response['error']
      end

      private

      def params(options = {})
        params           = {}

        header_content   = content_manager::Header.new(config, endpoint_name, options, url)

        params[:headers] = header_content.call
        params[:body]    = body_content(header_content).call

        params
      end

      def content_manager
        KrakenClient::Requests::Content
      end

      def body_content(header_content)
        content_manager::Body.new(header_content.send(:encoded_options))
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kraken_client-1.1.0 lib/kraken_client/requests/post.rb
kraken_client-1.0.3 lib/kraken_client/requests/post.rb
kraken_client-1.0.2 lib/kraken_client/requests/post.rb
kraken_client-1.0.1 lib/kraken_client/requests/post.rb
kraken_client-1.0.0 lib/kraken_client/requests/post.rb
kraken_client-0.2.1 lib/kraken_client/requests/post.rb
kraken_client-0.2.0 lib/kraken_client/requests/post.rb