Module: Fcmpush

Defined in:
lib/fcmpush.rb,
lib/fcmpush/batch.rb,
lib/fcmpush/client.rb,
lib/fcmpush/version.rb,
lib/fcmpush/exceptions.rb,
lib/fcmpush/configuration.rb,
lib/fcmpush/json_response.rb,
lib/fcmpush/batch_response.rb

Defined Under Namespace

Modules: Batch Classes: APIError, BadGateway, BadRequest, BatchResponse, Client, ClientError, Configuration, Conflict, Error, ExpectationFailed, FailedDependency, Forbidden, GatewayTimeout, Gone, HTTPVersionNotSupported, HttpError, ImaTeapot, InsufficientStorage, InternalServerError, JsonResponse, LengthRequired, Locked, LoopDetected, MethodNotAllowed, MisdirectedRequest, NetworkAuthenticationRequired, NetworkError, NotAcceptable, NotExtended, NotFound, NotImplemented, PayloadTooLarge, PaymentRequired, PreconditionFailed, PreconditionRequired, ProxyAuthenticationRequired, RangeNotSatisfiable, RequestHeaderFieldsTooLarge, RequestTimeout, ServerError, ServiceUnavailable, TooManyRequests, URITooLong, Unauthorized, UnavailableForLegalReasons, UnprocessableEntity, UnsupportedMediaType, UpgradeRequired, VariantAlsoNegotiates

Constant Summary collapse

DOMAIN =
'https://fcm.googleapis.com'.freeze
V1_ENDPOINT_PREFIX =
'/v1/projects/'.freeze
V1_ENDPOINT_SUFFIX =
'/messages:send'.freeze
TOPIC_DOMAIN =
'https://iid.googleapis.com'.freeze
TOPIC_ENDPOINT_PREFIX =
'/iid/v1'.freeze
BATCH_ENDPOINT =
'/batch'.freeze
VERSION =
'1.4.4'.freeze
STATUS_TO_EXCEPTION_MAPPING =
{
  '400' => BadRequest,
  '401' => Unauthorized,
  '402' => PaymentRequired,
  '403' => Forbidden,
  '404' => NotFound,
  '405' => MethodNotAllowed,
  '406' => NotAcceptable,
  '407' => ProxyAuthenticationRequired,
  '408' => RequestTimeout,
  '409' => Conflict,
  '410' => Gone,
  '411' => LengthRequired,
  '412' => PreconditionFailed,
  '413' => PayloadTooLarge,
  '414' => URITooLong,
  '415' => UnsupportedMediaType,
  '416' => RangeNotSatisfiable,
  '417' => ExpectationFailed,
  '418' => ImaTeapot,
  '421' => MisdirectedRequest,
  '422' => UnprocessableEntity,
  '423' => Locked,
  '424' => FailedDependency,
  '426' => UpgradeRequired,
  '428' => PreconditionRequired,
  '429' => TooManyRequests,
  '431' => RequestHeaderFieldsTooLarge,
  '451' => UnavailableForLegalReasons,
  '500' => InternalServerError,
  '501' => NotImplemented,
  '502' => BadGateway,
  '503' => ServiceUnavailable,
  '504' => GatewayTimeout,
  '505' => HTTPVersionNotSupported,
  '506' => VariantAlsoNegotiates,
  '507' => InsufficientStorage,
  '508' => LoopDetected,
  '510' => NotExtended,
  '511' => NetworkAuthenticationRequired
}.freeze

Class Method Summary collapse

Class Method Details

.build(project_id, domain: nil) ⇒ Object Also known as: new



13
14
15
# File 'lib/fcmpush.rb', line 13

def build(project_id, domain: nil)
  ::Fcmpush::Client.new(domain || DOMAIN, project_id, configuration)
end

.configurationObject



19
20
21
# File 'lib/fcmpush.rb', line 19

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration(&block)| ... } ⇒ Object

Yields:



27
28
29
# File 'lib/fcmpush.rb', line 27

def self.configure(&block)
  yield(configuration(&block))
end

.resetObject



23
24
25
# File 'lib/fcmpush.rb', line 23

def self.reset
  @configuration = Configuration.new
end