intacct_ruby_team 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +179 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/intacct_ruby.gemspec +36 -0
  14. data/lib/intacct_ruby.rb +27 -0
  15. data/lib/intacct_ruby/api.rb +31 -0
  16. data/lib/intacct_ruby/exceptions/empty_request_exception.rb +5 -0
  17. data/lib/intacct_ruby/exceptions/function_failure_exception.rb +5 -0
  18. data/lib/intacct_ruby/exceptions/insufficient_credentials_exception.rb +5 -0
  19. data/lib/intacct_ruby/exceptions/unknown_function_type.rb +5 -0
  20. data/lib/intacct_ruby/function.rb +92 -0
  21. data/lib/intacct_ruby/functions/base_function.rb +48 -0
  22. data/lib/intacct_ruby/functions/create_aradjustment.rb +48 -0
  23. data/lib/intacct_ruby/functions/create_customer.rb +23 -0
  24. data/lib/intacct_ruby/functions/create_employee.rb +21 -0
  25. data/lib/intacct_ruby/functions/create_gltransaction.rb +28 -0
  26. data/lib/intacct_ruby/functions/create_item.rb +21 -0
  27. data/lib/intacct_ruby/functions/create_location.rb +21 -0
  28. data/lib/intacct_ruby/functions/create_project.rb +20 -0
  29. data/lib/intacct_ruby/functions/create_statgltransaction.rb +28 -0
  30. data/lib/intacct_ruby/functions/customer_base_function.rb +27 -0
  31. data/lib/intacct_ruby/functions/employee_base_function.rb +36 -0
  32. data/lib/intacct_ruby/functions/gltransaction_base_function.rb +64 -0
  33. data/lib/intacct_ruby/functions/item_base_function.rb +29 -0
  34. data/lib/intacct_ruby/functions/location_base_function.rb +24 -0
  35. data/lib/intacct_ruby/functions/project_base_function.rb +22 -0
  36. data/lib/intacct_ruby/functions/update_customer.rb +22 -0
  37. data/lib/intacct_ruby/functions/update_employee.rb +20 -0
  38. data/lib/intacct_ruby/functions/update_item.rb +20 -0
  39. data/lib/intacct_ruby/functions/update_location.rb +20 -0
  40. data/lib/intacct_ruby/functions/update_project.rb +20 -0
  41. data/lib/intacct_ruby/helpers/contacts_helper.rb +32 -0
  42. data/lib/intacct_ruby/helpers/date_helper.rb +22 -0
  43. data/lib/intacct_ruby/request.rb +138 -0
  44. data/lib/intacct_ruby/response.rb +43 -0
  45. data/lib/intacct_ruby/version.rb +3 -0
  46. metadata +205 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2f439a06093566700c49ccc10d3b0e7fbb9d6d1
