Module: Salestation::Web::Responses

Defined in:
lib/salestation/web/responses.rb

Defined Under Namespace

Classes: Error, Response, Success, UnprocessableEntityFromSchemaErrors

Constant Summary collapse

OK =
Success.with_code(200)
Created =
Success.with_code(201)
Accepted =
Success.with_code(202)
NoContent =
Success.with_code(204)
Unauthorized =
Error.with_code(401)
Forbidden =
Error.with_code(403)
NotFound =
Error.with_code(404)
NotAcceptable =
Error.with_code(406)
Conflict =
Error.with_code(409)
RequestEntityTooLarge =
Error.with_code(413)
UnsupportedMediaType =
Error.with_code(415)
UnprocessableEntity =
Error.with_code(422)
InternalError =
Error.with_code(500)
ServiceUnavailable =
Error.with_code(503)

Class Method Summary collapse

Class Method Details

.to_acceptedObject



8
9
10
# File 'lib/salestation/web/responses.rb', line 8

def self.to_accepted
  -> (object) { Deterministic::Result::Success(Responses::Accepted.new(body: object)) }
end

.to_createdObject



4
5
6
# File 'lib/salestation/web/responses.rb', line 4

def self.to_created
  -> (object) { Deterministic::Result::Success(Responses::Created.new(body: object)) }
end

.to_no_contentObject



16
17
18
# File 'lib/salestation/web/responses.rb', line 16

def self.to_no_content
  -> (*) { Deterministic::Result::Success(Responses::NoContent.new(body: {})) }
end

.to_okObject



12
13
14
# File 'lib/salestation/web/responses.rb', line 12

def self.to_ok
  -> (object) { Deterministic::Result::Success(Responses::OK.new(body: object)) }
end