Class: Seko::Dispatch

Inherits:
Object
  • Object
show all
Defined in:
lib/seko/dispatch.rb

Class Method Summary collapse

Class Method Details

.line_items(response) ⇒ Object



4
5
6
# File 'lib/seko/dispatch.rb', line 4

def self.line_items(response)
  response.root_response["List"]["DispatchLineItem"]
end

.parse(response) ⇒ Object

returns array of GUIDs



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/seko/dispatch.rb', line 9

def self.parse(response)
  dispatches = line_items(response)
  # API is flawed and returns an array if multiple dispatches
  if dispatches.is_a?(Array)
    dispatches.collect { |h| h["GUID"] }
  else
    # and a singular object otherwise
    # so we wrap it as an array
    Array(dispatches["GUID"])
  end
end