4
+ data.tar.gz: cd01d623ab1645d636dd9f62434a220a9502a061
5
+ SHA512:
6
+ metadata.gz: cf2abf8eb4f24d954a6b0ddafdc3961546cf0db6da716a1ac8f55217cb8f048363d820ebb0a22ddadf652cf97e694bf5537391fea4eab0d6fdbea7c5012b542d
7
+ data.tar.gz: 41a926f410ce3bbb6347c48283b0d699cbceaf260e66afced619719be827f08da4a1aafd37487a020f8516e3694440f7d0a4c3a68161965428878bec15db9704
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ intacct-ruby
@@ -0,0 +1 @@
1
+ 2.3.5
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jeremy@zornow.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in intacct_ruby.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jeremy Zornow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,179 @@
1
+ [ ![Codeship Status for jzornow/intacct-ruby](https://app.codeship.com/projects/161bbcb0-037f-0135-febb-660dbc75d940/status?branch=master)](https://app.codeship.com/projects/213338)
2
+
3
+ # IntacctRuby
4
+
5
+ A wrapper for [Intacct's API](https://developer.intacct.com/wiki/functions-object), which tries to stay as close as it can to the syntax and philosophy of the API itself.
6
+
7
+ ## The Power of Multi-Function Api Calls
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
+
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` translates that philosophy into Ruby.
12
+
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!
15
+
16
+ ```ruby
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, {
22
+ customerid: '1',
23
+ first_name: 'Han',
24
+ last_name: 'Solo',
25
+ type: 'Person',
26
+ email1: 'han@solo.com',
27
+ status: 'active'
28
+ }
29
+
30
+ request.create :project, {
31
+ projectid: '1',
32
+ name: 'Get Chewie a Haircut',
33
+ projectcategory: 'Improve Wookie Hygene',
34
+ customerid: '1',
35
+ shampoo: 'true', # a custom field
36
+ blowdry: 'false' # a custom field
37
+ }
38
+
39
+ request.send
40
+ ```
41
+
42
+ This will fire off a request that looks something like this:
43
+
44
+ ```xml
45
+ <?xml version="1.0" encoding="UTF-8"?>
46
+ <request>
47
+ <control><!-- Authentication Params --></control>
48
+ <operation transaction="true">
49
+ <authentication><!-- Authentication Params --></authentication>
50
+ <content>
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>
62
+ </function>
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>
74
+ </function>
75
+ </content>
76
+ </operation>
77
+ </request>
78
+ ```
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.
80
+
81
+ ## Authentication
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/)
83
+
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:
85
+
86
+ - `senderid`
87
+ - `sender_password`\*
88
+ - `userid`
89
+ - `companyid`
90
+ - `user_password`\*
91
+
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._
93
+
94
+ ### Authentication Example:
95
+
96
+ ```ruby
97
+ IntacctRuby::Request.new(
98
+ some_function,
99
+ another_function,
100
+ senderid: 'some_senderid_value',
101
+ sender_password: 'some_sender_password_value',
102
+ userid: 'some_userid_value',
103
+ companyid: 'some_companyid_value',
104
+ user_password: 'some_user_password_value'
105
+ )
106
+ ```
107
+ Though, it probably makes more sense to keep all of these in some handy constant for easy reuse:
108
+ ```ruby
109
+ REQUEST_OPTS = {
110
+ senderid: 'some_senderid_value',
111
+ sender_password: 'some_sender_password_value',
112
+ userid: 'some_userid_value',
113
+ companyid: 'some_companyid_value',
114
+ user_password: 'some_user_password_value'
115
+ }.freeze
116
+
117
+ IntacctRuby::Request.new(REQUEST_OPTS)
118
+ ```
119
+
120
+ ### Important Notes on Authentication
121
+ #### These Are Required!
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.**
123
+
124
+ #### BE SAFE!
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.
126
+
127
+ ## Customizing Calls
128
+
129
+ This gem creates calls using the following defaults:
130
+ - **uniqueid:** false,
131
+ - **dtdversion:** 3.0,
132
+ - **includewhitespace:** false,
133
+ - **transaction:** true
134
+
135
+ If you'd like to override any of these, you can do so when you create a new request by adding additional fields to the options hash passed into `Request#new`:
136
+
137
+ ```ruby
138
+ REQUEST_OPTS = {
139
+ senderid: 'some_senderid_value',
140
+ sender_password: 'some_sender_password_value',
141
+ userid: 'some_userid_value',
142
+ companyid: 'some_companyid_value',
143
+ user_password: 'some_user_password_value'
144
+ }
145
+
146
+ REQUEST_OPTS.merge!(
147
+ uniqueid: 'some_uniqueid_override',
148
+ dtdversion: 'some_dtd_override'
149
+ )
150
+
151
+ IntacctRuby::Request.new(REQUEST_OPTS)
152
+ ```
153
+ ## Installation
154
+
155
+ ### The Gem Itself
156
+ Add this line to your application's Gemfile:
157
+
158
+ ```ruby
159
+ gem 'intacct_ruby'
160
+ ```
161
+
162
+ And then execute:
163
+
164
+ $ bundle
165
+
166
+ Or install it yourself as:
167
+
168
+ $ gem install intacct_ruby
169
+
170
+ ## Contributing
171
+
172
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jzornow/intacct-ruby/.
173
+
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.
175
+
176
+ ## License
177
+
178
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
179
+
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'intacct_ruby'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'intacct_ruby/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'intacct_ruby_team'
9
+ spec.version = IntacctRuby::VERSION
10
+ spec.authors = ['Erich L Timkar']
11
+ spec.email = ['erich@teamdriveaway.com']
12
+ spec.required_ruby_version = '>= 2.3.0'
13
+ spec.summary = 'A Ruby wrapper for the Intacct API'
14
+ spec.description = 'Allows for multi-function API calls, the ' \
15
+ 'addition of custom fields, and more. All in ' \
16
+ 'an easy-to-use package!'
17
+ spec.homepage = 'https://github.com/TeamDriveAway/intacct-ruby'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.13'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
32
+ spec.add_development_dependency 'mocha', '~> 0.13.3'
33
+ spec.add_development_dependency 'pry-byebug', '~> 3.4', '>= 3.4.2'
34
+
35
+ spec.add_runtime_dependency 'builder', '~> 3.0', '>= 3.0.4'
36
+ end
@@ -0,0 +1,27 @@
1
+ require 'intacct_ruby/api'
2
+ require 'intacct_ruby/version'
3
+
4
+ require 'intacct_ruby/request'
5
+ require 'intacct_ruby/response'
6
+
7
+ require 'intacct_ruby/functions/base_function'
8
+
9
+ require 'intacct_ruby/functions/create_customer'
10
+ require 'intacct_ruby/functions/update_customer'
11
+
12
+ require 'intacct_ruby/functions/create_project'
13
+ require 'intacct_ruby/functions/update_project'
14
+
15
+ require 'intacct_ruby/functions/create_employee'
16
+ require 'intacct_ruby/functions/update_employee'
17
+
18
+ require 'intacct_ruby/functions/create_location'
19
+ require 'intacct_ruby/functions/update_location'
20
+
21
+ require 'intacct_ruby/functions/create_item'
22
+ require 'intacct_ruby/functions/update_item'
23
+
24
+ require 'intacct_ruby/functions/create_aradjustment'
25
+
26
+ require 'intacct_ruby/functions/create_gltransaction'
27
+ require 'intacct_ruby/functions/create_statgltransaction'
@@ -0,0 +1,31 @@
1
+ module IntacctRuby
2
+ # the gateway by which IntacctRuby::Request instances are sent off to Intacct
3
+ class Api
4
+ def initialize(http_gateway = nil)
5
+ @http_gateway = http_gateway
6
+ end
7
+
8
+ def send_request(request_object, post_request = nil)
9
+ post_request ||= Net::HTTP::Post.new(uri.request_uri)
10
+
11
+ post_request['Content-Type'] = 'x-intacct-xml-request'
12
+ post_request.body = request_object.to_xml
13
+
14
+ https_request(post_request, uri)
15
+ end
16
+
17
+ private
18
+
19
+ URI_STRING = 'https://api.intacct.com/ia/xml/xmlgw.phtml'.freeze
20
+
21
+ def uri
22
+ @uri ||= URI.parse URI_STRING
23
+ end
24
+
25
+ def https_request(request, uri)
26
+ @http_gateway ||= Net::HTTP.new uri.host, uri.port
27
+ @http_gateway.use_ssl = true
28
+ @http_gateway.request request
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module IntacctRuby
2
+ module Exceptions
3
+ class EmptyRequestException < StandardError; end
4
+ end
5
+ end