Class: Rgcm::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/rgcm/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Rgcm::Config) ⇒ Message

Returns a new instance of Message.



6
7
8
9
10
11
12
13
14
# File 'lib/rgcm/message.rb', line 6

def initialize(config = Rgcm::Config)
  if config.kind_of?(String)
    @api_key = config
  elsif config.kind_of?(Hash)
    @api_key = config[:api_key]
  elsif config.kind_of?(Class)
    @api_key = config.api_key
  end
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



4
5
6
# File 'lib/rgcm/message.rb', line 4

def api_key
  @api_key
end

Instance Method Details

#post(registration_ids, data, options = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rgcm/message.rb', line 16

def post(registration_ids, data, options=nil)
  request = RequestBuilder.new(api_key, registration_ids, options, data).build

  response = request.run

  Rgcm::Response.new(response.body)
end