Class: Edi::MftGateway::Orchestrator

Inherits:
BaseOrchestrator show all
Defined in:
app/services/edi/mft_gateway/orchestrator.rb

Overview

Service object: orchestrator.

Constant Summary collapse

AS2ID_BY_PARTNER =

As2id by partner.

{
  # mft_gateway_build_com: (Rails.env.production? ? 'improvement-direct-02' : 'IMPROVEMENT-DIRECT-TEST')
  # mft_gateway_canadian_tire: (Rails.env.production? ? 'SPSAS2' : 'CA-TIRE-TEST'),
  # mft_gateway_zoro_tools: (Rails.env.production? ? 'SPSAS2' : 'ZORO-TOOLS-TEST'),
  mft_gateway_build_com: (Rails.env.production? ? 'AS2-FergusonHome' : 'IMPROVEMENT-DIRECT-TEST'),
  mft_gateway_canadian_tire: (Rails.env.production? ? 'RITHUMAS2' : 'CA-TIRE-TEST'), # DscoExAs2 # RITHUMAS2
  mft_gateway_zoro_tools: (Rails.env.production? ? 'SPSAS2' : 'ZORO-TOOLS-TEST'),
  mft_gateway_amazon_vc_edi_wasn4: (Rails.env.production? ? 'SNQDYISW0VJFYN' : 'AMZN-US-TEST'), # TEST 'SN2S7KZWP2V5SNW'
  mft_gateway_amazon_vc_edi_wat0f: (Rails.env.production? ? 'SNI2IYTGFP2DKI' : 'AMZN-US-TEST')
}.freeze

Constants inherited from BaseOrchestrator

BaseOrchestrator::DEFAULT_PENDING_DISCONTINUE_LIFETIME, BaseOrchestrator::ORCHESTRATORS, BaseOrchestrator::RECOMMENDED_EXECUTE_FLOW_EVERY_X_HOUR

Instance Attribute Summary

Attributes inherited from BaseOrchestrator

#config, #logger, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseOrchestrator

all_orchestrators_class, build, build_customer_id_to_partner_key_map, cached_build, cached_orchestrators, catalog_id_to_pending_discontinue_lifetime, catalog_ids_edi_enabled, #confirm_outbound_processing?, #customer, #customer_catalog, customer_id_to_partner_key_map, #customer_ids, customer_ids_edi_enabled, customer_ids_with_invoice_message_enabled, #customers, execute_discontinue_flow, execute_flow, execute_inventory_flow, execute_listing_message_feed_flow, execute_order_flow, execute_price_flow, #execute_price_flow, execute_product_data_flow, #execute_product_data_flow, #ignore_back_orders, #initialize, orchestrator_for_customer_id, orchestrators, #pending_discontinue_lifetime, #price_message_enabled?, #product_data_enabled?, #should_execute_flow?, #should_execute_order_flow?, #should_execute_product_data_flow?, #test_mode?

Constructor Details

This class inherits a constructor from Edi::BaseOrchestrator

Class Method Details

.partnersObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 49

