twinpush 0.0.3 → 0.0.9
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 +4 -4
- data/lib/twinpush.rb +27 -5
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5717985c13a01538526eefd8897d495a56bbd2599e8efc514a746cb1aa5d5294
|
4
|
+
data.tar.gz: 16a4084d2f15a26dbd48087e2a1930f2ba146e8125a5bcc445d7b60d76d153f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df9844c1551a35585aa66be4c1cee35183d095b8ea6a1e4c98e41c289fdde92db111cb25fa2a25fce407de2851d335f3dcc7aaf47db58afe8e22bd13b7dda70
|
7
|
+
data.tar.gz: 2b840efd8bc67d8c8b4e1d48541d3aab090b276b616df04c9c65d256354d771a166c1bd8174179658ba11cab0a00a7b9103fee60d0cef16ae6c39ccd378680a2
|
data/lib/twinpush.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'cgi'
|
3
3
|
require 'json'
|
4
|
+
require "knjrbfw"
|
4
5
|
|
5
6
|
class TWINPUSH
|
6
7
|
DEFAULT_TIMEOUT = 30
|
@@ -8,6 +9,8 @@ class TWINPUSH
|
|
8
9
|
BASE_URI = 'https://subdomain.twinpush.com'
|
9
10
|
API_URL = '/api/v2/apps'
|
10
11
|
|
12
|
+
class PayloadSizeError < StandardError; end
|
13
|
+
|
11
14
|
attr_accessor :uri, :app_id, :api_token, :api_token_creator
|
12
15
|
|
13
16
|
# @param [Hash] authentication_keys
|
@@ -19,7 +22,7 @@ class TWINPUSH
|
|
19
22
|
instance_variable_set("@#{key}", value)
|
20
23
|
self.class.instance_eval { attr_accessor key.to_sym }
|
21
24
|
end
|
22
|
-
@uri = BASE_URI.sub
|
25
|
+
@uri = BASE_URI.sub 'subdomain', @subdomain
|
23
26
|
@client_options = client_options
|
24
27
|
@timeout = timeout | DEFAULT_TIMEOUT
|
25
28
|
end
|
@@ -35,12 +38,22 @@ class TWINPUSH
|
|
35
38
|
|
36
39
|
alias show show_notification
|
37
40
|
|
41
|
+
#obtains notification details in OpenStruct
|
42
|
+
def show_notification_object(notification_id, device_id = nil)
|
43
|
+
OpenStruct.new JSON.parse(show_notification(notification_id, device_id)[:body])
|
44
|
+
end
|
45
|
+
|
38
46
|
#creates a new notification to be delivered from the platform
|
39
47
|
def create_notification(notification_params)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
48
|
+
analyzer = Knj::Memory_analyzer::Object_size_counter.new(notification_params)
|
49
|
+
if analyzer.calculate_size < 2048 # 2KB limit
|
50
|
+
path = "#{API_URL}/#{app_id}/notifications"
|
51
|
+
for_uri(uri) do |connection|
|
52
|
+
response = connection.post(path, notification_params.to_json)
|
53
|
+
build_response(response)
|
54
|
+
end
|
55
|
+
else
|
56
|
+
raise PayloadSizeError.new "The notification payload exceeds the 2KB limit"
|
44
57
|
end
|
45
58
|
end
|
46
59
|
|
@@ -115,6 +128,15 @@ class TWINPUSH
|
|
115
128
|
end
|
116
129
|
end
|
117
130
|
|
131
|
+
# Clears all the custom properties for a given device
|
132
|
+
def clear_properties(device_id)
|
133
|
+
path = "#{API_URL}/#{app_id}/devices/#{device_id}/clear_custom_properties"
|
134
|
+
for_uri(uri) do |connection|
|
135
|
+
response = connection.delete(path)
|
136
|
+
build_response(response)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
118
140
|
private
|
119
141
|
|
120
142
|
def validate_keys(authentication_keys)
|
metadata
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twinpush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amaury González
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.12'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 0.12.2
|
@@ -21,9 +24,26 @@ dependencies:
|
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.12'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 0.12.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: knjrbfw
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.0.113
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.0.113
|
27
47
|
description: TwinPush gem provides ruby bindings to TwinPush a messaging solution
|
28
48
|
that lets you reliably deliver messages and notifications at no cost to Android,
|
29
49
|
iOS or Web browsers.
|
@@ -55,8 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
75
|
- !ruby/object:Gem::Version
|
56
76
|
version: '0'
|
57
77
|
requirements: []
|
58
|
-
|
59
|
-
rubygems_version: 2.7.6
|
78
|
+
rubygems_version: 3.0.8
|
60
79
|
signing_key:
|
61
80
|
specification_version: 4
|
62
81
|
summary: Reliably deliver push notifications through TwinPush API
|