mailgun-helper/doc/MailgunTool.html

1075 lines
39 KiB
HTML
Raw Permalink Normal View History

2019-06-10 18:45:27 +02:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: MailgunTool
&mdash; Documentation by YARD 0.9.19
</title>
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
pathId = "MailgunTool";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="_index.html">Index (M)</a> &raquo;
<span class="title">MailgunTool</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: MailgunTool
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">MailgunTool</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>MailGunTool.rb</dd>
</dl>
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#add_list_members-instance_method" title="#add_list_members (instance method)">#<strong>add_list_members</strong>(f) &#x21d2; nil </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Adds email Addresses read from txt file to mailing list.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#del_bounces_from_list-instance_method" title="#del_bounces_from_list (instance method)">#<strong>del_bounces_from_list</strong> &#x21d2; nil </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Delete bounced email addresses.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#delete_list_members-instance_method" title="#delete_list_members (instance method)">#<strong>delete_list_members</strong>(f) &#x21d2; nil </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Deletes email Addresses read from txt file from mailing list.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_adresses-instance_method" title="#get_adresses (instance method)">#<strong>get_adresses</strong>(email = nil) &#x21d2; Array </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>List of email Adresses.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_bounces-instance_method" title="#get_bounces (instance method)">#<strong>get_bounces</strong> &#x21d2; Array </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Fetches list of bounced Addresses.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_logs-instance_method" title="#get_logs (instance method)">#<strong>get_logs</strong> &#x21d2; Array </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Get logs of rejected OR failed recipients.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(list, api_key, domain_name, of = &#39;out.csv&#39;) &#x21d2; MailgunTool </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'>
<p>A new instance of MailgunTool.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#send_message-instance_method" title="#send_message (instance method)">#<strong>send_message</strong> &#x21d2; nil </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Send message.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#send_scheduled_message-instance_method" title="#send_scheduled_message (instance method)">#<strong>send_scheduled_message</strong> &#x21d2; nil </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Send scheduled message.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(list, api_key, domain_name, of = &#39;out.csv&#39;) &#x21d2; <tt><span class='object_link'><a href="" title="MailgunTool (class)">MailgunTool</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of MailgunTool</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
4
5
6
7
8
9
10
11
12
13
14</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 4</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span> <span class='id identifier rubyid_list'>list</span><span class='comma'>,</span> <span class='id identifier rubyid_api_key'>api_key</span><span class='comma'>,</span> <span class='id identifier rubyid_domain_name'>domain_name</span><span class='comma'>,</span> <span class='id identifier rubyid_of'>of</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>out.csv</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># init vars
</span><span class='ivar'>@outfile</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='id identifier rubyid_of'>of</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>a</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='ivar'>@list_address</span> <span class='op'>=</span> <span class='id identifier rubyid_list'>list</span>
<span class='ivar'>@api_key</span> <span class='op'>=</span> <span class='id identifier rubyid_api_key'>api_key</span>
<span class='ivar'>@domain_name</span> <span class='op'>=</span> <span class='id identifier rubyid_domain_name'>domain_name</span>
<span class='ivar'>@mg_client</span> <span class='op'>=</span> <span class='const'>Mailgun</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='ivar'>@api_key</span>
<span class='ivar'>@email_adressen</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='ivar'>@first_run</span> <span class='op'>=</span> <span class='kw'>true</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="add_list_members-instance_method">
#<strong>add_list_members</strong>(f) &#x21d2; <tt>nil</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Adds email Addresses read from txt file to mailing list.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>nil</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
77
78
79
80
81
82
83</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 77</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add_list_members'>add_list_members</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span>
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span> <span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span>
<span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_email'>email</span><span class='op'>|</span>
<span class='id identifier rubyid_p'>p</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/lists/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@list_address</span><span class='embexpr_end'>}</span><span class='tstring_content'>/members</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:subscribed</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:address</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_email'>email</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span><span class='comma'>,</span> <span class='symbol'>:upsert</span> <span class='op'>=&gt;</span> <span class='kw'>true</span> <span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="del_bounces_from_list-instance_method">
#<strong>del_bounces_from_list</strong> &#x21d2; <tt>nil</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Delete bounced email addresses</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>nil</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
146
147
148
149
150
151
152
153
154
155
156</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 146</span>
<span class='kw'>def</span> <span class='id identifier rubyid_del_bounces_from_list'>del_bounces_from_list</span>
<span class='id identifier rubyid_bounces'>bounces</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_bounces'>get_bounces</span>
<span class='id identifier rubyid_bounces'>bounces</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>items</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='lparen'>(</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>code</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>554</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>address</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
<span class='id identifier rubyid_a'>a</span> <span class='op'>=</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>address</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Deleting </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_a'>a</span>
<span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/members/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_a'>a</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="delete_list_members-instance_method">
#<strong>delete_list_members</strong>(f) &#x21d2; <tt>nil</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Deletes email Addresses read from txt file from mailing list.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>nil</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
87
88
89
90
91
92
93
94
95
96
97
98</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 87</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete_list_members'>delete_list_members</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span>
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span> <span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span>
<span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_email'>email</span><span class='op'>|</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_p'>p</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/lists/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@list_address</span><span class='embexpr_end'>}</span><span class='tstring_content'>/members/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_email'>email</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>rescue</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--------\n</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_email'>email</span><span class='embexpr_end'>}</span><span class='tstring_content'> Not found..NEXT\n</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>next</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_adresses-instance_method">
#<strong>get_adresses</strong>(email = nil) &#x21d2; <tt>Array</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns list of email Adresses.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>email</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array</tt>)</span>
&mdash;
<div class='inline'>
<p>list of email Adresses.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 20</span>
<span class='kw'>def</span> <span class='id identifier rubyid_get_adresses'>get_adresses</span><span class='lparen'>(</span> <span class='id identifier rubyid_email'>email</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
<span class='kw'>if</span> <span class='ivar'>@first_run</span> <span class='op'>==</span> <span class='kw'>true</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>lists/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@list_address</span><span class='embexpr_end'>}</span><span class='tstring_content'>/members/pages</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:subscribed</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>yes</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='ivar'>@first_run</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='kw'>else</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_email'>email</span> <span class='op'>==</span> <span class='kw'>nil</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>lists/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@list_address</span><span class='embexpr_end'>}</span><span class='tstring_content'>/members/pages</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:subscribed</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>yes</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='symbol'>:address</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_email'>email</span> <span class='comma'>,</span> <span class='symbol'>:page</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>next</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>No Email Adress ??</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_my_hash'>my_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_email_addresses'>extract_email_addresses</span><span class='lparen'>(</span><span class='id identifier rubyid_my_hash'>my_hash</span><span class='rparen'>)</span>
<span class='comment'># check if more
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_my_hash'>my_hash</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>items</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>0</span>
<span class='id identifier rubyid_email'>email</span> <span class='op'>=</span> <span class='ivar'>@email_adressen</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_adresses'>get_adresses</span><span class='lparen'>(</span><span class='id identifier rubyid_email'>email</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fertig</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>return</span> <span class='ivar'>@email_adressen</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_bounces-instance_method">
#<strong>get_bounces</strong> &#x21d2; <tt>Array</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Fetches list of bounced Addresses.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array</tt>)</span>
&mdash;
<div class='inline'>
<p>list of bounced email.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 50</span>
<span class='kw'>def</span> <span class='id identifier rubyid_get_bounces'>get_bounces</span>
<span class='kw'>if</span> <span class='ivar'>@first_run</span> <span class='op'>==</span> <span class='kw'>true</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@domain_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>/bounces</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='ivar'>@first_run</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='kw'>else</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_email'>email</span> <span class='op'>==</span> <span class='kw'>nil</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@domain_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>/bounces</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:address</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_email'>email</span> <span class='comma'>,</span> <span class='symbol'>:page</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>next</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>No Email Adress ??</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_my_hash'>my_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_email_addresses'>extract_email_addresses</span><span class='lparen'>(</span><span class='id identifier rubyid_my_hash'>my_hash</span><span class='rparen'>)</span>
<span class='comment'># check if more
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_my_hash'>my_hash</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>items</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>0</span>
<span class='id identifier rubyid_email'>email</span> <span class='op'>=</span> <span class='ivar'>@email_adressen</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_adresses'>get_adresses</span><span class='lparen'>(</span><span class='id identifier rubyid_email'>email</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_p'>p</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>------------ Fertig --------------</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>return</span> <span class='ivar'>@email_adressen</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_logs-instance_method">
#<strong>get_logs</strong> &#x21d2; <tt>Array</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Get logs of rejected OR failed recipients</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array</tt>)</span>
&mdash;
<div class='inline'>
<p>of email addresses</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 127</span>
<span class='kw'>def</span> <span class='id identifier rubyid_get_logs'>get_logs</span>
<span class='id identifier rubyid_em'>em</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_resp'>resp</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='op'>::</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span> <span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://api:</span><span class='embexpr_beg'>#{</span><span class='ivar'>@api_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>@api.mailgun.net/v3/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@domain_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>/events</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:params</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:&quot;event&quot;</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>rejected OR failed</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span> <span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_resp'>resp</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>items</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>0</span>
<span class='id identifier rubyid_resp'>resp</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>items</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>recipient</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
<span class='id identifier rubyid_em'>em</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>recipient</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='rparen'>)</span>
<span class='rbrace'>}</span>
<span class='kw'>return</span> <span class='id identifier rubyid_em'>em</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_p'>p</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> No failed or rejected recipients ....</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="send_message-instance_method">
#<strong>send_message</strong> &#x21d2; <tt>nil</tt>
</h3><div class="docstring">
<div class="discussion">
<div class="note todo">
<strong>TODO:</strong>
<div class='inline'>
<p>email parameters</p>
</div>
</div>
<p>Send message</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>nil</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
116
117
118
119
120
121
122
123</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 116</span>
<span class='kw'>def</span> <span class='id identifier rubyid_send_message'>send_message</span>
<span class='id identifier rubyid_p'>p</span> <span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@domain_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>/messages</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:from</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt;mail@example.com&gt;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:to</span> <span class='op'>=&gt;</span> <span class='ivar'>@list_address</span><span class='comma'>,</span>
<span class='symbol'>:subject</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>TEST</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:text</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>TEST TEST TEST, %unsubscribe_url% </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:html</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>TEST TEST TEST, %unsubscribe_url% </span><span class='tstring_end'>&#39;</span></span> <span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="send_scheduled_message-instance_method">
#<strong>send_scheduled_message</strong> &#x21d2; <tt>nil</tt>
</h3><div class="docstring">
<div class="discussion">
<div class="note todo">
<strong>TODO:</strong>
<div class='inline'>
<p>email parameters</p>
</div>
</div>
<p>Send scheduled message</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>nil</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
103
104
105
106
107
108
109
110
111</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'MailGunTool.rb', line 103</span>
<span class='kw'>def</span> <span class='id identifier rubyid_send_scheduled_message'>send_scheduled_message</span>
<span class='ivar'>@mg_client</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@domain_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>/messages</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:from</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt;mail@example.com&gt;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:to</span> <span class='op'>=&gt;</span> <span class='ivar'>@list_address</span><span class='comma'>,</span>
<span class='symbol'>:subject</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Toller Test</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:text</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Testing some Mailgun awesomeness! %mailing_list_unsubscribe_url% </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='symbol'>:html</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt;h1&gt;html supi test&lt;/h1&gt;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>o:deliverytime</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Mon, 10 Jun 2019 17:15:00 +0200</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Jun 10 18:44:30 2019 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.19 (ruby-2.6.3).
</div>
</div>
</body>
</html>