promoter 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82b302c42afebc4958d965828131b4bd1ae7e226
4
- data.tar.gz: 390dcdb37ac48a67c7c350ba766522333fc83900
3
+ metadata.gz: 6d190bf6c1fe47dcbc6d1935ca875373b0eba137
4
+ data.tar.gz: b5035d75f42fae29d5b1cab59026716387b583b8
5
5
  SHA512:
6
- metadata.gz: 4cb56545fbffca1530de00a8d1bde82d8ffce90093a4a8dcd9ff0b7b4f2c5077c7046ece2a78fa55ddf1a501ac21ebba1b80fe6e4627da37c8ce8e62bceb28c4
7
- data.tar.gz: 7eb2ef3606aac16577343b596886a4fc4a264bdac31f68e66dc94b60bd459e2c82c6c73a4b1fdc562c19fccb6f754e8c9749ce30b5095a727421b1c379c15022
6
+ metadata.gz: 7781f1f2faee907bdbe95e4d832de883d1cc7bc8f78984311d65295bab5c4ef66bd1039948dd0b98bfbfef8ae08f1676da30c337c0396a6ad7cfc062c07c7322
7
+ data.tar.gz: 541a11ab61ef98afcfc155297e098e0cc83e730cc8521851d3baf2226dc1c1db1b423418aef1c11988ad57b2f2deed5b78e17ace16426f56edf84345fd1e23a9
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  promoter is a wrapper for the promoter.io REST API.
4
4
 
5
- You can find the promoter.io api docs here: https://promoterio.github.io/api/
5
+ You can find the promoter.io api docs here: http://docs.promoter.apiary.io/
6
6
 
7
7
  ## Installation
8
8
 
@@ -73,7 +73,31 @@ Promoter::Contact.create(email: "chris@lexoo.co.uk", # required
73
73
  send: false ) # set this to true to send the NPS immediately
74
74
  ```
75
75
 
76
+ ### Remove a contact
77
+
78
+ ```ruby
79
+ Promoter::Contact.destroy("chris@lexoo.co.uk")
80
+ ```
81
+
82
+ ### Survey a contact
83
+
84
+ ```ruby
85
+ Promoter::Contact.survey(email: "chris@lexoo.co.uk", # required
86
+ first_name: "Chris", # optional
87
+ last_name: "O'Sullivan", # optional
88
+ campaign: 78, # campaign which this belongs to
89
+ attributes: { plan: 'silver' })# any extra data you want to add to the contact
90
+ ```
91
+
76
92
  ## Campaigns
93
+ ### Create a campaign
94
+
95
+ ```ruby
96
+ Promoter::Campaign.create(name: "Campaign Name", # required
97
+ contact_list: 1, # required
98
+ email: 1) # required
99
+ ```
100
+
77
101
  ### Get all campaigns
78
102
 
79
103
  ```ruby
@@ -89,6 +113,12 @@ Promoter::Campaign.send_surveys(33, false)
89
113
  This takes two parameters, the campaign id, and a boolean as to send out surveys to ALL of the customers for the campaign. (This is defaulted to false!)
90
114
 
91
115
  ## Contact lists
116
+ ### Create a contact list
117
+
118
+ ```ruby
119
+ Promoter::ContactList.create(name: "List Name") # required
120
+ ```
121
+
92
122
  ### Get all contact lists
93
123
 
94
124
  ```ruby
@@ -109,6 +139,39 @@ Promoter::ContactList.remove_contact(contact_list_id: 7899,
109
139
  contact_id: 15777)
110
140
  ```
111
141
 
142
+ ### Remove a contact from a contact list by email
143
+
144
+ ```ruby
145
+ Promoter::ContactList.remove_contact(email: "me@me.com",
146
+ contact_id: 15777)
147
+ ```
148
+
149
+ ### Remove a contact from all contact lists
150
+
151
+ ```ruby
152
+ Promoter::ContactList.remove_contact(contact_id: 15777)
153
+ ```
154
+
155
+ ## Email Templates
156
+ ### Create an email template
157
+
158
+ ```ruby
159
+ Promoter::EmailTemplate.create(name: "Campaign Name", # required
160
+ subject: "Email Name", # required
161
+ logo: "<base64EncodedImageData>", # required
162
+ reply_to_email: "me@me.com", # required
163
+ from_name: "Name", # required
164
+ intro_message: "Message", # required
165
+ language: "en", # required
166
+ company_brand_product_name: "name") # required
167
+ ```
168
+
169
+ ### Get all email templates
170
+
171
+ ```ruby
172
+ Promoter::EmailTemplate.all # => returns all results
173
+ ```
174
+
112
175
  ## Metrics
113
176
 
