class
Amber::Schema::ResponseBuilder
- Amber::Schema::ResponseBuilder
- Reference
- Object
Defined in:
amber/schema/response_builder.crConstructors
- .error(message : String, code : String = "error") : ResponseBuilder
- .forbidden(message : String = "Forbidden") : ResponseBuilder
-
.from_result(result : LegacyResult) : ResponseBuilder
Build response from a validation result
- .new(status : Status = Status::Success)
- .not_found(resource : String | Nil = nil) : ResponseBuilder
-
.success(data : Hash(String, JSON::Any) | Nil = nil) : ResponseBuilder
Factory methods for common responses
- .unauthorized(message : String = "Unauthorized") : ResponseBuilder
- .validation_error(errors : Array(Error)) : ResponseBuilder
Instance Method Summary
- #add_error(error : Error)
- #add_metadata(key : String, value : JSON::Any)
- #add_warning(warning : Warning)
-
#build(format : Format = Format::JSON) : Hash(String, JSON::Any)
Build the response
- #data : Hash(String, JSON::Any) | Nil
-
#data=(data : Hash(String, JSON::Any) | Nil)
Setters with method chaining
- #errors : Array(Error)
-
#http_status : Int32
HTTP status code based on response status
- #metadata : Hash(String, JSON::Any)
-
#paginate(page : Int32, per_page : Int32, total : Int32)
Set pagination metadata
- #status : Status
-
#to_json(format : Format = Format::JSON) : String
Convert to JSON string
- #warnings : Array(Warning)
Constructor Detail
Build response from a validation result
Factory methods for common responses
Instance Method Detail
Build the response