optimizely 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 353677dc79d930155be9437cc63a12a7ba3c391d
4
- data.tar.gz: 66b1d065a85d78a1183046c022790c30f641ecb6
3
+ metadata.gz: fa83fb3b2bb1b65e4e2150afe12519dd2d3dd9e5
4
+ data.tar.gz: 7ea18ff8e4b38015ded6a68952215df458b3624f
5
5
  SHA512:
6
- metadata.gz: ce6dc54c863482f83787581be88d357166517992dbabf9f1a2eaa5de0ba46fcab8b8945915667c68e7a3dcdccca2db70c98fa93d54a1e579fbf1e354272e7b01
7
- data.tar.gz: 5f24a35dd0a980f03ecb208cfd763d3c9b0524bbb0ea20e7c16651aa88272c3764e8d8a7055c62bd5e18fac0bc450a90c784567d900cd5a723c152596dd2522f
6
+ metadata.gz: 5c63338bb7ab215c8a6cf64b3eb2541fabe1e894d5041ae62b1165916278b5bef82514c5b1598ec99da8baa6a73e8cf102da32b67d5526182b20c93c1323cf3e
7
+ data.tar.gz: f20b8372833a57a54c0dc6f0b9510dfccd6665ad87c4da32129e058ff41638113dd02399f24dbfaaefefb68834d88c43bbef5411049ac9d8447524d5f8ab5a92
data/README.md CHANGED
@@ -2,7 +2,7 @@ Optimizely
2
2
  ===========
3
3
 
4
4
  The unofficial (basic) Ruby gem to communicate with the Optimizely Experiment API (http://developers.optimizely.com/rest/).
5
- The Experiment API lets you create and manage Optimizely projects and the experiments inside of them.
5
+ The Experiment API lets you create and manage Optimizely projects and experiments.
6
6
 
7
7
  To start using the Optimizely Experiment API you need an API Token, you can request one via: developers@optimizely.com
8
8
 
@@ -3,6 +3,8 @@ module Optimizely
3
3
 
4
4
  BASE_URL = "https://www.optimizelyapis.com/experiment/v1/"
5
5
 
6
+ attr_accessor :id, :method
7
+
6
8
  # Initialize Optimizely using an API token.
7
9
  #
8
10
  # == Options:
@@ -159,33 +161,64 @@ module Optimizely
159
161
 
160
162
  # Response code error checking
161
163
  if response.code != '200'
162
- case response.code
163
- when '400'
164
- raise OptimizelyError::BadRequest, response.body + "Your request was not sent in valid JSON. (status code: #{response.code})."
165
- when '401'
166
- raise OptimizelyError::Unauthorized, "Your API token was missing or included in the body rather than the header (status code: #{response.code})."
167
- when '403'
168
- raise OptimizelyError::Forbidden, response.body + "You provided an API token but it was invalid or revoked, or if you don't have read/ write access to the entity you're trying to view/edit (status code: #{response.code})."
169
- when '404'
170
- raise OptimizelyError::NotFound, response.body + "The id used in the request was inaccurate or you didn't have permission to view/edit it (status code: #{response.code})."
171
- else
172
- raise OptimizelyError::UnknownError, response.body + "(status code: #{response.code})."
173
- end
164
+ check_response(response.code)
174
165
  else
175
166
  parse_json(response.body)
176
167
  end
177
168
  end
178
169
 
179
170
  def post()
171
+ uri = URI.parse("#{BASE_URL}#{url}/")
172
+ https = Net::HTTP.new(uri.host, uri.port)
173
+ https.read_timeout = @options[:timeout] if @options[:timeout]
174
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
175
+ https.use_ssl = true
176
+ request = Net::HTTP::Post.new(uri.request_uri, @headers)
177
+ response = https.request(request)
180
178
 
179
+ # Response code error checking
180
+ check_response(response.code) if response.code != '201'
181
181
  end
182
182
 
183
183
  def put()
184
+ uri = URI.parse("#{BASE_URL}#{url}/")
185
+ https = Net::HTTP.new(uri.host, uri.port)
186
+ https.read_timeout = @options[:timeout] if @options[:timeout]
187
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
188
+ https.use_ssl = true
189
+ request = Net::HTTP::Put.new(uri.request_uri, @headers)
190
+ response = https.request(request)
184
191
 
192
+ # Response code error checking
193
+ check_response(response.code) if response.code != '202'
185
194
  end
186
195
 
187
196
  def delete()
197
+ uri = URI.parse("#{BASE_URL}#{url}/")
198
+ https = Net::HTTP.new(uri.host, uri.port)
199
+ https.read_timeout = @options[:timeout] if @options[:timeout]
200
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
201
+ https.use_ssl = true
202
+ request = Net::HTTP::Delete.new(uri.request_uri, @headers)
203
+ response = https.request(request)
204
+
205
+ # Response code error checking
206
+ check_response(response.code, response.body) if response.code != '203'
207
+ end
188
208
 
209
+ def check_response(code, body)
210
+ case code
211
+ when '400'
212
+ raise OptimizelyError::BadRequest, body + "Your request was not sent in valid JSON. (status code: #{code})."
213
+ when '401'
214
+ raise OptimizelyError::Unauthorized, "Your API token was missing or included in the body rather than the header (status code: #{code})."
215
+ when '403'
216
+ raise OptimizelyError::Forbidden, body + "You provided an API token but it was invalid or revoked, or if you don't have read/ write access to the entity you're trying to view/edit (status code: #{code})."
217
+ when '404'
218
+ raise OptimizelyError::NotFound, body + "The id used in the request was inaccurate or you didn't have permission to view/edit it (status code: #{code})."
219
+ else
220
+ raise OptimizelyError::UnknownError, body + "(status code: #{code})."
221
+ end
189
222
  end
190
223
 
191
224
 
@@ -1,3 +1,3 @@
1
1
  module Optimizely
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
data/optimizely.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
  s.author = "Martijn Scheijbeler"
10
10
  s.email = "martijn@marusem.com"
11
11
  s.homepage = "https://github.com/martijnsch/optimizely-gem/"
12
- s.summary = %q{The Optimizely Experiment API lets you create and manage Optimizely projects and the experiments inside of them.}
13
- s.description = %q{A Ruby gem to communicate with the Optimizely Experiments API, it lets you create and manage Optimizely projects and the experiments inside of them.}
12
+ s.summary = %q{The Optimizely Experiment API lets you create and manage Optimizely projects and experiments.}
13
+ s.description = %q{A Ruby gem to communicate with the Optimizely Experiments API, it lets you create and manage Optimizely projects and experiments.}
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optimizely
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martijn Scheijbeler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: A Ruby gem to communicate with the Optimizely Experiments API, it lets
28
- you create and manage Optimizely projects and the experiments inside of them.
28
+ you create and manage Optimizely projects and experiments.
29
29
  email: martijn@marusem.com
30
30
  executables: []
31
31
  extensions: []
@@ -67,10 +67,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 2.0.3
70
+ rubygems_version: 2.0.14
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: The Optimizely Experiment API lets you create and manage Optimizely projects
74
- and the experiments inside of them.
74
+ and experiments.
75
75
  test_files:
76
76
  - test/test_optimizely.rb