Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/beyond_api/concerns/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def delete(path, params = {}, body = {})
end
end

def patch(path, body = {}, params = {})
handle_request do
agent.patch(path, body) do |request|
request.params = parse_request(params)
request.body = parse_request(body)
end
end
end

def upload_file(path, file_path, content_type, params = {})
handle_request do
agent.post(path) do |request|
Expand Down
21 changes: 21 additions & 0 deletions lib/beyond_api/services/product_management/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,27 @@ def remove_tags_from_products(ids, tags)
}
delete('products/batch/tags', {}, body)
end

# Update variation properties of a product.
#
# @see https://developer.epages.com/beyond-docs/#update_variation_properties
#
# @param id [String] the product UUID
# @param body [Hash] the request body containing variation properties
#
# @return [Hash]
#
# @example
# variation_properties = [
# { property: 'salesPrice', enabled: true },
# { property: 'listPrice', enabled: true },
# { property: 'manufacturerPrice', enabled: true },
# { property: 'productIdentifiers', enabled: true },
# { property: 'defaultImage', enabled: true },
# ]
def update_variation_properties(id, body)
patch("products/#{id}/variation-properties", body)
end
end
end
end
37 changes: 37 additions & 0 deletions lib/beyond_api/services/product_management/variation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,43 @@ class Variation < BaseService
def all(id, params = {})
get("products/#{id}/variations", params)
end

# Update a variation partially with json content type.
#
# @see https://developer.epages.com/beyond-docs/#update_variation_partially_json
#
# @param id [String] the product UUID
# @param variation_id [String] the variation UUID
# @param body [Hash] the request body
#
# @return [Hash]
#
# @example
# variation = {
# sales_price: {
# tax_model: "GROSS",
# amount: 29.99,
# currency: "EUR"
# },
# list_price: {
# tax_model: "GROSS",
# amount: 39.99,
# currency: "EUR"
# },
# manufacturer_price: {
# tax_model: "GROSS",
# amount: 40.99,
# currency: "EUR"
# },
# sku: "1010"
# }
# @client.update('4125b993-49fc-47c8-b9b3-76d8871e4e06',
# 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
# variation)
#
def update(id, variation_id, body)
patch("products/#{id}/variations/#{variation_id}", body)
end
end
end
end