tourico 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.rbc
2
+ *.sassc
3
+ .sass-cache
4
+ capybara-*.html
5
+ .rspec
6
+ /.bundle
7
+ /vendor/bundle
8
+ /log/*
9
+ /tmp/*
10
+ /db/*.sqlite3
11
+ /public/system/*
12
+ /coverage/
13
+ /spec/tmp/*
14
+ **.orig
15
+ rerun.txt
16
+ pickle-email-*.html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tourico.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tourico (0.0.2)
5
+ savon (~> 1.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ akami (1.2.0)
11
+ gyoku (>= 0.4.0)
12
+ nokogiri (>= 1.4.0)
13
+ builder (3.2.2)
14
+ diff-lcs (1.1.3)
15
+ gyoku (0.4.6)
16
+ builder (>= 2.1.2)
17
+ httpi (1.1.1)
18
+ rack
19
+ mini_portile (0.5.1)
20
+ nokogiri (1.6.0)
21
+ mini_portile (~> 0.5.0)
22
+ nori (1.1.5)
23
+ rack (1.5.2)
24
+ rake (10.1.0)
25
+ rspec (2.12.0)
26
+ rspec-core (~> 2.12.0)
27
+ rspec-expectations (~> 2.12.0)
28
+ rspec-mocks (~> 2.12.0)
29
+ rspec-core (2.12.2)
30
+ rspec-expectations (2.12.1)
31
+ diff-lcs (~> 1.1.3)
32
+ rspec-mocks (2.12.2)
33
+ savon (1.2.0)
34
+ akami (~> 1.2.0)
35
+ builder (>= 2.1.2)
36
+ gyoku (~> 0.4.5)
37
+ httpi (~> 1.1.0)
38
+ nokogiri (>= 1.4.0)
39
+ nori (~> 1.1.0)
40
+ wasabi (~> 2.5.0)
41
+ wasabi (2.5.1)
42
+ httpi (~> 1.0)
43
+ nokogiri (>= 1.4.0)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ rake
50
+ rspec (~> 2.6)
51
+ tourico!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 vitalim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Vitali Margolin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Tourico
2
+
3
+ Tourico gem is a ruby wrapper for Tourico API Affiliate Network
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tourico'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tourico
18
+
19
+ ## Usage
20
+
21
+ Create initializers/tourico.rb
22
+
23
+ Tourico.setup do |config|
24
+ config.login_name = ''
25
+ config.password = ''
26
+ config.culture = 'en_US'
27
+ config.hotels_service_version = '8.5'
28
+ config.reservations_service_version = '8.5'
29
+ config.location_service_version = '1'
30
+ end
31
+
32
+
33
+ ## Sample
34
+
35
+ api = Tourico::Api.new
36
+ args = {
37
+ 'hot:request' => {
38
+ 'hot1:Destination' => 'NYC',
39
+ 'hot1:CheckIn' => '2013-10-23',
40
+ 'hot1:CheckOut' => '2013-10-25',
41
+ 'hot1:RoomsInformation' => {
42
+ 'hot1:RoomInfo' => {
43
+ 'hot1:AdultNum' => '2',
44
+ 'hot1:ChildNum' => '0',
45
+ }
46
+ },
47
+ 'hot1:MaxPrice' => '0',
48
+ 'hot1:StarLevel' => '0',
49
+ 'hot1:AvailableOnly' => 'true'
50
+ }
51
+ }
52
+ response = api.get_list(args)
53
+
54
+
55
+ All the other samples could be found inside the Rspec directory:
56
+ spec/models/api_spec.rb
57
+
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,68 @@
1
+ module Tourico
2
+ class Api
3
+
4
+ def initialize
5
+
6
+ end
7
+
8
+ def get_list(args)
9
+ services(:search_hotels, args)
10
+ end
11
+
12
+ def get_hotel_details(args)
13
+ services(:get_hotel_details_v3,args)
14
+ end
15
+
16
+ def get_cancellation_policy(args)
17
+ services(:get_cancellation_policies, args)
18
+ end
19
+
20
+ def book_hotel_v3(args)
21
+ services(:book_hotel_v3,args)
22
+ end
23
+
24
+ def get_cancellation_fee_for_reservation(args)
25
+ services(:get_cancellation_fee, args)
26
+ end
27
+
28
+ def cancel_reservation(args)
29
+ services(:cancel_reservation,args)
30
+ end
31
+
32
+ def check_availability_and_prices(args)
33
+ services(:check_availability_and_prices,args)
34
+ end
35
+
36
+ ## - not working
37
+ def get_previous_reservations(args)
38
+ services(:get_previous_RG, args)
39
+ end
40
+
41
+ def cost_amend(args)
42
+
43
+ end
44
+
45
+ def do_amend(args)
46
+
47
+ end
48
+
49
+
50
+
51
+ private
52
+
53
+ def services (action, args)
54
+ reservations_services = [:get_cancellation_policies, :get_previous_RG,:get_cancellation_fee,:cancel_reservation]
55
+ hotel_services = [:search_hotels,:get_hotel_details_v3,:book_hotel_v3, :check_availability_and_prices]
56
+
57
+ if reservations_services.include?(action)
58
+ return HTTPService.make_request_reservation_service(action, args)
59
+ end
60
+
61
+ if hotel_services.include?(action)
62
+ return HTTPService.make_request(action, args)
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,70 @@
1
+ require 'savon'
2
+
3
+ module Tourico
4
+ module HTTPService
5
+ API_HOTEL_SERVICE_LINK = 'http://demo-hotelws.touricoholidays.com/HotelFlow.svc?wsdl'
6
+ API_RESERVATION_SERVICE_LINK = 'http://demo-wsnew.touricoholidays.com/reservationsservice.asmx?wsdl'
7
+
8
+ class << self
9
+ def make_request(action, args, options = {})
10
+
11
+ client = Savon::Client.new(API_HOTEL_SERVICE_LINK)
12
+
13
+ response = client.request :hot, action do
14
+
15
+ soap.namespaces['xmlns:env'] = 'http://schemas.xmlsoap.org/soap/envelope/'
16
+ soap.namespaces['xmlns:aut'] = 'http://schemas.tourico.com/webservices/authentication'
17
+ soap.namespaces['xmlns:hot'] = 'http://tourico.com/webservices/hotelv3'
18
+ soap.namespaces['xmlns:hot1'] = 'http://schemas.tourico.com/webservices/hotelv3'
19
+
20
+ soap.header = {
21
+ 'aut:AuthenticationHeader' => {
22
+ 'aut:LoginName' => Tourico.login_name,
23
+ 'aut:Password' => Tourico.password,
24
+ 'aut:Culture' => Tourico.culture,
25
+ 'aut:Version' => Tourico.hotels_service_version
26
+ }
27
+ }
28
+
29
+ soap.body = args
30
+
31
+ end
32
+
33
+ if response.success?
34
+ response.to_hash
35
+ else
36
+ nil
37
+ end
38
+ end
39
+
40
+
41
+ def make_request_reservation_service(action, args, options = {})
42
+
43
+ client = Savon::Client.new(API_RESERVATION_SERVICE_LINK)
44
+
45
+ response = client.request :hot, action do
46
+
47
+ soap.namespaces['xmlns:env'] = 'http://www.w3.org/2003/05/soap-envelope'
48
+ soap.namespaces['xmlns:web'] = 'http://tourico.com/webservices/'
49
+ soap.namespaces['xmlns:hot'] = 'http://tourico.com/webservices/'
50
+ soap.namespaces['xmlns:trav'] = 'http://tourico.com/travelservices/'
51
+
52
+ soap.header = {
53
+ 'web:LoginHeader' => {
54
+ 'trav:username' => Tourico.login_name,
55
+ 'trav:password' => Tourico.password,
56
+ 'trav:culture' => Tourico.culture,
57
+ 'trav:version' => Tourico.reservations_service_version
58
+ }
59
+ }
60
+
61
+ soap.body = args
62
+
63
+ end
64
+
65
+ response.to_hash
66
+
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module Tourico
2
+ VERSION = '0.0.2'
3
+ end
data/lib/tourico.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'tourico/version'
2
+ require 'tourico/api'
3
+ require 'tourico/http_service'
4
+
5
+ module Tourico
6
+ class << self
7
+ attr_accessor :login_name, :password, :culture, :hotels_service_version, :reservations_service_version, :location_service_version
8
+
9
+ # initializer with all the configuration values
10
+ def setup
11
+ yield self
12
+ end
13
+
14
+ end
15
+ end
Binary file
@@ -0,0 +1,135 @@
1
+ require 'tourico'
2
+
3
+ describe Tourico::Api do
4
+
5
+ it 'search by hotels' do
6
+ api = Tourico::Api.new
7
+ args = {
8
+ 'hot:request' => {
9
+ 'hot1:Destination' => 'NYC',
10
+ 'hot1:CheckIn' => '2013-08-23',
11
+ 'hot1:CheckOut' => '2013-08-25',
12
+ 'hot1:RoomsInformation' => {
13
+ 'hot1:RoomInfo' => {
14
+ 'hot1:AdultNum' => '2',
15
+ 'hot1:ChildNum' => '0',
16
+ }
17
+ },
18
+ 'hot1:MaxPrice' => '0',
19
+ 'hot1:StarLevel' => '0',
20
+ 'hot1:AvailableOnly' => 'true'
21
+ }
22
+ }
23
+ api.get_list(args).should_not be_nil
24
+ end
25
+
26
+ it 'get hotel details v3' do
27
+ api = Tourico::Api.new
28
+ args = {
29
+ 'hot:HotelIds' => {
30
+ 'hot:HotelID' => '',
31
+ :attributes! => { 'hot:HotelID' => { 'id' => '1314802' } }
32
+ }
33
+ }
34
+
35
+ api.get_hotel_details(args).should_not be_nil
36
+ end
37
+
38
+ it 'get cancellation policy' do
39
+ api = Tourico::Api.new
40
+ args = {
41
+ #'web:nResID' => '',
42
+ 'web:hotelId' =>'2210',
43
+ 'web:hotelRoomTypeId' => '5437',
44
+ 'web:dtCheckIn' => '2013-08-28',
45
+ 'web:dtCheckOut' => '2013-08-29'
46
+ }
47
+
48
+ api.get_cancellation_policy(args).should_not be_nil
49
+ end
50
+
51
+ it'get_previous_reservations' do
52
+ api = Tourico::Api.new
53
+ args = {
54
+ 'web:bFutureOnly' => 'true'
55
+ }
56
+
57
+ api.get_previous_reservations(args).should_not be_nil
58
+ end
59
+
60
+ it 'book hotel v3' do
61
+ api = Tourico::Api.new
62
+ args = {
63
+ 'hot:request' => {
64
+ 'hot1:RecordLocatorId' => '0',
65
+ 'hot1:HotelId' => '1215560',
66
+ 'hot1:HotelRoomTypeId' => '1973855',
67
+ 'hot1:CheckIn' => '2013-09-23',
68
+ 'hot1:CheckOut' => '2013-09-25',
69
+ 'hot1:RoomsInfo' => {
70
+ 'hot1:RoomReserveInfo' => {
71
+ 'hot1:RoomId' => '1',
72
+ 'hot1:ContactPassenger' => {
73
+ 'hot1:FirstName' => 'John',
74
+ 'hot1:LastName' => 'Doe',
75
+ },
76
+ 'hot1:Bedding' => '2,1',
77
+ 'hot1:AdultNum' => '2',
78
+ 'hot1:ChildNum' => '0',
79
+ }
80
+ },
81
+ 'hot1:PaymentType' => 'Obligo',
82
+ 'hot1:AgentRefNumber' => '13NA',
83
+ 'hot1:RequestedPrice' => '324.66',
84
+ 'hot1:DeltaPrice' => '3',
85
+ 'hot1:Currency' => 'USD',
86
+ 'hot1:isOnlyAvailable' => 'true'
87
+ }
88
+ }
89
+ api.book_hotel_v3(args).should_not be_nil
90
+ end
91
+
92
+ it 'cancel reservation' do
93
+ api = Tourico::Api.new
94
+ args = {
95
+ 'web:nResID' => '37434386',
96
+ }
97
+
98
+ api.cancel_reservation(args).should_not be_nil
99
+ end
100
+
101
+ it 'get cancellation fee for reservation' do
102
+ api = Tourico::Api.new
103
+ args = {
104
+ 'web:nResID' => '37434386',
105
+ 'web:clxDate' => '2013-08-26'
106
+ }
107
+
108
+ api.get_cancellation_fee_for_reservation(args).should_not be_nil
109
+
110
+ end
111
+
112
+ it 'check availability and prices' do
113
+ api = Tourico::Api.new
114
+ args = {
115
+ 'hot:request' => {
116
+ 'hot1:HotelIdsInfo'=> {
117
+ 'hot1:HotelIdInfo' => '',
118
+ :attributes! => {'hot1:HotelIdInfo' => {'id' => '1215560'}}
119
+ },
120
+ 'hot1:CheckIn' => '2013-10-23',
121
+ 'hot1:CheckOut' => '2013-10-25',
122
+ 'hot1:RoomsInformation' => {
123
+ 'hot1:RoomInfo' => {
124
+ 'hot1:AdultNum' => '2',
125
+ 'hot1:ChildNum' => '0',
126
+ }
127
+ },
128
+ 'hot1:MaxPrice' => '0',
129
+ 'hot1:StarLevel' => '0',
130
+ 'hot1:AvailableOnly' => 'true'
131
+ }
132
+ }
133
+ api.check_availability_and_prices(args).should_not be_nil
134
+ end
135
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'tourico'
@@ -0,0 +1,9 @@
1
+ require 'tourico'
2
+
3
+ describe Tourico do
4
+ it 'should have a version number' do
5
+ Tourico::VERSION.should_not be_nil
6
+ end
7
+
8
+ end
9
+
data/tourico.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tourico/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "tourico"
8
+ gem.version = Tourico::VERSION
9
+ gem.authors = ["Vitali Margolin"]
10
+ gem.email = ["vitali.m86@gmail.com"]
11
+ gem.description = %q{Tourico gem is a ruby wrapper for Tourico API Affiliate Network}
12
+ gem.summary = %q{Tourico gem is a ruby wrapper for Tourico API Affiliate Network}
13
+ gem.homepage = "http://doc.touricoholidays.com"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'rspec', '~> 2.6'
23
+ gem.add_runtime_dependency 'savon', '~> 1.2.0'
24
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tourico
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vitali Margolin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.6'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.6'
46
+ - !ruby/object:Gem::Dependency
47
+ name: savon
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ description: Tourico gem is a ruby wrapper for Tourico API Affiliate Network
63
+ email:
64
+ - vitali.m86@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - Gemfile.lock
72
+ - LICENSE
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - lib/tourico.rb
77
+ - lib/tourico/api.rb
78
+ - lib/tourico/http_service.rb
79
+ - lib/tourico/version.rb
80
+ - pkg/tourico-0.0.1.gem
81
+ - spec/models/api_spec.rb
82
+ - spec/spec_helper.rb
83
+ - spec/tourico_spec.rb
84
+ - tourico.gemspec
85
+ homepage: http://doc.touricoholidays.com
86
+ licenses:
87
+ - MIT
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 1.8.24
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Tourico gem is a ruby wrapper for Tourico API Affiliate Network
110
+ test_files:
111
+ - spec/models/api_spec.rb
112
+ - spec/spec_helper.rb
113
+ - spec/tourico_spec.rb