tour_cms_api 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/VERSION +1 -1
- data/lib/tour_cms/connection.rb +37 -5
- data/lib/tour_cms_api.rb +2 -0
- data/tour_cms.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11d05b1d0ff83713e47b4547c43f256b8ffd7b87cbde142c8b2b213d445d2824
|
4
|
+
data.tar.gz: 7937e1396f0a4a0a3ef58027af27e9a923c75346f55dc835e8aa10d03c10f7ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
1
|
+
1.0.2
|
data/lib/tour_cms/connection.rb
CHANGED
@@ -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
|
-
|
91
|
-
|
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
|
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
data/tour_cms.gemspec
CHANGED