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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cab4b7bb6b46bc730be51e3d0f690685751b30ed901aa66fd4ede97e2b4526e0
4
- data.tar.gz: ead76e9dca731cb80ab15302195d23ccdfafdc26c61003a26080aa7a2d7ed8e7
3
+ metadata.gz: 331b2df4f527205c4803c47cb3a80373578aa740d56fe79c092930881afb9a01
4
+ data.tar.gz: '09a83792f0f2b93d3b877cb10501d27c0049ef23c928e34ec65b90b9db956900'
5
5
  SHA512:
6
- metadata.gz: 3aa5b7b697fc482c5a461fc0f851880c0b784d69be3cc515b5d14d0f785c501f7bae26d63a44423e0f14e57314b88c08b711fdfd693146ef36757fd1ed7e5c1d
7
- data.tar.gz: 35704ade665195515fb32d906c2091b3fd4a8cecbb6e4a79f04e1b7831205469659a2d69edac25a6a83f626adef357cb1e3a647f824056f85869de88f718cbaa
6
+ metadata.gz: f47383023c6a67909c1eb1a54c8acc55880ba978bd20292633fb77362fdfd2e216d5b70869e1da88f1286a8640cec180fa12ef8b7d67351d8815b6b86d3d0e2e
7
+ data.tar.gz: db5f9915dd9d40558d627efc6ed1860d254ef0f324e40a30aaa4f2e1cf8d78ea10baab866572a82444e40f4b12c3d18da537474fecd7e1a3c839ce0faa4900e9
@@ -14,6 +14,9 @@ AllCops:
14
14
  Style/GlobalVars:
15
15
  Enabled: false
16
16
 
17
+ Gemspec/RequiredRubyVersion:
18
+ Enabled: false
19
+
17
20
  Layout/DotPosition:
18
21
  Enabled: true
19
22
  EnforcedStyle: trailing
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
- Not implemented yet
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
- Not implemented yet
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
- Not implemented yet
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
 
@@ -28,7 +28,7 @@ module ShotgunApiRuby
28
28
  public_send(type)
29
29
  end
30
30
 
31
- def respond_to_missing?(_name, _include_private = false) # rubocop:disable Lint/MissingSuper
31
+ def respond_to_missing?(_name, _include_private = false)
32
32
  true
33
33
  end
34
34
 
@@ -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',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShotgunApiRuby
4
- VERSION = "0.0.5.3"
4
+ VERSION = "0.0.7"
5
5
  end
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.5.3
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-10-06 00:00:00.000000000 Z
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.2
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.