Chrononaut-hostconnect 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/MIT-LICENSE +22 -0
- data/README.markdown +13 -0
- data/Rakefile +49 -0
- data/hostconnect.gemspec +202 -0
- data/lib/hostconnect/builder.rb +50 -0
- data/lib/hostconnect/builders/add_service_builder.rb +60 -0
- data/lib/hostconnect/builders/agent_info_builder.rb +19 -0
- data/lib/hostconnect/builders/get_booking_builder.rb +23 -0
- data/lib/hostconnect/builders/get_locations_builder.rb +18 -0
- data/lib/hostconnect/builders/get_services_builder.rb +18 -0
- data/lib/hostconnect/builders/get_system_settings_builder.rb +18 -0
- data/lib/hostconnect/builders/list_bookings_builder.rb +27 -0
- data/lib/hostconnect/builders/new_booking_info_builder.rb +23 -0
- data/lib/hostconnect/builders/option_info_builder.rb +49 -0
- data/lib/hostconnect/builders/pax_details_builder.rb +21 -0
- data/lib/hostconnect/builders/ping_builder.rb +11 -0
- data/lib/hostconnect/builders/room_config_builder.rb +25 -0
- data/lib/hostconnect/builders/service_line_note_builder.rb +17 -0
- data/lib/hostconnect/builders/suppler_info_builder.rb +27 -0
- data/lib/hostconnect/client.rb +32 -0
- data/lib/hostconnect/coercion.rb +57 -0
- data/lib/hostconnect/core_extensions/string.rb +18 -0
- data/lib/hostconnect/core_extensions/symbol.rb +9 -0
- data/lib/hostconnect/response.rb +119 -0
- data/lib/hostconnect/responses/add_service.rb +4 -0
- data/lib/hostconnect/responses/agent_info.rb +7 -0
- data/lib/hostconnect/responses/get_booking.rb +18 -0
- data/lib/hostconnect/responses/get_locations.rb +21 -0
- data/lib/hostconnect/responses/get_services.rb +21 -0
- data/lib/hostconnect/responses/get_system_settings.rb +24 -0
- data/lib/hostconnect/responses/list_bookings.rb +14 -0
- data/lib/hostconnect/responses/option_info.rb +60 -0
- data/lib/hostconnect/responses/ping.rb +7 -0
- data/lib/hostconnect/responses/supplier_info.rb +31 -0
- data/lib/hostconnect/rtf_document.rb +19 -0
- data/lib/hostconnect.rb +58 -0
- data/spec/builders/add_service_builder_spec.rb +36 -0
- data/spec/builders/agent_info_builder_spec.rb +13 -0
- data/spec/builders/get_locations_builder_spec.rb +13 -0
- data/spec/builders/new_booking_info_builder_spec.rb +34 -0
- data/spec/builders/option_info_builder_spec.rb +48 -0
- data/spec/builders/pax_details_builder_spec.rb +41 -0
- data/spec/builders/ping_builder_spec.rb +23 -0
- data/spec/builders/room_config_builder_spec.rb +60 -0
- data/spec/client_spec.rb +20 -0
- data/spec/coercion_spec.rb +94 -0
- data/spec/core_extensions_spec.rb +17 -0
- data/spec/fixtures/requests/add_service_request/hotel_booking.xml +42 -0
- data/spec/fixtures/requests/agent_info.xml +8 -0
- data/spec/fixtures/requests/get_locations.xml +8 -0
- data/spec/fixtures/requests/option_info/hotel_search.xml +11 -0
- data/spec/fixtures/requests/option_info/hotel_search_total_stay_price.xml +18 -0
- data/spec/fixtures/requests/option_info/option_number.xml +10 -0
- data/spec/fixtures/requests/ping.xml +5 -0
- data/spec/fixtures/responses/add_service.xml +11 -0
- data/spec/fixtures/responses/agent_info.xml +12 -0
- data/spec/fixtures/responses/agent_info_error.xml +7 -0
- data/spec/fixtures/responses/get_booking.xml +40 -0
- data/spec/fixtures/responses/get_locations.xml +48 -0
- data/spec/fixtures/responses/get_system_settings.xml +28 -0
- data/spec/fixtures/responses/option_info/hotel_price.xml +17 -0
- data/spec/fixtures/responses/option_info/hotel_search.xml +721 -0
- data/spec/fixtures/responses/option_info/hotel_search_with_stay_price.xml +470 -0
- data/spec/fixtures/responses/option_info/option_number.xml +14 -0
- data/spec/fixtures/responses/option_info/tours.xml +74 -0
- data/spec/fixtures/responses/ping.xml +8 -0
- data/spec/responses/add_service_spec.rb +13 -0
- data/spec/responses/agent_info_spec.rb +24 -0
- data/spec/responses/get_booking_spec.rb +33 -0
- data/spec/responses/get_locations_spec.rb +29 -0
- data/spec/responses/get_system_settings_spec.rb +21 -0
- data/spec/responses/option_info_spec.rb +48 -0
- data/spec/responses/ping_spec.rb +22 -0
- data/spec/spec_helper.rb +13 -0
- metadata +204 -0
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v0.1.0 Test release
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2007 Bjørn Arild Mæland
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Library for connecting to hostConnect
|
2
|
+
|
3
|
+
## Notes
|
4
|
+
* All variables passing in/out of hostConnect via XML are written in CapitalCamelCase.
|
5
|
+
We, however, use snake_case for all parameters/attributes.
|
6
|
+
* Variables that are to be defined zero or more times, should be passed in as an array.
|
7
|
+
For example ":opt => ['LONAC????????????', 'MAN??????????????']"
|
8
|
+
* For requests that return multiple results (i.e OptionInfo), we supply a size method to
|
9
|
+
display the number of results.
|
10
|
+
|
11
|
+
## Dev docs
|
12
|
+
* hostConnect API doc: http://www.tourplan.com/support/Connector/hostConnect_2_04_170.html
|
13
|
+
* Builder: http://builder.rubyforge.org/
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rake'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'echoe'
|
9
|
+
|
10
|
+
PROJECT = 'hostconnect'
|
11
|
+
|
12
|
+
Echoe.new(PROJECT) do |p|
|
13
|
+
p.author = "Bjørn Arild Mæland"
|
14
|
+
p.summary = "Library for interfacing with Tourplan's hostConnect software,
|
15
|
+
which is a web service interface for tour booking."
|
16
|
+
p.url = "http://www.github.com/Chrononaut/hostconnect/"
|
17
|
+
p.dependencies = ["activesupport", "hpricot", "builder"]
|
18
|
+
p.ignore_pattern = FileList[".gitignore"]
|
19
|
+
p.include_rakefile = true
|
20
|
+
p.rubygems_version >= "1.2.0"
|
21
|
+
end
|
22
|
+
|
23
|
+
task :default => 'spec'
|
24
|
+
|
25
|
+
desc "Run specifications"
|
26
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
27
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
28
|
+
t.spec_files = FileList[(ENV['FILES'] || 'spec/**/*_spec.rb')]
|
29
|
+
unless ENV["NO_RCOV"]
|
30
|
+
#t.rcov = true
|
31
|
+
t.rcov_opts = ['--exclude', 'spec']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Create spec docs"
|
36
|
+
Spec::Rake::SpecTask.new('spec_docs') do |t|
|
37
|
+
t.spec_opts = ["--format", "html:spec_docs.html"]
|
38
|
+
t.spec_files = FileList[(ENV['FILES'] || 'spec/**/*_spec.rb')]
|
39
|
+
end
|
40
|
+
|
41
|
+
DOCUMENTED_FILES = FileList['README.markdown', 'MIT-LICENSE', 'lib/**/*.rb']
|
42
|
+
|
43
|
+
desc "Generate Documentation"
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
rdoc.rdoc_dir = 'doc'
|
46
|
+
rdoc.title = "HostConnect"
|
47
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.markdown'
|
48
|
+
rdoc.rdoc_files.include(*DOCUMENTED_FILES)
|
49
|
+
end
|
data/hostconnect.gemspec
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hostconnect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Bj\xC3\xB8rn Arild M\xC3\xA6land"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
|
11
|
+
date: 2008-08-18 00:00:00 +02:00
|
12
|
+
default_executable:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
type: :runtime
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: hpricot
|
26
|
+
type: :runtime
|
27
|
+
version_requirement:
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: "0"
|
33
|
+
version:
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: builder
|
36
|
+
type: :runtime
|
37
|
+
version_requirement:
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version:
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: echoe
|
46
|
+
type: :development
|
47
|
+
version_requirement:
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
description: Library for interfacing with Tourplan's hostConnect software, which is a web service interface for tour booking.
|
55
|
+
email: ""
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files:
|
61
|
+
- README.markdown
|
62
|
+
- CHANGELOG
|
63
|
+
- lib/hostconnect.rb
|
64
|
+
- lib/hostconnect/builders/agent_info_builder.rb
|
65
|
+
- lib/hostconnect/builders/pax_details_builder.rb
|
66
|
+
- lib/hostconnect/builders/add_service_builder.rb
|
67
|
+
- lib/hostconnect/builders/room_config_builder.rb
|
68
|
+
- lib/hostconnect/builders/get_booking_builder.rb
|
69
|
+
- lib/hostconnect/builders/get_services_builder.rb
|
70
|
+
- lib/hostconnect/builders/get_system_settings_builder.rb
|
71
|
+
- lib/hostconnect/builders/get_locations_builder.rb
|
72
|
+
- lib/hostconnect/builders/new_booking_info_builder.rb
|
73
|
+
- lib/hostconnect/builders/suppler_info_builder.rb
|
74
|
+
- lib/hostconnect/builders/list_bookings_builder.rb
|
75
|
+
- lib/hostconnect/builders/option_info_builder.rb
|
76
|
+
- lib/hostconnect/builders/service_line_note_builder.rb
|
77
|
+
- lib/hostconnect/builders/ping_builder.rb
|
78
|
+
- lib/hostconnect/coercion.rb
|
79
|
+
- lib/hostconnect/core_extensions/string.rb
|
80
|
+
- lib/hostconnect/core_extensions/symbol.rb
|
81
|
+
- lib/hostconnect/responses/agent_info.rb
|
82
|
+
- lib/hostconnect/responses/get_services.rb
|
83
|
+
- lib/hostconnect/responses/list_bookings.rb
|
84
|
+
- lib/hostconnect/responses/get_locations.rb
|
85
|
+
- lib/hostconnect/responses/get_booking.rb
|
86
|
+
- lib/hostconnect/responses/option_info.rb
|
87
|
+
- lib/hostconnect/responses/add_service.rb
|
88
|
+
- lib/hostconnect/responses/supplier_info.rb
|
89
|
+
- lib/hostconnect/responses/get_system_settings.rb
|
90
|
+
- lib/hostconnect/responses/ping.rb
|
91
|
+
- lib/hostconnect/rtf_document.rb
|
92
|
+
- lib/hostconnect/builder.rb
|
93
|
+
- lib/hostconnect/client.rb
|
94
|
+
- lib/hostconnect/response.rb
|
95
|
+
files:
|
96
|
+
- Rakefile
|
97
|
+
- README.markdown
|
98
|
+
- CHANGELOG
|
99
|
+
- lib/hostconnect.rb
|
100
|
+
- lib/hostconnect/builders/agent_info_builder.rb
|
101
|
+
- lib/hostconnect/builders/pax_details_builder.rb
|
102
|
+
- lib/hostconnect/builders/add_service_builder.rb
|
103
|
+
- lib/hostconnect/builders/room_config_builder.rb
|
104
|
+
- lib/hostconnect/builders/get_booking_builder.rb
|
105
|
+
- lib/hostconnect/builders/get_services_builder.rb
|
106
|
+
- lib/hostconnect/builders/get_system_settings_builder.rb
|
107
|
+
- lib/hostconnect/builders/get_locations_builder.rb
|
108
|
+
- lib/hostconnect/builders/new_booking_info_builder.rb
|
109
|
+
- lib/hostconnect/builders/suppler_info_builder.rb
|
110
|
+
- lib/hostconnect/builders/list_bookings_builder.rb
|
111
|
+
- lib/hostconnect/builders/option_info_builder.rb
|
112
|
+
- lib/hostconnect/builders/service_line_note_builder.rb
|
113
|
+
- lib/hostconnect/builders/ping_builder.rb
|
114
|
+
- lib/hostconnect/coercion.rb
|
115
|
+
- lib/hostconnect/core_extensions/string.rb
|
116
|
+
- lib/hostconnect/core_extensions/symbol.rb
|
117
|
+
- lib/hostconnect/responses/agent_info.rb
|
118
|
+
- lib/hostconnect/responses/get_services.rb
|
119
|
+
- lib/hostconnect/responses/list_bookings.rb
|
120
|
+
- lib/hostconnect/responses/get_locations.rb
|
121
|
+
- lib/hostconnect/responses/get_booking.rb
|
122
|
+
- lib/hostconnect/responses/option_info.rb
|
123
|
+
- lib/hostconnect/responses/add_service.rb
|
124
|
+
- lib/hostconnect/responses/supplier_info.rb
|
125
|
+
- lib/hostconnect/responses/get_system_settings.rb
|
126
|
+
- lib/hostconnect/responses/ping.rb
|
127
|
+
- lib/hostconnect/rtf_document.rb
|
128
|
+
- lib/hostconnect/builder.rb
|
129
|
+
- lib/hostconnect/client.rb
|
130
|
+
- lib/hostconnect/response.rb
|
131
|
+
- MIT-LICENSE
|
132
|
+
- spec/builders/new_booking_info_builder_spec.rb
|
133
|
+
- spec/builders/ping_builder_spec.rb
|
134
|
+
- spec/builders/get_locations_builder_spec.rb
|
135
|
+
- spec/builders/add_service_builder_spec.rb
|
136
|
+
- spec/builders/room_config_builder_spec.rb
|
137
|
+
- spec/builders/option_info_builder_spec.rb
|
138
|
+
- spec/builders/agent_info_builder_spec.rb
|
139
|
+
- spec/builders/pax_details_builder_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/fixtures/requests/ping.xml
|
142
|
+
- spec/fixtures/requests/agent_info.xml
|
143
|
+
- spec/fixtures/requests/option_info/hotel_search_total_stay_price.xml
|
144
|
+
- spec/fixtures/requests/option_info/option_number.xml
|
145
|
+
- spec/fixtures/requests/option_info/hotel_search.xml
|
146
|
+
- spec/fixtures/requests/get_locations.xml
|
147
|
+
- spec/fixtures/requests/add_service_request/hotel_booking.xml
|
148
|
+
- spec/fixtures/responses/ping.xml
|
149
|
+
- spec/fixtures/responses/agent_info.xml
|
150
|
+
- spec/fixtures/responses/agent_info_error.xml
|
151
|
+
- spec/fixtures/responses/get_booking.xml
|
152
|
+
- spec/fixtures/responses/option_info/tours.xml
|
153
|
+
- spec/fixtures/responses/option_info/hotel_search_with_stay_price.xml
|
154
|
+
- spec/fixtures/responses/option_info/option_number.xml
|
155
|
+
- spec/fixtures/responses/option_info/hotel_price.xml
|
156
|
+
- spec/fixtures/responses/option_info/hotel_search.xml
|
157
|
+
- spec/fixtures/responses/get_system_settings.xml
|
158
|
+
- spec/fixtures/responses/add_service.xml
|
159
|
+
- spec/fixtures/responses/get_locations.xml
|
160
|
+
- spec/client_spec.rb
|
161
|
+
- spec/core_extensions_spec.rb
|
162
|
+
- spec/responses/get_booking_spec.rb
|
163
|
+
- spec/responses/get_system_settings_spec.rb
|
164
|
+
- spec/responses/agent_info_spec.rb
|
165
|
+
- spec/responses/option_info_spec.rb
|
166
|
+
- spec/responses/add_service_spec.rb
|
167
|
+
- spec/responses/ping_spec.rb
|
168
|
+
- spec/responses/get_locations_spec.rb
|
169
|
+
- spec/coercion_spec.rb
|
170
|
+
- Manifest
|
171
|
+
- hostconnect.gemspec
|
172
|
+
has_rdoc: true
|
173
|
+
homepage: http://www.github.com/Chrononaut/hostconnect/
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options:
|
176
|
+
- --line-numbers
|
177
|
+
- --inline-source
|
178
|
+
- --title
|
179
|
+
- Hostconnect
|
180
|
+
- --main
|
181
|
+
- README.markdown
|
182
|
+
require_paths:
|
183
|
+
- lib
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: "0"
|
189
|
+
version:
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: "1.2"
|
195
|
+
version:
|
196
|
+
requirements: []
|
197
|
+
|
198
|
+
rubyforge_project: hostconnect
|
199
|
+
rubygems_version: 1.2.0.1845
|
200
|
+
specification_version: 2
|
201
|
+
summary: Library for interfacing with Tourplan's hostConnect software, which is a web service interface for tour booking.
|
202
|
+
test_files: []
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# Abstract class which all the different builder-classes inherit from. The builders are
|
3
|
+
# used to produce valid XML requests, which are to be sent to the HostConnect server.
|
4
|
+
class AbstractBuilder
|
5
|
+
# String representation of self
|
6
|
+
def to_s
|
7
|
+
to_xml.target!
|
8
|
+
end
|
9
|
+
|
10
|
+
# Send xml to server. Returns a new object.
|
11
|
+
def submit
|
12
|
+
obj = Inflector.constantize(self.class.to_s.gsub(/Builder/, ''))
|
13
|
+
obj.new(Client.post_xml_request(to_s))
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
# Returns a bare xml-builder object, containing just dtd, xml version and encoding
|
18
|
+
def bare
|
19
|
+
x = Builder::XmlMarkup.new(:indent => 2)
|
20
|
+
x.instruct!
|
21
|
+
x.declare! :DOCTYPE, :Request, :SYSTEM, HostConnect.config.dtd
|
22
|
+
x
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def initialize(options = {})
|
27
|
+
@options = options
|
28
|
+
check_for_valid_options
|
29
|
+
set_attrs
|
30
|
+
end
|
31
|
+
|
32
|
+
def check_for_valid_options
|
33
|
+
@options.each_key do |k|
|
34
|
+
raise("No such option: #{k}") unless @valid_options.include?(k)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_attrs
|
39
|
+
@options.each do |k,v|
|
40
|
+
instance_variable_set("@#{k}", v)
|
41
|
+
end
|
42
|
+
|
43
|
+
# It should be possible to set all options after the objects creation,
|
44
|
+
# from it's accessors
|
45
|
+
unless @valid_options.blank?
|
46
|
+
@valid_options.each { |k| self.class.class_eval "attr_accessor :#{k}" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# A booking is built up service by service. Each AddService request adds one
|
3
|
+
# service to a (new or existing) booking. Note that for a service to be added
|
4
|
+
# to an existing booking the agent adding the service must be the same as the
|
5
|
+
# agent who made the original booking.
|
6
|
+
class AddServiceBuilder < AbstractBuilder
|
7
|
+
def initialize(options = {})
|
8
|
+
@valid_options = [ :agent_id, :password, :new_booking_info, :opt, :date_from,
|
9
|
+
:scu_qty, :room_configs, :email, :pu_time, :pu_remark,
|
10
|
+
:do_time, :do_remark, :remarks, :ud_text1, :ud_text2,
|
11
|
+
:ud_text3, :ud_text4, :ud_text5, :agent_ref,
|
12
|
+
:service_line_notes ].freeze
|
13
|
+
super(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_xml
|
17
|
+
x = bare
|
18
|
+
x.Request {
|
19
|
+
x.AddServiceRequest { |i|
|
20
|
+
x.AgentID @agent_id
|
21
|
+
x.Password @password
|
22
|
+
|
23
|
+
if @new_booking_info
|
24
|
+
i << @new_booking_info.to_xml.target!
|
25
|
+
end
|
26
|
+
|
27
|
+
if @room_configs
|
28
|
+
# Stack the room configs onto the request
|
29
|
+
x.RoomConfigs { |i|
|
30
|
+
@room_configs.each { |room| i << room.to_xml.target! }
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
if @service_line_notes
|
35
|
+
x.ServiceLineNotes { |i|
|
36
|
+
@service_line_notes.each { |note| i << note.to_xml.target! }
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
x.Opt @opt if @opt
|
41
|
+
x.DateFrom @date_from if @date_from
|
42
|
+
x.SCUqty @scu_qty if @scu_qty
|
43
|
+
x.Email @email if @email
|
44
|
+
x.AgentRef @agent_ref if @agent_ref
|
45
|
+
x.puTime @pu_time if @pu_time
|
46
|
+
x.puRemark @pu_remark if @pu_remark
|
47
|
+
x.doTime @do_time if @do_time
|
48
|
+
x.doRemark @do_remark if @do_remark
|
49
|
+
x.Remarks @remarks if @remarks
|
50
|
+
x.UDText1 @ud_text1 if @ud_text1
|
51
|
+
x.UDText2 @ud_text2 if @ud_text2
|
52
|
+
x.UDText3 @ud_text3 if @ud_text3
|
53
|
+
x.UDText4 Coercion.to_hc(@ud_text4) unless @ud_text4.nil?
|
54
|
+
x.UDText5 @ud_text5 if @ud_text5
|
55
|
+
}
|
56
|
+
}
|
57
|
+
x
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# The AgentInfo request returns information about the specified agent (and as with other
|
3
|
+
# requests that require AgentID and Password an error is reported if the
|
4
|
+
# AgentID / Password combination is invalid).
|
5
|
+
class AgentInfoBuilder < AbstractBuilder
|
6
|
+
def initialize(options = {})
|
7
|
+
@valid_options = [ :agent_id, :password ].freeze
|
8
|
+
super(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_xml
|
12
|
+
x = bare
|
13
|
+
x.Request {
|
14
|
+
x.AgentInfoRequest { x.AgentID @agent_id; x.Password @password }
|
15
|
+
}
|
16
|
+
x
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# This request retrieves a booking. Note that for a booking to be retrieved
|
3
|
+
# successfully the agent requesting the booking must be the same as the agent
|
4
|
+
# who made the booking.
|
5
|
+
class GetBookingBuilder < AbstractBuilder
|
6
|
+
def initialize(options = {})
|
7
|
+
@valid_options = [ :agent_id, :password, :booking_id ].freeze
|
8
|
+
super(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_xml
|
12
|
+
x = bare
|
13
|
+
x.Request {
|
14
|
+
x.GetBookingRequest {
|
15
|
+
x.AgentID @agent_id
|
16
|
+
x.Password @password
|
17
|
+
x.BookingId @booking_id
|
18
|
+
}
|
19
|
+
}
|
20
|
+
x
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# The GetLocations request returns a list of all location codes and names used
|
3
|
+
# in the system. Note that each Opt option identifier contains a location code.
|
4
|
+
class GetLocationsBuilder < AbstractBuilder
|
5
|
+
def initialize(options = {})
|
6
|
+
@valid_options = [ :agent_id, :password ].freeze
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
x = bare
|
12
|
+
x.Request {
|
13
|
+
x.GetLocationsRequest { x.AgentID @agent_id; x.Password @password }
|
14
|
+
}
|
15
|
+
x
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# The GetServices request returns a list of all service codes and names used
|
3
|
+
# in the system. Note that each Opt option identifier contains a service code.
|
4
|
+
class GetServicesBuilder < AbstractBuilder
|
5
|
+
def initialize(options = {})
|
6
|
+
@valid_options = [ :agent_id, :password ].freeze
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
x = bare
|
12
|
+
x.Request {
|
13
|
+
x.GetServicesRequest { x.AgentID @agent_id; x.Password @password }
|
14
|
+
}
|
15
|
+
x
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# The GetSystemSettings request returns information about the overall system
|
3
|
+
# settings.
|
4
|
+
class GetSystemSettingsBuilder < AbstractBuilder
|
5
|
+
def initialize(options = {})
|
6
|
+
@valid_options = [ :agent_id, :password ].freeze
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
x = bare
|
12
|
+
x.Request {
|
13
|
+
x.GetSystemSettingsRequest { x.AgentID @agent_id; x.Password @password }
|
14
|
+
}
|
15
|
+
x
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# The ListBookings request returns header-level details of zero or
|
3
|
+
# more bookings made by the specifed agent, and that meet all of the
|
4
|
+
# criteria specified. If a sub-login is supplied then only details of
|
5
|
+
# bookings associated with that sub-login are returned.
|
6
|
+
class ListBookingsBuilder < AbstractBuilder
|
7
|
+
def initialize(options = {})
|
8
|
+
@valid_options = [ :agent_id, :password, :travel_date_from, :travel_date_to,
|
9
|
+
:entered_date_from, :entered_date_to, :name_contains,
|
10
|
+
:agent_ref ].freeze
|
11
|
+
super(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_xml
|
15
|
+
x = bare
|
16
|
+
x.Request {
|
17
|
+
x.ListBookingsRequest {
|
18
|
+
@valid_options.each do |opt|
|
19
|
+
val = eval "#{opt}"
|
20
|
+
eval "x.#{opt.camelize.requestify} #{opt}" unless val.blank?
|
21
|
+
end
|
22
|
+
}
|
23
|
+
}
|
24
|
+
x
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module HostConnect
|
2
|
+
class NewBookingInfoBuilder < AbstractBuilder
|
3
|
+
def initialize(options = {})
|
4
|
+
@valid_options = [ :name, :qb, :branch, :department,
|
5
|
+
:sales_analysis1, :sales_analysis2, :sales_analysis3 ].freeze
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_xml
|
10
|
+
x = Builder::XmlMarkup.new(:indent => 2, :margin => 2)
|
11
|
+
x.NewBookingInfo {
|
12
|
+
x.Name @name
|
13
|
+
x.QB @qb
|
14
|
+
x.Branch @branch if @branch
|
15
|
+
x.Department @department if @department
|
16
|
+
x.SalesAnalysis1 @sales_analysis1 if @sales_analysis1
|
17
|
+
x.SalesAnalysis2 @sales_analysis2 if @sales_analysis2
|
18
|
+
x.SalesAnalysis3 @sales_analysis3 if @sales_analysis3
|
19
|
+
}
|
20
|
+
x
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module HostConnect
|
2
|
+
class OptionInfoBuilder < AbstractBuilder
|
3
|
+
def initialize(options = {})
|
4
|
+
@valid_options = [ :agent_id, :password, :opt, :option_number, :info,
|
5
|
+
:date_from, :date_to, :scu_qty, :a_cache, :rate_convert, :room_configs,
|
6
|
+
:minimum_availability, :sort_field, :ascending, :index_first_option,
|
7
|
+
:maximum_options, :note_category, :location_code, :locality_description,
|
8
|
+
:class_description, :description, :supplier_name, :rate_per_scu ].freeze
|
9
|
+
super(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_xml
|
13
|
+
x = bare
|
14
|
+
x.Request {
|
15
|
+
x.OptionInfoRequest {
|
16
|
+
# TODO: probably need to validate sanity of Info / RateConvert here,
|
17
|
+
# and raise exceptions if they are invalid
|
18
|
+
|
19
|
+
# Has to substract from @valid_options instead of @options, because
|
20
|
+
# we have to guarantee the order of elements.
|
21
|
+
(@valid_options - [ :room_configs, :opt, :option_number ]).each do |opt|
|
22
|
+
# Requestify turns Id into ID
|
23
|
+
|
24
|
+
# TODO: I guess this could be done with less eval usage.
|
25
|
+
# Basically, we build xml only for those options that are non-blank
|
26
|
+
val = eval "#{opt}"
|
27
|
+
eval "x.#{opt.camelize.requestify} #{opt}" unless val.blank?
|
28
|
+
end
|
29
|
+
|
30
|
+
if @opt
|
31
|
+
@opt.each { |o| x.Opt o }
|
32
|
+
end
|
33
|
+
|
34
|
+
if @option_number
|
35
|
+
@option_number.each { |o| x.OptionNumber o }
|
36
|
+
end
|
37
|
+
|
38
|
+
if @room_configs
|
39
|
+
# Stack the room configs onto the request
|
40
|
+
x.RoomConfigs { |i|
|
41
|
+
@room_configs.each { |room| i << room.to_xml.target! }
|
42
|
+
}
|
43
|
+
end
|
44
|
+
}
|
45
|
+
}
|
46
|
+
x
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HostConnect
|
2
|
+
class PaxDetailsBuilder < AbstractBuilder
|
3
|
+
def initialize(options = {})
|
4
|
+
@valid_options = [ :title, :forename, :surname, :date_of_birth, :pax_type,
|
5
|
+
:pax_text1, :pax_text2, :pax_text3, :pax_text4,
|
6
|
+
:pax_text5 ].freeze
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
x = Builder::XmlMarkup.new(:indent => 2, :margin => 5)
|
12
|
+
x.PaxDetails {
|
13
|
+
@valid_options.each do |opt|
|
14
|
+
val = eval "#{opt}"
|
15
|
+
eval "x.#{opt.camelize} #{opt}" unless val.blank?
|
16
|
+
end
|
17
|
+
}
|
18
|
+
x
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module HostConnect
|
2
|
+
class RoomConfigBuilder < AbstractBuilder
|
3
|
+
# Room types: SG (single), TW (twin), DB (double), TR (triple), QD (quad)
|
4
|
+
def initialize(options = {})
|
5
|
+
@valid_options = [ :adults, :room_type, :pax_list ].freeze
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_xml
|
10
|
+
x = Builder::XmlMarkup.new(:indent => 2, :margin => 3)
|
11
|
+
x.RoomConfig {
|
12
|
+
x.Adults @adults if @adults
|
13
|
+
x.RoomType Coercion.to_hc(@room_type) if @room_type
|
14
|
+
|
15
|
+
if @pax_list
|
16
|
+
# Stack the PaxDetails builder objects onto the request
|
17
|
+
x.PaxList { |i|
|
18
|
+
@pax_list.each { |pax| i << pax.to_xml.target! }
|
19
|
+
}
|
20
|
+
end
|
21
|
+
}
|
22
|
+
x
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|