Class: PaypalServerSdk::ErrorDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/error_details.rb

Overview

The error details. Required for client-side ‘4XX` errors.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(issue:, field: SKIP, value: SKIP, location: 'body', links: SKIP, description: SKIP) ⇒ ErrorDetails

Returns a new instance of ErrorDetails.



70
71
72
73
74
75
76
77
78
# File 'lib/paypal_server_sdk/models/error_details.rb', line 70

def initialize(issue:, field: SKIP, value: SKIP, location: 'body',
               links: SKIP, description: SKIP)
  @field = field unless field == SKIP
  @value = value unless value == SKIP
  @location = location unless location == SKIP
  @issue = issue
  @links = links unless links == SKIP
  @description = description unless description == SKIP
end

Instance Attribute Details

#descriptionString

The human-readable description for an issue. The description can change over the lifetime of an API, so clients must not depend on this value.

Returns:

  • (String)


40
41
42
# File 'lib/paypal_server_sdk/models/error_details.rb', line 40

def description
  @description
end

#fieldString

The field that caused the error. If this field is in the body, set this value to the field’s JSON pointer value. Required for client-side errors.

Returns:

  • (String)


15
16
17
# File 'lib/paypal_server_sdk/models/error_details.rb', line 15

def field
  @field
end

#issueString

The unique, fine-grained application-level error code.

Returns:

  • (String)


28
29
30
# File 'lib/paypal_server_sdk/models/error_details.rb', line 28

def issue
  @issue
end

An array of request-related [HATEOAS links](/api/rest/responses/#hateoas-links) that are either relevant to the issue by providing additional information or offering potential resolutions.

Returns:



35
36
37
# File 'lib/paypal_server_sdk/models/error_details.rb', line 35

def links
  @links
end

#locationString

The location of the field that caused the error. Value is ‘body`, `path`, or `query`.

Returns:

  • (String)


24
25
26
# File 'lib/paypal_server_sdk/models/error_details.rb', line 24

def location
  @location
end

#valueString

The value of the field that caused the error.

Returns:

  • (String)


19
20
21
# File 'lib/paypal_server_sdk/models/error_details.rb', line 19

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/paypal_server_sdk/models/error_details.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  issue = hash.key?('issue') ? hash['issue'] : nil
  field = hash.key?('field') ? hash['field'] : SKIP
  value = hash.key?('value') ? hash['value'] : SKIP
  location = hash['location'] ||= 'body'
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (LinkDescription.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')
  description = hash.key?('description') ? hash['description'] : SKIP

  # Create object from extracted values.
  ErrorDetails.new(issue: issue,
                   field: field,
                   value: value,
                   location: location,
                   links: links,
                   description: description)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
# File 'lib/paypal_server_sdk/models/error_details.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['field'] = 'field'
  @_hash['value'] = 'value'
  @_hash['location'] = 'location'
  @_hash['issue'] = 'issue'
  @_hash['links'] = 'links'
  @_hash['description'] = 'description'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
# File 'lib/paypal_server_sdk/models/error_details.rb', line 66

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
# File 'lib/paypal_server_sdk/models/error_details.rb', line 55

def self.optionals
  %w[
    field
    value
    location
    links
    description
  ]
end