Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 51de868

Browse files
bezoar17danielpowell4
authored andcommitted
Update README with read function examples
1 parent 400d6f0 commit 51de868

File tree

1 file changed

+91
-15
lines changed

1 file changed

+91
-15
lines changed

README.md

Lines changed: 91 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Unlike the other Gems out in the Rubyverse, this library supports one of the Int
1212

1313
In an ERP system like Intacct, you'll probably want to perform multiple actions at once, like debiting one account and crediting another, or creating several associated records simulatenously. The more calls you make, the longer it will take to see a response. That's just a fact. But if you can bundle all of those actions together into a single call, you lower the load on both your system and Intacct's servers and guarantee yourself a quicker response. Intacct's entire API is built around this idea, and `IntacctRuby` translates that philosophy into Ruby.
1414

15-
### How Do It Do?
15+
### Putting Gem to Use
1616

1717
Let's say you want to create a project and a customer associated with that project simultaneously. The Intacct API would tell you to create a call with a `<create><CUSTOMER>` function followed by a `<create><PROJECT>` function. So let's do it!
1818

@@ -21,27 +21,29 @@ Let's say you want to create a project and a customer associated with that proje
2121
# for more information.
2222
request = IntacctRuby::Request.new(REQUEST_OPTS)
2323

24-
request.create :customer, {
25-
customerid: '1',
26-
first_name: 'Han',
27-
last_name: 'Solo',
28-
type: 'Person',
29-
email1: 'han@solo.com',
30-
status: 'active'
24+
request.create :CUSTOMER, {
25+
CUSTOMERID: '1',
26+
FIRST_NAME: 'Han',
27+
LAST_NAME: 'Solo',
28+
TYPE: 'Person',
29+
EMAIL1: 'han@solo.com',
30+
STATUS: 'active'
3131
}
3232

33-
request.create :project, {
34-
projectid: '1',
35-
name: 'Get Chewie a Haircut',
36-
projectcategory: 'Improve Wookie Hygene',
37-
customerid: '1',
38-
shampoo: 'true', # a custom field
39-
blowdry: 'false' # a custom field
33+
request.create :PROJECT, {
34+
PROJECTID: '1',
35+
NAME: 'Get Chewie a Haircut',
36+
PROJECTCATEGORY: 'Improve Wookie Hygene',
37+
CUSTOMERID: '1',
38+
SHAMPOO: 'true', # a custom field
39+
BLOWDRY: 'false' # a custom field
4040
}
4141

4242
request.send
4343
```
4444

45+
**Note:** Here `:CUSTOMER` and `:PROJECT` are object-types which are tagged just after the function tag `create` and are case-sensitive along with the extra-parameters(CUSTOMERID, FIRST_NAME ..)
46+
4547
This will fire off a request that looks something like this:
4648

4749
```xml
@@ -80,6 +82,80 @@ This will fire off a request that looks something like this:
8082
</request>
8183
```
8284

85+
### Read Requests
86+
87+
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.
88+
89+
```ruby
90+
request = IntacctRuby::Request.new(REQUEST_OPTS)
91+
92+
# Object-Type VENDOR is sent through extra-parameters and not as the first argument.
93+
request.readByQuery nil, {
94+
object: 'VENDOR',
95+
query: '',
96+
fields: '*',
97+
pagesize: 100
98+
}
99+
100+
request.send
101+
```
102+
103+
**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).
104+
So, something like `query: "BATCH_DATE > '02/14/2018'"` should be `query: "BATCH_DATE &gt; '02/14/2018'"`
105+
106+
This will fire off a request that looks something like this:
107+
108+
```xml
109+
<?xml version="1.0" encoding="UTF-8"?>
110+
<request>
111+
<control><!-- Authentication Params --></control>
112+
<operation transaction="true">
113+
<authentication><!-- Authentication Params --></authentication>
114+
<content>
115+
<function controlid="readByQuery-2017-08-03 17:02:40 UTC">
116+
<readByQuery>
117+
<object>VENDOR</object>
118+
<fields>*</fields>
119+
<query></query>
120+
<pagesize>100</pagesize>
121+
</readByQuery>
122+
</function>
123+
</content>
124+
</operation>
125+
</request>
126+
```
127+
128+
Similarly, for pagination use the `readMore` function as mentioned here [Intacct Paginate Results](https://developer.intacct.com/web-services/queries/#paginate-results)
129+
130+
```ruby
131+
request = IntacctRuby::Request.new(REQUEST_OPTS)
132+
133+
request.readMore nil, {
134+
resultId: '7765623332WU1hh8CoA4QAAHxI9i8AAAAA5'
135+
}
136+
137+
request.send
138+
```
139+
140+
This will fire off a request that looks something like this:
141+
142+
```xml
143+
<?xml version="1.0" encoding="UTF-8"?>
144+
<request>
145+
<control><!-- Authentication Params --></control>
146+
<operation transaction="true">
147+
<authentication><!-- Authentication Params --></authentication>
148+
<content>
149+
<function controlid="readMore-2017-08-03 17:02:40 UTC">
150+
<readMore>
151+
<resultId>7765623332WU1hh8CoA4QAAHxI9i8AAAAA5</resultId>
152+
</readMore>
153+
</function>
154+
</content>
155+
</operation>
156+
</request>
157+
```
158+
83159
If there are function errors (e.g. you omitted a required field) you'll see an error on response. Same if you see an internal server error, or any error outside of the 2xx range.
84160

85161
## Authentication

0 commit comments

Comments
 (0)