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,2974 @@
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::Endpoint";
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 (E)</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">Endpoint</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::Endpoint
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::Endpoint</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="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/endpoint.rb</dd>
119
+ </dl>
120
+
121
+ </div>
122
+
123
+ <h2>Overview</h2><div class="docstring">
124
+ <div class="discussion">
125
+
126
+ <p>A base class for defining endpoint interactions and generating API
127
+ requests.</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="Endpoints/CustomStreamTargets.html" title="WscSdk::Endpoints::CustomStreamTargets (class)">WscSdk::Endpoints::CustomStreamTargets</a></span>, <span class='object_link'><a href="Endpoints/LiveStreams.html" title="WscSdk::Endpoints::LiveStreams (class)">WscSdk::Endpoints::LiveStreams</a></span>, <span class='object_link'><a href="Endpoints/OutputStreamTargets.html" title="WscSdk::Endpoints::OutputStreamTargets (class)">WscSdk::Endpoints::OutputStreamTargets</a></span>, <span class='object_link'><a href="Endpoints/Outputs.html" title="WscSdk::Endpoints::Outputs (class)">WscSdk::Endpoints::Outputs</a></span>, <span class='object_link'><a href="Endpoints/StreamTargets.html" title="WscSdk::Endpoints::StreamTargets (class)">WscSdk::Endpoints::StreamTargets</a></span>, <span class='object_link'><a href="Endpoints/Transcoders.html" title="WscSdk::Endpoints::Transcoders (class)">WscSdk::Endpoints::Transcoders</a></span>, <span class='object_link'><a href="Endpoints/UllStreamTargets.html" title="WscSdk::Endpoints::UllStreamTargets (class)">WscSdk::Endpoints::UllStreamTargets</a></span>, <span class='object_link'><a href="Endpoints/WowzaStreamTargets.html" title="WscSdk::Endpoints::WowzaStreamTargets (class)">WscSdk::Endpoints::WowzaStreamTargets</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="#client-instance_method" title="#client (instance method)">#<strong>client</strong> &#x21d2; Object </a>
150
+
151
+
152
+
153
+ </span>
154
+
155
+
156
+
157
+
158
+ <span class="note title readonly">readonly</span>
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+ <span class="summary_desc"><div class='inline'>
169
+ <p>Returns the value of attribute client.</p>
170
+ </div></span>
171
+
172
+ </li>
173
+
174
+
175
+ <li class="public ">
176
+ <span class="summary_signature">
177
+
178
+ <a href="#parent_path-instance_method" title="#parent_path (instance method)">#<strong>parent_path</strong> &#x21d2; Object </a>
179
+
180
+
181
+
182
+ </span>
183
+
184
+
185
+
186
+
187
+ <span class="note title readonly">readonly</span>
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ <span class="summary_desc"><div class='inline'>
198
+ <p>Returns the value of attribute parent_path.</p>
199
+ </div></span>
200
+
201
+ </li>
202
+
203
+
204
+ </ul>
205
+
206
+
207
+
208
+
209
+
210
+ <h2>
211
+ Class Method Summary
212
+ <small><a href="#" class="summary_toggle">collapse</a></small>
213
+ </h2>
214
+
215
+ <ul class="summary">
216
+
217
+ <li class="public ">
218
+ <span class="summary_signature">
219
+
220
+ <a href="#actions-class_method" title="actions (class method)">.<strong>actions</strong>(config = {}) &#x21d2; Object </a>
221
+
222
+
223
+
224
+ </span>
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ <span class="summary_desc"><div class='inline'>
235
+ <p>Define which built-in actions should be available in the endpoint.</p>
236
+ </div></span>
237
+
238
+ </li>
239
+
240
+
241
+ <li class="public ">
242
+ <span class="summary_signature">
243
+
244
+ <a href="#model_action-class_method" title="model_action (class method)">.<strong>model_action</strong>(action_name, method, model_class) &#x21d2; Object </a>
245
+
246
+
247
+
248
+ </span>
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+ <span class="summary_desc"><div class='inline'>
259
+ <p>Builds additional action methods for the given model into the endpoint.</p>
260
+ </div></span>
261
+
262
+ </li>
263
+
264
+
265
+ <li class="public ">
266
+ <span class="summary_signature">
267
+
268
+ <a href="#model_class-class_method" title="model_class (class method)">.<strong>model_class</strong>(model_class) &#x21d2; Object </a>
269
+
270
+
271
+
272
+ </span>
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+ <span class="summary_desc"><div class='inline'>
283
+ <p>Builds the `model` static method that returns the class of the expected
284
+ model for the given endpoint.</p>
285
+ </div></span>
286
+
287
+ </li>
288
+
289
+
290
+ </ul>
291
+
292
+ <h2>
293
+ Instance Method Summary
294
+ <small><a href="#" class="summary_toggle">collapse</a></small>
295
+ </h2>
296
+
297
+ <ul class="summary">
298
+
299
+ <li class="public ">
300
+ <span class="summary_signature">
301
+
302
+ <a href="#build-instance_method" title="#build (instance method)">#<strong>build</strong>(attributes = {}) &#x21d2; WscSdk::Model </a>
303
+
304
+
305
+
306
+ </span>
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <span class="summary_desc"><div class='inline'>
317
+ <p>Build a new instance of the model class, without committing it to the API.</p>
318
+ </div></span>
319
+
320
+ </li>
321
+
322
+
323
+ <li class="public ">
324
+ <span class="summary_signature">
325
+
326
+ <a href="#create-instance_method" title="#create (instance method)">#<strong>create</strong>(model_object) &#x21d2; WscSdk::Model, Nil </a>
327
+
328
+
329
+
330
+ </span>
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+ <span class="summary_desc"><div class='inline'>
341
+ <p>Create a new model using the endpoint.</p>
342
+ </div></span>
343
+
344
+ </li>
345
+
346
+
347
+ <li class="public ">
348
+ <span class="summary_signature">
349
+
350
+ <a href="#create_path-instance_method" title="#create_path (instance method)">#<strong>create_path</strong> &#x21d2; String </a>
351
+
352
+
353
+
354
+ </span>
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+ <span class="summary_desc"><div class='inline'>
365
+ <p>Get the path for creating an individual model.</p>
366
+ </div></span>
367
+
368
+ </li>
369
+
370
+
371
+ <li class="public ">
372
+ <span class="summary_signature">
373
+
374
+ <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong>(model_object) &#x21d2; WscSdk::Model, Nil </a>
375
+
376
+
377
+
378
+ </span>
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+ <span class="summary_desc"><div class='inline'>
389
+ <p>Delete an existing model in the endpoint.</p>
390
+ </div></span>
391
+
392
+ </li>
393
+
394
+
395
+ <li class="public ">
396
+ <span class="summary_signature">
397
+
398
+ <a href="#delete_path-instance_method" title="#delete_path (instance method)">#<strong>delete_path</strong>(id) &#x21d2; String </a>
399
+
400
+
401
+
402
+ </span>
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+ <span class="summary_desc"><div class='inline'>
413
+ <p>Get the path for deleting an individual model.</p>
414
+ </div></span>
415
+
416
+ </li>
417
+
418
+
419
+ <li class="public ">
420
+ <span class="summary_signature">
421
+
422
+ <a href="#find-instance_method" title="#find (instance method)">#<strong>find</strong>(id) &#x21d2; Object </a>
423
+
424
+
425
+
426
+ </span>
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+ <span class="summary_desc"><div class='inline'>
437
+ <p>Find a specific model in the endpoint.</p>
438
+ </div></span>
439
+
440
+ </li>
441
+
442
+
443
+ <li class="public ">
444
+ <span class="summary_signature">
445
+
446
+ <a href="#find_path-instance_method" title="#find_path (instance method)">#<strong>find_path</strong>(id) &#x21d2; String </a>
447
+
448
+
449
+
450
+ </span>
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+ <span class="summary_desc"><div class='inline'>
461
+ <p>Get the path for finding an individual model.</p>
462
+ </div></span>
463
+
464
+ </li>
465
+
466
+
467
+ <li class="public ">
468
+ <span class="summary_signature">
469
+
470
+ <a href="#handle_json_error-instance_method" title="#handle_json_error (instance method)">#<strong>handle_json_error</strong>(json_error, payload = nil) &#x21d2; Object </a>
471
+
472
+
473
+
474
+ </span>
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+ <span class="summary_desc"><div class='inline'>
485
+ <p>If there is an error while attempting to parse inbound JSON, then make sure
486
+ we have a uniform response mechanism.</p>
487
+ </div></span>
488
+
489
+ </li>
490
+
491
+
492
+ <li class="public ">
493
+ <span class="summary_signature">
494
+
495
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(client, options = {}) &#x21d2; Endpoint </a>
496
+
497
+
498
+
499
+ </span>
500
+
501
+
502
+ <span class="note title constructor">constructor</span>
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+ <span class="summary_desc"><div class='inline'>
512
+ <p>Instantiate a new endpoint.</p>
513
+ </div></span>
514
+
515
+ </li>
516
+
517
+
518
+ <li class="public ">
519
+ <span class="summary_signature">
520
+
521
+ <a href="#list-instance_method" title="#list (instance method)">#<strong>list</strong>(options = {}) &#x21d2; Hash&lt;Any,WscSdk::Model&gt;, WscSdk::Models::Error </a>
522
+
523
+
524
+
525
+ </span>
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+ <span class="summary_desc"><div class='inline'>
536
+ <p>List all of the models for the endpoint.</p>
537
+ </div></span>
538
+
539
+ </li>
540
+
541
+
542
+ <li class="public ">
543
+ <span class="summary_signature">
544
+
545
+ <a href="#list_path-instance_method" title="#list_path (instance method)">#<strong>list_path</strong> &#x21d2; String </a>
546
+
547
+
548
+
549
+ </span>
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+ <span class="summary_desc"><div class='inline'>
560
+ <p>Get the path for the list of models.</p>
561
+ </div></span>
562
+
563
+ </li>
564
+
565
+
566
+ <li class="public ">
567
+ <span class="summary_signature">
568
+
569
+ <a href="#model_name_plural-instance_method" title="#model_name_plural (instance method)">#<strong>model_name_plural</strong> &#x21d2; String </a>
570
+
571
+
572
+
573
+ </span>
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+ <span class="summary_desc"><div class='inline'>
584
+ <p>Get the plural form of the model name.</p>
585
+ </div></span>
586
+
587
+ </li>
588
+
589
+
590
+ <li class="public ">
591
+ <span class="summary_signature">
592
+
593
+ <a href="#model_name_singular-instance_method" title="#model_name_singular (instance method)">#<strong>model_name_singular</strong> &#x21d2; String </a>
594
+
595
+
596
+
597
+ </span>
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+ <span class="summary_desc"><div class='inline'>
608
+ <p>Get the singular form of the model name.</p>
609
+ </div></span>
610
+
611
+ </li>
612
+
613
+
614
+ <li class="public ">
615
+ <span class="summary_signature">
616
+
617
+ <a href="#model_path-instance_method" title="#model_path (instance method)">#<strong>model_path</strong>(id) &#x21d2; String </a>
618
+
619
+
620
+
621
+ </span>
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+ <span class="summary_desc"><div class='inline'>
632
+ <p>Get the path for an individual model.</p>
633
+ </div></span>
634
+
635
+ </li>
636
+
637
+
638
+ <li class="public ">
639
+ <span class="summary_signature">
640
+
641
+ <a href="#refresh-instance_method" title="#refresh (instance method)">#<strong>refresh</strong>(model) &#x21d2; Object </a>
642
+
643
+
644
+
645
+ </span>
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+ <span class="summary_desc"><div class='inline'>
656
+ <p>Refresh the data of a specific model.</p>
657
+ </div></span>
658
+
659
+ </li>
660
+
661
+
662
+ <li class="public ">
663
+ <span class="summary_signature">
664
+
665
+ <a href="#transform_list-instance_method" title="#transform_list (instance method)">#<strong>transform_list</strong>(payload) &#x21d2; WscSdk::ModelList </a>
666
+
667
+
668
+
669
+ </span>
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+
679
+ <span class="summary_desc"><div class='inline'>
680
+ <p>Transform a response payload into a list of models.</p>
681
+ </div></span>
682
+
683
+ </li>
684
+
685
+
686
+ <li class="public ">
687
+ <span class="summary_signature">
688
+
689
+ <a href="#transform_model-instance_method" title="#transform_model (instance method)">#<strong>transform_model</strong>(payload, options = {}) &#x21d2; WscSdk::Model </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>Transform a response payload into a model.</p>
705
+ </div></span>
706
+
707
+ </li>
708
+
709
+
710
+ <li class="public ">
711
+ <span class="summary_signature">
712
+
713
+ <a href="#update-instance_method" title="#update (instance method)">#<strong>update</strong>(model_object) &#x21d2; WscSdk::Model, Nil </a>
714
+
715
+
716
+
717
+ </span>
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+ <span class="summary_desc"><div class='inline'>
728
+ <p>Update an existing model in the endpoint.</p>
729
+ </div></span>
730
+
731
+ </li>
732
+
733
+
734
+ <li class="public ">
735
+ <span class="summary_signature">
736
+
737
+ <a href="#update_path-instance_method" title="#update_path (instance method)">#<strong>update_path</strong>(id) &#x21d2; String </a>
738
+
739
+
740
+
741
+ </span>
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+ <span class="summary_desc"><div class='inline'>
752
+ <p>Get the path for updating an individual model.</p>
753
+ </div></span>
754
+
755
+ </li>
756
+
757
+
758
+ </ul>
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Loggable.html" title="WscSdk::Loggable (module)">Loggable</a></span></h3>
771
+ <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>
772
+ <div id="constructor_details" class="method_details_list">
773
+ <h2>Constructor Details</h2>
774
+
775
+ <div class="method_details first">
776
+ <h3 class="signature first" id="initialize-instance_method">
777
+
778
+ #<strong>initialize</strong>(client, options = {}) &#x21d2; <tt><span class='object_link'><a href="" title="WscSdk::Endpoint (class)">Endpoint</a></span></tt>
779
+
780
+
781
+
782
+
783
+
784
+ </h3><div class="docstring">
785
+ <div class="discussion">
786
+
787
+ <p>Instantiate a new endpoint.</p>
788
+
789
+
790
+ </div>
791
+ </div>
792
+ <div class="tags">
793
+ <p class="tag_title">Parameters:</p>
794
+ <ul class="param">
795
+
796
+ <li>
797
+
798
+ <span class='name'>client</span>
799
+
800
+
801
+ <span class='type'>(<tt><span class='object_link'><a href="Client.html" title="WscSdk::Client (class)">WscSdk::Client</a></span></tt>)</span>
802
+
803
+
804
+
805
+ &mdash;
806
+ <div class='inline'>
807
+ <p>The client to associate with the endpoint.</p>
808
+ </div>
809
+
810
+ </li>
811
+
812
+ <li>
813
+
814
+ <span class='name'>options</span>
815
+
816
+
817
+ <span class='type'>(<tt>Hash</tt>)</span>
818
+
819
+
820
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
821
+
822
+
823
+ &mdash;
824
+ <div class='inline'>
825
+ <p>A hash of options</p>
826
+ </div>
827
+
828
+ </li>
829
+
830
+ </ul>
831
+
832
+
833
+
834
+
835
+
836
+
837
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
838
+ <ul class="option">
839
+
840
+ <li>
841
+ <span class="name">:parent_path</span>
842
+ <span class="type">(<tt>String</tt>)</span>
843
+ <span class="default">
844
+
845
+ </span>
846
+
847
+ &mdash; <div class='inline'>
848
+ <p>The parent object path to use when generating endpoint requests. This
849
+ enables chaining models together in the REST pattern.</p>
850
+ </div>
851
+
852
+ </li>
853
+
854
+ </ul>
855
+
856
+
857
+
858
+ </div><table class="source_code">
859
+ <tr>
860
+ <td>
861
+ <pre class="lines">
862
+
863
+
864
+ 30
865
+ 31
866
+ 32
867
+ 33</pre>
868
+ </td>
869
+ <td>
870
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 30</span>
871
+
872
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">initialize</span>(client, options={})
873
+ <span style="color:#33B">@client</span> = client
874
+ <span style="color:#33B">@parent_path</span> = options.fetch(<span style="color:#A60">:parent_path</span>, <span style="color:#069">nil</span>)
875
+ <span style="color:#080;font-weight:bold">end</span></pre>
876
+ </td>
877
+ </tr>
878
+ </table>
879
+ </div>
880
+
881
+ </div>
882
+
883
+ <div id="instance_attr_details" class="attr_details">
884
+ <h2>Instance Attribute Details</h2>
885
+
886
+
887
+ <span id=""></span>
888
+ <div class="method_details first">
889
+ <h3 class="signature first" id="client-instance_method">
890
+
891
+ #<strong>client</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
892
+
893
+
894
+
895
+
896
+
897
+ </h3><div class="docstring">
898
+ <div class="discussion">
899
+
900
+ <p>Returns the value of attribute client</p>
901
+
902
+
903
+ </div>
904
+ </div>
905
+ <div class="tags">
906
+
907
+
908
+ </div><table class="source_code">
909
+ <tr>
910
+ <td>
911
+ <pre class="lines">
912
+
913
+
914
+ 16
915
+ 17
916
+ 18</pre>
917
+ </td>
918
+ <td>
919
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 16</span>
920
+
921
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">client</span>
922
+ <span style="color:#33B">@client</span>
923
+ <span style="color:#080;font-weight:bold">end</span></pre>
924
+ </td>
925
+ </tr>
926
+ </table>
927
+ </div>
928
+
929
+
930
+ <span id=""></span>
931
+ <div class="method_details ">
932
+ <h3 class="signature " id="parent_path-instance_method">
933
+
934
+ #<strong>parent_path</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
935
+
936
+
937
+
938
+
939
+
940
+ </h3><div class="docstring">
941
+ <div class="discussion">
942
+
943
+ <p>Returns the value of attribute parent_path</p>
944
+
945
+
946
+ </div>
947
+ </div>
948
+ <div class="tags">
949
+
950
+
951
+ </div><table class="source_code">
952
+ <tr>
953
+ <td>
954
+ <pre class="lines">
955
+
956
+
957
+ 16
958
+ 17
959
+ 18</pre>
960
+ </td>
961
+ <td>
962
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 16</span>
963
+
964
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">parent_path</span>
965
+ <span style="color:#33B">@parent_path</span>
966
+ <span style="color:#080;font-weight:bold">end</span></pre>
967
+ </td>
968
+ </tr>
969
+ </table>
970
+ </div>
971
+
972
+ </div>
973
+
974
+
975
+ <div id="class_method_details" class="method_details_list">
976
+ <h2>Class Method Details</h2>
977
+
978
+
979
+ <div class="method_details first">
980
+ <h3 class="signature first" id="actions-class_method">
981
+
982
+ .<strong>actions</strong>(config = {}) &#x21d2; <tt>Object</tt>
983
+
984
+
985
+
986
+
987
+
988
+ </h3><div class="docstring">
989
+ <div class="discussion">
990
+
991
+ <p>Define which built-in actions should be available in the endpoint.</p>
992
+
993
+
994
+ </div>
995
+ </div>
996
+ <div class="tags">
997
+ <p class="tag_title">Parameters:</p>
998
+ <ul class="param">
999
+
1000
+ <li>
1001
+
1002
+ <span class='name'>config</span>
1003
+
1004
+
1005
+ <span class='type'>(<tt>Hash</tt>)</span>
1006
+
1007
+
1008
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1009
+
1010
+
1011
+ &mdash;
1012
+ <div class='inline'>
1013
+ <p>A hash of configuration options</p>
1014
+ </div>
1015
+
1016
+ </li>
1017
+
1018
+ </ul>
1019
+
1020
+
1021
+
1022
+
1023
+ <p class="tag_title">Options Hash (<tt>config</tt>):</p>
1024
+ <ul class="option">
1025
+
1026
+ <li>
1027
+ <span class="name">:include</span>
1028
+ <span class="type">(<tt>Array</tt>)</span>
1029
+ <span class="default">
1030
+
1031
+ </span>
1032
+
1033
+ &mdash; <div class='inline'>
1034
+ <p>An array of actions to keep enabled, anything not listed will be disabled.</p>
1035
+ </div>
1036
+
1037
+ </li>
1038
+
1039
+ <li>
1040
+ <span class="name">:exclude</span>
1041
+ <span class="type">(<tt>Array</tt>)</span>
1042
+ <span class="default">
1043
+
1044
+ </span>
1045
+
1046
+ &mdash; <div class='inline'>
1047
+ <p>An array of actions to disable. This option supercedes the :include option.</p>
1048
+ </div>
1049
+
1050
+ </li>
1051
+
1052
+ </ul>
1053
+
1054
+
1055
+
1056
+ </div><table class="source_code">
1057
+ <tr>
1058
+ <td>
1059
+ <pre class="lines">
1060
+
1061
+
1062
+ 433
1063
+ 434
1064
+ 435
1065
+ 436
1066
+ 437
1067
+ 438
1068
+ 439
1069
+ 440
1070
+ 441
1071
+ 442
1072
+ 443
1073
+ 444
1074
+ 445
1075
+ 446
1076
+ 447
1077
+ 448
1078
+ 449
1079
+ 450
1080
+ 451
1081
+ 452
1082
+ 453
1083
+ 454
1084
+ 455
1085
+ 456
1086
+ 457</pre>
1087
+ </td>
1088
+ <td>
1089
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 433</span>
1090
+
1091
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">actions</span> config={}
1092
+ available_actions = [<span style="color:#A60">:list</span>, <span style="color:#A60">:find</span>, <span style="color:#A60">:build</span>, <span style="color:#A60">:create</span>, <span style="color:#A60">:update</span>, <span style="color:#A60">:delete</span>]
1093
+ disabled_actions = available_actions.clone
1094
+
1095
+ include_actions = config.fetch(<span style="color:#A60">:include</span>, [])
1096
+ include_actions = [include_actions] <span style="color:#080;font-weight:bold">unless</span> include_actions.is_a?(<span style="color:#036;font-weight:bold">Array</span>)
1097
+ include_actions = include_actions.map{ |action| action.to_sym }
1098
+
1099
+ exclude_actions = config.fetch(<span style="color:#A60">:exclude</span>, [])
1100
+ exclude_actions = [exclude_actions] <span style="color:#080;font-weight:bold">unless</span> include_actions.is_a?(<span style="color:#036;font-weight:bold">Array</span>)
1101
+ exclude_actions = exclude_actions.map{ |action| action.to_sym }
1102
+
1103
+ <span style="color:#777"># Do the math to determine which actions should be disabled</span>
1104
+ disabled_actions = ((disabled_actions - include_actions) + exclude_actions).flatten.compact
1105
+
1106
+ <span style="color:#777"># Get the intersectino of the available actions and the disabled actions</span>
1107
+ <span style="color:#777"># to make sure that we aren't disabling unexpected actions.</span>
1108
+ disabled_actions = available_actions &amp; disabled_actions
1109
+
1110
+ disabled_actions.each <span style="color:#080;font-weight:bold">do</span> |disabled_action|
1111
+ define_method disabled_action.to_sym <span style="color:#080;font-weight:bold">do</span> |*args|
1112
+ 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>disabled_action<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">' action is not enabled on this endpoint</span><span style="color:#710">&quot;</span></span>)
1113
+ <span style="color:#080;font-weight:bold">end</span>
1114
+ <span style="color:#080;font-weight:bold">end</span>
1115
+ <span style="color:#080;font-weight:bold">end</span></pre>
1116
+ </td>
1117
+ </tr>
1118
+ </table>
1119
+ </div>
1120
+
1121
+ <div class="method_details ">
1122
+ <h3 class="signature " id="model_action-class_method">
1123
+
1124
+ .<strong>model_action</strong>(action_name, method, model_class) &#x21d2; <tt>Object</tt>
1125
+
1126
+
1127
+
1128
+
1129
+
1130
+ </h3><div class="docstring">
1131
+ <div class="discussion">
1132
+
1133
+ <p>Builds additional action methods for the given model into the endpoint.
1134
+ this allows the endpoint functionality to be extended.</p>
1135
+
1136
+
1137
+ </div>
1138
+ </div>
1139
+ <div class="tags">
1140
+ <p class="tag_title">Parameters:</p>
1141
+ <ul class="param">
1142
+
1143
+ <li>
1144
+
1145
+ <span class='name'>action_name</span>
1146
+
1147
+
1148
+ <span class='type'>(<tt>Symbol</tt>)</span>
1149
+
1150
+
1151
+
1152
+ &mdash;
1153
+ <div class='inline'>
1154
+ <p>The name of the action to append to the endpoint path (e.g. /start)</p>
1155
+ </div>
1156
+
1157
+ </li>
1158
+
1159
+ <li>
1160
+
1161
+ <span class='name'>method</span>
1162
+
1163
+
1164
+ <span class='type'>(<tt>Symbol</tt>)</span>
1165
+
1166
+
1167
+
1168
+ &mdash;
1169
+ <div class='inline'>
1170
+ <p>The request action method (:get, :post, :put, :patch, :delete)</p>
1171
+ </div>
1172
+
1173
+ </li>
1174
+
1175
+ <li>
1176
+
1177
+ <span class='name'>model_class</span>
1178
+
1179
+
1180
+ <span class='type'>(<tt>Class</tt>)</span>
1181
+
1182
+
1183
+
1184
+ &mdash;
1185
+ <div class='inline'>
1186
+ <p>The expected model class that is retuned by the action.</p>
1187
+ </div>
1188
+
1189
+ </li>
1190
+
1191
+ </ul>
1192
+
1193
+
1194
+ </div><table class="source_code">
1195
+ <tr>
1196
+ <td>
1197
+ <pre class="lines">
1198
+
1199
+
1200
+ 483
1201
+ 484
1202
+ 485
1203
+ 486
1204
+ 487
1205
+ 488
1206
+ 489
1207
+ 490</pre>
1208
+ </td>
1209
+ <td>
1210
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 483</span>
1211
+
1212
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">model_action</span>(action_name, method, model_class)
1213
+ define_method action_name.to_sym <span style="color:#080;font-weight:bold">do</span> |id|
1214
+ response = <span style="color:#069">self</span>.client.send(method.to_sym, [find_path(id), action_name.to_s].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>))
1215
+ (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code) ?
1216
+ transform_model(response.body, <span style="color:#606">model_class</span>: model_class) :
1217
+ transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
1218
+ <span style="color:#080;font-weight:bold">end</span>
1219
+ <span style="color:#080;font-weight:bold">end</span></pre>
1220
+ </td>
1221
+ </tr>
1222
+ </table>
1223
+ </div>
1224
+
1225
+ <div class="method_details ">
1226
+ <h3 class="signature " id="model_class-class_method">
1227
+
1228
+ .<strong>model_class</strong>(model_class) &#x21d2; <tt>Object</tt>
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+ </h3><div class="docstring">
1235
+ <div class="discussion">
1236
+
1237
+ <p>Builds the `model` static method that returns the class of the expected
1238
+ model for the given endpoint.</p>
1239
+
1240
+
1241
+ </div>
1242
+ </div>
1243
+ <div class="tags">
1244
+ <p class="tag_title">Parameters:</p>
1245
+ <ul class="param">
1246
+
1247
+ <li>
1248
+
1249
+ <span class='name'>model_class</span>
1250
+
1251
+
1252
+ <span class='type'>(<tt>Class</tt>)</span>
1253
+
1254
+
1255
+
1256
+ &mdash;
1257
+ <div class='inline'>
1258
+ <p>The class of the expected model.</p>
1259
+ </div>
1260
+
1261
+ </li>
1262
+
1263
+ </ul>
1264
+
1265
+
1266
+ </div><table class="source_code">
1267
+ <tr>
1268
+ <td>
1269
+ <pre class="lines">
1270
+
1271
+
1272
+ 465
1273
+ 466
1274
+ 467
1275
+ 468
1276
+ 469</pre>
1277
+ </td>
1278
+ <td>
1279
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 465</span>
1280
+
1281
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#069">self</span>.<span style="color:#06B;font-weight:bold">model_class</span> model_class
1282
+ define_singleton_method <span style="color:#A60">:model</span> <span style="color:#080;font-weight:bold">do</span>
1283
+ model_class
1284
+ <span style="color:#080;font-weight:bold">end</span>
1285
+ <span style="color:#080;font-weight:bold">end</span></pre>
1286
+ </td>
1287
+ </tr>
1288
+ </table>
1289
+ </div>
1290
+
1291
+ </div>
1292
+
1293
+ <div id="instance_method_details" class="method_details_list">
1294
+ <h2>Instance Method Details</h2>
1295
+
1296
+
1297
+ <div class="method_details first">
1298
+ <h3 class="signature first" id="build-instance_method">
1299
+
1300
+ #<strong>build</strong>(attributes = {}) &#x21d2; <tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>
1301
+
1302
+
1303
+
1304
+
1305
+
1306
+ </h3><div class="docstring">
1307
+ <div class="discussion">
1308
+
1309
+ <p>Build a new instance of the model class, without committing it to the API.</p>
1310
+
1311
+
1312
+ </div>
1313
+ </div>
1314
+ <div class="tags">
1315
+ <p class="tag_title">Parameters:</p>
1316
+ <ul class="param">
1317
+
1318
+ <li>
1319
+
1320
+ <span class='name'>attributes</span>
1321
+
1322
+
1323
+ <span class='type'>(<tt>Hash</tt>)</span>
1324
+
1325
+
1326
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1327
+
1328
+
1329
+ &mdash;
1330
+ <div class='inline'>
1331
+ <p>A hash of attributes to assign to the new instance.</p>
1332
+ </div>
1333
+
1334
+ </li>
1335
+
1336
+ </ul>
1337
+
1338
+ <p class="tag_title">Returns:</p>
1339
+ <ul class="return">
1340
+
1341
+ <li>
1342
+
1343
+
1344
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
1345
+
1346
+
1347
+
1348
+ &mdash;
1349
+ <div class='inline'>
1350
+ <p>The new instance of the model.</p>
1351
+ </div>
1352
+
1353
+ </li>
1354
+
1355
+ </ul>
1356
+
1357
+ </div><table class="source_code">
1358
+ <tr>
1359
+ <td>
1360
+ <pre class="lines">
1361
+
1362
+
1363
+ 107
1364
+ 108
1365
+ 109</pre>
1366
+ </td>
1367
+ <td>
1368
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 107</span>
1369
+
1370
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">build</span>(attributes={})
1371
+ <span style="color:#069">self</span>.class.model.new(<span style="color:#069">self</span>, attributes)
1372
+ <span style="color:#080;font-weight:bold">end</span></pre>
1373
+ </td>
1374
+ </tr>
1375
+ </table>
1376
+ </div>
1377
+
1378
+ <div class="method_details ">
1379
+ <h3 class="signature " id="create-instance_method">
1380
+
1381
+ #<strong>create</strong>(model_object) &#x21d2; <tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>, <tt>Nil</tt>
1382
+
1383
+
1384
+
1385
+
1386
+
1387
+ </h3><div class="docstring">
1388
+ <div class="discussion">
1389
+
1390
+ <p>Create a new model using the endpoint.</p>
1391
+
1392
+ <p>If successful this method will directly modify the model_object that is
1393
+ provided, and also return a reference to that object.</p>
1394
+
1395
+ <p>If the data in the model_object is not valid, then the validation messages
1396
+ will be updated in the errors property, and the method will return a Nil
1397
+ object.</p>
1398
+
1399
+
1400
+ </div>
1401
+ </div>
1402
+ <div class="tags">
1403
+ <p class="tag_title">Parameters:</p>
1404
+ <ul class="param">
1405
+
1406
+ <li>
1407
+
1408
+ <span class='name'>model_object</span>
1409
+
1410
+
1411
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
1412
+
1413
+
1414
+
1415
+ &mdash;
1416
+ <div class='inline'>
1417
+ <p>The model object to create in the endpoint.</p>
1418
+ </div>
1419
+
1420
+ </li>
1421
+
1422
+ </ul>
1423
+
1424
+ <p class="tag_title">Returns:</p>
1425
+ <ul class="return">
1426
+
1427
+ <li>
1428
+
1429
+
1430
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
1431
+
1432
+
1433
+
1434
+ &mdash;
1435
+ <div class='inline'>
1436
+ <p>If the newly created model is valid and returns properly from the endpoint.</p>
1437
+ </div>
1438
+
1439
+ </li>
1440
+
1441
+ <li>
1442
+
1443
+
1444
+ <span class='type'>(<tt>Nil</tt>)</span>
1445
+
1446
+
1447
+
1448
+ &mdash;
1449
+ <div class='inline'>
1450
+ <p>If the newly created model is invalid.</p>
1451
+ </div>
1452
+
1453
+ </li>
1454
+
1455
+ </ul>
1456
+
1457
+ </div><table class="source_code">
1458
+ <tr>
1459
+ <td>
1460
+ <pre class="lines">
1461
+
1462
+
1463
+ 130
1464
+ 131
1465
+ 132
1466
+ 133
1467
+ 134
1468
+ 135
1469
+ 136
1470
+ 137
1471
+ 138
1472
+ 139
1473
+ 140
1474
+ 141
1475
+ 142
1476
+ 143</pre>
1477
+ </td>
1478
+ <td>
1479
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 130</span>
1480
+
1481
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">create</span>(model_object)
1482
+ <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_exists(<span style="color:#069">self</span>) <span style="color:#080;font-weight:bold">unless</span> model_object.new_model?
1483
+
1484
+ payload = model_object.build_payload
1485
+ <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>.invalid_attributes(<span style="color:#069">self</span>) <span style="color:#080;font-weight:bold">unless</span> model_object.valid?
1486
+
1487
+ response = client.post(create_path, <span style="color:#606">body</span>: payload)
1488
+
1489
+ <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code)
1490
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">origin_model</span>: model_object)
1491
+ <span style="color:#080;font-weight:bold">else</span>
1492
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
1493
+ <span style="color:#080;font-weight:bold">end</span>
1494
+ <span style="color:#080;font-weight:bold">end</span></pre>
1495
+ </td>
1496
+ </tr>
1497
+ </table>
1498
+ </div>
1499
+
1500
+ <div class="method_details ">
1501
+ <h3 class="signature " id="create_path-instance_method">
1502
+
1503
+ #<strong>create_path</strong> &#x21d2; <tt>String</tt>
1504
+
1505
+
1506
+
1507
+
1508
+
1509
+ </h3><div class="docstring">
1510
+ <div class="discussion">
1511
+
1512
+ <p>Get the path for creating an individual model</p>
1513
+
1514
+
1515
+ </div>
1516
+ </div>
1517
+ <div class="tags">
1518
+
1519
+ <p class="tag_title">Returns:</p>
1520
+ <ul class="return">
1521
+
1522
+ <li>
1523
+
1524
+
1525
+ <span class='type'>(<tt>String</tt>)</span>
1526
+
1527
+
1528
+
1529
+ &mdash;
1530
+ <div class='inline'>
1531
+ <p>The create path.</p>
1532
+ </div>
1533
+
1534
+ </li>
1535
+
1536
+ </ul>
1537
+
1538
+ </div><table class="source_code">
1539
+ <tr>
1540
+ <td>
1541
+ <pre class="lines">
1542
+
1543
+
1544
+ 262
1545
+ 263
1546
+ 264</pre>
1547
+ </td>
1548
+ <td>
1549
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 262</span>
1550
+
1551
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">create_path</span>
1552
+ list_path
1553
+ <span style="color:#080;font-weight:bold">end</span></pre>
1554
+ </td>
1555
+ </tr>
1556
+ </table>
1557
+ </div>
1558
+
1559
+ <div class="method_details ">
1560
+ <h3 class="signature " id="delete-instance_method">
1561
+
1562
+ #<strong>delete</strong>(model_object) &#x21d2; <tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>, <tt>Nil</tt>
1563
+
1564
+
1565
+
1566
+
1567
+
1568
+ </h3><div class="docstring">
1569
+ <div class="discussion">
1570
+
1571
+ <p>Delete an existing model in the endpoint.</p>
1572
+
1573
+ <p>If the model_object&#39;s `WscSdk::Model#new_model?` call returns true,
1574
+ this method becomes an alias for `WscSdk::Model#create(model_object)`</p>
1575
+
1576
+ <p>If successful this method will directly modify the model_object that is
1577
+ provided, and also return a reference to that object.</p>
1578
+
1579
+ <p>If the data in the model_object is not valid, then the validation messages
1580
+ will be updated in the errors property, and the method will return a Nil
1581
+ object.</p>
1582
+
1583
+
1584
+ </div>
1585
+ </div>
1586
+ <div class="tags">
1587
+ <p class="tag_title">Parameters:</p>
1588
+ <ul class="param">
1589
+
1590
+ <li>
1591
+
1592
+ <span class='name'>model_object</span>
1593
+
1594
+
1595
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
1596
+
1597
+
1598
+
1599
+ &mdash;
1600
+ <div class='inline'>
1601
+ <p>The model object to create in the endpoint.</p>
1602
+ </div>
1603
+
1604
+ </li>
1605
+
1606
+ </ul>
1607
+
1608
+ <p class="tag_title">Returns:</p>
1609
+ <ul class="return">
1610
+
1611
+ <li>
1612
+
1613
+
1614
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
1615
+
1616
+
1617
+
1618
+ &mdash;
1619
+ <div class='inline'>
1620
+ <p>If the newly created model is valid and returns properly from the endpoint.</p>
1621
+ </div>
1622
+
1623
+ </li>
1624
+
1625
+ <li>
1626
+
1627
+
1628
+ <span class='type'>(<tt>Nil</tt>)</span>
1629
+
1630
+
1631
+
1632
+ &mdash;
1633
+ <div class='inline'>
1634
+ <p>If the newly created model is invalid.</p>
1635
+ </div>
1636
+
1637
+ </li>
1638
+
1639
+ </ul>
1640
+
1641
+ </div><table class="source_code">
1642
+ <tr>
1643
+ <td>
1644
+ <pre class="lines">
1645
+
1646
+
1647
+ 203
1648
+ 204
1649
+ 205
1650
+ 206
1651
+ 207
1652
+ 208
1653
+ 209
1654
+ 210
1655
+ 211
1656
+ 212
1657
+ 213</pre>
1658
+ </td>
1659
+ <td>
1660
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 203</span>
1661
+
1662
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">delete</span>(model_object)
1663
+ <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>) <span style="color:#080;font-weight:bold">if</span> model_object.new_model?
1664
+
1665
+ response = client.delete(delete_path(model_object.primary_key))
1666
+ <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code)
1667
+ model_object.clear_primary_key
1668
+ <span style="color:#080;font-weight:bold">return</span> model_object
1669
+ <span style="color:#080;font-weight:bold">else</span>
1670
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
1671
+ <span style="color:#080;font-weight:bold">end</span>
1672
+ <span style="color:#080;font-weight:bold">end</span></pre>
1673
+ </td>
1674
+ </tr>
1675
+ </table>
1676
+ </div>
1677
+
1678
+ <div class="method_details ">
1679
+ <h3 class="signature " id="delete_path-instance_method">
1680
+
1681
+ #<strong>delete_path</strong>(id) &#x21d2; <tt>String</tt>
1682
+
1683
+
1684
+
1685
+
1686
+
1687
+ </h3><div class="docstring">
1688
+ <div class="discussion">
1689
+
1690
+ <p>Get the path for deleting an individual model</p>
1691
+
1692
+
1693
+ </div>
1694
+ </div>
1695
+ <div class="tags">
1696
+ <p class="tag_title">Parameters:</p>
1697
+ <ul class="param">
1698
+
1699
+ <li>
1700
+
1701
+ <span class='name'>id</span>
1702
+
1703
+
1704
+ <span class='type'>(<tt>Any</tt>)</span>
1705
+
1706
+
1707
+
1708
+ &mdash;
1709
+ <div class='inline'>
1710
+ <p>The unique id of the model.</p>
1711
+ </div>
1712
+
1713
+ </li>
1714
+
1715
+ </ul>
1716
+
1717
+ <p class="tag_title">Returns:</p>
1718
+ <ul class="return">
1719
+
1720
+ <li>
1721
+
1722
+
1723
+ <span class='type'>(<tt>String</tt>)</span>
1724
+
1725
+
1726
+
1727
+ &mdash;
1728
+ <div class='inline'>
1729
+ <p>The destroy path.</p>
1730
+ </div>
1731
+
1732
+ </li>
1733
+
1734
+ </ul>
1735
+
1736
+ </div><table class="source_code">
1737
+ <tr>
1738
+ <td>
1739
+ <pre class="lines">
1740
+
1741
+
1742
+ 286
1743
+ 287
1744
+ 288</pre>
1745
+ </td>
1746
+ <td>
1747
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 286</span>
1748
+
1749
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">delete_path</span>(id)
1750
+ model_path(id)
1751
+ <span style="color:#080;font-weight:bold">end</span></pre>
1752
+ </td>
1753
+ </tr>
1754
+ </table>
1755
+ </div>
1756
+
1757
+ <div class="method_details ">
1758
+ <h3 class="signature " id="find-instance_method">
1759
+
1760
+ #<strong>find</strong>(id) &#x21d2; <tt>Object</tt>
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+ </h3><div class="docstring">
1767
+ <div class="discussion">
1768
+
1769
+ <p>Find a specific model in the endpoint.</p>
1770
+
1771
+
1772
+ </div>
1773
+ </div>
1774
+ <div class="tags">
1775
+ <p class="tag_title">Parameters:</p>
1776
+ <ul class="param">
1777
+
1778
+ <li>
1779
+
1780
+ <span class='name'>id</span>
1781
+
1782
+
1783
+ <span class='type'>(<tt>Any</tt>)</span>
1784
+
1785
+
1786
+
1787
+ &mdash;
1788
+ <div class='inline'>
1789
+ <p>The id/primary key of the model to find.</p>
1790
+ </div>
1791
+
1792
+ </li>
1793
+
1794
+ </ul>
1795
+
1796
+
1797
+ </div><table class="source_code">
1798
+ <tr>
1799
+ <td>
1800
+ <pre class="lines">
1801
+
1802
+
1803
+ 77
1804
+ 78
1805
+ 79
1806
+ 80
1807
+ 81
1808
+ 82
1809
+ 83
1810
+ 84</pre>
1811
+ </td>
1812
+ <td>
1813
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 77</span>
1814
+
1815
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">find</span>(id)
1816
+ response = client.get(find_path(id))
1817
+ <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code)
1818
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body)
1819
+ <span style="color:#080;font-weight:bold">else</span>
1820
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
1821
+ <span style="color:#080;font-weight:bold">end</span>
1822
+ <span style="color:#080;font-weight:bold">end</span></pre>
1823
+ </td>
1824
+ </tr>
1825
+ </table>
1826
+ </div>
1827
+
1828
+ <div class="method_details ">
1829
+ <h3 class="signature " id="find_path-instance_method">
1830
+
1831
+ #<strong>find_path</strong>(id) &#x21d2; <tt>String</tt>
1832
+
1833
+
1834
+
1835
+
1836
+
1837
+ </h3><div class="docstring">
1838
+ <div class="discussion">
1839
+
1840
+ <p>Get the path for finding an individual model</p>
1841
+
1842
+
1843
+ </div>
1844
+ </div>
1845
+ <div class="tags">
1846
+ <p class="tag_title">Parameters:</p>
1847
+ <ul class="param">
1848
+
1849
+ <li>
1850
+
1851
+ <span class='name'>id</span>
1852
+
1853
+
1854
+ <span class='type'>(<tt>Any</tt>)</span>
1855
+
1856
+
1857
+
1858
+ &mdash;
1859
+ <div class='inline'>
1860
+ <p>The unique id of the model.</p>
1861
+ </div>
1862
+
1863
+ </li>
1864
+
1865
+ </ul>
1866
+
1867
+ <p class="tag_title">Returns:</p>
1868
+ <ul class="return">
1869
+
1870
+ <li>
1871
+
1872
+
1873
+ <span class='type'>(<tt>String</tt>)</span>
1874
+
1875
+
1876
+
1877
+ &mdash;
1878
+ <div class='inline'>
1879
+ <p>The find path.</p>
1880
+ </div>
1881
+
1882
+ </li>
1883
+
1884
+ </ul>
1885
+
1886
+ </div><table class="source_code">
1887
+ <tr>
1888
+ <td>
1889
+ <pre class="lines">
1890
+
1891
+
1892
+ 253
1893
+ 254
1894
+ 255</pre>
1895
+ </td>
1896
+ <td>
1897
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 253</span>
1898
+
1899
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">find_path</span>(id)
1900
+ model_path(id)
1901
+ <span style="color:#080;font-weight:bold">end</span></pre>
1902
+ </td>
1903
+ </tr>
1904
+ </table>
1905
+ </div>
1906
+
1907
+ <div class="method_details ">
1908
+ <h3 class="signature " id="handle_json_error-instance_method">
1909
+
1910
+ #<strong>handle_json_error</strong>(json_error, payload = nil) &#x21d2; <tt>Object</tt>
1911
+
1912
+
1913
+
1914
+
1915
+
1916
+ </h3><div class="docstring">
1917
+ <div class="discussion">
1918
+
1919
+ <p>If there is an error while attempting to parse inbound JSON, then make sure
1920
+ we have a uniform response mechanism.</p>
1921
+
1922
+ <p>A logger error message is written with the error message. A logger debug
1923
+ message is written with the payload information. A WscSdk::Models::Error
1924
+ object is returned</p>
1925
+
1926
+
1927
+ </div>
1928
+ </div>
1929
+ <div class="tags">
1930
+ <p class="tag_title">Parameters:</p>
1931
+ <ul class="param">
1932
+
1933
+ <li>
1934
+
1935
+ <span class='name'>json_error</span>
1936
+
1937
+
1938
+ <span class='type'>(<tt>JSON::ParserError</tt>)</span>
1939
+
1940
+
1941
+
1942
+ &mdash;
1943
+ <div class='inline'>
1944
+ <p>The exception raised while parsing the JSON</p>
1945
+ </div>
1946
+
1947
+ </li>
1948
+
1949
+ <li>
1950
+
1951
+ <span class='name'>payload</span>
1952
+
1953
+
1954
+ <span class='type'>(<tt>String</tt>)</span>
1955
+
1956
+
1957
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1958
+
1959
+
1960
+ &mdash;
1961
+ <div class='inline'>
1962
+ <p>(nil) If a payload is available, then we will log the details at a DEBUG
1963
+ level.</p>
1964
+ </div>
1965
+
1966
+ </li>
1967
+
1968
+ </ul>
1969
+
1970
+ <p class="tag_title">Raises:</p>
1971
+ <ul class="raise">
1972
+
1973
+ <li>
1974
+
1975
+
1976
+ <span class='type'>(<tt>WscSdk::Model::Error</tt>)</span>
1977
+
1978
+
1979
+
1980
+ &mdash;
1981
+ <div class='inline'>
1982
+ <p>Returns an error model so that the SDK can continue without interruption
1983
+ but details will be available, and the `.success?` test will fail.</p>
1984
+ </div>
1985
+
1986
+ </li>
1987
+
1988
+ </ul>
1989
+
1990
+ </div><table class="source_code">
1991
+ <tr>
1992
+ <td>
1993
+ <pre class="lines">
1994
+
1995
+
1996
+ 407
1997
+ 408
1998
+ 409
1999
+ 410
2000
+ 411</pre>
2001
+ </td>
2002
+ <td>
2003
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 407</span>
2004
+
2005
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">handle_json_error</span>(json_error, payload=<span style="color:#069">nil</span>)
2006
+ client.logger.error(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Payload Invalid : </span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>json_error.message<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>)
2007
+ client.logger.debug(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Payload Data : </span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>payload<span style="font-weight:bold;color:#666">}</span></span><span style="color:#710">&quot;</span></span>) <span style="color:#080;font-weight:bold">if</span> payload
2008
+ <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>.invalid_payload(<span style="color:#069">self</span>)
2009
+ <span style="color:#080;font-weight:bold">end</span></pre>
2010
+ </td>
2011
+ </tr>
2012
+ </table>
2013
+ </div>
2014
+
2015
+ <div class="method_details ">
2016
+ <h3 class="signature " id="list-instance_method">
2017
+
2018
+ #<strong>list</strong>(options = {}) &#x21d2; <tt>Hash&lt;Any,<span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span>&gt;</tt>, <tt><span class='object_link'><a href="Models/Error.html" title="WscSdk::Models::Error (class)">WscSdk::Models::Error</a></span></tt>
2019
+
2020
+
2021
+
2022
+
2023
+
2024
+ </h3><div class="docstring">
2025
+ <div class="discussion">
2026
+
2027
+ <p>List all of the models for the endpoint.</p>
2028
+
2029
+
2030
+ </div>
2031
+ </div>
2032
+ <div class="tags">
2033
+ <p class="tag_title">Parameters:</p>
2034
+ <ul class="param">
2035
+
2036
+ <li>
2037
+
2038
+ <span class='name'>options</span>
2039
+
2040
+
2041
+ <span class='type'>(<tt>Hash</tt>)</span>
2042
+
2043
+
2044
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2045
+
2046
+
2047
+ &mdash;
2048
+ <div class='inline'>
2049
+ <p>A hash of options</p>
2050
+ </div>
2051
+
2052
+ </li>
2053
+
2054
+ </ul>
2055
+
2056
+
2057
+
2058
+
2059
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
2060
+ <ul class="option">
2061
+
2062
+ <li>
2063
+ <span class="name">:pagination</span>
2064
+ <span class="type">(<tt>Hash</tt>)</span>
2065
+ <span class="default">
2066
+
2067
+ </span>
2068
+
2069
+ &mdash; <div class='inline'>
2070
+ <p>Pagination configuration for the returned list.</p>
2071
+ </div>
2072
+
2073
+ </li>
2074
+
2075
+ <li>
2076
+ <span class="name">:filters</span>
2077
+ <span class="type">(<tt>Hash</tt>)</span>
2078
+ <span class="default">
2079
+
2080
+ </span>
2081
+
2082
+ &mdash; <div class='inline'>
2083
+ <p>Filters to be applied to the list.</p>
2084
+ </div>
2085
+
2086
+ </li>
2087
+
2088
+ </ul>
2089
+
2090
+
2091
+ <p class="tag_title">Returns:</p>
2092
+ <ul class="return">
2093
+
2094
+ <li>
2095
+
2096
+
2097
+ <span class='type'>(<tt>Hash&lt;Any,<span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span>&gt;</tt>)</span>
2098
+
2099
+
2100
+
2101
+ &mdash;
2102
+ <div class='inline'>
2103
+ <p>A hash of the models in the list, keyed by their primary key.</p>
2104
+ </div>
2105
+
2106
+ </li>
2107
+
2108
+ <li>
2109
+
2110
+
2111
+ <span class='type'>(<tt><span class='object_link'><a href="Models/Error.html" title="WscSdk::Models::Error (class)">WscSdk::Models::Error</a></span></tt>)</span>
2112
+
2113
+
2114
+
2115
+ &mdash;
2116
+ <div class='inline'>
2117
+ <p>An error response if the request failed.</p>
2118
+ </div>
2119
+
2120
+ </li>
2121
+
2122
+ </ul>
2123
+
2124
+ </div><table class="source_code">
2125
+ <tr>
2126
+ <td>
2127
+ <pre class="lines">
2128
+
2129
+
2130
+ 61
2131
+ 62
2132
+ 63
2133
+ 64
2134
+ 65
2135
+ 66
2136
+ 67
2137
+ 68
2138
+ 69
2139
+ 70</pre>
2140
+ </td>
2141
+ <td>
2142
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 61</span>
2143
+
2144
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">list</span>(options={})
2145
+ url = list_path
2146
+ response = client.get(url, options)
2147
+
2148
+ <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code)
2149
+ <span style="color:#080;font-weight:bold">return</span> transform_list(response.body)
2150
+ <span style="color:#080;font-weight:bold">else</span>
2151
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
2152
+ <span style="color:#080;font-weight:bold">end</span>
2153
+ <span style="color:#080;font-weight:bold">end</span></pre>
2154
+ </td>
2155
+ </tr>
2156
+ </table>
2157
+ </div>
2158
+
2159
+ <div class="method_details ">
2160
+ <h3 class="signature " id="list_path-instance_method">
2161
+
2162
+ #<strong>list_path</strong> &#x21d2; <tt>String</tt>
2163
+
2164
+
2165
+
2166
+
2167
+
2168
+ </h3><div class="docstring">
2169
+ <div class="discussion">
2170
+
2171
+ <p>Get the path for the list of models</p>
2172
+
2173
+
2174
+ </div>
2175
+ </div>
2176
+ <div class="tags">
2177
+
2178
+ <p class="tag_title">Returns:</p>
2179
+ <ul class="return">
2180
+
2181
+ <li>
2182
+
2183
+
2184
+ <span class='type'>(<tt>String</tt>)</span>
2185
+
2186
+
2187
+
2188
+ &mdash;
2189
+ <div class='inline'>
2190
+ <p>The list path.</p>
2191
+ </div>
2192
+
2193
+ </li>
2194
+
2195
+ </ul>
2196
+
2197
+ </div><table class="source_code">
2198
+ <tr>
2199
+ <td>
2200
+ <pre class="lines">
2201
+
2202
+
2203
+ 229
2204
+ 230
2205
+ 231</pre>
2206
+ </td>
2207
+ <td>
2208
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 229</span>
2209
+
2210
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">list_path</span>
2211
+ [ parent_path, model_name_plural ].compact.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>)
2212
+ <span style="color:#080;font-weight:bold">end</span></pre>
2213
+ </td>
2214
+ </tr>
2215
+ </table>
2216
+ </div>
2217
+
2218
+ <div class="method_details ">
2219
+ <h3 class="signature " id="model_name_plural-instance_method">
2220
+
2221
+ #<strong>model_name_plural</strong> &#x21d2; <tt>String</tt>
2222
+
2223
+
2224
+
2225
+
2226
+
2227
+ </h3><div class="docstring">
2228
+ <div class="discussion">
2229
+
2230
+ <p>Get the plural form of the model name.</p>
2231
+
2232
+
2233
+ </div>
2234
+ </div>
2235
+ <div class="tags">
2236
+
2237
+ <p class="tag_title">Returns:</p>
2238
+ <ul class="return">
2239
+
2240
+ <li>
2241
+
2242
+
2243
+ <span class='type'>(<tt>String</tt>)</span>
2244
+
2245
+
2246
+
2247
+ &mdash;
2248
+ <div class='inline'>
2249
+ <p>The plural form of the model name.</p>
2250
+ </div>
2251
+
2252
+ </li>
2253
+
2254
+ </ul>
2255
+
2256
+ </div><table class="source_code">
2257
+ <tr>
2258
+ <td>
2259
+ <pre class="lines">
2260
+
2261
+
2262
+ 304
2263
+ 305
2264
+ 306
2265
+ 307</pre>
2266
+ </td>
2267
+ <td>
2268
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 304</span>
2269
+
2270
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">model_name_plural</span>
2271
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#069">nil</span> <span style="color:#080;font-weight:bold">if</span> <span style="color:#069">self</span>.class.model.nil?
2272
+ <span style="color:#069">self</span>.class.model.plural_name
2273
+ <span style="color:#080;font-weight:bold">end</span></pre>
2274
+ </td>
2275
+ </tr>
2276
+ </table>
2277
+ </div>
2278
+
2279
+ <div class="method_details ">
2280
+ <h3 class="signature " id="model_name_singular-instance_method">
2281
+
2282
+ #<strong>model_name_singular</strong> &#x21d2; <tt>String</tt>
2283
+
2284
+
2285
+
2286
+
2287
+
2288
+ </h3><div class="docstring">
2289
+ <div class="discussion">
2290
+
2291
+ <p>Get the singular form of the model name</p>
2292
+
2293
+
2294
+ </div>
2295
+ </div>
2296
+ <div class="tags">
2297
+
2298
+ <p class="tag_title">Returns:</p>
2299
+ <ul class="return">
2300
+
2301
+ <li>
2302
+
2303
+
2304
+ <span class='type'>(<tt>String</tt>)</span>
2305
+
2306
+
2307
+
2308
+ &mdash;
2309
+ <div class='inline'>
2310
+ <p>The singular form of the model name</p>
2311
+ </div>
2312
+
2313
+ </li>
2314
+
2315
+ </ul>
2316
+
2317
+ </div><table class="source_code">
2318
+ <tr>
2319
+ <td>
2320
+ <pre class="lines">
2321
+
2322
+
2323
+ 314
2324
+ 315
2325
+ 316
2326
+ 317</pre>
2327
+ </td>
2328
+ <td>
2329
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 314</span>
2330
+
2331
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">model_name_singular</span>
2332
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#069">nil</span> <span style="color:#080;font-weight:bold">if</span> <span style="color:#069">self</span>.class.model.nil?
2333
+ <span style="color:#069">self</span>.class.model.singular_name
2334
+ <span style="color:#080;font-weight:bold">end</span></pre>
2335
+ </td>
2336
+ </tr>
2337
+ </table>
2338
+ </div>
2339
+
2340
+ <div class="method_details ">
2341
+ <h3 class="signature " id="model_path-instance_method">
2342
+
2343
+ #<strong>model_path</strong>(id) &#x21d2; <tt>String</tt>
2344
+
2345
+
2346
+
2347
+
2348
+
2349
+ </h3><div class="docstring">
2350
+ <div class="discussion">
2351
+
2352
+ <p>Get the path for an individual model.</p>
2353
+
2354
+
2355
+ </div>
2356
+ </div>
2357
+ <div class="tags">
2358
+ <p class="tag_title">Parameters:</p>
2359
+ <ul class="param">
2360
+
2361
+ <li>
2362
+
2363
+ <span class='name'>id</span>
2364
+
2365
+
2366
+ <span class='type'>(<tt>Any</tt>)</span>
2367
+
2368
+
2369
+
2370
+ &mdash;
2371
+ <div class='inline'>
2372
+ <p>The unique id of the model.</p>
2373
+ </div>
2374
+
2375
+ </li>
2376
+
2377
+ </ul>
2378
+
2379
+ <p class="tag_title">Returns:</p>
2380
+ <ul class="return">
2381
+
2382
+ <li>
2383
+
2384
+
2385
+ <span class='type'>(<tt>String</tt>)</span>
2386
+
2387
+
2388
+
2389
+ &mdash;
2390
+ <div class='inline'>
2391
+ <p>The model path.</p>
2392
+ </div>
2393
+
2394
+ </li>
2395
+
2396
+ </ul>
2397
+
2398
+ </div><table class="source_code">
2399
+ <tr>
2400
+ <td>
2401
+ <pre class="lines">
2402
+
2403
+
2404
+ 241
2405
+ 242
2406
+ 243</pre>
2407
+ </td>
2408
+ <td>
2409
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 241</span>
2410
+
2411
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">model_path</span>(id)
2412
+ [ parent_path, model_name_plural, id ].compact.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>)
2413
+ <span style="color:#080;font-weight:bold">end</span></pre>
2414
+ </td>
2415
+ </tr>
2416
+ </table>
2417
+ </div>
2418
+
2419
+ <div class="method_details ">
2420
+ <h3 class="signature " id="refresh-instance_method">
2421
+
2422
+ #<strong>refresh</strong>(model) &#x21d2; <tt>Object</tt>
2423
+
2424
+
2425
+
2426
+
2427
+
2428
+ </h3><div class="docstring">
2429
+ <div class="discussion">
2430
+
2431
+ <p>Refresh the data of a specific model.</p>
2432
+
2433
+
2434
+ </div>
2435
+ </div>
2436
+ <div class="tags">
2437
+ <p class="tag_title">Parameters:</p>
2438
+ <ul class="param">
2439
+
2440
+ <li>
2441
+
2442
+ <span class='name'>model</span>
2443
+
2444
+
2445
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2446
+
2447
+
2448
+
2449
+ </li>
2450
+
2451
+ </ul>
2452
+
2453
+
2454
+ </div><table class="source_code">
2455
+ <tr>
2456
+ <td>
2457
+ <pre class="lines">
2458
+
2459
+
2460
+ 90
2461
+ 91
2462
+ 92
2463
+ 93
2464
+ 94
2465
+ 95
2466
+ 96
2467
+ 97</pre>
2468
+ </td>
2469
+ <td>
2470
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 90</span>
2471
+
2472
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">refresh</span>(model)
2473
+ response = client.get(find_path(model.primary_key))
2474
+ <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code)
2475
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">origin_model</span>: model)
2476
+ <span style="color:#080;font-weight:bold">else</span>
2477
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
2478
+ <span style="color:#080;font-weight:bold">end</span>
2479
+ <span style="color:#080;font-weight:bold">end</span></pre>
2480
+ </td>
2481
+ </tr>
2482
+ </table>
2483
+ </div>
2484
+
2485
+ <div class="method_details ">
2486
+ <h3 class="signature " id="transform_list-instance_method">
2487
+
2488
+ #<strong>transform_list</strong>(payload) &#x21d2; <tt><span class='object_link'><a href="ModelList.html" title="WscSdk::ModelList (class)">WscSdk::ModelList</a></span></tt>
2489
+
2490
+
2491
+
2492
+
2493
+
2494
+ </h3><div class="docstring">
2495
+ <div class="discussion">
2496
+
2497
+ <p>Transform a response payload into a list of models.</p>
2498
+
2499
+
2500
+ </div>
2501
+ </div>
2502
+ <div class="tags">
2503
+ <p class="tag_title">Parameters:</p>
2504
+ <ul class="param">
2505
+
2506
+ <li>
2507
+
2508
+ <span class='name'>payload</span>
2509
+
2510
+
2511
+ <span class='type'>(<tt>Hash</tt>)</span>
2512
+
2513
+
2514
+
2515
+ &mdash;
2516
+ <div class='inline'>
2517
+ <p>The response payload from an API request.</p>
2518
+ </div>
2519
+
2520
+ </li>
2521
+
2522
+ </ul>
2523
+
2524
+ <p class="tag_title">Returns:</p>
2525
+ <ul class="return">
2526
+
2527
+ <li>
2528
+
2529
+
2530
+ <span class='type'>(<tt><span class='object_link'><a href="ModelList.html" title="WscSdk::ModelList (class)">WscSdk::ModelList</a></span></tt>)</span>
2531
+
2532
+
2533
+
2534
+ &mdash;
2535
+ <div class='inline'>
2536
+ <p>The list of models</p>
2537
+ </div>
2538
+
2539
+ </li>
2540
+
2541
+ </ul>
2542
+
2543
+ </div><table class="source_code">
2544
+ <tr>
2545
+ <td>
2546
+ <pre class="lines">
2547
+
2548
+
2549
+ 328
2550
+ 329
2551
+ 330
2552
+ 331
2553
+ 332
2554
+ 333
2555
+ 334
2556
+ 335
2557
+ 336
2558
+ 337
2559
+ 338
2560
+ 339
2561
+ 340
2562
+ 341
2563
+ 342
2564
+ 343
2565
+ 344
2566
+ 345</pre>
2567
+ </td>
2568
+ <td>
2569
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 328</span>
2570
+
2571
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">transform_list</span>(payload)
2572
+ list = <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">ModelList</span>.new
2573
+ <span style="color:#080;font-weight:bold">begin</span>
2574
+ data = <span style="color:#036;font-weight:bold">JSON</span>.parse(payload).deep_symbolize_keys
2575
+
2576
+ data[model_name_plural.to_sym].each <span style="color:#080;font-weight:bold">do</span> |model_data|
2577
+ model = <span style="color:#069">self</span>.class.model.new(<span style="color:#069">self</span>)
2578
+ model.ingest_attributes(model_data, <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>, <span style="color:#606">partial_data</span>: <span style="color:#069">true</span>)
2579
+ list.add(model)
2580
+ <span style="color:#080;font-weight:bold">end</span>
2581
+
2582
+ list.pagination = data[<span style="color:#A60">:pagination</span>] <span style="color:#080;font-weight:bold">if</span> data.has_key?(<span style="color:#A60">:pagination</span>)
2583
+
2584
+ <span style="color:#080;font-weight:bold">return</span> list
2585
+ <span style="color:#080;font-weight:bold">rescue</span> <span style="color:#036;font-weight:bold">JSON</span>::<span style="color:#036;font-weight:bold">ParserError</span> =&gt; e
2586
+ <span style="color:#080;font-weight:bold">return</span> handle_json_error(e, payload)
2587
+ <span style="color:#080;font-weight:bold">end</span>
2588
+ <span style="color:#080;font-weight:bold">end</span></pre>
2589
+ </td>
2590
+ </tr>
2591
+ </table>
2592
+ </div>
2593
+
2594
+ <div class="method_details ">
2595
+ <h3 class="signature " id="transform_model-instance_method">
2596
+
2597
+ #<strong>transform_model</strong>(payload, options = {}) &#x21d2; <tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>
2598
+
2599
+
2600
+
2601
+
2602
+
2603
+ </h3><div class="docstring">
2604
+ <div class="discussion">
2605
+
2606
+ <p>Transform a response payload into a model.</p>
2607
+
2608
+
2609
+ </div>
2610
+ </div>
2611
+ <div class="tags">
2612
+ <p class="tag_title">Parameters:</p>
2613
+ <ul class="param">
2614
+
2615
+ <li>
2616
+
2617
+ <span class='name'>payload</span>
2618
+
2619
+
2620
+ <span class='type'>(<tt>String</tt>)</span>
2621
+
2622
+
2623
+
2624
+ &mdash;
2625
+ <div class='inline'>
2626
+ <p>The response body from an API request.</p>
2627
+ </div>
2628
+
2629
+ </li>
2630
+
2631
+ <li>
2632
+
2633
+ <span class='name'>options</span>
2634
+
2635
+
2636
+ <span class='type'>(<tt>Hash</tt>)</span>
2637
+
2638
+
2639
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2640
+
2641
+
2642
+ &mdash;
2643
+ <div class='inline'>
2644
+ <p>A hash of options</p>
2645
+ </div>
2646
+
2647
+ </li>
2648
+
2649
+ </ul>
2650
+
2651
+
2652
+
2653
+
2654
+
2655
+
2656
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
2657
+ <ul class="option">
2658
+
2659
+ <li>
2660
+ <span class="name">:model_class</span>
2661
+ <span class="type">(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2662
+ <span class="default">
2663
+
2664
+ </span>
2665
+
2666
+ &mdash; <div class='inline'>
2667
+ <p>The class of the model to transform the payload into. This is set to then
2668
+ endpoints static `Endpoint#model` class that is assigned when the endpoint
2669
+ is built. This option is overridden if the `:origin_model` option is used.</p>
2670
+ </div>
2671
+
2672
+ </li>
2673
+
2674
+ <li>
2675
+ <span class="name">:origin_model</span>
2676
+ <span class="type">(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2677
+ <span class="default">
2678
+
2679
+ </span>
2680
+
2681
+ &mdash; <div class='inline'>
2682
+ <p>An existing model that is used instead of generating a new one. This model
2683
+ needs to be the same type of model that is represented by the payload
2684
+ otherwise errors may be generated. This options overrides the
2685
+ `:model_class` options if it&#39;s set.</p>
2686
+ </div>
2687
+
2688
+ </li>
2689
+
2690
+ </ul>
2691
+
2692
+
2693
+ <p class="tag_title">Returns:</p>
2694
+ <ul class="return">
2695
+
2696
+ <li>
2697
+
2698
+
2699
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2700
+
2701
+
2702
+
2703
+ &mdash;
2704
+ <div class='inline'>
2705
+ <p>The model</p>
2706
+ </div>
2707
+
2708
+ </li>
2709
+
2710
+ </ul>
2711
+
2712
+ </div><table class="source_code">
2713
+ <tr>
2714
+ <td>
2715
+ <pre class="lines">
2716
+
2717
+
2718
+ 370
2719
+ 371
2720
+ 372
2721
+ 373
2722
+ 374
2723
+ 375
2724
+ 376
2725
+ 377
2726
+ 378
2727
+ 379
2728
+ 380
2729
+ 381
2730
+ 382
2731
+ 383
2732
+ 384
2733
+ 385
2734
+ 386
2735
+ 387</pre>
2736
+ </td>
2737
+ <td>
2738
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 370</span>
2739
+
2740
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">transform_model</span>(payload, options={})
2741
+ model_class = options.fetch(<span style="color:#A60">:model_class</span>, <span style="color:#069">self</span>.class.model)
2742
+ origin_model = options.fetch(<span style="color:#A60">:origin_model</span>, <span style="color:#069">nil</span>)
2743
+ model = <span style="color:#069">nil</span>
2744
+
2745
+ <span style="color:#080;font-weight:bold">begin</span>
2746
+ data = <span style="color:#036;font-weight:bold">JSON</span>.parse(payload).deep_symbolize_keys
2747
+ model = origin_model.nil? ? model_class.new(<span style="color:#069">self</span>) : origin_model
2748
+ root_key = model.class.singular_name.to_sym
2749
+ model_data = data.has_key?(root_key) ? data[root_key] : data
2750
+
2751
+ model.ingest_attributes(model_data, <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>)
2752
+
2753
+ <span style="color:#080;font-weight:bold">return</span> model
2754
+ <span style="color:#080;font-weight:bold">rescue</span> <span style="color:#036;font-weight:bold">JSON</span>::<span style="color:#036;font-weight:bold">ParserError</span> =&gt; e
2755
+ <span style="color:#080;font-weight:bold">return</span> handle_json_error(e, payload)
2756
+ <span style="color:#080;font-weight:bold">end</span>
2757
+ <span style="color:#080;font-weight:bold">end</span></pre>
2758
+ </td>
2759
+ </tr>
2760
+ </table>
2761
+ </div>
2762
+
2763
+ <div class="method_details ">
2764
+ <h3 class="signature " id="update-instance_method">
2765
+
2766
+ #<strong>update</strong>(model_object) &#x21d2; <tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>, <tt>Nil</tt>
2767
+
2768
+
2769
+
2770
+
2771
+
2772
+ </h3><div class="docstring">
2773
+ <div class="discussion">
2774
+
2775
+ <p>Update an existing model in the endpoint.</p>
2776
+
2777
+ <p>If the model_object&#39;s `WscSdk::Model#new_model?` call returns true,
2778
+ this method becomes an alias for `WscSdk::Model#create(model_object)`</p>
2779
+
2780
+ <p>If successful this method will directly modify the model_object that is
2781
+ provided, and also return a reference to that object.</p>
2782
+
2783
+ <p>If the data in the model_object is not valid, then the validation messages
2784
+ will be updated in the errors property, and the method will return a Nil
2785
+ object.</p>
2786
+
2787
+
2788
+ </div>
2789
+ </div>
2790
+ <div class="tags">
2791
+ <p class="tag_title">Parameters:</p>
2792
+ <ul class="param">
2793
+
2794
+ <li>
2795
+
2796
+ <span class='name'>model_object</span>
2797
+
2798
+
2799
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2800
+
2801
+
2802
+
2803
+ &mdash;
2804
+ <div class='inline'>
2805
+ <p>The model object to create in the endpoint.</p>
2806
+ </div>
2807
+
2808
+ </li>
2809
+
2810
+ </ul>
2811
+
2812
+ <p class="tag_title">Returns:</p>
2813
+ <ul class="return">
2814
+
2815
+ <li>
2816
+
2817
+
2818
+ <span class='type'>(<tt><span class='object_link'><a href="Model.html" title="WscSdk::Model (class)">WscSdk::Model</a></span></tt>)</span>
2819
+
2820
+
2821
+
2822
+ &mdash;
2823
+ <div class='inline'>
2824
+ <p>If the newly created model is valid and returns properly from the endpoint.</p>
2825
+ </div>
2826
+
2827
+ </li>
2828
+
2829
+ <li>
2830
+
2831
+
2832
+ <span class='type'>(<tt>Nil</tt>)</span>
2833
+
2834
+
2835
+
2836
+ &mdash;
2837
+ <div class='inline'>
2838
+ <p>If the newly created model is invalid.</p>
2839
+ </div>
2840
+
2841
+ </li>
2842
+
2843
+ </ul>
2844
+
2845
+ </div><table class="source_code">
2846
+ <tr>
2847
+ <td>
2848
+ <pre class="lines">
2849
+
2850
+
2851
+ 167
2852
+ 168
2853
+ 169
2854
+ 170
2855
+ 171
2856
+ 172
2857
+ 173
2858
+ 174
2859
+ 175
2860
+ 176
2861
+ 177
2862
+ 178
2863
+ 179</pre>
2864
+ </td>
2865
+ <td>
2866
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 167</span>
2867
+
2868
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">update</span>(model_object)
2869
+ <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>) <span style="color:#080;font-weight:bold">if</span> model_object.new_model?
2870
+
2871
+ payload = model_object.build_payload
2872
+ <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>.invalid_attributes(<span style="color:#069">self</span>) <span style="color:#080;font-weight:bold">unless</span> model_object.valid?
2873
+
2874
+ response = client.put(update_path(model_object.primary_key), <span style="color:#606">body</span>: payload)
2875
+ <span style="color:#080;font-weight:bold">if</span> (<span style="color:#00D">200</span>..<span style="color:#00D">299</span>).include?(response.code)
2876
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">origin_model</span>: model_object)
2877
+ <span style="color:#080;font-weight:bold">else</span>
2878
+ <span style="color:#080;font-weight:bold">return</span> transform_model(response.body, <span style="color:#606">model_class</span>: <span style="color:#036;font-weight:bold">WscSdk</span>::<span style="color:#036;font-weight:bold">Models</span>::<span style="color:#036;font-weight:bold">Error</span>)
2879
+ <span style="color:#080;font-weight:bold">end</span>
2880
+ <span style="color:#080;font-weight:bold">end</span></pre>
2881
+ </td>
2882
+ </tr>
2883
+ </table>
2884
+ </div>
2885
+
2886
+ <div class="method_details ">
2887
+ <h3 class="signature " id="update_path-instance_method">
2888
+
2889
+ #<strong>update_path</strong>(id) &#x21d2; <tt>String</tt>
2890
+
2891
+
2892
+
2893
+
2894
+
2895
+ </h3><div class="docstring">
2896
+ <div class="discussion">
2897
+
2898
+ <p>Get the path for updating an individual model</p>
2899
+
2900
+
2901
+ </div>
2902
+ </div>
2903
+ <div class="tags">
2904
+ <p class="tag_title">Parameters:</p>
2905
+ <ul class="param">
2906
+
2907
+ <li>
2908
+
2909
+ <span class='name'>id</span>
2910
+
2911
+
2912
+ <span class='type'>(<tt>Any</tt>)</span>
2913
+
2914
+
2915
+
2916
+ &mdash;
2917
+ <div class='inline'>
2918
+ <p>The unique id of the model.</p>
2919
+ </div>
2920
+
2921
+ </li>
2922
+
2923
+ </ul>
2924
+
2925
+ <p class="tag_title">Returns:</p>
2926
+ <ul class="return">
2927
+
2928
+ <li>
2929
+
2930
+
2931
+ <span class='type'>(<tt>String</tt>)</span>
2932
+
2933
+
2934
+
2935
+ &mdash;
2936
+ <div class='inline'>
2937
+ <p>The update path.</p>
2938
+ </div>
2939
+
2940
+ </li>
2941
+
2942
+ </ul>
2943
+
2944
+ </div><table class="source_code">
2945
+ <tr>
2946
+ <td>
2947
+ <pre class="lines">
2948
+
2949
+
2950
+ 274
2951
+ 275
2952
+ 276</pre>
2953
+ </td>
2954
+ <td>
2955
+ <pre class="code"><span class="info file"># File 'lib/wsc_sdk/endpoint.rb', line 274</span>
2956
+
2957
+ <span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">update_path</span>(id)
2958
+ model_path(id)
2959
+ <span style="color:#080;font-weight:bold">end</span></pre>
2960
+ </td>
2961
+ </tr>
2962
+ </table>
2963
+ </div>
2964
+
2965
+ </div>
2966
+
2967
+ </div>
2968
+
2969
+
2970
+ </div>
2971
+ </div>
2972
+ </div>
2973
+ </body>
2974
+ </html>