Sha256: bd147017e1234e716e5c0f815465fbffa107466fcc36374b4b8b7ee8986713f3

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

require 'json'
require 'fitting/records/spherical/response'

module Fitting
  class Records
    class Spherical
      class Request
        attr_reader :method, :path, :body, :response, :title, :group

        def initialize(method:, path:, body:, response:, title:, group:)
          @method = method
          @path = path
          @body = body
          @response = response
          @title = title
          @group = group
        end

        def to_hash
          {
            method: method,
            path: path.to_s,
            body: body,
            response: response.to_hash,
            title: title,
            group: group
          }
        end

        def to_json
          JSON.dump(to_hash)
        end

        class << self
          def load(hash)
            new(
              method: hash['method'],
              path: hash['path'],
              body: hash['body'],
              response: Fitting::Records::Spherical::Response.load(hash['response']),
              title: hash['title'],
              group: hash['group']
            )
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fitting-2.17.0 lib/fitting/records/spherical/request.rb
fitting-2.16.1 lib/fitting/records/spherical/request.rb
fitting-2.16.0 lib/fitting/records/spherical/request.rb
fitting-2.15.0 lib/fitting/records/spherical/request.rb
fitting-2.14.1 lib/fitting/records/spherical/request.rb
fitting-2.14.0 lib/fitting/records/spherical/request.rb
fitting-2.13.1 lib/fitting/records/spherical/request.rb
fitting-2.13.0 lib/fitting/records/spherical/request.rb
fitting-2.12.1 lib/fitting/records/spherical/request.rb
fitting-2.12.0 lib/fitting/records/spherical/request.rb
fitting-2.11.0 lib/fitting/records/spherical/request.rb
fitting-2.10.0 lib/fitting/records/spherical/request.rb
fitting-2.9.1 lib/fitting/records/spherical/request.rb
fitting-2.9.0 lib/fitting/records/spherical/request.rb
fitting-2.8.1 lib/fitting/records/spherical/request.rb
fitting-2.8.0 lib/fitting/records/spherical/request.rb
fitting-2.7.2 lib/fitting/records/spherical/request.rb