rtx-api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/rtx/api/client.rb +8 -1
- data/lib/rtx/api/collection.rb +15 -4
- 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: a7517784db2586173fe6d8f89d9a715834b413e3
|
4
|
+
data.tar.gz: a69406c3015e7354ffb81391297065785087f9b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a241999b9dc5c24f904b1c80dbbeda32165cedae82c7ca8956c6b6e335dcf25767bb0c2fe93220506ca6ebb8859cde71ecc274900dc30c66d1f46f64a41e48
|
7
|
+
data.tar.gz: 289ba8e9120b8d91878747f699c0005170b5958408f38b2f0b4247583a461275c9ded6b8e1cb654c5b309d618af9be07ac50b9a518427d14f56bea4c5eb5128e
|
data/README.md
CHANGED
@@ -207,6 +207,15 @@ The `create!` method will perform the create and return the new object
|
|
207
207
|
note = client.notes.create!(review_id: "56f2ad01565d61bb2a606329", location_id: "566c91337536e826ec8ebfa0", content: "This is my note!")
|
208
208
|
```
|
209
209
|
|
210
|
+
### Resource Detail
|
211
|
+
|
212
|
+
The `detail!` method will perform a GET request that returns an object instead of an array
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
# Get a note
|
216
|
+
note = client.notes.detail!(id: "56f2ad01565d61bb2a606329", account_id: "566c91337536e826ec8ebfa0")
|
217
|
+
```
|
218
|
+
|
210
219
|
### Updating a Resource
|
211
220
|
|
212
221
|
The `update!` method will perform the update via PUT and return the new object
|
data/lib/rtx/api/client.rb
CHANGED
@@ -50,12 +50,19 @@ module RTX
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def collection(resource_name, attrs = {})
|
54
54
|
resource_exists?(resource_name)
|
55
55
|
request = self.class.get("#{rtx_api_url}/#{resource_name}", options(:get, attrs))
|
56
56
|
handle_request(request)
|
57
57
|
end
|
58
58
|
|
59
|
+
def detail(resource_name, resource_id, attrs = {})
|
60
|
+
resource_exists?(resource_name)
|
61
|
+
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))
|
63
|
+
handle_request(request)
|
64
|
+
end
|
65
|
+
|
59
66
|
def post(resource_name, attrs = {})
|
60
67
|
resource_exists?(resource_name)
|
61
68
|
request = self.class.post("#{rtx_api_url}/#{resource_name}", options(:post, attrs))
|
data/lib/rtx/api/collection.rb
CHANGED
@@ -16,6 +16,12 @@ module RTX
|
|
16
16
|
post(symbolize_hash(attrs))
|
17
17
|
end
|
18
18
|
|
19
|
+
# Gets an individual resource returns an object instead of an array
|
20
|
+
def detail!(attrs = {})
|
21
|
+
client.authenticate if !client.authenticated?
|
22
|
+
detail(symbolize_hash(attrs))
|
23
|
+
end
|
24
|
+
|
19
25
|
# Updates a resource via PUT and returns it on success
|
20
26
|
def update!(attrs = {})
|
21
27
|
client.authenticate if !client.authenticated?
|
@@ -51,14 +57,14 @@ module RTX
|
|
51
57
|
# Returns all data associated with the existing response
|
52
58
|
def data
|
53
59
|
client.authenticate if !client.authenticated?
|
54
|
-
|
60
|
+
collection if !has_response?
|
55
61
|
response[:_embedded][resource_name]
|
56
62
|
end
|
57
63
|
|
58
64
|
# Returns the metadata about the current response
|
59
65
|
def meta
|
60
66
|
client.authenticate if !client.authenticated?
|
61
|
-
|
67
|
+
collection if !has_response?
|
62
68
|
response.reject {|key,_| key == :_embedded}
|
63
69
|
end
|
64
70
|
|
@@ -130,8 +136,13 @@ module RTX
|
|
130
136
|
options[:page]
|
131
137
|
end
|
132
138
|
|
133
|
-
def
|
134
|
-
@response = client.
|
139
|
+
def collection
|
140
|
+
@response = client.collection(resource_name, options)
|
141
|
+
end
|
142
|
+
|
143
|
+
def detail(attrs = {})
|
144
|
+
resource_id = attrs[:id]
|
145
|
+
client.detail(resource_name, resource_id)
|
135
146
|
end
|
136
147
|
|
137
148
|
def post(attrs = {})
|
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.
|
4
|
+
version: 0.2.0
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|