phonify 1.0.2
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/MIT-LICENSE.txt +22 -0
- data/README.md +30 -0
- data/lib/phonify.rb +37 -0
- data/lib/phonify/version.rb +3 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27b5e8d5324a420c2661f945aaf740179105bd06
|
4
|
+
data.tar.gz: db31e7430257926f859249c26f34f8cfa2c5c5cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86bf5871a7bb115809c02ac7bb52bfdd02f7c579112b0e65b4bb7baabca593e38cda5dd97941a2065450af9fac49724dcb8fb04dd826ca21ca44af2681106b79
|
7
|
+
data.tar.gz: da6036425950a0e53571addbe8dfe9d27e6287921f68c6e7562998c080b033e28d0c263296e7739c35a02d40921ec4a44e017d6313f0e4f986a85cc8102225da
|
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Phonify.io
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
## Introduction
|
3
|
+
|
4
|
+
Phonify gem adds the power of Phonify service directly in your app. More info on [phonify.io/help](http://www.phonify.io/help).
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Framework independent.
|
9
|
+
|
10
|
+
### Add gem to your Gemfile
|
11
|
+
|
12
|
+
gem 'phonify'
|
13
|
+
|
14
|
+
### Install the gem
|
15
|
+
|
16
|
+
bundle install
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Configure your token:
|
21
|
+
|
22
|
+
Phonify.token = 'TOKEN'
|
23
|
+
|
24
|
+
Check if the subscription is active:
|
25
|
+
|
26
|
+
Phonify.subscription_active? 'APP', '+34670000000'
|
27
|
+
|
28
|
+
Send subscription message:
|
29
|
+
|
30
|
+
Phonify.send_subscription_message 'APP', '+34670000000', 'BODY'
|
data/lib/phonify.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Phonify
|
6
|
+
class << self
|
7
|
+
|
8
|
+
attr_accessor :token
|
9
|
+
|
10
|
+
def send_subscription_message(app, phone, body)
|
11
|
+
response = post('v1/subscriptions/messages', app: app, phone: phone, body: body)
|
12
|
+
response ? response[:id] : false
|
13
|
+
end
|
14
|
+
|
15
|
+
def subscription_active?(app, phone)
|
16
|
+
response = get('v1/subscriptions/active', app: app, phone: phone)
|
17
|
+
response ? response[:active] : false
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def request(path, params)
|
23
|
+
params[:token] = token
|
24
|
+
response = yield("http://api.phonify.io/#{path}")
|
25
|
+
JSON.parse(response.body, symbolize_names: true) if response and response.code == '200'
|
26
|
+
end
|
27
|
+
|
28
|
+
def post(path, params)
|
29
|
+
request(path, params) { |url| Net::HTTP.post_form URI(url), params }
|
30
|
+
end
|
31
|
+
|
32
|
+
def get(path, params)
|
33
|
+
request(path, params) { |url| Net::HTTP.get_response URI("#{url}?#{URI.encode_www_form(params.to_a)}") }
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phonify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Caetano
|
8
|
+
- Chew Choon Keat
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
description: Phonify gem adds the power of Phonify service directly in your app. More
|
29
|
+
info on http://www.phonify.io/help.
|
30
|
+
email:
|
31
|
+
- info@phonify.io
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- MIT-LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- lib/phonify.rb
|
39
|
+
- lib/phonify/version.rb
|
40
|
+
homepage: https://github.com/pelcasandra/phonify-gem
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.2.1
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Phonify.io ruby client.
|
64
|
+
test_files: []
|