Class: Guerrilla
- Inherits:
-
Object
- Object
- Guerrilla
- Defined in:
- lib/guerrilla_mailX/api.rb
Instance Attribute Summary collapse
-
#alias_id ⇒ Object
Returns the value of attribute alias_id.
-
#email ⇒ Object
Returns the value of attribute email.
-
#sid_token ⇒ Object
Returns the value of attribute sid_token.
-
#time ⇒ Object
Returns the value of attribute time.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#valid_till ⇒ Object
Returns the value of attribute valid_till.
Class Method Summary collapse
- .del_email(sid_token: nil, email_ids: nil) ⇒ Object
- .forget_me(sid_token: nil, email_addr: nil) ⇒ Object
- .get_email_address ⇒ Object
Instance Method Summary collapse
- #check_email(sid_token: nil, seq: 0) ⇒ Object
- #del_email(sid_token: nil, email_ids: nil) ⇒ Object
- #fetch_email(sid_token: nil, mail_id: nil) ⇒ Object
- #forget_me(sid_token: nil, email_addr: nil) ⇒ Object
- #get_email_list(sid_token: nil, offset: 0, seq: 0) ⇒ Object
- #get_older_list(sid_token: nil, seq: nil, limit: nil) ⇒ Object
-
#initialize(email_id = nil, sid_token: nil) ⇒ Guerrilla
constructor
A new instance of Guerrilla.
- #set_email_user(sid_token: nil, email_user: nil, lang: 'en', site: nil) ⇒ Object
- #verify_last_mail(sid_token: nil, wait: 120, body: nil, subject: nil) ⇒ Object
- #verify_mail(sid_token: nil, email_id: nil, offset: nil, wait: 120, body: nil, subject: nil) ⇒ Object
Constructor Details
#initialize(email_id = nil, sid_token: nil) ⇒ Guerrilla
Returns a new instance of Guerrilla.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/guerrilla_mailX/api.rb', line 23 def initialize(email_id = nil, sid_token: nil) if !sid_token.present? response = send_request("POST", "https://api.guerrillamail.com/ajax.php?f=get_email_address") @sid_token = sid_token = response[:body][:sid_token] else @sid_token = sid_token end if email_id.present? set_email_url = "https://api.guerrillamail.com/ajax.php?f=set_email_user&email_user=#{email_id}&lang=en&sid_token=#{sid_token}" response = send_request("POST",set_email_url) # site_id = response[:body][:site_id] # site = response[:body][:site] end @email = response[:body][:email_addr] @alias_id = response[:body][:alias] @timestamp = response[:body][:email_timestamp] @time = Time.at().to_datetime.to_s @valid_till = Time.at(+3600).to_datetime.to_s end |
Instance Attribute Details
#alias_id ⇒ Object
Returns the value of attribute alias_id.
21 22 23 |
# File 'lib/guerrilla_mailX/api.rb', line 21 def alias_id @alias_id end |
#email ⇒ Object
Returns the value of attribute email.
21 22 23 |
# File 'lib/guerrilla_mailX/api.rb', line 21 def email @email end |
#sid_token ⇒ Object
Returns the value of attribute sid_token.
21 22 23 |
# File 'lib/guerrilla_mailX/api.rb', line 21 def sid_token @sid_token end |
#time ⇒ Object
Returns the value of attribute time.
21 22 23 |
# File 'lib/guerrilla_mailX/api.rb', line 21 def time @time end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
21 22 23 |
# File 'lib/guerrilla_mailX/api.rb', line 21 def @timestamp end |
#valid_till ⇒ Object
Returns the value of attribute valid_till.
21 22 23 |
# File 'lib/guerrilla_mailX/api.rb', line 21 def valid_till @valid_till end |
Class Method Details
.del_email(sid_token: nil, email_ids: nil) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/guerrilla_mailX/api.rb', line 205 def self.del_email(sid_token: nil, email_ids: nil) if !sid_token.present? puts "\e[31mArgument Required\e[0m: No \e[33msid_token\e[0m given" raise Error.new.("sid_token") return end email_s = "" if email_ids.present? email_ids.each do |e| email_s += "&email_ids[]=#{e}" end end del_email_url = "https://api.guerrillamail.com/ajax.php?f=del_email&sid_token=#{sid_token}#{email_s}" response = send_request("POST",del_email_url) end |
.forget_me(sid_token: nil, email_addr: nil) ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/guerrilla_mailX/api.rb', line 181 def self.forget_me(sid_token: nil, email_addr: nil) if !sid_token.present? puts "\e[31mArgument Required\e[0m: No \e[33msid_token\e[0m given" raise Error.new.("sid_token") return end forget_sid_url = "https://api.guerrillamail.com/ajax.php?f=forget_me&sid_token=#{sid_token}&email_addr=#{email_addr}" response = send_request("POST",forget_sid_url) end |
.get_email_address ⇒ Object
44 45 46 |
# File 'lib/guerrilla_mailX/api.rb', line 44 def self.get_email_address response = send_request("POST", "https://api.guerrillamail.com/ajax.php?f=get_email_address") end |
Instance Method Details
#check_email(sid_token: nil, seq: 0) ⇒ Object
142 143 144 145 146 147 148 149 |
# File 'lib/guerrilla_mailX/api.rb', line 142 def check_email(sid_token: nil, seq: 0) if !sid_token.present? sid_token = @sid_token end check_email_url = "https://api.guerrillamail.com/ajax.php?f=check_email&seq=#{seq}&sid_token=#{sid_token}" response = send_request("POST",check_email_url) return response end |
#del_email(sid_token: nil, email_ids: nil) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/guerrilla_mailX/api.rb', line 191 def del_email(sid_token: nil, email_ids: nil) if !sid_token.present? sid_token = @sid_token end email_s = "" if email_ids.present? email_ids.each do |e| email_s += "&email_ids[]=#{e}" end end del_email_url = "https://api.guerrillamail.com/ajax.php?f=del_email&sid_token=#{sid_token}#{email_s}" response = send_request("POST",del_email_url) end |
#fetch_email(sid_token: nil, mail_id: nil) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/guerrilla_mailX/api.rb', line 160 def fetch_email(sid_token: nil, mail_id: nil) if !mail_id.present? puts "\e[31mArgument Required\e[0m: No \e[33mmail_id\e[0m given" raise Error.new.("mail_id") return end if !sid_token.present? sid_token = @sid_token end fetch_email_url = "https://api.guerrillamail.com/ajax.php?f=fetch_email&sid_token=#{sid_token}&email_id=#{mail_id}" response = send_request("POST",fetch_email_url) end |
#forget_me(sid_token: nil, email_addr: nil) ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/guerrilla_mailX/api.rb', line 173 def forget_me(sid_token: nil, email_addr: nil) if !sid_token.present? sid_token = @sid_token end forget_sid_url = "https://api.guerrillamail.com/ajax.php?f=forget_me&sid_token=#{sid_token}&email_addr=#{email_addr}" response = send_request("POST",forget_sid_url) end |
#get_email_list(sid_token: nil, offset: 0, seq: 0) ⇒ Object
151 152 153 154 155 156 157 158 |
# File 'lib/guerrilla_mailX/api.rb', line 151 def get_email_list(sid_token: nil, offset: 0, seq: 0) if !sid_token.present? sid_token = @sid_token end get_email_list_url = "https://api.guerrillamail.com/ajax.php?f=get_email_list&offset=#{offset}&seq=#{seq}&sid_token=#{sid_token}" response = send_request("POST",get_email_list_url) return response end |
#get_older_list(sid_token: nil, seq: nil, limit: nil) ⇒ Object
221 222 223 224 225 226 227 |
# File 'lib/guerrilla_mailX/api.rb', line 221 def get_older_list(sid_token: nil, seq: nil, limit: nil) if !sid_token.present? sid_token = @sid_token end get_older_list_url = "https://api.guerrillamail.com/ajax.php?f=get_older_list&sid_token=#{sid_token}&seq=#{seq}&limit=#{limit}" response = send_request("POST",get_older_list_url) end |
#set_email_user(sid_token: nil, email_user: nil, lang: 'en', site: nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/guerrilla_mailX/api.rb', line 48 def set_email_user(sid_token: nil, email_user: nil, lang: 'en', site: nil) if !sid_token.present? sid_token = @sid_token end set_email_url = "https://api.guerrillamail.com/ajax.php?f=set_email_user&email_user=#{email_user}&lang=#{lang}&sid_token=#{sid_token}&site=#{site}" response = send_request("POST",set_email_url) end |
#verify_last_mail(sid_token: nil, wait: 120, body: nil, subject: nil) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/guerrilla_mailX/api.rb', line 56 def verify_last_mail sid_token: nil, wait: 120, body: nil, subject: nil if !subject.present? puts "\e[31mArgument Required\e[0m: No \e[33msubject\e[0m given" raise Error.new.("subject") return end if !sid_token.present? sid_token = @sid_token end get_email_list_url = "https://api.guerrillamail.com/ajax.php?f=get_email_list&offset=0&sid_token=#{sid_token}" result = {} start_minute = Time.now while Time.now <= start_minute + wait sleep(5) response = send_request("POST",get_email_list_url) return "No Mail Present" if response[:body][:list] == nil || response[:body][:list][0] == nil mail_id = response[:body][:list][0][:mail_id] fetch_email_url = "https://api.guerrillamail.com/ajax.php?f=fetch_email&email_id=#{mail_id}&sid_token=#{sid_token}" email_response = send_request("POST",fetch_email_url) break if (email_response[:body][:mail_subject]).include?(subject.to_s) end if email_response[:body][:mail_subject].include?(subject) result[:subject] = true else result[:subject] = false end if body.present? if email_response[:body][:mail_body].include?(body) result[:body] = true else result[:body] = false end end return result end |
#verify_mail(sid_token: nil, email_id: nil, offset: nil, wait: 120, body: nil, subject: nil) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/guerrilla_mailX/api.rb', line 93 def verify_mail sid_token: nil, email_id: nil, offset: nil, wait: 120, body: nil, subject: nil if !subject.present? puts "\e[31mArgument Required\e[0m: No \e[33msubject\e[0m given" raise Error.new.("subject") return end if !sid_token.present? sid_token = @sid_token end if !email_id.present? if offset.present? get_email_list_url = "https://api.guerrillamail.com/ajax.php?f=get_email_list&offset=#{offset}&sid_token=#{sid_token}" else get_email_list_url = "https://api.guerrillamail.com/ajax.php?f=get_email_list&offset=0&sid_token=#{sid_token}" end end result ={} start_minute = Time.now while Time.now <= start_minute + wait sleep(5) if !email_id.present? response = send_request("POST",get_email_list_url) return "No Mail Present" if response[:body][:list] == nil || response[:body][:list][0] == nil mail_id = response[:body][:list][0][:mail_id] else mail_id = email_id end fetch_email_url = "https://api.guerrillamail.com/ajax.php?f=fetch_email&email_id=#{mail_id}&sid_token=#{sid_token}" email_response = send_request("POST",fetch_email_url) break if (email_response[:body][:mail_subject]).include?(subject.to_s) end if email_response[:body][:mail_subject].include?(subject) result[:subject] = true else result[:subject] = false end if body.present? if email_response[:body][:mail_body].include?(body) result[:body] = true else result[:body] = false end end return result end |