Class: NewStoreApi::Problem
- Defined in:
- lib/new_store_api/models/problem.rb
Overview
Problem Model.
Instance Attribute Summary collapse
-
#detail ⇒ String
A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed.
-
#error_code ⇒ String
A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed.
-
#instance ⇒ String
A URI reference that identifies the specific occurrence of the problem, e.g.
-
#message ⇒ String
A URI reference that identifies the specific occurrence of the problem, e.g.
-
#messages ⇒ Array[String]
A URI reference that identifies the specific occurrence of the problem, e.g.
-
#request_id ⇒ String
A URI reference that identifies the specific occurrence of the problem, e.g.
-
#status ⇒ Integer
The HTTP status code generated by the origin server for this occurrence of the problem.
-
#title ⇒ String
A short summary of the problem type.
-
#type ⇒ String
A URI reference that uniquely identifies the problem type only in the context of the provided API.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(detail = SKIP, error_code = SKIP, instance = SKIP, message = SKIP, messages = SKIP, request_id = SKIP, status = SKIP, title = SKIP, type = 'about:blank') ⇒ Problem
constructor
A new instance of Problem.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(detail = SKIP, error_code = SKIP, instance = SKIP, message = SKIP, messages = SKIP, request_id = SKIP, status = SKIP, title = SKIP, type = 'about:blank') ⇒ Problem
Returns a new instance of Problem.
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/new_store_api/models/problem.rb', line 103 def initialize(detail = SKIP, error_code = SKIP, instance = SKIP, = SKIP, = SKIP, request_id = SKIP, status = SKIP, title = SKIP, type = 'about:blank') @detail = detail unless detail == SKIP @error_code = error_code unless error_code == SKIP @instance = instance unless instance == SKIP @message = unless == SKIP @messages = unless == SKIP @request_id = request_id unless request_id == SKIP @status = status unless status == SKIP @title = title unless title == SKIP @type = type unless type == SKIP end |
Instance Attribute Details
#detail ⇒ String
A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
17 18 19 |
# File 'lib/new_store_api/models/problem.rb', line 17 def detail @detail end |
#error_code ⇒ String
A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
24 25 26 |
# File 'lib/new_store_api/models/problem.rb', line 24 def error_code @error_code end |
#instance ⇒ String
A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code.
30 31 32 |
# File 'lib/new_store_api/models/problem.rb', line 30 def instance @instance end |
#message ⇒ String
A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code.
36 37 38 |
# File 'lib/new_store_api/models/problem.rb', line 36 def @message end |
#messages ⇒ Array[String]
A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code.
42 43 44 |
# File 'lib/new_store_api/models/problem.rb', line 42 def @messages end |
#request_id ⇒ String
A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code.
48 49 50 |
# File 'lib/new_store_api/models/problem.rb', line 48 def request_id @request_id end |
#status ⇒ Integer
The HTTP status code generated by the origin server for this occurrence of the problem.
53 54 55 |
# File 'lib/new_store_api/models/problem.rb', line 53 def status @status end |
#title ⇒ String
A short summary of the problem type. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
59 60 61 |
# File 'lib/new_store_api/models/problem.rb', line 59 def title @title end |
#type ⇒ String
A URI reference that uniquely identifies the problem type only in the context of the provided API. Opposed to the specification in RFC-7807, it is neither recommended to be dereferenceable and point to a human-readable documentation nor globally unique for the problem type.
66 67 68 |
# File 'lib/new_store_api/models/problem.rb', line 66 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/new_store_api/models/problem.rb', line 118 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. detail = hash.key?('detail') ? hash['detail'] : SKIP error_code = hash.key?('error_code') ? hash['error_code'] : SKIP instance = hash.key?('instance') ? hash['instance'] : SKIP = hash.key?('message') ? hash['message'] : SKIP = hash.key?('messages') ? hash['messages'] : SKIP request_id = hash.key?('request_id') ? hash['request_id'] : SKIP status = hash.key?('status') ? hash['status'] : SKIP title = hash.key?('title') ? hash['title'] : SKIP type = hash['type'] ||= 'about:blank' # Create object from extracted values. Problem.new(detail, error_code, instance, , , request_id, status, title, type) end |
.names ⇒ Object
A mapping from model property names to API property names.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/new_store_api/models/problem.rb', line 69 def self.names @_hash = {} if @_hash.nil? @_hash['detail'] = 'detail' @_hash['error_code'] = 'error_code' @_hash['instance'] = 'instance' @_hash['message'] = 'message' @_hash['messages'] = 'messages' @_hash['request_id'] = 'request_id' @_hash['status'] = 'status' @_hash['title'] = 'title' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
99 100 101 |
# File 'lib/new_store_api/models/problem.rb', line 99 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/new_store_api/models/problem.rb', line 84 def self.optionals %w[ detail error_code instance message messages request_id status title type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
153 154 155 156 157 158 159 |
# File 'lib/new_store_api/models/problem.rb', line 153 def inspect class_name = self.class.name.split('::').last "<#{class_name} detail: #{@detail.inspect}, error_code: #{@error_code.inspect}, instance:"\ " #{@instance.inspect}, message: #{@message.inspect}, messages: #{@messages.inspect},"\ " request_id: #{@request_id.inspect}, status: #{@status.inspect}, title: #{@title.inspect},"\ " type: #{@type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
145 146 147 148 149 150 |
# File 'lib/new_store_api/models/problem.rb', line 145 def to_s class_name = self.class.name.split('::').last "<#{class_name} detail: #{@detail}, error_code: #{@error_code}, instance: #{@instance},"\ " message: #{@message}, messages: #{@messages}, request_id: #{@request_id}, status:"\ " #{@status}, title: #{@title}, type: #{@type}>" end |