optimizely 1.0.0 → 1.1.0

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: 56d6a8e2116a5dc47d782947d5e886d328d2a349
4
- data.tar.gz: 6b3fa8d2e138b8f185e143d32e401268860d57b4
3
+ metadata.gz: ab34ef7520c79ccfce8f1df5f5547f44cece9866
4
+ data.tar.gz: 6fa648252e54eb29fdbe58fda3cbfef64d8e3d65
5
5
  SHA512:
6
- metadata.gz: bd5bc338f82f455fb43130946e63bd11cde39bc641a4e6ee605111776d48f64c7ccbc462dda84ada75c27f87632a0efd913eb24189c8a4285ece8c5a2f5ea588
7
- data.tar.gz: 17ef6944f4da2efdb93465f27879591824457852b70d2fbec2577b0c1839a90513d342828f98616070f1a0ef2df3972d38ce45649475488057fe6c80d62a8094
6
+ metadata.gz: b48ab34f7bdc479b9d2ea5105dc3d29a92da7b1ec2def893c44e68ff563941c2b86c9ca3be2ad1b451de55e07580bc320a4b7069c51abfaf65f016b2dabf811b
7
+ data.tar.gz: b5a027217a0bd5ea375b18e229a460ced92443d23d590de10192ec66f433f93e52f2f3e55adbff89c4454f3bdbd629474fe24b320df0564b12383f124d7a8866
data/README.md CHANGED
@@ -29,27 +29,43 @@ Don't forget to bundle install:
29
29
  Retrieve all projects:
30
30
  projects = optimizely.projects
31
31
 
32
+ Retrieve a specific project:
33
+ project = optimizely.project(12345)
34
+
32
35
  ## Experiments
33
36
 
34
37
  Retrieve all experiments for a project:
35
38
  experiments = optimizely.experiments(12345)
36
39
 
40
+ Retrieve a specific experiment:
41
+ experiment = optimizely.experiment(12345)
42
+
37
43
  ## Variations
38
44
 
39
45
  Retrieve all variations for an experiment:
40
46
  variations = optimizely.variations(12345)
41
47
 
48
+ Retrieve a specific variation:
49
+ variation = optimizely.variation(12345)
50
+
42
51
  ## Audiences
43
52
 
44
53
  Retrieve all audiences for an project:
45
54
  audiences = optimizely.audiences(12345)
46
55
 
56
+ Retrieve a specific audience:
57
+ audience = optimizely.audience(12345)
58
+
47
59
  # Information
48
60
 
49
61
  ### Changelog
50
62
 
63
+ #### 1.1
64
+ * Fix some typos in the errors for having no variable in a function and added extra documentation.
65
+ * Add support for reading specific projects, experiments, variations and audiences.
66
+
51
67
  #### 1.0
52
- * Add all basic features for the Optimizely Experiment API.
68
+ * Add all basic features for the Optimizely Experiment API for listing projects, experiments, variations and audiences.
53
69
 
54
70
  ### Bug reports
55
71
 
@@ -32,6 +32,18 @@ module Optimizely
32
32
  @projects
33
33
  end
34
34
 
35
+ # Returns the details for a specific project.
36
+ #
37
+ # == Usage
38
+ # optimizely = Optimizely.new({ api_token: 'oauth2_token' })
39
+ # project = optimizely.project(12345) # Look up the project.
40
+ #
41
+ def project(id)
42
+ raise OptimizelyError::NoProjectID, "A Project ID is required to retrieve the project." if id.nil?
43
+ @project = self.get("projects/#{id}")
44
+ @project
45
+ end
46
+
35
47
  # Returns the list of experiments for a specified project.
36
48
  #
37
49
  # == Usage
@@ -39,11 +51,23 @@ module Optimizely
39
51
  # experiments = optimizely.experiments(12345) # Look up all experiments for a project.
40
52
  #
41
53
  def experiments(project_id)
