userfox 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.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +20 -0
- data/README.md +46 -0
- data/Rakefile +50 -0
- data/lib/userfox.rb +13 -0
- data/lib/userfox/client.rb +55 -0
- data/lib/userfox/version.rb +3 -0
- data/spec/fixtures/dish_cassettes/change.yml +67 -0
- data/spec/fixtures/dish_cassettes/send.yml +67 -0
- data/spec/fixtures/dish_cassettes/track.yml +67 -0
- data/spec/fixtures/dish_cassettes/unsubscribes.yml +67 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/userfox/client_spec.rb +73 -0
- data/spec/userfox_spec.rb +9 -0
- data/userfox.gemspec +78 -0
- metadata +196 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "httparty"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", ">= 0"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "bundler", ">= 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.8.4"
|
15
|
+
gem "simplecov", ">= 0"
|
16
|
+
gem "webmock", ">= 0", require: "webmock/minitest"
|
17
|
+
gem "vcr", ">= 0", require: "vcr"
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.2)
|
5
|
+
crack (0.3.2)
|
6
|
+
diff-lcs (1.1.3)
|
7
|
+
git (1.2.5)
|
8
|
+
httparty (0.10.0)
|
9
|
+
multi_json (~> 1.0)
|
10
|
+
multi_xml
|
11
|
+
jeweler (1.8.4)
|
12
|
+
bundler (~> 1.0)
|
13
|
+
git (>= 1.2.5)
|
14
|
+
rake
|
15
|
+
rdoc
|
16
|
+
json (1.7.6)
|
17
|
+
multi_json (1.5.0)
|
18
|
+
multi_xml (0.5.2)
|
19
|
+
rake (10.0.3)
|
20
|
+
rdoc (3.12)
|
21
|
+
json (~> 1.4)
|
22
|
+
rspec (2.12.0)
|
23
|
+
rspec-core (~> 2.12.0)
|
24
|
+
rspec-expectations (~> 2.12.0)
|
25
|
+
rspec-mocks (~> 2.12.0)
|
26
|
+
rspec-core (2.12.2)
|
27
|
+
rspec-expectations (2.12.1)
|
28
|
+
diff-lcs (~> 1.1.3)
|
29
|
+
rspec-mocks (2.12.0)
|
30
|
+
simplecov (0.7.1)
|
31
|
+
multi_json (~> 1.0)
|
32
|
+
simplecov-html (~> 0.7.1)
|
33
|
+
simplecov-html (0.7.1)
|
34
|
+
vcr (2.4.0)
|
35
|
+
webmock (1.9.0)
|
36
|
+
addressable (>= 2.2.7)
|
37
|
+
crack (>= 0.1.7)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
bundler (>= 1.0.0)
|
44
|
+
httparty
|
45
|
+
jeweler (~> 1.8.4)
|
46
|
+
rdoc (~> 3.12)
|
47
|
+
rspec
|
48
|
+
simplecov
|
49
|
+
vcr
|
50
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Antoine Lagadec
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#Userfox Ruby Gem
|
2
|
+
|
3
|
+
A Ruby Wrapper for the [Userfox API](http://www.userfox.com/docs/#rest-api)
|
4
|
+
|
5
|
+
##Installation
|
6
|
+
|
7
|
+
gem install userfox
|
8
|
+
|
9
|
+
##Getting Started
|
10
|
+
|
11
|
+
It’s as easy as pie, create a client like so :
|
12
|
+
|
13
|
+
userfox = Userfox.new("client_id", "client_secret")
|
14
|
+
|
15
|
+
Track a user :
|
16
|
+
|
17
|
+
userfox.track("hello@example.com", "http://example.com", name: "Antoine")
|
18
|
+
|
19
|
+
Send him an email :
|
20
|
+
|
21
|
+
userfox.send("hello@example.com", "Password Recovery", hello: "world")
|
22
|
+
|
23
|
+
Change Its email :
|
24
|
+
|
25
|
+
userfox.change("hello@example.com", "hi@example.com")
|
26
|
+
|
27
|
+
Unsubscribes him :
|
28
|
+
|
29
|
+
userfox.unsubscribes("hello@example.com")
|
30
|
+
|
31
|
+
See [Userfox API Documentation](http://www.userfox.com/docs/#rest-api) for further informations about what you can do with all of that.
|
32
|
+
|
33
|
+
##Contributing to userfox
|
34
|
+
|
35
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
36
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
37
|
+
* Fork the project.
|
38
|
+
* Start a feature/bugfix branch.
|
39
|
+
* Commit and push until you are happy with your contribution.
|
40
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
41
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
42
|
+
|
43
|
+
##Copyright
|
44
|
+
|
45
|
+
Copyright (c) 2013 Antoine Lagadec. See LICENSE.txt for
|
46
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rake'
|
14
|
+
require './lib/userfox/version.rb'
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
gem.name = "userfox"
|
19
|
+
gem.version = Userfox::VERSION
|
20
|
+
gem.homepage = "http://github.com/oakho/userfox"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{A Ruby Wrapper for the Userfox API}
|
23
|
+
gem.description = %Q{This gem is a Ruby Wrapper made to use the Userfox API conveniently}
|
24
|
+
gem.email = "hello@oakho.com"
|
25
|
+
gem.authors = ["Antoine Lagadec"]
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = Userfox::VERSION
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "userfox #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/lib/userfox.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Userfox
|
2
|
+
class UnauthorizedError < StandardError; end
|
3
|
+
class Client
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
base_uri "https://api.userfox.com/v1"
|
7
|
+
|
8
|
+
def initialize(client_id, client_secret)
|
9
|
+
@auth = { username: client_id, password: client_secret }
|
10
|
+
end
|
11
|
+
|
12
|
+
def post(path, options = {})
|
13
|
+
options.merge!({ basic_auth: @auth })
|
14
|
+
handle_response { self.class.post(path, options) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def track(email, url, delta = {}, options = {})
|
18
|
+
options[:body] = { addr: email, url: url, delta: delta.to_json }
|
19
|
+
|
20
|
+
post("/track.json", options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def send(email, name, delta = {}, options = {})
|
24
|
+
options[:body] = { addr: email, name: name, delta: delta.to_json }
|
25
|
+
|
26
|
+
post("/send.json", options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def change(from, to, options = {})
|
30
|
+
options[:body] = { from: from, to: to }
|
31
|
+
|
32
|
+
post("/change.json", options)
|
33
|
+
end
|
34
|
+
|
35
|
+
def unsubscribes(email, options = {})
|
36
|
+
options[:body] = { addr: email }
|
37
|
+
|
38
|
+
post("/unsubscribes.json", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def handle_response(&block)
|
44
|
+
response = block.call
|
45
|
+
|
46
|
+
case response.code
|
47
|
+
when 401 then raise(UnauthorizedError, "You are unauthorized, check your credentials.")
|
48
|
+
# At the moment, 404 errors from the API means lots of things...
|
49
|
+
when 404 then raise(UnauthorizedError, "You are unauthorized, check your credentials.")
|
50
|
+
end
|
51
|
+
|
52
|
+
response
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://123456:123456@api.userfox.com/v1/change.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: from=hello%40example.com&to=user%40example.com
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- max-age=0, private, must-revalidate
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Etag:
|
20
|
+
- ! '"2635460002a165242fa7f943dc723986"'
|
21
|
+
Server:
|
22
|
+
- thin 1.5.0 codename Knife
|
23
|
+
Set-Cookie:
|
24
|
+
- _session_id=f82fbcf80394d887f7f6c13521eb981a; path=/; secure; HttpOnly
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- IE=Edge,chrome=1
|
27
|
+
Content-Length:
|
28
|
+
- '52'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ! '{"status":"Success","detail":"Ok","callbackId":null}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sat, 19 Jan 2013 23:15:18 GMT
|
36
|
+
- request:
|
37
|
+
method: post
|
38
|
+
uri: https://abcde:abcde@api.userfox.com/v1/change.json
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: from=hello%40example.com&to=user%40example.com
|
42
|
+
headers: {}
|
43
|
+
response:
|
44
|
+
status:
|
45
|
+
code: 404
|
46
|
+
message: Not Found
|
47
|
+
headers:
|
48
|
+
Cache-Control:
|
49
|
+
- no-cache
|
50
|
+
Content-Type:
|
51
|
+
- application/json; charset=utf-8
|
52
|
+
Server:
|
53
|
+
- thin 1.5.0 codename Knife
|
54
|
+
Set-Cookie:
|
55
|
+
- _session_id=a0c003078abdeb1f576d051a8cdd04ef; path=/; secure; HttpOnly
|
56
|
+
X-Ua-Compatible:
|
57
|
+
- IE=Edge,chrome=1
|
58
|
+
Content-Length:
|
59
|
+
- '39'
|
60
|
+
Connection:
|
61
|
+
- keep-alive
|
62
|
+
body:
|
63
|
+
encoding: US-ASCII
|
64
|
+
string: ! '{"status":"Error","detail":"Not Found"}'
|
65
|
+
http_version:
|
66
|
+
recorded_at: Sat, 19 Jan 2013 23:15:19 GMT
|
67
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://123456:123456@api.userfox.com/v1/send.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: addr=hello%40example.com&name=Password%20Recovery&delta=%7B%22hello%22%3A%22world%22%7D
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- max-age=0, private, must-revalidate
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Etag:
|
20
|
+
- ! '"2635460002a165242fa7f943dc723986"'
|
21
|
+
Server:
|
22
|
+
- thin 1.5.0 codename Knife
|
23
|
+
Set-Cookie:
|
24
|
+
- _session_id=96b3d356e81b1e0d003faa022da70137; path=/; secure; HttpOnly
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- IE=Edge,chrome=1
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ! '{"status":"Success","detail":"Ok","callbackId":null}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sat, 19 Jan 2013 23:15:17 GMT
|
36
|
+
- request:
|
37
|
+
method: post
|
38
|
+
uri: https://abcde:abcde@api.userfox.com/v1/send.json
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: addr=http%3A%2F%2Fwww.example.com&name=hello%40example.com&delta=%7B%22hello%22%3A%22world%22%7D
|
42
|
+
headers: {}
|
43
|
+
response:
|
44
|
+
status:
|
45
|
+
code: 404
|
46
|
+
message: Not Found
|
47
|
+
headers:
|
48
|
+
Cache-Control:
|
49
|
+
- no-cache
|
50
|
+
Content-Type:
|
51
|
+
- application/json; charset=utf-8
|
52
|
+
Server:
|
53
|
+
- thin 1.5.0 codename Knife
|
54
|
+
Set-Cookie:
|
55
|
+
- _session_id=33f6b657711e7ff56cb62baa85d43210; path=/; secure; HttpOnly
|
56
|
+
X-Ua-Compatible:
|
57
|
+
- IE=Edge,chrome=1
|
58
|
+
Transfer-Encoding:
|
59
|
+
- chunked
|
60
|
+
Connection:
|
61
|
+
- keep-alive
|
62
|
+
body:
|
63
|
+
encoding: US-ASCII
|
64
|
+
string: ! '{"status":"Error","detail":"Not Found"}'
|
65
|
+
http_version:
|
66
|
+
recorded_at: Sat, 19 Jan 2013 23:15:18 GMT
|
67
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://123456:123456@api.userfox.com/v1/track.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: addr=hello%40example.com&url=http%3A%2F%2Fwww.example.com&delta=%7B%22hello%22%3A%22world%22%7D
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- max-age=0, private, must-revalidate
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Etag:
|
20
|
+
- ! '"2635460002a165242fa7f943dc723986"'
|
21
|
+
Server:
|
22
|
+
- thin 1.5.0 codename Knife
|
23
|
+
Set-Cookie:
|
24
|
+
- _session_id=e3791fb47f4d07412fd3e94a36f70d1d; path=/; secure; HttpOnly
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- IE=Edge,chrome=1
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ! '{"status":"Success","detail":"Ok","callbackId":null}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sat, 19 Jan 2013 23:15:15 GMT
|
36
|
+
- request:
|
37
|
+
method: post
|
38
|
+
uri: https://abcde:abcde@api.userfox.com/v1/track.json
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: addr=hello%40example.com&url=http%3A%2F%2Fwww.example.com&delta=%7B%22hello%22%3A%22world%22%7D
|
42
|
+
headers: {}
|
43
|
+
response:
|
44
|
+
status:
|
45
|
+
code: 404
|
46
|
+
message: Not Found
|
47
|
+
headers:
|
48
|
+
Cache-Control:
|
49
|
+
- no-cache
|
50
|
+
Content-Type:
|
51
|
+
- application/json; charset=utf-8
|
52
|
+
Server:
|
53
|
+
- thin 1.5.0 codename Knife
|
54
|
+
Set-Cookie:
|
55
|
+
- _session_id=e04bd22204dce708ea197bcbafec873e; path=/; secure; HttpOnly
|
56
|
+
X-Ua-Compatible:
|
57
|
+
- IE=Edge,chrome=1
|
58
|
+
Content-Length:
|
59
|
+
- '39'
|
60
|
+
Connection:
|
61
|
+
- keep-alive
|
62
|
+
body:
|
63
|
+
encoding: US-ASCII
|
64
|
+
string: ! '{"status":"Error","detail":"Not Found"}'
|
65
|
+
http_version:
|
66
|
+
recorded_at: Sat, 19 Jan 2013 23:15:16 GMT
|
67
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://123456:123456@api.userfox.com/v1/unsubscribes.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: addr=hello%40example.com
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- max-age=0, private, must-revalidate
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Etag:
|
20
|
+
- ! '"31fae2ae5d9493d813860635589b94f9"'
|
21
|
+
Server:
|
22
|
+
- thin 1.5.0 codename Knife
|
23
|
+
Set-Cookie:
|
24
|
+
- _session_id=0db4bc765199ec6cd2a6ffa11fe0bbcd; path=/; secure; HttpOnly
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- IE=Edge,chrome=1
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ! '{"status":"Success","detail":"Ok","email":"hello@example.com"}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sat, 19 Jan 2013 23:15:20 GMT
|
36
|
+
- request:
|
37
|
+
method: post
|
38
|
+
uri: https://abcde:abcde@api.userfox.com/v1/unsubscribes.json
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: addr=hello%40example.com
|
42
|
+
headers: {}
|
43
|
+
response:
|
44
|
+
status:
|
45
|
+
code: 404
|
46
|
+
message: Not Found
|
47
|
+
headers:
|
48
|
+
Cache-Control:
|
49
|
+
- no-cache
|
50
|
+
Content-Type:
|
51
|
+
- application/json; charset=utf-8
|
52
|
+
Server:
|
53
|
+
- thin 1.5.0 codename Knife
|
54
|
+
Set-Cookie:
|
55
|
+
- _session_id=8296ea233fe5ad9acb6608d5b42c93a1; path=/; secure; HttpOnly
|
56
|
+
X-Ua-Compatible:
|
57
|
+
- IE=Edge,chrome=1
|
58
|
+
Transfer-Encoding:
|
59
|
+
- chunked
|
60
|
+
Connection:
|
61
|
+
- keep-alive
|
62
|
+
body:
|
63
|
+
encoding: US-ASCII
|
64
|
+
string: ! '{"status":"Error","detail":"Not Found","product_id":null}'
|
65
|
+
http_version:
|
66
|
+
recorded_at: Sat, 19 Jan 2013 23:15:23 GMT
|
67
|
+
recorded_with: VCR 2.4.0
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'userfox'
|
5
|
+
require "webmock/rspec"
|
6
|
+
require "vcr"
|
7
|
+
|
8
|
+
VCR.configure do |c|
|
9
|
+
c.cassette_library_dir = 'spec/fixtures/dish_cassettes'
|
10
|
+
c.hook_into :webmock
|
11
|
+
end
|
12
|
+
|
13
|
+
# Requires supporting files with custom matchers and macros, etc,
|
14
|
+
# in ./support/ and its subdirectories.
|
15
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
describe Userfox::Client do
|
4
|
+
let(:client) { Userfox::Client.new("123456", "123456") }
|
5
|
+
|
6
|
+
it "should include HTTParty" do
|
7
|
+
Userfox::Client.should include(HTTParty)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a base uri set" do
|
11
|
+
Userfox::Client.base_uri.should eql("https://api.userfox.com/v1")
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#track" do
|
15
|
+
before { VCR.insert_cassette "track", record: :new_episodes }
|
16
|
+
after { VCR.eject_cassette }
|
17
|
+
|
18
|
+
context "given good credentials" do
|
19
|
+
subject { client.track("hello@example.com", "http://www.example.com", hello: "world") }
|
20
|
+
it { should be_success }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "given bad credentials" do
|
24
|
+
let(:client) { Userfox::Client.new("abcde", "abcde") }
|
25
|
+
it { expect { client.track("hello@example.com", "http://www.example.com", hello: "world") }.to raise_error(Userfox::UnauthorizedError) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#send" do
|
30
|
+
before { VCR.insert_cassette "send", record: :new_episodes }
|
31
|
+
after { VCR.eject_cassette }
|
32
|
+
|
33
|
+
context "given good credentials" do
|
34
|
+
subject { client.send("hello@example.com", "Password Recovery", hello: "world") }
|
35
|
+
it { should be_success }
|
36
|
+
end
|
37
|
+
|
38
|
+
context "given bad credentials" do
|
39
|
+
let(:client) { Userfox::Client.new("abcde", "abcde") }
|
40
|
+
it { expect { client.send("http://www.example.com", "hello@example.com", hello: "world") }.to raise_error(Userfox::UnauthorizedError) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#change" do
|
45
|
+
before { VCR.insert_cassette "change", record: :new_episodes }
|
46
|
+
after { VCR.eject_cassette }
|
47
|
+
|
48
|
+
context "given good credentials" do
|
49
|
+
subject { client.change("hello@example.com", "user@example.com") }
|
50
|
+
it { should be_success }
|
51
|
+
end
|
52
|
+
|
53
|
+
context "given bad credentials" do
|
54
|
+
let(:client) { Userfox::Client.new("abcde", "abcde") }
|
55
|
+
it { expect { client.change("hello@example.com", "user@example.com") }.to raise_error(Userfox::UnauthorizedError) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#unsubscribes" do
|
60
|
+
before { VCR.insert_cassette "unsubscribes", record: :new_episodes }
|
61
|
+
after { VCR.eject_cassette }
|
62
|
+
|
63
|
+
context "given good credentials" do
|
64
|
+
subject { client.unsubscribes("hello@example.com") }
|
65
|
+
it { should be_success }
|
66
|
+
end
|
67
|
+
|
68
|
+
context "given bad credentials" do
|
69
|
+
let(:client) { Userfox::Client.new("abcde", "abcde") }
|
70
|
+
it { expect { client.unsubscribes("hello@example.com") }.to raise_error(Userfox::UnauthorizedError) }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/userfox.gemspec
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "userfox"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Antoine Lagadec"]
|
12
|
+
s.date = "2013-01-22"
|
13
|
+
s.description = "This gem is a Ruby Wrapper made to use the Userfox API conveniently"
|
14
|
+
s.email = "hello@oakho.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"lib/userfox.rb",
|
28
|
+
"lib/userfox/client.rb",
|
29
|
+
"lib/userfox/version.rb",
|
30
|
+
"spec/fixtures/dish_cassettes/change.yml",
|
31
|
+
"spec/fixtures/dish_cassettes/send.yml",
|
32
|
+
"spec/fixtures/dish_cassettes/track.yml",
|
33
|
+
"spec/fixtures/dish_cassettes/unsubscribes.yml",
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"spec/userfox/client_spec.rb",
|
36
|
+
"spec/userfox_spec.rb",
|
37
|
+
"userfox.gemspec"
|
38
|
+
]
|
39
|
+
s.homepage = "http://github.com/oakho/userfox"
|
40
|
+
s.licenses = ["MIT"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = "1.8.23"
|
43
|
+
s.summary = "A Ruby Wrapper for the Userfox API"
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
54
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<vcr>, [">= 0"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
59
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
60
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
63
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
64
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
65
|
+
s.add_dependency(%q<vcr>, [">= 0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
71
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
73
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
74
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
75
|
+
s.add_dependency(%q<vcr>, [">= 0"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: userfox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Antoine Lagadec
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.4
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.8.4
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: webmock
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: vcr
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: This gem is a Ruby Wrapper made to use the Userfox API conveniently
|
143
|
+
email: hello@oakho.com
|
144
|
+
executables: []
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files:
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
149
|
+
files:
|
150
|
+
- .document
|
151
|
+
- .rspec
|
152
|
+
- Gemfile
|
153
|
+
- Gemfile.lock
|
154
|
+
- LICENSE.txt
|
155
|
+
- README.md
|
156
|
+
- Rakefile
|
157
|
+
- lib/userfox.rb
|
158
|
+
- lib/userfox/client.rb
|
159
|
+
- lib/userfox/version.rb
|
160
|
+
- spec/fixtures/dish_cassettes/change.yml
|
161
|
+
- spec/fixtures/dish_cassettes/send.yml
|
162
|
+
- spec/fixtures/dish_cassettes/track.yml
|
163
|
+
- spec/fixtures/dish_cassettes/unsubscribes.yml
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/userfox/client_spec.rb
|
166
|
+
- spec/userfox_spec.rb
|
167
|
+
- userfox.gemspec
|
168
|
+
homepage: http://github.com/oakho/userfox
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
segments:
|
182
|
+
- 0
|
183
|
+
hash: 4022086353917629774
|
184
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
requirements: []
|
191
|
+
rubyforge_project:
|
192
|
+
rubygems_version: 1.8.23
|
193
|
+
signing_key:
|
194
|
+
specification_version: 3
|
195
|
+
summary: A Ruby Wrapper for the Userfox API
|
196
|
+
test_files: []
|