module PIM::Services::ReviewService

Constants

REVIEW_STATUS

Public Instance Methods

__review_service() click to toggle source
# File services.rb, line 4004
def __review_service
  __service(:reviewService)
end
get_item_review_as_reviewer(primary_key) click to toggle source
# File services.rb, line 3955
def get_item_review_as_reviewer primary_key
  __review_service.getReviewerItemReview(primary_key)
end
get_item_review_as_supplier(primary_key, reviewer) click to toggle source
# File services.rb, line 3959
def get_item_review_as_supplier primary_key, reviewer
  __review_service.getSupplierItemReview(primary_key, reviewer)
end
send_review(review_hash) click to toggle source

Save and send a review containing data from the specified review hash.

The hash can include the following keys:

  • primary_key: Primary key of the item the review is for (MANDATORY!)

  • review_status: Status for the review, any of RECEIVED, APPROVED, REJECTED, REVIEWED (MANDATORY!)

  • comment: The review’s comment (OPTIONAL, not set if nil)

  • generated_comment: The review’s “generated comment”, i.e. it can not be overwritten by a user (OPTIONAL, not set if nil)

  • custom_values: An optional Hash containing arbitrary values which can be used e.g. in XML transformations (OPTIONAL, not set if nil)

NOTE: If NO ‘generated_comment’ is provided, the ‘comment’ value is used as ‘generated_comment’ instead!

# File services.rb, line 3976
def send_review review_hash

  comment = PIM.get_value(review_hash, :comment)
  generated_comment = PIM.get_value(review_hash, :generated_comment, :generatedComment)

  # Legacy behavior: If only a 'comment' was specified, use that as 'generated_comment' instead
  if generated_comment.nil?
    generated_comment = comment
    comment = nil
  end

  primary_key = PIM.get_value(review_hash, :primary_key, :primaryKey)
  raise "Item review 'primaryKey' must not be empty" if PIM.is_empty?(primary_key)

  review_status = PIM.get_value(review_hash, :review_status, :reviewStatus)
  raise "Item review 'review_status' must not be empty" if PIM.is_empty?(review_status)
  review_status = review_status.to_s
  raise "Item review review status '#{review_status}' for primary key '#{primary_key}' must by any of #{REVIEW_STATUS.join(', ')}" unless REVIEW_STATUS.include?(review_status)

  __review_service.saveReviewerItemReviewFromRuby(
    primary_key,
    review_status,
    comment,
    generated_comment,
    PIM.get_value(review_hash, :custom_values, :customValues)
  )
end