ionic_push 0.2.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +7 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/README.md +67 -0
- data/Rakefile +15 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ionic_push.gemspec +30 -0
- data/lib/ionic_push/base_uri.rb +3 -0
- data/lib/ionic_push/configuration.rb +10 -0
- data/lib/ionic_push/push.rb +33 -0
- data/lib/ionic_push/request.rb +40 -0
- data/lib/ionic_push/version.rb +3 -0
- data/lib/ionic_push.rb +21 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eebe9f021c48ab28d37592de9c95fc27aa9c3438
|
4
|
+
data.tar.gz: 863d5c8dda6bbd8c3d90736407c5f918416588c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e268804eaca4e0e6fe0fcb619d39217ff357903652910f65e74830dbeabf0c0c4ea445c93cef7a57d5b38b2e202709bf56945c782e257f71814555c5e02a17b
|
7
|
+
data.tar.gz: d0fe21d80858f6d7b0149e845644e78984ab4e1559f4fcb7c7c81bd583e4f42972ced0a42665e6fa40073b2482e2aa56e5e972bed6b23383f0dd06c8cb1c159a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
[](https://codeclimate.com/github/kidush/ionic_push)
|
2
|
+
# IonicPush
|
3
|
+
|
4
|
+
Just a simple gem to send push notificaitons through Ionic Push API.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'ionic_push'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install ionic_push
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Configuration
|
25
|
+
|
26
|
+
Before all You'll need your Ionic [API TOKEN](http://docs.ionic.io/v2.0.0-beta/docs/api-getting-started#section-authentication) and a [Security Profile](http://docs.ionic.io/v2.0.0-beta/docs/security-profiles). For more details about Ionic Push see the [official documentation](http://docs.ionic.io/docs/push-sending-push).
|
27
|
+
|
28
|
+
You'll have create a configuration file.
|
29
|
+
|
30
|
+
Ex.`initializers/ionic_push.rb`
|
31
|
+
```ruby
|
32
|
+
IonicPush.configure do |config|
|
33
|
+
config.api_key = '<YOUR-API-KEY>'
|
34
|
+
config.profile = '<YOUR-SECURIY-PROFILE>'
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
### The basic
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
IonicPush.push(['your', 'devices', 'tokens'], {title: 'Push Title', message: 'Push Message'})
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## To do
|
46
|
+
|
47
|
+
- [x] Basic API Usage
|
48
|
+
- [ ] Sengind Push to Ionic User ID's
|
49
|
+
- [ ] Scheduling a push for later delivery
|
50
|
+
- [ ] Adding custom data to your notificaitons
|
51
|
+
- [ ] Phonegap Push plugin options
|
52
|
+
- [ ] Customizing Notification appearance
|
53
|
+
- [ ] Templating your push notification
|
54
|
+
- [ ] Notification's priority
|
55
|
+
- [ ] Checking the status of push
|
56
|
+
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ionic_push.
|
67
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rspec/core/rake_task"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
#Rake::TestTask.new(:test) do |t|
|
5
|
+
# t.libs << "test"
|
6
|
+
# t.libs << "lib"
|
7
|
+
# t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
#end
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
11
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
12
|
+
#task.rspec_opts = ['--format', 'Nc']
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :spec
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ionic_push"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/ionic_push.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ionic_push/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ionic_push"
|
8
|
+
spec.version = IonicPush::VERSION
|
9
|
+
spec.authors = ["Thiago F. Lins"]
|
10
|
+
spec.email = ["thiago.evandson@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gem for send push notification through Ionic Push.}
|
13
|
+
spec.description = %q{A simple gem for comunicate and send push notfication through Ionic Push.}
|
14
|
+
spec.homepage = "https://github.com/kidush/ionic_push"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "httparty", "~> 0.13.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.4", ">= 3.4.0"
|
26
|
+
spec.add_development_dependency "vcr", "~> 3.0", ">= 3.0.1"
|
27
|
+
spec.add_development_dependency "webmock", "~> 2.0", ">= 2.0.0"
|
28
|
+
spec.add_development_dependency "pry", "~> 0.10.3"
|
29
|
+
spec.add_development_dependency "rubocop", "~> 0.39.0"
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module IonicPush
|
2
|
+
module Push
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def notification(tokens, notification_params = {})
|
9
|
+
notification = Notification.new(tokens, notification_params)
|
10
|
+
req_push = IonicPush::Request.new(@configuration, notification.body)
|
11
|
+
|
12
|
+
req_push.send
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Notification
|
17
|
+
def initialize(tokens, notification)
|
18
|
+
@tokens = tokens
|
19
|
+
@notification = notification
|
20
|
+
end
|
21
|
+
|
22
|
+
def body
|
23
|
+
{
|
24
|
+
tokens: @tokens,
|
25
|
+
notification: {
|
26
|
+
title: @notification[:title],
|
27
|
+
message: @notification[:message]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module IonicPush
|
4
|
+
class Request
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
base_uri IonicPush::BASE_URI
|
8
|
+
|
9
|
+
def initialize(configuration, data)
|
10
|
+
@configuration = configuration
|
11
|
+
@data = data
|
12
|
+
@options = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def send
|
16
|
+
self.class.post('/notifications', request_params)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def headers
|
22
|
+
auth = "Bearer #{@configuration.api_key}"
|
23
|
+
{ headers: { 'Content-Type': 'application/json', 'Authorization': auth } }
|
24
|
+
end
|
25
|
+
|
26
|
+
def body
|
27
|
+
profile
|
28
|
+
{ body: @data.to_json }
|
29
|
+
end
|
30
|
+
|
31
|
+
def profile
|
32
|
+
@data.merge!(profile: @configuration.profile)
|
33
|
+
end
|
34
|
+
|
35
|
+
def request_params
|
36
|
+
@options.merge!(headers)
|
37
|
+
@options.merge!(body)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ionic_push.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ionic_push/version'
|
2
|
+
require 'ionic_push/configuration'
|
3
|
+
require 'ionic_push/base_uri'
|
4
|
+
require 'ionic_push/request'
|
5
|
+
require 'ionic_push/push'
|
6
|
+
|
7
|
+
module IonicPush
|
8
|
+
include IonicPush::Push
|
9
|
+
class << self
|
10
|
+
attr_accessor :configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.configure
|
14
|
+
@configuration ||= IonicPush::Configuration.new
|
15
|
+
yield(configuration)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.push(tokens, notification_params = {})
|
19
|
+
notification(tokens, notification_params)
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ionic_push
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thiago F. Lins
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 3.4.0
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '3.4'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.4.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: vcr
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.0'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 3.0.1
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '3.0'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 3.0.1
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: webmock
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.0'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.0.0
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.0'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 2.0.0
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: pry
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 0.10.3
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 0.10.3
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: rubocop
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 0.39.0
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 0.39.0
|
143
|
+
description: A simple gem for comunicate and send push notfication through Ionic Push.
|
144
|
+
email:
|
145
|
+
- thiago.evandson@gmail.com
|
146
|
+
executables: []
|
147
|
+
extensions: []
|
148
|
+
extra_rdoc_files: []
|
149
|
+
files:
|
150
|
+
- ".gitignore"
|
151
|
+
- ".rspec"
|
152
|
+
- ".rubocop.yml"
|
153
|
+
- ".travis.yml"
|
154
|
+
- Gemfile
|
155
|
+
- README.md
|
156
|
+
- Rakefile
|
157
|
+
- bin/console
|
158
|
+
- bin/setup
|
159
|
+
- ionic_push.gemspec
|
160
|
+
- lib/ionic_push.rb
|
161
|
+
- lib/ionic_push/base_uri.rb
|
162
|
+
- lib/ionic_push/configuration.rb
|
163
|
+
- lib/ionic_push/push.rb
|
164
|
+
- lib/ionic_push/request.rb
|
165
|
+
- lib/ionic_push/version.rb
|
166
|
+
homepage: https://github.com/kidush/ionic_push
|
167
|
+
licenses: []
|
168
|
+
metadata: {}
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.6.1
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Gem for send push notification through Ionic Push.
|
189
|
+
test_files: []
|