wsc_sdk 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +146 -0
  3. data/.circleci/docker/build/Dockerfile +3 -0
  4. data/.circleci/helpers/add_preamble.rb +29 -0
  5. data/.circleci/helpers/build_docs.sh +5 -0
  6. data/.circleci/helpers/build_gem.sh +5 -0
  7. data/.circleci/helpers/debundle-context.sh +14 -0
  8. data/.circleci/helpers/finalize_release.sh +24 -0
  9. data/.circleci/helpers/publish_docs.sh +10 -0
  10. data/.circleci/helpers/release_gem.sh +8 -0
  11. data/.circleci/helpers/setup.sh +11 -0
  12. data/.circleci/helpers/setup_aws.sh +13 -0
  13. data/.circleci/helpers/setup_gem.sh +2 -0
  14. data/.circleci/helpers/setup_git.sh +27 -0
  15. data/.circleci/helpers/setup_rubygems.sh +15 -0
  16. data/.circleci/helpers/test_integration.sh +12 -0
  17. data/.circleci/helpers/test_unit.sh +6 -0
  18. data/.circleci/jobs/publish-production.sh +17 -0
  19. data/.circleci/jobs/publish-staging.sh +17 -0
  20. data/.circleci/jobs/release-production.sh +21 -0
  21. data/.circleci/jobs/test-integration.sh +9 -0
  22. data/.circleci/jobs/test-unit.sh +9 -0
  23. data/.circleci/tag_repo.rb +46 -0
  24. data/.gitignore +28 -0
  25. data/.rspec +2 -0
  26. data/.yard/config +2 -0
  27. data/.yard/template/default/fulldoc/html/css/custom.css +151 -0
  28. data/.yard/template/default/layout/html/footer.erb +0 -0
  29. data/.yard/template/default/layout/html/headers.erb +10 -0
  30. data/.yard/template/default/layout/html/layout.erb +45 -0
  31. data/.yard/template/default/layout/html/setup.rb +24 -0
  32. data/.yardopts +1 -0
  33. data/CODE_OF_CONDUCT.md +74 -0
  34. data/Gemfile +6 -0
  35. data/Gemfile.lock +99 -0
  36. data/LICENSE.txt +28 -0
  37. data/README.md +397 -0
  38. data/Rakefile +2 -0
  39. data/bin/console +14 -0
  40. data/bin/setup +8 -0
  41. data/doc/Hash.html +291 -0
  42. data/doc/WscSdk.html +570 -0
  43. data/doc/WscSdk/ApiResponse.html +242 -0
  44. data/doc/WscSdk/Attributes.html +128 -0
  45. data/doc/WscSdk/Attributes/Mode.html +191 -0
  46. data/doc/WscSdk/Attributes/Type.html +389 -0
  47. data/doc/WscSdk/Client.html +2677 -0
  48. data/doc/WscSdk/Configuration.html +595 -0
  49. data/doc/WscSdk/Endpoint.html +2974 -0
  50. data/doc/WscSdk/Endpoints.html +141 -0
  51. data/doc/WscSdk/Endpoints/CustomStreamTargets.html +383 -0
  52. data/doc/WscSdk/Endpoints/LiveStreams.html +197 -0
  53. data/doc/WscSdk/Endpoints/OutputStreamTargets.html +180 -0
  54. data/doc/WscSdk/Endpoints/Outputs.html +180 -0
  55. data/doc/WscSdk/Endpoints/StreamTargets.html +446 -0
  56. data/doc/WscSdk/Endpoints/Transcoders.html +197 -0
  57. data/doc/WscSdk/Endpoints/UllStreamTargets.html +383 -0
  58. data/doc/WscSdk/Endpoints/WowzaStreamTargets.html +383 -0
  59. data/doc/WscSdk/Enum.html +225 -0
  60. data/doc/WscSdk/Enums.html +321 -0
  61. data/doc/WscSdk/Enums/BillingMode.html +188 -0
  62. data/doc/WscSdk/Enums/BroadcastLocation.html +396 -0
  63. data/doc/WscSdk/Enums/BufferSize.html +301 -0
  64. data/doc/WscSdk/Enums/ClosedCaptionType.html +221 -0
  65. data/doc/WscSdk/Enums/CustomProvider.html +252 -0
  66. data/doc/WscSdk/Enums/DeliveryMethod.html +188 -0
  67. data/doc/WscSdk/Enums/DeliveryType.html +188 -0
  68. data/doc/WscSdk/Enums/Encoder.html +460 -0
  69. data/doc/WscSdk/Enums/Errors.html +555 -0
  70. data/doc/WscSdk/Enums/IdleTimeout.html +398 -0
  71. data/doc/WscSdk/Enums/ImagePosition.html +220 -0
  72. data/doc/WscSdk/Enums/ModelMode.html +175 -0
  73. data/doc/WscSdk/Enums/ModelType.html +373 -0
  74. data/doc/WscSdk/Enums/PlayerType.html +188 -0
  75. data/doc/WscSdk/Enums/Protocol.html +204 -0
  76. data/doc/WscSdk/Enums/TargetDeliveryProtocol.html +188 -0
  77. data/doc/WscSdk/Enums/TranscoderType.html +188 -0
  78. data/doc/WscSdk/Enums/UserRegion.html +383 -0
  79. data/doc/WscSdk/Enums/WowzaProvider.html +188 -0
  80. data/doc/WscSdk/Errors.html +683 -0
  81. data/doc/WscSdk/Loggable.html +346 -0
  82. data/doc/WscSdk/Model.html +3316 -0
  83. data/doc/WscSdk/ModelList.html +442 -0
  84. data/doc/WscSdk/ModelTemplate.html +267 -0
  85. data/doc/WscSdk/Models.html +141 -0
  86. data/doc/WscSdk/Models/CustomStreamTarget.html +192 -0
  87. data/doc/WscSdk/Models/Error.html +351 -0
  88. data/doc/WscSdk/Models/LiveStream.html +601 -0
  89. data/doc/WscSdk/Models/LiveStreamConnectionCode.html +192 -0
  90. data/doc/WscSdk/Models/LiveStreamState.html +200 -0
  91. data/doc/WscSdk/Models/LiveStreamStats.html +200 -0
  92. data/doc/WscSdk/Models/LiveStreamThumbnailUrl.html +200 -0
  93. data/doc/WscSdk/Models/Output.html +294 -0
  94. data/doc/WscSdk/Models/OutputStreamTarget.html +274 -0
  95. data/doc/WscSdk/Models/StreamTarget.html +273 -0
  96. data/doc/WscSdk/Models/Transcoder.html +793 -0
  97. data/doc/WscSdk/Models/TranscoderBooleanStat.html +278 -0
  98. data/doc/WscSdk/Models/TranscoderConnectionCode.html +192 -0
  99. data/doc/WscSdk/Models/TranscoderFloatStat.html +278 -0
  100. data/doc/WscSdk/Models/TranscoderIntegerStat.html +278 -0
  101. data/doc/WscSdk/Models/TranscoderState.html +196 -0
  102. data/doc/WscSdk/Models/TranscoderStats.html +196 -0
  103. data/doc/WscSdk/Models/TranscoderStreamTargetState.html +192 -0
  104. data/doc/WscSdk/Models/TranscoderStringStat.html +278 -0
  105. data/doc/WscSdk/Models/TranscoderThumbnailUrl.html +196 -0
  106. data/doc/WscSdk/Models/UllStreamTarget.html +360 -0
  107. data/doc/WscSdk/Models/WowzaStreamTarget.html +380 -0
  108. data/doc/WscSdk/Pagination.html +1277 -0
  109. data/doc/WscSdk/Schema.html +861 -0
  110. data/doc/WscSdk/SchemaAttribute.html +2400 -0
  111. data/doc/WscSdk/Templates.html +141 -0
  112. data/doc/WscSdk/Templates/CustomStreamTarget.html +1045 -0
  113. data/doc/WscSdk/Templates/LiveStream.html +1432 -0
  114. data/doc/WscSdk/Templates/Output.html +829 -0
  115. data/doc/WscSdk/Templates/Transcoder.html +699 -0
  116. data/doc/WscSdk/Templates/UllStreamTarget.html +411 -0
  117. data/doc/WscSdk/Templates/WowzaStreamTarget.html +447 -0
  118. data/doc/WscSdk/TranscoderSharedMethods.html +1113 -0
  119. data/doc/_index.html +705 -0
  120. data/doc/class_list.html +51 -0
  121. data/doc/css/bootstrap.css +5 -0
  122. data/doc/css/common.css +1 -0
  123. data/doc/css/custom.css +151 -0
  124. data/doc/css/full_list.css +58 -0
  125. data/doc/css/style.css +496 -0
  126. data/doc/file.README.html +570 -0
  127. data/doc/file_list.html +56 -0
  128. data/doc/frames.html +17 -0
  129. data/doc/images/wsc-ruby-1800x400.png +0 -0
  130. data/doc/index.html +570 -0
  131. data/doc/js/app.js +292 -0
  132. data/doc/js/full_list.js +216 -0
  133. data/doc/js/jquery.js +4 -0
  134. data/doc/method_list.html +1731 -0
  135. data/doc/top-level-namespace.html +182 -0
  136. data/examples/client.rb +40 -0
  137. data/examples/helpers.rb +100 -0
  138. data/examples/live_streams/create.rb +39 -0
  139. data/examples/live_streams/delete.rb +32 -0
  140. data/examples/live_streams/find.rb +22 -0
  141. data/examples/live_streams/flood.rb +126 -0
  142. data/examples/live_streams/list.rb +24 -0
  143. data/examples/live_streams/regenerate_connection_code.rb +29 -0
  144. data/examples/live_streams/reset.rb +32 -0
  145. data/examples/live_streams/reset_and_wait.rb +51 -0
  146. data/examples/live_streams/start.rb +33 -0
  147. data/examples/live_streams/start_and_wait.rb +51 -0
  148. data/examples/live_streams/state.rb +33 -0
  149. data/examples/live_streams/stats.rb +43 -0
  150. data/examples/live_streams/stop.rb +33 -0
  151. data/examples/live_streams/stop_and_wait.rb +51 -0
  152. data/examples/live_streams/thumbnail_url.rb +46 -0
  153. data/examples/live_streams/update.rb +43 -0
  154. data/examples/live_streams/workflow.rb +165 -0
  155. data/examples/output_stream_targets/create.rb +56 -0
  156. data/examples/output_stream_targets/delete.rb +45 -0
  157. data/examples/output_stream_targets/find.rb +37 -0
  158. data/examples/output_stream_targets/list.rb +36 -0
  159. data/examples/output_stream_targets/update.rb +56 -0
  160. data/examples/outputs/create.rb +49 -0
  161. data/examples/outputs/delete.rb +39 -0
  162. data/examples/outputs/find.rb +31 -0
  163. data/examples/outputs/list.rb +29 -0
  164. data/examples/outputs/update.rb +50 -0
  165. data/examples/stream_targets/custom/create.rb +42 -0
  166. data/examples/stream_targets/custom/delete.rb +31 -0
  167. data/examples/stream_targets/custom/find.rb +23 -0
  168. data/examples/stream_targets/custom/list.rb +24 -0
  169. data/examples/stream_targets/custom/update.rb +43 -0
  170. data/examples/stream_targets/list.rb +24 -0
  171. data/examples/stream_targets/ull/create.rb +41 -0
  172. data/examples/stream_targets/ull/delete.rb +31 -0
  173. data/examples/stream_targets/ull/find.rb +23 -0
  174. data/examples/stream_targets/ull/list.rb +24 -0
  175. data/examples/stream_targets/ull/update.rb +43 -0
  176. data/examples/stream_targets/wowza/create.rb +42 -0
  177. data/examples/stream_targets/wowza/delete.rb +31 -0
  178. data/examples/stream_targets/wowza/find.rb +23 -0
  179. data/examples/stream_targets/wowza/list.rb +23 -0
  180. data/examples/stream_targets/wowza/update.rb +43 -0
  181. data/examples/transcoders/create.rb +39 -0
  182. data/examples/transcoders/delete.rb +31 -0
  183. data/examples/transcoders/find.rb +23 -0
  184. data/examples/transcoders/list.rb +24 -0
  185. data/examples/transcoders/reset.rb +32 -0
  186. data/examples/transcoders/reset_and_wait.rb +48 -0
  187. data/examples/transcoders/start.rb +33 -0
  188. data/examples/transcoders/start_and_wait.rb +50 -0
  189. data/examples/transcoders/state.rb +33 -0
  190. data/examples/transcoders/stats.rb +43 -0
  191. data/examples/transcoders/stop.rb +33 -0
  192. data/examples/transcoders/stop_and_wait.rb +50 -0
  193. data/examples/transcoders/thumbnail_url.rb +46 -0
  194. data/examples/transcoders/update.rb +43 -0
  195. data/images/wsc-ruby-1800x400.png +0 -0
  196. data/lib/wsc_sdk.rb +81 -0
  197. data/lib/wsc_sdk/client.rb +417 -0
  198. data/lib/wsc_sdk/configuration.rb +21 -0
  199. data/lib/wsc_sdk/constants.rb +29 -0
  200. data/lib/wsc_sdk/endpoint.rb +492 -0
  201. data/lib/wsc_sdk/endpoints/custom_stream_targets.rb +44 -0
  202. data/lib/wsc_sdk/endpoints/live_streams.rb +34 -0
  203. data/lib/wsc_sdk/endpoints/output_stream_targets.rb +17 -0
  204. data/lib/wsc_sdk/endpoints/outputs.rb +17 -0
  205. data/lib/wsc_sdk/endpoints/stream_targets.rb +45 -0
  206. data/lib/wsc_sdk/endpoints/transcoders.rb +38 -0
  207. data/lib/wsc_sdk/endpoints/ull_stream_targets.rb +44 -0
  208. data/lib/wsc_sdk/endpoints/wowza_stream_targets.rb +44 -0
  209. data/lib/wsc_sdk/enums.rb +31 -0
  210. data/lib/wsc_sdk/enums/billing_mode.rb +20 -0
  211. data/lib/wsc_sdk/enums/broadcast_location.rb +58 -0
  212. data/lib/wsc_sdk/enums/buffer_size.rb +41 -0
  213. data/lib/wsc_sdk/enums/closed_caption_type.rb +26 -0
  214. data/lib/wsc_sdk/enums/custom_provider.rb +32 -0
  215. data/lib/wsc_sdk/enums/delivery_method.rb +20 -0
  216. data/lib/wsc_sdk/enums/delivery_type.rb +20 -0
  217. data/lib/wsc_sdk/enums/encoder.rb +71 -0
  218. data/lib/wsc_sdk/enums/idle_timeout.rb +50 -0
  219. data/lib/wsc_sdk/enums/image_position.rb +26 -0
  220. data/lib/wsc_sdk/enums/player_type.rb +20 -0
  221. data/lib/wsc_sdk/enums/protocol.rb +23 -0
  222. data/lib/wsc_sdk/enums/target_delivery_protocol.rb +20 -0
  223. data/lib/wsc_sdk/enums/transcoder_type.rb +20 -0
  224. data/lib/wsc_sdk/enums/wowza_provider.rb +20 -0
  225. data/lib/wsc_sdk/errors.rb +115 -0
  226. data/lib/wsc_sdk/model.rb +515 -0
  227. data/lib/wsc_sdk/model_list.rb +42 -0
  228. data/lib/wsc_sdk/model_template.rb +27 -0
  229. data/lib/wsc_sdk/models/custom_stream_target.rb +34 -0
  230. data/lib/wsc_sdk/models/error.rb +53 -0
  231. data/lib/wsc_sdk/models/live_stream.rb +130 -0
  232. data/lib/wsc_sdk/models/live_stream_connection_code.rb +31 -0
  233. data/lib/wsc_sdk/models/live_stream_state.rb +20 -0
  234. data/lib/wsc_sdk/models/live_stream_stats.rb +20 -0
  235. data/lib/wsc_sdk/models/live_stream_thumbnail_url.rb +20 -0
  236. data/lib/wsc_sdk/models/output.rb +61 -0
  237. data/lib/wsc_sdk/models/output_stream_target.rb +37 -0
  238. data/lib/wsc_sdk/models/stream_target.rb +29 -0
  239. data/lib/wsc_sdk/models/transcoder.rb +135 -0
  240. data/lib/wsc_sdk/models/transcoder_boolean_stat.rb +41 -0
  241. data/lib/wsc_sdk/models/transcoder_connection_code.rb +29 -0
  242. data/lib/wsc_sdk/models/transcoder_float_stat.rb +40 -0
  243. data/lib/wsc_sdk/models/transcoder_integer_stat.rb +40 -0
  244. data/lib/wsc_sdk/models/transcoder_state.rb +31 -0
  245. data/lib/wsc_sdk/models/transcoder_stats.rb +51 -0
  246. data/lib/wsc_sdk/models/transcoder_stream_target_state.rb +29 -0
  247. data/lib/wsc_sdk/models/transcoder_string_stat.rb +40 -0
  248. data/lib/wsc_sdk/models/transcoder_thumbnail_url.rb +29 -0
  249. data/lib/wsc_sdk/models/ull_stream_target.rb +54 -0
  250. data/lib/wsc_sdk/models/wowza_stream_target.rb +60 -0
  251. data/lib/wsc_sdk/modules/api_response.rb +24 -0
  252. data/lib/wsc_sdk/modules/loggable.rb +44 -0
  253. data/lib/wsc_sdk/modules/transcoder_shared_methods.rb +221 -0
  254. data/lib/wsc_sdk/pagination.rb +89 -0
  255. data/lib/wsc_sdk/schema.rb +140 -0
  256. data/lib/wsc_sdk/schema_attribute.rb +349 -0
  257. data/lib/wsc_sdk/templates/custom_stream_target.rb +154 -0
  258. data/lib/wsc_sdk/templates/live_stream.rb +234 -0
  259. data/lib/wsc_sdk/templates/output.rb +133 -0
  260. data/lib/wsc_sdk/templates/transcoder.rb +97 -0
  261. data/lib/wsc_sdk/templates/ull_stream_target.rb +49 -0
  262. data/lib/wsc_sdk/templates/wowza_stream_target.rb +57 -0
  263. data/lib/wsc_sdk/version.rb +7 -0
  264. data/wsc_sdk.gemspec +48 -0
  265. metadata +460 -0
