Class: BusinessCentral::Object::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



28
29
30
31
32
33
34
35
# File 'lib/business_central/object/response.rb', line 28

def initialize(response)
  @results = nil
  return if response.blank?

  @response = JSON.parse(response)
  @response = @response['value'] if @response.key?('value')
  process
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



26
27
28
# File 'lib/business_central/object/response.rb', line 26

def results
  @results
end

Class Method Details

.not_found?(status) ⇒ Boolean

Returns:

  • (Boolean)


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

def not_found?(status)
  status == 404
end

.success?(status) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/business_central/object/response.rb', line 9

def success?(status)
  [200, 201].include?(status)
end

.success_no_content?(status) ⇒ Boolean

Returns:

  • (Boolean)


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

def success_no_content?(status)
  status == 204
end

.unauthorized?(status) ⇒ Boolean

Returns:

  • (Boolean)


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

def unauthorized?(status)
  status == 401
end