Class: TrailerVote::Api::Product::Image::Create
- Inherits:
-
Object
- Object
- TrailerVote::Api::Product::Image::Create
- Includes:
- Composable::Common
- Defined in:
- lib/trailer_vote/api/product/image/create.rb
Constant Summary collapse
- CONTENT =
MediaTypes::ProductImage.to_constructable.version(1).view('create')
- SUCCESS =
MediaTypes::ProductImage.to_constructable.version(1)
- 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::Product::Image
The api to deal with the current
product
images. -
#call(data:, url: resolve_url) ⇒ TrailerVote::Api::Product::Image::Find
Create the image.
-
#initialize(configuration:, product:) ⇒ Create
constructor
A new instance of Create.
Methods included from Composable::Common
Constructor Details
#initialize(configuration:, product:) ⇒ Create
Returns a new instance of Create.
27 28 29 30 |
# File 'lib/trailer_vote/api/product/image/create.rb', line 27 def initialize(configuration:, product:) self.configuration = configuration self.product = product end |
Instance Method Details
#back ⇒ TrailerVote::Api::Product::Image
Returns the api to deal with the current product
images.
33 34 35 |
# File 'lib/trailer_vote/api/product/image/create.rb', line 33 def back product.image end |
#call(data:, url: resolve_url) ⇒ TrailerVote::Api::Product::Image::Find
Create the image
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/trailer_vote/api/product/image/create.rb', line 45 def call(data:, url: resolve_url) body = encode(data) guard_network_errors do branch( resolve_client.headers( Headers::ACCEPT => ACCEPT, Headers::CONTENT_TYPE => "#{CONTENT}; charset=#{body.encoding.name}" ).post(url, body: body), data: data ) end end |