Class: TrailerVote::Api::Product::Update
- Inherits:
-
Object
- Object
- TrailerVote::Api::Product::Update
- Includes:
- Composable::Common
- Defined in:
- lib/trailer_vote/api/product/update.rb
Constant Summary collapse
- CONTENT =
MediaTypes::Product.to_constructable.version(2)
- SUCCESS =
MediaTypes::Product.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::Product::Find
Api to deal with a found product.
- #call(data:, url: resolve_url, etag: resolve_etag) ⇒ Object
-
#initialize(configuration:, product:) ⇒ Update
constructor
A new instance of Update.
Methods included from Composable::Common
Constructor Details
#initialize(configuration:, product:) ⇒ Update
Returns a new instance of Update.
27 28 29 30 |
# File 'lib/trailer_vote/api/product/update.rb', line 27 def initialize(configuration:, product:) self.configuration = configuration self.product = product end |
Instance Method Details
#back ⇒ TrailerVote::Api::Product::Find
Returns api to deal with a found product.
33 34 35 |
# File 'lib/trailer_vote/api/product/update.rb', line 33 def back product end |
#call(data:, url: resolve_url, etag: resolve_etag) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/trailer_vote/api/product/update.rb', line 37 def call(data:, url: resolve_url, etag: resolve_etag) body = encode(data) guard_network_errors do branch( resolve_client.headers( Headers::ACCEPT => ACCEPT, Headers::CONTENT_TYPE => "#{CONTENT}; charset=#{body.encoding.name}", Headers::IF_MATCH => etag ).put(url, body: body), data: data ) end end |