Class: TrailerVote::Api::Place::Create
- Inherits:
-
Object
- Object
- TrailerVote::Api::Place::Create
- Includes:
- Composable::Common
- Defined in:
- lib/trailer_vote/api/place/create.rb
Constant Summary collapse
- CONTENT =
MediaTypes::Place.to_constructable.version(2).view('create')
- SUCCESS =
MediaTypes::Place.to_constructable.version(2)
- FAILURE =
MediaTypes::Errors.to_constructable.version(1)
- ACCEPT =
[SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
Instance Method Summary collapse
-
#back ⇒ TrailerVote::Api::Place::Find
The found place.
-
#call(data:, url: resolve_url) ⇒ TrailerVote::Api::Place::Find
Create a place.
-
#initialize(configuration:, place:) ⇒ Create
constructor
A new instance of Create.
Methods included from Composable::Common
Constructor Details
#initialize(configuration:, place:) ⇒ Create
Returns a new instance of Create.
28 29 30 31 |
# File 'lib/trailer_vote/api/place/create.rb', line 28 def initialize(configuration:, place:) self.configuration = configuration self.place = place end |
Instance Method Details
#back ⇒ TrailerVote::Api::Place::Find
Returns the found place.
34 35 36 |
# File 'lib/trailer_vote/api/place/create.rb', line 34 def back place end |
#call(data:, url: resolve_url) ⇒ TrailerVote::Api::Place::Find
Create a place
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/trailer_vote/api/place/create.rb', line 46 def call(data:, url: resolve_url) guard_network_errors do body = encode(data) branch( resolve_client.headers( Headers::ACCEPT => ACCEPT, Headers::CONTENT_TYPE => "#{CONTENT}; charset=#{body.encoding.name}" ).post(url, body: body), data: data ) end end |