intacct_ruby 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d91a712067c46b1878f02cd252f0ebb2ebf576e
4
- data.tar.gz: 476d463ee509d8ff743e6ac1eea8ef409c77e68b
3
+ metadata.gz: 6fdeda969319113c490136cf46946c4249f63232
4
+ data.tar.gz: a6c3031723fcd6e7a9fdf61521e7255912ba8b6f
5
5
  SHA512:
6
- metadata.gz: 5c7e51583d104820ec989ee2899b98e9aba8302021055ac58ed9a64bac640fee97ea653e532d2367ac59582b67283bed0eabff223598eccac006344552af51ed
7
- data.tar.gz: 677b8a609811c4bb2b1a8ea722c6a8a3e1cb016a2f357394114b9910f8e3dc657d4e42368acaf4fbbad852c5198ff5ea88893bcd0a6620efd0f71f8406d7ac26
6
+ metadata.gz: 2b753266030c50e51e94b81a190b108222b0ae2d7d0a16f6bef8244a60f0316ea4c09d02efb165d03ff7762bbc26dfd6ef06a2afe84c5028389ec65db07a73e8
7
+ data.tar.gz: 10b084c606c9cb83505a5290443c3c328502585aaf912bcd6180350e4ffef13ec8b6d864d1f214d50349d42153c1009b3cab41e2d608cd2645e3e4a113fb3d51
data/README.md CHANGED
@@ -8,33 +8,34 @@ A wrapper for [Intacct's API](https://developer.intacct.com/wiki/functions-objec
8
8
  Unlike the other Gems out in the Rubyverse, this library supports one of the Intacct API's most powerful features: multi-function API calls.
9
9
 
10
10
  ### Why Does This Matter?
11
- 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` tries to translate that philosophy into Ruby code as best as it can.
11
+ 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.
12
12
 
13
13
  ### How Do It Do?
14
- 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!
14
+ 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!
15
15
 
16
16
  ```ruby
17
- create_customer = IntacctRuby::Functions::CreateCustomer.new(
17
+ # REQUEST_OPTS contains authentication information. See 'Authentication' section
18
+ # for more information.
19
+ request = IntacctRuby::Request.new(REQUEST_OPTS)
20
+
21
+ request.create :customer, {
18
22
  customerid: '1',
19
23
  first_name: 'Han',
20
24
  last_name: 'Solo',
21
25
  type: 'Person',
22
26
  email1: 'han@solo.com',
23
27
  status: 'active'
24
- )
28
+ }
25
29
 
26
- create_project = IntacctRuby::Functions::CreateProject.new(
30
+ request.create :project, {
27
31
  projectid: '1',
28
32
  name: 'Get Chewie a Haircut',
29
33
  projectcategory: 'Improve Wookie Hygene',
30
34
  customerid: '1',
31
- customfields: {
32
- shampoo: 'true',
33
- blowdry: 'false'
34
- }
35
- )
35
+ shampoo: 'true', # a custom field
36
+ blowdry: 'false' # a custom field
37
+ }
36
38
 
37
- request = IntacctRuby::Request.new(create_customer, create_project, authentication_params)
38
39
  request.send
39
40
  ```
40
41
 
@@ -43,47 +44,33 @@ This will fire off a request that looks something like this:
43
44
  ```xml
44
45
  <?xml version="1.0" encoding="UTF-8"?>
45
46
  <request>
46
- <control>
47
- ** omitted **
48
- </control>
47
+ <control><!-- Authentication Params --></control>
49
48
  <operation transaction="true">
50
- <authentication>
51
- ** omitted **
52
- </authentication>
49
+ <authentication><!-- Authentication Params --></authentication>
53
50
  <content>
54
- <function controlid="create_customer_1">
55
- <create_customer>
56
- <customerid>1</customerid>
57
- <name>Han Solo</name>
58
- <status>active</status>
59
- <contactinfo>
60
- <contact>
61
- <contactname>Han Solo (Customer #1)</contactname>
62
- <printas>Han Solo</printas>
63
- <firstname>Han</firstname>
64
- <lastname>Solo</lastname>
65
- <email1>han@solo.com</email1>
66
- </contact>
67
- </contactinfo>
68
- </create_customer>
51
+ <function controlid="create-customer-2017-08-03 17:02:40 UTC">
52
+ <create>
53
+ <CUSTOMER>
54
+ <CUSTOMERID>1</CUSTOMERID>
55
+ <FIRST_NAME>Han</FIRST_NAME>
56
+ <LAST_NAME>Solo</LAST_NAME>
57
+ <TYPE>Person</TYPE>
58
+ <EMAIL1>han@solo.com</EMAIL1>
59
+ <STATUS>active</STATUS>
60
+ </CUSTOMER>
61
+ </create>
69
62
  </function>
70
- <function controlid="create_project_1">
71
- <create_project>
72
- <projectid>1</projectid>
73
- <name>Get Chewie a Haircut</name>
74
- <projectcategory>Improve Wookie Hygene</projectcategory>
75
- <customerid>1</customerid>
76
- <customfields>
77
- <customfield>
78
- <customfieldname>shampoo</customfieldname>
79
- <customfieldvalue>true</customfieldvalue>
80
- </customfield>
81
- <customfield>
82
- <customfieldname>blowdry</customfieldname>
83
- <customfieldvalue>false</customfieldvalue>
84
- </customfield>
85
- </customfields>
86
- </create_project>
63
+ <function controlid="create-project-2017-08-03 17:02:40 UTC">
64
+ <create>
65
+ <PROJECT>
66
+ <PROJECTID>1</PROJECTID>
67
+ <NAME>Get Chewie a Haircut</NAME>
68
+ <PROJECTCATEGORY>Improve Wookie Hygene</PROJECTCATEGORY>
69
+ <CUSTOMERID>1</CUSTOMERID>
70
+ <SHAMPOO>true</SHAMPOO>
71
+ <BLOWDRY>false</BLOWDRY>
72
+ </PROJECT>
73
+ </create>
87
74
  </function>
88
75
  </content>
89
76
  </operation>
@@ -92,7 +79,7 @@ This will fire off a request that looks something like this:
92
79
  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.
93
80
 
94
81
  ## Authentication
95
- Before we go any further, make sure you've read the [Intacct API Quickstart Guide](https://developer.intacct.com/wiki/constructing-web-services-request#The%20Intacct%20DTDs).
82
+ Before we go any further, make sure you've read the [Intacct API Quickstart Guide](https://developer.intacct.com/web-services/) and [their article on constructing XML Requests](https://developer.intacct.com/web-services/requests/)
96
83
 
97
84
  In IntacctRuby - as with the Intacct API that the gem wraps - your system credentials are pass along with each separate `Request` instance. The functions that define a request are followed by a hash that spells out each piece of information required by Intacct for authentication. These fields are:
98
85
 
@@ -102,7 +89,7 @@ In IntacctRuby - as with the Intacct API that the gem wraps - your system creden
102
89
  - `companyid`
103
90
  - `user_password`\*
104
91
 
105
- \* _In [Intacct's documentation](https://developer.intacct.com/wiki/constructing-web-services-request), these are referred to only as `password`. This won't work in Rubyland, though, because we're unable to have multiple hash entries with the same key._
92
+ \* _In [Intacct's documentation](https://developer.intacct.com/wiki/constructing-web-services-request), these are referred to only as `password`. This won't work in Rubyland, though, because we can't have multiple hash entries with the same key._
106
93
 
107
94
  ### Authentication Example:
108
95
 
@@ -117,7 +104,6 @@ IntacctRuby::Request.new(
117
104
  user_password: 'some_user_password_value'
118
105
  )
119
106
  ```
120
-
121
107
  Though, it probably makes more sense to keep all of these in some handy constant for easy reuse:
122
108
  ```ruby
123
109
  REQUEST_OPTS = {
@@ -126,14 +112,14 @@ REQUEST_OPTS = {
126
112
  userid: 'some_userid_value',
127
113
  companyid: 'some_companyid_value',
128
114
  user_password: 'some_user_password_value'
129
- }
115
+ }.freeze
130
116
 
131
- IntacctRuby::Request.new(some_function, another_function, REQUEST_OPTS)
117
+ IntacctRuby::Request.new(REQUEST_OPTS)
132
118
  ```
133
119
 
134
120
  ### Important Notes on Authentication
135
121
  #### These Are Required!
136
- Obviously, Intacct won't do anything if you don't tell it who you are. To save you the bandwidth, this gem will throw errors if any of these auth params are not provided.
122
+ Obviously, Intacct won't do anything if you don't tell it who you are. To save you the bandwidth, **this gem will throw errors if any of these auth params are not provided.**
137
123
 
138
124
  #### BE SAFE!
139
125
  Though the examples above show hard-coded username/password pairs, this is a really bad idea to do in production code. Instead, we recommend storing these variables in ENVs, using a tool like [Figaro](https://github.com/laserlemon/figaro) to bring it all together.
@@ -162,7 +148,7 @@ REQUEST_OPTS.merge!(
162
148
  dtdversion: 'some_dtd_override'
163
149
  )
164
150
 
165
- IntacctRuby::Request.new(some_function, another_function, REQUEST_OPTS)
151
+ IntacctRuby::Request.new(REQUEST_OPTS)
166
152
  ```
167
153
  ## Installation
168
154
 
@@ -181,23 +167,12 @@ Or install it yourself as:
181
167
 
182
168
  $ gem install intacct_ruby
183
169
 
184
- ## Adding New Functions
185
- This gem was designed, as so many are, for a specific use case. The Intacct API has hundreds of API calls, though I only built out a dozen or so. Within that dozen, I only built out the fields that I needed in each call.
186
-
187
- I know what you're thinking:
188
- **You dweeb! Why didn't make the stuff that I need, too?**
189
-
190
- I didn't, because I have full confidence in your ability to do it yourself. These calls are easy to construct, and they almost perfectly mirror the structure of the XML shown in Intacct's API documentation. You can figure it out! You're a developer, for shirt's sake.
191
-
192
- If you're interested, feel free to reach out to me for information on how to build or improve the functions that are already present in this gem.
193
-
194
170
  ## Contributing
195
171
 
196
172
  Bug reports and pull requests are welcome on GitHub at https://github.com/jzornow/intacct-ruby/.
197
173
 
198
174
  This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
199
175
 
200
-
201
176
  ## License
202
177
 
203
178
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -5,7 +5,7 @@ module IntacctRuby
5
5
  @http_gateway = http_gateway
6
6
  end
7
7
 
8
- def send(request_object, post_request = nil)
8
+ def send_request(request_object, post_request = nil)
9
9
  post_request ||= Net::HTTP::Post.new(uri.request_uri)
10
10
 
11
11
  post_request['Content-Type'] = 'x-intacct-xml-request'
@@ -49,13 +49,18 @@ module IntacctRuby
49
49
  end
50
50
  end
51
51
 
52
- def send(api = nil)
53
- api ||= Api.new
52
+ def send(opts = {})
53
+ if opts.is_a? Hash
54
+ api = opts[:api] || Api.new
54
55
 
55
- validate_keys!
56
- validate_functions!
56
+ validate_keys!
57
+ validate_functions!
57
58
 
58
- Response.new api.send(self)
59
+ Response.new api.send_request(self)
60
+ else
61
+ # so that Request#send can play nice alongside Object#send
62
+ super
63
+ end
59
64
  end
60
65
 
61
66
  private
@@ -1,3 +1,3 @@
1
1
  module IntacctRuby
2
- VERSION = '1.6.2'.freeze
2
+ VERSION = '1.6.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intacct_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Zornow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler