Class: Kongrations::Response

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

Direct Known Subclasses

CreatePluginResponse

Instance Method Summary collapse

Constructor Details

#initialize(response, request) ⇒ Response

Returns a new instance of Response.



8
9
10
11
# File 'lib/kongrations/response.rb', line 8

def initialize(response, request)
  @response = response
  @request = request
end

Instance Method Details

#bodyObject



21
22
23
# File 'lib/kongrations/response.rb', line 21

def body
  JSON.parse(@response.body, symbolize_names: true) unless @response.body.nil?
end

#data_to_saveObject



25
26
27
# File 'lib/kongrations/response.rb', line 25

def data_to_save
  nil
end

#error?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/kongrations/response.rb', line 17

def error?
  !success?
end

#save_data(migration_name) ⇒ Object



29
30
31
# File 'lib/kongrations/response.rb', line 29

def save_data(migration_name)
  MigrationData.save(migration_name, data_to_save)
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/kongrations/response.rb', line 13

def success?
  @response.is_a?(Net::HTTPSuccess)
end