easypost 4.8.1 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +5 -0
- data/.github/workflows/ci.yml +8 -0
- data/.gitignore +10 -14
- data/CHANGELOG.md +4 -0
- data/Makefile +10 -2
- data/README.md +5 -1
- data/VERSION +1 -1
- data/docs/EasyPost/Address.html +222 -0
- data/docs/EasyPost/ApiKey.html +99 -0
- data/docs/EasyPost/Batch.html +269 -0
- data/docs/EasyPost/Beta/EndShipper.html +225 -0
- data/docs/EasyPost/Beta/Referral.html +338 -0
- data/docs/EasyPost/Beta.html +91 -0
- data/docs/EasyPost/Billing.html +253 -0
- data/docs/EasyPost/Brand.html +140 -0
- data/docs/EasyPost/CarbonOffset.html +99 -0
- data/docs/EasyPost/CarrierAccount.html +136 -0
- data/docs/EasyPost/CarrierType.html +99 -0
- data/docs/EasyPost/CustomsInfo.html +136 -0
- data/docs/EasyPost/CustomsItem.html +136 -0
- data/docs/EasyPost/EasyPostObject.html +662 -0
- data/docs/EasyPost/EndShipper.html +175 -0
- data/docs/EasyPost/Error.html +258 -0
- data/docs/EasyPost/Event.html +136 -0
- data/docs/EasyPost/Insurance.html +99 -0
- data/docs/EasyPost/Order.html +222 -0
- data/docs/EasyPost/Parcel.html +136 -0
- data/docs/EasyPost/PaymentMethod.html +137 -0
- data/docs/EasyPost/Pickup.html +222 -0
- data/docs/EasyPost/PickupRate.html +99 -0
- data/docs/EasyPost/PostageLabel.html +99 -0
- data/docs/EasyPost/Rate.html +136 -0
- data/docs/EasyPost/Referral.html +334 -0
- data/docs/EasyPost/Refund.html +99 -0
- data/docs/EasyPost/Report.html +167 -0
- data/docs/EasyPost/Resource.html +399 -0
- data/docs/EasyPost/ScanForm.html +137 -0
- data/docs/EasyPost/Shipment.html +456 -0
- data/docs/EasyPost/TaxIdentifier.html +99 -0
- data/docs/EasyPost/Tracker.html +139 -0
- data/docs/EasyPost/User.html +307 -0
- data/docs/EasyPost/Util.html +462 -0
- data/docs/EasyPost/Webhook.html +221 -0
- data/docs/EasyPost.html +440 -0
- data/docs/created.rid +40 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +639 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +117 -0
- data/docs/js/darkfish.js +84 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +785 -0
- data/easypost.gemspec +3 -1
- data/lib/easypost/carrier_account.rb +17 -0
- data/lib/easypost/shipment.rb +1 -1
- data/lib/easypost/user.rb +5 -2
- data/lib/easypost/util.rb +2 -0
- metadata +115 -6
@@ -0,0 +1,662 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class EasyPost::EasyPostObject - EasyPost Ruby Docs</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">Object
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
<div id="includes-section" class="nav-section">
|
69
|
+
<h3>Included Modules</h3>
|
70
|
+
|
71
|
+
<ul class="link-list">
|
72
|
+
<li><span class="include">Enumerable</span>
|
73
|
+
</ul>
|
74
|
+
</div>
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
<!-- Method Quickref -->
|
79
|
+
<div id="method-list-section" class="nav-section">
|
80
|
+
<h3>Methods</h3>
|
81
|
+
|
82
|
+
<ul class="link-list" role="directory">
|
83
|
+
<li ><a href="#method-c-construct_from">::construct_from</a>
|
84
|
+
<li ><a href="#method-c-new">::new</a>
|
85
|
+
<li ><a href="#method-i-5B-5D">#[]</a>
|
86
|
+
<li ><a href="#method-i-5B-5D-3D">#[]=</a>
|
87
|
+
<li ><a href="#method-i-add_accessors">#add_accessors</a>
|
88
|
+
<li ><a href="#method-i-as_json">#as_json</a>
|
89
|
+
<li ><a href="#method-i-deconstruct_keys">#deconstruct_keys</a>
|
90
|
+
<li ><a href="#method-i-each">#each</a>
|
91
|
+
<li ><a href="#method-i-flatten_unsaved">#flatten_unsaved</a>
|
92
|
+
<li ><a href="#method-i-id">#id</a>
|
93
|
+
<li ><a href="#method-i-id-3D">#id=</a>
|
94
|
+
<li ><a href="#method-i-inspect">#inspect</a>
|
95
|
+
<li ><a href="#method-i-keys">#keys</a>
|
96
|
+
<li ><a href="#method-i-metaclass">#metaclass</a>
|
97
|
+
<li ><a href="#method-i-refresh_from">#refresh_from</a>
|
98
|
+
<li ><a href="#method-i-to_hash">#to_hash</a>
|
99
|
+
<li ><a href="#method-i-to_json">#to_json</a>
|
100
|
+
<li ><a href="#method-i-to_s">#to_s</a>
|
101
|
+
<li ><a href="#method-i-values">#values</a>
|
102
|
+
</ul>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
</nav>
|
107
|
+
|
108
|
+
<main role="main" aria-labelledby="class-EasyPost::EasyPostObject">
|
109
|
+
<h1 id="class-EasyPost::EasyPostObject" class="class">
|
110
|
+
class EasyPost::EasyPostObject
|
111
|
+
</h1>
|
112
|
+
|
113
|
+
<section class="description">
|
114
|
+
|
115
|
+
<p>The <a href="EasyPostObject.html"><code>EasyPostObject</code></a> is extended by the <a href="../EasyPost.html"><code>EasyPost</code></a> Resource object.</p>
|
116
|
+
|
117
|
+
</section>
|
118
|
+
|
119
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<section class="attribute-method-details" class="method-section">
|
124
|
+
<header>
|
125
|
+
<h3>Attributes</h3>
|
126
|
+
</header>
|
127
|
+
|
128
|
+
<div id="attribute-i-api_key" class="method-detail">
|
129
|
+
<div class="method-heading attribute-method-heading">
|
130
|
+
<span class="method-name">api_key</span><span
|
131
|
+
class="attribute-access-type">[RW]</span>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<div class="method-description">
|
135
|
+
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
<div id="attribute-i-name" class="method-detail">
|
139
|
+
<div class="method-heading attribute-method-heading">
|
140
|
+
<span class="method-name">name</span><span
|
141
|
+
class="attribute-access-type">[RW]</span>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div class="method-description">
|
145
|
+
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
<div id="attribute-i-parent" class="method-detail">
|
149
|
+
<div class="method-heading attribute-method-heading">
|
150
|
+
<span class="method-name">parent</span><span
|
151
|
+
class="attribute-access-type">[RW]</span>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div class="method-description">
|
155
|
+
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
<div id="attribute-i-unsaved_values" class="method-detail">
|
159
|
+
<div class="method-heading attribute-method-heading">
|
160
|
+
<span class="method-name">unsaved_values</span><span
|
161
|
+
class="attribute-access-type">[RW]</span>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<div class="method-description">
|
165
|
+
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
</section>
|
169
|
+
|
170
|
+
|
171
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
172
|
+
<header>
|
173
|
+
<h3>Public Class Methods</h3>
|
174
|
+
</header>
|
175
|
+
|
176
|
+
<div id="method-c-construct_from" class="method-detail ">
|
177
|
+
<div class="method-heading">
|
178
|
+
<span class="method-name">construct_from</span><span
|
179
|
+
class="method-args">(values, api_key = nil, parent = nil, name = nil)</span>
|
180
|
+
<span class="method-click-advice">click to toggle source</span>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div class="method-description">
|
184
|
+
<p>Construct an object from values.</p>
|
185
|
+
|
186
|
+
<div class="method-source-code" id="construct_from-source">
|
187
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 25</span>
|
188
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">construct_from</span>(<span class="ruby-identifier">values</span>, <span class="ruby-identifier">api_key</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">parent</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
|
189
|
+
<span class="ruby-identifier">obj</span> = <span class="ruby-identifier">new</span>(<span class="ruby-identifier">values</span>[<span class="ruby-value">:id</span>], <span class="ruby-identifier">api_key</span>, <span class="ruby-identifier">parent</span>, <span class="ruby-identifier">name</span>)
|
190
|
+
<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">refresh_from</span>(<span class="ruby-identifier">values</span>, <span class="ruby-identifier">api_key</span>)
|
191
|
+
<span class="ruby-identifier">obj</span>
|
192
|
+
<span class="ruby-keyword">end</span></pre>
|
193
|
+
</div>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
<div id="method-c-new" class="method-detail ">
|
200
|
+
<div class="method-heading">
|
201
|
+
<span class="method-name">new</span><span
|
202
|
+
class="method-args">(id = nil, api_key = nil, parent = nil, name = nil)</span>
|
203
|
+
<span class="method-click-advice">click to toggle source</span>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
<div class="method-description">
|
207
|
+
<p>Initialize an <a href="EasyPostObject.html"><code>EasyPostObject</code></a>.</p>
|
208
|
+
|
209
|
+
<div class="method-source-code" id="new-source">
|
210
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 14</span>
|
211
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">id</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">api_key</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">parent</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
|
212
|
+
<span class="ruby-ivar">@api_key</span> = <span class="ruby-identifier">api_key</span>
|
213
|
+
<span class="ruby-ivar">@values</span> = {}
|
214
|
+
<span class="ruby-ivar">@unsaved_values</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>
|
215
|
+
<span class="ruby-ivar">@transient_values</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>
|
216
|
+
<span class="ruby-ivar">@parent</span> = <span class="ruby-identifier">parent</span>
|
217
|
+
<span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
|
218
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">id</span> = <span class="ruby-identifier">id</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span>
|
219
|
+
<span class="ruby-keyword">end</span></pre>
|
220
|
+
</div>
|
221
|
+
</div>
|
222
|
+
|
223
|
+
|
224
|
+
</div>
|
225
|
+
|
226
|
+
</section>
|
227
|
+
|
228
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
229
|
+
<header>
|
230
|
+
<h3>Public Instance Methods</h3>
|
231
|
+
</header>
|
232
|
+
|
233
|
+
<div id="method-i-5B-5D" class="method-detail ">
|
234
|
+
<div class="method-heading">
|
235
|
+
<span class="method-name">[]</span><span
|
236
|
+
class="method-args">(key)</span>
|
237
|
+
<span class="method-click-advice">click to toggle source</span>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div class="method-description">
|
241
|
+
<p>Get element of an array.</p>
|
242
|
+
|
243
|
+
<div class="method-source-code" id="5B-5D-source">
|
244
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 67</span>
|
245
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">key</span>)
|
246
|
+
<span class="ruby-ivar">@values</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>]
|
247
|
+
<span class="ruby-keyword">end</span></pre>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
</div>
|
253
|
+
|
254
|
+
<div id="method-i-5B-5D-3D" class="method-detail ">
|
255
|
+
<div class="method-heading">
|
256
|
+
<span class="method-name">[]=</span><span
|
257
|
+
class="method-args">(key, value)</span>
|
258
|
+
<span class="method-click-advice">click to toggle source</span>
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
<p>Set the element of an array.</p>
|
263
|
+
|
264
|
+
<div class="method-source-code" id="5B-5D-3D-source">
|
265
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 72</span>
|
266
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]=</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
|
267
|
+
<span class="ruby-identifier">send</span>(<span class="ruby-value">:"#{key}="</span>, <span class="ruby-identifier">value</span>)
|
268
|
+
<span class="ruby-keyword">end</span></pre>
|
269
|
+
</div>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
|
273
|
+
</div>
|
274
|
+
|
275
|
+
<div id="method-i-as_json" class="method-detail ">
|
276
|
+
<div class="method-heading">
|
277
|
+
<span class="method-name">as_json</span><span
|
278
|
+
class="method-args">(_options = {})</span>
|
279
|
+
<span class="method-click-advice">click to toggle source</span>
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div class="method-description">
|
283
|
+
<p>Get values as JSON.</p>
|
284
|
+
|
285
|
+
<div class="method-source-code" id="as_json-source">
|
286
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 92</span>
|
287
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">as_json</span>(<span class="ruby-identifier">_options</span> = {})
|
288
|
+
<span class="ruby-ivar">@values</span>.<span class="ruby-identifier">as_json</span>
|
289
|
+
<span class="ruby-keyword">end</span></pre>
|
290
|
+
</div>
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
</div>
|
295
|
+
|
296
|
+
<div id="method-i-deconstruct_keys" class="method-detail ">
|
297
|
+
<div class="method-heading">
|
298
|
+
<span class="method-name">deconstruct_keys</span><span
|
299
|
+
class="method-args">(_keys)</span>
|
300
|
+
<span class="method-click-advice">click to toggle source</span>
|
301
|
+
</div>
|
302
|
+
|
303
|
+
<div class="method-description">
|
304
|
+
<p>Deconstruct the keys of an object.</p>
|
305
|
+
|
306
|
+
<div class="method-source-code" id="deconstruct_keys-source">
|
307
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 102</span>
|
308
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deconstruct_keys</span>(<span class="ruby-identifier">_keys</span>)
|
309
|
+
<span class="ruby-ivar">@values</span>.<span class="ruby-identifier">transform_keys</span>(<span class="ruby-operator">&</span><span class="ruby-value">:to_sym</span>)
|
310
|
+
<span class="ruby-keyword">end</span></pre>
|
311
|
+
</div>
|
312
|
+
</div>
|
313
|
+
|
314
|
+
|
315
|
+
</div>
|
316
|
+
|
317
|
+
<div id="method-i-each" class="method-detail ">
|
318
|
+
<div class="method-heading">
|
319
|
+
<span class="method-name">each</span><span
|
320
|
+
class="method-args">(&blk)</span>
|
321
|
+
<span class="method-click-advice">click to toggle source</span>
|
322
|
+
</div>
|
323
|
+
|
324
|
+
<div class="method-description">
|
325
|
+
<p>Get each element of values.</p>
|
326
|
+
|
327
|
+
<div class="method-source-code" id="each-source">
|
328
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 107</span>
|
329
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
330
|
+
<span class="ruby-ivar">@values</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
331
|
+
<span class="ruby-keyword">end</span></pre>
|
332
|
+
</div>
|
333
|
+
</div>
|
334
|
+
|
335
|
+
|
336
|
+
</div>
|
337
|
+
|
338
|
+
<div id="method-i-id" class="method-detail ">
|
339
|
+
<div class="method-heading">
|
340
|
+
<span class="method-name">id</span><span
|
341
|
+
class="method-args">()</span>
|
342
|
+
<span class="method-click-advice">click to toggle source</span>
|
343
|
+
</div>
|
344
|
+
|
345
|
+
<div class="method-description">
|
346
|
+
<p>Get the ID of an object.</p>
|
347
|
+
|
348
|
+
<div class="method-source-code" id="id-source">
|
349
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 117</span>
|
350
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">id</span>
|
351
|
+
<span class="ruby-ivar">@values</span>[<span class="ruby-value">:id</span>]
|
352
|
+
<span class="ruby-keyword">end</span></pre>
|
353
|
+
</div>
|
354
|
+
</div>
|
355
|
+
|
356
|
+
|
357
|
+
</div>
|
358
|
+
|
359
|
+
<div id="method-i-id-3D" class="method-detail ">
|
360
|
+
<div class="method-heading">
|
361
|
+
<span class="method-name">id=</span><span
|
362
|
+
class="method-args">(id)</span>
|
363
|
+
<span class="method-click-advice">click to toggle source</span>
|
364
|
+
</div>
|
365
|
+
|
366
|
+
<div class="method-description">
|
367
|
+
<p>Set the ID of an object.</p>
|
368
|
+
|
369
|
+
<div class="method-source-code" id="id-3D-source">
|
370
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 112</span>
|
371
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">id=</span>(<span class="ruby-identifier">id</span>)
|
372
|
+
<span class="ruby-ivar">@values</span>[<span class="ruby-value">:id</span>] = <span class="ruby-identifier">id</span>
|
373
|
+
<span class="ruby-keyword">end</span></pre>
|
374
|
+
</div>
|
375
|
+
</div>
|
376
|
+
|
377
|
+
|
378
|
+
</div>
|
379
|
+
|
380
|
+
<div id="method-i-inspect" class="method-detail ">
|
381
|
+
<div class="method-heading">
|
382
|
+
<span class="method-name">inspect</span><span
|
383
|
+
class="method-args">()</span>
|
384
|
+
<span class="method-click-advice">click to toggle source</span>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
<div class="method-description">
|
388
|
+
<p>Inspect JSON.</p>
|
389
|
+
|
390
|
+
<div class="method-source-code" id="inspect-source">
|
391
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 37</span>
|
392
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
|
393
|
+
<span class="ruby-identifier">id_string</span> = <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:id</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">id</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-node">" id=#{id}"</span> <span class="ruby-operator">:</span> <span class="ruby-string">''</span>
|
394
|
+
<span class="ruby-node">"#<#{self.class}:#{id_string}> JSON: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">to_json</span>
|
395
|
+
<span class="ruby-keyword">end</span></pre>
|
396
|
+
</div>
|
397
|
+
</div>
|
398
|
+
|
399
|
+
|
400
|
+
</div>
|
401
|
+
|
402
|
+
<div id="method-i-keys" class="method-detail ">
|
403
|
+
<div class="method-heading">
|
404
|
+
<span class="method-name">keys</span><span
|
405
|
+
class="method-args">()</span>
|
406
|
+
<span class="method-click-advice">click to toggle source</span>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
<div class="method-description">
|
410
|
+
<p>Keys of an object.</p>
|
411
|
+
|
412
|
+
<div class="method-source-code" id="keys-source">
|
413
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 77</span>
|
414
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">keys</span>
|
415
|
+
<span class="ruby-ivar">@values</span>.<span class="ruby-identifier">keys</span>
|
416
|
+
<span class="ruby-keyword">end</span></pre>
|
417
|
+
</div>
|
418
|
+
</div>
|
419
|
+
|
420
|
+
|
421
|
+
</div>
|
422
|
+
|
423
|
+
<div id="method-i-refresh_from" class="method-detail ">
|
424
|
+
<div class="method-heading">
|
425
|
+
<span class="method-name">refresh_from</span><span
|
426
|
+
class="method-args">(values, api_key)</span>
|
427
|
+
<span class="method-click-advice">click to toggle source</span>
|
428
|
+
</div>
|
429
|
+
|
430
|
+
<div class="method-description">
|
431
|
+
<p>Refresh an object from the API.</p>
|
432
|
+
|
433
|
+
<div class="method-source-code" id="refresh_from-source">
|
434
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 43</span>
|
435
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">refresh_from</span>(<span class="ruby-identifier">values</span>, <span class="ruby-identifier">api_key</span>)
|
436
|
+
<span class="ruby-ivar">@api_key</span> = <span class="ruby-identifier">api_key</span>
|
437
|
+
|
438
|
+
<span class="ruby-identifier">added</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">values</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">keys</span>)
|
439
|
+
|
440
|
+
<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword">do</span>
|
441
|
+
<span class="ruby-identifier">add_accessors</span>(<span class="ruby-identifier">added</span>)
|
442
|
+
<span class="ruby-keyword">end</span>
|
443
|
+
|
444
|
+
<span class="ruby-comment"># IDs should never change. But to be safe, only delete if they are different.</span>
|
445
|
+
<span class="ruby-ivar">@values</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:id</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">values</span>[<span class="ruby-value">:id</span>] <span class="ruby-operator">!=</span> <span class="ruby-ivar">@values</span>[<span class="ruby-value">:id</span>]
|
446
|
+
|
447
|
+
<span class="ruby-identifier">values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
448
|
+
<span class="ruby-ivar">@values</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-constant">EasyPost</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">convert_to_easypost_object</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">api_key</span>, <span class="ruby-keyword">self</span>, <span class="ruby-identifier">k</span>)
|
449
|
+
<span class="ruby-ivar">@transient_values</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
|
450
|
+
<span class="ruby-ivar">@unsaved_values</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
|
451
|
+
<span class="ruby-keyword">end</span>
|
452
|
+
|
453
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@values</span>[<span class="ruby-value">:id</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">values</span>[<span class="ruby-value">:id</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">values</span>[<span class="ruby-string">'id'</span>].<span class="ruby-identifier">nil?</span>)
|
454
|
+
|
455
|
+
<span class="ruby-ivar">@values</span>[<span class="ruby-value">:id</span>] = <span class="ruby-identifier">values</span>[<span class="ruby-value">:id</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">values</span>[<span class="ruby-string">'id'</span>]
|
456
|
+
<span class="ruby-keyword">end</span></pre>
|
457
|
+
</div>
|
458
|
+
</div>
|
459
|
+
|
460
|
+
|
461
|
+
</div>
|
462
|
+
|
463
|
+
<div id="method-i-to_hash" class="method-detail ">
|
464
|
+
<div class="method-heading">
|
465
|
+
<span class="method-name">to_hash</span><span
|
466
|
+
class="method-args">()</span>
|
467
|
+
<span class="method-click-advice">click to toggle source</span>
|
468
|
+
</div>
|
469
|
+
|
470
|
+
<div class="method-description">
|
471
|
+
<p>Make values a hash.</p>
|
472
|
+
|
473
|
+
<div class="method-source-code" id="to_hash-source">
|
474
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 97</span>
|
475
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_hash</span>
|
476
|
+
<span class="ruby-ivar">@values</span>
|
477
|
+
<span class="ruby-keyword">end</span></pre>
|
478
|
+
</div>
|
479
|
+
</div>
|
480
|
+
|
481
|
+
|
482
|
+
</div>
|
483
|
+
|
484
|
+
<div id="method-i-to_json" class="method-detail ">
|
485
|
+
<div class="method-heading">
|
486
|
+
<span class="method-name">to_json</span><span
|
487
|
+
class="method-args">(_options = {})</span>
|
488
|
+
<span class="method-click-advice">click to toggle source</span>
|
489
|
+
</div>
|
490
|
+
|
491
|
+
<div class="method-description">
|
492
|
+
<p>Make values JSON.</p>
|
493
|
+
|
494
|
+
<div class="method-source-code" id="to_json-source">
|
495
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 87</span>
|
496
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_json</span>(<span class="ruby-identifier">_options</span> = {})
|
497
|
+
<span class="ruby-constant">JSON</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-ivar">@values</span>)
|
498
|
+
<span class="ruby-keyword">end</span></pre>
|
499
|
+
</div>
|
500
|
+
</div>
|
501
|
+
|
502
|
+
|
503
|
+
</div>
|
504
|
+
|
505
|
+
<div id="method-i-to_s" class="method-detail ">
|
506
|
+
<div class="method-heading">
|
507
|
+
<span class="method-name">to_s</span><span
|
508
|
+
class="method-args">(*_args)</span>
|
509
|
+
<span class="method-click-advice">click to toggle source</span>
|
510
|
+
</div>
|
511
|
+
|
512
|
+
<div class="method-description">
|
513
|
+
<p>Convert to a string.</p>
|
514
|
+
|
515
|
+
<div class="method-source-code" id="to_s-source">
|
516
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 32</span>
|
517
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_s</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">_args</span>)
|
518
|
+
<span class="ruby-constant">JSON</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-ivar">@values</span>)
|
519
|
+
<span class="ruby-keyword">end</span></pre>
|
520
|
+
</div>
|
521
|
+
</div>
|
522
|
+
|
523
|
+
|
524
|
+
</div>
|
525
|
+
|
526
|
+
<div id="method-i-values" class="method-detail ">
|
527
|
+
<div class="method-heading">
|
528
|
+
<span class="method-name">values</span><span
|
529
|
+
class="method-args">()</span>
|
530
|
+
<span class="method-click-advice">click to toggle source</span>
|
531
|
+
</div>
|
532
|
+
|
533
|
+
<div class="method-description">
|
534
|
+
<p>Values of an object.</p>
|
535
|
+
|
536
|
+
<div class="method-source-code" id="values-source">
|
537
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 82</span>
|
538
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">values</span>
|
539
|
+
<span class="ruby-ivar">@values</span>.<span class="ruby-identifier">values</span>
|
540
|
+
<span class="ruby-keyword">end</span></pre>
|
541
|
+
</div>
|
542
|
+
</div>
|
543
|
+
|
544
|
+
|
545
|
+
</div>
|
546
|
+
|
547
|
+
</section>
|
548
|
+
|
549
|
+
<section id="protected-instance-5Buntitled-5D-method-details" class="method-section">
|
550
|
+
<header>
|
551
|
+
<h3>Protected Instance Methods</h3>
|
552
|
+
</header>
|
553
|
+
|
554
|
+
<div id="method-i-add_accessors" class="method-detail ">
|
555
|
+
<div class="method-heading">
|
556
|
+
<span class="method-name">add_accessors</span><span
|
557
|
+
class="method-args">(keys)</span>
|
558
|
+
<span class="method-click-advice">click to toggle source</span>
|
559
|
+
</div>
|
560
|
+
|
561
|
+
<div class="method-description">
|
562
|
+
<p>Add accessors of an object.</p>
|
563
|
+
|
564
|
+
<div class="method-source-code" id="add_accessors-source">
|
565
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 145</span>
|
566
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_accessors</span>(<span class="ruby-identifier">keys</span>)
|
567
|
+
<span class="ruby-identifier">metaclass</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword">do</span>
|
568
|
+
<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
569
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">@@immutable_values</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
|
570
|
+
|
571
|
+
<span class="ruby-identifier">k</span> = <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>
|
572
|
+
<span class="ruby-identifier">k_eq</span> = <span class="ruby-value">:"#{k}="</span>
|
573
|
+
<span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">k</span>) { <span class="ruby-ivar">@values</span>[<span class="ruby-identifier">k</span>] }
|
574
|
+
<span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">k_eq</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
575
|
+
<span class="ruby-ivar">@values</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
576
|
+
<span class="ruby-ivar">@unsaved_values</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">k</span>)
|
577
|
+
|
578
|
+
<span class="ruby-identifier">cur</span> = <span class="ruby-keyword">self</span>
|
579
|
+
<span class="ruby-identifier">cur_parent</span> = <span class="ruby-identifier">parent</span>
|
580
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">cur_parent</span>
|
581
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">cur</span>.<span class="ruby-identifier">name</span>
|
582
|
+
<span class="ruby-identifier">cur_parent</span>.<span class="ruby-identifier">unsaved_values</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">cur</span>.<span class="ruby-identifier">name</span>)
|
583
|
+
<span class="ruby-keyword">end</span>
|
584
|
+
|
585
|
+
<span class="ruby-identifier">cur</span> = <span class="ruby-identifier">cur_parent</span>
|
586
|
+
<span class="ruby-identifier">cur_parent</span> = <span class="ruby-identifier">cur</span>.<span class="ruby-identifier">parent</span>
|
587
|
+
<span class="ruby-keyword">end</span>
|
588
|
+
<span class="ruby-keyword">end</span>
|
589
|
+
<span class="ruby-keyword">end</span>
|
590
|
+
<span class="ruby-keyword">end</span>
|
591
|
+
<span class="ruby-keyword">end</span></pre>
|
592
|
+
</div>
|
593
|
+
</div>
|
594
|
+
|
595
|
+
|
596
|
+
</div>
|
597
|
+
|
598
|
+
<div id="method-i-flatten_unsaved" class="method-detail ">
|
599
|
+
<div class="method-heading">
|
600
|
+
<span class="method-name">flatten_unsaved</span><span
|
601
|
+
class="method-args">()</span>
|
602
|
+
<span class="method-click-advice">click to toggle source</span>
|
603
|
+
</div>
|
604
|
+
|
605
|
+
<div class="method-description">
|
606
|
+
<p>Flatten the unsaved values of an object.</p>
|
607
|
+
|
608
|
+
<div class="method-source-code" id="flatten_unsaved-source">
|
609
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 124</span>
|
610
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">flatten_unsaved</span>
|
611
|
+
<span class="ruby-identifier">values</span> = {}
|
612
|
+
<span class="ruby-ivar">@unsaved_values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
613
|
+
<span class="ruby-identifier">value</span> = <span class="ruby-ivar">@values</span>[<span class="ruby-identifier">key</span>]
|
614
|
+
|
615
|
+
<span class="ruby-identifier">values</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
616
|
+
|
617
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">EasyPost</span><span class="ruby-operator">::</span><span class="ruby-constant">EasyPostObject</span>)
|
618
|
+
<span class="ruby-identifier">values</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">flatten_unsaved</span>(<span class="ruby-identifier">value</span>)
|
619
|
+
<span class="ruby-keyword">end</span>
|
620
|
+
<span class="ruby-keyword">end</span>
|
621
|
+
|
622
|
+
<span class="ruby-identifier">values</span>
|
623
|
+
<span class="ruby-keyword">end</span></pre>
|
624
|
+
</div>
|
625
|
+
</div>
|
626
|
+
|
627
|
+
|
628
|
+
</div>
|
629
|
+
|
630
|
+
<div id="method-i-metaclass" class="method-detail ">
|
631
|
+
<div class="method-heading">
|
632
|
+
<span class="method-name">metaclass</span><span
|
633
|
+
class="method-args">()</span>
|
634
|
+
<span class="method-click-advice">click to toggle source</span>
|
635
|
+
</div>
|
636
|
+
|
637
|
+
<div class="method-description">
|
638
|
+
<p>The metaclass of an object.</p>
|
639
|
+
|
640
|
+
<div class="method-source-code" id="metaclass-source">
|
641
|
+
<pre><span class="ruby-comment"># File lib/easypost/object.rb, line 140</span>
|
642
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">metaclass</span>
|
643
|
+
<span class="ruby-keyword">class</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword">self</span>; <span class="ruby-keyword">self</span>; <span class="ruby-keyword">end</span>
|
644
|
+
<span class="ruby-keyword">end</span></pre>
|
645
|
+
</div>
|
646
|
+
</div>
|
647
|
+
|
648
|
+
|
649
|
+
</div>
|
650
|
+
|
651
|
+
</section>
|
652
|
+
|
653
|
+
</section>
|
654
|
+
</main>
|
655
|
+
|
656
|
+
|
657
|
+
<footer id="validator-badges" role="contentinfo">
|
658
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
659
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.
|
660
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
661
|
+
</footer>
|
662
|
+
|