Class: Fugle::Response Private

Inherits:
Object
  • Object
show all
Defined in:
lib/fugle/response.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API Response

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, attributes) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new response

Parameters:

  • attributes (Hash)

    response Hash from API

Since:

  • 0.1.0



19
20
21
22
23
# File 'lib/fugle/response.rb', line 19

def initialize(body, attributes)
  @version = attributes.fetch('apiVersion', nil)
  @info = Information.new(attributes.dig('data', 'info'))
  @body = body.new(attributes.dig('data', body.data_name))
end

Instance Attribute Details

#bodyObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



11
12
13
# File 'lib/fugle/response.rb', line 11

def body
  @body
end

#infoObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



11
12
13
# File 'lib/fugle/response.rb', line 11

def info
  @info
end

#versionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



11
12
13
# File 'lib/fugle/response.rb', line 11

def version
  @version
end

Instance Method Details

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert to Hash

Returns:

  • (Hash)

    the response as hash

Since:

  • 0.1.0



31
32
33
34
35
36
37
# File 'lib/fugle/response.rb', line 31

def to_h
  {
    version: @version,
    info: @info,
    body: @body
  }
end

#to_json(*args) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert to JSON

Returns:

  • (String)

    the json string

Since:

  • 0.1.0



45
46
47
# File 'lib/fugle/response.rb', line 45

def to_json(*args)
  to_h.to_json(*args)
end