shotgun_api_ruby 0.0.5.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +25 -3
- data/lib/shotgun_api_ruby/client.rb +1 -1
- data/lib/shotgun_api_ruby/entities.rb +72 -0
- data/lib/shotgun_api_ruby/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331b2df4f527205c4803c47cb3a80373578aa740d56fe79c092930881afb9a01
|
4
|
+
data.tar.gz: '09a83792f0f2b93d3b877cb10501d27c0049ef23c928e34ec65b90b9db956900'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f47383023c6a67909c1eb1a54c8acc55880ba978bd20292633fb77362fdfd2e216d5b70869e1da88f1286a8640cec180fa12ef8b7d67351d8815b6b86d3d0e2e
|
7
|
+
data.tar.gz: db5f9915dd9d40558d627efc6ed1860d254ef0f324e40a30aaa4f2e1cf8d78ea10baab866572a82444e40f4b12c3d18da537474fecd7e1a3c839ce0faa4900e9
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -308,15 +308,37 @@ client.assets.find(724, fields: [:code, 'description'], retired: false)
|
|
308
308
|
|
309
309
|
#### Create
|
310
310
|
|
311
|
-
|
311
|
+
Will create the entity referenced by the id with the following fields.
|
312
|
+
If successful, it will return the newly created entity.
|
313
|
+
|
314
|
+
```ruby
|
315
|
+
client.assets.create(code: 'New Asset', project: {type: 'Project', id: 63})
|
316
|
+
```
|
312
317
|
|
313
318
|
#### Update
|
314
319
|
|
315
|
-
|
320
|
+
Will update the entity referenced by the id with the following fields.
|
321
|
+
If successful, it will return the modified entity.
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
client.assets.update(1226, code: 'Updated Asset', sg_status_list: 'fin')
|
325
|
+
```
|
316
326
|
|
317
327
|
#### Delete
|
318
328
|
|
319
|
-
|
329
|
+
Will destroys the entity referenced by the id. Will return true if successful.
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
client.assets.delete(1226)
|
333
|
+
```
|
334
|
+
|
335
|
+
#### Revive
|
336
|
+
|
337
|
+
Will try to revive the entity referenced by the id. Will return true if successful.
|
338
|
+
|
339
|
+
```ruby
|
340
|
+
client.assets.revive(1226)
|
341
|
+
```
|
320
342
|
|
321
343
|
### Non implemented calls
|
322
344
|
|
@@ -52,6 +52,78 @@ module ShotgunApiRuby
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
def create(**attributes)
|
56
|
+
resp =
|
57
|
+
@connection.post('', attributes.to_json) do |req|
|
58
|
+
req.headers['Content-Type'] = 'application/json'
|
59
|
+
end
|
60
|
+
|
61
|
+
resp_body = JSON.parse(resp.body)
|
62
|
+
|
63
|
+
if resp.status >= 300
|
64
|
+
raise "Error while creating #{type}# with #{attributes}: #{resp_body['errors']}"
|
65
|
+
end
|
66
|
+
|
67
|
+
entity = resp_body["data"]
|
68
|
+
Entity.new(
|
69
|
+
entity['type'],
|
70
|
+
OpenStruct.new(entity['attributes']),
|
71
|
+
entity['relationships'],
|
72
|
+
entity['id'],
|
73
|
+
entity['links']
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def update(id, **changes)
|
78
|
+
return find(id) if changes.empty?
|
79
|
+
|
80
|
+
resp =
|
81
|
+
@connection.put(id.to_s, changes.to_json) do |req|
|
82
|
+
req.headers['Content-Type'] = 'application/json'
|
83
|
+
end
|
84
|
+
|
85
|
+
resp_body = JSON.parse(resp.body)
|
86
|
+
|
87
|
+
if resp.status >= 300
|
88
|
+
raise "Error while updating #{type}##{id} with #{changes}: #{resp_body['errors']}"
|
89
|
+
end
|
90
|
+
|
91
|
+
entity = resp_body["data"]
|
92
|
+
Entity.new(
|
93
|
+
entity['type'],
|
94
|
+
OpenStruct.new(entity['attributes']),
|
95
|
+
entity['relationships'],
|
96
|
+
entity['id'],
|
97
|
+
entity['links']
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
def delete(id)
|
102
|
+
resp =
|
103
|
+
@connection.delete(id.to_s) do |req|
|
104
|
+
req.headers['Content-Type'] = 'application/json'
|
105
|
+
end
|
106
|
+
|
107
|
+
if resp.status >= 300
|
108
|
+
resp_body = JSON.parse(resp.body)
|
109
|
+
raise "Error while deleting #{type}##{id}: #{resp_body['errors']}"
|
110
|
+
end
|
111
|
+
|
112
|
+
true
|
113
|
+
end
|
114
|
+
|
115
|
+
def revive(id)
|
116
|
+
resp =
|
117
|
+
@connection.post("#{id}?revive=true")
|
118
|
+
|
119
|
+
if resp.status >= 300
|
120
|
+
resp_body = JSON.parse(resp.body)
|
121
|
+
raise "Error while reviving #{type}##{id}: #{resp_body['errors']}"
|
122
|
+
end
|
123
|
+
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
55
127
|
def all(
|
56
128
|
fields: nil,
|
57
129
|
logical_operator: 'and',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shotgun_api_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis <Zaratan> Pasin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -211,6 +211,7 @@ files:
|
|
211
211
|
- ".ruby-version"
|
212
212
|
- ".travis.yml"
|
213
213
|
- Gemfile
|
214
|
+
- Gemfile.lock
|
214
215
|
- LICENSE.txt
|
215
216
|
- README.md
|
216
217
|
- Rakefile
|
@@ -247,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
248
|
- !ruby/object:Gem::Version
|
248
249
|
version: '0'
|
249
250
|
requirements: []
|
250
|
-
rubygems_version: 3.1.
|
251
|
+
rubygems_version: 3.1.4
|
251
252
|
signing_key:
|
252
253
|
specification_version: 4
|
253
254
|
summary: Gem to interact easily with Shotgun REST api.
|