@@ -0,0 +1,346 @@
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>Wowza Streaming Cloud - SDK Code Documentation</title>
7
+
8
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
9
+
10
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
11
+
12
+ <link rel="stylesheet" href="../css/custom.css" type="text/css" charset="utf-8" />
13
+
14
+ <script type="text/javascript" charset="utf-8">
15
+ pathId = "WscSdk::Loggable";
16
+ relpath = '../';
17
+ </script>
18
+
19
+
20
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
23
+
24
+
25
+ </head>
26
+ <body>
27
+ <div id="wowza-wrapper">
28
+ <header>
29
+ <div class="logo">
30
+ <a href="https://www.wowza.com">
31
+ <img src="https://cloud.wowza.com/apidocs/assets/logo.png" alt="Wowza Logo" />
32
+ </a>
33
+ <h1>Wowza Streaming Cloud<br/>SDK Code Documentation</h1>
34
+ <div class="clearfix"></div>
35
+ </div>
36
+ <div class="links">
37
+ <a href="https://www.wowza.com/">Wowza Home</a>
38
+ <a href="https://www.wowza.com/docs">Docs & APIS</a>
39
+ <a href="https://www.wowza.com/community/index.html">Forums</a>
40
+ <a href="https://www.wowza.com/support">Support</a>
41
+ </div>
42
+ <div class="clearfix"></div>
43
+ </header>
44
+
45
+ <div id="content">
46
+ <div class="nav_wrap">
47
+ <iframe id="nav" src="../class_list.html?1"></iframe>
48
+ <div id="resizer"></div>
49
+ </div>
50
+
51
+ <div id="main" tabindex="-1">
52
+ <div id="header">
53
+ <div id="menu">
54
+
55
+ <a href="../_index.html">Index (L)</a> &raquo;
56
+ <span class='title'><span class='object_link'><a href="../WscSdk.html" title="WscSdk (module)">WscSdk</a></span></span>
57
+ &raquo;
58
+ <span class="title">Loggable</span>
59
+
60
+ </div>
61
+
62
+ <div id="search">
63
+
64
+ <a class="full_list_link" id="class_list_link"
65
+ href="../class_list.html">
66
+
67
+ <svg width="24" height="24">
68
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
69
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
70
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
71
+ </svg>
72
+ </a>
73
+
74
+ </div>
75
+ <div class="clear"></div>
76
+ </div>
77
+
78
+ <div id="content"><h1>Module: WscSdk::Loggable
79
+
80
+
81
+
82
+ </h1>
83
+ <div class="box_info">
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+ <dl>
94
+ <dt>Included in:</dt>
95
+ <dd><span class='object_link'><a href="Endpoint.html" title="WscSdk::Endpoint (class)">Endpoint</a></span>, <span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">Model</a></span></dd>
96
+ </dl>
97
+
98
+
99
+
100
+ <dl>
101
+ <dt>Defined in:</dt>
102
+ <dd>lib/wsc_sdk/modules/loggable.rb</dd>
103
+ </dl>
104
+
105
+ </div>
106
+
107
+ <h2>Overview</h2><div class="docstring">
108
+ <div class="discussion">
109
+
110
+ <p>A module that adds access to a logger.</p>
111
+
112
+ <p>This will check to see if a Client object is available, and use its logger
113
+ otherwise it checks for an endpoint and will use its logger, as a last
114
+ ditch it will build a new plain old logger that logs to STDOUT.</p>
115
+
116
+ <p>There is a logger attribute accessor, so you can overwrite the logger with
117
+ your own.</p>
118
+
119
+
120
+ </div>
121
+ </div>
122
+ <div class="tags">
123
+
124
+
125
+ </div>
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <h2>
134
+ Instance Method Summary
135
+ <small><a href="#" class="summary_toggle">collapse</a></small>
136
+ </h2>
137
+
138
+ <ul class="summary">
139
+
140
+ <li class="public ">
141
+ <span class="summary_signature">
142
+
143
+ <a href="#logger-instance_method" title="#logger (instance method)">#<strong>logger</strong> &#x21d2; Logger </a>
144
+
145
+
146
+
147
+ </span>
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+ <span class="summary_desc"><div class='inline'>
158
+ <p>Returns an instance of a logger.</p>
159
+ </div></span>
160
+
161
+ </li>
162
+
163
+
164
+ <li class="public ">
165
+ <span class="summary_signature">
166
+
167
+ <a href="#logger=-instance_method" title="#logger= (instance method)">#<strong>logger=</strong>(_logger) &#x21d2; Object </a>
168
+
169
+
170
+
171
+ </span>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ <span class="summary_desc"><div class='inline'>
182
+ <p>Sets the instance of logger.</p>
183
+ </div></span>
184
+
185
+ </li>
186
+
187
+
188
+ </ul>
189
+
190
+
191
+
192
+
193
+ <div id="instance_method_details" class="method_details_list">
194
+ <h2>Instance Method Details</h2>
195
+
196
+
197
+ <div class="method_details first">
198
+ <h3 class="signature first" id="logger-instance_method">
199
+
200
+ #<strong>logger</strong> &#x21d2; <tt>Logger</tt>
201
+
202
+
203
+
204
+
205
+
206
+ </h3><div class="docstring">
207
+ <div class="discussion">
208
+
209
+ <p>Returns an instance of a logger.</p>
210
+
211
+
212
+ </div>
213
+ </div>
214
+ <div class="tags">
215
+
216
+ <p class="tag_title">Returns:</p>
217
+ <ul class="return">
218
+
219
+ <li>
220
+
221
+
222
+ <span class='type'>(<tt>Logger</tt>)</span>
223
+
224
+
225
+
226
+ &mdash;
227
+ <div class='inline'>
228
+ <p>The assigned logger.</p>
229
+ </div>
230
+
231
+ </li>
232
+
233
+ </ul>
234
+
235
+ </div><table class="source_code">
236
+ <tr>
237
+ <td>
238
+ <pre class="lines">
239
+
240
+
241
+ 22
242
+ 23
243
+ 24
244
+ 25
245
+ 26
246
+ 27
247
+ 28
248
+ 29
249
+ 30
250
+ 31
251
+ 32
252
+ 33
253
+ 34</pre>
254
+ </td>
255
+ <td>
256
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/modules/loggable.rb', line 22</span>
257
+
258
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">logger</span>
259
+ <span style="color:#080;font-weight:bold">if</span> <span style="color:#33B">@logger</span>.nil?
260
+ <span style="color:#080;font-weight:bold">if</span> <span style="color:#069">self</span>.respond_to?(<span style="color:#A60">:client</span>)
261
+ <span style="color:#33B">@logger</span> = <span style="color:#069">self</span>.client.logger
262
+ <span style="color:#080;font-weight:bold">elsif</span> <span style="color:#069">self</span>.respond_to?(<span style="color:#A60">:endpoint</span>)
263
+ <span style="color:#33B">@logger</span> = <span style="color:#069">self</span>.endpoint.logger
264
+ <span style="color:#080;font-weight:bold">end</span>
265
+
266
+ <span style="color:#33B">@logger</span> ||= <span style="color:#036;font-weight:bold">Logger</span>.new(<span style="color:#069">STDOUT</span>)
267
+ <span style="color:#080;font-weight:bold">end</span>
268
+
269
+ <span style="color:#33B">@logger</span>
270
+ <span style="color:#080;font-weight:bold">end</span></pre>
271
+ </td>
272
+ </tr>
273
+ </table>
274
+ </div>
275
+
276
+ <div class="method_details ">
277
+ <h3 class="signature " id="logger=-instance_method">
278
+
279
+ #<strong>logger=</strong>(_logger) &#x21d2; <tt>Object</tt>
280
+
281
+
282
+
283
+
284
+
285
+ </h3><div class="docstring">
286
+ <div class="discussion">
287
+
288
+ <p>Sets the instance of logger.</p>
289
+
290
+
291
+ </div>
292
+ </div>
293
+ <div class="tags">
294
+ <p class="tag_title">Parameters:</p>
295
+ <ul class="param">
296
+
297
+ <li>
298
+
299
+ <span class='name'>_logger</span>
300
+
301
+
302
+ <span class='type'>(<tt>Logger</tt>)</span>
303
+
304
+
305
+
306
+ &mdash;
307
+ <div class='inline'>
308
+ <p>The logger instance to use for logging.</p>
309
+ </div>
310
+
311
+ </li>
312
+
313
+ </ul>
314
+
315
+
316
+ </div><table class="source_code">
317
+ <tr>
318
+ <td>
319
+ <pre class="lines">
320
+
321
+
322
+ 40
323
+ 41
324
+ 42</pre>
325
+ </td>
326
+ <td>
327
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/modules/loggable.rb', line 40</span>
328
+
329
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">logger=</span> _logger
330
+ <span style="color:#33B">@logger</span> = _logger
331
+ <span style="color:#080;font-weight:bold">end</span></pre>
332
+ </td>
333
+ </tr>
334
+ </table>
335
+ </div>
336
+
337
+ </div>
338
+
339
+ </div>
340
+
341
+
342
+ </div>
343
+ </div>
344
+ </div>
345
+ </body>
346
+ </html>
@@ -0,0 +1,3316 @@
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>Wowza Streaming Cloud - SDK Code Documentation</title>
7
+
8
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
9
+
10
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
11
+
12
+ <link rel="stylesheet" href="../css/custom.css" type="text/css" charset="utf-8" />
13
+
14
+ <script type="text/javascript" charset="utf-8">
15
+ pathId = "WscSdk::Model";
16
+ relpath = '../';
17
+ </script>
18
+
19
+
20
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
23
+
24
+
25
+ </head>
26
+ <body>
27
+ <div id="wowza-wrapper">
28
+ <header>
29
+ <div class="logo">
30
+ <a href="https://www.wowza.com">
31
+ <img src="https://cloud.wowza.com/apidocs/assets/logo.png" alt="Wowza Logo" />
32
+ </a>
33
+ <h1>Wowza Streaming Cloud<br/>SDK Code Documentation</h1>
34
+ <div class="clearfix"></div>
35
+ </div>
36
+ <div class="links">
37
+ <a href="https://www.wowza.com/">Wowza Home</a>
38
+ <a href="https://www.wowza.com/docs">Docs & APIS</a>
39
+ <a href="https://www.wowza.com/community/index.html">Forums</a>
40
+ <a href="https://www.wowza.com/support">Support</a>
41
+ </div>
42
+ <div class="clearfix"></div>
43
+ </header>
44
+
45
+ <div id="content">
46
+ <div class="nav_wrap">
47
+ <iframe id="nav" src="../class_list.html?1"></iframe>
48
+ <div id="resizer"></div>
49
+ </div>
50
+
51
+ <div id="main" tabindex="-1">
52
+ <div id="header">
53
+ <div id="menu">
54
+
55
+ <a href="../_index.html">Index (M)</a> &raquo;
56
+ <span class='title'><span class='object_link'><a href="../WscSdk.html" title="WscSdk (module)">WscSdk</a></span></span>
57
+ &raquo;
58
+ <span class="title">Model</span>
59
+
60
+ </div>
61
+
62
+ <div id="search">
63
+
64
+ <a class="full_list_link" id="class_list_link"
65
+ href="../class_list.html">
66
+
67
+ <svg width="24" height="24">
68
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
69
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
70
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
71
+ </svg>
72
+ </a>
73
+
74
+ </div>
75
+ <div class="clear"></div>
76
+ </div>
77
+
78
+ <div id="content"><h1>Class: WscSdk::Model
79
+
80
+
81
+
82
+ </h1>
83
+ <div class="box_info">
84
+
85
+ <dl>
86
+ <dt>Inherits:</dt>
87
+ <dd>
88
+ <span class="inheritName">Object</span>
89
+
90
+ <ul class="fullTree">
91
+ <li>Object</li>
92
+
93
+ <li class="next">WscSdk::Model</li>
94
+
95
+ </ul>
96
+ <a href="#" class="inheritanceTree">show all</a>
97
+
98
+ </dd>
99
+ </dl>
100
+
101
+
102
+
103
+
104
+
105
+
106
+ <dl>
107
+ <dt>Includes:</dt>
108
+ <dd><span class='object_link'><a href="ApiResponse.html" title="WscSdk::ApiResponse (module)">ApiResponse</a></span>, <span class='object_link'><a href="Loggable.html" title="WscSdk::Loggable (module)">Loggable</a></span></dd>
109
+ </dl>
110
+
111
+
112
+
113
+
114
+
115
+
116
+ <dl>
117
+ <dt>Defined in:</dt>
118
+ <dd>lib/wsc_sdk/model.rb</dd>
119
+ </dl>
120
+
121
+ </div>
122
+
123
+ <h2>Overview</h2><div class="docstring">
124
+ <div class="discussion">
125
+
126
+ <p>Base class for defining model schemas and managing inbound/outbound model
127
+ data.</p>
128
+
129
+
130
+ </div>
131
+ </div>
132
+ <div class="tags">
133
+
134
+
135
+ </div><div id="subclasses">
136
+ <h2>Direct Known Subclasses</h2>
137
+ <p class="children"><span class='object_link'><a href="Models/CustomStreamTarget.html" title="WscSdk::Models::CustomStreamTarget (class)">WscSdk::Models::CustomStreamTarget</a></span>, <span class='object_link'><a href="Models/Error.html" title="WscSdk::Models::Error (class)">WscSdk::Models::Error</a></span>, <span class='object_link'><a href="Models/LiveStream.html" title="WscSdk::Models::LiveStream (class)">WscSdk::Models::LiveStream</a></span>, <span class='object_link'><a href="Models/LiveStreamConnectionCode.html" title="WscSdk::Models::LiveStreamConnectionCode (class)">WscSdk::Models::LiveStreamConnectionCode</a></span>, <span class='object_link'><a href="Models/Output.html" title="WscSdk::Models::Output (class)">WscSdk::Models::Output</a></span>, <span class='object_link'><a href="Models/OutputStreamTarget.html" title="WscSdk::Models::OutputStreamTarget (class)">WscSdk::Models::OutputStreamTarget</a></span>, <span class='object_link'><a href="Models/StreamTarget.html" title="WscSdk::Models::StreamTarget (class)">WscSdk::Models::StreamTarget</a></span>, <span class='object_link'><a href="Models/Transcoder.html" title="WscSdk::Models::Transcoder (class)">WscSdk::Models::Transcoder</a></span>, <span class='object_link'><a href="Models/TranscoderBooleanStat.html" title="WscSdk::Models::TranscoderBooleanStat (class)">WscSdk::Models::TranscoderBooleanStat</a></span>, <span class='object_link'><a href="Models/TranscoderConnectionCode.html" title="WscSdk::Models::TranscoderConnectionCode (class)">WscSdk::Models::TranscoderConnectionCode</a></span>, <span class='object_link'><a href="Models/TranscoderFloatStat.html" title="WscSdk::Models::TranscoderFloatStat (class)">WscSdk::Models::TranscoderFloatStat</a></span>, <span class='object_link'><a href="Models/TranscoderIntegerStat.html" title="WscSdk::Models::TranscoderIntegerStat (class)">WscSdk::Models::TranscoderIntegerStat</a></span>, <span class='object_link'><a href="Models/TranscoderState.html" title="WscSdk::Models::TranscoderState (class)">WscSdk::Models::TranscoderState</a></span>, <span class='object_link'><a href="Models/TranscoderStats.html" title="WscSdk::Models::TranscoderStats (class)">WscSdk::Models::TranscoderStats</a></span>, <span class='object_link'><a href="Models/TranscoderStreamTargetState.html" title="WscSdk::Models::TranscoderStreamTargetState (class)">WscSdk::Models::TranscoderStreamTargetState</a></span>, <span class='object_link'><a href="Models/TranscoderStringStat.html" title="WscSdk::Models::TranscoderStringStat (class)">WscSdk::Models::TranscoderStringStat</a></span>, <span class='object_link'><a href="Models/TranscoderThumbnailUrl.html" title="WscSdk::Models::TranscoderThumbnailUrl (class)">WscSdk::Models::TranscoderThumbnailUrl</a></span>, <span class='object_link'><a href="Models/UllStreamTarget.html" title="WscSdk::Models::UllStreamTarget (class)">WscSdk::Models::UllStreamTarget</a></span>, <span class='object_link'><a href="Models/WowzaStreamTarget.html" title="WscSdk::Models::WowzaStreamTarget (class)">WscSdk::Models::WowzaStreamTarget</a></span></p>
138
+ </div>
139
+
140
+
141
+
142
+
143
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
144
+ <ul class="summary">
145
+
146
+ <li class="public ">
147
+ <span class="summary_signature">
148
+
149
+ <a href="#attributes-instance_method" title="#attributes (instance method)">#<strong>attributes</strong> &#x21d2; Object </a>
150
+
151
+
152
+
153
+ </span>
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+ <span class="summary_desc"><div class='inline'>
167
+ <p>A hash of attributes and values for the model.</p>
168
+ </div></span>
169
+
170
+ </li>
171
+
172
+
173
+ <li class="public ">
174
+ <span class="summary_signature">
175
+
176
+ <a href="#changes-instance_method" title="#changes (instance method)">#<strong>changes</strong> &#x21d2; Object </a>
177
+
178
+
179
+
180
+ </span>
181
+
182
+
183
+
184
+
185
+ <span class="note title readonly">readonly</span>
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'>
196
+ <p>An array of fields that have changed since the model was last saved to the
197
+ API.</p>
198
+ </div></span>
199
+
200
+ </li>
201
+
202
+
203
+ <li class="public ">
204
+ <span class="summary_signature">
205
+
206
+ <a href="#data_mode-instance_method" title="#data_mode (instance method)">#<strong>data_mode</strong> &#x21d2; Object </a>
207
+
208
+
209
+
210
+ </span>
211
+
212
+
213
+
214
+
215
+ <span class="note title readonly">readonly</span>
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ <span class="summary_desc"><div class='inline'>
226
+ <p>Determines what mode the data is being ingested/accesed in.</p>
227
+ </div></span>
228
+
229
+ </li>
230
+
231
+
232
+ <li class="public ">
233
+ <span class="summary_signature">
234
+
235
+ <a href="#endpoint-instance_method" title="#endpoint (instance method)">#<strong>endpoint</strong> &#x21d2; Object </a>
236
+
237
+
238
+
239
+ </span>
240
+
241
+
242
+
243
+
244
+ <span class="note title readonly">readonly</span>
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+ <span class="summary_desc"><div class='inline'>
255
+ <p>The endpoint that generated the model.</p>
256
+ </div></span>
257
+
258
+ </li>
259
+
260
+
261
+ <li class="public ">
262
+ <span class="summary_signature">
263
+
264
+ <a href="#errors-instance_method" title="#errors (instance method)">#<strong>errors</strong> &#x21d2; Object </a>
265
+
266
+
267
+
268
+ </span>
269
+
270
+
271
+
272
+
273
+ <span class="note title readonly">readonly</span>
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+ <span class="summary_desc"><div class='inline'>
284
+ <p>A hash of fields and messages that indicates validation errors for the
285
+ model.</p>
286
+ </div></span>
287
+
288
+ </li>
289
+
290
+
291
+ <li class="public ">
292
+ <span class="summary_signature">
293
+
294
+ <a href="#partial_data-instance_method" title="#partial_data (instance method)">#<strong>partial_data</strong> &#x21d2; Object </a>
295
+
296
+
297
+
298
+ </span>
299
+
300
+
301
+
302
+
303
+ <span class="note title readonly">readonly</span>
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+ <span class="summary_desc"><div class='inline'>
314
+ <p>Determines if the model contains a partial or complete dataset.</p>
315
+ </div></span>
316
+
317
+ </li>
318
+
319
+
320
+ </ul>
321
+
322
+
323
+
324
+
325
+
326
+ <h2>
327
+ Class Method Summary
328
+ <small><a href="#" class="summary_toggle">collapse</a></small>
329
+ </h2>
330
+
331
+ <ul class="summary">
332
+
333
+ <li class="public ">
334
+ <span class="summary_signature">
335
+
336
+ <a href="#attribute-class_method" title="attribute (class method)">.<strong>attribute</strong>(name, type, options = {}) &#x21d2; Object </a>
337
+
338
+
339
+
340
+ </span>
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+ <span class="summary_desc"><div class='inline'>
351
+ <p>Defines an attribute in the model schema and establishes the appropriate
352
+ getters/setters according to its access settings.</p>
353
+ </div></span>
354
+
355
+ </li>
356
+
357
+
358
+ <li class="public ">
359
+ <span class="summary_signature">
360
+
361
+ <a href="#model_name_plural-class_method" title="model_name_plural (class method)">.<strong>model_name_plural</strong>(wrapper) &#x21d2; Object </a>
362
+
363
+
364
+
365
+ </span>
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+ <span class="summary_desc"><div class='inline'>
376
+ <p>Builds the `plural_name` static method that will return the name of the
377
+ model in plural form.</p>
378
+ </div></span>
379
+
380
+ </li>
381
+
382
+
383
+ <li class="public ">
384
+ <span class="summary_signature">
385
+
386
+ <a href="#model_name_singular-class_method" title="model_name_singular (class method)">.<strong>model_name_singular</strong>(wrapper) &#x21d2; Object </a>
387
+
388
+
389
+
390
+ </span>
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+ <span class="summary_desc"><div class='inline'>
401
+ <p>Builds the `singular_name` static method that will return the name of the
402
+ model in singular form.</p>
403
+ </div></span>
404
+
405
+ </li>
406
+
407
+
408
+ <li class="public ">
409
+ <span class="summary_signature">
410
+
411
+ <a href="#primary_key-class_method" title="primary_key (class method)">.<strong>primary_key</strong>(attribute_name) &#x21d2; Object </a>
412
+
413
+
414
+
415
+ </span>
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+ <span class="summary_desc"><div class='inline'>
426
+ <p>Rebuilds the `primary_key_attribute` method in the class to identify an
427
+ attribute other than the default as the primary key.</p>
428
+ </div></span>
429
+
430
+ </li>
431
+
432
+
433
+ <li class="public ">
434
+ <span class="summary_signature">
435
+
436
+ <a href="#schema-class_method" title="schema (class method)">.<strong>schema</strong> &#x21d2; Object </a>
437
+
438
+
439
+
440
+ </span>
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+ <span class="summary_desc"><div class='inline'>
451
+ <p>Defines the default schema structure.</p>
452
+ </div></span>
453
+
454
+ </li>
455
+
456
+
457
+ </ul>
458
+
459
+ <h2>
460
+ Instance Method Summary
461
+ <small><a href="#" class="summary_toggle">collapse</a></small>
462
+ </h2>
463
+
464
+ <ul class="summary">
465
+
466
+ <li class="public ">
467
+ <span class="summary_signature">
468
+
469
+ <a href="#add_error-instance_method" title="#add_error (instance method)">#<strong>add_error</strong>(attribute, message) &#x21d2; Object </a>
470
+
471
+
472
+
473
+ </span>
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+ <span class="summary_desc"><div class='inline'>
484
+ <p>Adds an error message to the errors hash.</p>
485
+ </div></span>
486
+
487
+ </li>
488
+
489
+
490
+ <li class="public ">
491
+ <span class="summary_signature">
492
+
493
+ <a href="#build_payload-instance_method" title="#build_payload (instance method)">#<strong>build_payload</strong> &#x21d2; Hash </a>
494
+
495
+
496
+
497
+ </span>
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+ <span class="summary_desc"><div class='inline'>
508
+ <p>Build the request payload.</p>
509
+ </div></span>
510
+
511
+ </li>
512
+
513
+
514
+ <li class="public ">
515
+ <span class="summary_signature">
516
+
517
+ <a href="#build_payload!-instance_method" title="#build_payload! (instance method)">#<strong>build_payload!</strong> &#x21d2; Hash </a>
518
+
519
+
520
+
521
+ </span>
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+ <span class="summary_desc"><div class='inline'>
532
+ <p>Build the request payload, or generate an exception if the data is not
533
+ valid.</p>
534
+ </div></span>
535
+
536
+ </li>
537
+
538
+
539
+ <li class="public ">
540
+ <span class="summary_signature">
541
+
542
+ <a href="#clean!-instance_method" title="#clean! (instance method)">#<strong>clean!</strong> &#x21d2; Object </a>
543
+
544
+
545
+
546
+ </span>
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+ <span class="summary_desc"><div class='inline'>
557
+ <p>Cleans out the changes array, which means that the data is no longer marked
558
+ as dirty.</p>
559
+ </div></span>
560
+
561
+ </li>
562
+
563
+
564
+ <li class="public ">
565
+ <span class="summary_signature">
566
+
567
+ <a href="#clear_primary_key-instance_method" title="#clear_primary_key (instance method)">#<strong>clear_primary_key</strong> &#x21d2; Object </a>
568
+
569
+
570
+
571
+ </span>
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+ <span class="summary_desc"><div class='inline'>
582
+ <p>Clear the primary key value.</p>
583
+ </div></span>
584
+
585
+ </li>
586
+
587
+
588
+ <li class="public ">
589
+ <span class="summary_signature">
590
+
591
+ <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> &#x21d2; WscSdk::Model, Nil </a>
592
+
593
+
594
+
595
+ </span>
596
+
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+ <span class="summary_desc"><div class='inline'>
606
+ <p>Delete the model data from the api.</p>
607
+ </div></span>
608
+
609
+ </li>
610
+
611
+
612
+ <li class="public ">
613
+ <span class="summary_signature">
614
+
615
+ <a href="#dirty%3F-instance_method" title="#dirty? (instance method)">#<strong>dirty?</strong> &#x21d2; Boolean </a>
616
+
617
+
618
+
619
+ </span>
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+ <span class="summary_desc"><div class='inline'>
630
+ <p>Determines if the data is dirty or not based on whether changes have been
631
+ marked in the changes array.</p>
632
+ </div></span>
633
+
634
+ </li>
635
+
636
+
637
+ <li class="public ">
638
+ <span class="summary_signature">
639
+
640
+ <a href="#has_attribute%3F-instance_method" title="#has_attribute? (instance method)">#<strong>has_attribute?</strong>(attribute) &#x21d2; Boolean </a>
641
+
642
+
643
+
644
+ </span>
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+ <span class="summary_desc"><div class='inline'>
655
+ <p>Determines if an attribute names exists in the schema.</p>
656
+ </div></span>
657
+
658
+ </li>
659
+
660
+
661
+ <li class="public ">
662
+ <span class="summary_signature">
663
+
664
+ <a href="#ingest_attribute-instance_method" title="#ingest_attribute (instance method)">#<strong>ingest_attribute</strong>(attribute, value, options = {}) &#x21d2; Object </a>
665
+
666
+
667
+
668
+ </span>
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+ <span class="summary_desc"><div class='inline'>
679
+ <p>Load an attribute value into the attributes hash and ensure that it meets
680
+ the requirements of the schema.</p>
681
+ </div></span>
682
+
683
+ </li>
684
+
685
+
686
+ <li class="public ">
687
+ <span class="summary_signature">
688
+
689
+ <a href="#ingest_attributes-instance_method" title="#ingest_attributes (instance method)">#<strong>ingest_attributes</strong>(attributes, options = {}) &#x21d2; Object </a>
690
+
691
+
692
+
693
+ </span>
694
+
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+ <span class="summary_desc"><div class='inline'>
704
+ <p>Load data into the attributes hash and ensure that it meets the
705
+ requirements of the schema.</p>
706
+ </div></span>
707
+
708
+ </li>
709
+
710
+
711
+ <li class="public ">
712
+ <span class="summary_signature">
713
+
714
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(endpoint, attributes = {}) &#x21d2; Model </a>
715
+
716
+
717
+
718
+ </span>
719
+
720
+
721
+ <span class="note title constructor">constructor</span>
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+ <span class="summary_desc"><div class='inline'>
731
+ <p>Create a new model instance.</p>
732
+ </div></span>
733
+
734
+ </li>
735
+
736
+
737
+ <li class="public ">
738
+ <span class="summary_signature">
739
+
740
+ <a href="#initialize_attributes-instance_method" title="#initialize_attributes (instance method)">#<strong>initialize_attributes</strong> &#x21d2; Object </a>
741
+
742
+
743
+
744
+ </span>
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+ <span class="summary_desc"><div class='inline'>
755
+ <p>Build the attributes hash from the schema definitions.</p>
756
+ </div></span>
757
+
758
+ </li>
759
+
760
+
761
+ <li class="public ">
762
+ <span class="summary_signature">
763
+
764
+ <a href="#new_model%3F-instance_method" title="#new_model? (instance method)">#<strong>new_model?</strong> &#x21d2; Boolean </a>
765
+
766
+
767
+
768
+ </span>
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+ <span class="summary_desc"><div class='inline'>
779
+ <p>Determine if the model data is new or not.</p>
780
+ </div></span>
781
+
782
+ </li>
783
+
784
+
785
+ <li class="public ">
786
+ <span class="summary_signature">
787
+
788
+ <a href="#primary_key-instance_method" title="#primary_key (instance method)">#<strong>primary_key</strong> &#x21d2; Any </a>
789
+
790
+
791
+
792
+ </span>
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+ <span class="summary_desc"><div class='inline'>
803
+ <p>Get the value of the primary key attribute.</p>
804
+ </div></span>
805
+
806
+ </li>
807
+
808
+
809
+ <li class="public ">
810
+ <span class="summary_signature">
811
+
812
+ <a href="#primary_key_attribute-instance_method" title="#primary_key_attribute (instance method)">#<strong>primary_key_attribute</strong> &#x21d2; Symbol </a>
813
+
814
+
815
+
816
+ </span>
817
+
818
+
819
+
820
+
821
+
822
+
823
+
824
+
825
+
826
+ <span class="summary_desc"><div class='inline'>
827
+ <p>Get the name of the attribute that represents the primary key of the model.</p>
828
+ </div></span>
829
+
830
+ </li>
831
+
832
+
833
+ <li class="public ">
834
+ <span class="summary_signature">
835
+
836
+ <a href="#refresh-instance_method" title="#refresh (instance method)">#<strong>refresh</strong> &#x21d2; WscSdk::Model </a>
837
+
838
+
839
+
840
+ </span>
841
+
842
+
843
+
844
+
845
+
846
+
847
+
848
+
849
+
850
+ <span class="summary_desc"><div class='inline'>
851
+ <p>Refresh the data in the model from the API.</p>
852
+ </div></span>
853
+
854
+ </li>
855
+
856
+
857
+ <li class="public ">
858
+ <span class="summary_signature">
859
+
860
+ <a href="#save-instance_method" title="#save (instance method)">#<strong>save</strong> &#x21d2; WscSdk::Model, Nil </a>
861
+
862
+
863
+
864
+ </span>
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
874
+ <span class="summary_desc"><div class='inline'>
875
+ <p>Save the data in the model to the api.</p>
876
+ </div></span>
877
+
878
+ </li>
879
+
880
+
881
+ <li class="public ">
882
+ <span class="summary_signature">
883
+
884
+ <a href="#schema-instance_method" title="#schema (instance method)">#<strong>schema</strong> &#x21d2; WscSdk::Schema </a>
885
+
886
+
887
+
888
+ </span>
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+ <span class="summary_desc"><div class='inline'>
899
+ <p>Get the current schema definition.</p>
900
+ </div></span>
901
+
902
+ </li>
903
+
904
+
905
+ <li class="public ">
906
+ <span class="summary_signature">
907
+
908
+ <a href="#success%3F-instance_method" title="#success? (instance method)">#<strong>success?</strong> &#x21d2; Boolean </a>
909
+
910
+
911
+
912
+ </span>
913
+
914
+
915
+
916
+
917
+
918
+
919
+
920
+
921
+
922
+ <span class="summary_desc"><div class='inline'>
923
+ <p>Return the success status of the API call that generated this model.</p>
924
+ </div></span>
925
+
926
+ </li>
927
+
928
+
929
+ <li class="public ">
930
+ <span class="summary_signature">
931
+
932
+ <a href="#valid!-instance_method" title="#valid! (instance method)">#<strong>valid!</strong> &#x21d2; Object </a>
933
+
934
+
935
+
936
+ </span>
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+ <span class="summary_desc"><div class='inline'>
947
+ <p>Determine if the model data is valid and raise an exception if its not.</p>
948
+ </div></span>
949
+
950
+ </li>
951
+
952
+
953
+ <li class="public ">
954
+ <span class="summary_signature">
955
+
956
+ <a href="#valid%3F-instance_method" title="#valid? (instance method)">#<strong>valid?</strong> &#x21d2; Boolean </a>
957
+
958
+
959
+
960
+ </span>
961
+
962
+
963
+
964
+
965
+
966
+
967
+
968
+
969
+
970
+ <span class="summary_desc"><div class='inline'>
971
+ <p>Determine if the model data is valid.</p>
972
+ </div></span>
973
+
974
+ </li>
975
+
976
+
977
+ <li class="public ">
978
+ <span class="summary_signature">
979
+
980
+ <a href="#validate-instance_method" title="#validate (instance method)">#<strong>validate</strong> &#x21d2; Object </a>
981
+
982
+
983
+
984
+ </span>
985
+
986
+
987
+
988
+
989
+
990
+
991
+
992
+
993
+
994
+ <span class="summary_desc"><div class='inline'>
995
+ <p>Validate the model data.</p>
996
+ </div></span>
997
+
998
+ </li>
999
+
1000
+
1001
+ </ul>
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Loggable.html" title="WscSdk::Loggable (module)">Loggable</a></span></h3>
1014
+ <p class="inherited"><span class='object_link'><a href="Loggable.html#logger-instance_method" title="WscSdk::Loggable#logger (method)">#logger</a></span>, <span class='object_link'><a href="Loggable.html#logger=-instance_method" title="WscSdk::Loggable#logger= (method)">#logger=</a></span></p>
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+ <div id="constructor_details" class="method_details_list">
1022
+ <h2>Constructor Details</h2>
1023
+
1024
+ <div class="method_details first">
1025
+ <h3 class="signature first" id="initialize-instance_method">
1026
+
1027
+ #<strong>initialize</strong>(endpoint, attributes = {}) &#x21d2; <tt><span class='object_link'><a href="" title="WscSdk::Model (class)">Model</a></span></tt>
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+ </h3><div class="docstring">
1034
+ <div class="discussion">
1035
+
1036
+ <p>Create a new model instance.</p>
1037
+
1038
+
1039
+ </div>
1040
+ </div>
1041
+ <div class="tags">
1042
+ <p class="tag_title">Parameters:</p>
1043
+ <ul class="param">
1044
+
1045
+ <li>
1046
+
1047
+ <span class='name'>endpoint</span>
1048
+
1049
+
1050
+ <span class='type'>(<tt><span class='object_link'><a href="Endpoint.html" title="WscSdk::Endpoint (class)">WscSdk::Endpoint</a></span></tt>)</span>
1051
+
1052
+
1053
+
1054
+ &mdash;
1055
+ <div class='inline'>
1056
+ <p>The endpoint instance that generated the model.</p>
1057
+ </div>
1058
+
1059
+ </li>
1060
+
1061
+ <li>
1062
+
1063
+ <span class='name'>attributes</span>
1064
+
1065
+
1066
+ <span class='type'>(<tt>Hash</tt>)</span>
1067
+
1068
+
1069
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1070
+
1071
+
1072
+ &mdash;
1073
+ <div class='inline'>
1074
+ <p>A hash of attribute values to assign to the model.</p>
1075
+ </div>
1076
+
1077
+ </li>
1078
+
1079
+ </ul>
1080
+
1081
+
1082
+ </div><table class="source_code">
1083
+ <tr>
1084
+ <td>
1085
+ <pre class="lines">
1086
+
1087
+
1088
+ 66
1089
+ 67
1090
+ 68
1091
+ 69
1092
+ 70
1093
+ 71
1094
+ 72
1095
+ 73
1096
+ 74
1097
+ 75</pre>
1098
+ </td>
1099
+ <td>
1100
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 66</span>
1101
+
1102
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">initialize</span>(endpoint, attributes={})
1103
+ <span style="color:#33B">@endpoint</span> = endpoint
1104
+ <span style="color:#33B">@changes</span> = []
1105
+ <span style="color:#33B">@partial_data</span> = <span style="color:#069">false</span>
1106
+ <span style="color:#33B">@data_mode</span> = <span style="color:#A60">:access</span>
1107
+ initialize_attributes
1108
+ ingest_attributes(attributes, <span style="color:#606">write_to_read_only</span>: <span style="color:#069">true</span>, <span style="color:#606">mark_clean</span>: <span style="color:#069">true</span>)
1109
+ <span style="color:#33B">@errors</span> = <span style="color:#069">nil</span>
1110
+ <span style="color:#33B">@dirty</span> = <span style="color:#069">false</span>
1111
+ <span style="color:#080;font-weight:bold">end</span></pre>
1112
+ </td>
1113
+ </tr>
1114
+ </table>
1115
+ </div>
1116
+
1117
+ </div>
1118
+
1119
+ <div id="instance_attr_details" class="attr_details">
1120
+ <h2>Instance Attribute Details</h2>
1121
+
1122
+
1123
+ <span id="attributes=-instance_method"></span>
1124
+ <div class="method_details first">
1125
+ <h3 class="signature first" id="attributes-instance_method">
1126
+
1127
+ #<strong>attributes</strong> &#x21d2; <tt>Object</tt>
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+ </h3><div class="docstring">
1134
+ <div class="discussion">
1135
+
1136
+
1137
+ </div>
1138
+ </div>
1139
+ <div class="tags">
1140
+
1141
+ <div class="docstring">
1142
+ <div class="discussion">
1143
+
1144
+ <p>A hash of attributes and values for the model</p>
1145
+
1146
+ <p><strong>NOTE:</strong> The attributes accessor directly accesses the
1147
+ attributes for a model. This is okay for reading data out of a model, but
1148
+ data assignment should be done using the getter (model.attribute) and
1149
+ setter (model.attribute=value) methods that are built into the model.
1150
+ Otherwise you will be bypassing the structures necessary to validate the
1151
+ data, which may generate unwanted outcomes.</p>
1152
+
1153
+
1154
+ </div>
1155
+ </div>
1156
+ <div class="tags">
1157
+
1158
+
1159
+ </div>
1160
+
1161
+
1162
+ </div><table class="source_code">
1163
+ <tr>
1164
+ <td>
1165
+ <pre class="lines">
1166
+
1167
+
1168
+ 32
1169
+ 33
1170
+ 34</pre>
1171
+ </td>
1172
+ <td>
1173
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 32</span>
1174
+
1175
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">attributes</span>
1176
+ <span style="color:#33B">@attributes</span>
1177
+ <span style="color:#080;font-weight:bold">end</span></pre>
1178
+ </td>
1179
+ </tr>
1180
+ </table>
1181
+ </div>
1182
+
1183
+
1184
+ <span id=""></span>
1185
+ <div class="method_details ">
1186
+ <h3 class="signature " id="changes-instance_method">
1187
+
1188
+ #<strong>changes</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+ </h3><div class="docstring">
1195
+ <div class="discussion">
1196
+
1197
+
1198
+ </div>
1199
+ </div>
1200
+ <div class="tags">
1201
+
1202
+ <div class="docstring">
1203
+ <div class="discussion">
1204
+
1205
+ <p>An array of fields that have changed since the model was last saved to the
1206
+ API.</p>
1207
+
1208
+
1209
+ </div>
1210
+ </div>
1211
+ <div class="tags">
1212
+
1213
+
1214
+ </div>
1215
+
1216
+
1217
+ </div><table class="source_code">
1218
+ <tr>
1219
+ <td>
1220
+ <pre class="lines">
1221
+
1222
+
1223
+ 48
1224
+ 49
1225
+ 50</pre>
1226
+ </td>
1227
+ <td>
1228
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 48</span>
1229
+
1230
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">changes</span>
1231
+ <span style="color:#33B">@changes</span>
1232
+ <span style="color:#080;font-weight:bold">end</span></pre>
1233
+ </td>
1234
+ </tr>
1235
+ </table>
1236
+ </div>
1237
+
1238
+
1239
+ <span id=""></span>
1240
+ <div class="method_details ">
1241
+ <h3 class="signature " id="data_mode-instance_method">
1242
+
1243
+ #<strong>data_mode</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
1244
+
1245
+
1246
+
1247
+
1248
+
1249
+ </h3><div class="docstring">
1250
+ <div class="discussion">
1251
+
1252
+
1253
+ </div>
1254
+ </div>
1255
+ <div class="tags">
1256
+
1257
+ <div class="docstring">
1258
+ <div class="discussion">
1259
+
1260
+ <p>Determines what mode the data is being ingested/accesed in.</p>
1261
+
1262
+
1263
+ </div>
1264
+ </div>
1265
+ <div class="tags">
1266
+
1267
+
1268
+ </div>
1269
+
1270
+
1271
+ </div><table class="source_code">
1272
+ <tr>
1273
+ <td>
1274
+ <pre class="lines">
1275
+
1276
+
1277
+ 56
1278
+ 57
1279
+ 58</pre>
1280
+ </td>
1281
+ <td>
1282
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 56</span>
1283
+
1284
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">data_mode</span>
1285
+ <span style="color:#33B">@data_mode</span>
1286
+ <span style="color:#080;font-weight:bold">end</span></pre>
1287
+ </td>
1288
+ </tr>
1289
+ </table>
1290
+ </div>
1291
+
1292
+
1293
+ <span id=""></span>
1294
+ <div class="method_details ">
1295
+ <h3 class="signature " id="endpoint-instance_method">
1296
+
1297
+ #<strong>endpoint</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+ </h3><div class="docstring">
1304
+ <div class="discussion">
1305
+
1306
+
1307
+ </div>
1308
+ </div>
1309
+ <div class="tags">
1310
+
1311
+ <div class="docstring">
1312
+ <div class="discussion">
1313
+
1314
+ <p>The endpoint that generated the model.</p>
1315
+
1316
+
1317
+ </div>
1318
+ </div>
1319
+ <div class="tags">
1320
+
1321
+
1322
+ </div>
1323
+
1324
+
1325
+ </div><table class="source_code">
1326
+ <tr>
1327
+ <td>
1328
+ <pre class="lines">
1329
+
1330
+
1331
+ 43
1332
+ 44
1333
+ 45</pre>
1334
+ </td>
1335
+ <td>
1336
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 43</span>
1337
+
1338
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">endpoint</span>
1339
+ <span style="color:#33B">@endpoint</span>
1340
+ <span style="color:#080;font-weight:bold">end</span></pre>
1341
+ </td>
1342
+ </tr>
1343
+ </table>
1344
+ </div>
1345
+
1346
+
1347
+ <span id=""></span>
1348
+ <div class="method_details ">
1349
+ <h3 class="signature " id="errors-instance_method">
1350
+
1351
+ #<strong>errors</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
1352
+
1353
+
1354
+
1355
+
1356
+
1357
+ </h3><div class="docstring">
1358
+ <div class="discussion">
1359
+
1360
+
1361
+ </div>
1362
+ </div>
1363
+ <div class="tags">
1364
+
1365
+ <div class="docstring">
1366
+ <div class="discussion">
1367
+
1368
+ <p>A hash of fields and messages that indicates validation errors for the
1369
+ model. Use `model.valid?` if the response is false, this hash will contain
1370
+ the information necessary to fix the concerns.</p>
1371
+
1372
+
1373
+ </div>
1374
+ </div>
1375
+ <div class="tags">
1376
+
1377
+
1378
+ </div>
1379
+
1380
+
1381
+ </div><table class="source_code">
1382
+ <tr>
1383
+ <td>
1384
+ <pre class="lines">
1385
+
1386
+
1387
+ 39
1388
+ 40
1389
+ 41</pre>
1390
+ </td>
1391
+ <td>
1392
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 39</span>
1393
+
1394
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">errors</span>
1395
+ <span style="color:#33B">@errors</span>
1396
+ <span style="color:#080;font-weight:bold">end</span></pre>
1397
+ </td>
1398
+ </tr>
1399
+ </table>
1400
+ </div>
1401
+
1402
+
1403
+ <span id=""></span>
1404
+ <div class="method_details ">
1405
+ <h3 class="signature " id="partial_data-instance_method">
1406
+
1407
+ #<strong>partial_data</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
1408
+
1409
+
1410
+
1411
+
1412
+
1413
+ </h3><div class="docstring">
1414
+ <div class="discussion">
1415
+
1416
+
1417
+ </div>
1418
+ </div>
1419
+ <div class="tags">
1420
+
1421
+ <div class="docstring">
1422
+ <div class="discussion">
1423
+
1424
+ <p>Determines if the model contains a partial or complete dataset.</p>
1425
+
1426
+
1427
+ </div>
1428
+ </div>
1429
+ <div class="tags">
1430
+
1431
+
1432
+ </div>
1433
+
1434
+
1435
+ </div><table class="source_code">
1436
+ <tr>
1437
+ <td>
1438
+ <pre class="lines">
1439
+
1440
+
1441
+ 52
1442
+ 53
1443
+ 54</pre>
1444
+ </td>
1445
+ <td>
1446
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 52</span>
1447
+
1448
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">partial_data</span>
1449
+ <span style="color:#33B">@partial_data</span>
1450
+ <span style="color:#080;font-weight:bold">end</span></pre>
1451
+ </td>
1452
+ </tr>
1453
+ </table>
1454
+ </div>
1455
+
1456
+ </div>
1457
+
1458
+
1459
+ <div id="class_method_details" class="method_details_list">
1460
+ <h2>Class Method Details</h2>
1461
+
1462
+
1463
+ <div class="method_details first">
1464
+ <h3 class="signature first" id="attribute-class_method">
1465
+
1466
+ .<strong>attribute</strong>(name, type, options = {}) &#x21d2; <tt>Object</tt>
1467
+
1468
+
1469
+
1470
+
1471
+
1472
+ </h3><div class="docstring">
1473
+ <div class="discussion">
1474
+
1475
+ <p>Defines an attribute in the model schema and establishes the appropriate
1476
+ getters/setters according to its access settings.</p>
1477
+
1478
+
1479
+ </div>
1480
+ </div>
1481
+ <div class="tags">
1482
+
1483
+
1484
+ </div><table class="source_code">
1485
+ <tr>
1486
+ <td>
1487
+ <pre class="lines">
1488
+
1489
+
1490
+ 477
1491
+ 478
1492
+ 479
1493
+ 480
1494
+ 481
1495
+ 482
1496
+ 483
1497
+ 484
1498
+ 485
1499
+ 486
1500
+ 487
1501
+ 488
1502
+ 489
1503
+ 490
1504
+ 491
1505
+ 492
1506
+ 493
1507
+ 494
1508
+ 495
1509
+ 496
1510
+ 497
1511
+ 498
1512
+ 499
1513
+ 500
1514
+ 501
1515
+ 502
1516
+ 503
1517
+ 504
1518
+ 505
1519
+ 506
1520
+ 507
1521
+ 508
1522
+ 509
1523
+ 510
1524
+ 511
1525
+ 512</pre>
1526
+ </td>
1527
+ <td>
1528
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 477</span>
1529
+
1530
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">attribute</span>(name, type, options={})
1531
+ name = name.to_sym
1532
+ accessor_name = options.fetch(<span style="color:#A60">:as</span>, name).to_sym
1533
+ type = type.to_sym
1534
+ current_schema = <span style="color:#069">self</span>.schema
1535
+ attr = current_schema.add_attribute(name, type, options)
1536
+
1537
+ define_singleton_method <span style="color:#A60">:schema</span> <span style="color:#080;font-weight:bold">do</span>
1538
+ current_schema
1539
+ <span style="color:#080;font-weight:bold">end</span>
1540
+
1541
+ define_method accessor_name <span style="color:#080;font-weight:bold">do</span>
1542
+ raise ::<span style="color:#036;font-weight:bold">NoMethodError</span>.new(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">the '</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>accessor_name<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">' attribute is not currently readable</span><span style="color:#710">&quot;</span></span>) <span style="color:#080;font-weight:bold">unless</span> schema[name].read_access?(<span style="color:#069">self</span>)
1543
+ current_value = <span style="color:#33B">@attributes</span>[name.to_sym]
1544
+ request_remaining_data <span style="color:#080;font-weight:bold">if</span> (<span style="color:#33B">@partial_data</span> <span style="color:#080;font-weight:bold">and</span> current_value.nil?)
1545
+ <span style="color:#33B">@attributes</span>[name.to_sym]
1546
+ <span style="color:#080;font-weight:bold">end</span>
1547
+
1548
+ set_sym = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>accessor_name.to_s<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">=</span><span style="color:#710">&quot;</span></span>.to_sym
1549
+ define_method(set_sym) <span style="color:#080;font-weight:bold">do</span> |value|
1550
+ not_writable = ((<span style="color:#33B">@data_mode</span> == <span style="color:#A60">:access</span>) <span style="color:#080;font-weight:bold">and</span> (!schema[name].write_access?(<span style="color:#069">self</span>)))
1551
+ <span style="color:#080;font-weight:bold">if</span> not_writable
1552
+ logger.warn(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Attempting to write to non-writable attribute: </span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>accessor_name<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>)
1553
+ <span style="color:#080;font-weight:bold">return</span>
1554
+ <span style="color:#080;font-weight:bold">end</span>
1555
+ valid_type = <span style="color:#069">self</span>.class.schema.valid_type?(name, value)
1556
+ <span style="color:#080;font-weight:bold">if</span> valid_type
1557
+ <span style="color:#069">self</span>.attributes[name] = <span style="color:#069">self</span>.class.schema.transform_value(name, <span style="color:#069">self</span>, value)
1558
+ <span style="color:#33B">@errors</span> = <span style="color:#069">nil</span>
1559
+ <span style="color:#33B">@changes</span> &lt;&lt; name
1560
+ <span style="color:#080;font-weight:bold">else</span>
1561
+ logger.warn(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">The attribute '</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>accessor_name.to_s<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">' expected a(n) </span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>type<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20"> value but got '</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>value<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">' [</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>value.class.name<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">] instead!</span><span style="color:#710">&quot;</span></span>)
1562
+ <span style="color:#080;font-weight:bold">end</span>
1563
+ <span style="color:#080;font-weight:bold">end</span>
1564
+
1565
+ <span style="color:#080;font-weight:bold">end</span></pre>
1566
+ </td>
1567
+ </tr>
1568
+ </table>
1569
+ </div>
1570
+
1571
+ <div class="method_details ">
1572
+ <h3 class="signature " id="model_name_plural-class_method">
1573
+
1574
+ .<strong>model_name_plural</strong>(wrapper) &#x21d2; <tt>Object</tt>
1575
+
1576
+
1577
+
1578
+
1579
+
1580
+ </h3><div class="docstring">
1581
+ <div class="discussion">
1582
+
1583
+ <p>Builds the `plural_name` static method that will return the name of the
1584
+ model in plural form.</p>
1585
+
1586
+
1587
+ </div>
1588
+ </div>
1589
+ <div class="tags">
1590
+
1591
+
1592
+ </div><table class="source_code">
1593
+ <tr>
1594
+ <td>
1595
+ <pre class="lines">
1596
+
1597
+
1598
+ 462
1599
+ 463
1600
+ 464
1601
+ 465
1602
+ 466</pre>
1603
+ </td>
1604
+ <td>
1605
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 462</span>
1606
+
1607
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">model_name_plural</span>(wrapper)
1608
+ define_singleton_method <span style="color:#A60">:plural_name</span> <span style="color:#080;font-weight:bold">do</span>
1609
+ wrapper
1610
+ <span style="color:#080;font-weight:bold">end</span>
1611
+ <span style="color:#080;font-weight:bold">end</span></pre>
1612
+ </td>
1613
+ </tr>
1614
+ </table>
1615
+ </div>
1616
+
1617
+ <div class="method_details ">
1618
+ <h3 class="signature " id="model_name_singular-class_method">
1619
+
1620
+ .<strong>model_name_singular</strong>(wrapper) &#x21d2; <tt>Object</tt>
1621
+
1622
+
1623
+
1624
+
1625
+
1626
+ </h3><div class="docstring">
1627
+ <div class="discussion">
1628
+
1629
+ <p>Builds the `singular_name` static method that will return the name of the
1630
+ model in singular form.</p>
1631
+
1632
+
1633
+ </div>
1634
+ </div>
1635
+ <div class="tags">
1636
+
1637
+
1638
+ </div><table class="source_code">
1639
+ <tr>
1640
+ <td>
1641
+ <pre class="lines">
1642
+
1643
+
1644
+ 453
1645
+ 454
1646
+ 455
1647
+ 456
1648
+ 457</pre>
1649
+ </td>
1650
+ <td>
1651
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 453</span>
1652
+
1653
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">model_name_singular</span>(wrapper)
1654
+ define_singleton_method <span style="color:#A60">:singular_name</span> <span style="color:#080;font-weight:bold">do</span>
1655
+ wrapper
1656
+ <span style="color:#080;font-weight:bold">end</span>
1657
+ <span style="color:#080;font-weight:bold">end</span></pre>
1658
+ </td>
1659
+ </tr>
1660
+ </table>
1661
+ </div>
1662
+
1663
+ <div class="method_details ">
1664
+ <h3 class="signature " id="primary_key-class_method">
1665
+
1666
+ .<strong>primary_key</strong>(attribute_name) &#x21d2; <tt>Object</tt>
1667
+
1668
+
1669
+
1670
+
1671
+
1672
+ </h3><div class="docstring">
1673
+ <div class="discussion">
1674
+
1675
+ <p>Rebuilds the `primary_key_attribute` method in the class to identify an
1676
+ attribute other than the default as the primary key</p>
1677
+
1678
+
1679
+ </div>
1680
+ </div>
1681
+ <div class="tags">
1682
+ <p class="tag_title">Parameters:</p>
1683
+ <ul class="param">
1684
+
1685
+ <li>
1686
+
1687
+ <span class='name'>attribute_name</span>
1688
+
1689
+
1690
+ <span class='type'>(<tt>Symbol</tt>)</span>
1691
+
1692
+
1693
+
1694
+ &mdash;
1695
+ <div class='inline'>
1696
+ <p>The name of the attribute to use as the primary key.</p>
1697
+ </div>
1698
+
1699
+ </li>
1700
+
1701
+ </ul>
1702
+
1703
+
1704
+ </div><table class="source_code">
1705
+ <tr>
1706
+ <td>
1707
+ <pre class="lines">
1708
+
1709
+
1710
+ 444
1711
+ 445
1712
+ 446
1713
+ 447
1714
+ 448</pre>
1715
+ </td>
1716
+ <td>
1717
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 444</span>
1718
+
1719
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">primary_key</span>(attribute_name)
1720
+ define_method <span style="color:#A60">:primary_key_attribute</span> <span style="color:#080;font-weight:bold">do</span>
1721
+ <span style="color:#080;font-weight:bold">return</span> attribute_name.to_sym
1722
+ <span style="color:#080;font-weight:bold">end</span>
1723
+ <span style="color:#080;font-weight:bold">end</span></pre>
1724
+ </td>
1725
+ </tr>
1726
+ </table>
1727
+ </div>
1728
+
1729
+ <div class="method_details ">
1730
+ <h3 class="signature " id="schema-class_method">
1731
+
1732
+ .<strong>schema</strong> &#x21d2; <tt>Object</tt>
1733
+
1734
+
1735
+
1736
+
1737
+
1738
+ </h3><div class="docstring">
1739
+ <div class="discussion">
1740
+
1741
+ <p>Defines the default schema structure.</p>
1742
+
1743
+
1744
+ </div>
1745
+ </div>
1746
+ <div class="tags">
1747
+
1748
+
1749
+ </div><table class="source_code">
1750
+ <tr>
1751
+ <td>
1752
+ <pre class="lines">
1753
+
1754
+
1755
+ 470
1756
+ 471
1757
+ 472</pre>
1758
+ </td>
1759
+ <td>
1760
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 470</span>
1761
+
1762
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">schema</span>
1763
+ <span style="color:#036;font-weight:bold">Schema</span>.new
1764
+ <span style="color:#080;font-weight:bold">end</span></pre>
1765
+ </td>
1766
+ </tr>
1767
+ </table>
1768
+ </div>
1769
+
1770
+ </div>
1771
+
1772
+ <div id="instance_method_details" class="method_details_list">
1773
+ <h2>Instance Method Details</h2>
1774
+
1775
+
1776
+ <div class="method_details first">
1777
+ <h3 class="signature first" id="add_error-instance_method">
1778
+
1779
+ #<strong>add_error</strong>(attribute, message) &#x21d2; <tt>Object</tt>
1780
+
1781
+
1782
+
1783
+
1784
+
1785
+ </h3><div class="docstring">
1786
+ <div class="discussion">
1787
+
1788
+ <p>Adds an error message to the errors hash.</p>
1789
+
1790
+
1791
+ </div>
1792
+ </div>
1793
+ <div class="tags">
1794
+ <p class="tag_title">Parameters:</p>
1795
+ <ul class="param">
1796
+
1797
+ <li>
1798
+
1799
+ <span class='name'>attribute</span>
1800
+
1801
+
1802
+ <span class='type'>(<tt>Symbol</tt>)</span>
1803
+
1804
+
1805
+
1806
+ &mdash;
1807
+ <div class='inline'>
1808
+ <p>The name of the attribute to add the error to.</p>
1809
+ </div>
1810
+
1811
+ </li>
1812
+
1813
+ <li>
1814
+
1815
+ <span class='name'>message</span>
1816
+
1817
+
1818
+ <span class='type'>(<tt>String</tt>)</span>
1819
+
1820
+
1821
+
1822
+ &mdash;
1823
+ <div class='inline'>
1824
+ <p>The message to add to the error</p>
1825
+ </div>
1826
+
1827
+ </li>
1828
+
1829
+ </ul>
1830
+
1831
+
1832
+ </div><table class="source_code">
1833
+ <tr>
1834
+ <td>
1835
+ <pre class="lines">
1836
+
1837
+
1838
+ 294
1839
+ 295
1840
+ 296
1841
+ 297</pre>
1842
+ </td>
1843
+ <td>
1844
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 294</span>
1845
+
1846
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">add_error</span>(attribute, message)
1847
+ <span style="color:#33B">@errors</span>[attribute] ||= []
1848
+ <span style="color:#33B">@errors</span>[attribute] &lt;&lt; message
1849
+ <span style="color:#080;font-weight:bold">end</span></pre>
1850
+ </td>
1851
+ </tr>
1852
+ </table>
1853
+ </div>
1854
+
1855
+ <div class="method_details ">
1856
+ <h3 class="signature " id="build_payload-instance_method">
1857
+
1858
+ #<strong>build_payload</strong> &#x21d2; <tt>Hash</tt>
1859
+
1860
+
1861
+
1862
+
1863
+
1864
+ </h3><div class="docstring">
1865
+ <div class="discussion">
1866
+
1867
+ <p>Build the request payload.</p>
1868
+
1869
+
1870
+ </div>
1871
+ </div>
1872
+ <div class="tags">
1873
+
1874
+ <p class="tag_title">Returns:</p>
1875
+ <ul class="return">
1876
+
1877
+ <li>
1878
+
1879
+
1880
+ <span class='type'>(<tt>Hash</tt>)</span>
1881
+
1882
+
1883
+
1884
+ &mdash;
1885
+ <div class='inline'>
1886
+ <p>The properly structure request data.</p>
1887
+ </div>
1888
+
1889
+ </li>
1890
+
1891
+ </ul>
1892
+
1893
+ </div><table class="source_code">
1894
+ <tr>
1895
+ <td>
1896
+ <pre class="lines">
1897
+
1898
+
1899
+ 408
1900
+ 409
1901
+ 410
1902
+ 411
1903
+ 412
1904
+ 413
1905
+ 414
1906
+ 415
1907
+ 416
1908
+ 417
1909
+ 418
1910
+ 419
1911
+ 420
1912
+ 421
1913
+ 422
1914
+ 423
1915
+ 424
1916
+ 425
1917
+ 426
1918
+ 427</pre>
1919
+ </td>
1920
+ <td>
1921
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 408</span>
1922
+
1923
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">build_payload</span>
1924
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#069">nil</span> <span style="color:#080;font-weight:bold">unless</span> valid?
1925
+
1926
+ model_wrapper = <span style="color:#069">self</span>.class.singular_name.to_sym
1927
+ payload = {}
1928
+ wrapper = payload[model_wrapper] = {}
1929
+
1930
+ <span style="color:#069">self</span>.schema.each <span style="color:#080;font-weight:bold">do</span> |name, attribute|
1931
+ <span style="color:#080;font-weight:bold">if</span> attribute.write_access?(<span style="color:#069">self</span>)
1932
+ value = attribute.value_or_default(<span style="color:#069">self</span>)
1933
+ required = attribute.required?(<span style="color:#069">self</span>)
1934
+
1935
+ <span style="color:#080;font-weight:bold">if</span> required <span style="color:#080;font-weight:bold">or</span> !value.nil?
1936
+ wrapper[name] = value
1937
+ <span style="color:#080;font-weight:bold">end</span>
1938
+ <span style="color:#080;font-weight:bold">end</span>
1939
+ <span style="color:#080;font-weight:bold">end</span>
1940
+
1941
+ payload
1942
+ <span style="color:#080;font-weight:bold">end</span></pre>
1943
+ </td>
1944
+ </tr>
1945
+ </table>
1946
+ </div>
1947
+
1948
+ <div class="method_details ">
1949
+ <h3 class="signature " id="build_payload!-instance_method">
1950
+
1951
+ #<strong>build_payload!</strong> &#x21d2; <tt>Hash</tt>
1952
+
1953
+
1954
+
1955
+
1956
+
1957
+ </h3><div class="docstring">
1958
+ <div class="discussion">
1959
+
1960
+ <p>Build the request payload, or generate an exception if the data is not
1961
+ valid.</p>
1962
+
1963
+
1964
+ </div>
1965
+ </div>
1966
+ <div class="tags">
1967
+
1968
+ <p class="tag_title">Returns:</p>
1969
+ <ul class="return">
1970
+
1971
+ <li>
1972
+
1973
+
1974
+ <span class='type'>(<tt>Hash</tt>)</span>
1975
+
1976
+
1977
+
1978
+ &mdash;
1979
+ <div class='inline'>
1980
+ <p>The properly structure request data.</p>
1981
+ </div>
1982
+
1983
+ </li>
1984
+
1985
+ </ul>
1986
+ <p class="tag_title">Raises:</p>
1987
+ <ul class="raise">
1988
+
1989
+ <li>
1990
+
1991
+
1992
+ <span class='type'>(<tt>ArgumenError</tt>)</span>
1993
+
1994
+
1995
+
1996
+ &mdash;
1997
+ <div class='inline'>
1998
+ <p>If the model has invalid data.</p>
1999
+ </div>
2000
+
2001
+ </li>
2002
+
2003
+ </ul>
2004
+
2005
+ </div><table class="source_code">
2006
+ <tr>
2007
+ <td>
2008
+ <pre class="lines">
2009
+
2010
+
2011
+ 398
2012
+ 399
2013
+ 400
2014
+ 401</pre>
2015
+ </td>
2016
+ <td>
2017
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 398</span>
2018
+
2019
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">build_payload!</span>
2020
+ valid!
2021
+ <span style="color:#080;font-weight:bold">return</span> build_payload
2022
+ <span style="color:#080;font-weight:bold">end</span></pre>
2023
+ </td>
2024
+ </tr>
2025
+ </table>
2026
+ </div>
2027
+
2028
+ <div class="method_details ">
2029
+ <h3 class="signature " id="clean!-instance_method">
2030
+
2031
+ #<strong>clean!</strong> &#x21d2; <tt>Object</tt>
2032
+
2033
+
2034
+
2035
+
2036
+
2037
+ </h3><div class="docstring">
2038
+ <div class="discussion">
2039
+
2040
+ <p>Cleans out the changes array, which means that the data is no longer marked
2041
+ as dirty.</p>
2042
+
2043
+
2044
+ </div>
2045
+ </div>
2046
+ <div class="tags">
2047
+
2048
+
2049
+ </div><table class="source_code">
2050
+ <tr>
2051
+ <td>
2052
+ <pre class="lines">
2053
+
2054
+
2055
+ 211
2056
+ 212
2057
+ 213</pre>
2058
+ </td>
2059
+ <td>
2060
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 211</span>
2061
+
2062
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">clean!</span>
2063
+ <span style="color:#33B">@changes</span> = []
2064
+ <span style="color:#080;font-weight:bold">end</span></pre>
2065
+ </td>
2066
+ </tr>
2067
+ </table>
2068
+ </div>
2069
+
2070
+ <div class="method_details ">
2071
+ <h3 class="signature " id="clear_primary_key-instance_method">
2072
+
2073
+ #<strong>clear_primary_key</strong> &#x21d2; <tt>Object</tt>
2074
+
2075
+
2076
+
2077
+
2078
+
2079
+ </h3><div class="docstring">
2080
+ <div class="discussion">
2081
+
2082
+ <p>Clear the primary key value.</p>
2083
+
2084
+ <p>This can be used to create a completely new instance of a model&#39;s data</p>
2085
+
2086
+
2087
+ </div>
2088
+ </div>
2089
+ <div class="tags">
2090
+
2091
+
2092
+ </div><table class="source_code">
2093
+ <tr>
2094
+ <td>
2095
+ <pre class="lines">
2096
+
2097
+
2098
+ 117
2099
+ 118
2100
+ 119</pre>
2101
+ </td>
2102
+ <td>
2103
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 117</span>
2104
+
2105
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">clear_primary_key</span>
2106
+ <span style="color:#33B">@attributes</span>[<span style="color:#069">self</span>.primary_key_attribute] = <span style="color:#069">nil</span>
2107
+ <span style="color:#080;font-weight:bold">end</span></pre>
2108
+ </td>
2109
+ </tr>
2110
+ </table>
2111
+ </div>
2112
+
2113
+ <div class="method_details ">
2114
+ <h3 class="signature " id="delete-instance_method">
2115
+
2116
+ #<strong>delete</strong> &#x21d2; <tt><span class='object_link'><a href="" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>, <tt>Nil</tt>
2117
+
2118
+
2119
+
2120
+
2121
+
2122
+ </h3><div class="docstring">
2123
+ <div class="discussion">
2124
+
2125
+ <p>Delete the model data from the api.</p>
2126
+
2127
+
2128
+ </div>
2129
+ </div>
2130
+ <div class="tags">
2131
+
2132
+ <p class="tag_title">Returns:</p>
2133
+ <ul class="return">
2134
+
2135
+ <li>
2136
+
2137
+
2138
+ <span class='type'>(<tt><span class='object_link'><a href="" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2139
+
2140
+
2141
+
2142
+ &mdash;
2143
+ <div class='inline'>
2144
+ <p>If the created/updated model is valid and returns properly from the
2145
+ endpoint.</p>
2146
+ </div>
2147
+
2148
+ </li>
2149
+
2150
+ <li>
2151
+
2152
+
2153
+ <span class='type'>(<tt>Nil</tt>)</span>
2154
+
2155
+
2156
+
2157
+ &mdash;
2158
+ <div class='inline'>
2159
+ <p>If the created/updated model is invalid.</p>
2160
+ </div>
2161
+
2162
+ </li>
2163
+
2164
+ </ul>
2165
+
2166
+ </div><table class="source_code">
2167
+ <tr>
2168
+ <td>
2169
+ <pre class="lines">
2170
+
2171
+
2172
+ 348
2173
+ 349
2174
+ 350
2175
+ 351
2176
+ 352
2177
+ 353
2178
+ 354
2179
+ 355
2180
+ 356
2181
+ 357</pre>
2182
+ </td>
2183
+ <td>
2184
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 348</span>
2185
+
2186
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">delete</span>
2187
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Errors</span>.model_does_not_exist(<span style="color:#069">self</span>.endpoint) <span style="color:#080;font-weight:bold">if</span> new_model?
2188
+ result = endpoint.delete(<span style="color:#069">self</span>)
2189
+ <span style="color:#080;font-weight:bold">if</span> result.success?
2190
+ clean!
2191
+ clear_primary_key
2192
+ <span style="color:#33B">@partial_data</span> = <span style="color:#069">false</span>
2193
+ <span style="color:#080;font-weight:bold">end</span>
2194
+ <span style="color:#080;font-weight:bold">return</span> result
2195
+ <span style="color:#080;font-weight:bold">end</span></pre>
2196
+ </td>
2197
+ </tr>
2198
+ </table>
2199
+ </div>
2200
+
2201
+ <div class="method_details ">
2202
+ <h3 class="signature " id="dirty?-instance_method">
2203
+
2204
+ #<strong>dirty?</strong> &#x21d2; <tt>Boolean</tt>
2205
+
2206
+
2207
+
2208
+
2209
+
2210
+ </h3><div class="docstring">
2211
+ <div class="discussion">
2212
+
2213
+ <p>Determines if the data is dirty or not based on whether changes have been
2214
+ marked in the changes array.</p>
2215
+
2216
+
2217
+ </div>
2218
+ </div>
2219
+ <div class="tags">
2220
+
2221
+ <p class="tag_title">Returns:</p>
2222
+ <ul class="return">
2223
+
2224
+ <li>
2225
+
2226
+
2227
+ <span class='type'>(<tt>Boolean</tt>)</span>
2228
+
2229
+
2230
+
2231
+ </li>
2232
+
2233
+ </ul>
2234
+
2235
+ </div><table class="source_code">
2236
+ <tr>
2237
+ <td>
2238
+ <pre class="lines">
2239
+
2240
+
2241
+ 218
2242
+ 219
2243
+ 220</pre>
2244
+ </td>
2245
+ <td>
2246
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 218</span>
2247
+
2248
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">dirty?</span>
2249
+ <span style="color:#33B">@changes</span>.length &gt; <span style="color:#00D">0</span>
2250
+ <span style="color:#080;font-weight:bold">end</span></pre>
2251
+ </td>
2252
+ </tr>
2253
+ </table>
2254
+ </div>
2255
+
2256
+ <div class="method_details ">
2257
+ <h3 class="signature " id="has_attribute?-instance_method">
2258
+
2259
+ #<strong>has_attribute?</strong>(attribute) &#x21d2; <tt>Boolean</tt>
2260
+
2261
+
2262
+
2263
+
2264
+
2265
+ </h3><div class="docstring">
2266
+ <div class="discussion">
2267
+
2268
+ <p>Determines if an attribute names exists in the schema.</p>
2269
+
2270
+
2271
+ </div>
2272
+ </div>
2273
+ <div class="tags">
2274
+ <p class="tag_title">Parameters:</p>
2275
+ <ul class="param">
2276
+
2277
+ <li>
2278
+
2279
+ <span class='name'>attribute</span>
2280
+
2281
+
2282
+ <span class='type'>(<tt>Symbol</tt>)</span>
2283
+
2284
+
2285
+
2286
+ &mdash;
2287
+ <div class='inline'>
2288
+ <p>The name of the attribute to determine the existence of.</p>
2289
+ </div>
2290
+
2291
+ </li>
2292
+
2293
+ </ul>
2294
+
2295
+ <p class="tag_title">Returns:</p>
2296
+ <ul class="return">
2297
+
2298
+ <li>
2299
+
2300
+
2301
+ <span class='type'>(<tt>Boolean</tt>)</span>
2302
+
2303
+
2304
+
2305
+ </li>
2306
+
2307
+ </ul>
2308
+
2309
+ </div><table class="source_code">
2310
+ <tr>
2311
+ <td>
2312
+ <pre class="lines">
2313
+
2314
+
2315
+ 204
2316
+ 205
2317
+ 206</pre>
2318
+ </td>
2319
+ <td>
2320
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 204</span>
2321
+
2322
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">has_attribute?</span>(attribute)
2323
+ attributes.keys.include?(attribute)
2324
+ <span style="color:#080;font-weight:bold">end</span></pre>
2325
+ </td>
2326
+ </tr>
2327
+ </table>
2328
+ </div>
2329
+
2330
+ <div class="method_details ">
2331
+ <h3 class="signature " id="ingest_attribute-instance_method">
2332
+
2333
+ #<strong>ingest_attribute</strong>(attribute, value, options = {}) &#x21d2; <tt>Object</tt>
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+ </h3><div class="docstring">
2340
+ <div class="discussion">
2341
+
2342
+ <p>Load an attribute value into the attributes hash and ensure that it meets
2343
+ the requirements of the schema.</p>
2344
+
2345
+
2346
+ </div>
2347
+ </div>
2348
+ <div class="tags">
2349
+ <p class="tag_title">Parameters:</p>
2350
+ <ul class="param">
2351
+
2352
+ <li>
2353
+
2354
+ <span class='name'>attribute</span>
2355
+
2356
+
2357
+ <span class='type'>(<tt>Symbol</tt>)</span>
2358
+
2359
+
2360
+
2361
+ &mdash;
2362
+ <div class='inline'>
2363
+ <p>The name of the attribute to ingest</p>
2364
+ </div>
2365
+
2366
+ </li>
2367
+
2368
+ <li>
2369
+
2370
+ <span class='name'>value</span>
2371
+
2372
+
2373
+ <span class='type'>(<tt>Any</tt>)</span>
2374
+
2375
+
2376
+
2377
+ &mdash;
2378
+ <div class='inline'>
2379
+ <p>The value to ingest into the attribute.</p>
2380
+ </div>
2381
+
2382
+ </li>
2383
+
2384
+ <li>
2385
+
2386
+ <span class='name'>options</span>
2387
+
2388
+
2389
+ <span class='type'>(<tt>Hash</tt>)</span>
2390
+
2391
+
2392
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2393
+
2394
+
2395
+ &mdash;
2396
+ <div class='inline'>
2397
+ <p>A hash of options</p>
2398
+ </div>
2399
+
2400
+ </li>
2401
+
2402
+ </ul>
2403
+
2404
+
2405
+
2406
+
2407
+
2408
+
2409
+
2410
+
2411
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
2412
+ <ul class="option">
2413
+
2414
+ <li>
2415
+ <span class="name">:write_to_read_only</span>
2416
+ <span class="type">(<tt>Boolean</tt>)</span>
2417
+ <span class="default">
2418
+
2419
+ </span>
2420
+
2421
+ &mdash; <div class='inline'>
2422
+ <p>Allow data to be written to read only fields. This option should only be
2423
+ used by the model class, and not by users.</p>
2424
+ </div>
2425
+
2426
+ </li>
2427
+
2428
+ </ul>
2429
+
2430
+
2431
+
2432
+ </div><table class="source_code">
2433
+ <tr>
2434
+ <td>
2435
+ <pre class="lines">
2436
+
2437
+
2438
+ 184
2439
+ 185
2440
+ 186
2441
+ 187
2442
+ 188
2443
+ 189
2444
+ 190
2445
+ 191
2446
+ 192
2447
+ 193
2448
+ 194
2449
+ 195
2450
+ 196
2451
+ 197</pre>
2452
+ </td>
2453
+ <td>
2454
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 184</span>
2455
+
2456
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">ingest_attribute</span>(attribute, value, options={})
2457
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#080;font-weight:bold">unless</span> has_attribute?(attribute)
2458
+
2459
+ write_to_read_only = options.fetch(<span style="color:#A60">:write_to_read_only</span>, <span style="color:#069">false</span>)
2460
+ attr = <span style="color:#069">self</span>.class.schema[attribute]
2461
+ <span style="color:#33B">@data_mode</span> = write_to_read_only ? <span style="color:#A60">:ingest</span> : <span style="color:#A60">:access</span>
2462
+ _temp_partial_data = <span style="color:#33B">@partial_data</span>
2463
+ <span style="color:#33B">@partial_data</span> = <span style="color:#069">false</span>
2464
+ set_sym = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>attr.attribute_name.to_s<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">=</span><span style="color:#710">&quot;</span></span>.to_sym
2465
+
2466
+ <span style="color:#069">self</span>.send(set_sym, value)
2467
+
2468
+ <span style="color:#33B">@partial_data</span> = _temp_partial_data
2469
+ <span style="color:#080;font-weight:bold">end</span></pre>
2470
+ </td>
2471
+ </tr>
2472
+ </table>
2473
+ </div>
2474
+
2475
+ <div class="method_details ">
2476
+ <h3 class="signature " id="ingest_attributes-instance_method">
2477
+
2478
+ #<strong>ingest_attributes</strong>(attributes, options = {}) &#x21d2; <tt>Object</tt>
2479
+
2480
+
2481
+
2482
+
2483
+
2484
+ </h3><div class="docstring">
2485
+ <div class="discussion">
2486
+
2487
+ <p>Load data into the attributes hash and ensure that it meets the
2488
+ requirements of the schema.</p>
2489
+
2490
+
2491
+ </div>
2492
+ </div>
2493
+ <div class="tags">
2494
+ <p class="tag_title">Parameters:</p>
2495
+ <ul class="param">
2496
+
2497
+ <li>
2498
+
2499
+ <span class='name'>attributes</span>
2500
+
2501
+
2502
+ <span class='type'>(<tt>Hash</tt>)</span>
2503
+
2504
+
2505
+
2506
+ &mdash;
2507
+ <div class='inline'>
2508
+ <p>The data to load into the attributes hash.</p>
2509
+ </div>
2510
+
2511
+ </li>
2512
+
2513
+ <li>
2514
+
2515
+ <span class='name'>options</span>
2516
+
2517
+
2518
+ <span class='type'>(<tt>Hash</tt>)</span>
2519
+
2520
+
2521
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2522
+
2523
+
2524
+ &mdash;
2525
+ <div class='inline'>
2526
+ <p>A hash of options</p>
2527
+ </div>
2528
+
2529
+ </li>
2530
+
2531
+ </ul>
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
2539
+ <ul class="option">
2540
+
2541
+ <li>
2542
+ <span class="name">:mark_clean</span>
2543
+ <span class="type">(<tt>Boolean</tt>)</span>
2544
+ <span class="default">
2545
+
2546
+ </span>
2547
+
2548
+ &mdash; <div class='inline'>
2549
+ <p>Mark the data as clean after ingesting it.</p>
2550
+ </div>
2551
+
2552
+ </li>
2553
+
2554
+ <li>
2555
+ <span class="name">:write_to_read_only</span>
2556
+ <span class="type">(<tt>Boolean</tt>)</span>
2557
+ <span class="default">
2558
+
2559
+ </span>
2560
+
2561
+ &mdash; <div class='inline'>
2562
+ <p>Allow data to be written to read only fields. This option should only be
2563
+ used by the model class, and not by users.</p>
2564
+ </div>
2565
+
2566
+ </li>
2567
+
2568
+ </ul>
2569
+
2570
+
2571
+
2572
+ </div><table class="source_code">
2573
+ <tr>
2574
+ <td>
2575
+ <pre class="lines">
2576
+
2577
+
2578
+ 154
2579
+ 155
2580
+ 156
2581
+ 157
2582
+ 158
2583
+ 159
2584
+ 160
2585
+ 161
2586
+ 162
2587
+ 163
2588
+ 164
2589
+ 165
2590
+ 166</pre>
2591
+ </td>
2592
+ <td>
2593
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 154</span>
2594
+
2595
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">ingest_attributes</span>(attributes, options={})
2596
+ write_to_read_only = options.fetch(<span style="color:#A60">:write_to_read_only</span>, <span style="color:#069">false</span>)
2597
+ mark_clean = options.fetch(<span style="color:#A60">:mark_clean</span>, <span style="color:#069">false</span>)
2598
+ <span style="color:#33B">@partial_data</span> = options.fetch(<span style="color:#A60">:partial_data</span>, <span style="color:#069">false</span>)
2599
+ attributes = (attributes || {}).deep_symbolize_keys
2600
+ root_key = <span style="color:#069">self</span>.class.singular_name.to_sym
2601
+ attributes = attributes.has_key?(root_key) ? attributes[root_key] : attributes
2602
+
2603
+ attributes.each <span style="color:#080;font-weight:bold">do</span> |attribute, value|
2604
+ ingest_attribute(attribute, value, options)
2605
+ <span style="color:#080;font-weight:bold">end</span>
2606
+ clean! <span style="color:#080;font-weight:bold">if</span> mark_clean
2607
+ <span style="color:#080;font-weight:bold">end</span></pre>
2608
+ </td>
2609
+ </tr>
2610
+ </table>
2611
+ </div>
2612
+
2613
+ <div class="method_details ">
2614
+ <h3 class="signature " id="initialize_attributes-instance_method">
2615
+
2616
+ #<strong>initialize_attributes</strong> &#x21d2; <tt>Object</tt>
2617
+
2618
+
2619
+
2620
+
2621
+
2622
+ </h3><div class="docstring">
2623
+ <div class="discussion">
2624
+
2625
+ <p>Build the attributes hash from the schema definitions.</p>
2626
+
2627
+ <p>This is a non-destructive process, so if the attributes are already
2628
+ established and have values, then nothing will happen to them.</p>
2629
+
2630
+
2631
+ </div>
2632
+ </div>
2633
+ <div class="tags">
2634
+
2635
+
2636
+ </div><table class="source_code">
2637
+ <tr>
2638
+ <td>
2639
+ <pre class="lines">
2640
+
2641
+
2642
+ 126
2643
+ 127
2644
+ 128
2645
+ 129
2646
+ 130
2647
+ 131
2648
+ 132
2649
+ 133
2650
+ 134
2651
+ 135
2652
+ 136</pre>
2653
+ </td>
2654
+ <td>
2655
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 126</span>
2656
+
2657
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">initialize_attributes</span>()
2658
+ <span style="color:#33B">@attributes</span> ||= {}
2659
+ merged_attributes = {}
2660
+ defaults = <span style="color:#069">self</span>.class.schema.defaults(<span style="color:#069">self</span>)
2661
+
2662
+ <span style="color:#777"># Merge the defaults in where attributes don't have a value defined.</span>
2663
+ defaults.each <span style="color:#080;font-weight:bold">do</span> |name, value|
2664
+ merged_attributes[name] = attributes[name] || value
2665
+ <span style="color:#080;font-weight:bold">end</span>
2666
+ <span style="color:#33B">@attributes</span> = merged_attributes
2667
+ <span style="color:#080;font-weight:bold">end</span></pre>
2668
+ </td>
2669
+ </tr>
2670
+ </table>
2671
+ </div>
2672
+
2673
+ <div class="method_details ">
2674
+ <h3 class="signature " id="new_model?-instance_method">
2675
+
2676
+ #<strong>new_model?</strong> &#x21d2; <tt>Boolean</tt>
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+ </h3><div class="docstring">
2683
+ <div class="discussion">
2684
+
2685
+ <p>Determine if the model data is new or not.</p>
2686
+
2687
+
2688
+ </div>
2689
+ </div>
2690
+ <div class="tags">
2691
+
2692
+ <p class="tag_title">Returns:</p>
2693
+ <ul class="return">
2694
+
2695
+ <li>
2696
+
2697
+
2698
+ <span class='type'>(<tt>Boolean</tt>)</span>
2699
+
2700
+
2701
+
2702
+ &mdash;
2703
+ <div class='inline'>
2704
+ <p>An indication if the model is new.</p>
2705
+ </div>
2706
+
2707
+ </li>
2708
+
2709
+ </ul>
2710
+
2711
+ </div><table class="source_code">
2712
+ <tr>
2713
+ <td>
2714
+ <pre class="lines">
2715
+
2716
+
2717
+ 247
2718
+ 248
2719
+ 249</pre>
2720
+ </td>
2721
+ <td>
2722
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 247</span>
2723
+
2724
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">new_model?</span>
2725
+ <span style="color:#069">self</span>.primary_key.nil? <span style="color:#080;font-weight:bold">or</span> <span style="color:#069">self</span>.primary_key.empty?
2726
+ <span style="color:#080;font-weight:bold">end</span></pre>
2727
+ </td>
2728
+ </tr>
2729
+ </table>
2730
+ </div>
2731
+
2732
+ <div class="method_details ">
2733
+ <h3 class="signature " id="primary_key-instance_method">
2734
+
2735
+ #<strong>primary_key</strong> &#x21d2; <tt>Any</tt>
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+ </h3><div class="docstring">
2742
+ <div class="discussion">
2743
+
2744
+ <p>Get the value of the primary key attribute.</p>
2745
+
2746
+
2747
+ </div>
2748
+ </div>
2749
+ <div class="tags">
2750
+
2751
+ <p class="tag_title">Returns:</p>
2752
+ <ul class="return">
2753
+
2754
+ <li>
2755
+
2756
+
2757
+ <span class='type'>(<tt>Any</tt>)</span>
2758
+
2759
+
2760
+
2761
+ &mdash;
2762
+ <div class='inline'>
2763
+ <p>The value of the primary key</p>
2764
+ </div>
2765
+
2766
+ </li>
2767
+
2768
+ </ul>
2769
+
2770
+ </div><table class="source_code">
2771
+ <tr>
2772
+ <td>
2773
+ <pre class="lines">
2774
+
2775
+
2776
+ 99
2777
+ 100
2778
+ 101</pre>
2779
+ </td>
2780
+ <td>
2781
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 99</span>
2782
+
2783
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">primary_key</span>
2784
+ <span style="color:#33B">@attributes</span>[<span style="color:#069">self</span>.primary_key_attribute]
2785
+ <span style="color:#080;font-weight:bold">end</span></pre>
2786
+ </td>
2787
+ </tr>
2788
+ </table>
2789
+ </div>
2790
+
2791
+ <div class="method_details ">
2792
+ <h3 class="signature " id="primary_key_attribute-instance_method">
2793
+
2794
+ #<strong>primary_key_attribute</strong> &#x21d2; <tt>Symbol</tt>
2795
+
2796
+
2797
+
2798
+
2799
+
2800
+ </h3><div class="docstring">
2801
+ <div class="discussion">
2802
+
2803
+ <p>Get the name of the attribute that represents the primary key of the model.</p>
2804
+
2805
+
2806
+ </div>
2807
+ </div>
2808
+ <div class="tags">
2809
+
2810
+ <p class="tag_title">Returns:</p>
2811
+ <ul class="return">
2812
+
2813
+ <li>
2814
+
2815
+
2816
+ <span class='type'>(<tt>Symbol</tt>)</span>
2817
+
2818
+
2819
+
2820
+ &mdash;
2821
+ <div class='inline'>
2822
+ <p>The name of the primary key field.</p>
2823
+ </div>
2824
+
2825
+ </li>
2826
+
2827
+ </ul>
2828
+
2829
+ </div><table class="source_code">
2830
+ <tr>
2831
+ <td>
2832
+ <pre class="lines">
2833
+
2834
+
2835
+ 109
2836
+ 110
2837
+ 111</pre>
2838
+ </td>
2839
+ <td>
2840
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 109</span>
2841
+
2842
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">primary_key_attribute</span>
2843
+ <span style="color:#A60">:id</span>
2844
+ <span style="color:#080;font-weight:bold">end</span></pre>
2845
+ </td>
2846
+ </tr>
2847
+ </table>
2848
+ </div>
2849
+
2850
+ <div class="method_details ">
2851
+ <h3 class="signature " id="refresh-instance_method">
2852
+
2853
+ #<strong>refresh</strong> &#x21d2; <tt><span class='object_link'><a href="" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>
2854
+
2855
+
2856
+
2857
+
2858
+
2859
+ </h3><div class="docstring">
2860
+ <div class="discussion">
2861
+
2862
+ <p>Refresh the data in the model from the API.</p>
2863
+
2864
+
2865
+ </div>
2866
+ </div>
2867
+ <div class="tags">
2868
+
2869
+ <p class="tag_title">Returns:</p>
2870
+ <ul class="return">
2871
+
2872
+ <li>
2873
+
2874
+
2875
+ <span class='type'>(<tt><span class='object_link'><a href="" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2876
+
2877
+
2878
+
2879
+ &mdash;
2880
+ <div class='inline'>
2881
+ <p>A copy of the model if the refresh was successful. An error model if the
2882
+ refresh was a failure.</p>
2883
+ </div>
2884
+
2885
+ </li>
2886
+
2887
+ </ul>
2888
+
2889
+ </div><table class="source_code">
2890
+ <tr>
2891
+ <td>
2892
+ <pre class="lines">
2893
+
2894
+
2895
+ 305
2896
+ 306
2897
+ 307
2898
+ 308
2899
+ 309
2900
+ 310
2901
+ 311</pre>
2902
+ </td>
2903
+ <td>
2904
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 305</span>
2905
+
2906
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">refresh</span>
2907
+ <span style="color:#080;font-weight:bold">if</span> new_model?
2908
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Errors</span>.model_does_not_exist(<span style="color:#069">self</span>.endpoint)
2909
+ <span style="color:#080;font-weight:bold">else</span>
2910
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#069">self</span>.endpoint.refresh(<span style="color:#069">self</span>)
2911
+ <span style="color:#080;font-weight:bold">end</span>
2912
+ <span style="color:#080;font-weight:bold">end</span></pre>
2913
+ </td>
2914
+ </tr>
2915
+ </table>
2916
+ </div>
2917
+
2918
+ <div class="method_details ">
2919
+ <h3 class="signature " id="save-instance_method">
2920
+
2921
+ #<strong>save</strong> &#x21d2; <tt><span class='object_link'><a href="" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>, <tt>Nil</tt>
2922
+
2923
+
2924
+
2925
+
2926
+
2927
+ </h3><div class="docstring">
2928
+ <div class="discussion">
2929
+
2930
+ <p>Save the data in the model to the api.</p>
2931
+
2932
+ <p>If the model is new, then the endpoint create method will be called, if the
2933
+ model is not new, then the endpoint update method will be called.</p>
2934
+
2935
+
2936
+ </div>
2937
+ </div>
2938
+ <div class="tags">
2939
+
2940
+ <p class="tag_title">Returns:</p>
2941
+ <ul class="return">
2942
+
2943
+ <li>
2944
+
2945
+
2946
+ <span class='type'>(<tt><span class='object_link'><a href="" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2947
+
2948
+
2949
+
2950
+ &mdash;
2951
+ <div class='inline'>
2952
+ <p>If the created/updated model is valid and returns properly from the
2953
+ endpoint.</p>
2954
+ </div>
2955
+
2956
+ </li>
2957
+
2958
+ <li>
2959
+
2960
+
2961
+ <span class='type'>(<tt>Nil</tt>)</span>
2962
+
2963
+
2964
+
2965
+ &mdash;
2966
+ <div class='inline'>
2967
+ <p>If the created/updated model is invalid.</p>
2968
+ </div>
2969
+
2970
+ </li>
2971
+
2972
+ </ul>
2973
+
2974
+ </div><table class="source_code">
2975
+ <tr>
2976
+ <td>
2977
+ <pre class="lines">
2978
+
2979
+
2980
+ 325
2981
+ 326
2982
+ 327
2983
+ 328
2984
+ 329
2985
+ 330
2986
+ 331
2987
+ 332
2988
+ 333
2989
+ 334
2990
+ 335
2991
+ 336
2992
+ 337</pre>
2993
+ </td>
2994
+ <td>
2995
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 325</span>
2996
+
2997
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">save</span>
2998
+ result = <span style="color:#069">nil</span>
2999
+ <span style="color:#080;font-weight:bold">if</span> new_model?
3000
+ result = endpoint.create(<span style="color:#069">self</span>)
3001
+ <span style="color:#33B">@attributes</span>[<span style="color:#069">self</span>.primary_key_attribute] = result.primary_key <span style="color:#080;font-weight:bold">if</span> result.success?
3002
+ <span style="color:#080;font-weight:bold">elsif</span> dirty?
3003
+ result = endpoint.update(<span style="color:#069">self</span>)
3004
+ <span style="color:#080;font-weight:bold">else</span>
3005
+ result = <span style="color:#069">self</span>
3006
+ <span style="color:#080;font-weight:bold">end</span>
3007
+ clean! <span style="color:#080;font-weight:bold">if</span> result.success?
3008
+ result
3009
+ <span style="color:#080;font-weight:bold">end</span></pre>
3010
+ </td>
3011
+ </tr>
3012
+ </table>
3013
+ </div>
3014
+
3015
+ <div class="method_details ">
3016
+ <h3 class="signature " id="schema-instance_method">
3017
+
3018
+ #<strong>schema</strong> &#x21d2; <tt><span class='object_link'><a href="Schema.html" title="WscSdk::Schema (class)">WscSdk::Schema</a></span></tt>
3019
+
3020
+
3021
+
3022
+
3023
+
3024
+ </h3><div class="docstring">
3025
+ <div class="discussion">
3026
+
3027
+ <p>Get the current schema definition</p>
3028
+
3029
+
3030
+ </div>
3031
+ </div>
3032
+ <div class="tags">
3033
+
3034
+ <p class="tag_title">Returns:</p>
3035
+ <ul class="return">
3036
+
3037
+ <li>
3038
+
3039
+
3040
+ <span class='type'>(<tt><span class='object_link'><a href="Schema.html" title="WscSdk::Schema (class)">WscSdk::Schema</a></span></tt>)</span>
3041
+
3042
+
3043
+
3044
+ </li>
3045
+
3046
+ </ul>
3047
+
3048
+ </div><table class="source_code">
3049
+ <tr>
3050
+ <td>
3051
+ <pre class="lines">
3052
+
3053
+
3054
+ 90
3055
+ 91
3056
+ 92</pre>
3057
+ </td>
3058
+ <td>
3059
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 90</span>
3060
+
3061
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">schema</span>
3062
+ <span style="color:#069">self</span>.class.schema
3063
+ <span style="color:#080;font-weight:bold">end</span></pre>
3064
+ </td>
3065
+ </tr>
3066
+ </table>
3067
+ </div>
3068
+
3069
+ <div class="method_details ">
3070
+ <h3 class="signature " id="success?-instance_method">
3071
+
3072
+ #<strong>success?</strong> &#x21d2; <tt>Boolean</tt>
3073
+
3074
+
3075
+
3076
+
3077
+
3078
+ </h3><div class="docstring">
3079
+ <div class="discussion">
3080
+
3081
+ <p>Return the success status of the API call that generated this model.</p>
3082
+
3083
+
3084
+ </div>
3085
+ </div>
3086
+ <div class="tags">
3087
+
3088
+ <p class="tag_title">Returns:</p>
3089
+ <ul class="return">
3090
+
3091
+ <li>
3092
+
3093
+
3094
+ <span class='type'>(<tt>Boolean</tt>)</span>
3095
+
3096
+
3097
+
3098
+ &mdash;
3099
+ <div class='inline'>
3100
+ <p>An indication of the status of the API call.</p>
3101
+ </div>
3102
+
3103
+ </li>
3104
+
3105
+ </ul>
3106
+
3107
+ </div><table class="source_code">
3108
+ <tr>
3109
+ <td>
3110
+ <pre class="lines">
3111
+
3112
+
3113
+ 364
3114
+ 365
3115
+ 366</pre>
3116
+ </td>
3117
+ <td>
3118
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 364</span>
3119
+
3120
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">success?</span>
3121
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#069">true</span>
3122
+ <span style="color:#080;font-weight:bold">end</span></pre>
3123
+ </td>
3124
+ </tr>
3125
+ </table>
3126
+ </div>
3127
+
3128
+ <div class="method_details ">
3129
+ <h3 class="signature " id="valid!-instance_method">
3130
+
3131
+ #<strong>valid!</strong> &#x21d2; <tt>Object</tt>
3132
+
3133
+
3134
+
3135
+
3136
+
3137
+ </h3><div class="docstring">
3138
+ <div class="discussion">
3139
+
3140
+ <p>Determine if the model data is valid and raise an exception if its not.</p>
3141
+
3142
+
3143
+ </div>
3144
+ </div>
3145
+ <div class="tags">
3146
+
3147
+ <p class="tag_title">Raises:</p>
3148
+ <ul class="raise">
3149
+
3150
+ <li>
3151
+
3152
+
3153
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
3154
+
3155
+
3156
+
3157
+ &mdash;
3158
+ <div class='inline'>
3159
+ <p>If the model has invalid data.</p>
3160
+ </div>
3161
+
3162
+ </li>
3163
+
3164
+ </ul>
3165
+
3166
+ </div><table class="source_code">
3167
+ <tr>
3168
+ <td>
3169
+ <pre class="lines">
3170
+
3171
+
3172
+ 256
3173
+ 257
3174
+ 258</pre>
3175
+ </td>
3176
+ <td>
3177
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 256</span>
3178
+
3179
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">valid!</span>
3180
+ raise <span style="color:#036;font-weight:bold">ArgumentError</span>.new(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Invalid attribute values: </span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span><span style="color:#33B">@errors</span>.map{ |f, m| <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>f<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">: </span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>m<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>}.join(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20"> | </span><span style="color:#710">&quot;</span></span>)<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>) <span style="color:#080;font-weight:bold">unless</span> valid?
3181
+ <span style="color:#080;font-weight:bold">end</span></pre>
3182
+ </td>
3183
+ </tr>
3184
+ </table>
3185
+ </div>
3186
+
3187
+ <div class="method_details ">
3188
+ <h3 class="signature " id="valid?-instance_method">
3189
+
3190
+ #<strong>valid?</strong> &#x21d2; <tt>Boolean</tt>
3191
+
3192
+
3193
+
3194
+
3195
+
3196
+ </h3><div class="docstring">
3197
+ <div class="discussion">
3198
+
3199
+ <p>Determine if the model data is valid.</p>
3200
+
3201
+
3202
+ </div>
3203
+ </div>
3204
+ <div class="tags">
3205
+
3206
+ <p class="tag_title">Returns:</p>
3207
+ <ul class="return">
3208
+
3209
+ <li>
3210
+
3211
+
3212
+ <span class='type'>(<tt>Boolean</tt>)</span>
3213
+
3214
+
3215
+
3216
+ &mdash;
3217
+ <div class='inline'>
3218
+ <p>An indication if the model data is valid.</p>
3219
+ </div>
3220
+
3221
+ </li>
3222
+
3223
+ </ul>
3224
+
3225
+ </div><table class="source_code">
3226
+ <tr>
3227
+ <td>
3228
+ <pre class="lines">
3229
+
3230
+
3231
+ 265
3232
+ 266
3233
+ 267
3234
+ 268</pre>
3235
+ </td>
3236
+ <td>
3237
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 265</span>
3238
+
3239
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">valid?</span>
3240
+ validate
3241
+ (errors.keys.length == <span style="color:#00D">0</span>)
3242
+ <span style="color:#080;font-weight:bold">end</span></pre>
3243
+ </td>
3244
+ </tr>
3245
+ </table>
3246
+ </div>
3247
+
3248
+ <div class="method_details ">
3249
+ <h3 class="signature " id="validate-instance_method">
3250
+
3251
+ #<strong>validate</strong> &#x21d2; <tt>Object</tt>
3252
+
3253
+
3254
+
3255
+
3256
+
3257
+ </h3><div class="docstring">
3258
+ <div class="discussion">
3259
+
3260
+ <p>Validate the model data.</p>
3261
+
3262
+ <p>This will populate the `.errors` hash if data is invalid.</p>
3263
+
3264
+
3265
+ </div>
3266
+ </div>
3267
+ <div class="tags">
3268
+
3269
+
3270
+ </div><table class="source_code">
3271
+ <tr>
3272
+ <td>
3273
+ <pre class="lines">
3274
+
3275
+
3276
+ 274
3277
+ 275
3278
+ 276
3279
+ 277
3280
+ 278
3281
+ 279
3282
+ 280
3283
+ 281
3284
+ 282
3285
+ 283
3286
+ 284</pre>
3287
+ </td>
3288
+ <td>
3289
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/model.rb', line 274</span>
3290
+
3291
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">validate</span>
3292
+ <span style="color:#33B">@errors</span> = {}
3293
+ <span style="color:#069">self</span>.class.schema.each <span style="color:#080;font-weight:bold">do</span> |name, attribute|
3294
+ value = attribute.value_or_default(<span style="color:#069">self</span>)
3295
+ <span style="color:#080;font-weight:bold">if</span> attribute.required?(<span style="color:#069">self</span>) <span style="color:#080;font-weight:bold">and</span> value.nil?
3296
+ add_error(name, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">is required</span><span style="color:#710">&quot;</span></span>)
3297
+ <span style="color:#080;font-weight:bold">end</span>
3298
+
3299
+ attribute.valid?(<span style="color:#069">self</span>) <span style="color:#080;font-weight:bold">unless</span> value.nil?
3300
+ <span style="color:#080;font-weight:bold">end</span>
3301
+ <span style="color:#080;font-weight:bold">end</span></pre>
3302
+ </td>
3303
+ </tr>
3304
+ </table>
3305
+ </div>
3306
+
3307
+ </div>
3308
+
3309
+ </div>
3310
+
3311
+
3312
+ </div>
3313
+ </div>
3314
+ </div>
3315
+ </body>
3316
+ </html>