def self.partners
  {
    mft_gateway_build_com: {
      active: true,
      partner: :mft_gateway_build_com,
      customer_id: 183_302,
      partner_id: 'ACPALLWARMLYYOU',
      as2_id: AS2ID_BY_PARTNER[:mft_gateway_build_com],
      partner_name: 'Build.com',
      vendor_id: 'Warmly_Yours',
      warehouse_code: "WY-US", # here we are using the code, no hash
      transporter: :basic_http_api,
      transporter_profile: :mft_gateway_api,
      order_message_enabled: true,
      acknowledge_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_build_com]}&ediType=855",
      confirm_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_build_com]}&ediType=856",
      ignore_back_orders: true,
      inventory_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_build_com]}&ediType=846",
      execute_inventory_flow_every_x_hour: 6,
      invoice_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_build_com]}&ediType=810",
      generate_packing_slip: false,
      support_contact: 'Udith Gunaratna, udith@edigenerator.com, support@mftgateway.com, support@edigenerator.com'
    },
    mft_gateway_canadian_tire: {
      active: true,
      partner: :mft_gateway_canadian_tire,
      customer_id: 20_095_485,
      partner_id: '043EDIWARMLYYOU',
      as2_id: AS2ID_BY_PARTNER[:mft_gateway_canadian_tire],
      partner_name: 'Canadian Tire',
      vendor_id: 'G6JH',
      warehouse_code: "WY-CA", # here we are using the code, no hash
      transporter: :basic_http_api,
      transporter_profile: :mft_gateway_api,
      order_message_enabled: true,
      acknowledge_only_on_pending_ship_confirm: true,
      acknowledge_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_canadian_tire]}&ediType=855",
      confirm_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_canadian_tire]}&ediType=856",
      ignore_back_orders: true,
      inventory_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_canadian_tire]}&ediType=846",
      execute_inventory_flow_every_x_hour: 6,
      invoice_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_canadian_tire]}&ediType=810",
      support_contact: 'Udith Gunaratna, udith@edigenerator.com, support@mftgateway.com, support@edigenerator.com',
      generate_packing_slip: false,
      tax_registration_number: '86138 7777 RT0001'
    },
    mft_gateway_zoro_tools: {
      active: true,
      partner: :mft_gateway_zoro_tools,
      customer_id: 17_765_581,
      partner_id: '0XNALLWARMLYYOU',
      as2_id: AS2ID_BY_PARTNER[:mft_gateway_zoro_tools],
      partner_name: 'Zoro Tools',
      vendor_id: '106123881', # per Sydney at SPS Commerse'VEN1205',
      warehouse_code: "WY-US", # here we are using the code, no hash
      transporter: :basic_http_api,
      transporter_profile: :mft_gateway_api,
      order_message_enabled: true,
      acknowledge_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_zoro_tools]}&ediType=855",
      confirm_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_zoro_tools]}&ediType=856",
      ignore_back_orders: true,
      inventory_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_zoro_tools]}&ediType=846",
      execute_inventory_flow_every_x_hour: 6,
      invoice_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_zoro_tools]}&ediType=810",
      generate_packing_slip: true,
      support_contact: 'Udith Gunaratna, udith@edigenerator.com, support@mftgateway.com, support@edigenerator.com'
    },
    mft_gateway_amazon_vc_edi_wasn4: {
      active: true,
      partner: :mft_gateway_amazon_vc_edi_wasn4,
      customer_id: 2_385_944,
      partner_id: 'WASN4',
      as2_id: AS2ID_BY_PARTNER[:mft_gateway_amazon_vc_edi_wasn4],
      partner_name: 'Amazon Vendor Central US WASN4',
      vendor_id: 'WASN4',
      warehouse_code: "WB0I1", # here we are using the code, no hash
      transporter: :basic_http_api,
      transporter_profile: :mft_gateway_api,
      order_message_enabled: false,
      acknowledge_only_on_pending_ship_confirm: false,
      acknowledge_message_remote_path: nil,
      confirm_message_remote_path: nil,
      ignore_back_orders: true,
      inventory_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_amazon_vc_edi_wasn4]}&ediType=846",
      execute_inventory_flow_every_x_hour: 6,
      invoice_message_remote_path: nil,
      support_contact: 'Udith Gunaratna, udith@edigenerator.com, support@mftgateway.com, support@edigenerator.com',
      generate_packing_slip: false,
      tax_registration_number: nil
    },
    mft_gateway_amazon_vc_edi_wat0f: {
      active: true,
      partner: :mft_gateway_amazon_vc_edi_wat0f,
      customer_id: 2_741_053,
      partner_id: 'WAT0F',
      as2_id: AS2ID_BY_PARTNER[:mft_gateway_amazon_vc_edi_wat0f],
      partner_name: 'Amazon Vendor Central Canada WAT0F',
      vendor_id: 'WAT0F',
      warehouse_code: "WB102", # here we are using the code, no hash
      transporter: :basic_http_api,
      transporter_profile: :mft_gateway_api,
      order_message_enabled: false,
      acknowledge_only_on_pending_ship_confirm: false,
      acknowledge_message_remote_path: nil,
      confirm_message_remote_path: nil,
      ignore_back_orders: true,
      inventory_message_remote_path: "#{Heatwave::Configuration.fetch(:mft_gateway_api, :hostname)}/OutgoingAdapterWarmlyYours?as2id=#{AS2ID_BY_PARTNER[:mft_gateway_amazon_vc_edi_wat0f]}&ediType=846",
      execute_inventory_flow_every_x_hour: 6,
      invoice_message_remote_path: nil,
      support_contact: 'Udith Gunaratna, udith@edigenerator.com, support@mftgateway.com, support@edigenerator.com',
      generate_packing_slip: false,
      tax_registration_number: nil
    }
  }
end

Instance Method Details

#acknowledge_message_enabled?Boolean

Returns:

  • (Boolean)


240
241
242
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 240

def acknowledge_message_enabled?
  try(:acknowledge_message_remote_path).present?
end

#acknowledge_message_senderObject



244
245
246
247
248
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 244

def acknowledge_message_sender
  return Edi::NullProcessor.new(self, :acknowledge_message_sender, options) unless acknowledge_message_enabled?

  AcknowledgeMessageSender.new(self, options)
end

#confirm_message_enabled?Boolean Also known as: shipment_message_enabled?

Returns:

  • (Boolean)


229
230
231
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 229

def confirm_message_enabled?
  try(:confirm_message_remote_path).present?
end

#confirm_message_processorObject



234
235
236
237
238
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 234

def confirm_message_processor
  return Edi::NullProcessor.new(self, :confirm_message_processor, options) unless confirm_message_enabled?

  ConfirmMessageProcessor.new(self, options)
end

#confirm_message_senderObject Also known as: shipment_message_sender



250
251
252
253
254
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 250

def confirm_message_sender
  return Edi::NullProcessor.new(self, :confirm_message_sender, options) unless confirm_message_enabled?

  ConfirmMessageSender.new(self, options)
end

#execute_inventory_flowObject



347
348
349
350
351
352
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 347

def execute_inventory_flow
  return unless active

  inventory_message_processor.process
  inventory_message_sender.process
end

#execute_order_flowObject



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 323

def execute_order_flow
  return unless active

  # order_message_retriever.process # We receive MFT orders directly via an API endpoint in HW from MFT, no retrieval necessary
  # sleep(1)
  packing_slip_retriever.process
  sleep(1)
  order_message_processor.process
  fa_message_sender.process
  sleep(5)
  packing_slip_processor.process
  sleep(1)
  acknowledge_message_sender.process
  confirm_message_sender.process
  sleep(1)
  invoice_message_sender.process
  sleep(1)
  remit_message_retriever.process
  sleep(1)
  remit_message_processor.process
  sleep(1)
  return_notification_message_sender.process
end

#fa_message_enabled?Boolean

Returns:

  • (Boolean)


213
214
215
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 213

def fa_message_enabled?
  try(:fa_message_remote_path).present?
end

#fa_message_processorObject



217
218
219
220
221
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 217

def fa_message_processor
  return Edi::NullProcessor.new(self, :fa_message_processor, options) unless fa_message_enabled?

  FaMessageProcessor.new(self, options)
end

#fa_message_senderObject



223
224
225
226
227
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 223

def fa_message_sender
  return Edi::NullProcessor.new(self, :fa_message_sender, options) unless fa_message_enabled?

  FaMessageSender.new(self, options)
end

#generate_unique_document_id(doc_category) ⇒ Object



354
355
356
357
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 354

def generate_unique_document_id(doc_category)
  prefix = EdiCommunicationLog.get_file_prefix_from(partner, doc_category)
  "#{prefix}#{Time.current.to_i}".first(30)
end

#inventory_message_enabled?Boolean

Returns:

  • (Boolean)


277
278
279
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 277

def inventory_message_enabled?
  try(:inventory_message_remote_path).present?
end

#inventory_message_processorObject



281
282
283
284
285
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 281

def inventory_message_processor
  return Edi::NullProcessor.new(self, :inventory_message_processor, options) unless inventory_message_enabled?

  InventoryMessageProcessor.new(self, options)
end

#inventory_message_senderObject



287
288
289
290
291
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 287

