Class: HeyYou::Config::Push

Inherits:
Object
  • Object
show all
Extended by:
Configurable
Defined in:
lib/hey_you/config/push.rb

Defined Under Namespace

Classes: FcmTokenNotExists

Constant Summary collapse

DEFAULT_PRIORITY =
'high'
DEFAULT_TTL =
60
DEFAULT_FCM_TIMEOUT =
30

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

config, configure, extended

Constructor Details

#initializePush

Returns a new instance of Push.



15
16
17
18
19
# File 'lib/hey_you/config/push.rb', line 15

def initialize
  @priority = DEFAULT_PRIORITY
  @ttl = DEFAULT_TTL
  @fcm_timeout = DEFAULT_FCM_TIMEOUT
end

Instance Attribute Details

#fcm_timeoutObject

Returns the value of attribute fcm_timeout.



13
14
15
# File 'lib/hey_you/config/push.rb', line 13

def fcm_timeout
  @fcm_timeout
end

#fcm_tokenObject

Returns the value of attribute fcm_token.



13
14
15
# File 'lib/hey_you/config/push.rb', line 13

def fcm_token
  @fcm_token
end

#priorityObject

Returns the value of attribute priority.



13
14
15
# File 'lib/hey_you/config/push.rb', line 13

def priority
  @priority
end

#ttlObject

Returns the value of attribute ttl.



13
14
15
# File 'lib/hey_you/config/push.rb', line 13

def ttl
  @ttl
end

Instance Method Details

#fcm_clientObject

Raises:



21
22
23
24
# File 'lib/hey_you/config/push.rb', line 21

def fcm_client
  raise FcmTokenNotExists, 'Can\'t create fcm client: fcm_token not exists' unless fcm_token
  @fcm_client ||= FCM.new(fcm_token, timeout: fcm_timeout)
end