module SendSonar
Constants
- VERSION
Attributes
config[R]
Public Instance Methods
add_customer(params)
click to toggle source
# File lib/send_sonar.rb, line 16 def add_customer params resp = Client.post url_for(:customers), params, headers Customer.new(JSON.parse(resp)) end
Also aliased as: add_update_customer
available_phone_number()
click to toggle source
# File lib/send_sonar.rb, line 51 def available_phone_number keys_in_header = { :publishable_key => true, :token => false } resp = Client.get url_for(:available_phone_number), headers(keys_in_header) Response.new(JSON.parse(resp)) end
close_customer(params)
click to toggle source
# File lib/send_sonar.rb, line 33 def close_customer params resp = Client.post url_for(:close_customer), params, headers Response.new(JSON.parse(resp)) end
configure() { |config ||= configuration| ... }
click to toggle source
# File lib/send_sonar.rb, line 12 def configure yield @config ||= Configuration.new end
delete_customer_property(params)
click to toggle source
# File lib/send_sonar.rb, line 38 def delete_customer_property params resp = Client.delete url_for(:delete_customer_property), params, headers Response.new(JSON.parse(resp)) end
get_customer(params)
click to toggle source
# File lib/send_sonar.rb, line 43 def get_customer params query = params.merge({ :token => config.token }) # RestClient forms the GET query string from the params field of the header # Set the query hash above to the params field of the header hash below resp = Client.get url_for(:customers), { params: query } Customer.new(JSON.parse(resp)) end
message_customer(params)
click to toggle source
# File lib/send_sonar.rb, line 23 def message_customer params resp = Client.post url_for(:messages), params, headers Message.new(JSON.parse(resp)) end
send_campaign(params)
click to toggle source
# File lib/send_sonar.rb, line 28 def send_campaign params resp = Client.post url_for(:campaigns), params, headers Response.new(JSON.parse(resp)) end
Private Instance Methods
headers(include_headers={})
click to toggle source
# File lib/send_sonar.rb, line 61 def headers include_headers={} include_headers = include_headers.merge({:token => true}) unless include_headers.key? :token headers = { :client => "rubygem #{SendSonar::VERSION}" } headers = headers.merge({ :token => config.token }) if include_headers[:token] headers = headers.merge({ :x_publishable_key => config.publishable_key }) if include_headers[:publishable_key] headers end
url_for(key)
click to toggle source
# File lib/send_sonar.rb, line 69 def url_for(key) Configuration::ENV_URLS[config.env.to_s][key.to_s] end