rtx-api 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rtx/api/client.rb +13 -23
- data/lib/rtx/api/resources.rb +32 -31
- data/lib/rtx/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b4db61a6bd24dffc972f5bed4d5cae701181d29
|
4
|
+
data.tar.gz: 79aadaf223ca11d2b64095279f2aed58f7153bce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 785c055d09f561f1b8cf3bc274a55a855525e01f230d4860f082b3a0ce35336cedd18bcccc6218cb76cc918cc87fd16cf2a7d984da2a317be0c5a76d874a54cb
|
7
|
+
data.tar.gz: 6736087d36bb27051ae5abb86a6676463d5e9c51786070d2a9c77ccad04ff240c9bfd90caff0314a04faf1953af6841598ef8d34ccce75e7aa1bd9be81a7261f
|
data/lib/rtx/api/client.rb
CHANGED
@@ -31,62 +31,53 @@ module RTX
|
|
31
31
|
if token
|
32
32
|
request = self.class.delete("#{rtx_api_url}/auth", options(:delete))
|
33
33
|
if request.code != 204
|
34
|
-
raise API::Errors::AuthenticationError.new("Authentication Logout Error: #{
|
34
|
+
raise API::Errors::AuthenticationError.new("Authentication Logout Error: #{request}")
|
35
35
|
end
|
36
36
|
@token, @expires, @account_id, @profile_id = nil, nil, nil, nil
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def method_missing(method, *args, &block)
|
41
|
-
|
42
|
-
method_name = method.to_s
|
43
|
-
|
44
|
-
if allowed_resources.include? method_name
|
41
|
+
if resource_path(method)
|
45
42
|
attrs = {}
|
46
43
|
if args.size > 0
|
47
44
|
attrs = args.last.is_a?(Hash) ? args.pop : {}
|
48
45
|
end
|
49
|
-
RTX::API::Collection.new(self,
|
46
|
+
RTX::API::Collection.new(self, method, attrs)
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
50
|
def collection(resource_name, attrs = {})
|
54
|
-
|
55
|
-
request = self.class.get("#{rtx_api_url}/#{resource_name}", options(:get, attrs))
|
51
|
+
request = self.class.get("#{rtx_api_url}/#{resource_path(resource_name)}", options(:get, attrs))
|
56
52
|
handle_request(request)
|
57
53
|
end
|
58
54
|
|
59
55
|
def detail(resource_name, resource_id, attrs = {})
|
60
|
-
resource_exists?(resource_name)
|
61
56
|
raise API::Errors::RequestError.new("id was not provided") if resource_id.nil?
|
62
|
-
request = self.class.get("#{rtx_api_url}/#{resource_name}/#{resource_id}", options(:get, attrs))
|
57
|
+
request = self.class.get("#{rtx_api_url}/#{resource_path(resource_name)}/#{resource_id}", options(:get, attrs))
|
63
58
|
handle_request(request)
|
64
59
|
end
|
65
60
|
|
66
61
|
def post(resource_name, attrs = {})
|
67
|
-
|
68
|
-
request = self.class.post("#{rtx_api_url}/#{resource_name}", options(:post, attrs))
|
62
|
+
request = self.class.post("#{rtx_api_url}/#{resource_path(resource_name)}", options(:post, attrs))
|
69
63
|
handle_request(request)
|
70
64
|
end
|
71
65
|
|
72
66
|
def put(resource_name, resource_id, attrs = {})
|
73
|
-
resource_exists?(resource_name)
|
74
67
|
raise API::Errors::RequestError.new("id was not provided") if resource_id.nil?
|
75
|
-
request = self.class.put("#{rtx_api_url}/#{resource_name}/#{resource_id}", options(:put, attrs))
|
68
|
+
request = self.class.put("#{rtx_api_url}/#{resource_path(resource_name)}/#{resource_id}", options(:put, attrs))
|
76
69
|
handle_request(request)
|
77
70
|
end
|
78
71
|
|
79
72
|
def patch(resource_name, resource_id, attrs = {})
|
80
|
-
resource_exists?(resource_name)
|
81
73
|
raise API::Errors::RequestError.new("id was not provided") if resource_id.nil?
|
82
|
-
request = self.class.patch("#{rtx_api_url}/#{resource_name}/#{resource_id}", options(:patch, attrs))
|
74
|
+
request = self.class.patch("#{rtx_api_url}/#{resource_path(resource_name)}/#{resource_id}", options(:patch, attrs))
|
83
75
|
handle_request(request)
|
84
76
|
end
|
85
77
|
|
86
78
|
def delete(resource_name, resource_id)
|
87
|
-
resource_exists?(resource_name)
|
88
79
|
raise API::Errors::RequestError.new("id was not provided") if resource_id.nil?
|
89
|
-
request = self.class.delete("#{rtx_api_url}/#{resource_name}/#{resource_id}", options(:delete))
|
80
|
+
request = self.class.delete("#{rtx_api_url}/#{resource_path(resource_name)}/#{resource_id}", options(:delete))
|
90
81
|
handle_request(request)
|
91
82
|
end
|
92
83
|
|
@@ -102,13 +93,12 @@ module RTX
|
|
102
93
|
Oj.load(request.body, symbol_keys: true)
|
103
94
|
end
|
104
95
|
|
105
|
-
def
|
106
|
-
|
107
|
-
if !
|
96
|
+
def resource_path(resource_name)
|
97
|
+
path = API::Resources.allowed_resources[resource_name.to_sym]
|
98
|
+
if !path
|
108
99
|
raise API::Errors::InvalidResourceError.new("The resource provided (#{resource_name}) is not allowed")
|
109
100
|
end
|
110
|
-
|
111
|
-
true
|
101
|
+
path
|
112
102
|
end
|
113
103
|
|
114
104
|
protected
|
data/lib/rtx/api/resources.rb
CHANGED
@@ -2,37 +2,38 @@ module RTX
|
|
2
2
|
module API
|
3
3
|
class Resources
|
4
4
|
def self.allowed_resources
|
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
|
-
|
5
|
+
{
|
6
|
+
accounts: 'accounts',
|
7
|
+
alerts: 'alerts',
|
8
|
+
alert_frequencies: 'alert_frequencies',
|
9
|
+
alert_types: 'alert_types',
|
10
|
+
campaigns: 'campaigns',
|
11
|
+
contacts: 'contacts',
|
12
|
+
countries: 'countries',
|
13
|
+
crawlers: 'crawlers',
|
14
|
+
groups: 'groups',
|
15
|
+
keywords: 'insights/keywords',
|
16
|
+
items: 'items',
|
17
|
+
layouts: 'layouts',
|
18
|
+
locations: 'locations',
|
19
|
+
notes: 'notes',
|
20
|
+
permissions: 'permissions',
|
21
|
+
profiles: 'profiles',
|
22
|
+
requests: 'requests',
|
23
|
+
request_pages: 'request_pages',
|
24
|
+
request_types: 'request_types',
|
25
|
+
reviews: 'reviews',
|
26
|
+
review_status_labels: 'review_status_labels',
|
27
|
+
single_sign_ons: 'single_sign_ons',
|
28
|
+
sources: 'sources',
|
29
|
+
states: 'states',
|
30
|
+
templates: 'templates',
|
31
|
+
template_tags: 'template_tags',
|
32
|
+
urls: 'urls',
|
33
|
+
users: 'users',
|
34
|
+
user_types: 'user_types',
|
35
|
+
whitelabels: 'whitelabels'
|
36
|
+
}.freeze
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
data/lib/rtx/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtx-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ReviewTrackers Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|