Skip to content

Instantly share code, notes, and snippets.

@mattfitzgerald
Created March 4, 2015 06:51
Show Gist options
  • Save mattfitzgerald/4c90e3fcfde923c79214 to your computer and use it in GitHub Desktop.
Save mattfitzgerald/4c90e3fcfde923c79214 to your computer and use it in GitHub Desktop.
Start of basic comms report with API
require 'HTTParty'
class SquawkboxAPI
include HTTParty
def initialize(username, password)
@auth = {:username => username, :password => password}
@squawkbox_host = 'app.mysquawkbox.com'
self.class.base_uri URI::HTTPS.build(host: @squawkbox_host, path: '/service/v1').to_s
end
def get_account(options={})
options.merge!({:basic_auth => @auth})
self.class.get("/account", options)
end
def get_communications(options={})
options.merge!({:basic_auth => @auth})
self.class.get("/communications", options)
end
end
class CommunicationReport
def initialize
@sb_api = SquawkboxAPI.new('secret', 'secret')
puts @sb_api.get_communications
end
end
CommunicationReport.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment