Sha256: 75f879e18452ecab5dfe2da37d1d19621129e69c1b1749e8bac40f7869dc7b7d

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

require 'xploy/api/request/body'

module Xploy
  class Api
    class Request
      attr_reader :method_name, :path, :headers, :body

      def initialize method_name, path, options={}
        @method_name = method_name
        @path = path
        @options = options
        @body = build_body
        @headers = build_headers
      end

      def build_headers
        {'X-App' => 'appway'}.tap do |headers|
          headers['Content-Type'] = body.mime_type if body
        end
      end

      def build_body
        if path = @options[:manifest]
          @body = Body.new path
        else
          @body = nil
        end
      end

      def http_options
        http_options = {headers: headers}.tap do |http_options|
          http_options[:body] = body.read if body
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xploy-0.1.1.beta lib/xploy/api/request.rb
xploy-0.1.0.beta lib/xploy/api/request.rb