Sha256: cf36b706ade5adb3ba0e3a238b5b98b851c1bf0a0eb74e976aa9ef54f6bc87d0

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 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(*_args)
          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

7 entries across 7 versions & 1 rubygems

Version Path
fitting-3.0.2 lib/fitting/records/spherical/request.rb
fitting-3.0.1 lib/fitting/records/spherical/request.rb
fitting-3.0.0 lib/fitting/records/spherical/request.rb
fitting-2.18.3 lib/fitting/records/spherical/request.rb
fitting-2.18.2 lib/fitting/records/spherical/request.rb
fitting-2.18.1 lib/fitting/records/spherical/request.rb
fitting-2.18.0 lib/fitting/records/spherical/request.rb