delighted 1.4.0.rc2 → 1.5.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: 0fa8281430a51548a8010a39f65cdafcdb70019e
4
- data.tar.gz: c6c74bef892f5e83bfdb3019fe561480d51363d5
3
+ metadata.gz: a61c272d2e9b5614ae8b289ac046686b89a537dc
4
+ data.tar.gz: b4511534ddea1075ff4e82892044eae1d39b6f45
5
5
  SHA512:
6
- metadata.gz: b3650ee32960f335aa669eec0187dd96d800fba8a95e598cc96bac63247b9892c49a4de59823e592e172589b62d2d8a7d67ab44d2adfa1eaefcba3f9469b3e03
7
- data.tar.gz: 0d78aa7a4f04ffd4ac9a7b23d79150466999e6b056027de9ba24cb9794ca8fc9fc51ffdc5f0b7363c27fbd41485ccbc37cd1cd72928f3c6bef302ddf0c2c05fb
6
+ metadata.gz: 2da76b95cfa9f4e3f0afb9516683b7d2d0ecd8036e92a8acab663f09d9cf1f1578e1095840919273b16945a8b9ae6088a019a742039548fcddabafa6517c5462
7
+ data.tar.gz: eff243c3c5b21dc77fe6985bd4aef5dff12a24f9796343a17ac000e71740b047cb2438c65ca60f5517b6db5bb69ede087d865523ef398aaf5326bfefa34b49ec
@@ -5,6 +5,12 @@ Features:
5
5
  - Add support for retrieving a SurveyResponse
6
6
  - Add support for updating a SurveyResponse
7
7
 
8
+ ## 1.3.1 (2015-09-14)
9
+
10
+ Features:
11
+
12
+ - Fix authentication header on 1.8.7
13
+
8
14
  ## 1.3.0 (2014-06-03)
9
15
 
10
16
  Features:
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Delighted Inc.
1
+ Copyright (c) 2013–2015 Delighted Inc.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,12 +1,185 @@
1
- # Delighted API client for Ruby [![Build Status](https://travis-ci.org/delighted/delighted-ruby.png)](https://travis-ci.org/delighted/delighted-ruby)
1
+ [![Build Status](https://img.shields.io/travis/delighted/delighted-ruby.svg)](https://travis-ci.org/delighted/delighted-ruby)
2
2
 
3
- Official Ruby client for the [Delighted](https://delightedapp.com) API.
3
+ # Delighted API Ruby Client
4
4
 
5
- For basic installation and usage instructions, please [sign in to your Delighted account](https://delightedapp.com/signin) and follow the API documentation under Settings.
5
+ Official Ruby client for the [Delighted API](https://delighted.com/docs/api).
6
6
 
7
- For more detailed examples, please see [USAGE.md](https://github.com/delighted/delighted-ruby/blob/master/USAGE.md).
7
+ ## Installation
8
8
 
9
- ## Supported Rubies
9
+ Add `gem 'delighted'` to your application's Gemfile, and then run `bundle` to install.
10
+
11
+ ## Configuration
12
+
13
+ To get started, you need to configure the client with your secret API key. If you're using Rails, you should add the following to new initializer file in `config/initializers/delighted.rb`.
14
+
15
+ ```ruby
16
+ require 'delighted'
17
+ Delighted.api_key = 'YOUR_API_KEY'
18
+ ```
19
+
20
+ For further options, read the [advanced configuration section](#advanced-configuration).
21
+
22
+ **Note:** Your API key is secret, and you should treat it like a password. You can find your API key in your Delighted account, under *Settings* > *API*.
23
+
24
+ ## Usage
25
+
26
+ Adding/updating people and scheduling surveys:
27
+
28
+ ```ruby
29
+ # Add a new person, and schedule a survey immediately
30
+ person1 = Delighted::Person.create(:email => "foo+test1@delighted.com")
31
+
32
+ # Add a new person, and schedule a survey after 1 minute (60 seconds)
33
+ person2 = Delighted::Person.create(:email => "foo+test2@delighted.com",
34
+ :delay => 60)
35
+
36
+ # Add a new person, but do not schedule a survey
37
+ person3 = Delighted::Person.create(:email => "foo+test3@delighted.com",
38
+ :send => false)
39
+
40
+ # Add a new person with full set of attributes, including a custom question
41
+ # product name, and schedule a survey with a 30 second delay
42
+ person4 = Delighted::Person.create(:email => "foo+test4@delighted.com",
43
+ :name => "Joe Bloggs", :properties => { :customer_id => 123, :country => "USA",
44
+ :question_product_name => "The London Trench" }, :delay => 30)
45
+
46
+ # Update an existing person (identified by email), adding a name, without
47
+ # scheduling a survey
48
+ updated_person1 = Delighted::Person.create(:email => "foo+test1@delighted.com",
49
+ :name => "James Scott", :send => false)
50
+ ```
51
+
52
+ Unsubscribing people:
53
+
54
+ ```ruby
55
+ # Unsubscribe an existing person
56
+ Delighted::Unsubscribe.create(:person_email => "foo+test1@delighted.com")
57
+ ```
58
+
59
+ Listing people who have unsubscribed:
60
+
61
+ ```ruby
62
+ # List all people who have unsubscribed, 20 per page, first 2 pages
63
+ survey_responses_page1 = Delighted::Unsubscribe.all
64
+ survey_responses_page2 = Delighted::Unsubscribe.all(:page => 2)
65
+ ```
66
+
67
+ Listing people whose emails have bounced:
68
+
69
+ ```ruby
70
+ # List all people whose emails have bounced, 20 per page, first 2 pages
71
+ survey_responses_page1 = Delighted::Bounce.all
72
+ survey_responses_page2 = Delighted::Bounce.all(:page => 2)
73
+ ```
74
+
75
+ Deleting pending survey requests
76
+
77
+ ```ruby
78
+ # Delete all pending (scheduled but unsent) survey requests for a person, by email.
79
+ Delighted::SurveyRequest.delete_pending(:person_email => "foo+test1@delighted.com")
80
+ ```
81
+
82
+ Adding survey responses:
83
+
84
+ ```ruby
85
+ # Add a survey response, score only
86
+ survey_response1 = Delighted::SurveyResponse.create(:person => person1.id,
87
+ :score => 10)
88
+
89
+ # Add *another* survey response (for the same person), score and comment
90
+ survey_response2 = Delighted::SurveyResponse.create(:person => person1.id,
91
+ :score => 5, :comment => "Really nice.")
92
+ ```
93
+
94
+ Retrieving a survey response:
95
+
96
+ ```ruby
97
+ # Retrieve an existing survey response
98
+ survey_response3 = Delighted::SurveyResponse.retrieve('123')
99
+ ```
100
+
101
+ Updating survey responses:
102
+
103
+ ```ruby
104
+ # Update a survey response score
105
+ survey_response4 = Delighted::SurveyResponse.retrieve('234')
106
+ survey_response4.score = 10
107
+ survey_response4.save #=> #<Delighted::SurveyResponse:...>
108
+
109
+ # Update (or add) survey response properties
110
+ survey_response4.person_properties = { :segment => "Online" }
111
+ survey_response4.save #=> #<Delighted::SurveyResponse:...>
112
+
113
+ # Update person who recorded the survey response
114
+ survey_response4.person = '321'
115
+ survey_response4.save #=> #<Delighted::SurveyResponse:...>
116
+ ```
117
+
118
+ Listing survey responses:
119
+
120
+ ```ruby
121
+ # List all survey responses, 20 per page, first 2 pages
122
+ survey_responses_page1 = Delighted::SurveyResponse.all
123
+ survey_responses_page2 = Delighted::SurveyResponse.all(:page => 2)
124
+
125
+ # List all survey responses, 20 per page, expanding person object
126
+ survey_responses_page1_expanded = Delighted::SurveyResponse.all(:expand => ['person'])
127
+ survey_responses_page1_expanded[0].person #=> #<Delighted::Person:...>
128
+
129
+ # List all survey responses, 20 per page, for a specific trend (ID: 123)
130
+ survey_responses_page1_trend = Delighted::SurveyResponse.all(:trend => "123")
131
+
132
+ # List all survey responses, 20 per page, in reverse chronological order (newest first)
133
+ survey_responses_page1_desc = Delighted::SurveyResponse.all(:order => 'desc')
134
+
135
+ # List all survey responses, 100 per page, page 5, with a time range
136
+ filtered_survey_responses = Delighted::SurveyResponse.all(:page => 5,
137
+ :per_page => 100, :since => Time.utc(2013, 10, 01),
138
+ :until => Time.utc(2013, 11, 01))
139
+ ```
140
+
141
+ Retrieving metrics:
142
+
143
+ ```ruby
144
+ # Get current metrics, 30-day simple moving average, from most recent response
145
+ metrics = Delighted::Metrics.retrieve
146
+
147
+ # Get current metrics, 30-day simple moving average, from most recent response,
148
+ # for a specific trend (ID: 123)
149
+ metrics = Delighted::Metrics.retrieve(:trend => "123")
150
+
151
+ # Get metrics, for given range
152
+ metrics = Delighted::Metrics.retrieve(:since => Time.utc(2013, 10, 01),
153
+ :until => Time.utc(2013, 11, 01))
154
+ ```
155
+
156
+ ## <a name="advanced-configuration"></a> Advanced configuration & testing
157
+
158
+ The following options are configurable for the client:
159
+
160
+ ```ruby
161
+ Delighted.api_key
162
+ Delighted.api_base_url # default: 'https://api.delighted.com/v1'
163
+ Delighted.http_adapter # default: Delighted::HTTPAdapter.new
164
+ ```
165
+
166
+ By default, a shared instance of `Delighted::Client` is created lazily in `Delighted.shared_client`. If you want to create your own client, perhaps for test or if you have multiple API keys, you can:
167
+
168
+ ```ruby
169
+ # Create an custom client instance, and pass as last argument to resource actions
170
+ client = Delighted::Client.new(:api_key => 'API_KEY',
171
+ :api_base_url => 'https://api.delighted.com/v1',
172
+ :http_adapter => Delighted::HTTPAdapter.new)
173
+ metrics_from_custom_client = Delighted::Metrics.retrieve({}, client)
174
+
175
+ # Or, you can set Delighted.shared_client yourself
176
+ Delighted.shared_client = Delighted::Client.new(:api_key => 'API_KEY',
177
+ :api_base_url => 'https://api.delighted.com/v1',
178
+ :http_adapter => Delighted::HTTPAdapter.new)
179
+ metrics_from_custom_shared_client = Delighted::Metrics.retrieve
180
+ ```
181
+
182
+ ## Supported runtimes
10
183
 
11
184
  - Ruby MRI (1.8.7+)
12
185
  - JRuby (1.8 + 1.9 modes)
@@ -17,6 +190,7 @@ For more detailed examples, please see [USAGE.md](https://github.com/delighted/d
17
190
 
18
191
  1. Fork it
19
192
  2. Create your feature branch (`git checkout -b my-new-feature`)
20
- 3. Commit your changes (`git commit -am 'Add some feature'`)
21
- 4. Push to the branch (`git push origin my-new-feature`)
22
- 5. Create new Pull Request
193
+ 3. Run the tests (`rake test`)
194
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
195
+ 5. Push to the branch (`git push origin my-new-feature`)
196
+ 6. Create new Pull Request
@@ -6,9 +6,9 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "delighted"
7
7
  spec.version = Delighted::VERSION
8
8
  spec.authors = ["Mark Dodwell"]
9
- spec.email = ["mark@madeofcode.com"]
10
- spec.description = "Delighted API client for Ruby."
11
- spec.summary = "Delighted is the easiest and most beautiful way to measure customer happiness. Are your customers delighted?"
9
+ spec.email = ["mark@delighted.com"]
10
+ spec.description = "Delighted API Ruby Client."
11
+ spec.summary = "Delighted is the fastest and easiest way to gather actionable feedback from your customers."
12
12
  spec.homepage = "https://github.com/delighted/delighted-ruby"
13
13
  spec.license = "MIT"
14
14
 
@@ -16,6 +16,7 @@ require 'delighted/operations/create'
16
16
  require 'delighted/operations/retrieve'
17
17
  require 'delighted/operations/update'
18
18
 
19
+ require 'delighted/resources/bounce'
19
20
  require 'delighted/resources/metrics'
20
21
  require 'delighted/resources/person'
21
22
  require 'delighted/resources/survey_request'
@@ -70,7 +70,7 @@ module Delighted
70
70
 
71
71
  def default_headers
72
72
  @default_headers ||= {
73
- 'Authorization' => "Basic #{["#{@api_key}:"].pack('m0')}",
73
+ 'Authorization' => "Basic #{["#{@api_key}:"].pack('m').chomp}",
74
74
  'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}"
75
75
  }.freeze
76
76
  end
@@ -0,0 +1,7 @@
1
+ module Delighted
2
+ class Bounce < Resource
3
+ self.path = '/bounces'
4
+
5
+ include Operations::All
6
+ end
7
+ end
@@ -2,6 +2,7 @@ module Delighted
2
2
  class Unsubscribe < Resource
3
3
  self.path = '/unsubscribes'
4
4
 
5
+ include Operations::All
5
6
  include Operations::Create
6
7
  end
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module Delighted
2
- VERSION = "1.4.0.rc2"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -10,7 +10,7 @@ end
10
10
  class Delighted::MetricsTest < Delighted::TestCase
11
11
  def test_retrieving_metrics
12
12
  uri = URI.parse("https://api.delightedapp.com/v1/metrics")
13
- headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
13
+ headers = { 'Authorization' => @auth_header, "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
14
14
  response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump({ :nps => 10 }))
15
15
  mock_http_adapter.expects(:request).with(:get, uri, headers).once.returns(response)
16
16
 
@@ -25,7 +25,7 @@ end
25
25
  class Delighted::PeopleTest < Delighted::TestCase
26
26
  def test_creating_or_updating_a_person
27
27
  uri = URI.parse("https://api.delightedapp.com/v1/people")
28
- headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'Content-Type' => 'application/json', 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
28
+ headers = { 'Authorization' => @auth_header, "Accept" => "application/json", 'Content-Type' => 'application/json', 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
29
29
  data = Delighted::JSON.dump({ :email => 'foo@bar.com' })
30
30
  response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump({ :id => '123', :email => 'foo@bar.com' }))
31
31
  mock_http_adapter.expects(:request).with(:post, uri, headers, data).once.returns(response)
@@ -41,7 +41,7 @@ class Delighted::PeopleTest < Delighted::TestCase
41
41
  person_email = 'person@example.com'
42
42
  uri = URI.parse('https://api.delightedapp.com/v1/unsubscribes')
43
43
  headers = {
44
- 'Authorization' => "Basic #{["123abc:"].pack('m0')}",
44
+ 'Authorization' => @auth_header,
45
45
  'Accept' => 'application/json',
46
46
  'Content-Type' => 'application/json',
47
47
  'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}"
@@ -57,7 +57,7 @@ class Delighted::PeopleTest < Delighted::TestCase
57
57
 
58
58
  def test_deleting_pending_survey_requests_for_a_person
59
59
  uri = URI.parse("https://api.delightedapp.com/v1/people/foo%40bar.com/survey_requests/pending")
60
- headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'Content-Type' => 'application/json', 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
60
+ headers = { 'Authorization' => @auth_header, "Accept" => "application/json", 'Content-Type' => 'application/json', 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
61
61
  response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump({ :ok => true }))
62
62
  mock_http_adapter.expects(:request).with(:delete, uri, headers, nil).once.returns(response)
63
63
 
@@ -70,7 +70,7 @@ end
70
70
  class Delighted::SurveyResponseTest < Delighted::TestCase
71
71
  def test_creating_a_survey_response
72
72
  uri = URI.parse("https://api.delightedapp.com/v1/survey_responses")
73
- headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'Content-Type' => 'application/json', 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
73
+ headers = { 'Authorization' => @auth_header, "Accept" => "application/json", 'Content-Type' => 'application/json', 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
74
74
  data = Delighted::JSON.dump({ :person => '123', :score => 10 })
75
75
  response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump({ :id => '456', :person => '123', :score => 10 }))
76
76
  mock_http_adapter.expects(:request).with(:post, uri, headers, data).once.returns(response)
@@ -132,7 +132,7 @@ class Delighted::SurveyResponseTest < Delighted::TestCase
132
132
 
133
133
  def test_listing_all_survey_responses
134
134
  uri = URI.parse("https://api.delightedapp.com/v1/survey_responses?order=desc")
135
- headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
135
+ headers = { 'Authorization' => @auth_header, "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
136
136
  response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump([{ :id => '123', :comment => 'One' }, { :id => '456', :comment => 'Two' }]))
137
137
  mock_http_adapter.expects(:request).with(:get, uri, headers).once.returns(response)
138
138
 
@@ -150,7 +150,7 @@ class Delighted::SurveyResponseTest < Delighted::TestCase
150
150
 
151
151
  def test_listing_all_survey_responses_expand_person
152
152
  uri = URI.parse("https://api.delightedapp.com/v1/survey_responses?expand%5B%5D=person")
153
- headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
153
+ headers = { 'Authorization' => @auth_header, "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
154
154
  response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump([{ :id => '123', :comment => 'One', :person => { :id => '123', :email => 'foo@bar.com' } }, { :id => '456', :comment => 'Two', :person => { :id => '123', :email => 'foo@bar.com' } }]))
155
155
  mock_http_adapter.expects(:request).with(:get, uri, headers).once.returns(response)
156
156
 
@@ -170,3 +170,39 @@ class Delighted::SurveyResponseTest < Delighted::TestCase
170
170
  assert_equal({ :email => 'foo@bar.com' }, survey_responses[1].person.to_hash)
171
171
  end
172
172
  end
173
+
174
+ class Delighted::UnsubscribesTest < Delighted::TestCase
175
+ def test_listing_unsubscribes
176
+ uri = URI.parse("https://api.delightedapp.com/v1/unsubscribes")
177
+ headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
178
+ example_unsub = {:person_id => '4945', :email => 'foo@example.com', :name => nil, :unsubscribed_at => 1440621400}
179
+ response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump([example_unsub]))
180
+ mock_http_adapter.expects(:request).with(:get, uri, headers).once.returns(response)
181
+
182
+ unsubscribes = Delighted::Unsubscribe.all
183
+ assert_equal 1, unsubscribes.size
184
+ first_unsub = unsubscribes.first
185
+ assert_kind_of Delighted::Unsubscribe, first_unsub
186
+ assert_equal '4945', first_unsub.person_id
187
+ assert_equal example_unsub, first_unsub.to_hash
188
+ end
189
+ end
190
+
191
+
192
+ class Delighted::BouncesTest < Delighted::TestCase
193
+ def test_listing_bounces
194
+ uri = URI.parse("https://api.delightedapp.com/v1/bounces")
195
+ headers = { 'Authorization' => "Basic #{["123abc:"].pack('m0')}", "Accept" => "application/json", 'User-Agent' => "Delighted RubyGem #{Delighted::VERSION}" }
196
+ example_bounce = {:person_id => '4945', :email => 'foo@example.com', :name => nil, :bounced_at => 1440621400}
197
+ response = Delighted::HTTPResponse.new(200, {}, Delighted::JSON.dump([example_bounce]))
198
+ mock_http_adapter.expects(:request).with(:get, uri, headers).once.returns(response)
199
+
200
+ bounces = Delighted::Bounce.all
201
+ assert_equal 1, bounces.size
202
+ first_bounce = bounces.first
203
+ assert_kind_of Delighted::Bounce, first_bounce
204
+ assert_equal '4945', first_bounce.person_id
205
+ assert_equal example_bounce, first_bounce.to_hash
206
+ end
207
+ end
208
+
@@ -8,6 +8,7 @@ class Delighted::TestCase < Minitest::Test
8
8
  def setup
9
9
  super
10
10
  Delighted.shared_client = Delighted::Client.new(:api_key => '123abc', :http_adapter => mock_http_adapter)
11
+ @auth_header = "Basic #{["123abc:"].pack('m').chomp}"
11
12
  end
12
13
 
13
14
  def mock_http_adapter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delighted
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.rc2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Dodwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-19 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -66,9 +66,9 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Delighted API client for Ruby.
69
+ description: Delighted API Ruby Client.
70
70
  email:
71
- - mark@madeofcode.com
71
+ - mark@delighted.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -80,7 +80,6 @@ files:
80
80
  - LICENSE
81
81
  - README.md
82
82
  - Rakefile
83
- - USAGE.md
84
83
  - delighted.gemspec
85
84
  - lib/delighted.rb
86
85
  - lib/delighted/client.rb
@@ -94,6 +93,7 @@ files:
94
93
  - lib/delighted/operations/retrieve.rb
95
94
  - lib/delighted/operations/update.rb
96
95
  - lib/delighted/resource.rb
96
+ - lib/delighted/resources/bounce.rb
97
97
  - lib/delighted/resources/metrics.rb
98
98
  - lib/delighted/resources/person.rb
99
99
  - lib/delighted/resources/survey_request.rb
@@ -118,16 +118,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>'
121
+ - - '>='
122
122
  - !ruby/object:Gem::Version
123
- version: 1.3.1
123
+ version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.4.8
127
127
  signing_key:
128
128
  specification_version: 4
129
- summary: Delighted is the easiest and most beautiful way to measure customer happiness.
130
- Are your customers delighted?
129
+ summary: Delighted is the fastest and easiest way to gather actionable feedback from
130
+ your customers.
131
131
  test_files:
132
132
  - test/delighted_test.rb
133
133
  - test/test_helper.rb
data/USAGE.md DELETED
@@ -1,150 +0,0 @@
1
- ## Installation
2
-
3
- Add `gem 'delighted'` to your application's Gemfile, and then run `bundle` to install.
4
-
5
- ## Configuration
6
-
7
- To get started, you need to configure the client with your secret API key. If you're using Rails, you should add the following to new initializer file in `config/initializers/delighted.rb`.
8
-
9
- ```ruby
10
- require 'delighted'
11
- Delighted.api_key = 'YOUR_API_KEY'
12
- ```
13
-
14
- For further options, read the [advanced configuration section](#advanced-configuration).
15
-
16
- **Note:** Your API key is secret, and you should treat it like a password. You can find your API key in your Delighted account, under *Settings* > *API*.
17
-
18
- ## Usage
19
-
20
- ### Adding/updating people and scheduling surveys
21
-
22
- ```ruby
23
- # Add a new person, and schedule a survey immediately
24
- person1 = Delighted::Person.create(:email => "foo+testing1@delightedapp.com")
25
-
26
- # Add a new person, and schedule a survey after 1 minute (60 seconds)
27
- person2 = Delighted::Person.create(:email => "foo+testing2@delightedapp.com", :delay => 60)
28
-
29
- # Add a new person, but do not schedule a survey
30
- person3 = Delighted::Person.create(:email => "foo+testing3@delightedapp.com", :send => false)
31
-
32
- # Add a new person with full set of attributes, including a custom question product name,
33
- # and schedule a survey with a 30 second delay
34
- person4 = Delighted::Person.create(:email => "foo+testing4@delightedapp.com", :name => "Joe Bloggs",
35
- :properties => { :customer_id => 123, :country => "USA", :question_product_name => "Apple Genius Bar" },
36
- :delay => 30)
37
-
38
- # Update an existing person (identified by email), adding a name, without scheduling a survey
39
- updated_person1 = Delighted::Person.create(:email => "foo+testing1@delightedapp.com",
40
- :name => "James Scott", :send => false)
41
- ```
42
-
43
- ### Unsubscribing people
44
-
45
- ```ruby
46
- # Unsubscribe an existing person
47
- Delighted::Unsubscribe.create(:person_email => "foo+testing1@delightedapp.com")
48
- ```
49
-
50
- ### Deleting pending survey requests
51
-
52
- ```ruby
53
- # Delete all pending (scheduled but unsent) survey requests for a person, by email.
54
- Delighted::SurveyRequest.delete_pending(:person_email => "foo+testing1@delightedapp.com")
55
- ```
56
-
57
- ### Adding survey responses
58
-
59
- ```ruby
60
- # Add a survey response, score only
61
- survey_response1 = Delighted::SurveyResponse.create(:person => person1.id, :score => 10)
62
-
63
- # Add *another* survey response (for the same person), score and comment
64
- survey_response2 = Delighted::SurveyResponse.create(:person => person1.id, :score => 5,
65
- :comment => "Really nice.")
66
- ```
67
-
68
- ### Retrieving a survey response
69
-
70
- ```ruby
71
- # Retrieve an existing survey response
72
- survey_response3 = Delighted::SurveyResponse.retrieve('123')
73
- ```
74
-
75
- ### Updating survey responses
76
-
77
- ```ruby
78
- # Update a survey response score
79
- survey_response4 = Delighted::SurveyResponse.retrieve('234')
80
- survey_response4.score = 10
81
- survey_response4.save #=> #<Delighted::SurveyResponse:...>
82
-
83
- # Update (or add) survey response properties
84
- survey_response4.person_properties = { :segment => "Online" }
85
- survey_response4.save #=> #<Delighted::SurveyResponse:...>
86
-
87
- # Update person who recorded the survey response
88
- survey_response4.person = '321'
89
- survey_response4.save #=> #<Delighted::SurveyResponse:...>
90
- ```
91
-
92
- ### Listing survey responses
93
-
94
- ```ruby
95
- # List all survey responses, 20 per page, first 2 pages
96
- survey_responses_page_1 = Delighted::SurveyResponse.all
97
- survey_responses_page_2 = Delighted::SurveyResponse.all(:page => 2)
98
-
99
- # List all survey responses, 20 per page, expanding person object
100
- survey_responses_page_1_expanded = Delighted::SurveyResponse.all(:expand => ['person'])
101
- survey_responses_page_1_expanded[0].person #=> #<Delighted::Person:...>
102
-
103
- # List all survey responses, 20 per page, for a specific trend (ID: 123)
104
- survey_responses_page_1_trend = Delighted::SurveyResponse.all(:trend => "123")
105
-
106
- # List all survey responses, 20 per page, in reverse chronological order (newest first)
107
- survey_responses_page_1_desc = Delighted::SurveyResponse.all(:order => 'desc')
108
-
109
- # List all survey responses, 100 per page, page 5, with a time range
110
- filtered_survey_responses = Delighted::SurveyResponse.all(:page => 5, :per_page => 100,
111
- :since => Time.utc(2013, 10, 01), :until => Time.utc(2013, 11, 01))
112
- ```
113
-
114
- ### Retrieving metrics
115
-
116
- ```ruby
117
- # Get current metrics, 30-day simple moving average, from most recent response
118
- metrics = Delighted::Metrics.retrieve
119
-
120
- # Get current metrics, 30-day simple moving average, from most recent response, for a specific trend (ID: 123)
121
- metrics = Delighted::Metrics.retrieve(:trend => "123")
122
-
123
- # Get metrics, for given range
124
- metrics = Delighted::Metrics.retrieve(:since => Time.utc(2013, 10, 01),
125
- :until => Time.utc(2013, 11, 01))
126
- ```
127
-
128
- ## <a name="advanced-configuration"></a> Advanced configuration
129
-
130
- The following options are configurable for the client:
131
-
132
- ```ruby
133
- Delighted.api_key
134
- Delighted.api_base_url # default: 'https://api.delightedapp.com/v1'
135
- Delighted.http_adapter # default: Delighted::HTTPAdapter.new
136
- ```
137
-
138
- By default, a shared instance of `Delighted::Client` is created lazily in `Delighted.shared_client`. If you want to create your own client, perhaps for testing or if you have multiple API keys, you can:
139
-
140
- ```ruby
141
- # Create an custom client instance, and pass as last argument to resource actions
142
- client = Delighted::Client.new(:api_key => 'API_KEY',
143
- :api_base_url => 'https://api.delightedapp.com/v1', :http_adapter => Delighted::HTTPAdapter.new)
144
- metrics_from_custom_client = Delighted::Metrics.retrieve({}, client)
145
-
146
- # Or, you can set Delighted.shared_client yourself
147
- Delighted.shared_client = Delighted::Client.new(:api_key => 'API_KEY',
148
- :api_base_url => 'https://api.delightedapp.com/v1', :http_adapter => Delighted::HTTPAdapter.new)
149
- metrics_from_custom_shared_client = Delighted::Metrics.retrieve
150
- ```