rtx-api 0.0.8 → 0.1.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 -2
- data/lib/rtx/api/client.rb +9 -2
- data/lib/rtx/api/collection.rb +11 -0
- data/lib/rtx/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ddf0a887ad4ab9c10f14dda325f71149306f655
|
4
|
+
data.tar.gz: c156a95bc0c17f2beb8508c973350355b4d54d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8f74bf14caf3dbd7f9d35702877b4f2aeff4b24a05b28fc17d5894a41975dac552f0310dd418a5c2cd8e08d4181346ce14ce94093fa3b35677a7375a8ff775b
|
7
|
+
data.tar.gz: 8373ea691bcd64d4f4f164a9bb17fb36cf1a1c618e87c373234c196c9e8bbdfc12fba8ec8a89908d96abcefb064c7a9ee67b4b887e7f8e59be4bdfb889f0594f
|
data/README.md
CHANGED
@@ -209,13 +209,20 @@ note = client.notes.create!(review_id: "56f2ad01565d61bb2a606329", location_id:
|
|
209
209
|
|
210
210
|
### Updating a Resource
|
211
211
|
|
212
|
-
The `update!` method will perform the update and return the new object
|
212
|
+
The `update!` method will perform the update via PUT and return the new object
|
213
213
|
|
214
214
|
```ruby
|
215
|
-
# Update a review
|
215
|
+
# Update a review via PUT
|
216
216
|
review = client.reviews.update!(id: "56f2ad01565d61bb2a606329", summary: "Updated Summary Text")
|
217
217
|
```
|
218
218
|
|
219
|
+
The `patch!` method will perform the update via PATCH and return the new object
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
# Update a review via PATCH
|
223
|
+
review = client.reviews.patch!(id: "56f2ad01565d61bb2a606329", summary: "Updated Summary Text")
|
224
|
+
```
|
225
|
+
|
219
226
|
### Deleting a Resource
|
220
227
|
|
221
228
|
The `delete!` method will perform the update and return true on success
|
data/lib/rtx/api/client.rb
CHANGED
@@ -69,6 +69,13 @@ module RTX
|
|
69
69
|
handle_request(request)
|
70
70
|
end
|
71
71
|
|
72
|
+
def patch(resource_name, resource_id, attrs = {})
|
73
|
+
resource_exists?(resource_name)
|
74
|
+
raise API::Errors::RequestError.new("id was not provided") if resource_id.nil?
|
75
|
+
request = self.class.patch("#{rtx_api_url}/#{resource_name}/#{resource_id}", options(:patch, attrs))
|
76
|
+
handle_request(request)
|
77
|
+
end
|
78
|
+
|
72
79
|
def delete(resource_name, resource_id)
|
73
80
|
resource_exists?(resource_name)
|
74
81
|
raise API::Errors::RequestError.new("id was not provided") if resource_id.nil?
|
@@ -113,7 +120,7 @@ module RTX
|
|
113
120
|
params = default_params.merge(attrs)
|
114
121
|
options = {headers: default_headers, basic_auth: {username: email, password: token}}
|
115
122
|
if write_request?(action)
|
116
|
-
options[:body] = Oj.dump(
|
123
|
+
options[:body] = Oj.dump(attrs, mode: :compat)
|
117
124
|
else
|
118
125
|
options[:query] = params
|
119
126
|
end
|
@@ -125,7 +132,7 @@ module RTX
|
|
125
132
|
end
|
126
133
|
|
127
134
|
def write_request?(action)
|
128
|
-
(action == :post || action == :put)
|
135
|
+
(action == :post || action == :put || action == :patch)
|
129
136
|
end
|
130
137
|
end
|
131
138
|
end
|
data/lib/rtx/api/collection.rb
CHANGED
@@ -22,6 +22,12 @@ module RTX
|
|
22
22
|
put(symbolize_hash(attrs))
|
23
23
|
end
|
24
24
|
|
25
|
+
# Updates a resource via PATCH and returns it on success
|
26
|
+
def patch!(attrs = {})
|
27
|
+
client.authenticate if !client.authenticated?
|
28
|
+
patch(symbolize_hash(attrs))
|
29
|
+
end
|
30
|
+
|
25
31
|
# Deletes a resource via DELETE and returns true on success
|
26
32
|
def delete!(attrs = {})
|
27
33
|
client.authenticate if !client.authenticated?
|
@@ -137,6 +143,11 @@ module RTX
|
|
137
143
|
client.put(resource_name, resource_id, attrs)
|
138
144
|
end
|
139
145
|
|
146
|
+
def patch(attrs = {})
|
147
|
+
resource_id = attrs[:id]
|
148
|
+
client.patch(resource_name, resource_id, attrs)
|
149
|
+
end
|
150
|
+
|
140
151
|
def delete(attrs = {})
|
141
152
|
resource_id = attrs[:id]
|
142
153
|
client.delete(resource_name, resource_id)
|
data/lib/rtx/api/version.rb
CHANGED