pushbots 0.3.1 → 0.4.0

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
  SHA1:
3
- metadata.gz: 4fe7a02451bd030c89ec8006484c128096c9b529
4
- data.tar.gz: 40c057b30a1a1f7b8b46e5870a8e21a9e34c9bd4
3
+ metadata.gz: 7b766d00b676a82fdcfea64e2c3baa7509f61900
4
+ data.tar.gz: b36715e61c9708936e41c9cc37e68fbe66fd423c
5
5
  SHA512:
6
- metadata.gz: cbbbfa0bb86e57d74baa4925cfe38d13c6ab5f9f7275db35304d9cfc61b3d6d21d5dc83377d612e4167aa3f0f3278cb382ec76691f1316113cdbfb09139908a2
7
- data.tar.gz: 83e7866a708206bc5c854d11d0c9de214460171a0bedb34f8f1b933b63e7b089d022b1e3477fccadea5489501d567a14230514fc1883ca7c76725b27b7db918e
6
+ metadata.gz: 1fcfa2c1a14c66a7c00462c500a3b4f4ed132f7c4b0078664ad54cad2a0e82e8dcf29d467d657a26b1d0f64c2c86f514c39eca5e8efa8a2859f4fe9b59a75f78
7
+ data.tar.gz: 688203201284b99fa6dfadb36f66278b124eefd283aed4e1fffef23facbaee275584ce44df026eb592a8c7ff6246982b3c5da1aa604edd46c9431eaa53e6e4c6
data/README.md CHANGED
@@ -5,6 +5,22 @@ Ruby Wrapper for PushBots Rest API made with love by Kandiie
5
5
  PushBots is a Light SDK for mobile push notifications and now you can use
6
6
  this gem on your favorite Ruby on Rails Projects.
7
7
 
