fluffy-ruby 0.0.2 → 0.0.3

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: ff7ee179b75b1a98e5e4555b43c5d712885bb148
4
- data.tar.gz: b28e79d8f015d1c4425d7116584bcf9b78d84c72
3
+ metadata.gz: bd1f2cc767052443b946825acf9e028ba98da81d
4
+ data.tar.gz: 96f2024ad746cce397b1dfc6ee7ac24c6956d804
5
5
  SHA512:
6
- metadata.gz: 50d36445fba495fbbc532ce88abdf274b72226c05889a6cab4f745800777866a715b937530118e008b972837f3bc37373ecb934388d5d15eefc12b3b495f5f2e
7
- data.tar.gz: 3e1ffe1d7ad28c6cf2e7dde01b53d88e3ef33d1a4b28225b26ff2f0dac568cd10c03072294d5434c6002cf53fa21ec1108bdd6cb8d514445f1272481f1fc27d8
6
+ metadata.gz: ac7f882c0267749c2d48ea8273b4d340d43227bcc1e6b2cb5b249fa92529b83db9e9e176345a30d069e45653f3d480425a28a42e991267e737b95546304e54c3
7
+ data.tar.gz: dd8212175c7dc2672ec511cc1c089e14956236d6de8003b37b93792dff56177e916777108189e0776ad321dbfe0e9802ed8cbd39a5d631bab3fdf0fc63a8ca0a
data/lib/fluffy/api.rb CHANGED
@@ -49,6 +49,19 @@ module Fluffy
49
49
  data['message']
50
50
  end
51
51
 
52
+ # Perform a HTTP PATCH request
53
+ #
54
+ # @param endpoint [Array[String], String] HTTP API endpoint
55
+ # @param params [Hash] HTTP API body
56
+ # @return [Hash, nil] API JSON response
57
+ #
58
+ def patch(endpoint:, params: {})
59
+ resp = self.http.patch([self.url, endpoint.is_a?(Array) ? endpoint.join('/') : endpoint].join('/'), params.to_json, {'Content-Type' => 'application/json', 'Accept' => 'application/json'})
60
+ data = JSON.parse(resp.body)
61
+ raise APIError.new(data['message'], data['error'], resp.status) if resp.status >= 400
62
+ data['message']
63
+ end
64
+
52
65
  # Perform a HTTP DELETE request
53
66
  #
54
67
  # @param endpoint [Array[String], String] HTTP API endpoint
@@ -1,5 +1,5 @@
1
1
  module Fluffy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluffy-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Cerutti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-18 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json