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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d07f27e94f812c2b5ccbe8b88db45ac143f235f
4
- data.tar.gz: 1870fed081935a8eb94375cb14d5ad6019aa726b
3
+ metadata.gz: 7ddf0a887ad4ab9c10f14dda325f71149306f655
4
+ data.tar.gz: c156a95bc0c17f2beb8508c973350355b4d54d97
5
5
  SHA512:
6
- metadata.gz: 62bf561923b34c05841d5146132e644e721b357e63076bb73e95478b1ac9a447ac67c45686aa8968479f689245f31350cc150858d945bc2e97509ea6f8951a1b
7
- data.tar.gz: 8e8dee210c598a5c2074358c9f55d2ae0ecc3609d8276d72695f0e2a074ca89b6e2ad4fbed2e5618a134a6f60cb8f5376947091e8474626766c614d13487f177
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
@@ -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(params, mode: :compat)
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
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module RTX
2
2
  module API
3
- VERSION = "0.0.8"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtx-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ReviewTrackers Engineering