acts-as-atdw 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Yuri Tomanek
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,19 @@
1
+ = acts-as-atdw
2
+
3
+ A simple wrapper for the ATDW SOAP API
4
+
5
+ == Contributing to acts-as-atdw
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Yuri Tomanek. See LICENSE.txt for
18
+ further details.
19
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "acts-as-atdw"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Yuri Tomanek"]
12
+ s.date = "2011-11-29"
13
+ s.description = "A simple wrapper for the ATDW SOAP API"
14
+ s.email = "yuri@tomanek.com.au"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "VERSION",
21
+ "acts-as-atdw.gemspec",
22
+ "lib/acts_as_atdw.rb",
23
+ "lib/client.rb"
24
+ ]
25
+ s.homepage = "http://github.com/yuritomanek/acts-as-atdw"
26
+ s.licenses = ["MIT"]
27
+ s.require_paths = ["lib"]
28
+ s.rubygems_version = "1.8.11"
29
+ s.summary = "A simple wrapper for the ATDW SOAP API"
30
+
31
+ if s.respond_to? :specification_version then
32
+ s.specification_version = 3
33
+
34
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
35
+ s.add_runtime_dependency(%q<savon>, ["= 0.9.7"])
36
+ s.add_runtime_dependency(%q<xml-simple>, ["= 1.1.1"])
37
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
38
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.rc"])
39
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
40
+ s.add_development_dependency(%q<rcov>, [">= 0"])
41
+ else
42
+ s.add_dependency(%q<savon>, ["= 0.9.7"])
43
+ s.add_dependency(%q<xml-simple>, ["= 1.1.1"])
44
+ s.add_dependency(%q<shoulda>, [">= 0"])
45
+ s.add_dependency(%q<bundler>, ["~> 1.1.rc"])
46
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
47
+ s.add_dependency(%q<rcov>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<savon>, ["= 0.9.7"])
51
+ s.add_dependency(%q<xml-simple>, ["= 1.1.1"])
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.1.rc"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ end
57
+ end
58
+
@@ -0,0 +1,6 @@
1
+ require 'client'
2
+ require 'savon'
3
+
4
+ module ActsAsAtdw
5
+ VERSION = '0.0.1'
6
+ end
data/lib/client.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'xmlsimple'
2
+
3
+ module ActsAsAtdw
4
+ class Client
5
+
6
+ def initialize(options = {})
7
+ @api_key = options[:api_key]
8
+ Savon.configure do |config|
9
+ config.log = false
10
+ end
11
+ @client = Savon::Client.new do
12
+ wsdl.document = "http://national.atdw.com.au/soap/AustralianTourismWebService.asmx?WSDL"
13
+ end
14
+ end
15
+
16
+ def query_product_records(options = {})
17
+
18
+ api_key = @api_key
19
+
20
+ response = @client.request "query_product_records" do
21
+ soap.namespaces["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
22
+ soap.namespaces["xmlns:xsd"] = "http://www.w3.org/2001/XMLSchema"
23
+ soap.namespaces["xmlns:soap"] = "http://schemas.xmlsoap.org/soap/envelope/"
24
+ soap.body = {"DistributorKey" => "#{api_key}"}
25
+ options.each do |key, value|
26
+ soap.body[key] = value
27
+ end
28
+ end
29
+
30
+ result = XmlSimple.xml_in(response.body[:query_product_records_response][:query_product_records_result].gsub("<?xml version=\"1.0\" encoding=\"utf-16\" ?>", ""))
31
+
32
+ if result["error"] && result["error"] == ["No rows returned"]
33
+ return []
34
+ elsif result["product_distribution"]
35
+ return result["product_distribution"]
36
+ else
37
+ return []
38
+ end
39
+
40
+ end
41
+
42
+ def get_specific_product_record(options = {})
43
+ api_key = @api_key
44
+
45
+ response = @client.request "get_specific_product_record" do
46
+ soap.namespaces["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
47
+ soap.namespaces["xmlns:xsd"] = "http://www.w3.org/2001/XMLSchema"
48
+ soap.namespaces["xmlns:soap"] = "http://schemas.xmlsoap.org/soap/envelope/"
49
+ soap.body = {"DistributorKey" => "#{api_key}"}
50
+ options.each do |key, value|
51
+ soap.body[key] = value
52
+ end
53
+ end
54
+
55
+ result = XmlSimple.xml_in(response.body[:get_specific_product_record_response][:get_specific_product_record_result].gsub("<?xml version=\"1.0\" encoding=\"utf-16\" ?>", ""))
56
+
57
+ end
58
+
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts-as-atdw
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Yuri Tomanek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-11-29 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: savon
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - "="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: xml-simple
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: shoulda
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.1.rc
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: jeweler
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.6.4
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: rcov
72
+ requirement: &id006 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *id006
81
+ description: A simple wrapper for the ATDW SOAP API
82
+ email: yuri@tomanek.com.au
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - VERSION
92
+ - acts-as-atdw.gemspec
93
+ - lib/acts_as_atdw.rb
94
+ - lib/client.rb
95
+ - LICENSE.txt
96
+ - README.rdoc
97
+ homepage: http://github.com/yuritomanek/acts-as-atdw
98
+ licenses:
99
+ - MIT
100
+ post_install_message:
101
+ rdoc_options: []
102
+
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: -4409220899947231518
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.11
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: A simple wrapper for the ATDW SOAP API
127
+ test_files: []
128
+