shotgrid_api_ruby 0.1.3.3 → 0.2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test_and_publish.yml +2 -0
  3. data/.github/workflows/test_only.yml +2 -0
  4. data/.gitignore +3 -0
  5. data/.overcommit.yml +9 -0
  6. data/.rubocop.yml +2 -0
  7. data/CHANGELOG.md +11 -1
  8. data/Gemfile +18 -0
  9. data/Guardfile +2 -2
  10. data/bin/generate_and_add_documentation +1 -0
  11. data/bin/generate_sorbet_coverage +3 -0
  12. data/bin/prettirun +1 -1
  13. data/bin/sorbet_check +1 -0
  14. data/bin/tapioca +29 -0
  15. data/docs/ShotgridApiRuby/Auth/Validator.html +319 -0
  16. data/docs/ShotgridApiRuby/Auth.html +1079 -0
  17. data/docs/ShotgridApiRuby/Client.html +933 -0
  18. data/docs/ShotgridApiRuby/Entities/Params/TooComplexFiltersError.html +124 -0
  19. data/docs/ShotgridApiRuby/Entities/Params.html +1377 -0
  20. data/docs/ShotgridApiRuby/Entities/Schema.html +646 -0
  21. data/docs/ShotgridApiRuby/Entities/Summarize/Summary.html +401 -0
  22. data/docs/ShotgridApiRuby/Entities/Summarize.html +775 -0
  23. data/docs/ShotgridApiRuby/Entities.html +2461 -0
  24. data/docs/ShotgridApiRuby/Entity.html +935 -0
  25. data/docs/ShotgridApiRuby/Preferences.html +417 -0
  26. data/docs/ShotgridApiRuby/ServerInfo.html +415 -0
  27. data/docs/ShotgridApiRuby/ShotgridCallError.html +328 -0
  28. data/docs/ShotgridApiRuby/Types.html +136 -0
  29. data/docs/ShotgridApiRuby.html +307 -0
  30. data/docs/_index.html +253 -0
  31. data/docs/class_list.html +51 -0
  32. data/docs/css/common.css +1 -0
  33. data/docs/css/full_list.css +58 -0
  34. data/docs/css/style.css +497 -0
  35. data/docs/file.README.html +578 -0
  36. data/docs/file_list.html +56 -0
  37. data/docs/frames.html +17 -0
  38. data/docs/index.html +578 -0
  39. data/docs/js/app.js +314 -0
  40. data/docs/js/full_list.js +216 -0
  41. data/docs/js/jquery.js +4 -0
  42. data/docs/method_list.html +643 -0
  43. data/docs/top-level-namespace.html +110 -0
  44. data/lib/shotgrid_api_ruby/auth.rb +89 -33
  45. data/lib/shotgrid_api_ruby/client.rb +50 -7
  46. data/lib/shotgrid_api_ruby/entities/params.rb +304 -65
  47. data/lib/shotgrid_api_ruby/entities/schema.rb +18 -3
  48. data/lib/shotgrid_api_ruby/entities/summarize.rb +39 -7
  49. data/lib/shotgrid_api_ruby/entities.rb +118 -29
  50. data/lib/shotgrid_api_ruby/entity.rb +29 -12
  51. data/lib/shotgrid_api_ruby/preferences.rb +7 -1
  52. data/lib/shotgrid_api_ruby/server_info.rb +7 -1
  53. data/lib/shotgrid_api_ruby/shotgrid_call_error.rb +5 -1
  54. data/lib/shotgrid_api_ruby/types/auth_type.rb +23 -0
  55. data/lib/shotgrid_api_ruby/version.rb +2 -1
  56. data/lib/shotgrid_api_ruby.rb +20 -2
  57. data/shotgrid_api_ruby.gemspec +2 -10
  58. data/sorbet/config +6 -0
  59. data/sorbet/rbi/faraday.rbi +20 -0
  60. data/sorbet/rbi/gems/activesupport@6.1.4.1.rbi +3770 -0
  61. data/sorbet/rbi/gems/ast@2.4.2.rbi +54 -0
  62. data/sorbet/rbi/gems/backport@1.2.0.rbi +8 -0
  63. data/sorbet/rbi/gems/benchmark@0.1.1.rbi +65 -0
  64. data/sorbet/rbi/gems/bundler-audit@0.8.0.rbi +8 -0
  65. data/sorbet/rbi/gems/byebug@11.1.3.rbi +1569 -0
  66. data/sorbet/rbi/gems/childprocess@4.1.0.rbi +8 -0
  67. data/sorbet/rbi/gems/coderay@1.1.3.rbi +1005 -0
  68. data/sorbet/rbi/gems/colorize@0.8.1.rbi +39 -0
  69. data/sorbet/rbi/gems/commander@4.6.0.rbi +8 -0
  70. data/sorbet/rbi/gems/concurrent-ruby@1.1.9.rbi +2403 -0
  71. data/sorbet/rbi/gems/diff-lcs@1.4.4.rbi +8 -0
  72. data/sorbet/rbi/gems/docile@1.4.0.rbi +54 -0
  73. data/sorbet/rbi/gems/dotenv@2.7.6.rbi +88 -0
  74. data/sorbet/rbi/gems/e2mmap@0.1.0.rbi +8 -0
  75. data/sorbet/rbi/gems/faker@2.19.0.rbi +2513 -0
  76. data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +101 -0
  77. data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +78 -0
  78. data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +77 -0
  79. data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +73 -0
  80. data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +82 -0
  81. data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +72 -0
  82. data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +74 -0
  83. data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +73 -0
  84. data/sorbet/rbi/gems/faraday@1.7.0.rbi +783 -0
  85. data/sorbet/rbi/gems/ffi@1.15.3.rbi +8 -0
  86. data/sorbet/rbi/gems/formatador@0.3.0.rbi +8 -0
  87. data/sorbet/rbi/gems/guard-compat@1.2.1.rbi +8 -0
  88. data/sorbet/rbi/gems/guard-rspec@4.7.3.rbi +8 -0
  89. data/sorbet/rbi/gems/guard@2.18.0.rbi +8 -0
  90. data/sorbet/rbi/gems/haml@5.2.2.rbi +8 -0
  91. data/sorbet/rbi/gems/highline@2.0.3.rbi +8 -0
  92. data/sorbet/rbi/gems/i18n@1.8.10.rbi +584 -0
  93. data/sorbet/rbi/gems/iniparse@1.5.0.rbi +8 -0
  94. data/sorbet/rbi/gems/jaro_winkler@1.5.4.rbi +8 -0
  95. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +8 -0
  96. data/sorbet/rbi/gems/kramdown@2.3.1.rbi +8 -0
  97. data/sorbet/rbi/gems/listen@3.7.0.rbi +476 -0
  98. data/sorbet/rbi/gems/lumberjack@1.2.8.rbi +8 -0
  99. data/sorbet/rbi/gems/method_source@1.0.0.rbi +72 -0
  100. data/sorbet/rbi/gems/minitest@5.14.4.rbi +344 -0
  101. data/sorbet/rbi/gems/multipart-post@2.1.1.rbi +69 -0
  102. data/sorbet/rbi/gems/nenv@0.3.0.rbi +8 -0
  103. data/sorbet/rbi/gems/nokogiri@1.12.3.rbi +8 -0
  104. data/sorbet/rbi/gems/notiffany@0.1.3.rbi +8 -0
  105. data/sorbet/rbi/gems/overcommit@0.58.0.rbi +8 -0
  106. data/sorbet/rbi/gems/parallel@1.20.1.rbi +8 -0
  107. data/sorbet/rbi/gems/parlour@6.0.1.rbi +1610 -0
  108. data/sorbet/rbi/gems/parser@3.0.2.0.rbi +1731 -0
  109. data/sorbet/rbi/gems/prettier@1.6.1.rbi +8 -0
  110. data/sorbet/rbi/gems/pry-byebug@3.9.0.rbi +461 -0
  111. data/sorbet/rbi/gems/pry@0.13.1.rbi +2553 -0
  112. data/sorbet/rbi/gems/racc@1.5.2.rbi +47 -0
  113. data/sorbet/rbi/gems/rainbow@3.0.0.rbi +153 -0
  114. data/sorbet/rbi/gems/rake@13.0.6.rbi +807 -0
  115. data/sorbet/rbi/gems/rb-fsevent@0.11.0.rbi +8 -0
  116. data/sorbet/rbi/gems/rb-inotify@0.10.1.rbi +8 -0
  117. data/sorbet/rbi/gems/regexp_parser@2.1.1.rbi +8 -0
  118. data/sorbet/rbi/gems/reverse_markdown@2.0.0.rbi +8 -0
  119. data/sorbet/rbi/gems/rexml@3.2.5.rbi +672 -0
  120. data/sorbet/rbi/gems/rspec-core@3.10.1.rbi +2500 -0
  121. data/sorbet/rbi/gems/rspec-expectations@3.10.1.rbi +1574 -0
  122. data/sorbet/rbi/gems/rspec-mocks@3.10.2.rbi +1462 -0
  123. data/sorbet/rbi/gems/rspec-support@3.10.2.rbi +510 -0
  124. data/sorbet/rbi/gems/rspec@3.10.0.rbi +39 -0
  125. data/sorbet/rbi/gems/rspec_in_context@1.1.0.3.rbi +196 -0
  126. data/sorbet/rbi/gems/rubocop-ast@1.11.0.rbi +8 -0
  127. data/sorbet/rbi/gems/rubocop-faker@1.1.0.rbi +8 -0
  128. data/sorbet/rbi/gems/rubocop-performance@1.11.5.rbi +8 -0
  129. data/sorbet/rbi/gems/rubocop-sorbet@0.6.2.rbi +8 -0
  130. data/sorbet/rbi/gems/rubocop@1.20.0.rbi +8 -0
  131. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +8 -0
  132. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
  133. data/sorbet/rbi/gems/shellany@0.0.1.rbi +8 -0
  134. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +89 -0
  135. data/sorbet/rbi/gems/simplecov@0.21.2.rbi +577 -0
  136. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.3.rbi +8 -0
  137. data/sorbet/rbi/gems/solargraph@0.43.0.rbi +8 -0
  138. data/sorbet/rbi/gems/spoom@1.1.2.rbi +1204 -0
  139. data/sorbet/rbi/gems/tapioca@0.4.25.rbi +1239 -0
  140. data/sorbet/rbi/gems/temple@0.8.2.rbi +8 -0
  141. data/sorbet/rbi/gems/thor@1.1.0.rbi +838 -0
  142. data/sorbet/rbi/gems/tilt@2.0.10.rbi +8 -0
  143. data/sorbet/rbi/gems/timecop@0.9.4.rbi +82 -0
  144. data/sorbet/rbi/gems/tzinfo@2.0.4.rbi +857 -0
  145. data/sorbet/rbi/gems/unicode-display_width@2.0.0.rbi +8 -0
  146. data/sorbet/rbi/gems/unparser@0.6.0.rbi +8 -0
  147. data/sorbet/rbi/gems/vcr@6.0.0.rbi +782 -0
  148. data/sorbet/rbi/gems/yard-sorbet@0.5.3.rbi +8 -0
  149. data/sorbet/rbi/gems/yard@0.9.26.rbi +8 -0
  150. data/sorbet/rbi/gems/zeitwerk@2.4.2.rbi +173 -0
  151. data/sorbet/tapioca/config +0 -0
  152. data/sorbet/tapioca/require.rb +5 -0
  153. metadata +144 -127
