json_api_toolbox 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a3598f87e949855f9f2bc6fcb64caa44f9e170d
4
- data.tar.gz: 428ca57f018b06a414c5289e6ac5e9c2d299411b
3
+ metadata.gz: 93a2045c2294932efa199ba493e039f17f050ad9
4
+ data.tar.gz: e8ed8912207f37a2620eeb69c19f7da2aec2ed9b
5
5
  SHA512:
6
- metadata.gz: 0d431f1d4f666505381239fa826efdb911bb432ac21ab9853d0534dce4f3436d3f96467dd79b0c51ba0ddc16749681286861e1a40a6709029541c4d82a1db1ff
7
- data.tar.gz: aac705c5d9689f2e58371e1ee9f36769abf72054985a16083ccd79fd6e8045bdbea560b3b27bb1deb7310270e922ed6b1660345bf4dcaefa2438a6ce084617c3
6
+ metadata.gz: 11676fb0e857a27e12fc7e2fb402854d4234cea07238f13a90efd4451630b0a649620e37dcdfccc209716895c1fa17175697188ec1cacc08d31bd3dc1bfa00e7
7
+ data.tar.gz: 72cc4f6c03ee1466481498840311c4775589d1029047ad85c2fe7e5f096e8477796490b6975ea453271ca459daf1189cdc10237a0e11c538da258cd00d982848
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.15.0] - 2018-06-15
10
+ ### Added
11
+ - Added method `.patch` to JsonApiToolbox::Service
12
+
9
13
  ## [0.14.0] - 2018-05-02
10
14
  ### Changed
11
15
  - Removing 'includes' attributes when calling without any 'includes' parameter
data/README.md CHANGED
@@ -36,6 +36,31 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/abacha
36
36
 
37
37
  ## Examples
38
38
 
39
+ #Service
40
+ ```ruby
41
+ class MyService < JsonApiToolbox::Service
42
+ BASE_URL = 'http://localhost:3000/my_model'
43
+
44
+ class << self
45
+ def all(includes: nil, query_string: nil)
46
+ get(url: BASE_URL, includes: includes, query_string: query_string)
47
+ end
48
+
49
+ def find(id, includes: includes)
50
+ get(url: "#{BASE_URL}/#{id}", includes: includes)
51
+ end
52
+
53
+ def create(payload)
54
+ post(url: BASE_URL, body: payload)
55
+ end
56
+
57
+ def update(payload)
58
+ patch(url: "#{BASE_URL}/#{payload.delete(:id)}", body: payload)
59
+ end
60
+ end
61
+ end
62
+ ```
63
+
39
64
  #Renderizable
40
65
 
41
66
  Render common
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonApiToolbox
4
- VERSION = '0.14.0'
4
+ VERSION = '0.15.0'
5
5
  end
data/lib/service.rb CHANGED
@@ -38,7 +38,7 @@ module JsonApiToolbox
38
38
  end
39
39
 
40
40
  def build_body
41
- method == :post ? body : nil
41
+ return body if method != :get
42
42
  end
43
43
 
44
44
  class << self
@@ -51,6 +51,10 @@ module JsonApiToolbox
51
51
  new(:post, url, body).execute
52
52
  end
53
53
 
54
+ def patch(url: nil, body: nil)
55
+ new(:patch, url, body).execute
56
+ end
57
+
54
58
  def parse_response(response)
55
59
  response_parsed = JSON::Api::Vanilla.parse(response.body)
56
60
  response_parsed.data || response_parsed.errors
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Bacha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack