twinpush 0.0.6 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/twinpush.rb +12 -4
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c766ca0a2214694bdaa6398757c7d3e47b6037c02e403dee37c7463370ce098d
4
- data.tar.gz: d9656e6c24b941e67276fda230d0e2469a8614b24eb340d277adf1d27b9ffb01
3
+ metadata.gz: 5717985c13a01538526eefd8897d495a56bbd2599e8efc514a746cb1aa5d5294
4
+ data.tar.gz: 16a4084d2f15a26dbd48087e2a1930f2ba146e8125a5bcc445d7b60d76d153f8
5
5
  SHA512:
6
- metadata.gz: 66ba6b9c9449dabbb60451591b3ea4b57ca3ebd36269489b054ac0e4d507be4ff719b1317c5dc1a73d61175ebe19041d59ed038dc97fdf9a8d9fa1560e7389fa
7
- data.tar.gz: be3d1b76dbfece2174abd97cc3324a29628df0e98a376d1c014c96227f7bd215258aec15c3d45b6b362c3a0c7a8efc0511093bb62cfddab6d4302c3b8348b765
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
@@ -42,10 +45,15 @@ class TWINPUSH
42
45
 
43
46
  #creates a new notification to be delivered from the platform
44
47
  def create_notification(notification_params)
45
- path = "#{API_URL}/#{app_id}/notifications"
46
- for_uri(uri) do |connection|
47
- response = connection.post(path, notification_params.to_json)
48
- build_response(response)
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"
49
57
  end
50
58
  end
51
59
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twinpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
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: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
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
33
47
  description: TwinPush gem provides ruby bindings to TwinPush a messaging solution
34
48
  that lets you reliably deliver messages and notifications at no cost to Android,
35
49
  iOS or Web browsers.
@@ -61,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
75
  - !ruby/object:Gem::Version
62
76
  version: '0'
63
77
  requirements: []
64
- rubygems_version: 3.0.4
78
+ rubygems_version: 3.0.8
65
79
  signing_key:
66
80
  specification_version: 4
67
81
  summary: Reliably deliver push notifications through TwinPush API