Module: PlentyClient::Endpoint
- Included in:
- Item, Item::Attribute, Item::Barcode, Item::CrossSelling, Item::Image, Item::Manufacturer, Item::Manufacturer::Commission, Item::Property, Item::PropertyGroup, Item::PropertyGroupName, Item::SalesPrice, Item::ShippingProfile, Item::Unit, Item::UnitName, Item::Variation, Item::Variation::Barcode, Item::Variation::Bundle, Item::Variation::Category, Item::Variation::Client, Item::Variation::DefaultCategory, Item::Variation::Description, Item::Variation::Image, Item::Variation::Market, Item::Variation::MarketIdentNumber, Item::Variation::Sku, Item::Variation::Stock, Item::Variation::Supplier, Item::Variation::Warehouse, Item::VariationProperty, ItemSet, ItemSet::Config, Order, Order::ContactWish, Order::CouponCode, Order::CouponCode::Contact, Order::CouponCode::Validation, Order::Currency, Order::Date, Order::Item, Order::Item::Date, Order::Item::Property, Order::Item::SerialNumber, Order::Property, Order::Referrer, Order::Shipping, Order::Shipping::Country, Order::Shipping::Information, Order::Shipping::Package, Order::Shipping::Profile, Order::Shipping::ServiceProvider, SalesPrice::Account, SalesPrice::Country, SalesPrice::Currency, SalesPrice::CustomerClass, SalesPrice::Name, SalesPrice::OnlineStore, SalesPrice::Referrer
- Defined in:
- lib/plenty_client/endpoint.rb
Instance Method Summary collapse
-
#build_endpoint(api_endpoint_template, arguments = {}) ⇒ Object
Method that replaces the arguments in an endpoint with the given parameters.
- #routes ⇒ Object
Instance Method Details
#build_endpoint(api_endpoint_template, arguments = {}) ⇒ Object
Method that replaces the arguments in an endpoint with the given parameters. Arguments that are passed to the build_endpoint method, but do not live in the endpoint, are discarded.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/plenty_client/endpoint.rb', line 6 def build_endpoint(api_endpoint_template, arguments = {}) # Duplicate constant to temporary endpoint string api_endpoint_result = api_endpoint_template.dup # Endpoint parameters hash that links symbols to regex endpoint_parameters = { account: /\{accountId\}/, account_ype: /\{accountType\}/, attribute: /\{attributeId\}/, attribute_value: /\{attributeValueId\}/, barcode: /\{barcodeId\}/, bundle: /\{bundleId\}/, cat: /\{catId\}/, commission: /\{commissionId\}/, component: /\{componentId\}/, contact: /\{contactId\}/, country: /\{countryId\}/, coupon_string: /\{coupon\}/, cross_item: /\{crossItemId\}/, currency: /\{currencyIso\}/, customer_class: /\{customerClassId\}/, image: /\{imageId\}/, item: /\{itemId\}/, item_set: /\{itemSetId\}/, lang: /\{lang\}/, manufacturer: /\{manufacturerId\}/, market: /\{marketId\}/, market_ident_number: /\{marketIdentNumberId\}/, marketplace: /\{marketplaceId\}/, order: /\{orderId\}/, order_item: /\{orderItemId\}/, parent_referrer: /\{parentReferrerId\}/, plenty: /\{plentyId\}/, preset: /\{presetId\}/, price: /\{priceId\}/, property_group: /\{propertyGroupId\}/, property: /\{propertyId\}/, referrer: /\{referrerId\}/, sales_price: /\{salesPriceId\}/, shipping_profile: /\{shippingProfileId\}/, shipping_package: /\{orderShippingPackageId\}/, shipping_service_provider: /\{shippingServiceProviderID\}/, sku: /\{skuId\}/, type: /\{typeId\}/, type_string: /\{type\}/, unit: /\{unitId\}/, value: /\{valueId\}/, variation: /\{variationId\}/, variation_supplier: /\{variationSupplierId\}/, warehouse: /\{warehouseId\}/, webstore: /\{webstoreId\}/ } # Loop over the given argument symbols, retrieve the corresponding regex # and replace the argument with the corresponding value. arguments.each do |k, v| api_endpoint_result.gsub!(endpoint_parameters.fetch(k), v.to_s) end api_endpoint_result end |
#routes ⇒ Object
66 67 68 69 70 71 |
# File 'lib/plenty_client/endpoint.rb', line 66 def routes # Prints all available routes with their values in the given module constants.each do |const| puts "#{const}: \t #{const_get(const)}" if const.to_s.upcase!.nil? end end |