Class: Laika::Yammer
- Inherits:
-
Object
- Object
- Laika::Yammer
- Defined in:
- lib/laika/yammer.rb
Defined Under Namespace
Classes: CouldNotLoadCredentials, CouldNotPost
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#initialize(credential_file = 'laika.yml') ⇒ Yammer
constructor
A new instance of Yammer.
- #post(message) ⇒ Object
Constructor Details
#initialize(credential_file = 'laika.yml') ⇒ Yammer
Returns a new instance of Yammer.
14 15 16 17 18 19 20 21 22 |
# File 'lib/laika/yammer.rb', line 14 def initialize(credential_file='laika.yml') begin @credentials = YAML.load_file(credential_file) rescue raise CouldNotLoadCredentials, "Couldn't load your Yammer credentials. You may need to run laika-auth." end @consumer = OAuth::Consumer.new(@credentials[:consumer_key], @credentials[:consumer_secret], {:site => "https://www.yammer.com"}) @access_token = OAuth::AccessToken.new(@consumer, @credentials[:access_token], @credentials[:access_token_secret]) end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
12 13 14 |
# File 'lib/laika/yammer.rb', line 12 def access_token @access_token end |
Instance Method Details
#post(message) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/laika/yammer.rb', line 24 def post() response = @access_token.post('/api/v1/messages', {:body => }, {'Accept' => 'application/xml'}) if response.is_a?(Net::HTTPCreated) true else raise CouldNotPost, response.body end end |