Class: Bing::Content::Api::BatchOperation
- Inherits:
-
Object
- Object
- Bing::Content::Api::BatchOperation
- Defined in:
- lib/bing/content/api/batch_operation.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#batch_id ⇒ Object
readonly
Returns the value of attribute batch_id.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
Instance Method Summary collapse
- #bing_operation ⇒ Object
-
#initialize(batch_id, product, action = :insert) ⇒ BatchOperation
constructor
A new instance of BatchOperation.
Constructor Details
#initialize(batch_id, product, action = :insert) ⇒ BatchOperation
Returns a new instance of BatchOperation.
10 11 12 13 14 15 16 |
# File 'lib/bing/content/api/batch_operation.rb', line 10 def initialize(batch_id, product, action=:insert) raise "Please select a valid operation." unless %i(insert delete).include? action @batch_id = batch_id @product = product @action = action end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'lib/bing/content/api/batch_operation.rb', line 8 def action @action end |
#batch_id ⇒ Object (readonly)
Returns the value of attribute batch_id.
6 7 8 |
# File 'lib/bing/content/api/batch_operation.rb', line 6 def batch_id @batch_id end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
7 8 9 |
# File 'lib/bing/content/api/batch_operation.rb', line 7 def product @product end |
Instance Method Details
#bing_operation ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bing/content/api/batch_operation.rb', line 18 def bing_operation operation = { batchId: @batch_id } case @action when :insert operation[:product] = @product.to_record operation[:method] = "insert" when :delete operation[:productId] = @product.bing_product_id operation[:method] = "delete" end operation end |