Sha256: ba55432a94810a0647ea7b32fb0afb332dd6b329129ca188cf2a3babf2e5c091

Contents?: true

Size: 1.1 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
fitting-2.7.1 lib/fitting/records/spherical/request.rb
fitting-2.7.0 lib/fitting/records/spherical/request.rb
fitting-2.6.0 lib/fitting/records/spherical/request.rb