Module: Edi::PartnerNames

Defined in:
app/services/edi/partner_names.rb

Overview

Human names for EDI partner keys.

A key is not always a claim about who the partner is — commercehub_thd_*
is "Home Depot", nobody's key spells out "Brico Dépôt" — so this map, not
the key, is what anyone is shown.

Constant Summary collapse

DISPLAY_NAMES =

Matched by prefix, so per-market keys (_us / _ca / _fr) share one
entry. commercehub_lowes_com is spelled out in full: a bare
commercehub_lowes prefix is what titled RONA's order digest "Lowe's"
back when RONA's own key still said lowes.

{
  'amazon_seller_central' => 'Amazon',
  'amazon_vc_seller_api' => 'Amazon Vendor Central',
  'mft_gateway_amazon_vc' => 'Amazon Vendor Central',
  'commercehub_costco' => 'Costco',
  'commercehub_thd' => 'Home Depot',
  'commercehub_rona_ca' => 'RONA',
  'commercehub_lowes_com' => "Lowe's",
  'walmart_seller' => 'Walmart',
  'wayfair' => 'Wayfair',
  'mft_gateway_build_com' => 'Build.com',
  'mft_gateway_canadian_tire' => 'Canadian Tire',
  'mft_gateway_zoro_tools' => 'Zoro Tools',
  'leroymerlin_adeo' => 'Leroy Merlin',
  'castorama' => 'Castorama',
  'bricodepot' => 'Brico Dépôt',
  'bricomarche' => 'Bricomarché',
  'leclerc' => 'Leclerc',
  'maxeda' => 'Maxeda'
}.freeze

Class Method Summary collapse

Class Method Details

.display_for(partner_key, fallback: 'EDI') ⇒ String

Resolves a partner key to the name a human should see.

Parameters:

  • partner_key (String, Symbol, nil)

    key from the orchestrator config
    (e.g. +'commercehub_rona_ca'+)

  • fallback (String) (defaults to: 'EDI')

    returned when the key is blank

Returns:

  • (String)

    display name, or a titleized key when unmapped



41
42
43
44
45
46
47
# File 'app/services/edi/partner_names.rb', line 41

def self.display_for(partner_key, fallback: 'EDI')
  return fallback if partner_key.blank?

  key = partner_key.to_s
  DISPLAY_NAMES.each { |prefix, name| return name if key.start_with?(prefix) }
  key.titleize
end