114
177
  ```ruby
@@ -2,6 +2,7 @@ require "promoter/version"
2
2
  require "promoter/errors"
3
3
  require "promoter/request"
4
4
  require "promoter/campaign"
5
+ require "promoter/email_template"
5
6
  require "promoter/contact"
6
7
  require "promoter/contact_list"
7
8
  require "promoter/feedback"
@@ -35,5 +35,15 @@ module Promoter
35
35
  { all_contacts: all_contacts, response_format: :plain })
36
36
  response.match /Success\, surveys sent\./
37
37
  end
38
+
39
+ # Campaign Params
40
+ # Parameter Optional? Description
41
+ # name no The name of the campaign
42
+ # contact_list no The id of the contact list to associate to this campaign. The contact list will contain a list of contacts you will survey.
43
+ # email no The id of the email template you will use to survey your contacts in the contact list.
44
+ def self.create(attributes)
45
+ response = Request.post(API_URL + "/", attributes)
46
+ new(response)
47
+ end
38
48
  end
39
49
  end
@@ -15,6 +15,10 @@ module Promoter
15
15
  @attributes = attrs["attributes"]
16
16
  end
17
17
 
18
+ def destroy
19
+ Contact.destroy(self.email)
20
+ end
21
+
18
22
  def self.all(page=1)
19
23
  response = Request.get("#{API_URL}/?page=#{page}")
20
24
  response['results'].map {|attrs| new(attrs)}
@@ -25,6 +29,14 @@ module Promoter
25
29
  new(response)
26
30
  end
27
31
 
32
+ def self.destroy(email)
33
+ attributes = {
34
+ email: email
35
+ }
36
+ response = Request.post("#{API_URL}/remove/", attributes)
37
+ new(response)
38
+ end
39
+
28
40
  # Contact Params
29
41
  # Parameter Optional? Description
30
42
  # email no The email of the contact to add to the organization.
@@ -49,5 +61,10 @@ module Promoter
49
61
  new(response)
50
62
  end
51
63
 
64
+ def self.survey(attributes)
65
+ response = Request.post(API_URL + "/survey/", attributes)
66
+ new(response)
67
+ end
68
+
52
69
  end
53
70
  end
@@ -24,7 +24,29 @@ module Promoter
24
24
  def self.remove_contact(params={})
25
25
  contact_list_id = params[:contact_list_id]
26
26
  contact_id = params[:contact_id]
27
- Request.delete("#{API_URL}/#{contact_list_id}/contacts/#{contact_id}")
27
+ contact_email = params[:email]
28
+
29
+ if contact_list_id
30
+ if contact_id
31
+ Request.delete("#{API_URL}/#{contact_list_id}/contacts/#{contact_id}")
32
+ elsif contact_email
33
+ Request.post("#{API_URL}/#{contact_list_id}/remove/", {email: contact_email})
34
+ else
35
+ raise "Not enough information provided to remove a contact"
36
+ end
37
+ elsif contact_email
38
+ Request.post("#{API_URL}/remove/", {email: contact_email})
39
+ else
40
+ raise "Not enough information provided to remove a contact"
41
+ end
42
+ end
43
+
44
+ # Campaign Params
45
+ # Parameter Optional? Description
46
+ # name no The name of the campaign
47
+ def self.create(attributes)
48
+ response = Request.post(API_URL + "/", attributes)
49
+ new(response)
28
50
  end
29
51
 
30
52
  end
@@ -0,0 +1,47 @@
1
+ module Promoter
2
+
3
+ class EmailTemplate
4
+
5
+ API_URL = "https://app.promoter.io/api/email"
6
+
7
+ attr_reader :id, :name, :logo, :subject, :reply_to_email, :from_name,
8
+ :intro_message, :language, :company_brand_product_name
9
+
10
+ def initialize(attrs)
11
+ @id = attrs["id"]
12
+ @name = attrs["name"]
13
+ @logo = attrs["logo"]
14
+ @subject = attrs["subject"]
15
+ @reply_to_email = attrs["reply_to_email"]
16
+ @from_name = attrs["from_name"]
17
+ @intro_message = attrs["intro_message"]
18
+ @language = attrs["language"]
19
+ @company_brand_product_name = attrs["company_brand_product_name"]
20
+ end
21
+
22
+ def self.all(page=1)
23
+ response = Request.get("#{API_URL}/?page=#{page}")
24
+ response['results'].map {|attrs| new(attrs)}
25
+ end
26
+
27
+ # Email Template Params
28
+ # Parameter Optional? Description
29
+ # name no The name of the email template
30
+ # subject no The subject line of the email template
31
+ # logo no Base64 encoded image data (only) representing
32
+ # the logo with your survey. It is also the logo
33
+ # they see when they respond to the survey with a score.
34
+ # The logo will be located at the top of the survey
35
+ # reply_to_email no The reply-to email address for the email template
36
+ # from_name no The name the template is showing to be from
37
+ # intro_message no This is the message that appears just above
38
+ # the 0-10 scale and below the logo
39
+ # language no The language the template is in
40
+ # company_brand_product_name no The name inserted into the main question
41
+ def self.create(attributes)
42
+ response = Request.post(API_URL + "/", attributes)
43
+ new(response)
44
+ end
45
+
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module Promoter
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promoter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris O'Sullivan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2016-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,6 +112,7 @@ files:
112
112
  - lib/promoter/campaign.rb
113
113
  - lib/promoter/contact.rb
114
114
  - lib/promoter/contact_list.rb
115
+ - lib/promoter/email_template.rb
115
116
  - lib/promoter/errors.rb
116
117
  - lib/promoter/feedback.rb
117
118
  - lib/promoter/metric.rb
@@ -138,8 +139,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.4.8
142
+ rubygems_version: 2.5.1
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: promoter is a wrapper for the promoter.io REST API
145
146
  test_files: []
147
+ has_rdoc: