firebase-admin-sdk 0.1.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cff98525ea9487f1e3a8f7358c0190a72933dab5a28548a15b9a5c759e8e3897
4
- data.tar.gz: aec561d06104af836bdb43312bfe8bb2a93298f1588d17a2aa578d2498a78fa0
3
+ metadata.gz: 9cab514afaf405f5f2d4ca06543879990bdf99a66e0818ace5bff7cb68eddd92
4
+ data.tar.gz: 8ae6de14035dff8fc6909ce0767b59cb9d21441729e566fc62a5d092ca3a7d00
5
5
  SHA512:
6
- metadata.gz: 370b215c81299b68f079ba36876fad8ec65bdd72eb7eaead4e309258106ea37e61854ca19282128999a32aac0299f96ad6bcecf704385e49d27b6ff04a8f1bf7
7
- data.tar.gz: cd6b429f7cd3237e9dfb3e065c4a04b051b35f3d5144956bb4da048adc754bd343995c167d9f5574af83e5c2e7c6eda64515a53e5db0c15fc318d79d8b7a19bb
6
+ metadata.gz: e62edc66ec1e58e2ea9bc6a4430bd8de62d02ec396ec657f65c03088ee27a63ab19bd12da83dcf1d556ba230323359b8d82e3543214476029a8d75e62f78f03b
7
+ data.tar.gz: bed9f27482d5f192b27d6f7de2ab22cc62644f805ce6e78592c2e42c1ecb9d645630646740b31a33df86e7fffc8d23ad478d011d183589ad21585de256d6aefc
@@ -12,6 +12,7 @@ jobs:
12
12
  - name: Setup Ruby
13
13
  uses: ruby/setup-ruby@v1
14
14
  with:
15
+ ruby-version: 3.0
15
16
  bundler-cache: true
16
17
 
17
18
  - name: Run standard
data/.gitignore CHANGED
@@ -13,3 +13,6 @@ Gemfile.lock
13
13
 
14
14
  # rspec failure tracking
15
15
  .rspec_status
16
+
17
+ # ruby version
18
+ .ruby-version
data/Gemfile CHANGED
@@ -2,4 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ ruby "3.2.2"
6
+
5
7
  gemspec
data/README.md CHANGED
@@ -6,7 +6,7 @@ in Ruby.
6
6
  For more information, visit the
7
7
  [Firebase Admin SDK setup guide](https://firebase.google.com/docs/admin/setup/).
8
8
 
9
- This gem is currently in alpha and not recommended for production use (yet).
9
+ This gem is being used in production by https://cheddar.me
10
10
 
11
11
  ## Installation
12
12
 
@@ -22,15 +22,15 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_runtime_dependency "googleauth", "> 0.16", "< 2.0"
25
- spec.add_runtime_dependency "faraday", "< 2"
26
- spec.add_runtime_dependency "faraday_middleware", "~> 1.0"
25
+ spec.add_runtime_dependency "faraday", "> 1", "< 3"
27
26
  spec.add_runtime_dependency "jwt", ">= 1.5", "< 3.0"
27
+ spec.add_runtime_dependency "google-apis-fcm_v1", ">= 0.19.0", "< 1.0"
28
28
 
29
- spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "webmock", "~> 3.13"
32
- spec.add_development_dependency "fakefs", "~> 1.3.2"
29
+ spec.add_development_dependency "rake"
30
+ spec.add_development_dependency "rspec"
31
+ spec.add_development_dependency "webmock"
32
+ spec.add_development_dependency "fakefs"
33
33
  spec.add_development_dependency "climate_control"
34
34
  spec.add_development_dependency "standard"
35
- spec.add_development_dependency "activesupport"
35
+ spec.add_development_dependency "activesupport", "~> 7.0.8"
36
36
  end
@@ -1,5 +1,5 @@
1
1
  require "faraday"
2
- require "faraday_middleware"
2
+ require_relative "../middleware/request/credentials"
3
3
 
4
4
  module Firebase
5
5
  module Admin
@@ -35,7 +35,7 @@ module Firebase
35
35
  end
36
36
 
37
37
  def post(url = nil, params = nil, headers = nil)
38
- connection.post(url, params, headers)
38
+ connection.post(url, params.to_json, headers)
39
39
  end
40
40
 
41
41
  def patch(url = nil, params = nil, headers = nil)
@@ -55,23 +55,13 @@ module Firebase
55
55
  }
56
56
 
57
57
  @connection ||= Faraday::Connection.new(@uri, options) do |c|
58
- c.use CredentialsMiddleware, credentials: @credentials unless @credentials.nil?
59
- c.use Faraday::Request::UrlEncoded
60
- c.use FaradayMiddleware::EncodeJson
61
- c.use Faraday::Response::ParseJson
62
- c.use Faraday::Response::RaiseError
58
+ c.request :url_encoded
59
+ c.request :credentials, credentials: @credentials unless @credentials.nil?
60
+ c.response :json
61
+ c.response :raise_error
63
62
  c.adapter(Faraday.default_adapter)
64
63
  end
65
64
  end
66
-
67
- # Middleware for applying credentials to authenticate requests.
68
- class CredentialsMiddleware < Faraday::Middleware
69
- def on_request(env)
70
- creds = options[:credentials]
71
- creds.apply!(env[:request_headers])
72
- end
73
- end
74
- private_constant :CredentialsMiddleware
75
65
  end
76
66
  end
77
67
  end
@@ -3,7 +3,7 @@ module Firebase
3
3
  module Messaging
4
4
  # Aps dictionary to be included in an APNS payload.
5
5
  class APS
6
- # @return [APSAlert, String, nil]
6
+ # @return [Firebase::Admin::Messaging::APSAlert, String, nil]
7
7
  # Alert to be included in the message.
8
8
  attr_accessor :alert
9
9
 
@@ -12,7 +12,7 @@ module Firebase
12
12
  # remain unchanged.
13
13
  attr_accessor :badge
14
14
 
15
- # @return [String, CriticalSound, nil]
15
+ # @return [Firebase::Admin::Messaging::CriticalSound, String, nil]
16
16
  # Sound to be played with the message.
17
17
  attr_accessor :sound
18
18
 
@@ -39,12 +39,12 @@ module Firebase
39
39
 
40
40
  # Initializes an {APS}.
41
41
  #
42
- # @param [APSAlert, String, nil] alert
42
+ # @param [Firebase::Admin::Messaging::APSAlert, String, nil] alert
43
43
  # Alert to be included in the message (optional).
44
44
  # @param [Integer, nil] badge
45
45
  # Badge to be displayed with the message (optional).
46
46
  # Set to 0 to remove the badge. When not specified, the badge will remain unchanged.
47
- # @param [String, CriticalSound, nil] sound
47
+ # @param [Firebase::Admin::Messaging::CriticalSound, String, nil] sound
48
48
  # Sound to be played with the message (optional).
49
49
  # @param [Boolean, nil] content_available
50
50
  # Specifies whether to configure a background update notification (optional).
@@ -0,0 +1,29 @@
1
+ module Firebase
2
+ module Admin
3
+ module Messaging
4
+ # The response received from a batch request
5
+ class BatchResponse
6
+ # The list of responses (possibly empty).
7
+ # @return [Array<SendResponse>]
8
+ attr_reader :responses
9
+
10
+ # The number of successful messages.
11
+ # @return [Integer]
12
+ attr_reader :success_count
13
+
14
+ # The number of failed messages.
15
+ # @return [Integer]
16
+ attr_reader :failure_count
17
+
18
+ # A response received from a batch request.
19
+ #
20
+ # @param [Array<SendResponse>] responses
21
+ def initialize(responses:)
22
+ @responses = responses
23
+ @success_count = responses.count(:success?)
24
+ @failure_count = responses.count - @success_count
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,5 @@
1
+ require "google-apis-fcm_v1"
2
+
1
3
  module Firebase
2
4
  module Admin
3
5
  module Messaging
@@ -5,8 +7,11 @@ module Firebase
5
7
  class Client
6
8
  def initialize(app)
7
9
  @project_id = app.project_id
8
- @http_client = Firebase::Admin::Internal::HTTPClient.new(credentials: app.credentials)
10
+ @project_path = "projects/#{app.project_id}"
9
11
  @message_encoder = MessageEncoder.new
12
+ @http_client = Firebase::Admin::Internal::HTTPClient.new(credentials: app.credentials)
13
+ @service = Google::Apis::FcmV1::FirebaseCloudMessagingService.new
14
+ @service.authorization = app.credentials
10
15
  end
11
16
 
12
17
  # Sends a message via Firebase Cloud Messaging (FCM).
@@ -19,13 +24,10 @@ module Firebase
19
24
  #
20
25
  # @return [String] A message id that uniquely identifies the message.
21
26
  def send_one(message, dry_run: false)
22
- body = {
23
- validate_only: dry_run,
24
- message: @message_encoder.encode(message)
25
- }
26
- res = @http_client.post(send_url, body, FCM_HEADERS)
27
- res.body["name"]
28
- rescue Faraday::Error => e
27
+ body = encode_message(message, dry_run: dry_run)
28
+ res = @service.send_message(@project_path, body, options: {skip_serialization: true})
29
+ res.name
30
+ rescue Google::Apis::Error => e
29
31
  raise parse_fcm_error(e)
30
32
  end
31
33
 
@@ -39,7 +41,21 @@ module Firebase
39
41
  #
40
42
  # @return [BatchResponse] A batch response.
41
43
  def send_all(messages, dry_run: false)
42
- raise NotImplementedError
44
+ raise "messages must be an Array" unless messages.is_a?(Array)
45
+ raise "messages must not contain more than 500 elements" unless messages.length < 500
46
+
47
+ responses = []
48
+ @service.batch do |service|
49
+ options = {skip_serialization: true}
50
+ messages.each do |message|
51
+ body = encode_message(message, dry_run: dry_run)
52
+ service.send_message(@project_path, body, options: options) do |res, err|
53
+ wrapped_err = parse_fcm_error(err) unless err.nil?
54
+ responses << SendResponse.new(message_id: res&.name, error: wrapped_err)
55
+ end
56
+ end
57
+ end
58
+ BatchResponse.new(responses: responses)
43
59
  end
44
60
 
45
61
  # Sends the given multicast message to all tokens via Firebase Cloud Messaging (FCM).
@@ -124,9 +140,9 @@ module Firebase
124
140
  TopicManagementResponse.new(res)
125
141
  end
126
142
 
127
- # @param [Faraday::Error] err
143
+ # @param [Google::Apis::Error] err
128
144
  def parse_fcm_error(err)
129
- msg, info = parse_platform_error(err.response_status, err.response_body)
145
+ msg, info = parse_platform_error(err.status_code, err.body)
130
146
  return err if info.empty?
131
147
 
132
148
  details = info["details"] || []
@@ -153,10 +169,19 @@ module Firebase
153
169
  [msg, details]
154
170
  end
155
171
 
172
+ # Encodes a send message request.
173
+ def encode_message(message, dry_run:)
174
+ body = {
175
+ message: @message_encoder.encode(message),
176
+ validateOnly: dry_run
177
+ }
178
+ JSON.generate(body)
179
+ end
180
+
156
181
  FCM_HOST = "https://fcm.googleapis.com"
157
182
  FCM_HEADERS = {"X-GOOG-API-FORMAT-VERSION": "2"}
158
183
  IID_HOST = "https://iid.googleapis.com"
159
- IID_HEADERS = {"access_token_auth" => "true"}
184
+ IID_HEADERS = {access_token_auth: "true"}
160
185
 
