roomorama_api 0.1.0 → 0.2.0
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.
- data/CHANGELOG +27 -19
- data/README.md +7 -3
- data/lib/roomorama_api/api/destinations.rb +9 -0
- data/lib/roomorama_api/api/favorites.rb +17 -0
- data/lib/roomorama_api/api/host_availabilities.rb +13 -0
- data/lib/roomorama_api/api/host_properties.rb +21 -0
- data/lib/roomorama_api/api/perks.rb +13 -0
- data/lib/roomorama_api/api/properties.rb +29 -0
- data/lib/roomorama_api/api/users.rb +25 -0
- data/lib/roomorama_api/version.rb +1 -1
- data/lib/roomorama_api.rb +98 -174
- data/test/fixtures/hosts/availabilities/list.json +20 -0
- data/test/fixtures/hosts/availabilities/update.json +15 -0
- data/test/roomorama_api_test.rb +185 -167
- metadata +13 -2
data/CHANGELOG
CHANGED
@@ -1,23 +1,31 @@
|
|
1
|
+
## v0.2.0
|
2
|
+
* New API Calls for Host
|
3
|
+
* host_properties_create
|
4
|
+
* host_properties_update
|
5
|
+
* host_availabilities_list
|
6
|
+
* host_availabilities_update
|
7
|
+
* Namespacing API ruby files
|
8
|
+
|
1
9
|
## v0.1.0
|
2
10
|
|
3
11
|
* Initial release
|
4
12
|
* Supports the following API calls
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
* destinations_all
|
14
|
+
* properties_find
|
15
|
+
* properties_get_data
|
16
|
+
* properties_find_similar
|
17
|
+
* properties_availabilities
|
18
|
+
* properties_price_check
|
19
|
+
* properties_reviews
|
20
|
+
* favorites_list
|
21
|
+
* favorites_create
|
22
|
+
* favorites_delete
|
23
|
+
* perks_list
|
24
|
+
* perks_get_data
|
25
|
+
* users_me
|
26
|
+
* users_update_profile
|
27
|
+
* users_get_data
|
28
|
+
* users_register
|
29
|
+
* users_reviews
|
30
|
+
* hosts_properties_list
|
31
|
+
* hosts_properties_show
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ This gem does not handle OAuth authentication or token generation. You may want
|
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
|
-
gem 'roomorama_api'
|
15
|
+
gem 'roomorama_api'
|
16
16
|
|
17
17
|
And then execute:
|
18
18
|
|
@@ -68,8 +68,12 @@ Currently this gem does not handle any oauth authentication yet. Host and Guest
|
|
68
68
|
users_get_data
|
69
69
|
users_register
|
70
70
|
users_reviews
|
71
|
-
|
72
|
-
|
71
|
+
host_properties_list
|
72
|
+
host_properties_show
|
73
|
+
host_properties_create
|
74
|
+
host_properties_update
|
75
|
+
host_availabilities_list
|
76
|
+
host_availabilities_update
|
73
77
|
|
74
78
|
### Can't find the API Call you want?
|
75
79
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RoomoramaApi
|
2
|
+
module Api
|
3
|
+
module Favorites
|
4
|
+
def favorites_list(options = {})
|
5
|
+
api_call "favorites", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def favorites_create(options = {})
|
9
|
+
api_call "favorites", options, :post
|
10
|
+
end
|
11
|
+
|
12
|
+
def favorites_delete(id, options = {})
|
13
|
+
api_call "favorites/" + id.to_s, options, :delete
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RoomoramaApi
|
2
|
+
module Api
|
3
|
+
module HostAvailabilities
|
4
|
+
def host_availabilities_list(room_id, options={})
|
5
|
+
api_call "host/rooms/#{room_id}/availabilities.json", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def host_availabilities_update(room_id, options={})
|
9
|
+
api_call "host/rooms/#{room_id}/availabilities.json", options, :put
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RoomoramaApi
|
2
|
+
module Api
|
3
|
+
module HostProperties
|
4
|
+
def host_properties_list(options={})
|
5
|
+
api_call "host/rooms", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def host_properties_show(room_id, options={})
|
9
|
+
api_call "host/rooms/" + room_id.to_s, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def host_properties_create(room_id, options={})
|
13
|
+
api_call "host/rooms/" + room_id.to_s, options, :post
|
14
|
+
end
|
15
|
+
|
16
|
+
def host_properties_update(room_id, options={})
|
17
|
+
api_call "host/rooms/" + room_id.to_s, options, :put
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RoomoramaApi
|
2
|
+
module Api
|
3
|
+
module Properties
|
4
|
+
def properties_find(options={})
|
5
|
+
api_call "rooms", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def properties_get_data(room_id, options={})
|
9
|
+
api_call "rooms/" + room_id.to_s, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def properties_find_similar(room_id, options={})
|
13
|
+
api_call "rooms/" + room_id.to_s + "/similar", options
|
14
|
+
end
|
15
|
+
|
16
|
+
def properties_availabilities(room_id, options={})
|
17
|
+
api_call "rooms/" + room_id.to_s + "/availabilities", options
|
18
|
+
end
|
19
|
+
|
20
|
+
def properties_price_check(room_id, options={})
|
21
|
+
api_call "inquiries/new.json", options.merge(room_id: room_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def properties_reviews(room_id, options={})
|
25
|
+
api_call "rooms/" + room_id.to_s + "/reviews", options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RoomoramaApi
|
2
|
+
module Api
|
3
|
+
module Users
|
4
|
+
def users_me(options={})
|
5
|
+
api_call "me", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def users_update_profile(options={})
|
9
|
+
api_call "me", options, :put
|
10
|
+
end
|
11
|
+
|
12
|
+
def users_get_data(user_id, options={})
|
13
|
+
api_call "users/" + user_id.to_s, options
|
14
|
+
end
|
15
|
+
|
16
|
+
def users_register(options={})
|
17
|
+
api_call "users", options, :post
|
18
|
+
end
|
19
|
+
|
20
|
+
def users_reviews(user_id, options={})
|
21
|
+
api_call "users/" + user_id.to_s + "/reviews", options
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/roomorama_api.rb
CHANGED
@@ -1,182 +1,106 @@
|
|
1
1
|
require "roomorama_api/version"
|
2
|
+
|
3
|
+
require "roomorama_api/api/destinations"
|
4
|
+
require "roomorama_api/api/favorites"
|
5
|
+
require "roomorama_api/api/perks"
|
6
|
+
require "roomorama_api/api/properties"
|
7
|
+
require "roomorama_api/api/users"
|
8
|
+
require "roomorama_api/api/host_properties"
|
9
|
+
require "roomorama_api/api/host_availabilities"
|
10
|
+
|
2
11
|
require "faraday"
|
3
12
|
require "json"
|
4
13
|
|
5
14
|
module RoomoramaApi
|
6
15
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
#### Hosts/Properties
|
98
|
-
|
99
|
-
def hosts_properties_list(options={})
|
100
|
-
api_call "host/rooms", options
|
101
|
-
end
|
102
|
-
|
103
|
-
def hosts_properties_show(room_id, options={})
|
104
|
-
api_call "host/rooms/" + room_id.to_s, options
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
def api_url
|
111
|
-
BASE_URL + API_VERSION + '/'
|
112
|
-
end
|
113
|
-
|
114
|
-
def api_call(method_name, options, verb=:get)
|
115
|
-
response = connection(method_name, options, verb)
|
116
|
-
parse_response response
|
117
|
-
end
|
118
|
-
|
119
|
-
def parse_response(response)
|
120
|
-
raise_errors response
|
121
|
-
if response.body == " "
|
122
|
-
{}
|
123
|
-
else
|
124
|
-
JSON.parse response.body
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def connection(method_name, options, verb)
|
129
|
-
|
130
|
-
conn = Faraday.new(:url => api_url) do |faraday|
|
131
|
-
faraday.request :url_encoded
|
132
|
-
#faraday.response :logger
|
133
|
-
faraday.adapter Faraday.default_adapter
|
134
|
-
faraday.headers['Authorization'] = "Bearer " + @oauth_token
|
135
|
-
end
|
136
|
-
|
137
|
-
if verb == :put
|
138
|
-
response = conn.put(method_name, options)
|
139
|
-
elsif verb == :post
|
140
|
-
response = conn.post(method_name, options)
|
141
|
-
elsif verb == :delete
|
142
|
-
response = conn.delete(method_name)
|
143
|
-
else
|
144
|
-
response = conn.get(method_name + "?" + to_query_params(options))
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
def to_query_params(options)
|
150
|
-
options.collect { |key, value| "#{key}=#{value}" }.join('&')
|
151
|
-
end
|
152
|
-
|
153
|
-
def raise_errors(response)
|
154
|
-
message = "(#{response.status})"
|
155
|
-
|
156
|
-
case response.status.to_i
|
157
|
-
when 400
|
158
|
-
raise BadRequest, message
|
159
|
-
when 401
|
160
|
-
raise Unauthorized, message
|
161
|
-
when 403
|
162
|
-
raise General, message
|
163
|
-
when 404
|
164
|
-
raise NotFound, message
|
165
|
-
when 500
|
166
|
-
raise InternalError, "An internal error is thrown."
|
167
|
-
when 502..503
|
168
|
-
raise Unavailable, message
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
class BadRequest < StandardError; end
|
176
|
-
class Unauthorized < StandardError; end
|
177
|
-
class General < StandardError; end
|
178
|
-
class Unavailable < StandardError; end
|
179
|
-
class InternalError < StandardError; end
|
180
|
-
class NotFound < StandardError; end
|
16
|
+
class Client
|
17
|
+
|
18
|
+
include RoomoramaApi::Api::Destinations
|
19
|
+
include RoomoramaApi::Api::Favorites
|
20
|
+
include RoomoramaApi::Api::Perks
|
21
|
+
include RoomoramaApi::Api::Properties
|
22
|
+
include RoomoramaApi::Api::Users
|
23
|
+
include RoomoramaApi::Api::HostProperties
|
24
|
+
include RoomoramaApi::Api::HostAvailabilities
|
25
|
+
|
26
|
+
def initialize(oauth_token=nil)
|
27
|
+
@oauth_token = oauth_token
|
28
|
+
end
|
29
|
+
|
30
|
+
BASE_URL = 'https://api.roomorama.com/'
|
31
|
+
API_VERSION = 'v1.0'
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def api_url
|
36
|
+
BASE_URL + API_VERSION + '/'
|
37
|
+
end
|
38
|
+
|
39
|
+
def api_call(method_name, options, verb=:get)
|
40
|
+
response = connection(method_name, options, verb)
|
41
|
+
puts response.inspect
|
42
|
+
parse_response response
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_response(response)
|
46
|
+
raise_errors response
|
47
|
+
if response.body == " "
|
48
|
+
{}
|
49
|
+
else
|
50
|
+
JSON.parse response.body
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def connection(method_name, options, verb)
|
55
|
+
conn = Faraday.new(:url => api_url) do |faraday|
|
56
|
+
faraday.request :url_encoded
|
57
|
+
#faraday.response :logger
|
58
|
+
faraday.adapter Faraday.default_adapter
|
59
|
+
faraday.headers['Authorization'] = "Bearer " + @oauth_token if @oauth_token
|
60
|
+
end
|
61
|
+
|
62
|
+
if verb == :put
|
63
|
+
response = conn.put(method_name, options)
|
64
|
+
elsif verb == :post
|
65
|
+
response = conn.post(method_name, options)
|
66
|
+
elsif verb == :delete
|
67
|
+
response = conn.delete(method_name)
|
68
|
+
else
|
69
|
+
response = conn.get(method_name + "?" + to_query_params(options))
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def to_query_params(options)
|
75
|
+
options.collect { |key, value| "#{key}=#{value}" }.join('&')
|
76
|
+
end
|
77
|
+
|
78
|
+
def raise_errors(response)
|
79
|
+
message = "(#{response.status})"
|
80
|
+
|
81
|
+
case response.status.to_i
|
82
|
+
when 400
|
83
|
+
raise BadRequest, message
|
84
|
+
when 401
|
85
|
+
raise Unauthorized, message
|
86
|
+
when 403
|
87
|
+
raise General, message
|
88
|
+
when 404
|
89
|
+
raise NotFound, message
|
90
|
+
when 500
|
91
|
+
raise InternalError, "An internal error is thrown."
|
92
|
+
when 502, 503
|
93
|
+
raise Unavailable, message
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
class BadRequest < StandardError; end
|
100
|
+
class Unauthorized < StandardError; end
|
101
|
+
class General < StandardError; end
|
102
|
+
class Unavailable < StandardError; end
|
103
|
+
class InternalError < StandardError; end
|
104
|
+
class NotFound < StandardError; end
|
181
105
|
|
182
106
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"result": {
|
3
|
+
"availabilities": [
|
4
|
+
{
|
5
|
+
"date": "2013-01-01",
|
6
|
+
"available": true,
|
7
|
+
"currency_code": "SGD",
|
8
|
+
"nightly_rate": 10,
|
9
|
+
"weekly_rate": 70,
|
10
|
+
"monthly_rate": 300,
|
11
|
+
"can_checkin": true,
|
12
|
+
"can_checkout": true,
|
13
|
+
"default": true,
|
14
|
+
"inquiry_id": "null"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
},
|
18
|
+
"count": 1,
|
19
|
+
"status": 200
|
20
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"date": "2013-08-01",
|
4
|
+
"available": true,
|
5
|
+
"currency_code": "SGD",
|
6
|
+
"nightly_rate": 1,
|
7
|
+
"weekly_rate": 1,
|
8
|
+
"monthly_rate": 1,
|
9
|
+
"can_checkin": true,
|
10
|
+
"can_checkout": true,
|
11
|
+
"default": false,
|
12
|
+
"inquiry_id": "null",
|
13
|
+
"errors": []
|
14
|
+
}
|
15
|
+
]
|
data/test/roomorama_api_test.rb
CHANGED
@@ -3,173 +3,191 @@ require 'roomorama_api'
|
|
3
3
|
|
4
4
|
class RoomoramaApiTest < MiniTest::Unit::TestCase
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
6
|
+
OAUTH_TOKEN = 'xxx' # Insert OAuth token to test
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@client = RoomoramaApi::Client.new(OAUTH_TOKEN)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_order
|
13
|
+
:alpha
|
14
|
+
end
|
15
|
+
|
16
|
+
#### Destinations
|
17
|
+
|
18
|
+
def test_destinations_all
|
19
|
+
stub_get("https://api.roomorama.com/v1.0/destinations", 'destinations/all.json')
|
20
|
+
result = @client.destinations_all
|
21
|
+
assert_equal result["result"].count, 5288
|
22
|
+
end
|
23
|
+
|
24
|
+
#### Properties
|
25
|
+
|
26
|
+
def test_properties_find
|
27
|
+
stub_get("https://api.roomorama.com/v1.0/rooms?destination=singapore&num_guests=2&num_rooms=2&max_price=300&min_price=100", 'properties/find.json')
|
28
|
+
result = @client.properties_find(destination:"singapore", num_guests:2, num_rooms:2, max_price:300, min_price:100)
|
29
|
+
assert_equal result["result"].count, 10
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_properties_get_data
|
33
|
+
stub_get("https://api.roomorama.com/v1.0/rooms/3002", 'properties/get_data.json')
|
34
|
+
result = @client.properties_get_data 3002
|
35
|
+
assert_equal result["result"]["id"], 3002
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_properties_find_similar
|
39
|
+
stub_get("https://api.roomorama.com/v1.0/rooms/3002/similar", 'properties/find_similar.json')
|
40
|
+
result = @client.properties_find_similar 3002
|
41
|
+
assert_equal result["result"].count, 5
|
42
|
+
assert_equal result["result"].first["title"], "Madison Avenue Apartment for rent on weekends"
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_properties_availabilities
|
46
|
+
stub_get("https://api.roomorama.com/v1.0/rooms/3002/availabilities?start_date=2013-12-01&end_date=2013-12-31", 'properties/availabilities.json')
|
47
|
+
result = @client.properties_availabilities 3002, start_date:"2013-12-01", end_date:"2013-12-31"
|
48
|
+
assert_equal result["result"].count, 31
|
49
|
+
assert_equal result["result"].first["available"], true
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_properties_price_check
|
53
|
+
stub_get("https://api.roomorama.com/v1.0/inquiries/new.json?room_id=60425&check_in=2013-07-01&check_out=2013-07-10", 'properties/price_check.json')
|
54
|
+
result = @client.properties_price_check 60425, check_in:"2013-07-01", check_out:"2013-07-10"
|
55
|
+
assert_equal result["result"]["total"], 9168
|
56
|
+
assert_equal result["result"]["check_in"], "2013-07-01"
|
57
|
+
assert_equal result["result"]["check_out"], "2013-07-10"
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_properties_reviews
|
61
|
+
stub_get("https://api.roomorama.com/v1.0/rooms/8582/reviews", 'properties/reviews.json')
|
62
|
+
result = @client.properties_reviews 8582
|
63
|
+
assert_equal result["result"].first["rating"], 1
|
64
|
+
assert_equal result["result"].first["room"]["id"], 8582
|
65
|
+
end
|
66
|
+
|
67
|
+
#### Favorites
|
68
|
+
|
69
|
+
def test_favorites_list
|
70
|
+
stub_get("https://api.roomorama.com/v1.0/favorites", 'favorites/list.json')
|
71
|
+
result = @client.favorites_list
|
72
|
+
assert_equal result["result"].first["title"], "[7801] STUNNING WEST VILLAGE"
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_favorites_create
|
76
|
+
stub_post("https://api.roomorama.com/v1.0/favorites", "favorites/create.json")
|
77
|
+
result = @client.favorites_create room_id: 2291
|
78
|
+
assert_equal result["room_id"], 2291
|
79
|
+
end
|
80
|
+
|
81
|
+
#### Perks
|
82
|
+
|
83
|
+
def test_perks_list
|
84
|
+
stub_get("https://api.roomorama.com/v1.0/perks?destination=singapore", "perks/list.json")
|
85
|
+
result = @client.perks_list destination: "singapore"
|
86
|
+
assert_equal result["count"], 25
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_perks_get_data
|
90
|
+
stub_get("https://api.roomorama.com/v1.0/perks/25", "perks/get_data.json")
|
91
|
+
result = @client.perks_get_data 25
|
92
|
+
assert_equal result["result"]["name"], "Mygola Trip Planning"
|
93
|
+
end
|
94
|
+
|
95
|
+
#### Users
|
96
|
+
|
97
|
+
def test_users_me
|
98
|
+
stub_get("https://api.roomorama.com/v1.0/me", "users/me.json")
|
99
|
+
result = @client.users_me
|
100
|
+
assert_equal result["result"]["id"], 1419
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_users_update_profile
|
104
|
+
stub_put("https://api.roomorama.com/v1.0/me", "users/update_profile.json")
|
105
|
+
result = @client.users_update_profile
|
106
|
+
assert_equal result["result"]["id"], 1419
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_users_get_data
|
110
|
+
stub_get("https://api.roomorama.com/v1.0/users/1900", "users/get_data.json")
|
111
|
+
result = @client.users_get_data 1900
|
112
|
+
assert_equal result["result"]["id"], 1900
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_users_register
|
116
|
+
stub_post("https://api.roomorama.com/v1.0/users", "users/register.json")
|
117
|
+
result = @client.users_register login: "test123", password: "testapi", email: "test@example.com", first_name: "Skrillex", last_name: "Avicii"
|
118
|
+
assert_equal result["result"]["login"], "test123"
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_users_reviews
|
122
|
+
stub_get("https://api.roomorama.com/v1.0/users/291/reviews", "users/reviews.json")
|
123
|
+
result = @client.users_reviews 291
|
124
|
+
assert_equal result["result"][0]["host_to_guest"], false
|
125
|
+
assert_equal result["result"][0]["host"]["id"], 291
|
126
|
+
end
|
127
|
+
|
128
|
+
#### Hosts/Properties
|
129
|
+
|
130
|
+
def test_hosts_properties_list
|
131
|
+
stub_get("https://api.roomorama.com/v1.0/host/rooms", "hosts/properties/list.json")
|
132
|
+
result = @client.host_properties_list
|
133
|
+
assert_equal result["result"][0]["id"], 9999
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_hosts_properties_show
|
137
|
+
stub_get("https://api.roomorama.com/v1.0/host/rooms/9999", "hosts/properties/show.json")
|
138
|
+
result = @client.host_properties_show 9999
|
139
|
+
assert_equal result["result"]["id"], 9999
|
140
|
+
end
|
141
|
+
|
142
|
+
# def test_hosts_properties_create
|
143
|
+
# end
|
144
|
+
|
145
|
+
# def test_hosts_properties_delete
|
146
|
+
# end
|
147
|
+
|
148
|
+
def test_hosts_availabilities_list
|
149
|
+
stub_get("https://api.roomorama.com/v1.0/host/rooms/9999/availabilities.json", "hosts/availabilities/list.json")
|
150
|
+
result = @client.host_availabilities_list 9999
|
151
|
+
assert_equal result["count"], 1
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_hosts_availabilities_update
|
155
|
+
stub_put("https://api.roomorama.com/v1.0/host/rooms/9999/availabilities.json", "hosts/availabilities/update.json")
|
156
|
+
result = @client.host_availabilities_update 9999
|
157
|
+
assert_equal result[0].is_a?(Hash), true
|
158
|
+
end
|
159
|
+
|
160
|
+
# def test_get_data_for_an_empty_property
|
161
|
+
# assert_raises RoomoramaApi::NotFound do
|
162
|
+
# result = @client.properties_get_data 500
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
|
166
|
+
# def test_get_information_about_me_oauth
|
167
|
+
# result = @client.users_me
|
168
|
+
# # assert_equal
|
169
|
+
# end
|
170
|
+
|
171
|
+
#### Favorites
|
172
|
+
|
173
|
+
# def test_favorites_create
|
174
|
+
# result = @client.favorites_create room_id: 1890
|
175
|
+
# end
|
176
|
+
|
177
|
+
# def test_favorites_list
|
178
|
+
# result = @client.favorites_list
|
179
|
+
# puts result
|
180
|
+
# end
|
181
|
+
|
182
|
+
# def test_favorites_delete
|
183
|
+
# result = @client.favorites_delete 1890
|
184
|
+
# puts result
|
185
|
+
#end
|
186
|
+
|
187
|
+
#### Perks
|
188
|
+
|
189
|
+
|
190
|
+
#### Users
|
173
191
|
|
174
192
|
|
175
193
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roomorama_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -91,11 +91,20 @@ files:
|
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
93
|
- lib/roomorama_api.rb
|
94
|
+
- lib/roomorama_api/api/destinations.rb
|
95
|
+
- lib/roomorama_api/api/favorites.rb
|
96
|
+
- lib/roomorama_api/api/host_availabilities.rb
|
97
|
+
- lib/roomorama_api/api/host_properties.rb
|
98
|
+
- lib/roomorama_api/api/perks.rb
|
99
|
+
- lib/roomorama_api/api/properties.rb
|
100
|
+
- lib/roomorama_api/api/users.rb
|
94
101
|
- lib/roomorama_api/version.rb
|
95
102
|
- roomorama_api.gemspec
|
96
103
|
- test/fixtures/destinations/all.json
|
97
104
|
- test/fixtures/favorites/create.json
|
98
105
|
- test/fixtures/favorites/list.json
|
106
|
+
- test/fixtures/hosts/availabilities/list.json
|
107
|
+
- test/fixtures/hosts/availabilities/update.json
|
99
108
|
- test/fixtures/hosts/properties/list.json
|
100
109
|
- test/fixtures/hosts/properties/show.json
|
101
110
|
- test/fixtures/perks/get_data.json
|
@@ -141,6 +150,8 @@ test_files:
|
|
141
150
|
- test/fixtures/destinations/all.json
|
142
151
|
- test/fixtures/favorites/create.json
|
143
152
|
- test/fixtures/favorites/list.json
|
153
|
+
- test/fixtures/hosts/availabilities/list.json
|
154
|
+
- test/fixtures/hosts/availabilities/update.json
|
144
155
|
- test/fixtures/hosts/properties/list.json
|
145
156
|
- test/fixtures/hosts/properties/show.json
|
146
157
|
- test/fixtures/perks/get_data.json
|