Method: EasyPost::InternalUtilities.objects_to_ids

Defined in:
lib/easypost/internal_utilities.rb

.objects_to_ids(obj) ⇒ Object

Converts an object to an object ID.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/easypost/internal_utilities.rb', line 41

def self.objects_to_ids(obj)
  case obj
  when EasyPost::Models::EasyPostObject
    { id: obj.id }
  when Hash
    result = {}
    obj.each { |k, v| result[k] = objects_to_ids(v) unless v.nil? }
    result
  when Array
    obj.map { |v| objects_to_ids(v) }
  else
    obj
  end
end