module Phonify
Constants
- VERSION
Attributes
token[RW]
Public Class Methods
send_subscription_message(app, phone, body)
click to toggle source
# File lib/phonify.rb, line 10 def send_subscription_message(app, phone, body) response = post('v1/subscriptions/messages', app: app, phone: phone, body: body) response ? response[:id] : false end
subscription_active?(app, phone)
click to toggle source
# File lib/phonify.rb, line 15 def subscription_active?(app, phone) response = get('v1/subscriptions/active', app: app, phone: phone) response ? response[:active] : false end
Private Class Methods
get(path, params)
click to toggle source
# File lib/phonify.rb, line 32 def get(path, params) request(path, params) { |url| Net::HTTP.get_response URI("#{url}?#{URI.encode_www_form(params.to_a)}") } end
post(path, params)
click to toggle source
# File lib/phonify.rb, line 28 def post(path, params) request(path, params) { |url| Net::HTTP.post_form URI(url), params } end
request(path, params) { |"http://phonify.io/#{path}"| ... }
click to toggle source
# File lib/phonify.rb, line 22 def request(path, params) params[:token] = token response = yield("http://api.phonify.io/#{path}") JSON.parse(response.body, symbolize_names: true) if response and response.code == '200' end