@@ -0,0 +1,578 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1 id="shotgridapiruby">ShotgridApiRuby</h1>
61
+
62
+ <p><a href="https://badge.fury.io/rb/shotgrid_api_ruby"><img src="https://badge.fury.io/rb/shotgrid_api_ruby.svg" alt="Gem Version" /></a>
63
+ <img src="https://github.com/shotgunsoftware/shotgrid_api_ruby/workflows/Test%20and%20Release/badge.svg" alt="Test and Release badge" /></p>
64
+
65
+ <p>A gem to integrate with shotgrid REST API easily.</p>
66
+
67
+ <h2 id="installation">Installation</h2>
68
+
69
+ <p>Add this line to your application’s Gemfile:</p>
70
+
71
+ <p><code>ruby
72
+ gem 'shotgrid_api_ruby'
73
+ </code></p>
74
+
75
+ <p>And then execute:</p>
76
+
77
+ <pre class="code ruby"><code class="ruby">$ bundle
78
+ </code></pre>
79
+
80
+ <p>Or install it yourself as:</p>
81
+
82
+ <pre class="code ruby"><code class="ruby">$ gem install shotgrid_api_ruby
83
+ </code></pre>
84
+
85
+ <h2 id="usage">Usage</h2>
86
+
87
+ <h3 id="client-instantiation">Client instantiation</h3>
88
+
89
+ <p>For creating a new client you need to provide two values.</p>
90
+
91
+ <ul>
92
+ <li>One to identify the shotgrid site:
93
+ <ul>
94
+ <li>Can be <code>shotgun_site</code>: which is the <code>xxx</code> part in <code>https://xxx.shotgunstudio.com</code></li>
95
+ <li>Can be <code>shotgrid_site</code>: which is the <code>xxx</code> part in <code>https://xxx.shotgrid.autodesk.com</code></li>
96
+ <li>Can be <code>site_url</code>: which is the full url to your site</li>
97
+ </ul>
98
+ </li>
99
+ <li>One to <code>auth</code> you see <em>Authentication</em> lower in this guide.</li>
100
+ </ul>
101
+
102
+ <p>Example:</p>
103
+
104
+ <p><code>ruby
105
+ client = ShotgridApiRuby.new(shotgrid_site: 'i-love-shotgrid', auth: {client_id: 'my_nice_script', client_secret: 'CantTouchThis'})
106
+ </code></p>
107
+
108
+ <h3 id="authentication">Authentication</h3>
109
+
110
+ <p>Any kind of authentication specified <a href="https://developer.shotgunsoftware.com/rest-api/#authentication">here</a> is implemented</p>
111
+
112
+ <h4 id="client-credentials">Client Credentials</h4>
113
+
114
+ <p><code>ruby
115
+ client = ShotgridApiRuby.new(shotgrid_site: 'xxx', auth: {client_id: 'script_name', client_secret: 'script_secret'})
116
+ </code></p>
117
+
118
+ <h4 id="password-credentials">Password Credentials</h4>
119
+
120
+ <p><code>ruby
121
+ client = ShotgridApiRuby.new(shotgrid_site: 'xxx', auth: {username: 'login', password: 'password'})
122
+ </code></p>
123
+
124
+ <h4 id="session-token">Session Token</h4>
125
+
126
+ <p><strong>We highly advise not using this for a long term script as this won’t be a stable value over time</strong></p>
127
+
128
+ <p><code>ruby
129
+ client = ShotgridApiRuby.new(shotgrid_site: 'xxx', auth: {session_token: 'session_token'})
130
+ </code></p>
131
+
132
+ <h4 id="refresh-token">Refresh Token</h4>
133
+
134
+ <p><strong>We highly advise not using this for a long term script as this won’t be a stable value over time</strong></p>
135
+
136
+ <p><code>ruby
137
+ client = ShotgridApiRuby.new(shotgrid_site: 'xxx', auth: {refresh_token: 'refresh_token'})
138
+ </code></p>
139
+
140
+ <h3 id="shotgridcallerror">ShotgridCallError</h3>
141
+
142
+ <p>Every ShotGrid call resulting in an error will throw a ShotgridCallError. This error class derive from StandardError and will implement 2 extra methods:
143
+ - <code>#response</code> =&gt; Will returns the original HTTP response (a Faraday::Response).
144
+ - <code>#status</code> =&gt; This method is a shortcut to get the status from the response.</p>
145
+
146
+ <p>exemple
147
+ <code>ruby
148
+ begin
149
+ # A ShotGrid call resulting in a error
150
+ rescue StandardError =&gt; e
151
+ p e.message, e.backtrace # Will behave as a normal StandardError
152
+ p e.response.body # Original unparsed body from ShotGrid response
153
+ p e.status # Status code from ShotGrid answer
154
+ end
155
+ </code></p>
156
+
157
+ <h3 id="server-infos">Server Infos</h3>
158
+
159
+ <p>Get general server infos:</p>
160
+
161
+ <p>```ruby
162
+ client.server_info.get</p>
163
+
164
+ <h1 id="openstruct">#&lt;OpenStruct</h1>
165
+ <pre class="code ruby"><code class="ruby"> shotgun_version=&quot;v8.6.0.0-dev (build 12864de)&quot;,
166
+ api_version=&quot;v1&quot;,
167
+ shotgun_version_number=&quot;8.6.0.0-dev&quot;,
168
+ shotgun_build_number=&quot;12864de&quot;,
169
+ portfolio_version=&quot;UNKNOWN&quot;,
170
+ unified_login_flow_enabled=true,
171
+ user_authentication_method=&quot;default&quot;&gt; ```
172
+ </code></pre>
173
+
174
+ <h3 id="preferences">Preferences</h3>
175
+
176
+ <p>Get some preferences infos:</p>
177
+
178
+ <p>```ruby
179
+ prefs = client.preferences.get
180
+ prefs.to_h.keys</p>
181
+
182
+ <h1 id="formatdatefields">[:format_date_fields,</h1>
183
+ <p># :date_component_order,
184
+ # :format_time_hour_fields,
185
+ # :format_currency_fields_display_dollar_sign,
186
+ # :format_currency_fields_decimal_options,
187
+ # :format_currency_fields_negative_options,
188
+ # :format_number_fields,
189
+ # :format_float_fields,
190
+ # :format_float_fields_rounding,
191
+ # :format_footage_fields,
192
+ # :support_local_storage,
193
+ # :view_master_settings,
194
+ # :duration_units,
195
+ # :hours_per_day,
196
+ # :last_day_work_week]
197
+ ```</p>
198
+
199
+ <h3 id="entities">Entities</h3>
200
+
201
+ <p>Querying entities is done by accessing the named method</p>
202
+
203
+ <p><code>ruby
204
+ client.assets # =&gt; ShotgridApiRuby::Entities …
205
+ </code></p>
206
+
207
+ <p>As entities can be user defined the client will try to answer to any unknown type with an entity call so any of those calls will returns the same thing:</p>
208
+
209
+ <p><code>ruby
210
+ client.assets
211
+ client.asset
212
+ client.entities("Asset")
213
+ client.entities(:Assets)
214
+ </code></p>
215
+
216
+ <p>Any not yet implemented call can be accessed through the connection: <code>client.assets.connection</code></p>
217
+
218
+ <h4 id="entity">Entity</h4>
219
+
220
+ <p>Returned entity will try to behave as nicely as possible.</p>
221
+
222
+ <p>An entity will always answer to:</p>
223
+
224
+ <ul>
225
+ <li>.type : the type of the entity</li>
226
+ <li>.id : the id of the entity</li>
227
+ <li>.relationships : a hash of relationships</li>
228
+ <li>.links : a hash of links to other entities</li>
229
+ <li>.attributes : An object answering to any available attributes</li>
230
+ </ul>
231
+
232
+ <p>It will also answer to any method that is present in the attributes:</p>
233
+
234
+ <p><code>ruby
235
+ assets = client.assets.all(fields: 'code')
236
+ assets.first.type # =&gt; "Asset"
237
+ assets.first.id # =&gt; 726
238
+ assets.first.attributes.code # =&gt; "Buck"
239
+ assets.first.code # =&gt; "Buck"
240
+ </code></p>
241
+
242
+ <h3 id="search">Search</h3>
243
+
244
+ <h4 id="all">all</h4>
245
+
246
+ <p>The all call will return all possible entities.</p>
247
+
248
+ <p><code>ruby
249
+ client.assets.all
250
+ </code></p>
251
+
252
+ <h4 id="search-1">search</h4>
253
+
254
+ <p>Does the same thing as <code>all</code></p>
255
+
256
+ <h4 id="first">first</h4>
257
+
258
+ <p>Will return only the first entity found (same thing as setting the page_size to 1 and then getting the first result)</p>
259
+
260
+ <p><code>
261
+ client.assets.first
262
+ </code></p>
263
+
264
+ <h4 id="arguments">arguments</h4>
265
+
266
+ <h5 id="fields">fields</h5>
267
+
268
+ <p>This attribute describe the wanted fields in the returned entity</p>
269
+
270
+ <p>Can be a string describing wanted fields: <code>'code'</code> or <code>'code,description'</code>
271
+ Or an array for better readability: <code>[:code, 'description']</code></p>
272
+
273
+ <p>Example:</p>
274
+
275
+ <p><code>ruby
276
+ client.assets.all(fields: [:code, :description])
277
+ </code></p>
278
+
279
+ <h5 id="sort">sort</h5>
280
+
281
+ <p>Describe how you want your entities to be sorted.</p>
282
+
283
+ <p>Can be either:</p>
284
+
285
+ <ul>
286
+ <li>A string: <code>'code'</code> or <code>'code,-description'</code> (the <code>-</code> asking for a descending order)</li>
287
+ <li>An array for better readability: <code>[:code, '-description']</code></li>
288
+ <li>A hash for ease of use: <code>{code: 'asc', description: :desc}</code></li>
289
+ </ul>
290
+
291
+ <p>Example:</p>
292
+
293
+ <p><code>ruby
294
+ client.assets.all(fields: [:code, :description], sort: {code: :asc, description: :desc})
295
+ </code></p>
296
+
297
+ <h5 id="logicaloperator">logical_operator</h5>
298
+
299
+ <p>Default: “and”</p>
300
+
301
+ <p>This will be only used on complex queries. This is how we treat multiple first level conditions.</p>
302
+
303
+ <p>Accepted values: ‘and’, ‘or’</p>
304
+
305
+ <h5 id="filter">filter</h5>
306
+
307
+ <p>For simple filters, the filter field is waiting for a hash.</p>
308
+
309
+ <p>Each value is:</p>
310
+
311
+ <ul>
312
+ <li>A string: then a <code>is</code> filter will be used</li>
313
+ <li>An array: then a <code>in</code> filter will be used</li>
314
+ </ul>
315
+
316
+ <p>Example:</p>
317
+
318
+ <p><code>ruby
319
+ client.assets.all(fields: [:code, :description], filter: {code: ['Buck', :Darcy], description: 'I LOVE SG'})
320
+ </code></p>
321
+
322
+ <p>For complex filters, see the documentation <a href="https://developer.shotgunsoftware.com/rest-api/#searching">here</a>.</p>
323
+
324
+ <p>If the filters are complex there’s many cases:</p>
325
+
326
+ <ul>
327
+ <li>If they are a hash containing logical_operator and conditions =&gt; we will use them</li>
328
+ <li>If the filter is <strong>not</strong> a hash =&gt; we will use it without translation</li>
329
+ <li>If the filter is a hash not containing “conditions”. We will try to translate this to SG compatible query.</li>
330
+ </ul>
331
+
332
+ <p>Example:
333
+ <code>ruby
334
+ client.assets.all(
335
+ filter: {
336
+ project: { id: 2 },
337
+ sg_status_list: ["act", "hld", "omt"]
338
+ },
339
+ )
340
+ # Will be translated to:
341
+ {
342
+ "filters"=&gt;{
343
+ "conditions"=&gt; [
344
+ ["project.Project.id", "is", 2],
345
+ ["sg_status_list", "in", ["act", "hld", "omt"]]
346
+ ],
347
+ "logical_operator"=&gt;"and"
348
+ }
349
+ }
350
+ </code></p>
351
+
352
+ <p>The complexity of calling a different route and passing different headers/body/params will be taken care of automatically.</p>
353
+
354
+ <h5 id="page">page</h5>
355
+
356
+ <p>You can ask for any page size or page number.</p>
357
+
358
+ <ul>
359
+ <li><code>page</code>: set the page number.</li>
360
+ <li><code>page_size</code>: set the size of each page.</li>
361
+ </ul>
362
+
363
+ <p>Any of the two can be omited. Their type should be a number but it’ll work with a string</p>
364
+
365
+ <p>Example:</p>
366
+
367
+ <p><code>ruby
368
+ client.assets.all(fields: [:code], page: 3, page_size: 10)
369
+ client.assets.all(fields: [:code], page: '3')
370
+ client.assets.all(fields: [:code], page_size: 10)
371
+ </code></p>
372
+
373
+ <h5 id="options">options</h5>
374
+
375
+ <p>Special options can be added:</p>
376
+
377
+ <ul>
378
+ <li>retired: a flag telling if the returned entities should be retired or not</li>
379
+ <li>include_archived_projects: a flag telling if the archived projets should be included int the search</li>
380
+ </ul>
381
+
382
+ <p>Example:</p>
383
+
384
+ <p><code>ruby
385
+ client.assets.all(fields: [:code], retired: true)
386
+ client.assets.all(fields: [:code], include_archived_projects: true)
387
+ </code></p>
388
+
389
+ <h3 id="finding-one-element">Finding one element</h3>
390
+
391
+ <p><code>find</code> function on <code>entities</code> allow you to get one element in particular.</p>
392
+
393
+ <p>It accepts (all arguments are optional):</p>
394
+
395
+ <ul>
396
+ <li>fields: string, symbol or array of fields</li>
397
+ <li>retired: boolean specifying if the record is retired</li>
398
+ <li>include_archived_projects: boolean specifying if the entity is part of an archived project</li>
399
+ </ul>
400
+
401
+ <p>Example:</p>
402
+
403
+ <p><code>ruby
404
+ client.assets.find(724, fields: [:code, 'description'], retired: false)
405
+ </code></p>
406
+
407
+ <h3 id="create">Create</h3>
408
+
409
+ <p>Will create the entity referenced by the id with the following fields.
410
+ If successful, it will return the newly created entity.</p>
411
+
412
+ <p><code>ruby
413
+ client.assets.create(code: 'New Asset', project: {type: 'Project', id: 63})
414
+ </code></p>
415
+
416
+ <h3 id="update">Update</h3>
417
+
418
+ <p>Will update the entity referenced by the id with the following fields.
419
+ If successful, it will return the modified entity.</p>
420
+
421
+ <p><code>ruby
422
+ client.assets.update(1226, code: 'Updated Asset', sg_status_list: 'fin')
423
+ </code></p>
424
+
425
+ <h3 id="delete">Delete</h3>
426
+
427
+ <p>Will destroys the entity referenced by the id. Will return true if successful.</p>
428
+
429
+ <p><code>ruby
430
+ client.assets.delete(1226)
431
+ </code></p>
432
+
433
+ <h3 id="revive">Revive</h3>
434
+
435
+ <p>Will try to revive the entity referenced by the id. Will return true if successful.</p>
436
+
437
+ <p><code>ruby
438
+ client.assets.revive(1226)
439
+ </code></p>
440
+
441
+ <h3 id="summarize">Summarize</h3>
442
+
443
+ <p>Will summarize data for an entity type.</p>
444
+
445
+ <p>Example:
446
+ ```ruby
447
+ # Simplest example
448
+ client.assets.summarize(summary_fields: :count)</p>
449
+
450
+ <h1 id="full-complex-example">Full complex example</h1>
451
+ <p>client.assets.summarize(
452
+ filter: { project: { id: 122 }, sg_status_list: :act },
453
+ logical_operator: ‘or’,
454
+ include_archived_projects: true,
455
+ grouping: {
456
+ code: :desc, type: ‘exact’
457
+ },
458
+ summary_fields: { id: :count }
459
+ )</p>
460
+
461
+ <h1 id="raw-shotgrid-queries">Raw shotgrid queries</h1>
462
+ <p>client.assets.summarize(
463
+ grouping: [
464
+ {
465
+ “field”: “sg_asset_type”,
466
+ “type”: “exact”,
467
+ “direction”: “asc”
468
+ }
469
+ ],
470
+ summary_fields: [
471
+ {
472
+ “field”: “id”,
473
+ “type”: “count”
474
+ }
475
+ ],
476
+ )
477
+ ```</p>
478
+
479
+ <p>It accepts the same <code>filter</code> and <code>logical_operator</code> as a <code>search</code> will.</p>
480
+
481
+ <h4 id="summary-fields">Summary fields</h4>
482
+
483
+ <p>Those can have two forms:</p>
484
+
485
+ <h5 id="the-normal-api-form">The normal API form</h5>
486
+
487
+ <p>You need to supply the summary_fields as an array and it will be passed directly to the SG REST API</p>
488
+
489
+ <h4 id="the-convenient-form">The convenient form</h4>
490
+
491
+ <p>Using an array isn’t very convenient most of the time. You can use a hash instead and it will be translated into a “SG summary_fields array”.</p>
492
+
493
+ <p>Each key of the hash is the field name and the corresponding value is the type a summary you want (can be a string or a symbol)</p>
494
+
495
+ <h4 id="grouping">Grouping</h4>
496
+
497
+ <p>Those can have two forms:</p>
498
+
499
+ <h5 id="the-normal-api-form-1">The normal API form</h5>
500
+
501
+ <p>You need to supply the grouping as an array and it will be passed directly to the SG REST API</p>
502
+
503
+ <h4 id="the-convenient-form-1">The convenient form</h4>
504
+
505
+ <p>Using an array isn’t very convenient most of the time. You can use a hash instead and it will be translated into a “SG grouping array”.</p>
506
+
507
+ <p>Each key of the hash is the field name and the corresponding value can either be :
508
+ * A String/Symbol and then will be used a a direction. The type will be ‘exact’
509
+ * A Hash with optional ‘type’ and ‘direction’ keys. If a key is not specified it will be ‘exact’ and ‘asc’ respectively.</p>
510
+
511
+ <h3 id="count">Count</h3>
512
+
513
+ <p>This is a helper for more a readable count summary. This can be passed <code>filter</code> and <code>logical_operator</code>.</p>
514
+
515
+ <p>Example:</p>
516
+
517
+ <p>```ruby
518
+ client.assets.count</p>
519
+
520
+ <h1 id="this-will-be-equivalent-as-doing">This will be equivalent as doing:</h1>
521
+ <p>client.assets.summarize(summary_fields: [:record_count, field: :id])
522
+ ```</p>
523
+
524
+ <h3 id="schema">Schema</h3>
525
+
526
+ <p>Those calls allow to inspect the schema for a shotgrid site.</p>
527
+
528
+ <h4 id="entity-1">Entity</h4>
529
+
530
+ <p><code>ruby
531
+ client.assets.schema
532
+ </code></p>
533
+
534
+ <h4 id="entity-fields">Entity fields</h4>
535
+
536
+ <p>Fetch the different fields available on an entity type and their definition.</p>
537
+
538
+ <p><code>ruby
539
+ fields = client.assets.fields
540
+ fields.code.name # =&gt; "Asset Name"
541
+ fields.code.properties.summary_default # =&gt; "none"
542
+ </code></p>
543
+
544
+ <h3 id="non-implemented-calls">Non implemented calls</h3>
545
+
546
+ <p>All calls which are not yet implemented can be done through the <code>connection</code> method. This method will still take care of the authentication for you.</p>
547
+
548
+ <p><code>ruby
549
+ client = ShotgridApiRuby.new(…)
550
+ client.connection.get('/entity/assets') # =&gt; #&lt;Faraday::Response:xxx @on_complete_callbacks=[], @env=#&lt;Faraday::Env @method=:get @body="{\"data\":[{\"type\":\"Asset\",\"attributes\":{},\"relationships\":{},\"id\":726 …
551
+ </code></p>
552
+
553
+ <h2 id="development">Development</h2>
554
+
555
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake spec</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
556
+
557
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
558
+
559
+ <p>Every commit/push is checked by overcommit.</p>
560
+
561
+ <h2 id="contributing">Contributing</h2>
562
+
563
+ <p>Bug reports and pull requests are welcome on GitHub at https://github.com/shotgunsoftware/shotgrid_api_ruby.</p>
564
+
565
+ <h2 id="license">License</h2>
566
+
567
+ <p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
568
+ </div></div>
569
+
570
+ <div id="footer">
571
+ Generated on Tue Oct 12 21:57:54 2021 by
572
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
573
+ 0.9.26 (ruby-3.0.2).
574
+ </div>
575
+
576
+ </div>
577
+ </body>
578
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
data/docs/frames.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.26</title>
6
+ </head>
7
+ <script type="text/javascript">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>