togglehq 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/README.md +6 -22
- data/lib/togglehq.rb +1 -1
- data/lib/togglehq/config.rb +2 -0
- data/lib/togglehq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec05a3d9b1ca854f13bd1eb2e240a51b59789e65
|
4
|
+
data.tar.gz: 84ffb1d582688afdcf054d9cbf68e76d4d284f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130f1635f38c1d3aeb84c343f5916b19d9f118aa002e676442d384a0776a16a2b09a2285c77ea33bea2606fafc3214b986cf717176167bde0adb502648b0ab1f
|
7
|
+
data.tar.gz: 31fbd63d206b06f1a36591fa2f05dbed5ceda9b88944a5b9f6b31b14c6787ca0c359e17477c70bbfbb819196c99eef58d0161d26776936ec3e2cf53bf09d89b3
|
data/README.md
CHANGED
@@ -29,6 +29,10 @@ Togglehq.configure do |config|
|
|
29
29
|
|
30
30
|
# To log the HTTP requests/responses to and from the ToggleHQ API, set log_requests to true (defaults to false)
|
31
31
|
config.log_requests = true
|
32
|
+
|
33
|
+
# To modify the adapter used for network connections (defaults to :net_http_persistent)
|
34
|
+
# Available: [:net_http, :net_http_persistent, :excon, :typhoeus, :patron, :em_http, :httpclient]
|
35
|
+
config.adapter = :net_http
|
32
36
|
end
|
33
37
|
```
|
34
38
|
|
@@ -66,7 +70,7 @@ preferences = Togglehq::Notify::Preferences.all
|
|
66
70
|
A `Togglehq::Notify::Preferences` object has a `categories` attribute which contains an array of all preference categories:
|
67
71
|
```ruby
|
68
72
|
preferences.categories
|
69
|
-
=> [{"name"=>"Friends", "key"=>"friends", "preferences"=>[{"name"=>"Friend Request", "key"=>"friend_request", "default"=>true}]}]
|
73
|
+
=> [{"name"=>"Friends", "key"=>"friends", "preferences"=>[{"name"=>"Friend Request", "key"=>"friend_request", "default"=>true}]}]
|
70
74
|
```
|
71
75
|
|
72
76
|
Each preference category contains a name, a key, and an array of preferences, which also have a name, key, and default value.
|
@@ -84,7 +88,7 @@ user_preferences = Togglehq::Notify::UserPreferences.new(user)
|
|
84
88
|
Get the user's preferences by calling the `categories` method:
|
85
89
|
```ruby
|
86
90
|
user_preferences.categories
|
87
|
-
=> [{"name"=>"Friends", "key"=>"friends", "preferences"=>[{"name"=>"Friend Request", "key"=>"friend_request", "default"=>true, "enabled"=>true}]}]
|
91
|
+
=> [{"name"=>"Friends", "key"=>"friends", "preferences"=>[{"name"=>"Friend Request", "key"=>"friend_request", "default"=>true, "enabled"=>true}]}]
|
88
92
|
```
|
89
93
|
|
90
94
|
Like `Togglehq::Notify::Preferences`, a `Togglehq::Notify::UserPreferences` object has a `categories` attribute which contains an array of all preference categories.
|
@@ -143,26 +147,6 @@ notification.send_global
|
|
143
147
|
This will return true upon success, and raise a RuntimeError on failure.
|
144
148
|
|
145
149
|
|
146
|
-
## Gotchas
|
147
|
-
|
148
|
-
If you encounter SSL errors while using the togglehq-gem similar to the following:
|
149
|
-
|
150
|
-
```
|
151
|
-
Faraday::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
|
152
|
-
```
|
153
|
-
|
154
|
-
ToggleHQ's SSL certificate is issued by Comodo. Comodo recently added a new certificate root, which may not be in your Ruby/OpenSSL trusted root certificates file. To find the location of your root file:
|
155
|
-
|
156
|
-
```ruby
|
157
|
-
require 'openssl'
|
158
|
-
puts OpenSSL::X509::DEFAULT_CERT_FILE
|
159
|
-
```
|
160
|
-
|
161
|
-
This will output something like `/usr/local/etc/openssl/cert.pem`. Open this file, and add the "Comodo RSA Certification Authority (SHA-2)"" root cert PEM found [here](https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/969/108/root-comodo-rsa-certification-authority-sha-2) to this file.
|
162
|
-
|
163
|
-
For more gory details, [see this excellent blog post](http://mislav.net/2013/07/ruby-openssl/) and this [StackOverflow question](http://stackoverflow.com/questions/36966650/ruby-nethttp-responds-with-opensslsslsslerror-certificate-verify-failed).
|
164
|
-
|
165
|
-
|
166
150
|
## Contributing
|
167
151
|
|
168
152
|
Bug reports and pull requests are welcome on GitHub at https://github.com/togglehq/togglehq-gem.
|
data/lib/togglehq.rb
CHANGED
@@ -33,7 +33,7 @@ module Togglehq
|
|
33
33
|
|
34
34
|
def self.connection
|
35
35
|
conn = Faraday.new(:url => config.uri) do |faraday|
|
36
|
-
faraday.adapter
|
36
|
+
faraday.adapter config.adapter
|
37
37
|
faraday.response :logger, self.logger, bodies: true if config.log_requests
|
38
38
|
end
|
39
39
|
conn
|
data/lib/togglehq/config.rb
CHANGED
@@ -4,10 +4,12 @@ module Togglehq
|
|
4
4
|
attr_accessor :client_secret
|
5
5
|
attr_accessor :uri
|
6
6
|
attr_accessor :log_requests
|
7
|
+
attr_accessor :adapter
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@uri = "https://api.togglehq.com"
|
10
11
|
@log_requests = false
|
12
|
+
@adapter = :net_http_persistent
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/togglehq/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: togglehq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toggle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|