roomorama_api 0.3.0 → 0.4.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/.gitignore +1 -0
- data/README.md +7 -0
- data/lib/roomorama_api/version.rb +1 -1
- data/lib/roomorama_api.rb +16 -15
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -77,6 +77,13 @@ Currently this gem does not handle any oauth authentication yet. Host and Guest
|
|
77
77
|
host_inquiries_list
|
78
78
|
host_inquiries_show
|
79
79
|
|
80
|
+
### Debugging
|
81
|
+
|
82
|
+
Turn on debug mode with
|
83
|
+
|
84
|
+
RoomoramaApi::Client = true
|
85
|
+
|
86
|
+
|
80
87
|
### Can't find the API Call you want?
|
81
88
|
|
82
89
|
Submit an issue or a pull request.
|
data/lib/roomorama_api.rb
CHANGED
@@ -15,7 +15,6 @@ require "json"
|
|
15
15
|
module RoomoramaApi
|
16
16
|
|
17
17
|
class Client
|
18
|
-
|
19
18
|
include RoomoramaApi::Api::Destinations
|
20
19
|
include RoomoramaApi::Api::Favorites
|
21
20
|
include RoomoramaApi::Api::Perks
|
@@ -29,6 +28,14 @@ module RoomoramaApi
|
|
29
28
|
@oauth_token = oauth_token
|
30
29
|
end
|
31
30
|
|
31
|
+
def self.debug
|
32
|
+
@debug ||= false
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.debug=(v)
|
36
|
+
@debug = !!v
|
37
|
+
end
|
38
|
+
|
32
39
|
BASE_URL = 'https://api.roomorama.com/'
|
33
40
|
API_VERSION = 'v1.0'
|
34
41
|
|
@@ -40,7 +47,7 @@ module RoomoramaApi
|
|
40
47
|
|
41
48
|
def api_call(method_name, options, verb=:get)
|
42
49
|
response = connection(method_name, options, verb)
|
43
|
-
puts response.inspect
|
50
|
+
puts response.inspect if self.class.debug
|
44
51
|
parse_response response
|
45
52
|
end
|
46
53
|
|
@@ -56,27 +63,21 @@ module RoomoramaApi
|
|
56
63
|
def connection(method_name, options, verb)
|
57
64
|
conn = Faraday.new(:url => api_url) do |faraday|
|
58
65
|
faraday.request :url_encoded
|
59
|
-
#faraday.response
|
66
|
+
#faraday.response(:logger) if self.class.debug
|
60
67
|
faraday.adapter Faraday.default_adapter
|
68
|
+
faraday.headers['User-Agent'] = "RoomoramaApi gem v#{VERSION}"
|
61
69
|
faraday.headers['Authorization'] = "Bearer " + @oauth_token if @oauth_token
|
62
70
|
end
|
63
71
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
response = conn.delete(method_name)
|
70
|
-
else
|
71
|
-
response = conn.get(method_name + "?" + to_query_params(options))
|
72
|
+
case verb
|
73
|
+
when :put then conn.put(method_name, options)
|
74
|
+
when :post then conn.post(method_name, options)
|
75
|
+
when :delete then conn.delete(method_name, options)
|
76
|
+
else conn.get(method_name, options)
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
75
80
|
|
76
|
-
def to_query_params(options)
|
77
|
-
options.collect { |key, value| "#{key}=#{value}" }.join('&')
|
78
|
-
end
|
79
|
-
|
80
81
|
def raise_errors(response)
|
81
82
|
message = "(#{response.status})"
|
82
83
|
|
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.4.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-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|