42
- raise OptimizelyError::NoProjectID, "A Project ID required to retrieve experiments." if project_id.nil?
54
+ raise OptimizelyError::NoProjectID, "A Project ID is required to retrieve experiments." if project_id.nil?
43
55
  @experiments = self.get("projects/#{project_id}/experiments") if @experiments.nil?
44
56
  @experiments
45
57
  end
46
58
 
59
+ # Returns the details for a specific experiment.
60
+ #
61
+ # == Usage
62
+ # optimizely = Optimizely.new({ api_token: 'oauth2_token' })
63
+ # experiment = optimizely.experiment(12345) # Look up the experiment.
64
+ #
65
+ def experiment(id)
66
+ raise OptimizelyError::NoExperimentID, "An Experiment ID is required to retrieve the experiment." if id.nil?
67
+ @experiment = self.get("experiments/#{id}")
68
+ @experiment
69
+ end
70
+
47
71
  # Returns the list of variations for a specified experiment.
48
72
  #
49
73
  # == Usage
@@ -51,11 +75,23 @@ module Optimizely
51
75
  # variations = optimizely.variations(12345) # Look up all variations for an experiment.
52
76
  #
53
77
  def variations(experiment_id)
54
- raise OptimizelyError::NoExperimentID, "An Experiment ID required to retrieve variations." if experiment_id.nil?
78
+ raise OptimizelyError::NoExperimentID, "An Experiment ID is required to retrieve variations." if experiment_id.nil?
55
79
  @variations = self.get("projects/#{experiment_id}/variations") if @variations.nil?
56
80
  @experiments
57
81
  end
58
82
 
83
+ # Returns the details for a specific variation.
84
+ #
85
+ # == Usage
86
+ # optimizely = Optimizely.new({ api_token: 'oauth2_token' })
87
+ # variation = optimizely.variation(12345) # Look up the variation.
88
+ #
89
+ def variation(id)
90
+ raise OptimizelyError::NoVariationID, "A Variation ID is required to retrieve the variation." if id.nil?
91
+ @variation = self.get("variations/#{id}")
92
+ @variation
93
+ end
94
+
59
95
  # Returns the list of audiences for a specified project.
60
96
  #
61
97
  # == Usage
@@ -63,11 +99,24 @@ module Optimizely
63
99
  # audiences = optimizely.audiences(12345) # Look up all audiences for a project.
64
100
  #
65
101
  def audiences(project_id)
66
- raise OptimizelyError::NoProjectID, "A Project ID required to retrieve audiences." if project_id.nil?
102
+ raise OptimizelyError::NoProjectID, "A Project ID is required to retrieve audiences." if project_id.nil?
67
103
  @audiences = self.get("projects/#{project_id}/audiences") if @audiences.nil?
68
104
  @audiences
69
105
  end
70
106
 
107
+ # Returns the details for a specific audience.
108
+ #
109
+ # == Usage
110
+ # optimizely = Optimizely.new({ api_token: 'oauth2_token' })
111
+ # audience = optimizely.audience(12345) # Look up the audience.
112
+ #
113
+ def audience(id)
114
+ raise OptimizelyError::NoAudienceID, "An Audience ID is required to retrieve the audience." if id.nil?
115
+ @audience = self.get("audiences/#{id}")
116
+ @audience
117
+ end
118
+
119
+ # Return the parsed JSON data for a request that is done to the Optimizely REST API.
71
120
  def get(url)
72
121
  uri = URI.parse("#{BASE_URL}#{url}/")
73
122
  https = Net::HTTP.new(uri.host, uri.port)
@@ -12,4 +12,6 @@ module OptimizelyError
12
12
  # Request Error
13
13
  class NoProjectID < StandardError; end;
14
14
  class NoExperimentID < StandardError; end;
15
+ class NoVariationID < StandardError; end;
16
+ class NoAudienceID < StandardError; end;
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module Optimizely
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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.0.0
4
+ version: 1.1.0
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-04-30 00:00:00.000000000 Z
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby gem to communicate with the Optimizely Experiments API, it lets
14
14
  you create and manage Optimizely projects and the experiments inside of them.