Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse internal ID when adding File #241

Open
jordan-allan opened this issue Feb 23, 2016 · 2 comments
Open

Unable to parse internal ID when adding File #241

jordan-allan opened this issue Feb 23, 2016 · 2 comments

Comments

@jordan-allan
Copy link
Contributor

When adding a new File, the following error occurs:

NoMethodError: undefined method `[]' for #<Nori::StringIOFile:0x007fdea1cfac88>
        from /Users/jordan/projects/netsuite/lib/netsuite/actions/add.rb:82:in `add'
        from (irb):4

It appears the Nori to_hash method assumes type="file" is a data type and typecasts it to file object.

Response:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
    <soapenv:Body>
        <addResponse xmlns=\"urn:messages_2015_1.platform.webservices.netsuite.com\">
            <writeResponse>
                <platformCore:status isSuccess=\"true\" xmlns:platformCore=\"urn:core_2015_1.platform.webservices.netsuite.com\"/>
                <baseRef internalId=\"914\" type=\"file\" xsi:type=\"platformCore:RecordRef\" xmlns:platformCore=\"urn:core_2015_1.platform.webservices.netsuite.com\"/>
            </writeResponse>
        </addResponse>
    </soapenv:Body>
</soapenv:Envelope>
@jordan-allan jordan-allan changed the title Unable to parse response when adding File Unable to parse internal ID when adding File Feb 23, 2016
@iloveitaly
Copy link
Member

@jdedels I'm not going to have time in the near future to fix this one up for you, feel free to submit a PR!

@jordan-allan
Copy link
Contributor Author

Temporarily created a monkey patch in my project:

class Nori
  class XmlUtilityNode
    def initialize(options, name, attributes = {})
      @options = options
      @name = Nori.hash_key(name, options)

      if converter = options[:convert_attributes_to]
        intermediate = attributes.map {|k, v| converter.call(k, v) }.flatten
        attributes = Hash[*intermediate]
      end

      # leave the type alone if we don't know what it is
      @type = self.class.available_typecasts.include?(attributes["type"]) ? attributes.delete("type") : attributes["type"]

      @nil_element = false
      attributes.keys.each do |key|
        if result = /^((.*):)?nil$/.match(key)
          @nil_element = attributes.delete(key) == "true"
          attributes.delete("xmlns:#{result[2]}") if result[1]
        end
        attributes.delete(key) if @options[:delete_namespace_attributes] && key[/^(xmlns|xsi)/]
      end
      @attributes = undasherize_keys(attributes)
      @children = []
      @text = false

      # Treat NetSuite type file as a string
      @type = "string" if @type == "file"
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants