mention-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/lib/mention-api.rb +14 -0
- data/lib/mention/account.rb +55 -0
- data/lib/mention/alert.rb +29 -0
- data/lib/mention/alert_creator.rb +56 -0
- data/lib/mention/api.rb +7 -0
- data/lib/mention/api/version.rb +5 -0
- data/lib/mention/error.rb +4 -0
- data/lib/mention/share.rb +12 -0
- data/lib/mention/validation_error.rb +4 -0
- data/mention-api.gemspec +27 -0
- data/spec/acceptance/alert_management_spec.rb +15 -0
- data/spec/fixtures/get_account.json +1 -0
- data/spec/fixtures/get_account_alerts.json +1 -0
- data/spec/fixtures/post_account_alerts.json +1 -0
- data/spec/fixtures/post_account_alerts_failed.json +1 -0
- data/spec/lib/mention/account_spec.rb +63 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/spec_helper_acceptance.rb +2 -0
- data/spec/spec_helper_unit.rb +2 -0
- data/spec/support/credentials_context.rb +5 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9e4467d498d2f233ca786a5b5f6ae695c4c10d1d
|
4
|
+
data.tar.gz: 5c60bed83709587b5ae6523fd6a2e5db9f8ad7be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27a4e81b80e926f14b570326ee2a669134a0daba55f12c3ac597cadaee174bd46ef9b04f61773642c005b6686a179888a015dff467f7f94734692fe222158034
|
7
|
+
data.tar.gz: f770415997967a97ce8c9fc37a5d070086360bb1b693c6b6c8f949382ccc40236529d1507ab530d54ffd2568db6506294e88ad535a8f7f22f164495b32e8b320
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Michael Ries
|
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,45 @@
|
|
1
|
+
# Mention::Api
|
2
|
+
|
3
|
+
A nice ruby interface to wrap the [Mention.net](mention.net) API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mention-api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mention-api
|
18
|
+
|
19
|
+
## Developing
|
20
|
+
|
21
|
+
There are a list of acceptance specs that run against the live mention service. In order to run these specs you will need to create a file at spec/fixtures/credentials.yml. The contents should look like this:
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
---
|
25
|
+
:account_id: your-account-id-here
|
26
|
+
:access_token: your-access-token-here
|
27
|
+
```
|
28
|
+
|
29
|
+
The unit tests for this project are under spec/lib. These need to be run separately from the acceptance tests since they use webmock to stub out all of the HTTP requests, whereas the acceptance tests specifically need to reach out the actual web service.
|
30
|
+
|
31
|
+
```bash
|
32
|
+
rspec spec/lib
|
33
|
+
...
|
34
|
+
|
35
|
+
rspec spec/acceptance
|
36
|
+
...
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/mention-api.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Dependencies
|
2
|
+
require 'json'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'virtus'
|
5
|
+
|
6
|
+
# core entities
|
7
|
+
require 'mention/account'
|
8
|
+
require 'mention/share'
|
9
|
+
require 'mention/alert'
|
10
|
+
|
11
|
+
# utility classes
|
12
|
+
require 'mention/error'
|
13
|
+
require 'mention/validation_error'
|
14
|
+
require 'mention/alert_creator'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Mention
|
2
|
+
class Account
|
3
|
+
def initialize(credentials)
|
4
|
+
@account_id = credentials.fetch(:account_id)
|
5
|
+
@access_token = credentials.fetch(:access_token)
|
6
|
+
end
|
7
|
+
|
8
|
+
def alerts
|
9
|
+
@alerts ||= begin
|
10
|
+
raw_data = JSON.parse(resource['alerts'].get)
|
11
|
+
raw_data['alerts'].map do |hash|
|
12
|
+
Mention::Alert.new(hash)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
account_info['account']['name']
|
19
|
+
end
|
20
|
+
|
21
|
+
def id
|
22
|
+
account_info['account']['id']
|
23
|
+
end
|
24
|
+
|
25
|
+
def email
|
26
|
+
account_info['account']['email']
|
27
|
+
end
|
28
|
+
|
29
|
+
def created_at
|
30
|
+
Time.parse(account_info['account']['created_at'])
|
31
|
+
end
|
32
|
+
|
33
|
+
def add(alert)
|
34
|
+
creator = AlertCreator.new(resource, alert)
|
35
|
+
@alerts = nil if creator.valid?
|
36
|
+
creator.created_alert
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove(alert, share)
|
40
|
+
resource["/alerts/#{alert.id}/shares/#{share.id}"].delete
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
attr_reader :account_id, :access_token
|
45
|
+
|
46
|
+
def resource
|
47
|
+
@resource ||= RestClient::Resource.new("https://api.mention.net/api/accounts/#{account_id}",
|
48
|
+
headers: {'Authorization' => "Bearer #{access_token}", "Accept" => "application/json"})
|
49
|
+
end
|
50
|
+
|
51
|
+
def account_info
|
52
|
+
@account_info ||= JSON.parse(resource.get)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Mention
|
2
|
+
class Alert
|
3
|
+
include Virtus.model
|
4
|
+
|
5
|
+
attribute :id, String
|
6
|
+
attribute :name, String
|
7
|
+
attribute :primary_keyword, String
|
8
|
+
attribute :included_keywords, Array[String]
|
9
|
+
attribute :excluded_keywords, Array[String]
|
10
|
+
attribute :required_keywords, Array[String]
|
11
|
+
attribute :noise_detection, Boolean, default: true
|
12
|
+
attribute :sentiment_analysis, Boolean, default: false
|
13
|
+
attribute :languages, Array[String], default: ['en']
|
14
|
+
attribute :sources, Array[String], default: ["web","facebook","twitter","news","blogs","videos","forums","images"]
|
15
|
+
attribute :shares, Array[Share], default: []
|
16
|
+
|
17
|
+
def remove_from(account)
|
18
|
+
share = share_for(account)
|
19
|
+
account.remove(self, share)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def share_for(account)
|
24
|
+
found = shares.find{|share| share.account_id}
|
25
|
+
raise Error.new("could not find share for account #{account.id}") if found.nil?
|
26
|
+
found
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Mention
|
2
|
+
class AlertCreator
|
3
|
+
def initialize(account_resource, alert)
|
4
|
+
@account_resource, @alert = account_resource, alert
|
5
|
+
end
|
6
|
+
|
7
|
+
def created_alert
|
8
|
+
@created_alert ||= Mention::Alert.new(response['alert'])
|
9
|
+
end
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
validate_response!
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
attr_reader :account_resource, :alert
|
18
|
+
|
19
|
+
def response
|
20
|
+
@response ||= JSON.parse(response_str)
|
21
|
+
end
|
22
|
+
|
23
|
+
def response_str
|
24
|
+
@response_str ||= account_resource['alerts'].post(
|
25
|
+
JSON.generate(request_params),
|
26
|
+
:content_type => 'application/json')
|
27
|
+
end
|
28
|
+
|
29
|
+
def request_params
|
30
|
+
alert.attributes.reject{|k,v| k == :id}
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate_response!
|
34
|
+
raise ValidationError.new(validation_errors.join(", ")) unless response['alert']
|
35
|
+
end
|
36
|
+
|
37
|
+
def validation_errors
|
38
|
+
aggregate_errors(response)
|
39
|
+
end
|
40
|
+
|
41
|
+
def aggregate_errors(hash_node, list = [])
|
42
|
+
if !hash_node.is_a?(Hash)
|
43
|
+
[]
|
44
|
+
elsif hash_node['errors']
|
45
|
+
hash_node['errors']
|
46
|
+
else
|
47
|
+
error_lists = hash_node.map do |key, node|
|
48
|
+
aggregate_errors(node)
|
49
|
+
end
|
50
|
+
error_lists.inject([]) do |list, node_list|
|
51
|
+
list + node_list
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/mention/api.rb
ADDED
data/mention-api.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mention/api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mention-api"
|
8
|
+
spec.version = Mention::Api::VERSION
|
9
|
+
spec.authors = ["Michael Ries"]
|
10
|
+
spec.email = ["michael@riesd.com"]
|
11
|
+
spec.description = "A wrapper for the mention.net API"
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/hqmq/mention-api"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
24
|
+
spec.add_development_dependency "webmock", "~> 1.14"
|
25
|
+
spec.add_runtime_dependency "rest-client", "~> 1.6.7"
|
26
|
+
spec.add_runtime_dependency "virtus", "~> 1.0.0.rc1"
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
|
3
|
+
describe "Managing Alerts" do
|
4
|
+
include_context "credentials"
|
5
|
+
|
6
|
+
it "returns a list of alerts" do
|
7
|
+
account.alerts.should be_a(Enumerable)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "creates and deletes an alert" do
|
11
|
+
alert = Mention::Alert.new(name: 'mention-api', primary_keyword: 'mention-api', required_keywords: ['ruby','gem'])
|
12
|
+
alert = account.add(alert)
|
13
|
+
alert.remove_from(account)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"account":{"id":"abc","subscription":{"mentions_remaining":9972,"mentions_quota":10000,"max_members":0,"history":-1,"max_alerts":20,"statistics_access":true,"data_export_access":true,"search_access":true,"plan_code":"freetrial_pro10000","plan_name":"Pro 10 000 Trial","resets_at":"2013-11-06T22:09:48.0+00:00","team_owner":false,"permissions":{"change_plan":true,"manage":true,"manage_team_members":false},"prepaid_remaining":0,"trial_plan":true,"max_languages_per_alert":5,"custom":false,"paid_subscription":false},"name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-08T02:24:49.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg","email_subscriptions":{"quota_exceeded":true},"company_name":"Ries Designs","phone":"123 555 1234","extended_profile_set":false},"_links":{"href":{"self":"\/api\/accounts\/abc"}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"alerts":[{"id":"459069","name":"Riesd","primary_keyword":"Riesd","included_keywords":[],"excluded_keywords":[],"required_keywords":[],"languages":["en"],"sources":["web","facebook","twitter","news","blogs","videos","forums","images"],"blocked_sites":[],"role":"admin","stats":{"mentions":{"total":"1","twitter":"1"},"unread_mentions":{"total":"0"},"favorite_mentions":{"total":"0"},"important_mentions":{"total":"0"},"trashed_mentions":{"total":"0","spam":"0"},"tasks":{"total":"0"},"todo_tasks":{"total":"0"},"done_tasks":{"total":"0"},"logs":{"total":"0"}},"shares":[{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","account":{"id":"abc","name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-08T02:24:49.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg"},"role":"admin","subscriber":true,"color":"#1abc9c","permissions":{"edit":true,"delete":true},"created_at":"2013-10-07T05:08:12.0+00:00"}],"noise_detection":true,"sentiment_analysis":true,"created_at":"2013-10-07T05:08:12.0+00:00","updated_at":"2013-10-08T01:43:24.0+00:00","last_update":"2013-10-08T01:43:24.0+00:00","read_access_secret":"def","quota_used":0,"permissions":{"edit":true,"share":true,"list_tasks":false,"list_logs":false}}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"alert":{"id":"461518","name":"ROM","primary_keyword":"ROM","included_keywords":[],"excluded_keywords":[],"required_keywords":["ruby","object","mapper"],"languages":["en"],"sources":["web","facebook","twitter","news","blogs","videos","forums","images"],"blocked_sites":[],"role":"admin","stats":{"mentions":{"total":"0"},"unread_mentions":{"total":"0"},"favorite_mentions":{"total":"0"},"important_mentions":{"total":"0"},"trashed_mentions":{"total":"0","spam":"0"},"tasks":{"total":"0"},"todo_tasks":{"total":"0"},"done_tasks":{"total":"0"},"logs":{"total":"0"}},"shares":[{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","account":{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-08T02:24:49.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg"},"role":"admin","subscriber":true,"color":"#2ecc71","permissions":{"edit":true,"delete":true},"created_at":"2013-10-08T03:56:35.0+00:00"}],"noise_detection":true,"sentiment_analysis":true,"created_at":"2013-10-08T03:56:35.0+00:00","updated_at":"2013-10-08T03:56:35.0+00:00","read_access_secret":"5onrhj93khgcsgokg8484gswwskwoko08gog0gokw8wock0s8w","quota_used":0,"permissions":{"edit":true,"share":true,"list_tasks":false,"list_logs":false}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"form":{"children":{"name":[],"primary_keyword":[],"included_keywords":[],"excluded_keywords":[],"required_keywords":{"children":[[],[],[]]},"languages":{"errors":["Please select at least one language"]},"sources":{"errors":["Please select at least one source"]},"noise_detection":[],"sentiment_analysis":[],"blocked_sites":[]}},"max_alerts_exceeded":false,"max_alerts":20}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper_unit'
|
2
|
+
|
3
|
+
describe Mention::Account do
|
4
|
+
let(:account){ Mention::Account.new(account_id: 'abc', access_token: 'def') }
|
5
|
+
|
6
|
+
it "queries a list of alerts" do
|
7
|
+
stub_request(:get, "https://api.mention.net/api/accounts/abc/alerts").
|
8
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer def', 'User-Agent'=>'Ruby'}).
|
9
|
+
to_return(:status => 200, :body => File.read("spec/fixtures/get_account_alerts.json"))
|
10
|
+
|
11
|
+
account.alerts.size.should == 1
|
12
|
+
account.alerts.first.should be_a(Mention::Alert)
|
13
|
+
account.alerts.first.id.should == '459069'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "queries basic information about the account" do
|
17
|
+
stub_request(:get, "https://api.mention.net/api/accounts/abc").
|
18
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer def', 'User-Agent'=>'Ruby'}).
|
19
|
+
to_return(:status => 200, :body => File.read("spec/fixtures/get_account.json"))
|
20
|
+
|
21
|
+
account.id.should == 'abc'
|
22
|
+
account.name.should == "Michael Ries"
|
23
|
+
account.email.should == 'michael@riesd.com'
|
24
|
+
account.created_at.should == Time.parse("2013-10-06T22:09:48.0+00:00")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can add alerts to an account" do
|
28
|
+
stub_request(:post, "https://api.mention.net/api/accounts/abc/alerts").
|
29
|
+
with(:body => "{\"name\":\"ROM\",\"primary_keyword\":\"ROM\",\"included_keywords\":[],\"excluded_keywords\":[],\"required_keywords\":[\"ruby\",\"object\",\"mapper\"],\"noise_detection\":true,\"sentiment_analysis\":false,\"languages\":[\"en\"],\"sources\":[\"web\",\"facebook\",\"twitter\",\"news\",\"blogs\",\"videos\",\"forums\",\"images\"]}",
|
30
|
+
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer def', 'Content-Type'=>'application/json'}).
|
31
|
+
to_return(:status => 200, :body => File.read("spec/fixtures/post_account_alerts.json"))
|
32
|
+
|
33
|
+
alert = Mention::Alert.new(name: 'ROM', primary_keyword: 'ROM', required_keywords: ['ruby','object','mapper'])
|
34
|
+
alert = account.add(alert)
|
35
|
+
alert.id.should == '461518'
|
36
|
+
alert.name.should == 'ROM'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "reports validation errors when creating a new alert" do
|
40
|
+
stub_request(:post, "https://api.mention.net/api/accounts/abc/alerts").
|
41
|
+
with(:body => "{\"name\":\"ROM\",\"primary_keyword\":\"ROM\",\"included_keywords\":[],\"excluded_keywords\":[],\"required_keywords\":[\"ruby\",\"object\",\"mapper\"],\"noise_detection\":true,\"sentiment_analysis\":false,\"languages\":[],\"sources\":[]}",
|
42
|
+
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer def', 'Content-Type'=>'application/json'}).
|
43
|
+
to_return(:status => 200, :body => File.read("spec/fixtures/post_account_alerts_failed.json"))
|
44
|
+
|
45
|
+
alert = Mention::Alert.new(name: 'ROM', primary_keyword: 'ROM', required_keywords: ['ruby', 'object', 'mapper'], languages: [], sources: [])
|
46
|
+
->{
|
47
|
+
account.add(alert)
|
48
|
+
}.should raise_error(Mention::ValidationError, /language/)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "removes an alert from the account" do
|
52
|
+
stub_request(:get, "https://api.mention.net/api/accounts/abc/alerts").
|
53
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer def', 'User-Agent'=>'Ruby'}).
|
54
|
+
to_return(:status => 200, :body => File.read("spec/fixtures/get_account_alerts.json"))
|
55
|
+
|
56
|
+
stub_request(:delete, "https://api.mention.net/api/accounts/abc/alerts/459069/shares/209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw").
|
57
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer def'}).
|
58
|
+
to_return(:status => 200, :body => "true")
|
59
|
+
|
60
|
+
alert = account.alerts.first
|
61
|
+
alert.remove_from(account)
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mention-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Ries
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rest-client
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.6.7
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.6.7
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: virtus
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.0.0.rc1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.0.0.rc1
|
97
|
+
description: A wrapper for the mention.net API
|
98
|
+
email:
|
99
|
+
- michael@riesd.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/mention-api.rb
|
110
|
+
- lib/mention/account.rb
|
111
|
+
- lib/mention/alert.rb
|
112
|
+
- lib/mention/alert_creator.rb
|
113
|
+
- lib/mention/api.rb
|
114
|
+
- lib/mention/api/version.rb
|
115
|
+
- lib/mention/error.rb
|
116
|
+
- lib/mention/share.rb
|
117
|
+
- lib/mention/validation_error.rb
|
118
|
+
- mention-api.gemspec
|
119
|
+
- spec/acceptance/alert_management_spec.rb
|
120
|
+
- spec/fixtures/get_account.json
|
121
|
+
- spec/fixtures/get_account_alerts.json
|
122
|
+
- spec/fixtures/post_account_alerts.json
|
123
|
+
- spec/fixtures/post_account_alerts_failed.json
|
124
|
+
- spec/lib/mention/account_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/spec_helper_acceptance.rb
|
127
|
+
- spec/spec_helper_unit.rb
|
128
|
+
- spec/support/credentials_context.rb
|
129
|
+
homepage: https://github.com/hqmq/mention-api
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.0.6
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: A wrapper for the mention.net API
|
153
|
+
test_files:
|
154
|
+
- spec/acceptance/alert_management_spec.rb
|
155
|
+
- spec/fixtures/get_account.json
|
156
|
+
- spec/fixtures/get_account_alerts.json
|
157
|
+
- spec/fixtures/post_account_alerts.json
|
158
|
+
- spec/fixtures/post_account_alerts_failed.json
|
159
|
+
- spec/lib/mention/account_spec.rb
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
- spec/spec_helper_acceptance.rb
|
162
|
+
- spec/spec_helper_unit.rb
|
163
|
+
- spec/support/credentials_context.rb
|