-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade json_api_client gem #158
Changes from 29 commits
f7f4f41
9e70d94
44eaebb
b33d9ca
a88e9b2
7279a3c
cf595a7
1f2245e
ae5dc63
01c92a1
17fa4cb
18ad0ce
eb0f265
b0c130d
93761c9
e7ae593
40525d3
35f0181
22062d0
8561880
606f745
bb9a314
52d7451
e8464b5
98df40d
52b6424
6ea38f9
1997da8
178c115
e0c0715
f426663
138d3e9
462d041
4c52a04
d12a665
bc607da
a891c26
af6d0be
f3c2671
e9ec373
75ee4ea
5e90eb3
a1c93bb
64ee648
88640c4
691358e
493fc40
3fa2b98
e20e9a8
63e9970
62eaea0
e8f2fae
891c75f
eb1894c
ea571c5
a330196
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module FlexCommerceApi | ||
module JsonApiClientExtension | ||
class RemoteBuilder < ::JsonApiClient::Query::Builder | ||
def initialize(klass, path: klass.path, connection: klass.connection) | ||
super(klass) | ||
self.connection = connection | ||
self.path = path | ||
def initialize(klass, opts = {}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some changes to bring us in line with interface changes within the |
||
super(klass, opts) | ||
self.connection = opts.fetch(:connection, klass.connection) | ||
self.path = opts.fetch(:path, klass.path) | ||
end | ||
|
||
def find(args = {}) | ||
|
@@ -21,7 +21,7 @@ def find(args = {}) | |
private | ||
|
||
def get_request(params) | ||
klass.parser.parse(klass, connection.run(:get, path, params, klass.custom_headers)) | ||
klass.parser.parse(klass, connection.run(:get, path, params: params, headers: klass.custom_headers)) | ||
end | ||
attr_accessor :path, :connection | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,20 @@ class Requestor < ::JsonApiClient::Query::Requestor | |
# expects a record | ||
def create(record) | ||
request(:post, klass.path(record.attributes, record), { | ||
data: record.as_json_api | ||
body: { data: record.as_json_api } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some changes to bring us in line with interface changes within the |
||
}) | ||
end | ||
|
||
def update(record) | ||
request(:patch, resource_path(record.attributes, record), { | ||
data: record.as_json_api | ||
body: { data: record.as_json_api } | ||
}) | ||
end | ||
|
||
def get(params = {}) | ||
path = resource_path(params) | ||
params.delete(klass.primary_key) | ||
request(:get, path, params) | ||
request(:get, path, params: params) | ||
end | ||
|
||
def destroy(record) | ||
|
@@ -39,4 +39,4 @@ def encoded(part) | |
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
require "json_api_client/version" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont we require this patch anymore? |
||
if ["1.1.1"].include?(JsonApiClient::VERSION) | ||
|
||
if ["1.1.1", "1.5.3"].include?(JsonApiClient::VERSION) | ||
require "json_api_client/resource" | ||
module JsonApiClient | ||
class Resource | ||
|
@@ -13,20 +14,13 @@ def save | |
end | ||
|
||
if last_result_set.has_errors? | ||
last_result_set.errors.each do |error| | ||
if error.source_parameter | ||
errors.add(error.source_parameter, error.title || error.detail) | ||
else | ||
errors.add(:base, error.title || error.detail) | ||
end | ||
end | ||
fill_errors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our patch needed updating to use the |
||
false | ||
else | ||
self.errors.clear if self.errors | ||
mark_as_persisted! | ||
if updated = last_result_set.first | ||
self.attributes = updated.attributes | ||
# This line has been added as part of https://github.com/chingor13/json_api_client/pull/238 | ||
self.links.attributes = updated.links.attributes | ||
self.relationships.attributes = updated.relationships.attributes | ||
clear_changes_information | ||
|
@@ -39,9 +33,8 @@ def save | |
end | ||
end | ||
else | ||
raise %q( | ||
Please check these two PRs: | ||
* https://github.com/chingor13/json_api_client/pull/238 (This was released in version 1.5.0) | ||
puts %q( | ||
Please check this PR: | ||
* https://github.com/JsonApiClient/json_api_client/pull/285 (This hasn't yet been released at the time of writing this) | ||
|
||
If both have been merged into the gem version you are using, remove this file (#{__FILE__}). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including this middleware 1) adds
Accept-Encoding: gzip,deflate
header by default and 2) includes support for Gzip decoding