forked from NetSweet/netsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for NullFieldList (starting with invoices)
NullFieldList is used to either clear an existing value on update, or avoid a default being applied on adding a record. My use case only required support for invoices, so I started there, but this could likely be added to most records. This was heavily inspired by @gmike11's work in NetSweet#481, but that seems to lump a bunch of changes together. This also solves NetSweet#398. Where NetSweet#481 manipulated the XML request body to address that the `<platformCore:nullFieldList>` needs to always use the `platformCore` namespace, as opposed to the records normal namespace (ie `transSale` for invoice) as happens for any other field, I tried to address that on the `#to_record` side.
- Loading branch information
Showing
8 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module NetSuite | ||
module Records | ||
class NullFieldList | ||
include Support::Fields | ||
include Support::Records | ||
include Namespaces::PlatformCore | ||
|
||
fields :name | ||
|
||
def initialize(attributes = {}) | ||
initialize_from_attributes_hash(attributes) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'spec_helper' | ||
|
||
describe NetSuite::Records::RecordRef do | ||
let(:null_field_list) { NetSuite::Records::NullFieldList.new } | ||
|
||
describe '#to_record' do | ||
it 'can represent itself as a SOAP record for single value' do | ||
null_field_list.name = 'blah' | ||
record = { | ||
'platformCore:name' => 'blah' | ||
} | ||
expect(null_field_list.to_record).to eql(record) | ||
end | ||
|
||
it 'can represent itself as a SOAP record for multiple values' do | ||
null_field_list.name = ['blah', 'foo'] | ||
record = { | ||
'platformCore:name' => ['blah', 'foo'] | ||
} | ||
expect(null_field_list.to_record).to eql(record) | ||
end | ||
end | ||
|
||
describe '#record_type' do | ||
it 'returns a string of the SOAP type' do | ||
expect(null_field_list.record_type).to eql('platformCore:NullFieldList') | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters