tour_cms_api 1.0.1 → 1.0.4
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 +4 -4
- data/README.md +8 -1
- data/VERSION +1 -1
- data/lib/tour_cms/connection.rb +53 -7
- 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: 279bcddf1293dce0e0f6496ef7c180cf0526108e19a09ca79e22605e6b62c3d3
|
4
|
+
data.tar.gz: 771605d0642d07a19556d8859ef510e622802befd3fdb992559b6b264b04362e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
1
|
+
1.0.4
|
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)
|
@@ -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(
|
68
|
-
request("/c/tour/datesprices/dep/show.xml", channel,
|
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
|
-
|
91
|
-
|
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
|
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
data/tour_cms.gemspec
CHANGED