simple_jsonapi_client 0.1.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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +264 -0
- data/Rakefile +8 -0
- data/bin/console +3 -0
- data/bin/development_start +12 -0
- data/bin/rails +3 -0
- data/bin/setup +7 -0
- data/bin/wait_for_it +178 -0
- data/docker-compose.yml +50 -0
- data/lib/simple_jsonapi_client.rb +5 -0
- data/lib/simple_jsonapi_client/base.rb +325 -0
- data/lib/simple_jsonapi_client/error.rb +6 -0
- data/lib/simple_jsonapi_client/errors/api_error.rb +84 -0
- data/lib/simple_jsonapi_client/redirection/fetch_all.rb +43 -0
- data/lib/simple_jsonapi_client/redirection/proxy.rb +54 -0
- data/lib/simple_jsonapi_client/relationships/array_data_relationship.rb +19 -0
- data/lib/simple_jsonapi_client/relationships/array_link_relationship.rb +15 -0
- data/lib/simple_jsonapi_client/relationships/data_relationship_proxy.rb +30 -0
- data/lib/simple_jsonapi_client/relationships/has_many_relationship.rb +16 -0
- data/lib/simple_jsonapi_client/relationships/has_one_relationship.rb +16 -0
- data/lib/simple_jsonapi_client/relationships/link_relationship_proxy.rb +19 -0
- data/lib/simple_jsonapi_client/relationships/relationship.rb +34 -0
- data/lib/simple_jsonapi_client/relationships/singular_data_relationship.rb +17 -0
- data/lib/simple_jsonapi_client/relationships/singular_link_relationship.rb +13 -0
- data/lib/simple_jsonapi_client/version.rb +3 -0
- data/simple_jsonapi_client.gemspec +31 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48b579116cf787a39e4a97030ad4961063c4db940ec2fbdee03353ae162d2b6b
|
4
|
+
data.tar.gz: 26ae2466b469d541e2ce3105db766fbcb4dc72c80d6ba49a284a2b8a432e2341
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82279b13b63ae34daec3f2e72118108bf345d847a790e064aca6471b42bbb303d899d29cbafc76930c2738418835a69d4c918a119474d53b00ce06159b43c108
|
7
|
+
data.tar.gz: 1725ec376ef0e45f8e3a7bc59b59e473a516b047db2d061c5a469330e382eb18996464db771698c59a8cacd7ac21656f6252f1b753f0f5509b1312a8835a8f3c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at arielmcaplan@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
FROM ruby:2.3.1
|
2
|
+
RUN apt-get update -qq
|
3
|
+
RUN gem update bundler
|
4
|
+
RUN mkdir /simple_jsonapi_client
|
5
|
+
WORKDIR /simple_jsonapi_client
|
6
|
+
ADD Gemfile /simple_jsonapi_client/Gemfile
|
7
|
+
ADD simple_jsonapi_client.gemspec /simple_jsonapi_client/simple_jsonapi_client.gemspec
|
8
|
+
ADD . /simple_jsonapi_client
|
9
|
+
RUN bundle install
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ariel Caplan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
[](https://travis-ci.org/amcaplan/simple_jsonapi_client)
|
2
|
+
|
3
|
+
# What is `SimpleJSONAPIClient`?
|
4
|
+
|
5
|
+
`SimpleJSONAPIClient` is a framework for building Ruby clients for JSONAPI-compliant services.
|
6
|
+
|
7
|
+
# How do I use `SimpleJSONAPIClient`?
|
8
|
+
|
9
|
+
## Setup
|
10
|
+
|
11
|
+
First create models inheriting from `SimpleJSONAPIClient::Base`, and specifying a few details.
|
12
|
+
|
13
|
+
* `COLLECTION_URL` - the path to fetch the resource collection
|
14
|
+
* `INDIVIDUAL_URL` - the path to fetch an individual resource
|
15
|
+
* `TYPE` - the JSONAPI resource type to use when creating a new resource
|
16
|
+
* `attributes` - the names of attributes which can be found on the resource
|
17
|
+
* relationships - `has_one` and `has_many` define relationships, and take these arguments:
|
18
|
+
* relationship name (e.g., the `:goats` in `has_many :goats`)
|
19
|
+
* `class_name` to use when instantiating related objects
|
20
|
+
|
21
|
+
They should look like this:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class Post < SimpleJSONAPIClient::Base
|
25
|
+
COLLECTION_URL = '/posts'
|
26
|
+
INDIVIDUAL_URL = '/posts/%{id}'
|
27
|
+
TYPE = 'posts'
|
28
|
+
|
29
|
+
attributes :title, :text
|
30
|
+
meta :copyright
|
31
|
+
|
32
|
+
has_one :author, class_name: 'Author'
|
33
|
+
has_many :comments, class_name: 'Comment'
|
34
|
+
end
|
35
|
+
|
36
|
+
class Author < SimpleJSONAPIClient::Base
|
37
|
+
COLLECTION_URL = '/authors'
|
38
|
+
INDIVIDUAL_URL = '/authors/%{id}'
|
39
|
+
TYPE = 'authors'
|
40
|
+
|
41
|
+
attributes :name
|
42
|
+
|
43
|
+
has_many :posts, class_name: 'Post'
|
44
|
+
has_many :comments, class_name: 'Comment'
|
45
|
+
end
|
46
|
+
|
47
|
+
class Comment < SimpleJSONAPIClient::Base
|
48
|
+
COLLECTION_URL = '/comments'
|
49
|
+
INDIVIDUAL_URL = '/comments/%{id}'
|
50
|
+
TYPE = 'comments'
|
51
|
+
|
52
|
+
attributes :text
|
53
|
+
|
54
|
+
has_one :post, class_name: 'Post'
|
55
|
+
has_one :author, class_name: 'Author'
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
If you have behavior you'd like to share across models, you may want to first create an abstract class inheriting from `SimpleJSONAPIClient::Base` and then have all your models inherit from that.
|
60
|
+
|
61
|
+
Next, create a [`Faraday`](https://github.com/lostisland/faraday) connection to handle the domain, authorization strategy, and anything else you need (making sure to include [JSON parsing middleware](https://github.com/lostisland/faraday_middleware/wiki/Parsing-responses)):
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
def connection(token)
|
65
|
+
default_headers = {
|
66
|
+
'Accept' => 'application/vnd.api+json',
|
67
|
+
'Content-Type' => 'application/vnd.api+json',
|
68
|
+
'Authorization' => "token=#{token}"
|
69
|
+
}
|
70
|
+
|
71
|
+
@connection ||= Faraday.new(url: 'https://example.com', headers: default_headers) do |connection|
|
72
|
+
connection.request :json
|
73
|
+
connection.response :json, :content_type => /\bjson$/ # use middleware to parse JSON when response Content-Type is json
|
74
|
+
connection.adapter :net_http
|
75
|
+
end
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
Now you can start making requests!
|
80
|
+
|
81
|
+
## Fetching
|
82
|
+
|
83
|
+
### Laziness and `SimpleJSONAPIClient`
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
Post.fetch_all(connection: connection)
|
87
|
+
=> #<Enumerator: #<Enumerator::Generator:0x00562894acd420>:each>
|
88
|
+
```
|
89
|
+
|
90
|
+
What's going on? `SimpleJSONAPIClient` tries to be as lazy as possible while still being convenient. So if you actually want to fetch everything, you'll be able to call `Array` methods and it will fetch the resource, paginating through all the results. If it's an endpoint with thousands of pages, you can use `Enumerator` methods like `#each` and it'll paginate through the results, fetching the next page when it runs out of objects.
|
91
|
+
|
92
|
+
Let's call `#to_a` to see a bit more detail.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
posts = Post.fetch_all(connection: connection).to_a
|
96
|
+
=> [#<Post id=1 title="A Very Proper Post Title" text="I am absolutely incensed about something." author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>,
|
97
|
+
#<Post id=2 title="The System is Down" text="The Cheat" author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/2/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/2/comments>>]
|
98
|
+
```
|
99
|
+
|
100
|
+
Attributes are loaded immediately, but relationships are lazily instantiated. So if we dig a little bit further:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
posts.first.author
|
104
|
+
=> #<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author>
|
105
|
+
```
|
106
|
+
|
107
|
+
Nope, still lazy! However, once we start fetching details about the author, `SimpleJSONAPIClient` knows a request has to be made, and fills in the details:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
posts.first.author.id
|
111
|
+
=> "3"
|
112
|
+
|
113
|
+
posts.first.author
|
114
|
+
=> #<Author id=3 name="Filbert" posts=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Post url=http://jsonapi_app:3000/authors/3/posts> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/authors/3/comments>>
|
115
|
+
```
|
116
|
+
|
117
|
+
We can read more easily by calling `#as_json`:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
posts.first.author.as_json
|
121
|
+
=> {
|
122
|
+
:data => {
|
123
|
+
:type => "authors",
|
124
|
+
:attributes => { :name => "Filbert" },
|
125
|
+
:relationships => {
|
126
|
+
:posts => {
|
127
|
+
:data => [{ :type => "posts", :id => "1" }]
|
128
|
+
},
|
129
|
+
:comments => { :data => [] }
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
133
|
+
```
|
134
|
+
|
135
|
+
### More About Fetching Capabilities
|
136
|
+
|
137
|
+
You can also explicitly fetch a single item:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
post = Post.fetch(connection: connection, url_opts: { id: 1 })
|
141
|
+
=> #<Post id=1 title="A Very Proper Post Title" text="I am absolutely incensed about something." author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>
|
142
|
+
```
|
143
|
+
|
144
|
+
`url_opts`, in all cases where you see them, are passed to the template Strings for `INDIVIDUAL_URL` and `COLLECTION_URL` in the model.
|
145
|
+
|
146
|
+
You've already seen that `id` and `relationships` are available; `attributes` and `meta` information also become methods on the object:
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
post = Post.fetch(connection: connection, url_opts: { id: 1 })
|
150
|
+
post.title
|
151
|
+
=> "A Very Proper Post Title"
|
152
|
+
post.text
|
153
|
+
=> "I am absolutely incensed about something."
|
154
|
+
post.copyright
|
155
|
+
=> "Copyright 2017"
|
156
|
+
```
|
157
|
+
|
158
|
+
You can also use JSONAPI includes to reduce the number of requests that are necessary:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
post = JSONAPIAppClient::Post.fetch(connection: connection, url_opts: { id: 1 }, includes: ['author', 'comments.author'])
|
162
|
+
post.author # will not make another web request
|
163
|
+
post.comments.first.author # will not make another web request
|
164
|
+
```
|
165
|
+
|
166
|
+
`SimpleJSONAPIClient` will check the included records for related records you access through the returned model.
|
167
|
+
|
168
|
+
And finally, you can use JSONAPI-style filtering as well:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
JSONAPIAppClient::Author.fetch_all(connection: connection, filter_opts: { name: 'Filbert' }).to_a
|
172
|
+
=> [#<JSONAPIAppClient::Author id=1 name="Filbert" posts=#<SimpleJSONAPIClient::Relationships::ArrayLinkRelationship model_class=JSONAPIAppClient::Post url=http://jsonapi_app_console:3002/authors/1/posts> comments=#<SimpleJSONAPIClient::Relationships::ArrayLinkRelationship model_class=JSONAPIAppClient::Comment url=http://jsonapi_app_console:3002/authors/1/comments>>]
|
173
|
+
```
|
174
|
+
|
175
|
+
## Creating
|
176
|
+
|
177
|
+
Creating records is available from the model class:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
post = Post.fetch(url_opts: { id: 1 }, connection: connection)
|
181
|
+
=> #<Post id=1 title="A Very Proper Post Title" text="I am absolutely incensed about something." author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>
|
182
|
+
author = Author.fetch(url_opts: { id: 1}, connection: connection)
|
183
|
+
=> #<Author id=1 name="Filbert" posts=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Post url=http://jsonapi_app:3000/authors/1/posts> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/authors/1/comments>>
|
184
|
+
|
185
|
+
Comment.create(connection: connection, text: 'I adore your article!', post: post, author: author)
|
186
|
+
=> #<Comment id=19 text="I adore your article!" post=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Client::Post url=http://jsonapi_app:3000/comments/19/post> author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/comments/19/author>>
|
187
|
+
```
|
188
|
+
|
189
|
+
The created record is returned; if creation fails, a `SimpleJSONAPIClient::Errors::ApiError` is raised.
|
190
|
+
|
191
|
+
## Updating
|
192
|
+
|
193
|
+
If you want to update a record, you can do it from the model itself:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
post = Post.fetch(url_opts: { id: 1 }, connection: connection)
|
197
|
+
=> #<Post id=1 title="A Very Proper Post Title" text="I am absolutely incensed about something." author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>
|
198
|
+
[2] pry(main)> post.update(attributes: { text: 'foo' })
|
199
|
+
=> #<Post id=1 title="A Very Proper Post Title" text="foo" author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>
|
200
|
+
```
|
201
|
+
|
202
|
+
If you have the ID of the record handy, you update straight from the model class without fetching the record first:
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
Post.update(id: 1, url_opts: { id: 1 }, connection: connection, text: 'foo')
|
206
|
+
=> #<Post id=1 title="A Very Proper Post Title" text="foo" author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>
|
207
|
+
```
|
208
|
+
|
209
|
+
## Deleting
|
210
|
+
|
211
|
+
You can delete a record from the model itself:
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
post = Post.fetch(url_opts: { id: 1 }, connection: connection)
|
215
|
+
=> #<Post id=1 title="A Very Proper Post Title" text="I am absolutely incensed about something." author=#<SimpleJSONAPIClient::Base::SingularLinkRelationship model_class=Author url=http://jsonapi_app:3000/posts/1/author> comments=#<SimpleJSONAPIClient::Base::ArrayLinkRelationship model_class=Comment url=http://jsonapi_app:3000/posts/1/comments>>
|
216
|
+
|
217
|
+
post.delete
|
218
|
+
=> true
|
219
|
+
Post.fetch(url_opts: { id: 1 }, connection: connection)
|
220
|
+
=> nil
|
221
|
+
```
|
222
|
+
|
223
|
+
or from the class, if you have the ID:
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
Post.delete(url_opts: { id: 1 }, connection: connection)
|
227
|
+
=> true
|
228
|
+
Post.fetch(url_opts: { id: 1 }, connection: connection)
|
229
|
+
=> nil
|
230
|
+
```
|
231
|
+
|
232
|
+
## Installation
|
233
|
+
|
234
|
+
Add this line to your application's Gemfile:
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
gem 'simple_jsonapi_client'
|
238
|
+
```
|
239
|
+
|
240
|
+
And then execute:
|
241
|
+
|
242
|
+
$ bundle
|
243
|
+
|
244
|
+
Or install it yourself as:
|
245
|
+
|
246
|
+
$ gem install simple_jsonapi_client
|
247
|
+
|
248
|
+
## Development
|
249
|
+
|
250
|
+
You must have [Docker](https://docker.com) and [Docker Compose](https://docs.docker.com/compose/) installed to run the tests and use the built-in development utilities.
|
251
|
+
|
252
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment, and `bin/rails` to interact with the Rails app in `spec/jsonapi_app` that is provided for local development and testing.
|
253
|
+
|
254
|
+
## Contributing
|
255
|
+
|
256
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/amcaplan/simple_jsonapi_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
257
|
+
|
258
|
+
## License
|
259
|
+
|
260
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
261
|
+
|
262
|
+
## Code of Conduct
|
263
|
+
|
264
|
+
Everyone interacting in the SimpleJsonapiClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/amcaplan/simple_jsonapi_client/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "simple_jsonapi_client"
|
5
|
+
require "./spec/jsonapi_app_client"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
require "pry"
|
12
|
+
Pry.start
|