Class: API::WhatCounts::OneOffMessage

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/whatcounts/base.rb

Overview

class Service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_data = {}) ⇒ OneOffMessage

Returns a new instance of OneOffMessage.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/whatcounts/base.rb', line 79

def initialize(message_data = {})
  # check for required params
  [:pwd, :list_id, :realm, :format, :to, :template_id, :data].each do |key|
    raise ServiceError, "#{key.to_s} is required" unless message_data.has_key?(key)
  end
  
  self.api_service = API::WhatCounts::Service.new
  
  self.pwd          = message_data[:pwd]
  self.list_id      = message_data[:list_id]
  self.realm        = message_data[:realm]
  self.format       = message_data[:format]
  self.to           = message_data[:to]
  self.template_id  = message_data[:template_id]
  self.data         = build_data_args(message_data[:data])
end

Instance Attribute Details

#api_serviceObject

Returns the value of attribute api_service.



77
78
79
# File 'lib/whatcounts/base.rb', line 77

def api_service
  @api_service
end

#dataObject

Returns the value of attribute data.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def data
  @data
end

#formatObject

Returns the value of attribute format.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def format
  @format
end

#list_idObject

Returns the value of attribute list_id.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def list_id
  @list_id
end

#pwdObject

Returns the value of attribute pwd.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def pwd
  @pwd
end

#realmObject

Returns the value of attribute realm.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def realm
  @realm
end

#template_idObject

Returns the value of attribute template_id.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def template_id
  @template_id
end

#toObject

Returns the value of attribute to.



76
77
78
# File 'lib/whatcounts/base.rb', line 76

def to
  @to
end

Instance Method Details

#sendObject



96
97
98
99
100
101
102
# File 'lib/whatcounts/base.rb', line 96

def send
  msg = self.api_service.send_one_off_message(self)
  
  return msg.result
rescue ServiceError
  return false
end