horntell 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +39 -14
- data/lib/horntell/errors/authentication_error.rb +3 -1
- data/lib/horntell/errors/error.rb +10 -8
- data/lib/horntell/errors/forbidden_error.rb +3 -1
- data/lib/horntell/errors/invalid_request_error.rb +3 -1
- data/lib/horntell/errors/network_error.rb +9 -7
- data/lib/horntell/errors/not_found_error.rb +3 -1
- data/lib/horntell/errors/service_error.rb +3 -1
- data/lib/horntell/http/client.rb +8 -8
- data/lib/horntell/version.rb +1 -1
- data/lib/horntell.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e59ea212c8612cec68559998a305e0375c8c848
|
|
4
|
+
data.tar.gz: b0bb08528724e12dfca9cba50fb47f7b17da7f44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d37ad03a32b0834f2e2b656aad8ebc240f87028b900f03e0d5ef577050e1687bd035474314c9e1d7a5b058a1bc6d6478d6207380ac1f4151e50b5e24313717e8
|
|
7
|
+
data.tar.gz: f3e95161101a37b77fba2c83f7b33fa51b81d77a12c36128ec3f045ffc66a4d7bc47b34f60e97559cba24bb321ab31535ee8083c86facf752ef0d7fbb2ef227a
|
data/README.md
CHANGED
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
Horntell SDK for Ruby
|
|
2
|
+
====================
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
This SDK allows you to easily integrate Horntell in your Ruby applications.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
**Ruby 1.9.2 and later.**
|
|
8
|
+
|
|
9
|
+
**Gems: rest-client, json**
|
|
4
10
|
|
|
5
11
|
## Installation
|
|
12
|
+
You don't need this source code unless you want to modify the gem. If you just want to use the Horntell Ruby SDK, you should run:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
gem install horntell
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
If you want to build the gem from source, run this:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
gem build horntell.gemspec
|
|
22
|
+
```
|
|
6
23
|
|
|
7
|
-
|
|
24
|
+
## Bundler
|
|
25
|
+
If you are installing via bundler, you should be sure to use the https rubygems source in your Gemfile, as any gems fetched over http could potentially be compromised in transit and alter the code of gems fetched securely over https:
|
|
8
26
|
|
|
9
27
|
```ruby
|
|
28
|
+
source 'https://rubygems.org'
|
|
29
|
+
|
|
10
30
|
gem 'horntell'
|
|
11
31
|
```
|
|
12
32
|
|
|
13
33
|
And then execute:
|
|
14
34
|
|
|
15
|
-
|
|
35
|
+
```
|
|
36
|
+
bundle install
|
|
37
|
+
```
|
|
16
38
|
|
|
17
|
-
|
|
39
|
+
## Getting Started
|
|
18
40
|
|
|
19
|
-
|
|
41
|
+
You need to `init`ialize the SDK with the app's key and secret, which you can find in your account at [http://app.horntell.com](http://app.horntell.com). Sample usage looks like this.
|
|
20
42
|
|
|
21
|
-
|
|
43
|
+
```ruby
|
|
44
|
+
Horntell::init('YOUR_APP_KEY', 'YOUR_APP_SECRET');
|
|
45
|
+
Horntell::Profile.create({
|
|
46
|
+
:uid => "1337",
|
|
47
|
+
:first_name => "John",
|
|
48
|
+
:last_name => "Doe",
|
|
49
|
+
:signedup_at => 1383350400
|
|
50
|
+
})
|
|
22
51
|
|
|
23
|
-
|
|
52
|
+
```
|
|
24
53
|
|
|
25
|
-
##
|
|
54
|
+
## Documentation
|
|
26
55
|
|
|
27
|
-
|
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
31
|
-
5. Create a new Pull Request
|
|
56
|
+
Please see [http://docs.horntell.com/api](http://docs.horntell.com/api/?ruby) for up-to-date documentation.
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
module Horntell
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
module Errors
|
|
3
|
+
class Error < StandardError
|
|
4
|
+
attr_reader :message
|
|
5
|
+
attr_reader :code
|
|
6
|
+
attr_reader :type
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
def initialize(message = nil, code = nil, type = nil)
|
|
9
|
+
@message = message
|
|
10
|
+
@code = code
|
|
11
|
+
@type = type
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
module Horntell
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
module Errors
|
|
3
|
+
class NetworkError < Error
|
|
4
|
+
attr_accessor :message
|
|
5
|
+
attr_accessor :type
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
def initialize(message = nil, code = nil, type = nil)
|
|
8
|
+
super(message, code, type)
|
|
9
|
+
@message = "Could not connect to Horntell. Please check your network connection and try again. If the problem persists, please get in touch with us at hello@horntell.com."
|
|
10
|
+
@type = 'network_error'
|
|
11
|
+
end
|
|
10
12
|
end
|
|
11
13
|
end
|
|
12
14
|
end
|
data/lib/horntell/http/client.rb
CHANGED
|
@@ -21,10 +21,10 @@ module Horntell
|
|
|
21
21
|
if code = e.http_code and body = e.http_body
|
|
22
22
|
return handle_api_error(code, body)
|
|
23
23
|
else
|
|
24
|
-
raise Horntell::NetworkError.new
|
|
24
|
+
raise Horntell::Errors::NetworkError.new
|
|
25
25
|
end
|
|
26
26
|
rescue Exception => e
|
|
27
|
-
raise Horntell::NetworkError.new
|
|
27
|
+
raise Horntell::Errors::NetworkError.new
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -49,27 +49,27 @@ module Horntell
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def authentication_error(error, code)
|
|
52
|
-
AuthenticationError.new(error["message"], code, error["type"])
|
|
52
|
+
Horntell::Errors::AuthenticationError.new(error["message"], code, error["type"])
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def forbidden_error(error, code)
|
|
56
|
-
ForbiddenError.new(error["message"], code, error["type"])
|
|
56
|
+
Horntell::Errors::ForbiddenError.new(error["message"], code, error["type"])
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def horntell_error(error, code)
|
|
60
|
-
HorntellError.new(error["message"], code, error["type"])
|
|
60
|
+
Horntell::Errors::HorntellError.new(error["message"], code, error["type"])
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def invalid_request_error(error, code)
|
|
64
|
-
InvalidRequestError.new(error["message"], code, error["type"])
|
|
64
|
+
Horntell::Errors::InvalidRequestError.new(error["message"], code, error["type"])
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def not_found_error(error, code)
|
|
68
|
-
NotFoundError.new(error["message"], code, error["type"])
|
|
68
|
+
Horntell::Errors::NotFoundError.new(error["message"], code, error["type"])
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def service_error(error, code)
|
|
72
|
-
ServiceError.new(error["message"], code, error["type"])
|
|
72
|
+
Horntell::Errors::ServiceError.new(error["message"], code, error["type"])
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
data/lib/horntell/version.rb
CHANGED
data/lib/horntell.rb
CHANGED