8
+ ## Table of Contents
9
+ - [Installation](#installation)
10
+ - [Configuration](#configuration)
11
+
12
+ - [How to use](#how-to-use)
13
+ - [Device management](#device-management)
14
+ - [Register a device](#register-a-device)
15
+ - [Delete a device](#delete-a-device)
16
+ - [Device information](#device-information)
17
+
18
+ - [Notifications](#notifications)
19
+ - [Single device notification](#single-device-notification)
20
+ - [Multiple device notifications](#multiple-device-notification)
21
+ - [Read pushbots response](#read-pushbots-response)
22
+
23
+
8
24
  ## Installation
9
25
 
10
26
  Add this line to your application's Gemfile:
@@ -21,9 +37,7 @@ Or install it yourself as:
21
37
 
22
38
  $ gem install pushbots
23
39
 
24
-
25
- ## How to use:
26
- #### Configuration
40
+ ## Configuration
27
41
  ```ruby
28
42
  # config/initializers/pushbots.rb
29
43
 
@@ -32,6 +46,43 @@ Pushbots.configure do |config|
32
46
  config.application_secret = 'Application Secret'
33
47
  end
34
48
  ```
49
+
50
+ # How to use:
51
+ ## Device management
52
+ #### Register a device
53
+ ```ruby
54
+ # token and platform are required to add a device
55
+ device = Pushbots::Device.new(token, platform)
56
+ # register the device to pushbots returns true/false
57
+ # an attempt to register a device
58
+ # that has been already registered returns false
59
+ device.register
60
+ ```
61
+
62
+ #### Delete a device
63
+ ```ruby
64
+ # token and platform are required to delete a device
65
+ device = Pushbots::Device.new(token, platform)
66
+ # remove the device from pushbots
67
+ # returns true if no errors occurred
68
+ device.delete
69
+ ```
70
+
71
+ #### Device information
72
+ ```ruby
73
+ # token is required to get device information
74
+ # platform is an optional parameter
75
+ device = Pushbots::Device.new(token)
76
+ # Get device information
77
+ # Device token
78
+ device.token
79
+ # Device status
80
+ device.platform
81
+ # Device tags
82
+ device.tags
83
+ ```
84
+
85
+ ## Notifications
35
86
  #### Single device notification
36
87
  ```ruby
37
88
  # Device token
@@ -44,7 +95,7 @@ message = 'Hello World!!!'
44
95
  # Build up the notification
45
96
  # platform, message, token and sound (required parameters).
46
97
  # options (custom fields) (optional parameter)
47
- push = PushBot::One.new(platform, token, message, sound, options)
98
+ push = PushBots::One.new(platform, token, message, sound, options)
48
99
  push.send # Delivers the notification
49
100
  ```
50
101
 
@@ -60,11 +111,11 @@ schedule = DateTime.now
60
111
  # Build up the notification
61
112
  # platform, message, schedule (required parameters).
62
113
  # options (custom fields) (optional parameter)
63
- push = PushBot::All.new(platforms, message, schedule, options = {})
114
+ push = PushBots::All.new(platforms, message, schedule, options = {})
64
115
  push.send # Delivers the notification
65
116
  ```
66
117
 
67
- ##### You can read Pushbots API response using:
118
+ ##### Read pushbots response
68
119
  ```ruby
69
120
  # Your notification response
70
121
  push.response
data/lib/pushbots.rb CHANGED
@@ -5,6 +5,7 @@ require 'pushbots/request'
5
5
  require 'pushbots/response'
6
6
  require 'pushbots/one'
7
7
  require 'pushbots/all'
8
+ require 'pushbots/device'
8
9
 
9
10
  # Pushbots module
10
11
  module Pushbots
data/lib/pushbots/all.rb CHANGED
@@ -17,8 +17,7 @@ module Pushbots
17
17
  end
18
18
 
19
19
  def send
20
- request = Request.new(body, :all)
21
- self.response = request.send
20
+ self.response = Request.send(:all, body)
22
21
  self.status =
23
22
  response.failed? ? STATUS[:failed] : STATUS[:delivered]
24
23
  end
@@ -0,0 +1,34 @@
1
+ module Pushbots
2
+ # Device class
3
+ class Device
4
+ attr_accessor :token, :platform, :tags
5
+ PLATFORM_TYPE = { ios: 0, android: 1 }.freeze
6
+ PLATFORM_TYPE_R = [:ios, :android].freeze
7
+
8
+ def initialize(token, platform = nil)
9
+ self.token = token
10
+ self.platform = platform if platform
11
+ end
12
+
13
+ def info
14
+ response = Request.info(token)
15
+ if response.code == 200
16
+ http_response = JSON.parse(response)
17
+ self.platform = PLATFORM_TYPE_R[http_response['platform']]
18
+ self.tags = http_response['tags']
19
+ end
20
+ end
21
+
22
+ def register
23
+ body = { token: token, platform: PLATFORM_TYPE[platform] }
24
+ response = Request.register(body)
25
+ response.code == 201
26
+ end
27
+
28
+ def delete
29
+ body = { token: token, platform: PLATFORM_TYPE[platform] }
30
+ response = Request.delete(body)
31
+ response.code == 200
32
+ end
33
+ end
34
+ end
data/lib/pushbots/one.rb CHANGED
@@ -12,8 +12,8 @@ module Pushbots
12
12
  end
13
13
 
14
14
  def send
15
- request = Request.new(body, :one)
16
- self.response = request.send
15
+ # request = Request.new(body, :one)
16
+ self.response = Request.send(:one, body)
17
17
  self.status =
18
18
  response.failed? ? STATUS[:failed] : STATUS[:delivered]
19
19
  end
data/lib/pushbots/push.rb CHANGED
@@ -30,10 +30,11 @@ module Pushbots
30
30
  private
31
31
 
32
32
  def validates_platform(platform)
33
- fail 'platform is not valid' if PLATFORM_TYPE[platform].nil?
33
+ raise 'platform is not valid' if PLATFORM_TYPE[platform].nil?
34
34
  end
35
35
 
36
36
  def validates_platforms(platforms)
37
+ raise 'platform is not valid' if platforms.empty?
37
38
  platforms.each do |t|
38
39
  validates_platform(t)
39
40
  end
@@ -3,24 +3,45 @@ require 'http'
3
3
  module Pushbots
4
4
  # Request class
5
5
  class Request
6
- attr_accessor :body, :base_url
6
+ def self.send(type, body)
7
+ url = "https://api.pushbots.com/push/#{type}"
8
+ header = header_base.merge(header_push)
9
+ response = HTTP.headers(header).post(url, json: body)
10
+ Response.new(response)
11
+ end
7
12
 
8
- def initialize(body, base_url)
9
- self.body = body
10
- self.base_url = base_url
13
+ def self.info(token)
14
+ url = 'https://api.pushbots.com/deviceToken/one'
15
+ header = header_base.merge(header_info(token))
16
+ HTTP.headers(header).get(url)
11
17
  end
12
18
 
13
- def send
14
- url = "https://api.pushbots.com/push/#{base_url}"
15
- response = HTTP.headers(header).post(url, json: body)
16
- Response.new(response)
19
+ def self.register(body)
20
+ url = 'https://api.pushbots.com/deviceToken'
21
+ HTTP.headers(header_base).put(url, json: body)
22
+ end
23
+
24
+ def self.delete(body)
25
+ url = 'https://api.pushbots.com/deviceToken/del'
26
+ HTTP.headers(header_base).put(url, json: body)
27
+ end
28
+
29
+ def self.header_base
30
+ {
31
+ :'X-PushBots-AppID' => Config.config.application_id,
32
+ :'Content-Type' => 'application/json'
33
+ }
34
+ end
35
+
36
+ def self.header_push
37
+ {
38
+ :'X-PushBots-Secret' => Config.config.application_secret
39
+ }
17
40
  end
18
41
 
19
- def header
42
+ def self.header_info(token)
20
43
  {
21
- 'X-PushBots-AppID' => Config.config.application_id,
22
- 'X-PushBots-Secret' => Config.config.application_secret,
23
- 'Content-Type' => 'application/json'
44
+ token: token
24
45
  }
25
46
  end
26
47
  end
@@ -1,4 +1,4 @@
1
1
  # Pushbots gem version
2
2
  module Pushbots
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
data/pushbots.gemspec CHANGED
@@ -9,14 +9,17 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Carlos Omana', 'Cesar Rodriguez']
10
10
  spec.email = ['contact@kandiie.com']
11
11
  spec.summary = 'Ruby Wrapper for PushBots Rest API.'
12
- spec.description = 'Ruby Wrapper for PushBots Rest API.'
12
+ spec.description = 'Ruby Wrapper for PushBots Rest API. '\
13
+ 'Includes push notification methods for single and'\
14
+ ' multiple devices simplifying notification management '\
15
+ ' and pushbots api usage in your ruby projects.'
13
16
  spec.homepage = 'https://github.com/Kandiie/pushbots'
14
17
  spec.license = 'MIT'
15
18
 
16
19
  if spec.respond_to?(:metadata)
17
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
21
  else
19
- fail 'RubyGems 2 or newer, required to protect against public gem pushes.'
22
+ raise 'RubyGems 2 or newer, required to protect against public gem pushes.'
20
23
  end
21
24
 
22
25
  spec.files = `git ls-files -z`.split("\x0")
@@ -0,0 +1,64 @@
1
+ # spec/features/external_request_spec.rb
2
+ require 'spec_helper'
3
+
4
+ describe Pushbots do
5
+ let(:token) { 'token' }
6
+ let(:platform) { :android }
7
+ let(:message) { 'Hello World!!!' }
8
+ let(:sound) { 'sound' }
9
+ context 'request' do
10
+ context 'single device' do
11
+ context 'with valid data' do
12
+ it 'can push' do
13
+ push = described_class::One.new(platform, token, message, sound)
14
+ push.send
15
+ expect(push.response.code).to eq(200)
16
+ end
17
+ end
18
+
19
+ context 'with invalid data' do
20
+ context 'nil or empty token' do
21
+ it 'can not push (empty)' do
22
+ push = described_class::One.new(platform, '', message, sound)
23
+ push.send
24
+ expect(push.response.code).to eq(400)
25
+ end
26
+
27
+ it 'can not push (nil)' do
28
+ push = described_class::One.new(platform, nil, message, sound)
29
+ push.send
30
+ expect(push.response.code).to eq(400)
31
+ end
32
+ end
33
+
34
+ context 'nil or empty message' do
35
+ it 'can not push (empty)' do
36
+ push = described_class::One.new(platform, token, '', sound)
37
+ push.send
38
+ expect(push.response.code).to eq(400)
39
+ end
40
+
41
+ it 'can not push (nil)' do
42
+ push = described_class::One.new(platform, token, nil, sound)
43
+ push.send
44
+ expect(push.response.code).to eq(400)
45
+ end
46
+ end
47
+
48
+ context 'nil or empty sound' do
49
+ it 'can not push (empty)' do
50
+ push = described_class::One.new(platform, token, message, '')
51
+ push.send
52
+ expect(push.response.code).to eq(400)
53
+ end
54
+
55
+ it 'can not push (nil)' do
56
+ push = described_class::One.new(platform, token, message, nil)
57
+ push.send
58
+ expect(push.response.code).to eq(400)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,50 @@
1
+ # spec/features/external_request_spec.rb
2
+ require 'spec_helper'
3
+
4
+ describe Pushbots do
5
+ let(:token) { 'token' }
6
+ let(:platforms) { [:ios] }
7
+ let(:message) { 'Hello World!!!' }
8
+ let(:schedule) { '2016-03-14T19:25:53-06:00' }
9
+ context 'request' do
10
+ context 'multiple devices' do
11
+ context 'with valid data' do
12
+ it 'can push' do
13
+ push = described_class::All.new(platforms, message, schedule)
14
+ push.send
15
+ expect(push.response.code).to eq(200)
16
+ end
17
+ end
18
+
19
+ context 'with invalid data' do
20
+ context 'nil or empty message' do
21
+ it 'can not push (nil)' do
22
+ push = described_class::All.new([:ios], nil, schedule)
23
+ push.send
24
+ expect(push.response.code).to eq(400)
25
+ end
26
+
27
+ it 'can not push (empty)' do
28
+ push = described_class::All.new([:ios], '', schedule)
29
+ push.send
30
+ expect(push.response.code).to eq(400)
31
+ end
32
+ end
33
+
34
+ context 'nil or empty schedule' do
35
+ it 'can not push (nil)' do
36
+ push = described_class::All.new([:ios], message, nil)
37
+ push.send
38
+ expect(push.response.code).to eq(400)
39
+ end
40
+
41
+ it 'can not push (empty)' do
42
+ push = described_class::All.new([:ios], message, '')
43
+ push.send
44
+ expect(push.response.code).to eq(400)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -6,17 +6,56 @@ describe Pushbots do
6
6
  let(:message) { 'Hello World!!!' }
7
7
  let(:sound) { 'sound' }
8
8
  context 'initialize' do
9
- context 'with invalid data' do
10
- it 'raises wrong platform error' do
11
- expect do
12
- described_class::One.new(:other, token, message, sound)
13
- end.to raise_error(RuntimeError, 'platform is not valid')
9
+ context 'single device' do
10
+ context 'with invalid paltform' do
11
+ it 'raises wrong platform error (empty)' do
12
+ expect do
13
+ described_class::One.new('', token, message, sound)
14
+ end.to raise_error(RuntimeError, 'platform is not valid')
15
+ end
16
+
17
+ it 'raises wrong platform error (nil)' do
18
+ expect do
19
+ described_class::One.new(nil, token, message, sound)
20
+ end.to raise_error(RuntimeError, 'platform is not valid')
21
+ end
22
+
23
+ it 'raises wrong platform error (wrong)' do
24
+ expect do
25
+ described_class::One.new(:other, token, message, sound)
26
+ end.to raise_error(RuntimeError, 'platform is not valid')
27
+ end
28
+ end
29
+ context 'with valid data' do
30
+ it 'initializes' do
31
+ described_class::One.new(:ios, token, message, sound)
32
+ end
14
33
  end
15
34
  end
35
+ context 'multiple device' do
36
+ context 'with invalid platform' do
37
+ it 'raises wrong platform error (empty)' do
38
+ expect do
39
+ described_class::All.new([], message, sound)
40
+ end.to raise_error(RuntimeError, 'platform is not valid')
41
+ end
16
42
 
17
- context 'with valid data' do
18
- it 'initializes' do
19
- described_class::One.new(platform, token, message, sound)
43
+ it 'raises wrong platform error (nil)' do
44
+ expect do
45
+ described_class::All.new([], message, sound)
46
+ end.to raise_error(RuntimeError, 'platform is not valid')
47
+ end
48
+
49
+ it 'raises wrong platform error (wrong)' do
50
+ expect do
51
+ described_class::All.new([:ios, :androiid], message, sound)
52
+ end.to raise_error(RuntimeError, 'platform is not valid')
53
+ end
54
+ end
55
+ context 'with valid data' do
56
+ it 'initializes' do
57
+ described_class::All.new([:ios], message, sound)
58
+ end
20
59
  end
21
60
  end
22
61
  end
data/spec/requests.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'webmock/rspec'
2
+ module Requests
3
+ def single_device_requests
4
+ token = 'token'
5
+ message = 'Hello World!!!'
6
+ sound = 'sound'
7
+ # Valid data
8
+ pushbots_single_request(:post, token, message, sound, 200)
9
+ # Empty or nil token returns status 400
10
+ pushbots_single_request(:post, '', message, sound, 400)
11
+ pushbots_single_request(:post, nil, message, sound, 400)
12
+ # Empty or nil message returns status 400
13
+ pushbots_single_request(:post, token, '', sound, 400)
14
+ pushbots_single_request(:post, token, nil, sound, 400)
15
+ # Empty or nil sound returns status 400
16
+ pushbots_single_request(:post, token, message, '', 400)
17
+ pushbots_single_request(:post, token, message, nil, 400)
18
+ end
19
+
20
+ def multiple_device_requests
21
+ msg = 'Hello World!!!'
22
+ schedule = '2016-03-14T19:25:53-06:00'
23
+ # Multiple device requests
24
+ pushbots_multiple_request(:post, msg, schedule, 200)
25
+ # Empty or nil msg
26
+ pushbots_multiple_request(:post, nil, schedule, 400)
27
+ pushbots_multiple_request(:post, '', schedule, 400)
28
+ # Empty or nil schedule
29
+ pushbots_multiple_request(:post, msg, '', 400)
30
+ pushbots_multiple_request(:post, msg, nil, 400)
31
+ end
32
+
33
+ private
34
+
35
+ def common_headers
36
+ {
37
+ 'Connection' => 'close',
38
+ 'Content-Type' => 'application/json',
39
+ 'Host' => 'api.pushbots.com',
40
+ 'User-Agent' => /./,
41
+ 'X-Pushbots-Appid' => 'Application ID',
42
+ 'X-Pushbots-Secret' => 'Application Secret'
43
+ }
44
+ end
45
+
46
+ def single_device_content(token, msg, sound)
47
+ { 'platform' => 1,
48
+ 'token' => token,
49
+ 'msg' => msg,
50
+ 'sound' => sound
51
+ }.to_json
52
+ end
53
+
54
+ def multiple_device_content(platforms, msg, schedule)
55
+ { 'platform' => platforms,
56
+ 'msg' => msg,
57
+ 'schedule' => schedule
58
+ }.to_json
59
+ end
60
+
61
+ def pushbots_single_request(method, token, message, sound, response)
62
+ stub_request(method, 'https://api.pushbots.com/push/one')
63
+ .with(body: single_device_content(token, message, sound),
64
+ headers: common_headers)
65
+ .to_return(status: response,
66
+ body: '',
67
+ headers: {})
68
+ end
69
+
70
+ def pushbots_multiple_request(method, msg, schedule, response)
71
+ stub_request(method, 'https://api.pushbots.com/push/all')
72
+ .with(body: multiple_device_content([0], msg,
73
+ schedule),
74
+ headers: common_headers)
75
+ .to_return(status: response,
76
+ body: '',
77
+ headers: {})
78
+ end
79
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,104 +1,15 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'pushbots'
3
3
  require 'net/http'
4
- require 'webmock/rspec'
4
+ require 'requests'
5
5
  WebMock.disable_net_connect!(allow_localhost: true)
6
6
 
7
7
  # Stub Request common headers
8
- common_headers = { 'Connection' => 'close',
9
- 'Content-Type' => 'application/json',
10
- 'Host' => 'api.pushbots.com',
11
- 'User-Agent' => 'http.rb/1.0.2',
12
- 'X-Pushbots-Appid' => 'Application ID',
13
- 'X-Pushbots-Secret' => 'Application Secret' }
14
-
15
- api_path = 'https://api.pushbots.com/push/one'
16
-
17
8
  RSpec.configure do |config|
9
+ config.include Requests
18
10
  config.before(:each) do
19
- # Valid data
20
- content = { 'platform' => 0,
21
- 'token' => 'token',
22
- 'msg' => 'Hello World!!!',
23
- 'sound' => 'sound' }
24
- stub_request(:post, api_path)
25
- .with(body: content.to_json,
26
- headers: common_headers)
27
- .to_return(status: 200,
28
- body: '',
29
- headers: {})
30
-
31
- # Empty token returns status 400
32
- content = { 'platform' => 0,
33
- 'token' => '',
34
- 'msg' => 'Hello World!!!',
35
- 'sound' => 'sound' }
36
- stub_request(:post, api_path)
37
- .with(body: content.to_json,
38
- headers: common_headers)
39
- .to_return(status: 400,
40
- body: '',
41
- headers: {})
42
-
43
- # Null token returns status 400
44
- content = { 'platform' => 0,
45
- 'token' => nil,
46
- 'msg' => 'Hello World!!!',
47
- 'sound' => 'sound' }
48
- stub_request(:post, api_path)
49
- .with(body: content.to_json,
50
- headers: common_headers)
51
- .to_return(status: 400,
52
- body: '',
53
- headers: {})
54
-
55
- # Empty message returns status 400
56
- content = { 'platform' => 0,
57
- 'token' => 'token',
58
- 'msg' => '',
59
- 'sound' => 'sound' }
60
- stub_request(:post, api_path)
61
- .with(body: content.to_json,
62
- headers: common_headers)
63
- .to_return(status: 400,
64
- body: '',
65
- headers: {})
66
-
67
- # Null message returns status 400
68
- content = { 'platform' => 0,
69
- 'token' => 'token',
70
- 'msg' => nil,
71
- 'sound' => 'sound' }
72
- stub_request(:post, api_path)
73
- .with(body: content.to_json,
74
- headers: common_headers)
75
- .to_return(status: 400,
76
- body: '',
77
- headers: {})
78
-
79
- # Empty sound returns status 400
80
- content = { 'platform' => 0,
81
- 'token' => 'token',
82
- 'msg' => 'Hello World!!!',
83
- 'sound' => '' }
84
- stub_request(:post, api_path)
85
- .with(body: content.to_json,
86
- headers: common_headers)
87
- .to_return(status: 400,
88
- body: '',
89
- headers: {})
90
-
91
- # Null sound returns status 400
92
- content = { 'platform' => 0,
93
- 'token' => 'token',
94
- 'msg' => 'Hello World!!!',
95
- 'sound' => nil }
96
- stub_request(:post, api_path)
97
- .with(body: content.to_json,
98
- headers: common_headers)
99
- .to_return(status: 400,
100
- body: '',
101
- headers: {})
11
+ single_device_requests
12
+ multiple_device_requests
102
13
  end
103
14
  end
104
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushbots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Omana
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-03-12 00:00:00.000000000 Z
12
+ date: 2016-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -87,7 +87,9 @@ dependencies:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.0.2
90
- description: Ruby Wrapper for PushBots Rest API.
90
+ description: Ruby Wrapper for PushBots Rest API. Includes push notification methods
91
+ for single and multiple devices simplifying notification management and pushbots
92
+ api usage in your ruby projects.
91
93
  email:
92
94
  - contact@kandiie.com
93
95
  executables: []
@@ -107,14 +109,17 @@ files:
107
109
  - lib/pushbots.rb
108
110
  - lib/pushbots/all.rb
109
111
  - lib/pushbots/config.rb
112
+ - lib/pushbots/device.rb
110
113
  - lib/pushbots/one.rb
111
114
  - lib/pushbots/push.rb
112
115
  - lib/pushbots/request.rb
113
116
  - lib/pushbots/response.rb
114
117
  - lib/pushbots/version.rb
115
118
  - pushbots.gemspec
116
- - spec/external_request_spec.rb
119
+ - spec/external_request_single_device_spec.rb
120
+ - spec/external_requests_multiple_device_spec.rb
117
121
  - spec/pushbots_spec.rb
122
+ - spec/requests.rb
118
123
  - spec/spec_helper.rb
119
124
  homepage: https://github.com/Kandiie/pushbots
120
125
  licenses:
@@ -1,62 +0,0 @@
1
- # spec/features/external_request_spec.rb
2
- require 'spec_helper'
3
-
4
- describe Pushbots do
5
- let(:token) { 'token' }
6
- let(:platform) { :ios }
7
- let(:message) { 'Hello World!!!' }
8
- let(:sound) { 'sound' }
9
- context 'request' do
10
- context 'with valid data' do
11
- it 'can push to a single device' do
12
- push = described_class::One.new(platform, token, message, sound)
13
- push.send
14
- expect(push.response.code).to eq(200)
15
- end
16
- end
17
-
18
- context 'with invalid data' do
19
- context 'nil or empty token' do
20
- it 'can not push (empty)' do
21
- push = described_class::One.new(platform, '', message, sound)
22
- push.send
23
- expect(push.response.code).to eq(400)
24
- end
25
-
26
- it 'can not push (nil)' do
27
- push = described_class::One.new(platform, nil, message, sound)
28
- push.send
29
- expect(push.response.code).to eq(400)
30
- end
31
- end
32
-
33
- context 'nil or empty message' do
34
- it 'can not push (empty)' do
35
- push = described_class::One.new(platform, token, '', sound)
36
- push.send
37
- expect(push.response.code).to eq(400)
38
- end
39
-
40
- it 'can not push (nil)' do
41
- push = described_class::One.new(platform, token, nil, sound)
42
- push.send
43
- expect(push.response.code).to eq(400)
44
- end
45
- end
46
-
47
- context 'nil or empty sound' do
48
- it 'can not push (empty)' do
49
- push = described_class::One.new(platform, token, message, '')
50
- push.send
51
- expect(push.response.code).to eq(400)
52
- end
53
-
54
- it 'can not push (nil)' do
55
- push = described_class::One.new(platform, token, message, nil)
56
- push.send
57
- expect(push.response.code).to eq(400)
58
- end
59
- end
60
- end
61
- end
62
- end