easypost 4.8.1 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +5 -0
  3. data/.github/workflows/ci.yml +8 -0
  4. data/.gitignore +10 -14
  5. data/CHANGELOG.md +4 -0
  6. data/Makefile +10 -2
  7. data/README.md +5 -1
  8. data/VERSION +1 -1
  9. data/docs/EasyPost/Address.html +222 -0
  10. data/docs/EasyPost/ApiKey.html +99 -0
  11. data/docs/EasyPost/Batch.html +269 -0
  12. data/docs/EasyPost/Beta/EndShipper.html +225 -0
  13. data/docs/EasyPost/Beta/Referral.html +338 -0
  14. data/docs/EasyPost/Beta.html +91 -0
  15. data/docs/EasyPost/Billing.html +253 -0
  16. data/docs/EasyPost/Brand.html +140 -0
  17. data/docs/EasyPost/CarbonOffset.html +99 -0
  18. data/docs/EasyPost/CarrierAccount.html +136 -0
  19. data/docs/EasyPost/CarrierType.html +99 -0
  20. data/docs/EasyPost/CustomsInfo.html +136 -0
  21. data/docs/EasyPost/CustomsItem.html +136 -0
  22. data/docs/EasyPost/EasyPostObject.html +662 -0
  23. data/docs/EasyPost/EndShipper.html +175 -0
  24. data/docs/EasyPost/Error.html +258 -0
  25. data/docs/EasyPost/Event.html +136 -0
  26. data/docs/EasyPost/Insurance.html +99 -0
  27. data/docs/EasyPost/Order.html +222 -0
  28. data/docs/EasyPost/Parcel.html +136 -0
  29. data/docs/EasyPost/PaymentMethod.html +137 -0
  30. data/docs/EasyPost/Pickup.html +222 -0
  31. data/docs/EasyPost/PickupRate.html +99 -0
  32. data/docs/EasyPost/PostageLabel.html +99 -0
  33. data/docs/EasyPost/Rate.html +136 -0
  34. data/docs/EasyPost/Referral.html +334 -0
  35. data/docs/EasyPost/Refund.html +99 -0
  36. data/docs/EasyPost/Report.html +167 -0
  37. data/docs/EasyPost/Resource.html +399 -0
  38. data/docs/EasyPost/ScanForm.html +137 -0
  39. data/docs/EasyPost/Shipment.html +456 -0
  40. data/docs/EasyPost/TaxIdentifier.html +99 -0
  41. data/docs/EasyPost/Tracker.html +139 -0
  42. data/docs/EasyPost/User.html +307 -0
  43. data/docs/EasyPost/Util.html +462 -0
  44. data/docs/EasyPost/Webhook.html +221 -0
  45. data/docs/EasyPost.html +440 -0
  46. data/docs/created.rid +40 -0
  47. data/docs/css/fonts.css +167 -0
  48. data/docs/css/rdoc.css +639 -0
  49. data/docs/fonts/Lato-Light.ttf +0 -0
  50. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  51. data/docs/fonts/Lato-Regular.ttf +0 -0
  52. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  53. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  54. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  55. data/docs/images/add.png +0 -0
  56. data/docs/images/arrow_up.png +0 -0
  57. data/docs/images/brick.png +0 -0
  58. data/docs/images/brick_link.png +0 -0
  59. data/docs/images/bug.png +0 -0
  60. data/docs/images/bullet_black.png +0 -0
  61. data/docs/images/bullet_toggle_minus.png +0 -0
  62. data/docs/images/bullet_toggle_plus.png +0 -0
  63. data/docs/images/date.png +0 -0
  64. data/docs/images/delete.png +0 -0
  65. data/docs/images/find.png +0 -0
  66. data/docs/images/loadingAnimation.gif +0 -0
  67. data/docs/images/macFFBgHack.png +0 -0
  68. data/docs/images/package.png +0 -0
  69. data/docs/images/page_green.png +0 -0
  70. data/docs/images/page_white_text.png +0 -0
  71. data/docs/images/page_white_width.png +0 -0
  72. data/docs/images/plugin.png +0 -0
  73. data/docs/images/ruby.png +0 -0
  74. data/docs/images/tag_blue.png +0 -0
  75. data/docs/images/tag_green.png +0 -0
  76. data/docs/images/transparent.png +0 -0
  77. data/docs/images/wrench.png +0 -0
  78. data/docs/images/wrench_orange.png +0 -0
  79. data/docs/images/zoom.png +0 -0
  80. data/docs/index.html +117 -0
  81. data/docs/js/darkfish.js +84 -0
  82. data/docs/js/navigation.js +105 -0
  83. data/docs/js/navigation.js.gz +0 -0
  84. data/docs/js/search.js +110 -0
  85. data/docs/js/search_index.js +1 -0
  86. data/docs/js/search_index.js.gz +0 -0
  87. data/docs/js/searcher.js +229 -0
  88. data/docs/js/searcher.js.gz +0 -0
  89. data/docs/table_of_contents.html +785 -0
  90. data/easypost.gemspec +3 -1
  91. data/lib/easypost/carrier_account.rb +17 -0
  92. data/lib/easypost/shipment.rb +1 -1
  93. data/lib/easypost/user.rb +5 -2
  94. data/lib/easypost/util.rb +2 -0
  95. metadata +115 -6
