google-api-fcm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/google/apis/messages.rb +17 -0
- data/lib/google/apis/messages/classes.rb +66 -0
- data/lib/google/apis/messages/representations.rb +44 -0
- data/lib/google/apis/messages/service.rb +44 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 76a314583edbd705b27869dc5b6439e79317075d
|
4
|
+
data.tar.gz: ff8a6b107f3c603353f0b8722f0a1a8303446211
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '02958cf1e129570176d2159bc7cbf8bdd74927bfdf8b9974362e0fc0b3432fb0fbfce5a6f194f9d5120e3ae7cc5a53d5a3e073ded5bd2c52bf9f1e956f8b7c44'
|
7
|
+
data.tar.gz: 015ac774df70696bb6b5884eecd2a8a1f6c9bd3817848aac045fba496f373bbb98961b5121b0f87c8d89f20933b122afcd8f09589ae5216ee87a5fd4fba4a149
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'google/apis/messages/service'
|
2
|
+
require 'google/apis/messages/representations'
|
3
|
+
require 'google/apis/messages/classes'
|
4
|
+
|
5
|
+
module Google
|
6
|
+
module Apis
|
7
|
+
# Firebase Cloud Messaging
|
8
|
+
#
|
9
|
+
# @see https://firebase.google.com/docs/cloud-messaging/
|
10
|
+
module Messages
|
11
|
+
VERSION = 'V1'
|
12
|
+
REVISION = '20171130'
|
13
|
+
|
14
|
+
AUTH_MESSAGES = 'https://www.googleapis.com/auth/firebase.messaging'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Google
|
2
|
+
module Apis
|
3
|
+
module Messages
|
4
|
+
|
5
|
+
class Message
|
6
|
+
include Google::Apis::Core::Hashable
|
7
|
+
|
8
|
+
attr_accessor :message_object
|
9
|
+
|
10
|
+
def initialize(**args)
|
11
|
+
build_keys = %i(topic title body)
|
12
|
+
|
13
|
+
if (build_keys - args.keys).empty?
|
14
|
+
initialize_build(**args)
|
15
|
+
else
|
16
|
+
update!(**args)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_build(topic:, title:, body:)
|
22
|
+
notification = Notification.new(title: title, body: body)
|
23
|
+
@message_object = MessageObject.new(topic: topic, notification: notification)
|
24
|
+
end
|
25
|
+
|
26
|
+
def update!(**args)
|
27
|
+
@message_object = args[:message_object] if args.key?(:message_object)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class MessageObject
|
32
|
+
include Google::Apis::Core::Hashable
|
33
|
+
|
34
|
+
attr_accessor :topic
|
35
|
+
attr_accessor :notification
|
36
|
+
|
37
|
+
def initialize(**args)
|
38
|
+
update!(**args)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Update properties of this object
|
42
|
+
def update!(**args)
|
43
|
+
@topic = args[:topic] if args.key?(:topic)
|
44
|
+
@notification = args[:notification] if args.key?(:notification)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Notification
|
49
|
+
include Google::Apis::Core::Hashable
|
50
|
+
|
51
|
+
attr_accessor :title
|
52
|
+
attr_accessor :body
|
53
|
+
|
54
|
+
def initialize(**args)
|
55
|
+
update!(**args)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Update properties of this object
|
59
|
+
def update!(**args)
|
60
|
+
@title = args[:title] if args.key?(:title)
|
61
|
+
@body = args[:body] if args.key?(:body)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Google
|
2
|
+
module Apis
|
3
|
+
module Messages
|
4
|
+
class Message
|
5
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
6
|
+
include Google::Apis::Core::JsonObjectSupport
|
7
|
+
end
|
8
|
+
|
9
|
+
class MessageObject
|
10
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
11
|
+
include Google::Apis::Core::JsonObjectSupport
|
12
|
+
end
|
13
|
+
|
14
|
+
class Notification
|
15
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
16
|
+
include Google::Apis::Core::JsonObjectSupport
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
class Message
|
22
|
+
# @private
|
23
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
24
|
+
property :message_object, as: 'message', class: Google::Apis::Messages::MessageObject, decorator: Google::Apis::Messages::MessageObject::Representation
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class MessageObject
|
29
|
+
# @private
|
30
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
31
|
+
property :topic, as: 'topic'
|
32
|
+
property :notification, as: 'notification', class: Google::Apis::Messages::Notification, decorator: Google::Apis::Messages::Notification::Representation
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Notification
|
37
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
38
|
+
property :title, as: 'title'
|
39
|
+
property :body, as: 'body'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'google/apis/core/base_service'
|
2
|
+
require 'google/apis/core/json_representation'
|
3
|
+
require 'google/apis/core/hashable'
|
4
|
+
require 'google/apis/errors'
|
5
|
+
|
6
|
+
module Google
|
7
|
+
module Apis
|
8
|
+
module Messages
|
9
|
+
class MessagesService < Google::Apis::Core::BaseService
|
10
|
+
|
11
|
+
# @return [String]
|
12
|
+
# Your project ID from Google Firebase Console https://console.firebase.google.com/
|
13
|
+
attr_accessor :project_id
|
14
|
+
|
15
|
+
# @param project_id: [String]
|
16
|
+
def initialize(project_id:)
|
17
|
+
@project_id = project_id
|
18
|
+
|
19
|
+
super('https://fcm.googleapis.com/', 'v1/projects/{projectId}/')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Notify topic subscribers with message
|
23
|
+
# @see https://firebase.google.com/docs/cloud-messaging/send-message
|
24
|
+
#
|
25
|
+
# @param message [Google::Apis::Messages::Message]
|
26
|
+
def notify_topic(message, options: nil, &block)
|
27
|
+
command = make_simple_command(:post, 'messages:send', options)
|
28
|
+
command.request_representation = Google::Apis::Messages::Message::Representation
|
29
|
+
command.request_object = message
|
30
|
+
command.response_representation = Google::Apis::Messages::Message::Representation
|
31
|
+
command.response_class = Google::Apis::Messages::Message
|
32
|
+
|
33
|
+
execute_or_queue_command(command, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def apply_command_defaults(command)
|
39
|
+
command.params['projectId'] = project_id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-api-fcm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilya Krigouzov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-api-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.17'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.17'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- webmaster@oniksfly.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/google/apis/messages.rb
|
35
|
+
- lib/google/apis/messages/classes.rb
|
36
|
+
- lib/google/apis/messages/representations.rb
|
37
|
+
- lib/google/apis/messages/service.rb
|
38
|
+
homepage: https://github.com/oniksfly/google-api-fcm
|
39
|
+
licenses:
|
40
|
+
- Apache-2.0
|
41
|
+
metadata: {}
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2.0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 2.6.11
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Client for accessing Firebase Cloud Messaging APIs
|
62
|
+
test_files: []
|