integration_point 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 895f1dc68a61e642f0d0e226621635b2652a1961f2d95a3589e736a627c8bc23
4
+ data.tar.gz: 52e18d90045545733eb592951e4462a0d957e687f3669303fa960f4667a13e2a
5
+ SHA512:
6
+ metadata.gz: ba9363350e1c93e9389cc2eb8b486e51b838fc7137232b4ee6b9133ce79338c70497401c02794427ca9e840491a9196987318ccebe775b713cdc1f012e4cb69e
7
+ data.tar.gz: 93e73b9ad30eb650389e923347a0d375b50f983de76c9b50fcbfe165c5ea5c8f4b4c4c04fb818028de19543b239e3ff4744096ba5437505bc96ae57170b4dacc
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Scott Hagan
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,3 @@
1
+ = IntegrationPoint
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'IntegrationPoint'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'savon'
4
+ require 'countries'
5
+
6
+ module IntegrationPoint
7
+ class Client
8
+
9
+ attr_reader :xml_client, :xml_response
10
+
11
+ def xml_client(wsdl_url)
12
+ return nil if wsdl_url.nil?
13
+
14
+ @xml_client ||= ::Savon.client(wsdl: wsdl_url, namespace_identifier: 's', convert_request_keys_to: :none)
15
+ end
16
+
17
+ def dps_integrated_search(wsdl_url, xml_values)
18
+ client = xml_client(wsdl_url)
19
+
20
+ return nil if client.nil?
21
+
22
+ query = build_dps_integration_search_query(xml_values)
23
+ @xml_response = client.call(:dps_integrated_search, message: query)
24
+ self
25
+ end
26
+
27
+ private
28
+
29
+ def build_dps_integration_search_query(xml_values)
30
+ {
31
+ 'company': empty_string_if_nil(xml_values[:company]),
32
+ 'username': empty_string_if_nil(xml_values[:username]),
33
+ 'password': empty_string_if_nil(xml_values[:password]),
34
+ 'loggedInUser': empty_string_if_nil(xml_values[:logged_in_user]),
35
+ 'companyId': empty_string_if_nil(xml_values[:company_id]),
36
+ 'searchType': empty_string_if_nil(xml_values[:search_type]),
37
+ 'settingsDescription': empty_string_if_nil(xml_values[:settings_description]),
38
+ 'name': empty_string_if_nil(xml_values[:name]),
39
+ 'address': empty_string_if_nil(xml_values[:address]),
40
+ 'city': empty_string_if_nil(xml_values[:city]),
41
+ 'countryCode': determine_country_code(xml_values[:country]),
42
+ 'countryStateCode': determine_state_code(xml_values[:state]),
43
+ 'postalCode': empty_string_if_nil(xml_values[:postal_code]),
44
+ 'dtsSearchFlag': empty_string_if_nil(xml_values[:dts_search_flag]),
45
+ 'dtsLastValidatedDate': empty_string_if_nil(xml_values[:dts_last_validated_date]),
46
+ 'dtsOverride': empty_string_if_nil(xml_values[:dts_override]),
47
+ 'dtsOverrideDate': empty_string_if_nil(xml_values[:dts_override_date]),
48
+ 'SearchRefNum': empty_string_if_nil(xml_values[:search_ref_num]),
49
+ 'CompanySync': empty_string_if_nil(xml_values[:company_sync])
50
+ }
51
+ end
52
+
53
+ def determine_country_code(country)
54
+ return "" if country.nil?
55
+
56
+ @country = ISO3166::Country.find_country_by_name(country)
57
+ if @country.nil?
58
+ ""
59
+ else
60
+ @country.alpha2
61
+ end
62
+ end
63
+
64
+ def empty_string_if_nil(value)
65
+ return "" if value.nil?
66
+
67
+ value
68
+ end
69
+
70
+ def determine_state_code(state)
71
+ return "" if @country.nil?
72
+
73
+ states = @country.states
74
+ state_struct = states.detect { |s| s.last.name.downcase == "british columbia".downcase }
75
+ if state_struct.nil?
76
+ ""
77
+ else
78
+ state_struct.first
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,3 @@
1
+ module IntegrationPoint
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'integration_point/client'
2
+ require 'integration_point/version'
3
+
4
+ module IntegrationPoint
5
+ XYZ = 'XYZ'
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :integration_point do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: integration_point
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Scott Hagan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: countries
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.2.11.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.2.11.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: savon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.12.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.12.0
55
+ description: A ruby client to interact with Integration Point's XML API
56
+ email:
57
+ - shagan@tractionondemand.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.rdoc
64
+ - Rakefile
65
+ - lib/integration_point.rb
66
+ - lib/integration_point/client.rb
67
+ - lib/integration_point/version.rb
68
+ - lib/tasks/integration_point_tasks.rake
69
+ homepage: https://github.com/tractionguest/integration-point
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.0.3
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Integration Point Ruby Client
92
+ test_files: []