tour_cms_api 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 551915e0e0a4dbaa2284cdd46952a7416df7feb6b8397c6cc9848241a63ed8b3
4
- data.tar.gz: e5ab9492bb6a90952b20638f731afe9f5fb8f87c7774bed9d0d8e0bf305bbc7d
3
+ metadata.gz: 11d05b1d0ff83713e47b4547c43f256b8ffd7b87cbde142c8b2b213d445d2824
4
+ data.tar.gz: 7937e1396f0a4a0a3ef58027af27e9a923c75346f55dc835e8aa10d03c10f7ee
5
5
  SHA512:
6
- metadata.gz: 2c91169babdb098c3cd77618da6d8e13ad89fc49c22529740d6b987a357e5a16c1888f89e67ee7bb066bb3fdc224e7e1cf0c9ff0ed7786dbf2f1f05d9fac46c7
7
- data.tar.gz: b314b88af7c0534db8b5c56cc142c6162fc886647b245e655830947bc1a86d775d127942f4d58ea1d1bcb2b2bc4d76b156c24d363d884646ba841306dd75c380
6
+ metadata.gz: fba1a9ce11bd92edb0dbada59076ce0a71630bbbc3fcc6b4d393bf8007a6f61329abea81493707be77b7a5c65df66ba6800f2a61402d90d6971fc7838b4792d4
7
+ data.tar.gz: 66cd8705360c3b4ace36a438c52d41f69abae2bc3deecea0b51f6a333ca8c9f4dc45fc14b91b455575e3941e284d76adc73e55158ebbac6c8b7b58655e61c793
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,9 @@ 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
79
83
 
80
84
  ## Dependencies
81
85
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.2
@@ -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,20 @@ 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
+
75
90
  private
76
91
 
77
92
  def generate_signature(path, verb, channel, outbound_time)
@@ -83,15 +98,32 @@ module TourCMS
83
98
  end
84
99
 
85
100
  def request(path, channel = 0, params = {}, verb = "GET")
86
- url = @base_url + path + "?#{params.to_query}"
101
+ url = URI(@base_url + path + "?#{params.to_query}")
102
+
87
103
  req_time = Time.now.utc
88
104
  signature = generate_signature(path + "?#{params.to_query}", verb, channel, req_time.to_i)
89
105
 
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}" }
106
+ https = Net::HTTP.new(url.host, url.port)
107
+ https.use_ssl = true
108
+
109
+ if verb == 'GET'
110
+ request = Net::HTTP::Get.new(url)
111
+ else
112
+ request = Net::HTTP::Post.new(url)
113
+ end
114
+
115
+ request["Content-type"] = "text/xml"
116
+ request["charset"] = "utf-8"
117
+ request["Date"] = req_time.strftime("%a, %d %b %Y %H:%M:%S GMT")
118
+ request["Authorization"] = "TourCMS #{channel}:#{@marketp_id}:#{signature}"
119
+
120
+ if @body != ''
121
+ request.body = @body
122
+ end
123
+
124
+ response = https.request(request)
92
125
 
93
- response = URI.open(url, headers).read
94
- @result_type == "raw" ? response : Hash.from_xml(response)["response"]
126
+ @result_type == "raw" ? response : Hash.from_xml(response.read_body)["response"]
95
127
  end
96
128
  end
97
129
  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,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tour_cms_api"
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tour_cms_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Pimenta