Class: Edi::Wayfair::CatalogReadV2Request

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/edi/wayfair/catalog_read_v2_request.rb

Overview

Executes and parses one Catalog Read v2 supplier-part-number request.
Transport failures become data so one bad batch does not abort the pull.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callResult

Performs the request and parses the response.

Returns:



29
30
31
32
33
34
35
36
37
38
39
# File 'app/services/edi/wayfair/catalog_read_v2_request.rb', line 29

def call
  transport = transport_builder.call
  http = transport.send_request('POST', url, payload, headers(transport))[:http_res]
  return failure("HTTP #{http&.status}") unless http&.status&.between?(200, 299)

  parse(http.body)
rescue JSON::ParserError => e
  failure("parse error: #{e.message}")
rescue StandardError => e
  failure("#{e.class}: #{e.message}")
end