Class: InternetBS::DomainPush

Inherits:
Base
  • Object
show all
Defined in:
lib/internetbs/domain_push.rb

Instance Method Summary collapse

Methods inherited from Base

#inspect

Instance Method Details

#push!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/internetbs/domain_push.rb', line 6

def push!
  ensure_attribute_has_value :domain, :email_address
  return false if @errors.any?
  
  params = {'domain' => @domain, 'destination' => @email_address}
  response = Client.post('/domain/push', params)
  code = response.code rescue ""
  
  case code
  when '200'
    hash = JSON.parse(response.body)

    @status = hash['status']
    @transaction_id = hash['transactid']
    
    unless @status == 'SUCCESS'
      set_errors(response)
      return false
    end
    
    return true
  else
    set_errors(response)
    return false
  end
end