def inventory_message_sender
  return Edi::NullProcessor.new(self, :inventory_message_sender, options) unless inventory_message_enabled?

  InventoryMessageSender.new(self, options)
end

#invoice_message_enabled?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 181

def invoice_message_enabled?
  try(:invoice_message_remote_path).present?
end

#invoice_message_processorObject



185
186
187
188
189
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 185

def invoice_message_processor
  return Edi::NullProcessor.new(self, :invoice_message_processor, options) unless invoice_message_enabled?

  InvoiceMessageProcessor.new(self, options)
end

#invoice_message_senderObject



191
192
193
194
195
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 191

def invoice_message_sender
  return Edi::NullProcessor.new(self, :invoice_message_sender, options) unless invoice_message_enabled?

  InvoiceMessageSender.new(self, options)
end

#order_message_enabled?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 165

def order_message_enabled?
  try(:order_message_enabled)
end

#order_message_processorObject

OrderMessageRetriever.new(self, options)
end



175
176
177
178
179
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 175

def order_message_processor
  return Edi::NullProcessor.new(self, :order_message_processor, options) unless order_message_enabled?

  OrderMessageProcessor.new(self, options)
end

#packing_slip_enabled?Boolean

Returns:

  • (Boolean)


293
294
295
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 293

def packing_slip_enabled?
  try(:packing_slip_remote_path).present? && try(:packing_slip_file_pattern).present?
end

#packing_slip_processorObject



303
304
305
306
307
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 303

def packing_slip_processor
  return Edi::NullProcessor.new(self, :packing_slip_processor, options) unless packing_slip_enabled?

  PackingSlipProcessor.new(self, options)
end

#packing_slip_readerObject



313
314
315
316
317
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 313

def packing_slip_reader
  return Edi::NullProcessor.new(self, :packing_slip_reader, options) unless packing_slip_reader_enabled?

  packing_slip_reader_type.new(self, options)
end

#packing_slip_reader_enabled?Boolean

Returns:

  • (Boolean)


309
310
311
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 309

def packing_slip_reader_enabled?
  try(:packing_slip_reader_type).present?
end

#packing_slip_retrieverObject



297
298
299
300
301
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 297

def packing_slip_retriever
  return Edi::NullProcessor.new(self, :packing_slip_retriever, options) unless packing_slip_enabled?

  PackingSlipRetriever.new(self, options)
end

#remit_message_enabled?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 257

def remit_message_enabled?
  try(:remit_message_remote_path).present? && try(:remit_message_file_pattern).present?
end

#remit_message_processorObject



271
272
273
274
275
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 271

def remit_message_processor
  return Edi::NullProcessor.new(self, :remit_message_processor, options) unless remit_message_enabled?

  RemitMessageProcessor.new(self, options)
end

#remit_message_processor_enabled?Boolean

Returns:

  • (Boolean)


261
262
263
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 261

def remit_message_processor_enabled?
  try(:remit_message_processor_active).present? && remit_message_processor_active == true
end

#remit_message_retrieverObject



265
266
267
268
269
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 265

def remit_message_retriever
  return Edi::NullProcessor.new(self, :remit_message_retriever, options) unless remit_message_enabled?

  RemitMessageRetriever.new(self, options)
end

#return_notification_message_enabled?Boolean

Returns:

  • (Boolean)


197
198
199
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 197

def return_notification_message_enabled?
  try(:return_notification_message_remote_path).present?
end

#return_notification_message_processorObject



201
202
203
204
205
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 201

def return_notification_message_processor
  return Edi::NullProcessor.new(self, :return_notification_message_processor, options) unless return_notification_message_enabled?

  ReturnNotificationMessageProcessor.new(self, options)
end

#return_notification_message_senderObject



207
208
209
210
211
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 207

def return_notification_message_sender
  return Edi::NullProcessor.new(self, :return_notification_message_sender, options) unless return_notification_message_enabled?

  ReturnNotificationMessageSender.new(self, options)
end

#ship_code_mapperObject



319
320
321
# File 'app/services/edi/mft_gateway/orchestrator.rb', line 319

def ship_code_mapper
  ShipCodeMapper.new(self)
end