|
2 | 2 |
|
3 | 3 | module BeyondApi |
4 | 4 | module ProductManagement |
| 5 | + # @example How to instantiate a client |
| 6 | + # @client = BeyondApi::ProductManagement::Product.new(api_url: 'https://example.com/api', access_token: 'your_token') |
5 | 7 | class Product < BaseService |
| 8 | + # List all products in a paged manner. |
| 9 | + # |
| 10 | + # @see https://developer.epages.com/beyond-docs/#list_products |
| 11 | + # |
| 12 | + # @option params [Boolean] :paginated |
| 13 | + # @option params [Integer] :size the page size |
| 14 | + # @option params [Integer] :page the page number |
| 15 | + # |
| 16 | + # @return [Hash] |
| 17 | + # |
| 18 | + # @example |
| 19 | + # @client.all(size: 100, page: 0) |
6 | 20 | def all(params = {}) |
7 | 21 | fetch_all_pages('products', params) |
8 | 22 | end |
9 | 23 |
|
| 24 | + # Create a product. |
| 25 | + # |
| 26 | + # @see https://developer.epages.com/beyond-docs/#create_product |
| 27 | + # |
| 28 | + # @param body [Hash] the request body |
| 29 | + # |
| 30 | + # @return [Hash] |
| 31 | + # |
| 32 | + # @example |
| 33 | + # product_data = { |
| 34 | + # sku: '123456789-001', |
| 35 | + # name: 'Rioja Castillo de Puerto (2013)', |
| 36 | + # description: 'Spain\nRioja Tempranillo', |
| 37 | + # manufacturer: 'Grape Vineyard', |
| 38 | + # essential_features: 'Dry. 12% alcohol. Best vine variety.', |
| 39 | + # tags: ['Bestseller', 'Red Wine', 'Sale'], |
| 40 | + # product_identifiers: [ |
| 41 | + # { |
| 42 | + # type: 'EAN', |
| 43 | + # value: '9780134308135' |
| 44 | + # } |
| 45 | + # ], |
| 46 | + # sales_price: { |
| 47 | + # tax_model: 'GROSS', |
| 48 | + # amount: 8.7, |
| 49 | + # currency: 'EUR' |
| 50 | + # }, |
| 51 | + # list_price: { |
| 52 | + # tax_model: 'GROSS', |
| 53 | + # amount: 10.95, |
| 54 | + # currency: 'EUR' |
| 55 | + # }, |
| 56 | + # manufacturer_price: { |
| 57 | + # tax_model: 'GROSS', |
| 58 | + # amount: 11.95, |
| 59 | + # currency: 'EUR' |
| 60 | + # }, |
| 61 | + # visible: true, |
| 62 | + # tax_class: 'REGULAR', |
| 63 | + # shipping_weight: { |
| 64 | + # value: 1175.0, |
| 65 | + # display_unit: 'GRAMS' |
| 66 | + # }, |
| 67 | + # max_order_quantity: 6, |
| 68 | + # shipping_dimension: { |
| 69 | + # length: 1500, |
| 70 | + # width: 1000, |
| 71 | + # height: 2000 |
| 72 | + # }, |
| 73 | + # ref_price: { |
| 74 | + # ref_quantity: 1, |
| 75 | + # unit: 'LITER', |
| 76 | + # quantity: 0.75, |
| 77 | + # price: { |
| 78 | + # tax_model: 'GROSS', |
| 79 | + # amount: 11.6, |
| 80 | + # currency: 'EUR' |
| 81 | + # } |
| 82 | + # }, |
| 83 | + # shipping_period: { |
| 84 | + # min: 2, |
| 85 | + # max: 4, |
| 86 | + # display_unit: 'WEEKS' |
| 87 | + # }, |
| 88 | + # pickup_period: { |
| 89 | + # min: 1, |
| 90 | + # max: 2, |
| 91 | + # display_unit: 'WEEKS' |
| 92 | + # }, |
| 93 | + # product_labels: [ |
| 94 | + # { |
| 95 | + # type: 'NEW', |
| 96 | + # active_from: '2024-08-19T13:04:55.897122293', |
| 97 | + # active_until: '2024-09-16T13:04:55.897122293' |
| 98 | + # } |
| 99 | + # ] |
| 100 | + # } |
| 101 | + # @client.create(product_data) |
10 | 102 | def create(body) |
11 | 103 | post('products', body) |
12 | 104 | end |
13 | 105 |
|
| 106 | + # Retrieve the details of a product. |
| 107 | + # |
| 108 | + # @see https://developer.epages.com/beyond-docs/#show_product_details |
| 109 | + # |
| 110 | + # @param id [String] the product UUID |
| 111 | + # |
| 112 | + # @return [Hash] |
| 113 | + # |
| 114 | + # @example |
| 115 | + # @client.find('985efde9-577c-4752-9556-af5ed8a81b1b') |
14 | 116 | def find(id) |
15 | 117 | get("products/#{id}") |
16 | 118 | end |
|
0 commit comments