tour_cms_api 1.0.1 → 1.0.4

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: 551915e0e0a4dbaa2284cdd46952a7416df7feb6b8397c6cc9848241a63ed8b3
4
- data.tar.gz: e5ab9492bb6a90952b20638f731afe9f5fb8f87c7774bed9d0d8e0bf305bbc7d
3
+ metadata.gz: 279bcddf1293dce0e0f6496ef7c180cf0526108e19a09ca79e22605e6b62c3d3
4
+ data.tar.gz: 771605d0642d07a19556d8859ef510e622802befd3fdb992559b6b264b04362e
5
5
  SHA512:
6
- metadata.gz: 2c91169babdb098c3cd77618da6d8e13ad89fc49c22529740d6b987a357e5a16c1888f89e67ee7bb066bb3fdc224e7e1cf0c9ff0ed7786dbf2f1f05d9fac46c7
7
- data.tar.gz: b314b88af7c0534db8b5c56cc142c6162fc886647b245e655830947bc1a86d775d127942f4d58ea1d1bcb2b2bc4d76b156c24d363d884646ba841306dd75c380
6
+ metadata.gz: f89f55c7f895afa04d71f36f1e78005d05645684f12caf0645d008279a1b2533fe247be9360ef74f6fa8489abd5c443f5b2d9edaac43031aed9e731e4d8509ad
7
+ data.tar.gz: 2b5b58fea871678812c34ede39f0788a984ac236d5c87f939aba068e794281c1ffda2b81a25780d0036d0ea2eb3e93f705105d84fc9e7c52475671cb628d29ea
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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.4
@@ -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)
@@ -64,14 +65,42 @@ module TourCMS
64
65
  request("/c/tour/show.xml", channel, {"id" => tour})
65
66
  end
66
67
 
67
- def show_tour_departures(tour, channel)
68
- request("/c/tour/datesprices/dep/show.xml", channel, {"id" => tour})
68
+ def show_tour_departures(params, channel)
69
+ request("/c/tour/datesprices/dep/show.xml", channel, params)
69
70
  end
70
71
 
71
72
  def show_tour_freesale(tour, channel)
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 = URI.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,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.4"
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Pimenta