boomi-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "rest-client", "~> 1.6.0"
5
+ gem "xml-simple", "~> 1.0.0", :require => 'xmlsimple'
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "shoulda", ">= 0"
11
+ gem "rdoc", "~> 3.12"
12
+ gem "bundler"
13
+ gem "jeweler", "~> 1.8.4"
14
+ gem "rcov", "0.9.11"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.0.0)
5
+ i18n (~> 0.6, >= 0.6.4)
6
+ minitest (~> 4.2)
7
+ multi_json (~> 1.3)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 0.3.37)
10
+ atomic (1.1.9)
11
+ git (1.2.5)
12
+ i18n (0.6.4)
13
+ jeweler (1.8.4)
14
+ bundler (~> 1.0)
15
+ git (>= 1.2.5)
16
+ rake
17
+ rdoc
18
+ json (1.8.0)
19
+ mime-types (1.23)
20
+ minitest (4.7.5)
21
+ multi_json (1.7.7)
22
+ rake (10.1.0)
23
+ rcov (0.9.11)
24
+ rdoc (3.12.2)
25
+ json (~> 1.4)
26
+ rest-client (1.6.7)
27
+ mime-types (>= 1.16)
28
+ shoulda (3.5.0)
29
+ shoulda-context (~> 1.0, >= 1.0.1)
30
+ shoulda-matchers (>= 1.4.1, < 3.0)
31
+ shoulda-context (1.1.3)
32
+ shoulda-matchers (2.2.0)
33
+ activesupport (>= 3.0.0)
34
+ thread_safe (0.1.0)
35
+ atomic
36
+ tzinfo (0.3.37)
37
+ xml-simple (1.0.12)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ bundler
44
+ jeweler (~> 1.8.4)
45
+ rcov (= 0.9.11)
46
+ rdoc (~> 3.12)
47
+ rest-client (~> 1.6.0)
48
+ shoulda
49
+ xml-simple (~> 1.0.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Charles Cooke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = boomi-ruby
2
+
3
+ Boomi gem for Ruby
4
+
5
+ == Usage
6
+
7
+ Providing the optional override_account will use the Boomi Partner API
8
+
9
+ @boomi = Boomi.new(:account => 'boomi-account123', :user => 'boomiuser', :pass => 'boomipass', :override_account => 'mychildaccount')
10
+ @boomi.get_execution_records("executionTime[GREATER_THAN_OR_EQUAL]" => 15.minutes.ago)
11
+
12
+ == Copyright
13
+
14
+ Copyright (c) 2013 Coupa Software. See LICENSE.txt for
15
+ further details.
16
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "boomi-ruby"
18
+ gem.homepage = "http://github.com/coupacooke/boomi-ruby"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby gem for Boomi webservices}
21
+ gem.description = %Q{Supports the Boomi REST Webservice}
22
+ gem.email = "charles@coupa.com"
23
+ gem.authors = ["Charles Cooke"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "boomi-ruby #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,122 @@
1
+ class Boomi
2
+ BASE_URI = "https://platform.boomi.com/api/rest/v1"
3
+ BASE_PARTNER_URI = "https://platform.boomi.com/partner/api/rest/v1"
4
+
5
+ def initialize(opts)
6
+ @resource = RestClient::Resource.new(opts[:override_account] ? BASE_PARTNER_URI : BASE_URI, :user => opts[:user], :password => opts[:pass])
7
+ @override_account = opts[:override_account]
8
+ @account = opts[:account]
9
+ end
10
+
11
+ def get_widget_list(widget_manager_id,partner_user_id)
12
+ response(@resource["getWidgetList/#{widget_manager_id}/#{partner_user_id}?overrideAccountId=#{@override_account}"])
13
+ end
14
+
15
+ def get_account
16
+ get(@resource["#{@account}/Account/query"])
17
+ end
18
+
19
+ def query_account
20
+ query = <<-EOS
21
+ <QueryConfig xmlns="http://api.platform.boomi.com/">
22
+ <QueryMore>
23
+ <QueryToken>%s</QueryToken>
24
+ </QueryMore>
25
+ <QueryFilter>
26
+ <expression operator="and" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
27
+ xsi:type="GroupingExpression">
28
+ <nestedExpression operator="GREATER_THAN_OR_EQUAL" property="dateCreated"
29
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SimpleExpression">
30
+ <argument>1980-01-01T00:00:00Z</argument>
31
+ </nestedExpression>
32
+ </expression>
33
+ </QueryFilter>
34
+ </QueryConfig>
35
+ EOS
36
+ post("#{@account}/Account/query",query)
37
+ end
38
+
39
+ def get_events(opts)
40
+ post("#{@account}/Event/query?overrideAccount=#{@override_account}", make_query(opts))
41
+ end
42
+
43
+
44
+ def get_execution_records(opts)
45
+ post("#{@account}/ExecutionRecord/query?overrideAccount=#{@override_account}", make_query(opts))
46
+ end
47
+
48
+ def execute_process(atom_id,process_id)
49
+ query = <<-EOS
50
+ <ProcessExecutionRequest processId="#{process_id}" atomId="#{atom_id}" xmlns="http://api.platform.boomi.com/">
51
+ <ProcessProperties>
52
+ <!-- Zero or more repetitions: -->
53
+ <!-- TODO: parameterize this -->
54
+ <!-- <ProcessProperty>
55
+ <Name>?</Name>
56
+ <Value>?</Value>
57
+ </ProcessProperty> -->
58
+ </ProcessProperties>
59
+ </ProcessExecutionRequest>
60
+ EOS
61
+ post("#{@account}/executeProcess",query)
62
+ end
63
+
64
+ private
65
+ def make_query(opts)
66
+ query = <<-EXPR
67
+ <QueryConfig xmlns="http://api.platform.boomi.com/">
68
+ <QueryFilter>
69
+ <expression operator="and" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="GroupingExpression">
70
+ #{opts.collect do |key,value|
71
+ field, operator = key.gsub(/\]/,'').split('[').collect(&:to_s)
72
+ operator ||= 'EQUALS'
73
+
74
+ "<nestedExpression operator='#{operator}' property='#{field}' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='SimpleExpression'>
75
+ <argument>#{value.is_a?(Time) ? value.iso8601 : value}</argument>
76
+ </nestedExpression>"
77
+ end.join('\n')
78
+ }
79
+ </expression>
80
+ </QueryFilter>
81
+ </QueryConfig>
82
+ EXPR
83
+ end
84
+
85
+ def get(url)
86
+ contents = @resource[url].get
87
+ parsed = parse(contents)
88
+ parsed['queryToken']
89
+ end
90
+
91
+ def post(url,content)
92
+ results = []
93
+ response = ''
94
+ query_token = nil
95
+ error = false
96
+ attempts = 0
97
+ begin
98
+ attempts += 1
99
+ if query_token
100
+ response = @resource["#{url.gsub(/query/,'queryMore')}"].post(query_token)
101
+ else
102
+ response = @resource[url].post(content)
103
+ end
104
+ if xml_doc = parse(response)
105
+ results += xml_doc['result'] if xml_doc['result']
106
+ query_token = xml_doc['queryToken'] && xml_doc['queryToken'].first
107
+ end
108
+ rescue RestClient::BadRequest => e
109
+ puts e.http_body
110
+ error = true
111
+ rescue RestClient::InternalServerError => e
112
+ puts "Received error from server, stopped processing but dealing with any results that exist: #{e}"
113
+ error = true
114
+ end while query_token && !error && attempts < 50
115
+ results
116
+ end
117
+
118
+ def parse(content)
119
+ return if content.blank?
120
+ XmlSimple.xml_in(content)
121
+ end
122
+ end
data/lib/boomi-ruby.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'rest-client'
2
+ require 'xmlsimple'
3
+
4
+ require File.join(File.dirname(__FILE__), 'boomi', 'boomi')
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'boomi-ruby'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestBoomiRuby < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boomi-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Charles Cooke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: &74579280 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *74579280
25
+ - !ruby/object:Gem::Dependency
26
+ name: xml-simple
27
+ requirement: &74614500 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *74614500
36
+ - !ruby/object:Gem::Dependency
37
+ name: shoulda
38
+ requirement: &74612590 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *74612590
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdoc
49
+ requirement: &74611640 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *74611640
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &74609900 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *74609900
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &74607290 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.4
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *74607290
80
+ - !ruby/object:Gem::Dependency
81
+ name: rcov
82
+ requirement: &74622080 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - =
86
+ - !ruby/object:Gem::Version
87
+ version: 0.9.11
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *74622080
91
+ description: Supports the Boomi REST Webservice
92
+ email: charles@coupa.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files:
96
+ - LICENSE.txt
97
+ - README.rdoc
98
+ files:
99
+ - .document
100
+ - Gemfile
101
+ - Gemfile.lock
102
+ - LICENSE.txt
103
+ - README.rdoc
104
+ - Rakefile
105
+ - VERSION
106
+ - lib/boomi-ruby.rb
107
+ - lib/boomi/boomi.rb
108
+ - test/helper.rb
109
+ - test/test_boomi-ruby.rb
110
+ homepage: http://github.com/coupacooke/boomi-ruby
111
+ licenses:
112
+ - MIT
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ segments:
124
+ - 0
125
+ hash: 229927375
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 1.8.11
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Ruby gem for Boomi webservices
138
+ test_files: []