Skip to content

Commit

Permalink
Merge 55a5d35 into da324fc
Browse files Browse the repository at this point in the history
  • Loading branch information
lukabratos committed Feb 28, 2018
2 parents da324fc + 55a5d35 commit db6ab07
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
repo_token: SvS3UyLJls0uc3J7nJgti4ypWxKosxo7U
repo_token: uaAoIkOEP9l7PCLENpJSSVVrcm94JDNYO
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
pusher-push-notifications (0.1.1)
pusher-push-notifications (0.2.1)
caze
rest-client

Expand Down
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# PushNotifications [![Build Status](https://travis-ci.org/lucasmedeirosleite/push-notifications-ruby.svg)](https://travis-ci.org/lucasmedeirosleite/push-notifications-ruby) [![Coverage Status](https://coveralls.io/repos/github/lucasmedeirosleite/push-notifications-ruby/badge.svg?branch=master)](https://coveralls.io/github/lucasmedeirosleite/push-notifications-ruby?branch=master)
# Pusher Push Notifications Ruby Server SDK

Push notifications using the Pusher system.

## Getting started
[![Build Status](https://travis-ci.org/pusher/push-notifications-ruby.svg?branch=master)](https://travis-ci.org/pusher/push-notifications-ruby) [![![Coverage Status](https://coveralls.io/repos/github/pusher/push-notifications-ruby/badge.svg?branch=master)](https://coveralls.io/github/pusher/push-notifications-ruby?branch=master)

The Push notifications system is still in BETA and it's free, but first you need to create an account on pusher (click [here](https://dash.pusher.com)).
With an account created you can create a new push notification instance (you will need to upload the apns certificates for apple and the server keys for Google's Firebase Cloud Messaging). Also you will need the `instance id` and `secret key` so the gem can be configured properly.

**NOTE**: The official Pusher [gem](https://github.com/pusher/pusher-http-ruby) currently does not support push notifications (probably because they moved it to another dashboard), you need to rely on the WEB API (that's why this gem was created).
Push notifications using the Pusher system.

## Installation

Add this line to your application's Gemfile:
```bash
gem install pusher-push-notifications
```

Or add this line to your application's Gemfile:

```ruby
gem 'pusher-push-notifications'
Expand All @@ -23,7 +22,7 @@ This configuration can be done anywhere you want, but if you are using rails the

```ruby
Pusher::PushNotifications.configure do |config|
 config.instance_id = ENV['PUSHER_INSTANCE_ID'] # or the value directly :)
 config.instance_id = ENV['PUSHER_INSTANCE_ID'] # or the value directly
 config.secret_key = ENV['PUSHER_SECRET_KEY']
end
```
Expand Down Expand Up @@ -52,7 +51,7 @@ data = {
}
}

Pusher::PushNotifications.notify(interests: ['my-interest'], payload: data)
Pusher::PushNotifications.publish(interests: ['hello'], payload: data)
```

The return of this call is a ruby struct containing the http status code (`status`) the response body (`content`) and an `ok?` attribute saying if the notification was successful or not.
Expand All @@ -70,10 +69,6 @@ HTTP Status | Reason
404 | Instance not found
500 | Internal server error

## TODO

Add an optional parameter containing the webhook url to be send together with the payload.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand All @@ -82,7 +77,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lucasmedeirosleite/push-notifications-ruby.
- Found a bug? Please open an [issue](https://github.com/pusher/push-notifications-ruby/issues).
- Have a feature request. Please open an [issue](https://github.com/pusher/push-notifications-ruby/issues).
- If you want to contribute, please submit a [pull request](https://github.com/pusher/push-notifications-ruby/pulls) (preferrably with some tests).

## License

Expand Down
4 changes: 2 additions & 2 deletions lib/pusher/push_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'caze'

require_relative './push_notifications/client'
require_relative './push_notifications/use_cases/notify'
require_relative './push_notifications/use_cases/publish'
require_relative './push_notifications/version'

module Pusher
Expand All @@ -12,7 +12,7 @@ module PushNotifications

class PushError < RuntimeError; end

has_use_case :notify, UseCases::Notify
has_use_case :publish, UseCases::Publish

class << self
attr_reader :instance_id, :secret_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
module Pusher
module PushNotifications
module UseCases
class Notify
class Publish
include Caze

export :call, as: :notify
export :call, as: :publish

def initialize(interests:, payload: {})
@interests = interests
Expand Down
2 changes: 1 addition & 1 deletion lib/pusher/push_notifications/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Pusher
module PushNotifications
VERSION = '0.1.1'
VERSION = '0.2.1'
end
end
9 changes: 4 additions & 5 deletions pusher-push-notifications.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ require 'pusher/push_notifications/version'
Gem::Specification.new do |spec|
spec.name = 'pusher-push-notifications'
spec.version = Pusher::PushNotifications::VERSION
spec.authors = ['Lucas Medeiros', 'Luka Bratos']
spec.email = ['lucastoc@gmail.com', 'luka@pusher.com']
spec.authors = ['Lucas Medeiros', 'Pusher']
spec.email = ['lucastoc@gmail.com', 'support@pusher.com']

spec.summary = 'PushNotifications pusher product'
spec.description = 'A gem to use the Pusher BETA product Push Notifications'
spec.homepage = 'https://github.com/lucasmedeirosleite/push-notifications-ruby'
spec.summary = 'Pusher Push Notifications Ruby server SDK'
spec.homepage = 'https://github.com/pusher/push-notifications-ruby'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0").reject do |f|
Expand Down
6 changes: 3 additions & 3 deletions spec/cassettes/publishes/invalid_payload.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions spec/cassettes/publishes/invalid_secret_key.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions spec/cassettes/publishes/valid_payload.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/pusher/push_notifications/notify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe Pusher::PushNotifications::UseCases::Notify do
RSpec.describe Pusher::PushNotifications::UseCases::Publish do
subject(:use_case) { described_class.new(interests: interests, payload: payload) }

let(:interests) { ['hello'] }
Expand Down

0 comments on commit db6ab07

Please sign in to comment.