tour_cms_api 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9755cbf0a64d81fc71b84e41de66aefb90e6460a4de6b591173666566d6b468
4
- data.tar.gz: d3b77c59e8155ac6bad5ad6d17d465d766e34e5b76ed82951c6ee6d2f2ee787c
3
+ metadata.gz: 49b78f2957e7e2249771343d23f8fd96d2d7d816e449c6b80f1e54f33edfeeea
4
+ data.tar.gz: d3e64464c950654eae4ff828d0b2cfdfc370ce0da5fdd258d1f3a584976a820a
5
5
  SHA512:
6
- metadata.gz: f21714e56efb5290f83148e37d947895d7403b4e5a6df8916532150d12716b8137feea53f5512c86aca73f86dd0416fe8c879a8b84abb80f7ece5e49199bf618
7
- data.tar.gz: bb6b66115dc704921d593365a4a2866e1209de646adc4c6ca3c2e55b41af35cbd272efe0049b298d2836ff0a27c5577d5c82c06ceb5978f2f6bad19461960934
6
+ metadata.gz: 771cf491feb386e13a11286c028e3b66a9dac3138f65596db7feb5f7682b62516ddd32729b61d7e24365dd3f3e57cd29f088f49e49f37de1e626a1f596c99777
7
+ data.tar.gz: 0a414eaecfa2659b9f0cf006d80cf5cbc5e7eb23c2af57bd453d1425d77f8bc5cbb065b896a9875b4b921381569010c5141ee9248e3bf687170c7fa63758b745
data/README.md CHANGED
@@ -4,7 +4,7 @@ A simple wrapper for connecting to [TourCMS Marketplace API](http://www.tourcms.
4
4
 
5
5
  ## Install
6
6
 
7
- gem install tour_cms
7
+ gem install tour_cms_api
8
8
 
9
9
  ## Usage
10
10
 
@@ -57,6 +57,7 @@ Your Marketplace ID and Private Key can be found in the TourCMS Partner Portal.
57
57
  obj['tour'].first['tour_name']
58
58
  => "Canyoning"
59
59
 
60
+
60
61
  ### Passing parameters
61
62
 
62
63
  Many TourCMS methods accept parameters. Most methods take a hash of parameters like so:
@@ -76,6 +77,12 @@ Many TourCMS methods accept parameters. Most methods take a hash of parameters l
76
77
  * show\_tour
77
78
  * show\_tour\_departures
78
79
  * show\_tour\_freesale
80
+ * check\_tour\_availability
81
+ * booking\_start\_new
82
+ * booking\_commit\_new
83
+ * booking\_show
84
+ * booking\_cancel
85
+ * booking\_send\_email
79
86
 
80
87
  ## Dependencies
81
88
 
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake'
12
12
  require 'jeweler'
13
13
  Jeweler::Tasks.new do |gem|
14
14
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "tour_cms"
15
+ gem.name = "tour_cms_api"
16
16
  gem.homepage = "https://github.com/luispimenta/tour_cms"
17
17
  gem.license = "MIT"
18
18
  gem.summary = %Q{A Ruby Library for the TourCMS API}
@@ -43,7 +43,7 @@ Rake::RDocTask.new do |rdoc|
43
43
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
44
 
45
45
  rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "tour_cms #{version}"
46
+ rdoc.title = "tour_cms_api #{version}"
47
47
  rdoc.rdoc_files.include('README*')
48
48
  rdoc.rdoc_files.include('lib/**/*.rb')
49
49
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.3
@@ -6,6 +6,7 @@ module TourCMS
6
6
  @private_key = private_key
7
7
  @result_type = result_type
8
8
  @base_url = "https://api.tourcms.com"
9
+ @body = ''
9
10
  end
10
11
 
11
12
  def api_rate_limit_status(channel = 0)
@@ -72,6 +73,34 @@ module TourCMS
72
73
  request("/c/tour/datesprices/freesale/show.xml", channel, {"id" => tour})
73
74
  end
74
75
 
76
+ def check_tour_availability(params, channel)
77
+ request("/c/tour/datesprices/checkavail.xml", channel, params)
78
+ end
79
+
80
+ def booking_start_new(body = '', channel)
81
+ @body = body
82
+ request("/c/booking/new/start.xml", channel, {}, "POST")
83
+ end
84
+
85
+ def booking_commit_new(body = '', channel)
86
+ @body = body
87
+ request("/c/booking/new/commit.xml", channel, {}, "POST")
88
+ end
89
+
90
+ def booking_show(params, channel)
91
+ request("/c/booking/show.xml", channel, params)
92
+ end
93
+
94
+ def booking_cancel(body = '', channel)
95
+ @body = body
96
+ request("/c/booking/cancel.xml", channel, {}, "POST")
97
+ end
98
+
99
+ def booking_send_email(body = '', channel)
100
+ @body = body
101
+ request("/c/booking/email/send.xml", channel, {}, "POST")
102
+ end
103
+
75
104
  private
76
105
 
77
106
  def generate_signature(path, verb, channel, outbound_time)
@@ -83,15 +112,32 @@ module TourCMS
83
112
  end
84
113
 
85
114
  def request(path, channel = 0, params = {}, verb = "GET")
86
- url = @base_url + path + "?#{params.to_query}"
115
+ url = URI(@base_url + path + "?#{params.to_query}")
116
+
87
117
  req_time = Time.now.utc
88
118
  signature = generate_signature(path + "?#{params.to_query}", verb, channel, req_time.to_i)
89
119
 
90
- headers = {"Content-type" => "text/xml", "charset" => "utf-8", "Date" => req_time.strftime("%a, %d %b %Y %H:%M:%S GMT"),
91
- "Authorization" => "TourCMS #{channel}:#{@marketp_id}:#{signature}" }
120
+ https = Net::HTTP.new(url.host, url.port)
121
+ https.use_ssl = true
122
+
123
+ if verb == 'GET'
124
+ request = Net::HTTP::Get.new(url)
125
+ else
126
+ request = Net::HTTP::Post.new(url)
127
+ end
128
+
129
+ request["Content-type"] = "text/xml"
130
+ request["charset"] = "utf-8"
131
+ request["Date"] = req_time.strftime("%a, %d %b %Y %H:%M:%S GMT")
132
+ request["Authorization"] = "TourCMS #{channel}:#{@marketp_id}:#{signature}"
133
+
134
+ if @body != ''
135
+ request.body = @body
136
+ end
137
+
138
+ response = https.request(request)
92
139
 
93
- response = open(url, headers).read
94
- @result_type == "raw" ? response : Hash.from_xml(response)["response"]
140
+ @result_type == "raw" ? response : Hash.from_xml(response.read_body)["response"]
95
141
  end
96
142
  end
97
143
  end
data/lib/tour_cms_api.rb CHANGED
@@ -8,5 +8,7 @@ require 'base64'
8
8
  require 'cgi'
9
9
  require 'open-uri'
10
10
  require 'rubygems'
11
+ require "uri"
12
+ require "net/http"
11
13
 
12
14
  require 'tour_cms/connection'
data/tour_cms.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tour_cms_api"
8
- s.version = "1.0.0"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Luis Pimenta"]
12
- s.date = %q{2022-04-30}
12
+ s.date = %q{2022-05-01}
13
13
  s.description = %q{A simple Ruby wrapper for interacting with the TourCMS API}
14
14
  s.email = %q{email@luispimenta.me}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tour_cms_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Pimenta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-30 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport