promoter 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/lib/promoter/campaign.rb +15 -3
- data/lib/promoter/contact.rb +15 -2
- data/lib/promoter/request.rb +2 -2
- data/lib/promoter/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: 3a1c0b45c8ca3ac0de008c7aad0c01e050a386d1
|
4
|
+
data.tar.gz: a1637b87cd2389bfe042549e6525a86950d5417d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b465beeb2d3020128bb14f7ec8e683033e64cd03b3bbfc192691250cf1de37293f0441307f23d57c745f840878f6beac9ad515ccc9fe831a291e35d07ccbd37b
|
7
|
+
data.tar.gz: f536e0537e28f960cf3f5922da8161af472d383ba211da846575d75f7a01eda1a2a3d37ea893367a77e7baf0a6bb1bc79ca9f0763142e0f7275494b235552f2c
|
data/README.md
CHANGED
@@ -33,6 +33,8 @@ Promoter.api_key = 'YOUR API KEY'
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
Promoter::Feedback.all(score: 8) # => returns all feedback with a score of 8
|
36
|
+
# this is paginated. Pass page: 2 to get the second page
|
37
|
+
# (I know, this is different from the other api calls! This will be fixed in later versions)
|
36
38
|
```
|
37
39
|
|
38
40
|
Possible filters:
|
@@ -52,7 +54,12 @@ Promoter::Feedback.find(79) #=> id of the feedback to return
|
|
52
54
|
### Get all contacts
|
53
55
|
|
54
56
|
```ruby
|
55
|
-
Promoter::Contact.all(2) # => this is paginated - returns page 2 of results
|
57
|
+
Promoter::Contact.all(page: 2) # => this is paginated - returns page 2 of results
|
58
|
+
```
|
59
|
+
|
60
|
+
To find the a contact by an email pass in the ```email``` option:
|
61
|
+
```ruby
|
62
|
+
Promoter::Contact.all(email: "chris@lexoo.co.uk")
|
56
63
|
```
|
57
64
|
|
58
65
|
### Get a specific contact
|
@@ -101,7 +108,7 @@ Promoter::Campaign.create(name: "Campaign Name", # required
|
|
101
108
|
### Get all campaigns
|
102
109
|
|
103
110
|
```ruby
|
104
|
-
Promoter::Campaign.all(2) # => this is paginated - returns page 2 of results
|
111
|
+
Promoter::Campaign.all(page: 2) # => this is paginated - returns page 2 of results
|
105
112
|
```
|
106
113
|
|
107
114
|
### Send surveys for a campaign
|
data/lib/promoter/campaign.rb
CHANGED
@@ -17,8 +17,20 @@ module Promoter
|
|
17
17
|
@launch_date = Time.parse(attrs["launch_date"]) if attrs["launch_date"]
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# Parameter Optional? Description
|
21
|
+
# page yes Returns which page of results to return.
|
22
|
+
# Defaults to 1
|
23
|
+
def self.all(options={})
|
24
|
+
if !options.is_a?(Hash)
|
25
|
+
puts "-- DEPRECATION WARNING--"
|
26
|
+
puts "Passing in a number as a page is deprecated and will be removed from future versions of this gem.\nInstead pass in a hash of attributes.\n\n e.g. Promoter::Campaign.all(page: 2)"
|
27
|
+
query_string = "page=#{options}"
|
28
|
+
else
|
29
|
+
# default to first page
|
30
|
+
options[:page] ||= 1
|
31
|
+
query_string = URI.encode_www_form(options)
|
32
|
+
end
|
33
|
+
response = Request.get("#{API_URL}/?#{query_string}")
|
22
34
|
response['results'].map {|attrs| new(attrs)}
|
23
35
|
end
|
24
36
|
|
@@ -46,4 +58,4 @@ module Promoter
|
|
46
58
|
new(response)
|
47
59
|
end
|
48
60
|
end
|
49
|
-
end
|
61
|
+
end
|
data/lib/promoter/contact.rb
CHANGED
@@ -19,8 +19,21 @@ module Promoter
|
|
19
19
|
Contact.destroy(self.email)
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
# Parameter Optional? Description
|
23
|
+
# page yes Returns which page of results to return.
|
24
|
+
# Defaults to 1
|
25
|
+
# email yes Filter the results by email address.
|
26
|
+
def self.all(options={})
|
27
|
+
if !options.is_a?(Hash)
|
28
|
+
puts "-- DEPRECATION WARNING--"
|
29
|
+
puts "Passing in a number as a page is deprecated and will be removed from future versions of this gem.\nInstead pass in a hash of attributes.\n\n e.g. Promoter::Contact.all(page: 2)"
|
30
|
+
query_string = "page=#{options}"
|
31
|
+
else
|
32
|
+
# default to first page
|
33
|
+
options[:page] ||= 1
|
34
|
+
query_string = URI.encode_www_form(options)
|
35
|
+
end
|
36
|
+
response = Request.get("#{API_URL}/?#{query_string}")
|
24
37
|
response['results'].map {|attrs| new(attrs)}
|
25
38
|
end
|
26
39
|
|
data/lib/promoter/request.rb
CHANGED
@@ -45,8 +45,8 @@ module Promoter
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.auth_header
|
48
|
-
if Promoter.api_key.
|
49
|
-
raise Unauthorized.new("You need to set your promoter api key. You can register for a Promoter API key with a Promoter.io Account.")
|
48
|
+
if Promoter.api_key.nil?
|
49
|
+
raise Errors::Unauthorized.new("You need to set your promoter api key. You can register for a Promoter API key with a Promoter.io Account.")
|
50
50
|
end
|
51
51
|
{ "Authorization" => "Token #{Promoter.api_key}",
|
52
52
|
'Content-Type' => 'application/json' }
|
data/lib/promoter/version.rb
CHANGED
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
|
+
version: 0.1.6
|
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: 2016-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|