@@ -0,0 +1,221 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class EasyPost::Webhook - 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"><a href="Resource.html">EasyPost::Resource</a>
65
+ </div>
66
+
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+ <li ><a href="#method-c-validate_webhook">::validate_webhook</a>
76
+ <li ><a href="#method-i-delete">#delete</a>
77
+ <li ><a href="#method-i-update">#update</a>
78
+ </ul>
79
+ </div>
80
+
81
+ </div>
82
+ </nav>
83
+
84
+ <main role="main" aria-labelledby="class-EasyPost::Webhook">
85
+ <h1 id="class-EasyPost::Webhook" class="class">
86
+ class EasyPost::Webhook
87
+ </h1>
88
+
89
+ <section class="description">
90
+
91
+ <p>Each <a href="Webhook.html"><code>Webhook</code></a> contains the url which <a href="../EasyPost.html"><code>EasyPost</code></a> will notify whenever an object in our system updates. Several types of objects are processed asynchronously in the <a href="../EasyPost.html"><code>EasyPost</code></a> system, so whenever an object updates, an Event is sent via HTTP POST to each configured webhook URL.</p>
92
+
93
+ </section>
94
+
95
+ <section id="5Buntitled-5D" class="documentation-section">
96
+
97
+
98
+
99
+
100
+
101
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
102
+ <header>
103
+ <h3>Public Class Methods</h3>
104
+ </header>
105
+
106
+ <div id="method-c-validate_webhook" class="method-detail ">
107
+ <div class="method-heading">
108
+ <span class="method-name">validate_webhook</span><span
109
+ class="method-args">(event_body, headers, webhook_secret)</span>
110
+ <span class="method-click-advice">click to toggle source</span>
111
+ </div>
112
+
113
+ <div class="method-description">
114
+ <p>Validate a webhook by comparing the HMAC signature header sent from <a href="../EasyPost.html"><code>EasyPost</code></a> to your shared secret. If the signatures do not match, an error will be raised signifying the webhook either did not originate from <a href="../EasyPost.html"><code>EasyPost</code></a> or the secrets do not match. If the signatures do match, the ‘event_body` will be returned as JSON.</p>
115
+
116
+ <div class="method-source-code" id="validate_webhook-source">
117
+ <pre><span class="ruby-comment"># File lib/easypost/webhook.rb, line 40</span>
118
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">validate_webhook</span>(<span class="ruby-identifier">event_body</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">webhook_secret</span>)
119
+ <span class="ruby-identifier">easypost_hmac_signature</span> = <span class="ruby-identifier">headers</span>[<span class="ruby-string">&#39;X-Hmac-Signature&#39;</span>]
120
+
121
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">easypost_hmac_signature</span>.<span class="ruby-identifier">nil?</span>
122
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">EasyPost</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;Webhook received does not contain an HMAC signature.&#39;</span>)
123
+ <span class="ruby-keyword">end</span>
124
+
125
+ <span class="ruby-identifier">encoded_webhook_secret</span> = <span class="ruby-identifier">webhook_secret</span>.<span class="ruby-identifier">unicode_normalize</span>(<span class="ruby-value">:nfkd</span>).<span class="ruby-identifier">encode</span>(<span class="ruby-string">&#39;utf-8&#39;</span>)
126
+
127
+ <span class="ruby-identifier">expected_signature</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">HMAC</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-string">&#39;sha256&#39;</span>, <span class="ruby-identifier">encoded_webhook_secret</span>, <span class="ruby-identifier">event_body</span>)
128
+ <span class="ruby-identifier">digest</span> = <span class="ruby-node">&quot;hmac-sha256-hex=#{expected_signature}&quot;</span>
129
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">digest</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">easypost_hmac_signature</span>
130
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">EasyPost</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;Webhook received did not originate from EasyPost or had a webhook secret mismatch.&#39;</span>)
131
+ <span class="ruby-keyword">end</span>
132
+
133
+ <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">event_body</span>)
134
+ <span class="ruby-keyword">end</span></pre>
135
+ </div>
136
+ </div>
137
+
138
+
139
+ </div>
140
+
141
+ </section>
142
+
143
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
144
+ <header>
145
+ <h3>Public Instance Methods</h3>
146
+ </header>
147
+
148
+ <div id="method-i-delete" class="method-detail ">
149
+ <div class="method-heading">
150
+ <span class="method-name">delete</span><span
151
+ class="method-args">()</span>
152
+ <span class="method-click-advice">click to toggle source</span>
153
+ </div>
154
+
155
+ <div class="method-description">
156
+ <p>Delete a <a href="Webhook.html"><code>Webhook</code></a>.</p>
157
+
158
+ <div class="method-source-code" id="delete-source">
159
+ <pre><span class="ruby-comment"># File lib/easypost/webhook.rb, line 22</span>
160
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete</span>
161
+ <span class="ruby-comment"># NOTE: This method is redefined here since the &quot;url&quot; method conflicts with the objects field</span>
162
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">id</span>
163
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">EasyPost</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}&quot;</span>)
164
+ <span class="ruby-keyword">end</span>
165
+
166
+ <span class="ruby-identifier">instance_url</span> = <span class="ruby-node">&quot;#{self.class.url}/#{CGI.escape(id)}&quot;</span>
167
+
168
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">EasyPost</span>.<span class="ruby-identifier">make_request</span>(<span class="ruby-value">:delete</span>, <span class="ruby-identifier">instance_url</span>, <span class="ruby-ivar">@api_key</span>)
169
+ <span class="ruby-identifier">refresh_from</span>(<span class="ruby-identifier">response</span>, <span class="ruby-identifier">api_key</span>)
170
+
171
+ <span class="ruby-keyword">self</span>
172
+ <span class="ruby-keyword">end</span></pre>
173
+ </div>
174
+ </div>
175
+
176
+
177
+ </div>
178
+
179
+ <div id="method-i-update" class="method-detail ">
180
+ <div class="method-heading">
181
+ <span class="method-name">update</span><span
182
+ class="method-args">(params = {})</span>
183
+ <span class="method-click-advice">click to toggle source</span>
184
+ </div>
185
+
186
+ <div class="method-description">
187
+ <p>Update a <a href="Webhook.html"><code>Webhook</code></a>.</p>
188
+
189
+ <div class="method-source-code" id="update-source">
190
+ <pre><span class="ruby-comment"># File lib/easypost/webhook.rb, line 7</span>
191
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update</span>(<span class="ruby-identifier">params</span> = {})
192
+ <span class="ruby-comment"># NOTE: This method is redefined here since the &quot;url&quot; method conflicts with the objects field</span>
193
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">id</span>
194
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">EasyPost</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}&quot;</span>)
195
+ <span class="ruby-keyword">end</span>
196
+
197
+ <span class="ruby-identifier">instance_url</span> = <span class="ruby-node">&quot;#{self.class.url}/#{CGI.escape(id)}&quot;</span>
198
+
199
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">EasyPost</span>.<span class="ruby-identifier">make_request</span>(<span class="ruby-value">:patch</span>, <span class="ruby-identifier">instance_url</span>, <span class="ruby-ivar">@api_key</span>, <span class="ruby-identifier">params</span>)
200
+ <span class="ruby-identifier">refresh_from</span>(<span class="ruby-identifier">response</span>, <span class="ruby-identifier">api_key</span>)
201
+
202
+ <span class="ruby-keyword">self</span>
203
+ <span class="ruby-keyword">end</span></pre>
204
+ </div>
205
+ </div>
206
+
207
+
208
+ </div>
209
+
210
+ </section>
211
+
212
+ </section>
213
+ </main>
214
+
215
+
216
+ <footer id="validator-badges" role="contentinfo">
217
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
218
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.
219
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
220
+ </footer>
221
+