mollom_rest_api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +18 -0
  5. data/Guardfile +4 -0
  6. data/LICENSE +21 -0
  7. data/README.md +86 -0
  8. data/Rakefile +6 -0
  9. data/lib/mollom_rest_api/exceptions.rb +12 -0
  10. data/lib/mollom_rest_api/interface.rb +81 -0
  11. data/lib/mollom_rest_api/v1/blacklist.rb +29 -0
  12. data/lib/mollom_rest_api/v1/captcha.rb +11 -0
  13. data/lib/mollom_rest_api/v1/content.rb +12 -0
  14. data/lib/mollom_rest_api/v1/feedback.rb +14 -0
  15. data/lib/mollom_rest_api/v1/site.rb +23 -0
  16. data/lib/mollom_rest_api/v1/whitelist.rb +29 -0
  17. data/lib/mollom_rest_api/v1.rb +3 -0
  18. data/lib/mollom_rest_api/version.rb +3 -0
  19. data/lib/mollom_rest_api/versioned_api.rb +51 -0
  20. data/lib/mollom_rest_api.rb +31 -0
  21. data/log/.gitkeep +0 -0
  22. data/mollom_rest_api.gemspec +21 -0
  23. data/spec/fixtures/cassette_library/blacklist/create.yml +43 -0
  24. data/spec/fixtures/cassette_library/blacklist/delete.yml +43 -0
  25. data/spec/fixtures/cassette_library/blacklist/list.yml +39 -0
  26. data/spec/fixtures/cassette_library/blacklist/read.yml +41 -0
  27. data/spec/fixtures/cassette_library/blacklist/update.yml +43 -0
  28. data/spec/fixtures/cassette_library/captcha/create/default_request.yml +45 -0
  29. data/spec/fixtures/cassette_library/captcha/create/invalid_type.yml +45 -0
  30. data/spec/fixtures/cassette_library/captcha/create/valid_request.yml +45 -0
  31. data/spec/fixtures/cassette_library/captcha/verify/invalid_captcha_id.yml +45 -0
  32. data/spec/fixtures/cassette_library/captcha/verify/invalid_solution.yml +46 -0
  33. data/spec/fixtures/cassette_library/captcha/verify/valid_solution.yml +46 -0
  34. data/spec/fixtures/cassette_library/content/create.yml +46 -0
  35. data/spec/fixtures/cassette_library/content/update/invalid_content_id.yml +45 -0
  36. data/spec/fixtures/cassette_library/content/update/valid_request.yml +45 -0
  37. data/spec/fixtures/cassette_library/feedback/add/captcha_request.yml +45 -0
  38. data/spec/fixtures/cassette_library/feedback/add/content_request.yml +45 -0
  39. data/spec/fixtures/cassette_library/interface/some_api/a_post_action.yml +32 -0
  40. data/spec/fixtures/cassette_library/interface/some_api/an_overriden_get_action.yml +26 -0
  41. data/spec/fixtures/cassette_library/interface/some_api/an_overriden_post_action.yml +32 -0
  42. data/spec/fixtures/cassette_library/interface/some_api/delete.yml +26 -0
  43. data/spec/fixtures/cassette_library/interface/some_api/list.yml +26 -0
  44. data/spec/fixtures/cassette_library/invalid_request.yml +59 -0
  45. data/spec/fixtures/cassette_library/site/create.yml +45 -0
  46. data/spec/fixtures/cassette_library/site/delete.yml +45 -0
  47. data/spec/fixtures/cassette_library/site/list.yml +75 -0
  48. data/spec/fixtures/cassette_library/site/read.yml +41 -0
  49. data/spec/fixtures/cassette_library/site/update.yml +43 -0
  50. data/spec/fixtures/cassette_library/whitelist/create.yml +43 -0
  51. data/spec/fixtures/cassette_library/whitelist/delete.yml +43 -0
  52. data/spec/fixtures/cassette_library/whitelist/list.yml +41 -0
  53. data/spec/fixtures/cassette_library/whitelist/read.yml +39 -0
  54. data/spec/fixtures/cassette_library/whitelist/update.yml +43 -0
  55. data/spec/fixtures/v_test_01.rb +27 -0
  56. data/spec/mollom_rest_api/exceptions_spec.rb +25 -0
  57. data/spec/mollom_rest_api/interface_spec.rb +43 -0
  58. data/spec/mollom_rest_api/v1/blacklist_spec.rb +64 -0
  59. data/spec/mollom_rest_api/v1/captcha_spec.rb +63 -0
  60. data/spec/mollom_rest_api/v1/content_spec.rb +41 -0
  61. data/spec/mollom_rest_api/v1/feedback_spec.rb +37 -0
  62. data/spec/mollom_rest_api/v1/site_spec.rb +63 -0
  63. data/spec/mollom_rest_api/v1/whitelist_spec.rb +64 -0
  64. data/spec/mollom_rest_api/v1_spec.rb +9 -0
  65. data/spec/mollom_rest_api/version_spec.rb +5 -0
  66. data/spec/mollom_rest_api/versioned_api_spec.rb +26 -0
  67. data/spec/mollom_rest_api_spec.rb +30 -0
  68. data/spec/spec_helper.rb +15 -0
  69. data/spec/support/macros/alternate_syntax_macro.rb +38 -0
  70. data/spec/support/shared_examples/api_error_handling.rb +33 -0
  71. data/spec/support/vcr.rb +37 -0
  72. metadata +192 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWZiNDM0Mjg5ZGIyMmZhMTdmYWI4OWY3YTg0NWE4Mjk5OWNlZmI5Zg==
5
+ data.tar.gz: !binary |-
6
+ MjUxNGVkZDljYTU1ZDYyZWQyY2I0MTU3ZTU0Y2I4MWZmYWFiNmRjZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDE2NGFjNmM1ZWZhOGQyNWIwYjk5MzRmNDkxNGU1OGRmM2Q3NTUxNDVlNzk5
10
+ MzkyYWEyNDYyNWYzMTQ4ZDQ5YmFjMWZmZWY1NzFiYzc3NmZiODZkMWQ3MWE3
11
+ NjI5ZWExMjllODY0MGM1MjJhNTBjM2RkYzliNDhkMjVhZjA2MzE=
12
+ data.tar.gz: !binary |-
13
+ OWZmMzU1YWI0YzgyODk3NjMyODhjZDE0MWE2NDA4MTc2NTRlYWUwN2QwZGE1
14
+ YTBmZGIxNzNjYjczNGIzNzcwNDZkMzlhZTM2ZTY4YTIzNGU2ZDZkZWQ2YWJk
15
+ OWVjZDY4Y2JjMjc0ZTNkMmE4ODk2ZGI3MzE5NGY5MTMzNTY4YWQ=
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
19
+ .ruby-version
20
+ .ruby-gemset
21
+ .sass-cache
22
+ log/test.log
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'coveralls', require: false
6
+
7
+ group :development do
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'terminal-notifier-guard'
11
+ end
12
+
13
+ group :test do
14
+ gem 'rake'
15
+ gem 'rspec'
16
+ gem 'webmock'
17
+ gem 'vcr'
18
+ end
data/Guardfile ADDED
@@ -0,0 +1,4 @@
1
+ guard :rspec do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Krystian Czesak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ [![Build Status](https://travis-ci.org/Krystosterone/mollom_rest_api.svg?branch=master)](https://travis-ci.org/Krystosterone/mollom_rest_api)
2
+ [![Coverage Status](https://coveralls.io/repos/Krystosterone/mollom_rest_api/badge.png?branch=master)](https://coveralls.io/r/Krystosterone/mollom_rest_api?branch=master)
3
+
4
+ # Mollom Rest API
5
+
6
+ mollom_rest_api is a ruby wrapper, using oauth authentication, for the [Mollom](https://mollom.com) Rest API.
7
+
8
+ ## Installation
9
+
10
+ Add to your Gemfile:
11
+
12
+ gem 'mollom_rest_api'
13
+
14
+ or install from Rubygems:
15
+
16
+ gem install mollom_rest_api
17
+
18
+ ## Usage
19
+
20
+ Before using the gem, you must first configure it as such:
21
+
22
+ ```ruby
23
+ MollomRestApi.url = 'http://rest.mollom.com' # Do not include the API version number
24
+ MollomRestApi.public_key = 'my_public_key'
25
+ MollomRestApi.private_key = 'my_private_key'
26
+ MollomRestApi.oauth_options = {proxy: 'http://proxy.com:8888'} # some additional oauth options
27
+ ```
28
+
29
+ You can get your public key and private key using Mollom's [site manager](https://mollom.com/user/130051/site-manager), after signing in.
30
+
31
+ ### Calling endpoints
32
+ The gem implementation replicates the [Mollom's API Documentation](https://mollom.com/api) as much as possible.
33
+
34
+ #### Example of API call
35
+
36
+ Here is an example of how to verify a captcha using the gem.
37
+
38
+ As per Mollom's Documentation on [verifying a captcha](https://mollom.com/api#captcha):
39
+
40
+ ```
41
+ Syntax: POST http://rest.mollom.com/v1/captcha
42
+ ```
43
+
44
+ - Path parameters
45
+ - **captchaId: The ID of the CAPTCHA resource.**
46
+ - Request parameters
47
+ - **solution:**
48
+ - **The answer provided by the author.**
49
+ - authorName: (optional)
50
+ - The name of the content author.
51
+ - authorUrl: (optional)
52
+ - The homepage/website URL of the content author.
53
+ - authorMail: (optional)
54
+ - The e-mail address of the content author.
55
+ - authorIp: (optional)
56
+ - The IP address of the content author.
57
+ - authorId: (optional)
58
+ - The local user ID of the content author on the client site.
59
+ - authorOpenid: (multiple, optional)
60
+ - One or more Open IDs of the content author.
61
+ - rateLimit: (optional, default = 15)
62
+ - Seconds that must have passed by for the same author to post again.
63
+ - honeypot: (optional)
64
+ - Client-side honeypot value, if non-empty.
65
+
66
+ As such, `captchaId` and `solution` must both be specified for the endpoint call to succeed. All other parameters are optional, and can be passed to the call using a hash.
67
+
68
+ Using the gem, we call this endpoint using:
69
+
70
+ ```ruby
71
+ MollomRestApi::V1::Captcha.verify("captchaId", "solution", {authorName: "Bob", ...})
72
+ ```
73
+
74
+ or using the alternative syntax:
75
+
76
+ ```ruby
77
+ MollomRestApi::V1::verify_captcha("captchaId", "solution", {authorName: "Bob", ...})
78
+ ```
79
+
80
+ ### Running Tests
81
+
82
+ `bundle exec rspec spec` - Running specs (all web interactions are mocked with VCR cassettes)
83
+
84
+ ### Contributors
85
+ + [royjs](https://github.com/royjs)
86
+ + [krystosterone](https://github.com/krystosterone)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
@@ -0,0 +1,12 @@
1
+ module MollomRestApi
2
+ class ApiException < StandardError
3
+ attr_reader :error_code
4
+
5
+ def initialize(message, error_code)
6
+ super(message)
7
+ @error_code = error_code
8
+ end
9
+ end
10
+
11
+ class MissingConfig < StandardError; end
12
+ end
@@ -0,0 +1,81 @@
1
+ class MollomRestApi::Interface
2
+ REQUEST_HEADERS = {'Accept' => 'application/json'}
3
+ MANDATORY_CONFIGURATIONS = %w(url public_key private_key)
4
+
5
+ class << self
6
+ protected
7
+
8
+ def results_key
9
+ path_from_class_name
10
+ end
11
+
12
+ def path
13
+ path_from_class_name
14
+ end
15
+
16
+ def version
17
+ version_from_class_name
18
+ end
19
+
20
+ def post(request_parameters = {}, path_parameters = [])
21
+ request(:post, request_parameters, path_parameters)
22
+ end
23
+
24
+ def get(request_parameters = {}, path_parameters = [])
25
+ request(:get, request_parameters, path_parameters)
26
+ end
27
+
28
+ private
29
+
30
+ def request(http_method, request_parameters, path_parameters)
31
+ ensure_configuration_is_valid!
32
+
33
+ request_arguments = request_arguments(http_method, path, path_parameters, request_parameters, version)
34
+ response = MollomRestApi.oauth_access_token.request(http_method, *request_arguments)
35
+
36
+ throw_api_exception_using(response) unless response.code == '200'
37
+
38
+ computed_results_key = method_that_called_the_api_operation == 'list' ? 'list' : results_key
39
+ JSON.parse(response.body)[computed_results_key]
40
+ end
41
+
42
+ def ensure_configuration_is_valid!
43
+ MANDATORY_CONFIGURATIONS.each do |config|
44
+ raise MollomRestApi::MissingConfig.new("Missing #{config}.") if MollomRestApi.send(config).nil?
45
+ end
46
+ end
47
+
48
+ def request_arguments(http_method, path, path_parameters, request_parameters, version)
49
+ url = url(path_parameters, version, path)
50
+
51
+ if http_method == :get
52
+ ["#{url}?#{request_parameters.to_query}", REQUEST_HEADERS]
53
+ elsif http_method == :post
54
+ [url, request_parameters, REQUEST_HEADERS]
55
+ end
56
+ end
57
+
58
+ def url(path_parameters, version, path)
59
+ path_parameters << 'delete' if method_that_called_the_api_operation == 'delete'
60
+ url_path = [path, path_parameters].flatten.compact.join('/')
61
+ "#{MollomRestApi.url}/#{version}/#{url_path}"
62
+ end
63
+
64
+ def method_that_called_the_api_operation
65
+ index = caller.index { |callstack| callstack[/`([^']*)'/, 1] == 'request' }
66
+ caller[index + 2][/`([^']*)'/, 1]
67
+ end
68
+
69
+ def version_from_class_name
70
+ self.name.split('::')[-2].downcase
71
+ end
72
+
73
+ def path_from_class_name
74
+ self.name.split('::').last.underscore
75
+ end
76
+
77
+ def throw_api_exception_using(response)
78
+ raise MollomRestApi::ApiException.new(response.body, response.code.to_i)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,29 @@
1
+ class MollomRestApi::V1::Blacklist < MollomRestApi::Interface
2
+ class << self
3
+ def create(public_key, value, request_parameters = {})
4
+ post(request_parameters.reverse_merge(value: value), [public_key])
5
+ end
6
+
7
+ def update(public_key, blacklist_entry_id, request_parameters = {})
8
+ post(request_parameters, [public_key, blacklist_entry_id])
9
+ end
10
+
11
+ def delete(public_key, blacklist_entry_id)
12
+ post({}, [public_key, blacklist_entry_id])
13
+ end
14
+
15
+ def list(public_key, request_parameters = {})
16
+ get(request_parameters, [public_key])
17
+ end
18
+
19
+ def read(public_key, blacklist_entry_id)
20
+ get({}, [public_key, blacklist_entry_id])
21
+ end
22
+
23
+ protected
24
+
25
+ def results_key
26
+ 'entry'
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ class MollomRestApi::V1::Captcha < MollomRestApi::Interface
2
+ class << self
3
+ def create(type = 'image', request_parameters = {})
4
+ post(request_parameters.reverse_merge(type: type))
5
+ end
6
+
7
+ def verify(captcha_id, solution, request_parameters = {})
8
+ post(request_parameters.reverse_merge(solution: solution), captcha_id)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class MollomRestApi::V1::Content < MollomRestApi::Interface
2
+ class << self
3
+ def create(request_parameters = {})
4
+ post(request_parameters)
5
+ end
6
+ alias_method :check, :create
7
+
8
+ def update(content_id, request_parameters = {})
9
+ post(request_parameters, [content_id])
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class MollomRestApi::V1::Feedback < MollomRestApi::Interface
2
+ class << self
3
+ def create(reason, request_parameters = {})
4
+ raise_missing_parameter_error unless request_parameters.include?(:contentId) ^ request_parameters.include?(:captchaId)
5
+ post(request_parameters.reverse_merge(reason: reason))
6
+ end
7
+
8
+ private
9
+
10
+ def raise_missing_parameter_error
11
+ raise ArgumentError.new("Specify one of two parameters: contentId or captchaId.")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ class MollomRestApi::V1::Site < MollomRestApi::Interface
2
+ class << self
3
+ def create(url, email, request_parameters = {})
4
+ post(request_parameters.reverse_merge(url: url, email: email))
5
+ end
6
+
7
+ def update(public_key, request_parameters = {})
8
+ post(request_parameters, [public_key])
9
+ end
10
+
11
+ def list(request_parameters = {})
12
+ get(request_parameters)
13
+ end
14
+
15
+ def read(public_key)
16
+ get({}, [public_key])
17
+ end
18
+
19
+ def delete(public_key)
20
+ post({}, [public_key])
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ class MollomRestApi::V1::Whitelist < MollomRestApi::Interface
2
+ class << self
3
+ def create(public_key, value, context, request_parameters = {})
4
+ post(request_parameters.reverse_merge(value: value, context: context), [public_key])
5
+ end
6
+
7
+ def update(public_key, whitelist_entry_id, request_parameters = {})
8
+ post(request_parameters, [public_key, whitelist_entry_id])
9
+ end
10
+
11
+ def delete(public_key, whitelist_entry_id)
12
+ post({}, [public_key, whitelist_entry_id])
13
+ end
14
+
15
+ def list(public_key, request_parameters = {})
16
+ get(request_parameters, [public_key])
17
+ end
18
+
19
+ def read(public_key, whitelist_entry_id)
20
+ get({}, [public_key, whitelist_entry_id])
21
+ end
22
+
23
+ protected
24
+
25
+ def results_key
26
+ 'entry'
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module MollomRestApi
2
+ class V1 < VersionedApi; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module MollomRestApi
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,51 @@
1
+ module MollomRestApi
2
+ class VersionedApi
3
+ class << self
4
+ def method_missing(method_name, *arguments, &block)
5
+ if handles_api_call?(method_name)
6
+ target_class = extract_class_from(method_name)
7
+ target_method = extract_method_from(method_name)
8
+ target_class.send(target_method, *arguments)
9
+ else
10
+ super
11
+ end
12
+ end
13
+
14
+ def respond_to?(method_name, include_private = false)
15
+ if handles_api_call?(method_name)
16
+ true
17
+ else
18
+ super
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def handles_api_call?(method_name)
25
+ target_class = extract_class_from(method_name)
26
+ return false if target_class.nil?
27
+
28
+ target_method = extract_method_from(method_name)
29
+
30
+ receiver_public_methods_of(target_class).include?(target_method.to_sym)
31
+ end
32
+
33
+ def receiver_public_methods_of(klass)
34
+ klass.public_methods(false) & klass.methods(false)
35
+ end
36
+
37
+ def extract_class_from(method_name)
38
+ interface_name = method_name.to_s.split('_').last
39
+ class_name = interface_name.camelize
40
+ return unless self.const_defined?(class_name)
41
+
42
+ target_class_name = "#{self.name}::#{class_name}"
43
+ target_class_name.constantize
44
+ end
45
+
46
+ def extract_method_from(method_name)
47
+ method_name.to_s.split('_').first
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,31 @@
1
+ require 'oauth'
2
+ require 'json'
3
+ require 'active_support/all'
4
+
5
+ module MollomRestApi
6
+ require 'mollom_rest_api/version'
7
+ require 'mollom_rest_api/exceptions'
8
+ require 'mollom_rest_api/interface'
9
+ require 'mollom_rest_api/versioned_api'
10
+ require 'mollom_rest_api/v1'
11
+ require 'mollom_rest_api/v1/content'
12
+ require 'mollom_rest_api/v1/captcha'
13
+ require 'mollom_rest_api/v1/feedback'
14
+ require 'mollom_rest_api/v1/site'
15
+ require 'mollom_rest_api/v1/blacklist'
16
+ require 'mollom_rest_api/v1/whitelist'
17
+
18
+ class << self
19
+ attr_accessor :url, :public_key, :private_key, :oauth_options
20
+
21
+ def oauth_access_token
22
+ @oauth_access_token ||= OAuth::AccessToken.new(oauth_consumer)
23
+ end
24
+
25
+ private
26
+
27
+ def oauth_consumer
28
+ OAuth::Consumer.new(public_key, private_key, @oauth_options || {})
29
+ end
30
+ end
31
+ end
data/log/.gitkeep ADDED
File without changes
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'mollom_rest_api/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "mollom_rest_api"
7
+ spec.version = MollomRestApi::VERSION
8
+ spec.authors = ["Jean-Sébastien Roy", "Krystian Czesak"]
9
+ spec.email = ["mollom.gem@gmail.com"]
10
+ spec.description = %q{A ruby wrapper for the Mollom Rest API.}
11
+ spec.summary = %q{A ruby wrapper for the Mollom Rest API.}
12
+ spec.homepage = ""
13
+ spec.license = ""
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.test_files = spec.files.grep(%r{^(spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency 'oauth'
20
+ spec.add_dependency 'activesupport'
21
+ end
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/blacklist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n
6
+ body:
7
+ encoding: US-ASCII
8
+ string: context=allFields&value=text
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Content-Length:
15
+ - '0'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="CP19Jf3MxtPxat0k5E4CARZ6PQJIZ8wsLkikBtbk",
20
+ oauth_signature="B0Cp%2FbPpz9ZaniKQ0Cbx5Z5WIuw%3D", oauth_signature_method="HMAC-SHA1",
21
+ oauth_timestamp="1409677740", oauth_version="1.0"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Powered-By:
28
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
29
+ Corporation/1.7)
30
+ Server:
31
+ - GlassFish Server Open Source Edition 3.1.2.2
32
+ Content-Type:
33
+ - application/json
34
+ Date:
35
+ - Tue, 02 Sep 2014 17:09:45 GMT
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ! '{"code":"200","entry":{"context":"allFields","created":"1409677772829","id":"41a0e033-3d6a-465b-87d5-1ef60476da62","match":"contains","note":"","reason":"unwanted","status":"1","value":"text"}}'
41
+ http_version:
42
+ recorded_at: Tue, 02 Sep 2014 17:09:00 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/blacklist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n/42a51362-bab6-4256-8e28-60d5df568250/delete
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Content-Length:
15
+ - '0'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="YRrT2k8Ld5HxTavGNav7MvTFo5se6fUC9syL2UvwPUM",
20
+ oauth_signature="v%2BCn79%2F6kiO6FTnGDklgaygcA8M%3D", oauth_signature_method="HMAC-SHA1",
21
+ oauth_timestamp="1410368605", oauth_version="1.0"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Powered-By:
28
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
29
+ Corporation/1.7)
30
+ Server:
31
+ - GlassFish Server Open Source Edition 3.1.2.2
32
+ Content-Type:
33
+ - application/json
34
+ Date:
35
+ - Wed, 10 Sep 2014 17:04:16 GMT
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ! '{"code":"200"}'
41
+ http_version:
42
+ recorded_at: Wed, 10 Sep 2014 17:03:25 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://dev.mollom.com/v1/blacklist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n?count=5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Authorization:
15
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="bxGeBFEd7ZBEwW7C9zHKPgIAs0dJ1thMdBUSpuoco4",
16
+ oauth_signature="UiA35v%2FZIgyxCD2L1i%2B5MG7VxsE%3D", oauth_signature_method="HMAC-SHA1",
17
+ oauth_timestamp="1410374054", oauth_version="1.0"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Powered-By:
24
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
25
+ Corporation/1.7)
26
+ Server:
27
+ - GlassFish Server Open Source Edition 3.1.2.2
28
+ Content-Type:
29
+ - application/json
30
+ Date:
31
+ - Wed, 10 Sep 2014 18:35:04 GMT
32
+ Connection:
33
+ - close
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '{"code":"200","list":{"entry":[{"context":"allFields","created":"1410369319158","id":"eafc878d-94f7-462d-bb67-49d5170a9a71","match":"contains","note":"","reason":"unwanted","status":"1","value":"patate-chaude"},{"context":"allFields","created":"1410369319342","id":"975805c8-ee06-4750-8cda-ec5626712c50","match":"contains","note":"","reason":"unwanted","status":"1","value":"system_32"}]},"listOffset":"0","listCount":"2","listTotal":"2"}'
37
+ http_version:
38
+ recorded_at: Wed, 10 Sep 2014 18:34:14 GMT
39
+ recorded_with: VCR 2.9.2