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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d190bf6c1fe47dcbc6d1935ca875373b0eba137
4
- data.tar.gz: b5035d75f42fae29d5b1cab59026716387b583b8
3
+ metadata.gz: 3a1c0b45c8ca3ac0de008c7aad0c01e050a386d1
4
+ data.tar.gz: a1637b87cd2389bfe042549e6525a86950d5417d
5
5
  SHA512:
6
- metadata.gz: 7781f1f2faee907bdbe95e4d832de883d1cc7bc8f78984311d65295bab5c4ef66bd1039948dd0b98bfbfef8ae08f1676da30c337c0396a6ad7cfc062c07c7322
7
- data.tar.gz: 541a11ab61ef98afcfc155297e098e0cc83e730cc8521851d3baf2226dc1c1db1b423418aef1c11988ad57b2f2deed5b78e17ace16426f56edf84345fd1e23a9
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
@@ -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
- def self.all(page=1)
21
- response = Request.get("#{API_URL}/?page=#{page}")
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
@@ -19,8 +19,21 @@ module Promoter
19
19
  Contact.destroy(self.email)
20
20
  end
21
21
 
22
- def self.all(page=1)
23
- response = Request.get("#{API_URL}/?page=#{page}")
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
 
@@ -45,8 +45,8 @@ module Promoter
45
45
  end
46
46
 
47
47
  def self.auth_header
48
- if Promoter.api_key.empty?
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' }
@@ -1,3 +1,3 @@
1
1
  module Promoter
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
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.5
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-02-20 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler