jera_push 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aed822e33bf25c1e59e030e3d32d4aa45de406535a3993339ae12e43cd27b90c
4
- data.tar.gz: d11416aeea95d06bbaa598a0d3c3c2c61c7912c0361f4e2888c378de9cf7add9
3
+ metadata.gz: f7236749dd21e8caed1678a8e44c9e00b6e034e1198b9049bf5bc36ba5cee605
4
+ data.tar.gz: 36f20664f005ad3459f6651ad32ac1094bd1fa9556d198a332005c92363f6138
5
5
  SHA512:
6
- metadata.gz: 793828acf069f18159e6ec301327b0cbe21e4e8600c1485931e26b0229e299d7c287e8b275aa0e7e5ca254fab8e5317f5d618f703eea78cc01d8572ebb482e91
7
- data.tar.gz: 8bd496cc69b14561a847e5ae7ce1b198a9d21a98642abec25c11e46863be75b1e8ae5af357c04ec24728d0050178f3f346eeeb7ae553624271cbb7ae5d736393
6
+ metadata.gz: 03e288ec7ce98901ab70ac41a64df9f607117af92f954357cc383191abe4a970da61764367b324d97fad57c95805fc32a4fc0833ed8980a54bf550acd7418e7c
7
+ data.tar.gz: f33ffb817dc6f3f3491415703559cbeff5a3efc3e3f1aebab38f49b818605befe837d3a52538ec0f5c9ea64c4b8b3e8b7a11f0cb2dcb063bae049441045f14c9
@@ -4,7 +4,7 @@ class CreateJeraPushMessagesDevices < ActiveRecord::Migration<%= migration_versi
4
4
  t.integer :device_id, index: true
5
5
  t.integer :message_id, index: true
6
6
  t.string :status
7
- t.string :error_message
7
+ t.text :error_message
8
8
  t.string :firebase_id
9
9
 
10
10
  t.timestamps
@@ -1,10 +1,10 @@
1
1
  #this is the intilizer
2
2
  #here you will set up the jera push configuration
3
3
  JeraPush.setup do |config|
4
- config.firebase_api_key = "YOUR_API_KEY"
5
4
  # Change this for every new model
6
5
  config.resources_name = ["<%= file_name.classify %>"]
7
- config.project_name = "YOUR_PROJECT_NAME"
6
+ # You need to create a Account Service on google cloud, with editor permission or administrator. Flow this doc: https://cloud.google.com/iam/docs/service-accounts-create?hl=pt-br
7
+ config.project_id = "YOUR_PROJECT_ID" # inside of the account service json
8
8
  config.credentials_path = "YOUR_CREDENTIALS_PATH" #https://firebase.google.com/docs/cloud-messaging/migrate-v1?hl=pt-br#provide-credentials-manually
9
9
  ######################################################
10
10
  # Resource attribute showed in views #
@@ -14,53 +14,15 @@ module JeraPush::Firebase
14
14
  end
15
15
 
16
16
  def send_to_device(push:)
17
- @client.send_message("projects/#{::JeraPush.project_name}", push.to_json, options: { retries: 3, multiplier: 1, max_interval: 2 })
18
- end
19
-
20
- def add_device_to_topic(topic:, device:)
21
- send(url: "#{FIREBASE_INSTANCE_ID_URL}/v1/#{device.token}/rel/topics/#{topic}")
22
- end
23
-
24
- def remove_device_from_topic(topic:, devices: [])
25
- send(
26
- url: "#{FIREBASE_INSTANCE_ID_URL}/v1:batchRemove",
27
- body: {
28
- to: "/topics/#{topic}",
29
- registration_tokens: devices.pluck(:token)
30
- }.to_json
31
- )
32
- end
33
-
34
- def send_message_to_topic(message:, topic:)
35
- send(
36
- url: FIREBASE_URL,
37
- body: {
38
- title: message.title,
39
- body: message.body,
40
- to: "/topics/#{topic}",
41
- priority: 'high'
42
- }.to_json
43
- )
17
+ @client.send_message("projects/#{::JeraPush.project_id}", push.to_json, options: { retries: 3, multiplier: 1, max_interval: 2 })
44
18
  end
45
19
 
46
20
  private
47
21
 
48
- def send(url:, body: {})
49
- response = HTTParty.post(url, { body: body, headers: default_headers })
50
- JSON.parse(response)
51
- end
52
-
53
22
  def fetch_access_token
54
23
  @authorizer.fetch_access_token! if @authorizer.needs_access_token?
55
24
 
56
25
  @authorizer
57
26
  end
58
-
59
- def default_headers
60
- {
61
- "Authorization" => "key=#{::JeraPush.firebase_api_key}",
62
- "Content-Type" => "application/json"
63
- }
64
- end
65
27
  end
66
28
  end
@@ -26,7 +26,7 @@ module JeraPush
26
26
  self.device = device
27
27
  self.devices = devices
28
28
  self.validate_only = validate_only
29
- self.analytics_label = analytics_label
29
+ self.analytics_label = analytics_label.gsub(/\s/, '_').gsub(/[^a-zA-Z0-9.~%_]/, '').slice(0, 50).downcase
30
30
  self.ios = ios_config
31
31
  self.notification = notification.nil? ? Notification.new(title: title, body: body, image: image) : notification
32
32
  self.android = android_config
@@ -1,3 +1,3 @@
1
1
  module JeraPush
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.2"
3
3
  end
data/lib/jera_push.rb CHANGED
@@ -27,11 +27,8 @@ module JeraPush
27
27
  autoload :AndroidConfig, 'jera_push/models/android_config.rb'
28
28
  autoload :Notification, 'jera_push/models/notification.rb'
29
29
 
30
- mattr_accessor :firebase_api_key
31
- @@firebase_api_key = nil
32
-
33
- mattr_accessor :project_name
34
- @@project_name = nil
30
+ mattr_accessor :project_id
31
+ @@project_id = nil
35
32
 
36
33
  mattr_accessor :project_id
37
34
  @@project_id = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jera_push
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-24 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails