Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,24 @@ This will fire off a request that looks something like this:

### Read Requests

The read requests follow a slightly different pattern. The object-type is mentioned inside the object tag as seen here [Intacct List Vendors](https://developer.intacct.com/api/accounts-payable/vendors/#list-vendors). The following code will read all vendor objects.
The read requests follow a slightly different pattern. The object-type is mentioned inside the object tag as seen here [Intacct List Journal Entries](https://developer.intacct.com/api/general-ledger/journal-entries/#list-journal-entry-lines). The following code will read all GLENTRY objects in a specific interval

**Note:** The gem encodes the queries to a valid XML so that you don't have to. You can query using the `&, >, <` operators as seen below.

```ruby
request = IntacctRuby::Request.new(REQUEST_OPTS)

# Object-Type VENDOR is sent through extra-parameters and not as the first argument.
# Object-Type GLENTRY is sent through extra-parameters and not as the first argument.
request.readByQuery nil, {
object: 'VENDOR',
query: '',
object: 'GLENTRY',
query: "BATCH_DATE >= '03-01-2018' AND BATCH_DATE <= '03-15-2018'",
fields: '*',
pagesize: 100
}

request.send
```

**Note:** Clean up the query argument before using it in readByQuery function as mentioned here [Intacct Illegal characters in XML](https://developer.intacct.com/web-services/queries/#illegal-characters-in-xml).
So, something like `query: "BATCH_DATE > '02/14/2018'"` should be `query: "BATCH_DATE &gt; '02/14/2018'"`

This will fire off a request that looks something like this:

```xml
Expand All @@ -114,9 +113,9 @@ This will fire off a request that looks something like this:
<content>
<function controlid="readByQuery-2017-08-03 17:02:40 UTC">
<readByQuery>
<object>VENDOR</object>
<object>GLENTRY</object>
<fields>*</fields>
<query></query>
<query>BATCH_DATE &gt;= '03-01-2018' AND BATCH_DATE &lt;= '03-15-2018'</query>
<pagesize>100</pagesize>
</readByQuery>
</function>
Expand Down
2 changes: 1 addition & 1 deletion lib/intacct_ruby/function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def argument_value_as_xml(value)
when Array
argument_value_list_xml(value) # recursive case
else
value.to_s # end case
value.to_s.encode(xml: :text) # end case
end
end

Expand Down
15 changes: 8 additions & 7 deletions spec/function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ def to_xml_key(symbol)
{
some: 'argument',
another: 'string',
nested_as_hash: { nested_key: 'nested value' },
another_nested_as_hash: { another_key: 'another value' },
risky: 'risky&><argument',
nested_as_hash: { nested_key: 'nested > value' },
another_nested_as_hash: { another_key: 'another < value' },
nested_as_array: [
{ first_key: 'first_value' },
{ second_key: 'second_value' }
{ first_key: 'first_value <' },
{ second_key: 'second_value >' }
]
}
end
Expand Down Expand Up @@ -78,7 +79,7 @@ def to_xml_key(symbol)
)

expect(xml_argument_value.first.children.to_s)
.to eq expected_value
.to eq expected_value.encode(xml: :text)
end
end
end
Expand All @@ -98,7 +99,7 @@ def to_xml_key(symbol)
)

expect(xml_inner_value.first.children.to_s)
.to eq inner_value
.to eq inner_value.encode(xml: :text)
end
end
end
Expand All @@ -118,7 +119,7 @@ def to_xml_key(symbol)
)

expect(xml_array_item_value.first.children.to_s)
.to eq array_item_value
.to eq array_item_value.encode(xml: :text)
end
end
end
Expand Down