161
186
  FCM_ERROR_TYPES = {
162
187
  "APNS_AUTH_ERROR" => ThirdPartyAuthError,
@@ -1,3 +1,5 @@
1
+ require "json"
2
+
1
3
  module Firebase
2
4
  module Admin
3
5
  module Messaging
@@ -6,7 +8,7 @@ module Firebase
6
8
  #
7
9
  # @param [Message] message
8
10
  # The message to encode.
9
- # @return [Hash]
11
+ # @return [String] A json encoded string.
10
12
  def encode(message)
11
13
  raise ArgumentError, "message must be a Message" unless message.is_a?(Message)
12
14
  result = {
@@ -17,7 +19,7 @@ module Firebase
17
19
  notification: encode_notification(message.notification),
18
20
  token: check_string("Message.token", message.token, non_empty: true),
19
21
  topic: check_string("Message.topic", message.topic, non_empty: true),
20
- fcm_options: encode_fcm_options(message.fcm_options)
22
+ fcmOptions: encode_fcm_options(message.fcm_options)
21
23
  }
22
24
  result[:topic] = sanitize_topic_name(result[:topic])
23
25
  result = remove_nil_values(result)
@@ -47,13 +49,13 @@ module Firebase
47
49
  return nil unless v
48
50
  raise ArgumentError, "Message.android must be an AndroidConfig." unless v.is_a?(AndroidConfig)
49
51
  result = {
50
- collapse_key: check_string("AndroidConfig.collapse_key", v.collapse_key),
52
+ collapseKey: check_string("AndroidConfig.collapse_key", v.collapse_key),
51
53
  data: check_string_hash("AndroidConfig.data", v.data),
52
54
  notification: encode_android_notification(v.notification),
53
55
  priority: check_string("AndroidConfig.priority", v.priority, non_empty: true),
54
- restricted_package_name: check_string("AndroidConfig.restricted_package_name", v.restricted_package_name),
56
+ restrictedPackageName: check_string("AndroidConfig.restricted_package_name", v.restricted_package_name),
55
57
  ttl: encode_duration("AndroidConfig.ttl", v.ttl),
56
- fcm_options: encode_android_fcm_options(v.fcm_options)
58
+ fcmOptions: encode_android_fcm_options(v.fcm_options)
57
59
  }
58
60
  result = remove_nil_values(result)
59
61
  if result.key?(:priority) && !%w[normal high].include?(result[:priority])
@@ -71,49 +73,49 @@ module Firebase
71
73
 
72
74
  result = {
73
75
  body: check_string("AndroidNotification.body", v.body),
74
- body_loc_key: check_string("AndroidNotification.body_loc_key", v.body_loc_key),
75
- body_loc_args: check_string_array("AndroidNotification.body_loc_args", v.body_loc_args),
76
- click_action: check_string("AndroidNotification.click_action", v.click_action),
76
+ bodyLocKey: check_string("AndroidNotification.body_loc_key", v.body_loc_key),
77
+ bodyLocArgs: check_string_array("AndroidNotification.body_loc_args", v.body_loc_args),
78
+ clickAction: check_string("AndroidNotification.click_action", v.click_action),
77
79
  color: check_color("AndroidNotification.color", v.color, allow_alpha: true, required: false),
78
80
  icon: check_string("AndroidNotification.icon", v.icon),
79
81
  sound: check_string("AndroidNotification.sound", v.sound),
80
82
  tag: check_string("AndroidNotification.tag", v.tag),
81
83
  title: check_string("AndroidNotification.title", v.title),
82
- title_loc_key: check_string("AndroidNotification.title_loc_key", v.title_loc_key),
83
- title_loc_args: check_string_array("AndroidNotification.title_loc_args", v.title_loc_args),
84
- channel_id: check_string("AndroidNotification.channel_id", v.channel_id),
84
+ titleLocKey: check_string("AndroidNotification.title_loc_key", v.title_loc_key),
85
+ titleLocArgs: check_string_array("AndroidNotification.title_loc_args", v.title_loc_args),
86
+ channelId: check_string("AndroidNotification.channel_id", v.channel_id),
85
87
  image: check_string("AndroidNotification.image", v.image),
86
88
  ticker: check_string("AndroidNotification.ticker", v.ticker),
87
89
  sticky: v.sticky,
88
- event_time: check_time("AndroidNotification.event_time", v.event_time),
89
- local_only: v.local_only,
90
- notification_priority: check_string("AndroidNotification.priority", v.priority, non_empty: true),
91
- vibrate_timings: check_numeric_array("AndroidNotification.vibrate_timings", v.vibrate_timings),
92
- default_vibrate_timings: v.default_vibrate_timings,
93
- default_sound: v.default_sound,
94
- default_light_settings: v.default_light_settings,
95
- light_settings: encode_light_settings(v.light_settings),
90
+ eventTime: check_time("AndroidNotification.event_time", v.event_time),
91
+ localOnly: v.local_only,
92
+ notificationPriority: check_string("AndroidNotification.priority", v.priority, non_empty: true),
93
+ vibrateTimings: check_numeric_array("AndroidNotification.vibrate_timings", v.vibrate_timings),
94
+ defaultVibrateTimings: v.default_vibrate_timings,
95
+ defaultSound: v.default_sound,
96
+ defaultLightSettings: v.default_light_settings,
97
+ lightSettings: encode_light_settings(v.light_settings),
96
98
  visibility: check_string("AndroidNotification.visibility", v.visibility, non_empty: true),
97
- notification_count: check_numeric("AndroidNotification.notification_count", v.notification_count)
99
+ notificationCount: check_numeric("AndroidNotification.notification_count", v.notification_count)
98
100
  }
99
101
  result = remove_nil_values(result)
100
102
 
101
- if result.key?(:body_loc_args) && !result.key?(:body_loc_key)
103
+ if result.key?(:bodyLocArgs) && !result.key?(:bodyLocKey)
102
104
  raise ArgumentError, "AndroidNotification.body_loc_key is required when specifying body_loc_args"
103
- elsif result.key?(:title_loc_args) && !result.key?(:title_loc_key)
105
+ elsif result.key?(:titleLocArgs) && !result.key?(:titleLocKey)
104
106
  raise ArgumentError, "AndroidNotification.title_loc_key is required when specifying title_loc_args"
105
107
  end
106
108
 
107
- if (event_time = result[:event_time])
108
- event_time = event_time.dup.utc unless event_time.utc?
109
- result[:event_time] = event_time.strftime("%Y-%m-%dT%H:%M:%S.%6NZ")
109
+ if (event_time = result[:eventTime])
110
+ event_time = event_time.getutc unless event_time.utc?
111
+ result[:eventTime] = event_time.strftime("%Y-%m-%dT%H:%M:%S.%6NZ")
110
112
  end
111
113
 
112
- if (priority = result[:notification_priority])
114
+ if (priority = result[:notificationPriority])
113
115
  unless %w[min low default high max].include?(priority)
114
116
  raise ArgumentError, "AndroidNotification.priority must be 'default', 'min', 'low', 'high' or 'max'."
115
117
  end
116
- result[:notification_priority] = "PRIORITY_#{priority.upcase}"
118
+ result[:notificationPriority] = "PRIORITY_#{priority.upcase}"
117
119
  end
118
120
 
119
121
  if (visibility = result[:visibility])
@@ -123,11 +125,11 @@ module Firebase
123
125
  result[:visibility] = visibility.upcase
124
126
  end
125
127
 
126
- if (vibrate_timings = result[:vibrate_timings])
128
+ if (vibrate_timings = result[:vibrateTimings])
127
129
  vibrate_timing_strings = vibrate_timings.map do |t|
128
130
  encode_duration("AndroidNotification.vibrate_timings", t)
129
131
  end
130
- result[:vibrate_timings] = vibrate_timing_strings
132
+ result[:vibrateTimings] = vibrate_timing_strings
131
133
  end
132
134
 
133
135
  result
@@ -140,7 +142,7 @@ module Firebase
140
142
  raise ArgumentError, "AndroidConfig.fcm_options must be an AndroidFCMOptions"
141
143
  end
142
144
  result = {
143
- analytics_label: check_analytics_label("AndroidFCMOptions.analytics_label", v.analytics_label)
145
+ analyticsLabel: check_analytics_label("AndroidFCMOptions.analytics_label", v.analytics_label)
144
146
  }
145
147
  remove_nil_values(result)
146
148
  end
@@ -159,14 +161,14 @@ module Firebase
159
161
  raise ArgumentError, "AndroidNotification.light_settings must be a LightSettings." unless v.is_a?(LightSettings)
160
162
  result = {
161
163
  color: encode_color("LightSettings.color", v.color, allow_alpha: true),
162
- light_on_duration: encode_duration("LightSettings.light_on_duration", v.light_on_duration),
163
- light_off_duration: encode_duration("LightSettings.light_off_duration", v.light_off_duration)
164
+ lightOnDuration: encode_duration("LightSettings.light_on_duration", v.light_on_duration),
165
+ lightOffDuration: encode_duration("LightSettings.light_off_duration", v.light_off_duration)
164
166
  }
165
167
  result = remove_nil_values(result)
166
- unless result.key?(:light_on_duration)
168
+ unless result.key?(:lightOnDuration)
167
169
  raise ArgumentError, "LightSettings.light_on_duration is required"
168
170
  end
169
- unless result.key?(:light_off_duration)
171
+ unless result.key?(:lightOffDuration)
170
172
  raise ArgumentError, "LightSettings.light_off_duration is required"
171
173
  end
172
174
  result
@@ -190,7 +192,7 @@ module Firebase
190
192
  result = {
191
193
  headers: check_string_hash("APNSConfig.headers", apns.headers),
192
194
  payload: encode_apns_payload(apns.payload),
193
- fcm_options: encode_apns_fcm_options(apns.fcm_options)
195
+ fcmOptions: encode_apns_fcm_options(apns.fcm_options)
194
196
  }
195
197
  remove_nil_values(result)
196
198
  end
@@ -213,7 +215,7 @@ module Firebase
213
215
  return nil unless options
214
216
  raise ArgumentError, "APNSConfig.fcm_options must be an APNSFCMOptions" unless options.is_a?(APNSFCMOptions)
215
217
  result = {
216
- analytics_label: check_analytics_label("APNSFCMOptions.analytics_label", options.analytics_label),
218
+ analyticsLabel: check_analytics_label("APNSFCMOptions.analytics_label", options.analytics_label),
217
219
  image: check_string("APNSFCMOptions.image", options.image)
218
220
  }
219
221
  remove_nil_values(result)
@@ -331,7 +333,7 @@ module Firebase
331
333
  return nil unless options
332
334
  raise ArgumentError, "Message.fcm_options must be a FCMOptions." unless options.is_a?(FCMOptions)
333
335
  result = {
334
- analytics_label: check_analytics_label("Message.fcm_options", options.analytics_label)
336
+ analyticsLabel: check_analytics_label("Message.fcm_options", options.analytics_label)
335
337
  }
336
338
  remove_nil_values(result)
337
339
  end
@@ -0,0 +1,31 @@
1
+ module Firebase
2
+ module Admin
3
+ module Messaging
4
+ # The response received from an individual batched request.
5
+ class SendResponse
6
+ # A message id string that uniquely identifies the message.
7
+ # @return [String]
8
+ attr_reader :message_id
9
+
10
+ # The error if one occurred while sending the message.
11
+ # @return [Error]
12
+ attr_reader :error
13
+
14
+ # A boolean indicating if the request was successful.
15
+ # @return [Boolean]
16
+ def success?
17
+ !!@message_id
18
+ end
19
+
20
+ # Initializes the object.
21
+ #
22
+ # @param [String, nil] message_id the id of the sent message
23
+ # @param [Error, nil] error the error that occurred
24
+ def initialize(message_id:, error:)
25
+ @message_id = message_id
26
+ @error = error
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -61,11 +61,10 @@ module Firebase
61
61
  return nil unless value || required
62
62
  raise ArgumentError, "#{label} is required" unless value
63
63
  raise ArgumentError, "#{label} must be a string" unless value.is_a?(String)
64
- unless /\A#[0-9a-fA-F]{6}\Z/.match?(value) || (/\A#[0-9a-fA-F]{8}\Z/.match?(value) && allow_alpha)
65
- raise ArgumentError, "#{label} must be in the form #RRGGBB" unless allow_alpha
66
- raise ArgumentError, "#{label} must be in the form #RRGGBB or #RRGGBBAA"
67
- end
68
- value
64
+ return value if /\A#[0-9a-fA-F]{6}\Z/.match?(value)
65
+ return value if /\A#[0-9a-fA-F]{8}\Z/.match?(value) && allow_alpha
66
+ raise ArgumentError, "#{label} must be in the form #RRGGBB" unless allow_alpha
67
+ raise ArgumentError, "#{label} must be in the form #RRGGBB or #RRGGBBAA"
69
68
  end
70
69
 
71
70
  def to_seconds_string(seconds)
@@ -0,0 +1,15 @@
1
+ require "faraday/middleware"
2
+
3
+ # Middleware for applying credentials to authenticate requests.
4
+ module Faraday
5
+ module Credentials
6
+ class Middleware < ::Faraday::Middleware
7
+ def on_request(env)
8
+ creds = options[:credentials]
9
+ creds.apply!(env[:request_headers])
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ Faraday::Request.register_middleware(credentials: Faraday::Credentials::Middleware)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Firebase
4
4
  module Admin
5
- VERSION = "0.1.3"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -34,4 +34,6 @@ require_relative "firebase/admin/messaging/message_encoder"
34
34
  require_relative "firebase/admin/messaging/multicast_message"
35
35
  require_relative "firebase/admin/messaging/error_info"
36
36
  require_relative "firebase/admin/messaging/topic_management_response"
37
+ require_relative "firebase/admin/messaging/send_response"
38
+ require_relative "firebase/admin/messaging/batch_response"
37
39
  require_relative "firebase/admin/messaging/client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebase-admin-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tariq Zaid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-30 00:00:00.000000000 Z
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: googleauth
@@ -34,106 +34,118 @@ dependencies:
34
34
  name: faraday
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
+ - - ">"
38
+ - !ruby/object:Gem::Version
39
+ version: '1'
37
40
  - - "<"
38
41
  - !ruby/object:Gem::Version
39
- version: '2'
42
+ version: '3'
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
47
+ - - ">"
48
+ - !ruby/object:Gem::Version
49
+ version: '1'
44
50
  - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: '2'
52
+ version: '3'
47
53
  - !ruby/object:Gem::Dependency
48
- name: faraday_middleware
54
+ name: jwt
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
- - - "~>"
57
+ - - ">="
52
58
  - !ruby/object:Gem::Version
53
- version: '1.0'
59
+ version: '1.5'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
54
63
  type: :runtime
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
66
  requirements:
58
- - - "~>"
67
+ - - ">="
59
68
  - !ruby/object:Gem::Version
60
- version: '1.0'
69
+ version: '1.5'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '3.0'
61
73
  - !ruby/object:Gem::Dependency
62
- name: jwt
74
+ name: google-apis-fcm_v1
63
75
  requirement: !ruby/object:Gem::Requirement
64
76
  requirements:
65
77
  - - ">="
66
78
  - !ruby/object:Gem::Version
67
- version: '1.5'
79
+ version: 0.19.0
68
80
  - - "<"
69
81
  - !ruby/object:Gem::Version
70
- version: '3.0'
82
+ version: '1.0'
71
83
  type: :runtime
72
84
  prerelease: false
73
85
  version_requirements: !ruby/object:Gem::Requirement
74
86
  requirements:
75
87
  - - ">="
76
88
  - !ruby/object:Gem::Version
77
- version: '1.5'
89
+ version: 0.19.0
78
90
  - - "<"
79
91
  - !ruby/object:Gem::Version
80
- version: '3.0'
92
+ version: '1.0'
81
93
  - !ruby/object:Gem::Dependency
82
94
  name: rake
83
95
  requirement: !ruby/object:Gem::Requirement
84
96
  requirements:
85
- - - "~>"
97
+ - - ">="
86
98
  - !ruby/object:Gem::Version
87
- version: '13.0'
99
+ version: '0'
88
100
  type: :development
89
101
  prerelease: false
90
102
  version_requirements: !ruby/object:Gem::Requirement
91
103
  requirements:
92
- - - "~>"
104
+ - - ">="
93
105
  - !ruby/object:Gem::Version
94
- version: '13.0'
106
+ version: '0'
95
107
  - !ruby/object:Gem::Dependency
96
108
  name: rspec
97
109
  requirement: !ruby/object:Gem::Requirement
98
110
  requirements:
99
- - - "~>"
111
+ - - ">="
100
112
  - !ruby/object:Gem::Version
101
- version: '3.0'
113
+ version: '0'
102
114
  type: :development
103
115
  prerelease: false
104
116
  version_requirements: !ruby/object:Gem::Requirement
105
117
  requirements:
106
- - - "~>"
118
+ - - ">="
107
119
  - !ruby/object:Gem::Version
108
- version: '3.0'
120
+ version: '0'
109
121
  - !ruby/object:Gem::Dependency
110
122
  name: webmock
111
123
  requirement: !ruby/object:Gem::Requirement
112
124
  requirements:
113
- - - "~>"
125
+ - - ">="
114
126
  - !ruby/object:Gem::Version
115
- version: '3.13'
127
+ version: '0'
116
128
  type: :development
117
129
  prerelease: false
118
130
  version_requirements: !ruby/object:Gem::Requirement
119
131
  requirements:
120
- - - "~>"
132
+ - - ">="
121
133
  - !ruby/object:Gem::Version
122
- version: '3.13'
134
+ version: '0'
123
135
  - !ruby/object:Gem::Dependency
124
136
  name: fakefs
125
137
  requirement: !ruby/object:Gem::Requirement
126
138
  requirements:
127
- - - "~>"
139
+ - - ">="
128
140
  - !ruby/object:Gem::Version
129
- version: 1.3.2
141
+ version: '0'
130
142
  type: :development
131
143
  prerelease: false
132
144
  version_requirements: !ruby/object:Gem::Requirement
133
145
  requirements:
134
- - - "~>"
146
+ - - ">="
135
147
  - !ruby/object:Gem::Version
136
- version: 1.3.2
148
+ version: '0'
137
149
  - !ruby/object:Gem::Dependency
138
150
  name: climate_control
139
151
  requirement: !ruby/object:Gem::Requirement
@@ -166,16 +178,16 @@ dependencies:
166
178
  name: activesupport
167
179
  requirement: !ruby/object:Gem::Requirement
168
180
  requirements:
169
- - - ">="
181
+ - - "~>"
170
182
  - !ruby/object:Gem::Version
171
- version: '0'
183
+ version: 7.0.8
172
184
  type: :development
173
185
  prerelease: false
174
186
  version_requirements: !ruby/object:Gem::Requirement
175
187
  requirements:
176
- - - ">="
188
+ - - "~>"
177
189
  - !ruby/object:Gem::Version
178
- version: '0'
190
+ version: 7.0.8
179
191
  description:
180
192
  email:
181
193
  - tariq@cheddar.me
@@ -186,7 +198,6 @@ files:
186
198
  - ".github/workflows/main.yml"
187
199
  - ".gitignore"
188
200
  - ".rspec"
189
- - ".ruby-version"
190
201
  - Gemfile
191
202
  - LICENSE.txt
192
203
  - README.md
@@ -217,6 +228,7 @@ files:
217
228
  - lib/firebase/admin/messaging/apns_payload.rb
218
229
  - lib/firebase/admin/messaging/aps.rb
219
230
  - lib/firebase/admin/messaging/aps_alert.rb
231
+ - lib/firebase/admin/messaging/batch_response.rb
220
232
  - lib/firebase/admin/messaging/client.rb
221
233
  - lib/firebase/admin/messaging/critical_sound.rb
222
234
  - lib/firebase/admin/messaging/error.rb
@@ -227,8 +239,10 @@ files:
227
239
  - lib/firebase/admin/messaging/message_encoder.rb
228
240
  - lib/firebase/admin/messaging/multicast_message.rb
229
241
  - lib/firebase/admin/messaging/notification.rb
242
+ - lib/firebase/admin/messaging/send_response.rb
230
243
  - lib/firebase/admin/messaging/topic_management_response.rb
231
244
  - lib/firebase/admin/messaging/utils.rb
245
+ - lib/firebase/admin/middleware/request/credentials.rb
232
246
  - lib/firebase/admin/version.rb
233
247
  homepage: https://github.com/cheddar-me/firebase-admin-sdk-ruby
234
248
  licenses:
@@ -249,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
263
  - !ruby/object:Gem::Version
250
264
  version: '0'
251
265
  requirements: []
252
- rubygems_version: 3.2.15
266
+ rubygems_version: 3.4.10
253
267
  signing_key:
254
268
  specification_version: 4
255
269
  summary: Firebase Admin SDK for Ruby
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.0.1