Class: Rgcm::RequestBuilder

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

Constant Summary collapse

URI =
'https://android.googleapis.com/gcm/send'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, registration_ids, collapse_key, data) ⇒ RequestBuilder

Returns a new instance of RequestBuilder.



8
9
10
11
12
13
# File 'lib/rgcm/request_builder.rb', line 8

def initialize(api_key, registration_ids,  collapse_key, data)
  @api_key = api_key
  @registration_ids = registration_ids.kind_of?(Array) ? registration_ids : [registration_ids]
  @collapse_key = collapse_key
  @data = data
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/rgcm/request_builder.rb', line 6

def api_key
  @api_key
end

#collapse_keyObject (readonly)

Returns the value of attribute collapse_key.



6
7
8
# File 'lib/rgcm/request_builder.rb', line 6

def collapse_key
  @collapse_key
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/rgcm/request_builder.rb', line 6

def data
  @data
end

#registration_idsObject (readonly)

Returns the value of attribute registration_ids.



6
7
8
# File 'lib/rgcm/request_builder.rb', line 6

def registration_ids
  @registration_ids
end

Instance Method Details

#buildObject



15
16
17
# File 'lib/rgcm/request_builder.rb', line 15

def build
  Typhoeus::Request.new(URI, headers: headers, method: :post, body: body.to_json, followlocation: true)
end